# proto - spot

# Table of Contents

Top

# nibiru/spot/v1/event.proto

# EventAssetsSwapped

Field Type Label Description
address string the address of the user who swapped tokens
token_in cosmos.base.v1beta1.Coin the amount of tokens that the user deposited
token_out cosmos.base.v1beta1.Coin the amount of tokens that the user received
fee cosmos.base.v1beta1.Coin the amount of fees collected by the pool
final_pool Pool the final state of the pool

# EventPoolCreated

Field Type Label Description
creator string the address of the user who created the pool
fees cosmos.base.v1beta1.Coin repeated the create pool fee
final_pool Pool the final state of the pool
final_user_pool_shares cosmos.base.v1beta1.Coin the amount of pool shares that the user received

# EventPoolExited

Field Type Label Description
address string the address of the user who exited the pool
pool_shares_in cosmos.base.v1beta1.Coin the amount of pool shares that the user exited with
tokens_out cosmos.base.v1beta1.Coin repeated the amount of tokens returned to the user
fees cosmos.base.v1beta1.Coin repeated the amount of fees collected by the pool
final_pool Pool the final state of the pool
final_user_pool_shares cosmos.base.v1beta1.Coin the final amount of user pool shares

# EventPoolJoined

Field Type Label Description
address string the address of the user who joined the pool
tokens_in cosmos.base.v1beta1.Coin repeated the amount of tokens that the user deposited
pool_shares_out cosmos.base.v1beta1.Coin the amount of pool shares that the user received
rem_coins cosmos.base.v1beta1.Coin repeated the amount of tokens remaining for the user
final_pool Pool the final state of the pool
final_user_pool_shares cosmos.base.v1beta1.Coin the final amount of user pool shares

Top

# nibiru/spot/v1/genesis.proto

# GenesisState

GenesisState defines the spot module's genesis state.

Field Type Label Description
params Params params defines all the parameters of the module.
pools Pool repeated pools defines all the pools of the module.

Top

# nibiru/spot/v1/params.proto

# Params

Params defines the parameters for the module.

Field Type Label Description
starting_pool_number uint64 The start pool number, i.e. the first pool number that isn't taken yet.
pool_creation_fee cosmos.base.v1beta1.Coin repeated The cost of creating a pool, taken from the pool creator's account.
whitelisted_asset string repeated The assets that can be used to create liquidity pools

Top

# nibiru/spot/v1/pool.proto

# Pool

Field Type Label Description
id uint64 The pool id.
address string The pool account address.
pool_params PoolParams Fees and other pool-specific parameters.
pool_assets PoolAsset repeated These are assumed to be sorted by denomiation. They contain the pool asset and the information about the weight
total_weight string sum of all non-normalized pool weights
total_shares cosmos.base.v1beta1.Coin sum of all LP tokens sent out

# PoolAsset

Which assets the pool contains.

Field Type Label Description
token cosmos.base.v1beta1.Coin Coins we are talking about, the denomination must be unique amongst all PoolAssets for this pool.
weight string Weight that is not normalized. This weight must be less than 2^50

# PoolParams

Configuration parameters for the pool.

Field Type Label Description
swap_fee string
exit_fee string
A string Amplification Parameter (A): Larger value of A make the curve better resemble a straight line in the center (when pool is near balance). Highly volatile assets should use a lower value, while assets that are closer together may be best with a higher value. This is only used if the pool_type is set to 1 (stableswap)
pool_type PoolType

# PoolType

  • balancer: Balancer are pools defined by the equation xy=k, extended by the weighs introduced by Balancer.
  • stableswap: Stableswap pools are defined by a combination of constant-product and constant-sum pool
Name Number Description
BALANCER 0
STABLESWAP 1

Top

# nibiru/spot/v1/query.proto

# QueryExitExactAmountInRequest

Field Type Label Description
pool_id uint64
pool_shares_in string amount of pool shares to return to pool

# QueryExitExactAmountInResponse

Field Type Label Description
tokens_out cosmos.base.v1beta1.Coin repeated coins obtained after exiting
fees cosmos.base.v1beta1.Coin repeated

# QueryExitExactAmountOutRequest

Field Type Label Description
pool_id uint64

# QueryExitExactAmountOutResponse

# QueryJoinExactAmountInRequest

Field Type Label Description
pool_id uint64
tokens_in cosmos.base.v1beta1.Coin repeated

# QueryJoinExactAmountInResponse

