Crates.io | oraiswap |
lib.rs | oraiswap |
version | 1.0.1 |
source | src |
created_at | 2023-02-10 20:13:27.829961 |
updated_at | 2023-07-26 03:56:22.214839 |
description | Common oraiswap types used in different Oraichain Labs contracts like oraiDEX, IBC Wasm |
homepage | https://orai.io |
repository | https://github.com/oraichain/cosmwasm.git |
max_upload_size | |
id | 782116 |
size | 82,626 |
This is a collection of common types and the queriers which are commonly used in oraiswap contracts.
AssetInfo is a convience wrapper to represent the native token and the contract token as a single type. Currently there only Orai native token in Oraichain blockchain.
#[cw_serde]
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],
}
It uses CosmWasm standard interface to query the account balance to chain.
pub fn query_balance(
querier: &QuerierWrapper,
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,
contract_addr: Addr,
account_addr: Addr,
) -> StdResult<Uint128> {
It provides token supply querier for CW20 token contract.
pub fn query_supply(
querier: &QuerierWrapper,
contract_addr: Addr,
) -> StdResult<Uint128> {
It also provides the query interface to query avaliable oraiswap pair contract info. Any contract can query pair info to oraiswap factory contract.
pub fn query_pair_info(
querier: &QuerierWrapper,
factory_contract: Addr,
asset_infos: &[AssetInfo; 2],
) -> StdResult<PairInfo> {