Cover image for #22 | Nibiru Tech Developments (Aug 2023)

#22 | Nibiru Tech Developments (Aug 2023)

· 3 min read

Historical context: This post describes early Sai work as of 2023-08-24. Product details and launch plans reflect that period. See the Sai documentation for current trading and integration guides.

An update on key tech advancements for Nibiru over the past months, including upgrades to the core Nibiru node, SDKs, smart contracts, and indexing infrastructure.

Tech Developments - Table of Contents

Developer Royalties Based on Gas Usage

  • Date: August 15, 2023

  • Implementation: Nibiru PR #1543

  • Summary:

    Adds a built-in revenue mote for developers on Nibiru by splitting gas fees spent on smart contract executions with the developers of the contracts being invoked.

To understand this, imagine if Uniswap Labs received half of the ETH gas spent on the Uniswap Protocol. This is analogous to how YouTube shares ad revenue on videos with their creators, just translated into a smart contract context. This feature should help facilitate further developer adoption by inherently providing incentive alignment in a decentralized manner.

Nibiru v0.21

The newest version of the chain with feature upgrades and fixes from the audit remediation is currently running. This will be the chain used for the trading competition and last phase of NIT.

Switching from LevelDB → Facebook’s RocksDB

  • Date: July, 2023
  • Summary: Node performance running the Nibiru binary (nibid) improved by 20x because we switched out the database solution for the chain from the Cosmos-SDK’s default GoLevelDB to Facebook’s RocksDB. RocksDB is designed for high performance in larger datasets and multi-core machines, employs compaction strategies and bloom filters to increase read and write speeds and handles data in a tiered structure for more efficiency. RocksDB also has multi-threading for parallel read/writes, providing significant speedups.
  • Heart Monitor V2: We upgraded the indexer to and liquidation stack to read the underlying RocksDB state directly rather than requiring tons of queries against a node. The Heart-Monitor was also moved from Python into Golang to leverage routines and the testing utilities we use for the chain itself.

Added Ledger Hard-Wallet Support for Nibiru

Migration → Cosmos-SDK v0.47

  • Date: Jul, 2023
  • Implementation: Nibiru PR #1407
  • Summary: We’re one of the first chains to move from versions v0.45-46 to the newer v0.47+, which improves the performance of several core modules related to staking and consensus, has native support for NFTs, supports parallelism at the consensus level, and enables new IBC functionality.

Sai: Liquidation UX Improvements, Partial Close

  • Date: Date: Jul, 2023
  • Summary: The perpetual futures platform now includes features such as partial closes (lessen exposure without changing )and auto-executing liquidations for when users send transactions to close or remove margin with an underwater position. Here, “Auto-executing” means that if a trader interacts with the position in any manner that increases risk while the position is underwater, you automatically act as the liquidator on your own position, preventing losses and making trading a bit safer through the partial or full liquidation.

Audits

  • Date: Jun-Jul, 2023
  • Zellic: Our perpetual exchange, oracle module, and several CosmWasm smart contracts underwent a thorough audit.
  • Salus Security: Conducted a penetration testing review on our cloud infrastructure, web app, and security practices.

Wasm bindings for Custom Nibiru Modules

  • Date: May, 2023

  • Summary

    Enables smart contracts to send transaction messages from custom modules, facilitating the usage of stateful oracle data on Nibiru and over IBC, and enabling the development of dapps that manage trading positions with a contract as the trader (e.g. delta-neutral or other yield vaults).

  • Implementation: x/wasm module of Nibiru

Depth Shift and Peg Shift

  • Date: Apr-May, 2023
  • Summary: Helps adapt Sai slippage on trades according to open notional and volume while reconciling issues related to separation of the terminal and index prices. Described in the Sai technical paper in the data room.
  • Implementation: Combination of x/perp, x/wasm, and contracts in the cw-nibiru repo.

Locks and Incentives Smart Contracts

  • Date: Apr 16, 2023
  • Summary: We implemented and tested smart contracts for locking LP tokens and applying external incentives with a configurable release schedule for these locked positions. See for the implementation.
  • Implementation: See lockup and incentives in the contracts directory of NibiruChain/cw-nibiru.

Oracle Module

  • Date: Mar, 2023
  • Summary: We completed the Oracle Module and price feeder binary, having 120 validators use it live on testnet. This helped

Validator nodes act as oracles by voting on the exchange rates between pairs of crypto asseould tally up all the votes and create a ballot for each exchange rate. To disincentive bad actors, oracles are rewarded for posting “good prices” and slashed for posting “bad prices.” The weighted median of the ballot becomes the on-chain exchange rate.

Heart Monitor V1: Indexing Solution on Tendermint Consensus

  • Date: Mar, 2023

Indexers solve this problem by creating a searchable index of blockchain data that can be easily queried and analyzed, allowing DeFi projects to track user behavior, monitor network activity, and make data-driven decisions. Nibiru developed an indexing service called the Heart Monitor that:

  1. Listens to blockchain events, messages, and transactions
  2. Stores data into a structured database tables for easier representation and reporting,
  3. Enables us to leverage custom alerts with Grafana.
  4. Supplies complex data to the web application with high performance and scalability.
  5. Facilitates the creation of public APIs for data science and analytics.

The Heart Monitor works by continuously scanning the blockchain for new data and indexing it in a searchable format, allowing us to track the performance of the protocol in real-time.

Collections API

  • Date: Jan, 2023
  • Summary: Our “Collections” storage library significantly improved state management in the Cosmos-SDK. The collections library is an extension to the base storage functionality that mimics that of CosmWasm smart contracts, making it easy to work with complex datatypes in an efficient way while reducing boilerplate and code complexity.
  • Implementation: NibiruChain/collections

Several key builders on Cosmos fell in love with it, and the tool’s been officially up-streamed into the Cosmos-SDK as of ADR 062. All IBC chains supporting ABCI++ (SDK v0.47 or higher) can now utilize it by default via the cosmossdk.io/collections import.

Nibiru v0.19

  • Date: Feb, 2023
  • Summary: Version of Nibi-Swap, an centralized oracle solution that preceded the decentralized module, and Sai that is put under load with the incentivized testnet.

Throughput Improvements on Tendermint Core.

  • Summary: Nibiru’s binary has a custom initialization that overwrites these settings to a more optimal configuration, making validator nodes have smaller timeouts between actions in the consensus process without causing network instability, jailing, or slashing.

Multi Liquidate

  • Summary: Liquidations on most protocols occur as 1 liquidation per TxMsg

    We upgraded the Nibiru’s default liquidate transaction to accept a batch of liquidation targets in one TxMsg instead. This is a called a MultiLiquidate message. If 20 market-trader pairs are sent in one MultiLiquidate, and 13 of them should fail due to the position being healthy or nonexistent, the 7 valid targets will still go through successfully and trigger liquidations in the transaction. This helps the perps application on the network scale to support high volumes of liquidations without causing transactions to revert.

  • Ref: Nibiru Docs: Messages (TxMsgs)

Nibiru TypeScript SDK (NibiJS)

Nibiru Python SDK

🔮 Docs | 👾 Discord | 🐦 Twitter | 🔥 Web App 🌴 Link Tree | 👨‍💻 Code | 🎥 YouTube