π½Querier
General query functions for tokens and core Astroport contracts
1. Summary
The Querier holds query functions used to retrieve data about token balances, token supply, the Astroport factory configuration, fee setups for pair types, and pair type configurations. It also holds logic that allows someone to simulate or reverse simulate pair swaps.
2. Variables & Functions
Constants
NATIVE_TOKEN_PRECISION
Token precision used in native Terra assets (LUNA, UST etc)
Structs
FeeInfo
This struct holds parameters used to define the fee structure for a specific pair type.
fee_address- the address that collects fees for governance (the Maker contract)total_fee_rate- the total amount of fees charged per swap for this pair typemaker_fee_rate- the amount of fees that go to the Maker contract
Functions
query_balance
(querier: &QuerierWrapper, account_addr: Addr, denom: String) -> StdResult<Uint128>
Returns a native token's balance for a specific account
query_all_balances
(querier: &QuerierWrapper, account_addr: Addr) -> StdResult<Vec<Coin>>
Returns the total balances for all native Terra coins that a specific account holds
query_token_balance
(querier: &QuerierWrapper, contract_addr: Addr, account_addr: Addr) -> StdResult<Uint128>
Returns a token balance (CW20) for a specific account
query_token_symbol
(querier: &QuerierWrapper, contract_addr: Addr) -> StdResult<Uint128>
Return the token symbol for a CW20 token
query_supply
(querier: &QuerierWrapper, contract_addr: Addr) -> StdResult<Uint128>
Returns the total supply of a specific token
query_token_precision
(querier: &QuerierWrapper, asset_info: AssetInfo) -> StdResult<u8>
Returns the number of decimals that a token has. AssetInfo is defined in the asset utils file
query_factory_config
(querier: &QuerierWrapper, factory_contract: Addr) -> StdResult<FactoryConfigResponse>
Returns the contract configuration for the Astroport factory. FactoryConfigResponse is defined in the factory
query_fee_info
(querier: &QuerierWrapper, factory_contract: Addr, pair_type: PairType) -> StdResult<FeeInfo>
Returns the fee information for a specific pair type. PairType is defined in the factory
query_pair_info
(querier: &QuerierWrapper, factory_contract: Addr, asset_infos: &[AssetInfo; 2]) -> StdResult<PairInfo>
Accepts two tokens as input and returns a pair's information (pair that has the specified tokens). AssetInfo and PairInfo are defined in the asset utils file
query_pairs_info
(querier: &QuerierWrapper, factory_contract: Addr, start_after: Option<[AssetInfo; 2]>, limit: Option<u12>) -> StdResult<PairsResponse>
Returns a vector that contains items of type PairInfo which symbolize pairs instantiated in the Astroport factory. AssetInfo is defined in the asset utils file. PairsResponse is defined in the factory
simulate
(querier: &QuerierWrapper, pair_contract: Addr, offer_asset: &Asset) -> StdResult<SimulationResponse>
Simulates a swap and returns information about it using a SimulationResponse object. SimulationResponse is defined in pair contracts
reverse_simulate
(querier: &QuerierWrapper, pair_contract: &Addr, ask_asset: &Asset) -> StdResult<ReverseSimulationResponse>
Simulates a reverse swap (provides a desired output in order to get the token input) and returns information about it using a ReverseSimulationResponse object. ReverseSimulationResponse is defined in pair contracts
Last updated