Skip to main content

Virtual Liquidity Pools

Query Messages

note

We will only go through the queries for this contract, as users are not allowed to execute any messages on the VLP contract. You can read about the VLP architecture here

List of queries that can be performed on the VLP contract.

State

Queries the state of the VLP contract.

pub enum QueryMsg {
   #[returns(GetStateResponse)]
    State {},
}
{"state":{}}

The query returns the following response:

pub struct GetStateResponse {
pub pair: Pair,
pub router: String,
pub vcoin: String,
pub fee: Fee,
pub last_updated: u64,
pub total_lp_tokens: Uint128,
pub admin: String,
}
FieldTypeDescription
pairPairThe token pair of the VLP.
routerStringThe address of the router contract.
vcoinStringThe address of the Virtual balance contract.
feeFeeThe fee structure for the transactions.
last_updatedu64The timestamp of the last update to the state.
total_lp_tokensUint128The total amount of liquidity pool tokens.
adminStringThe address of the admin of the contract.

SimulateSwap

Simulates a swap for the specified asset in the VLP.

pub enum QueryMsg {
    #[returns(GetSwapResponse)]
    SimulateSwap {
        asset: Token,
        asset_amount: Uint128,
        swaps: Vec<NextSwapVlp>,
    },
}
{
  "simulate_swap": {
    "asset": {
      "id": "token-id"
    },
    "asset_amount": "1000000",
    "swaps": [
      {
        "vlp_address": "nibi1..."
      },
      {
        "vlp_address": "nibi1..."
      }
    ]
  }
}
NameTypeDescription
assetTokenThe asset being swapped.
asset_amountUint128The amount of the asset being swapped.
swapsVec<NextSwapVlp>A vector of VLP addresses that will be used for the swap.
pub struct NextSwapVlp {
pub vlp_address: String,
}

The query returns the following response:

#[cw_serde]
pub struct GetSwapResponse {
pub amount_out: Uint128,
pub asset_out: Token,
}
NameTypeDescription
amount_outUint128The amount of asset_out that will be released.
asset_outTokenThe token Id of the asset going out of the VLP.

Liquidity

Queries the total liquidity reserves for the token pair in the VLP.

pub enum QueryMsg {
#[returns(GetLiquidityResponse)]
    Liquidity { height: Option<u64> },
}
{
  "liquidity": {
    "height": 324673284
  }
}
NameTypeDescription
heightOption<u64>Optional block height to query liquidity at a specific block.

The query returns the following response:

pub struct GetLiquidityResponse {
pub pair: Pair,
pub token_1_reserve: Uint128,
pub token_2_reserve: Uint128,
pub total_lp_tokens: Uint128,
}

NameTypeDescription
pairPairThe token pair involved in the liquidity. The token Id for each token is returned.
token_1_reserveUint128The reserve amount of the first token.
token_2_reserveUint128The reserve amount of the second token.
total_lp_tokensUint128The total amount of liquidity pool tokens. These tokens are given to a user whenever they add liquidity to a pool and can be returned to the VLP to withdraw the added liquidity later on.

Fee

Queries the distribution structure for any applied fees on the VLP.

pub enum QueryMsg {
  #[returns(FeeResponse)]
    Fee {},
}
{"fee":{}}

The query returns the following response:

#[cw_serde]
pub struct FeeResponse {
pub fee: Fee,
}

With the following Fee struct:

pub struct Fee {
pub lp_fee_bps: u64,
pub euclid_fee_bps: u64,
pub recipient: CrossChainUser,
}

NameTypeDescription
lp_fee_bpsu64Fee for liquidity providers, in basis points. Can be set to a maximum of 10%.
euclid_fee_bpsu64Fee for Euclid treasury, distributed among stakers and other Euclid-related rewards, in basis points e. 1 = 0.01% 10000 = 100%. Can be set to a maximum of 10%.
recipientCrossChainUserThe recipient for the fee. Can be an address on any chain.

Pool

Queries the pool information for the VLP pair on the specified chain.

pub enum QueryMsg {
   #[returns(PoolResponse)]
    Pool { chain_uid: ChainUid },
}
{
  "pool": {
    "chain_uid": "chainA"
  }
}
NameTypeDescription
chain_uidChainUidThe unique ID of the chain to retrieve the pool information from for the pair.

The query returns the following response:

#[cw_serde]
pub struct PoolResponse {
pub lp_shares: Uint128,
pub reserve_1: Uint128,
pub reserve_2: Uint128,
}
NameTypeDescription
lp_sharesUint128The total amount of liquidity pool shares.
reserve_1Uint128The total reserve amount of the first token.
reserve_2Uint128The total reserve amount of the second token.

GetAllPools

Queries all the pools for the token pair of the VLP on all chains.

pub enum QueryMsg {
      #[returns(AllPoolsResponse)]
    GetAllPools {},
}
{"get_all_pools":{}}

The query returns the following response:

pub struct AllPoolsResponse {
/// A vector containing information on the pool for each chain it is found on.
pub pools: Vec<PoolInfo>,
}

pub struct PoolInfo {
pub chain_uid: ChainUid,
pub pool: PoolResponse,
}
NameTypeDescription
chain_uidChainUidThe unique Id of the chain where the pool is deployed.
poolPoolResponseThe information on the pool. Same as the struct returned by the Pool query.

TotalFeesCollected

Queries the total amount of fees collected by the VLP.

pub enum QueryMsg {
   #[returns(TotalFeesResponse)]
    TotalFeesCollected {},
}
{
  "total_fees_collected": {}
}

The query returns the following response:

pub struct TotalFeesResponse {
pub total_fees: TotalFees,
}

pub struct TotalFees {
// Fee for lp providers
pub lp_fees: DenomFees,
// Fee for euclid treasury, distributed among stakers and other euclid related rewards
pub euclid_fees: DenomFees,
}

pub struct DenomFees {
// A map to store the total fees per denomination
pub totals: HashMap<String, Uint128>,
}
FieldTypeDescription
lp_feesDenomFeesThe total fees allocated to liquidity providers (LPs).
euclid_feesDenomFeesFee for euclid treasury, distributed among stakers and other euclid related rewards

TotalFeesPerDenom

Queries the total amount of fees collected by the VLP for the specified denom of funds.

pub enum QueryMsg {
    #[returns(TotalFeesPerDenomResponse)]
    TotalFeesPerDenom { denom: String },
}
{
  "total_fees_per_denom": {
    "denom":"nibiru"
  }
}
FieldTypeDescription
denomStringThe denom of the fees to get the total for.

The query returns the following response:

pub struct TotalFeesPerDenomResponse {
pub lp_fees: Uint128,
pub euclid_fees: Uint128,
}
FieldTypeDescription
lp_feesUint128The total fees allocated to liquidity providers (LPs).
euclid_feesUint128Fee for euclid treasury, distributed among stakers and other euclid related rewards