Skip to main content

DEX state

This document provides an overview of the metadata query function within the DEX state contract.

metadata (query)

The metadata query function returns information, such as the Veax owner, number of existing pools, protocol fee fraction, fee rates, and fee divisor. No prerequisites or errors are associated with this function. The document provides an example command for viewing the metadata of a specific Dex contract, along with the expected output format.

Arguments

None

Returns

ContractMetadata {
owner: AccountId,
pool_count: u64,
protocol_fee_fraction: u16,
fee_rates: [u16; 8],
fee_divisor: u16,
}

Where:

  • ContractMetadata.owner: Veax owner. Near account that is allowed to call administration functions. This must be the account hosting the governance contract.
  • ContractMetadata.pool_count: a number of existing pools.
  • ContractMetadata.protocol_fee_fraction: a fraction of the fee which goes to DEX in Basis Points.
  • ContractMetadata.fee_rates: an array of fee rates per fee level, in Basis Points.
  • ContractMetadata.fee_divisor: by how much a quantity expressed in Basis Points need to be divided to get the absolute value.

Prerequisites

None

Errors

None

Example

$ near view veax.test.near metadata
View call: veax.test.near.metadata()
Loaded master account test.near key from /home/user/.neartosis/validator-key.json with public key = ed25519:3Kuyi2DUXdoHgoaNEvCxa1m6G8xqc6Xs7WGajaqLhNmW
{
owner: 'veax-governance.sputnik-factory.test.near',
pool_count: 7,
protocol_fee_fraction: 1300,
fee_rates: [
1, 2, 4, 8,
16, 32, 64, 128
],
fee_divisor: 10000
}

get_pool_info (query)

Returns summary information about a specific pool.

Arguments

  • tokens: Pair<TokenId>: Token pair identifying the pool.

Returns:

PoolInfo {
total_reserves: (U128, U128),
position_reserves: (U128, U128),
sqrt_spot_prices: [f64; 8]
sqrt_effective_prices: [(f64, f64); 8],
liquidities: [U128; 8],
fee_rates: [BasisPoints; 8],
fee_divisor: BasisPoints,
}

Where:

  • PoolInfo.total_reserves: Total amounts of tokens in the pool: sum of all positions and collected fees (LP and protocol).
  • PoolInfo.position_reserves: Total amount of tokens locked in positions.
  • PoolInfo.sqrt_spot_prices: Square root of the spot price on each of the fee levels. Zero means the pool is empty, so the price is undefined.
  • PoolInfo.sqrt_effective_prices: Square root of the effective price on each of the fee levels, for the forward and reverse swap directions, respectively. Zero means the pool is empty, so the price is undefined.
  • PoolInfo.liquidities: Liquidity on each of the fee levels.
  • PoolInfo.fee_rates: Fee rate scaled up by fee_divisor.
  • PoolInfo.fee_divisor: Scale factor for the fee levels.

Prerequisites

Pool exists

Errors

  • PoolNotRegistered: corresponding pool does not exist

Example