Crates.io | astroport-types |
lib.rs | astroport-types |
version | 0.1.3 |
source | src |
created_at | 2023-02-13 16:25:32.741025 |
updated_at | 2023-02-13 20:49:07.492044 |
description | Common astroport types |
homepage | |
repository | https://github.com/apollodao/astroport-types |
max_upload_size | |
id | 784101 |
size | 101,413 |
This is a collection of common types and the queriers which are commonly used in astroport contracts.
AssetInfo is a convenience wrapper to represent the native token and the contract token as a single type.
#[serde(rename_all = "snake_case")]
pub enum AssetInfo {
Token { contract_addr: Addr },
NativeToken { denom: String },
}
It contains asset info with the amount of token.
pub struct Asset {
pub info: AssetInfo,
pub amount: Uint128,
}
It is used to represent response data of Pair-Info-Querier
pub struct PairInfo {
pub contract_addr: Addr,
pub asset_infos: [AssetInfo; 2],
pub liquidity_token: Addr,
pub pair_type: PairType,
}
It uses CosmWasm standard interface to query the account balance to chain.
pub fn query_balance(
deps: &Extern<S, A, Q>,
account_addr: &Addr,
denom: String,
) -> StdResult<Uint128>
It provides similar query interface with Native-Token-Balance-Querier for CW20 token balance.
pub fn query_token_balance(
deps: &Extern<S, A, Q>,
contract_addr: &Addr,
account_addr: &Addr,
) -> StdResult<Uint128>
It provides token supply querier for CW20 token contract.
pub fn query_supply(
deps: &Extern<S, A, Q>,
contract_addr: &Addr,
) -> StdResult<Uint128>
It also provides the query interface to query available astroport pair contract info. Any contract can query pair info to astroport factory contract.
pub fn query_pair_contract(
deps: &Extern<S, A, Q>,
contract_addr: &Addr,
asset_infos: &[AssetInfo; 2],
) -> StdResult<Addr>
It returns liquidity token contract address of astroport pair contract.
pub fn query_liquidity_token(
deps: &Extern<S, A, Q>,
contract_addr: &Addr,
) -> StdResult<Addr>
Returns simulation swap return, spread, commission amounts.
pub fn simulate(
querier: &QuerierWrapper,
pair_contract: Addr,
offer_asset: &Asset,
) -> StdResult<SimulationResponse>
Returns simulation swap offer, spread, commission amounts.
pub fn reverse_simulate(
querier: &QuerierWrapper,
pair_contract: Addr,
offer_asset: &Asset,
) -> StdResult<ReverseSimulationResponse>