From 9e9d32a31e4c952b0d6c9d3fca57c5eecaf034b5 Mon Sep 17 00:00:00 2001 From: ApolloGie Date: Mon, 10 Jun 2024 06:59:48 -0500 Subject: [PATCH] fix: omit astroport whitelist --- CHANGELOG.md | 8 ++ Cargo.lock | 3 +- Cargo.toml | 5 +- deny.toml | 12 ++- src/astroport/mod.rs | 1 - src/astroport/robot.rs | 79 +++++++++------ src/astroport/utils.rs | 215 +++++++++++++++++------------------------ 7 files changed, 158 insertions(+), 165 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e40730a..e0be364 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.3.2] - 2024-06-17 + +### Changed + +- Update Astroport packages to native lp token implementation. +- Replace Astroport artifacts. +- Update tests for native lp tokens instead of CW20. + ## [0.3.1] - 2024-03-07 ### Changed diff --git a/Cargo.lock b/Cargo.lock index 479187f..31b7ecf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -919,13 +919,12 @@ dependencies = [ [[package]] name = "cw-it" -version = "0.3.1" +version = "0.3.2" dependencies = [ "anyhow", "apollo-cw-multi-test", "apollo-utils", "astroport 2.9.5", - "astroport 3.11.1", "astroport 5.0.0-rc.2-tokenfactory", "astroport-factory", "astroport-generator", diff --git a/Cargo.toml b/Cargo.toml index e4cc3b3..29935d4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw-it" -version = "0.3.1" +version = "0.3.2" authors = ["Pacman ", "Sturdy "] edition = "2021" license = "MPL-2.0" @@ -33,7 +33,7 @@ overflow-checks = true [features] default = [] -astroport = ["cw20", "dep:astroport", "dep:astroport_v3", "dep:astroport_v5"] +astroport = ["cw20", "dep:astroport", "dep:astroport_v5"] osmosis = ["proptest", "apollo-utils", "osmosis-test-tube"] rpc-runner = ["bip32"] chain-download = ["tokio"] @@ -90,7 +90,6 @@ osmosis-test-tube = { version = "25.0.0", optional = true } # Astroport deps astroport = { version = "2.9.0", optional = true } -astroport_v3 = { package = "astroport", version = "3.11.1", optional = true } astroport_v5 = { package = "astroport", version = "5.0.0-rc.2-tokenfactory", optional = true } cw20 = { version = "0.15", optional = true } diff --git a/deny.toml b/deny.toml index af7214a..9b7bf4e 100644 --- a/deny.toml +++ b/deny.toml @@ -35,7 +35,16 @@ allow = ["Apache-2.0", "MIT", "BSD-3-Clause", "MPL-2.0", "ISC"] exceptions = [ { allow = ["Unicode-DFS-2016"], name = "unicode-ident" }, { allow = ["OpenSSL"], name = "ring" }, - { allow = ["GPL-3.0"], name = "astroport-incentives" } + { allow = ["GPL-3.0"], name = "astroport-incentives" }, + { allow = ["GPL-3.0"], name = "astroport-factory" }, + { allow = ["GPL-3.0"], name = "astroport-generator" }, + { allow = ["GPL-3.0"], name = "astroport-maker" }, + { allow = ["GPL-3.0"], name = "astroport-pair" }, + { allow = ["GPL-3.0"], name = "astroport-pair-concentrated" }, + { allow = ["GPL-3.0"], name = "astroport-pair-stable" }, + { allow = ["GPL-3.0"], name = "astroport-pcl-common" }, + { allow = ["GPL-3.0"], name = "astroport-router" }, + { allow = ["GPL-3.0"], name = "astroport-vesting" } ] [[licenses.clarify]] @@ -49,3 +58,4 @@ name = "ring" # OpenSSL - Obviously expression = "ISC AND MIT AND OpenSSL" license-files = [{ path = "LICENSE", hash = 0xbd0eed23 }] + diff --git a/src/astroport/mod.rs b/src/astroport/mod.rs index 2962d44..dcb3e9d 100644 --- a/src/astroport/mod.rs +++ b/src/astroport/mod.rs @@ -2,5 +2,4 @@ pub mod robot; pub mod utils; pub use astroport; -pub use astroport_v3; pub use astroport_v5; diff --git a/src/astroport/robot.rs b/src/astroport/robot.rs index 6b66f64..76979a8 100644 --- a/src/astroport/robot.rs +++ b/src/astroport/robot.rs @@ -1,5 +1,5 @@ -use astroport::asset::{Asset, AssetInfo}; -use astroport::factory::{ConfigResponse, ExecuteMsg as AstroportFactoryExecuteMsg, PairType}; +use astroport_v5::asset::{Asset, AssetInfo}; +use astroport_v5::factory::{ConfigResponse, ExecuteMsg as AstroportFactoryExecuteMsg, PairType}; use cosmwasm_std::{Binary, Coin, Decimal, Uint128}; use cw20::{BalanceResponse, Cw20ExecuteMsg, Cw20QueryMsg}; use std::collections::HashMap; @@ -113,10 +113,10 @@ where /// Queries the LP token balance given the pair's address and the address of the account. fn query_lp_token_balance(&self, pair_addr: &str, address: &str) -> Uint128 { // Get lp token address - let msg = astroport::pair::QueryMsg::Pair {}; + let msg = astroport_v5::pair::QueryMsg::Pair {}; let lp_token_addr = self .wasm() - .query::<_, astroport::asset::PairInfo>(pair_addr, &msg) + .query::<_, astroport_v5::asset::PairInfo>(pair_addr, &msg) .unwrap() .liquidity_token; @@ -125,24 +125,24 @@ where } /// Queries the PairInfo of the given pair. - fn query_pair_info(&self, pair_addr: &str) -> astroport::asset::PairInfo { - let msg = astroport::pair::QueryMsg::Pair {}; + fn query_pair_info(&self, pair_addr: &str) -> astroport_v5::asset::PairInfo { + let msg = astroport_v5::pair::QueryMsg::Pair {}; self.wasm() - .query::<_, astroport::asset::PairInfo>(pair_addr, &msg) + .query::<_, astroport_v5::asset::PairInfo>(pair_addr, &msg) .unwrap() } /// Queries the PoolInfo of the given pair (contains the reserves and the total supply of LP tokens). - fn query_pool(&self, pair_addr: &str) -> astroport::pair::PoolResponse { - let msg = astroport::pair::QueryMsg::Pool {}; + fn query_pool(&self, pair_addr: &str) -> astroport_v5::pair::PoolResponse { + let msg = astroport_v5::pair::QueryMsg::Pool {}; self.wasm() - .query::<_, astroport::pair::PoolResponse>(pair_addr, &msg) + .query::<_, astroport_v5::pair::PoolResponse>(pair_addr, &msg) .unwrap() } /// Queries the Config of the Astroport Factory contract. fn query_factory_config(&self, factory_addr: &str) -> ConfigResponse { - let msg = astroport::factory::QueryMsg::Config {}; + let msg = astroport_v5::factory::QueryMsg::Config {}; self.wasm() .query::<_, ConfigResponse>(factory_addr, &msg) .unwrap() @@ -152,7 +152,7 @@ where fn query_native_coin_registry(&self, denom: &str) -> RunnerResult { let contracts = self.astroport_contracts(); let registry_addr = contracts.coin_registry.address.as_str(); - let msg = astroport::native_coin_registry::QueryMsg::NativeToken { + let msg = astroport_v5::native_coin_registry::QueryMsg::NativeToken { denom: denom.to_string(), }; self.wasm().query::<_, u8>(registry_addr, &msg) @@ -165,7 +165,7 @@ where native_coins: Vec<(String, u8)>, signer: &SigningAccount, ) -> &Self { - let msg = astroport::native_coin_registry::ExecuteMsg::Add { native_coins }; + let msg = astroport_v5::native_coin_registry::ExecuteMsg::Add { native_coins }; self.wasm() .execute(registry_addr, &msg, &[], signer) .unwrap(); @@ -205,11 +205,12 @@ where funds.sort_by(|a, b| a.denom.cmp(&b.denom)); // Provide liquidity - let msg = astroport::pair::ExecuteMsg::ProvideLiquidity { + let msg = astroport_v5::pair::ExecuteMsg::ProvideLiquidity { assets, slippage_tolerance: None, receiver: None, auto_stake: Some(false), + min_lp_to_receive: None, }; self.wasm() .execute(pair_addr, &msg, &funds, signer) @@ -228,7 +229,7 @@ where signer: &SigningAccount, initial_liquidity: Option<&[u128; 2]>, decimals: Option<&[u8; 2]>, - ) -> (String, String) { + ) -> (String, String, String) { let factory_addr = &self.astroport_contracts().factory.address; // If decimals are provided, add native coins to registry @@ -258,7 +259,8 @@ where .unwrap(); // Get pair and lp_token addresses from event - let (pair_addr, lp_token_addr) = parse_astroport_create_pair_events(&res.events); + let (pair_addr, lp_token_addr, token_denom) = + parse_astroport_create_pair_events(&res.events); if let Some(initial_liquidity) = initial_liquidity { let assets = asset_infos @@ -272,7 +274,7 @@ where self.provide_liquidity(&pair_addr, assets, signer); } - (pair_addr, lp_token_addr) + (pair_addr, lp_token_addr, token_denom) } fn query_simulate_swap( @@ -280,13 +282,13 @@ where pair_addr: &str, offer_asset: Asset, ask_asset_info: Option, - ) -> astroport::pair::SimulationResponse { - let msg = astroport::pair::QueryMsg::Simulation { + ) -> astroport_v5::pair::SimulationResponse { + let msg = astroport_v5::pair::QueryMsg::Simulation { offer_asset, ask_asset_info, }; self.wasm() - .query::<_, astroport::pair::SimulationResponse>(pair_addr, &msg) + .query::<_, astroport_v5::pair::SimulationResponse>(pair_addr, &msg) .unwrap() } @@ -321,7 +323,7 @@ where } }; - let msg = astroport::pair::ExecuteMsg::Swap { + let msg = astroport_v5::pair::ExecuteMsg::Swap { offer_asset, ask_asset_info, belief_price, @@ -340,7 +342,7 @@ where precision: u8, signer: &SigningAccount, ) -> &Self { - let msg = astroport::native_coin_registry::ExecuteMsg::Add { + let msg = astroport_v5::native_coin_registry::ExecuteMsg::Add { native_coins: vec![(denom.into(), precision)], }; self.wasm() @@ -424,7 +426,7 @@ where mod tests { use std::str::FromStr; - use astroport::{ + use astroport_v5::{ asset::{Asset, AssetInfo}, factory::PairType, pair::StablePoolParams, @@ -434,13 +436,13 @@ mod tests { use test_tube::{Account, SigningAccount}; use super::AstroportTestRobot; + use crate::traits::CwItRunner; use crate::{ astroport::utils::{cw20_info, native_info, AstroportContracts}, robot::TestRobot, ContractMap, OwnedTestRunner, TestRunner, }; - - use crate::traits::CwItRunner; + use cosmwasm_std::Addr; struct TestingRobot<'a> { runner: &'a TestRunner<'a>, @@ -503,7 +505,14 @@ mod tests { /// Helper to get a pair of native token asset infos. fn native_native_pair() -> [AssetInfo; 2] { - [native_info("uatom"), native_info("uion")] + [ + AssetInfo::NativeToken { + denom: "uatom".to_string(), + }, + AssetInfo::NativeToken { + denom: "uion".to_string(), + }, + ] } /// Helper enum for choice of asset infos. @@ -516,7 +525,14 @@ mod tests { fn get_asset_infos(choice: AssetChoice, astro_token: &str) -> [AssetInfo; 2] { match choice { AssetChoice::NativeNative => native_native_pair(), - AssetChoice::NativeCw20 => [native_info("uatom"), cw20_info(astro_token)], + AssetChoice::NativeCw20 => [ + AssetInfo::NativeToken { + denom: "uatom".to_string(), + }, + AssetInfo::Token { + contract_addr: Addr::unchecked(astro_token), + }, + ], } } @@ -567,7 +583,7 @@ mod tests { let asset_infos = get_asset_infos(asset_info_choice, &contracts.astro_token.address); - let (pair_addr, lp_token_addr) = robot.create_astroport_pair( + let (pair_addr, lp_token_addr, lp_token_denom) = robot.create_astroport_pair( pair_type.clone(), &asset_infos, init_params, @@ -580,11 +596,12 @@ mod tests { let pair_info = robot.query_pair_info(&pair_addr); assert_eq!(pair_info.pair_type, pair_type); assert_eq!(pair_info.asset_infos, asset_infos.to_vec()); - assert_eq!(pair_info.liquidity_token.to_string(), lp_token_addr); + assert_eq!(pair_info.liquidity_token.to_string(), lp_token_denom); if let Some(initial_liq) = initial_liquidity { // Check lp token balance - let lp_token_balance = robot.query_cw20_balance(&lp_token_addr, &admin.address()); + let lp_token_balance = + robot.query_native_token_balance(&admin.address(), lp_token_denom); assert_ne!(lp_token_balance, Uint128::zero()); // Check pair reserves @@ -618,7 +635,7 @@ mod tests { let asset_infos = get_asset_infos(asset_info_choice, &contracts.astro_token.address); let initial_liquidity = Some(&[420420u128, 696969u128]); - let (pair_addr, _lp_token_addr) = robot.create_astroport_pair( + let (pair_addr, _lp_token_addr, lp_token_denom) = robot.create_astroport_pair( pair_type, &asset_infos, init_params, diff --git a/src/astroport/utils.rs b/src/astroport/utils.rs index 09e9fb9..45c7fff 100644 --- a/src/astroport/utils.rs +++ b/src/astroport/utils.rs @@ -3,21 +3,25 @@ use crate::helpers::upload_wasm_files; use crate::traits::CwItRunner; use crate::{ContractMap, ContractType, TestRunner}; use astroport::asset::{Asset, AssetInfo}; -use astroport::generator::InstantiateMsg as GeneratorInstantiateMsg; use astroport::maker::InstantiateMsg as MakerInstantiateMsg; use astroport::native_coin_registry::InstantiateMsg as CoinRegistryInstantiateMsg; +use astroport_v5::asset::AssetInfo as AssetInfoV5; use astroport_v5::factory::{ ExecuteMsg as AstroportFactoryExecuteMsg, InstantiateMsg as AstroportFactoryInstantiateMsg, PairConfig, PairType, }; -use astroport_v5::asset::AssetInfo as AssetInfoV5; use astroport_v5::incentives::InstantiateMsg as IncentivesInstantiateMsg; +use osmosis_std::types::cosmos::base::v1beta1::Coin as OsmosisCoin; +use osmosis_std::types::osmosis::tokenfactory::v1beta1::{ + MsgCreateDenom, MsgCreateDenomResponse, MsgMint, MsgMintResponse, +}; +use test_tube::ExecuteResponse; +// use astroport_v5::tokenfactory_tracker::InstantiateMsg as TrackerInstantiateMsg; use osmosis_std::types::cosmos::bank::v1beta1::QueryBalanceRequest; use std::collections::HashMap; // use astroport::liquidity_manager::InstantiateMsg as LiquidityManagerInstantiateMsg; use astroport::router::InstantiateMsg as RouterInstantiateMsg; -use astroport::staking::InstantiateMsg as StakingInstantiateMsg; use astroport::token::InstantiateMsg as AstroTokenInstantiateMsg; use astroport::vesting::{ Cw20HookMsg as VestingHookMsg, InstantiateMsg as VestingInstantiateMsg, VestingAccount, @@ -39,21 +43,22 @@ pub fn astroport_asset_info_to_astroport_v5_asset_info( } } -pub const ASTROPORT_CONTRACT_NAMES: [&str; 13] = [ +pub const ASTROPORT_CONTRACT_NAMES: [&str; 11] = [ "astroport_token", "astroport_native_coin_registry", "astroport_factory", - "astroport_generator", + // "astroport_generator", "astroport_maker", "astroport_pair_stable", "astroport_pair", "astroport_router", - "astroport_staking", + // "astroport_staking", "astroport_vesting", - "astroport_whitelist", + // "astroport_whitelist", // "astroport_liquidity_manager", "astroport_pair_concentrated", "astroport_incentives", + "astroport_tokenfactory_tracker", ]; #[cw_serde] @@ -72,16 +77,12 @@ impl Contract { pub struct AstroportContracts { pub factory: Contract, pub coin_registry: Contract, - pub generator: Contract, pub astro_token: Contract, pub maker: Contract, pub pair_stable: Contract, pub pair: Contract, pub router: Contract, - pub staking: Contract, pub vesting: Contract, - pub whitelist: Contract, - // pub liquidity_manager: Contract, pub incentives: Contract, } @@ -205,7 +206,8 @@ where fee_address: None, generator_address: None, // TODO: Set this owner: admin.address(), - whitelist_code_id: code_ids["astroport_whitelist"], + // whitelist_code_id: code_ids["astroport_whitelist"], + whitelist_code_id: 0, coin_registry_address: coin_registry.clone(), tracker_config: None, }, @@ -255,36 +257,6 @@ where .data .address; - // Instantiate generator - println!("Instantiating generator ..."); - let generator = wasm - .instantiate( - code_ids["astroport_generator"], - &GeneratorInstantiateMsg { - owner: admin.address(), - whitelist_code_id: code_ids["astroport_whitelist"], - factory: factory.clone(), - generator_controller: Some(admin.address()), - voting_escrow: None, - guardian: None, - astro_token: AssetInfo::Token { - contract_addr: Addr::unchecked(&astro_token), - }, - tokens_per_block: Uint128::from(10000000u128), - start_block: Uint64::one(), - vesting_contract: vesting.clone(), - voting_escrow_delegation: None, - }, - Some(&admin.address()), // contract admin used for migration - Some("Astroport Factory"), // contract label - &[], // funds - admin, // signer - ) - .unwrap() - .data - .address; - - println!("Instantiating incentives ..."); let incentives = wasm .instantiate( @@ -299,10 +271,10 @@ where vesting_contract: vesting.clone(), incentivization_fee_info: None, }, - Some(&admin.address()), // contract admin used for migration + Some(&admin.address()), // contract admin used for migration Some("Astroport Incentives"), // contract label - &[], // funds - admin, // signer + &[], // funds + admin, // signer ) .unwrap() .data @@ -314,7 +286,7 @@ where .execute( &factory, &AstroportFactoryExecuteMsg::UpdateConfig { - generator_address: Some(generator.clone()), + generator_address: Some(incentives.clone()), fee_address: None, token_code_id: None, whitelist_code_id: None, @@ -325,27 +297,25 @@ where ) .unwrap(); - // Instantiate staking - println!("Instantiating staking ..."); - let staking_code_id = code_ids.get("astroport_staking"); - let staking = staking_code_id.map(|code_id| { - wasm.instantiate( - *code_id, - &StakingInstantiateMsg { - owner: admin.address(), - deposit_token_addr: astro_token.clone(), - token_code_id: code_ids["astroport_token"], - marketing: None, - }, - Some(&admin.address()), // contract admin used for migration - Some("Astroport Staking"), // contract label - &[], // funds - admin, // signer - ) - .unwrap() - .data - .address - }); + let msg = MsgCreateDenom { + sender: admin.address(), + subdenom: "astro".to_string(), + }; + + let res: ExecuteResponse = + app.execute(msg, MsgCreateDenom::TYPE_URL, admin).unwrap(); + + let staking_denom = res.data.new_token_denom; + let msg = MsgMint { + sender: admin.address(), + amount: Some(OsmosisCoin { + denom: staking_denom.clone(), + amount: 1e18.to_string(), + }), + mint_to_address: admin.address(), + }; + let _res: ExecuteResponse = + app.execute(msg, MsgMint::TYPE_URL, admin).unwrap(); // Instantiate Router println!("Instantiating router ..."); @@ -371,11 +341,11 @@ where code_ids["astroport_maker"], &MakerInstantiateMsg { factory_contract: factory.clone(), - governance_contract: None, - governance_percent: None, + governance_contract: Some(admin.address()), + governance_percent: Some(Uint64::new(100u64)), max_spread: None, owner: admin.address(), - staking_contract: staking.clone(), + staking_contract: None, astro_token: AssetInfo::Token { contract_addr: Addr::unchecked(&astro_token), }, @@ -402,7 +372,7 @@ where amount: vesting_amount, msg: to_json_binary(&VestingHookMsg::RegisterVestingAccounts { vesting_accounts: vec![VestingAccount { - address: generator.clone(), + address: incentives.clone(), schedules: vec![VestingSchedule { start_point: VestingSchedulePoint { amount: vesting_amount, @@ -418,8 +388,6 @@ where AstroportContracts { factory: Contract::new(factory, code_ids["astroport_factory"]), - generator: Contract::new(generator, code_ids["astroport_generator"]), - staking: Contract::new(staking.unwrap_or_default(), code_ids["astroport_staking"]), router: Contract::new(router, code_ids["astroport_router"]), maker: Contract::new(maker, code_ids["astroport_maker"]), vesting: Contract::new(vesting, code_ids["astroport_vesting"]), @@ -427,11 +395,6 @@ where coin_registry: Contract::new(coin_registry, code_ids["astroport_native_coin_registry"]), pair_stable: Contract::new(String::from(""), code_ids["astroport_pair_stable"]), pair: Contract::new(String::from(""), code_ids["astroport_pair"]), - whitelist: Contract::new(String::from(""), code_ids["astroport_whitelist"]), - // liquidity_manager: Contract::new( - // liquidity_manager, - // code_ids["astroport_liquidity_manager"], - // ), incentives: Contract::new(incentives, code_ids["astroport_incentives"]), } } @@ -444,7 +407,7 @@ pub fn create_astroport_pair<'a, R>( init_params: Option, signer: &SigningAccount, initial_liquidity: Option<[Uint128; 2]>, -) -> (String, String) +) -> (String, String, String) where R: Runner<'a>, { @@ -462,7 +425,7 @@ where let res = wasm.execute(factory_addr, &msg, &[], signer).unwrap(); // Get pair and lp_token addresses from event - let (pair_addr, lp_token_addr) = parse_astroport_create_pair_events(&res.events); + let (pair_addr, lp_token_addr, token_denom) = parse_astroport_create_pair_events(&res.events); if let Some(initial_liquidity) = initial_liquidity { let assets = asset_infos @@ -473,12 +436,14 @@ where provide_liquidity(app, &pair_addr, assets, signer); } - (pair_addr, lp_token_addr) + (pair_addr, lp_token_addr, token_denom) } -pub fn parse_astroport_create_pair_events(events: &[Event]) -> (String, String) { +pub fn parse_astroport_create_pair_events(events: &[Event]) -> (String, String, String) { let mut pair_addr = String::from(""); let mut lp_token = String::from(""); + let mut token_denom = String::from(""); + for event in events { if event.ty == "wasm" { let attributes = &event.attributes; @@ -489,10 +454,13 @@ pub fn parse_astroport_create_pair_events(events: &[Event]) -> (String, String) if attr.key == "liquidity_token_addr" { lp_token = attr.value.clone(); } + if attr.key == "lp_denom" { + token_denom = attr.value.clone() + } } } } - (pair_addr, lp_token) + (pair_addr, lp_token, token_denom) } pub fn get_lp_token_balance<'a, R>( @@ -699,13 +667,12 @@ pub fn get_astroport_multitest_contracts() -> HashMap { "astroport_maker", "astroport_token", "astroport_router", - "astroport_vesting", - "astroport_whitelist" + "astroport_vesting" // "astroport_whitelist" ); contract_wrappers.extend(create_contract_wrappers_with_reply!( - "astroport_generator", - "astroport_staking", + // "astroport_generator", + // "astroport_staking", "astroport_factory", "astroport_pair_stable", "astroport_pair" @@ -713,17 +680,6 @@ pub fn get_astroport_multitest_contracts() -> HashMap { // Liquidity manager, incentives, and concentrated pair don't have query entrypoint in contract module contract_wrappers.extend(vec![ - // ( - // "astroport_liquidity_manager".to_string(), - // Box::new( - // ContractWrapper::new_with_empty( - // astroport_liquidity_manager::contract::execute, - // astroport_liquidity_manager::contract::instantiate, - // astroport_liquidity_manager::query::query, - // ) - // .with_reply(astroport_liquidity_manager::contract::reply), - // ) as Box>, - // ), ( "astroport_pair_concentrated".to_string(), Box::new( @@ -761,7 +717,7 @@ mod tests { use cosmwasm_std::{Addr, Coin, Decimal, Uint128}; use cw20::{AllowanceResponse, BalanceResponse, Cw20ExecuteMsg, Cw20QueryMsg}; use osmosis_std::types::cosmos::bank::v1beta1::QueryAllBalancesRequest; - + use osmosis_std::types::cosmos::bank::v1beta1::QueryBalanceRequest; use test_tube::{Account, Bank, Module, Wasm}; use crate::{ @@ -876,15 +832,15 @@ mod tests { }) .collect::>(); // Staking contract not deployed on Neutron testnet - artifacts.insert( - "astroport_staking".to_string(), - ContractType::Artifact(Artifact::Local(get_wasm_path( - "astroport_staking", - &ARTIFACTS_PATH, - APPEND_ARCH, - &ARCH, - ))), - ); + // artifacts.insert( + // "astroport_staking".to_string(), + // ContractType::Artifact(Artifact::Local(get_wasm_path( + // "astroport_staking", + // &ARTIFACTS_PATH, + // APPEND_ARCH, + // &ARCH, + // ))), + // ); artifacts } @@ -978,15 +934,19 @@ mod tests { contract_addr: Addr::unchecked(&contracts.astro_token.address), }, ]; - let (uluna_astro_pair_addr, uluna_astro_lp_token) = create_astroport_pair( - &app, - &contracts.factory.address, - astroport_v5::factory::PairType::Xyk {}, - asset_infos, - None, - admin, - None, - ); + let (uluna_astro_pair_addr, uluna_astro_lp_token, uluna_astro_denom) = + create_astroport_pair( + &app, + &contracts.factory.address, + astroport_v5::factory::PairType::Xyk {}, + asset_infos, + None, + admin, + None, + ); + + println!("uluna_astro_pair_addr: {:?}", uluna_astro_pair_addr); + println!("uluna_astro_lp_token: {:?}", uluna_astro_lp_token); // Increase allowance of astro token let increase_allowance_msg = Cw20ExecuteMsg::IncreaseAllowance { @@ -1045,16 +1005,17 @@ mod tests { admin, ); - // Query LP token balance - let lp_token_balance: BalanceResponse = wasm - .query( - &uluna_astro_lp_token, - &Cw20QueryMsg::Balance { - address: admin.address(), - }, - ) + println!("uluna_astro_denom {:?}", uluna_astro_denom); + + let lp_token_balance = bank + .query_balance(&QueryBalanceRequest { + address: admin.address(), + denom: uluna_astro_denom, + }) .unwrap(); - println!("LP token balance: {:?}", lp_token_balance); - assert!(lp_token_balance.balance > Uint128::zero()); + + assert!( + Uint128::from_str(&lp_token_balance.balance.unwrap().amount).unwrap() > Uint128::zero() + ); } }