Crates.io | astro4nit |
lib.rs | astro4nit |
version | 0.0.1 |
source | src |
created_at | 2022-02-05 11:01:55.33342 |
updated_at | 2022-02-05 11:01:55.33342 |
description | Common astroport types |
homepage | https://astroport.fi |
repository | https://github.com/astroport-fi/astroport |
max_upload_size | |
id | 527368 |
size | 115,128 |
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 and it also returns the contract address of that token.
#[serde(rename_all = "snake_case")]
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 contract_addr: Addr,
pub asset_infos: [AssetInfo; 2],
pub liquidity_token: Addr,
pub pair_type: PairType,
}
It uses the CosmWasm standard interface to query an account's balance.
pub fn query_balance(
deps: &Extern<S, A, Q>,
account_addr: &Addr,
denom: String,
) -> StdResult<Uint128>
It provides a similar query interface to Native-Token-Balance-Querier for fetching CW20 token balances.
pub fn query_token_balance(
deps: &Extern<S, A, Q>,
contract_addr: &Addr,
account_addr: &Addr,
) -> StdResult<Uint128>
It fetches a CW20 token's total supply.
pub fn query_supply(
deps: &Extern<S, A, Q>,
contract_addr: &Addr,
) -> StdResult<Uint128>
It returns an Astroport pair contract address if that pair is already available in the factory contract.
pub fn query_pair_contract(
deps: &Extern<S, A, Q>,
contract_addr: &Addr,
asset_infos: &[AssetInfo; 2],
) -> StdResult<Addr>
It returns the address of a LP token if that LP token is already available (has a pair) on Astroport.
pub fn query_liquidity_token(
deps: &Extern<S, A, Q>,
contract_addr: &Addr,
) -> StdResult<Addr>
Simulates a swap and returns the output amount, the spread and commission amounts.
pub fn simulate(
querier: &QuerierWrapper,
pair_contract: Addr,
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: Addr,
offer_asset: &Asset,
) -> StdResult<ReverseSimulationResponse>