Skip to content

CrocQuery Contract

The CrocQuery contract provides a set of view functions for querying various aspects of the DEX contract, including pool parameters, liquidity curves, user LP positions, and user surplus collateral positions.

The contract is deployed at

bArtio Testnet: 0x31DAc06019D983f79cEAc819fAAC0612518597D7

Pool Price Functions

The below functions are used to query a pool's instantenous price and prick tick respectively.

queryPrice:

queryPrice returns the current price of the pool as a Q64.64 fixed point representation of the square-root of the current base to quote exchange rate.

solidity
function queryPrice (
    address base,
    address quote,
    uint256 poolIdx
) public view returns (uint128)

Parameters

ParameterTypeDescription
baseaddressThe address of the base-side token in the pool's pair (always the smaller address)
quoteaddressThe address of the quote-side token in the pool's pair
poolIdxuint256The pool type index

queryCurveTick

Returns the current price tick of the pool, defined as the floor of the base 1.0001 logarithm of the pool price.

solidity
function queryCurveTick (
    address base,
    address quote,
    uint256 poolIdx
) public view returns (int24)

Parameters;

ParameterTypeDescription
baseaddressThe address of the base-side token in the pool's pair (always the smaller address)
quoteaddressThe address of the quote-side token in the pool's pair
poolIdxuint256The pool type index

Pool Liquidity

The queryLiquidity function returns the liquidity in a pool at its current tick, represented as the square-root of the product of the base and quote virtual liquidity in the pool. This can be used to estimate a price impact for small swaps.

solidity
function queryLiquidity (
    address base,
    address quote,
    uint256 poolIdx
) public view returns (uint128)

Parameters

ParameterTypeDescription
baseaddressThe address of the base-side token in the pool's pair (always the smaller address)
quoteaddressThe address of the quote-side token in the pool's pair
poolIdxuint256The pool type index

Liquidity Positions

The queryAmbientTokens function returns information associated with a liquidity position

solidity
function queryAmbientTokens (
    address owner,
    address base,
    address quote,
    uint256 poolIdx
) public view returns (uint128 liq, uint128 baseQty, uint128 quoteQty)

Parameters

ParameterTypeDescription
owneraddressThe address of the position's owner
baseaddressThe address of the base-side token in the pool's pair (always the smaller address)
quoteaddressThe address of the quote-side token in the pool's pair
poolIdxuint256The pool type index

Returns

NameTypeDescription
liquint128The full range liquidity contribution of this position as the square root of the base and quote tokens.
baseQtyuint128The total amount of base side tokens currently owned by this position.
quoteQtyuint128The total amount of quote side tokens currently owned by this position.