Crates.io | classic_terraswap |
lib.rs | classic_terraswap |
version | 2.8.0 |
source | src |
created_at | 2022-09-14 16:07:37.47102 |
updated_at | 2023-10-31 04:57:45.730364 |
description | Common terraswap types |
homepage | https://terraswap.io |
repository | https://github.com/terraswap/classic-terraswap |
max_upload_size | |
id | 665913 |
size | 93,302 |
This is a collection of common types and the queriers which are commonly used in terraswap contracts.
AssetInfo is a convience 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: HumanAddr },
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 asset_infos: [AssetInfo; 2],
pub contract_addr: String,
pub liquidity_token: String,
pub asset_decimals: [u8; 2],
}
It uses CosmWasm standard interface to query the account balance to chain.
pub fn query_balance(
querier: &QuerierWrapper<Empty>,
account_addr: Addr,
denom: String,
) -> StdResult<Uint128>
It provides simliar query interface with Native-Token-Balance-Querier for CW20 token balance.
pub fn query_token_balance(
querier: &QuerierWrapper<Empty>,
contract_addr: Addr,
account_addr: Addr,
) -> StdResult<Uint128>
It provides token info querier for CW20 token contract.
pub fn query_token_info(
querier: &QuerierWrapper<Empty>,
contract_addr: Addr,
) -> StdResult<TokenInfoResponse>
It provides native token decimals querier for factory contract.
pub fn query_native_decimals(
querier: &QuerierWrapper,
factory_contract: Addr,
denom: String,
) -> StdResult<u8>
It also provides the query interface to query avaliable terraswap pair contract info. Any contract can query pair info to terraswap factory contract.
pub fn query_pair_info(
querier: &QuerierWrapper<Empty>,
factory_contract: Addr,
asset_infos: &[AssetInfo; 2],
) -> StdResult<PairInfo>
It also provides the query interface to query avaliable terraswap pair contract info. Any contract can query pair info to pair contract.
pub fn query_pair_info_from_pair(
querier: &QuerierWrapper<Empty>,
pair_contract: Addr,
) -> StdResult<PairInfo>