Crates.io | astroport |
lib.rs | astroport |
version | 5.7.0-cw1.0 |
source | src |
created_at | 2021-12-15 16:57:38.849256 |
updated_at | 2024-10-28 11:34:52.001334 |
description | Common Astroport types, queriers and other utils |
homepage | https://astroport.fi |
repository | https://github.com/astroport-fi/astroport |
max_upload_size | |
id | 498365 |
size | 201,925 |
This is a collection of common types and queriers which are commonly used in Astroport contracts.
AssetInfo is a convenience wrapper to represent whether a token is the native one (from a specific chain, like LUNA for Terra) or not. It also returns the contract address of that token.
pub enum AssetInfo {
Token { contract_addr: Addr },
NativeToken { denom: String },
}
It contains asset info and a token amount.
pub struct Asset {
pub info: AssetInfo,
pub amount: Uint128,
}
It is used to represent response data coming from a Pair-Info-Querier.
pub struct PairInfo {
pub asset_infos: [AssetInfo; 2],
pub contract_addr: Addr,
pub liquidity_token: String,
pub pair_type: PairType,
}
It uses the CosmWasm standard interface to query an account's balance.
pub fn query_balance(
querier: &QuerierWrapper,
account_addr: impl Into<String>,
denom: impl Into<String>,
) -> StdResult<Uint128>
It provides a similar query interface to Native-Token-Balance-Querier for fetching CW20 token balances.
pub fn query_token_balance(
querier: &QuerierWrapper,
contract_addr: impl Into<String>,
account_addr: impl Into<String>,
) -> StdResult<Uint128>
It fetches a CW20 token's total supply.
pub fn query_supply(
querier: &QuerierWrapper,
contract_addr: impl Into<String>,
) -> StdResult<Uint128>
Accepts two tokens as input and returns a pair's information.
pub fn query_pair_info(
querier: &QuerierWrapper,
factory_contract: impl Into<String>,
asset_infos: &[AssetInfo; 2],
) -> StdResult<PairInfo>
Simulates a swap and returns the output amount, the spread and commission amounts.
pub fn simulate(
querier: &QuerierWrapper,
pair_contract: impl Into<String>,
offer_asset: &Asset,
) -> StdResult<SimulationResponse>
Simulates a reverse swap and returns an input amount, the spread and commission amounts.
pub fn reverse_simulate(
querier: &QuerierWrapper,
pair_contract: impl Into<String>,
offer_asset: &Asset,
) -> StdResult<ReverseSimulationResponse>