Field Type Label Description
pool_shares_out string amount of pool shares returned to user after join
rem_coins cosmos.base.v1beta1.Coin repeated coins remaining after pool join

# QueryJoinExactAmountOutRequest

Field Type Label Description
pool_id uint64

# QueryJoinExactAmountOutResponse

# QueryNumPoolsRequest

# QueryNumPoolsResponse

Field Type Label Description
num_pools uint64

# QueryParamsRequest

QueryParamsRequest is request type for the Query/Params RPC method.

# QueryParamsResponse

QueryParamsResponse is response type for the Query/Params RPC method.

Field Type Label Description
params Params params holds all the parameters of this module.

# QueryPoolNumberRequest

# QueryPoolNumberResponse

Field Type Label Description
pool_id uint64

# QueryPoolParamsRequest

Field Type Label Description
pool_id uint64

# QueryPoolParamsResponse

Field Type Label Description
pool_params PoolParams

# QueryPoolRequest

Field Type Label Description
pool_id uint64

# QueryPoolResponse

Field Type Label Description
pool Pool

# QueryPoolsRequest

Field Type Label Description
pagination cosmos.base.query.v1beta1.PageRequest pagination defines an optional pagination for the request.

# QueryPoolsResponse

Field Type Label Description
pools Pool repeated
pagination cosmos.base.query.v1beta1.PageResponse pagination defines the pagination in the response.

# QuerySpotPriceRequest

Returns the amount of tokenInDenom to produce 1 tokenOutDenom For example, if the price of NIBI = 9.123 NUSD, then setting tokenInDenom=NUSD and tokenOutDenom=NIBI would give "9.123".

Field Type Label Description
pool_id uint64
token_in_denom string the denomination of the token you are giving into the pool
token_out_denom string the denomination of the token you are taking out of the pool

# QuerySpotPriceResponse

Field Type Label Description
spot_price string

# QuerySwapExactAmountInRequest

Given an exact amount of tokens in and a target tokenOutDenom, calculates the expected amount of tokens out received from a swap.

Field Type Label Description
pool_id uint64
token_in cosmos.base.v1beta1.Coin
token_out_denom string

# QuerySwapExactAmountInResponse

Field Type Label Description
token_out cosmos.base.v1beta1.Coin
fee cosmos.base.v1beta1.Coin

# QuerySwapExactAmountOutRequest

Given an exact amount of tokens out and a target tokenInDenom, calculates the expected amount of tokens in required to do the swap.

Field Type Label Description
pool_id uint64
token_out cosmos.base.v1beta1.Coin
token_in_denom string

# QuerySwapExactAmountOutResponse

Field Type Label Description
token_in cosmos.base.v1beta1.Coin

# QueryTotalLiquidityRequest


Query total liquidity the protocol

# QueryTotalLiquidityResponse

Field Type Label Description
liquidity cosmos.base.v1beta1.Coin repeated

# QueryTotalPoolLiquidityRequest


Query total liquidity for a pool

Field Type Label Description
pool_id uint64

# QueryTotalPoolLiquidityResponse

Field Type Label Description
liquidity cosmos.base.v1beta1.Coin repeated

# QueryTotalSharesRequest

Field Type Label Description
pool_id uint64

# QueryTotalSharesResponse

Field Type Label Description
total_shares cosmos.base.v1beta1.Coin sum of all LP tokens sent out

# Query

Query defines the gRPC querier service.

Method Name Request Type Response Type Description
Params QueryParamsRequest QueryParamsResponse Parameters of the spot module.
PoolNumber QueryPoolNumberRequest QueryPoolNumberResponse Next available pool id number.
Pool QueryPoolRequest QueryPoolResponse Fetch a pool by id.
Pools QueryPoolsRequest QueryPoolsResponse Returns all pools.
PoolParams QueryPoolParamsRequest QueryPoolParamsResponse Parameters of a single pool.
NumPools QueryNumPoolsRequest QueryNumPoolsResponse Number of pools.
TotalLiquidity QueryTotalLiquidityRequest QueryTotalLiquidityResponse Total liquidity across all pools.
TotalPoolLiquidity QueryTotalPoolLiquidityRequest QueryTotalPoolLiquidityResponse Total liquidity in a single pool.
TotalShares QueryTotalSharesRequest QueryTotalSharesResponse Total shares in a single pool.
SpotPrice QuerySpotPriceRequest QuerySpotPriceResponse Instantaneous price of an asset in a pool.
EstimateSwapExactAmountIn QuerySwapExactAmountInRequest QuerySwapExactAmountInResponse Estimates the amount of assets returned given an exact amount of tokens to swap.
EstimateSwapExactAmountOut QuerySwapExactAmountOutRequest QuerySwapExactAmountOutResponse Estimates the amount of tokens required to return the exact amount of assets requested.
EstimateJoinExactAmountIn QueryJoinExactAmountInRequest QueryJoinExactAmountInResponse Estimates the amount of pool shares returned given an amount of tokens to join.
EstimateJoinExactAmountOut QueryJoinExactAmountOutRequest QueryJoinExactAmountOutResponse Estimates the amount of tokens required to obtain an exact amount of pool shares.
EstimateExitExactAmountIn QueryExitExactAmountInRequest QueryExitExactAmountInResponse Estimates the amount of tokens returned to the user given an exact amount of pool shares.
EstimateExitExactAmountOut QueryExitExactAmountOutRequest QueryExitExactAmountOutResponse Estimates the amount of pool shares required to extract an exact amount of tokens from the pool.

Top

# nibiru/spot/v1/tx.proto

# MsgCreatePool

Field Type Label Description
creator string
pool_params PoolParams
pool_assets PoolAsset repeated

# MsgCreatePoolResponse

Field Type Label Description
pool_id uint64

# MsgExitPool

Field Type Label Description
sender string
pool_id uint64
pool_shares cosmos.base.v1beta1.Coin

# MsgExitPoolResponse

Field Type Label Description
tokens_out cosmos.base.v1beta1.Coin repeated

# MsgJoinPool

Message to join a pool (identified by poolId) with a set of tokens to deposit.

Field Type Label Description
sender string
pool_id uint64
tokens_in cosmos.base.v1beta1.Coin repeated
use_all_coins bool

# MsgJoinPoolResponse

Response when a user joins a pool.

Field Type Label Description
pool Pool the final state of the pool after a join
num_pool_shares_out cosmos.base.v1beta1.Coin sum of LP tokens minted from the join
remaining_coins cosmos.base.v1beta1.Coin repeated remaining tokens from attempting to join the pool

# MsgSwapAssets

Field Type Label Description
sender string
pool_id uint64
token_in cosmos.base.v1beta1.Coin
token_out_denom string

# MsgSwapAssetsResponse

Field Type Label Description
token_out cosmos.base.v1beta1.Coin

# Msg

Msg defines the Msg service.

Method Name Request Type Response Type Description
CreatePool MsgCreatePool MsgCreatePoolResponse Used to create a pool.
JoinPool MsgJoinPool MsgJoinPoolResponse Join a pool as a liquidity provider.
ExitPool MsgExitPool MsgExitPoolResponse Exit a pool position by returning LP shares
SwapAssets MsgSwapAssets MsgSwapAssetsResponse Swap assets in a pool

# Scalar Value Types

.proto Type Notes C++ Java Python Go C# PHP Ruby
double double double float float64 double float Float
float float float float float32 float float Float
int32 Uses variable-length encoding. Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint32 instead. int32 int int int32 int integer Bignum or Fixnum (as required)
int64 Uses variable-length encoding. Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint64 instead. int64 long int/long int64 long integer/string Bignum
uint32 Uses variable-length encoding. uint32 int int/long uint32 uint integer Bignum or Fixnum (as required)
uint64 Uses variable-length encoding. uint64 long int/long uint64 ulong integer/string Bignum or Fixnum (as required)
sint32 Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int32s. int32 int int int32 int integer Bignum or Fixnum (as required)
sint64 Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int64s. int64 long int/long int64 long integer/string Bignum
fixed32 Always four bytes. More efficient than uint32 if values are often greater than 2^28. uint32 int int uint32 uint integer Bignum or Fixnum (as required)
fixed64 Always eight bytes. More efficient than uint64 if values are often greater than 2^56. uint64 long int/long uint64 ulong integer/string Bignum
sfixed32 Always four bytes. int32 int int int32 int integer Bignum or Fixnum (as required)
sfixed64 Always eight bytes. int64 long int/long int64 long integer/string Bignum
bool bool boolean boolean bool bool boolean TrueClass/FalseClass
string A string must always contain UTF-8 encoded or 7-bit ASCII text. string String str/unicode string string string String (UTF-8)
bytes May contain any arbitrary sequence of bytes. string ByteString str []byte ByteString string String (ASCII-8BIT)