diff --git a/Cargo.lock b/Cargo.lock index a931bca..f38e76e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -155,9 +155,9 @@ dependencies = [ [[package]] name = "astroport" -version = "5.2.0" +version = "5.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c4af74ada17a13fe7b75d0d529367eb5dcb15e06fd7e744892191856eedc742" +checksum = "0b3b225e86694e2fd1adbf230581bce1690a871585aec9edd64b022a313a8493" dependencies = [ "astroport-circular-buffer 0.2.0", "cosmos-sdk-proto 0.19.0", @@ -202,7 +202,7 @@ version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68abcc896255acba2f4aa39f239a1e8361a6035d7bc712442da122dc31f6f959" dependencies = [ - "astroport 5.2.0", + "astroport 5.3.0", "cosmwasm-schema", "cosmwasm-std", "cw-storage-plus 1.2.0", @@ -315,7 +315,7 @@ version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a5e6cd4508d45d89f9f44b607eb482aa614fa54274c46746d6f251bf10b27ae" dependencies = [ - "astroport 5.2.0", + "astroport 5.3.0", "cosmwasm-schema", "cosmwasm-std", "cw-storage-plus 1.2.0", @@ -328,11 +328,11 @@ dependencies = [ [[package]] name = "astroport-pair-concentrated" -version = "4.0.1" +version = "4.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a32d9cadee60182935879a465d7bff7733b917e814ce29d97d6903f7336119a" +checksum = "a85a79c523843d180a7ca3c1607c12f9d6146ab332fc7209dee3907c191ebb04" dependencies = [ - "astroport 5.2.0", + "astroport 5.3.0", "astroport-circular-buffer 0.2.0", "astroport-factory", "astroport-pcl-common", @@ -370,7 +370,7 @@ version = "4.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3386d5771faedd33fc7741cb0a7082cbdc0416d42f1bd051d4f1a0b987248e3c" dependencies = [ - "astroport 5.2.0", + "astroport 5.3.0", "astroport-circular-buffer 0.2.0", "cosmwasm-schema", "cosmwasm-std", @@ -388,7 +388,7 @@ version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a810d9ff3459d62a6288314c01201b4270e96fa518bfa36ef759a4c76b87334f" dependencies = [ - "astroport 5.2.0", + "astroport 5.3.0", "astroport-factory", "cosmwasm-schema", "cosmwasm-std", @@ -1020,7 +1020,7 @@ version = "0.5.4-rc.1" dependencies = [ "apollo-cw-asset", "apollo-utils", - "astroport 2.9.5", + "astroport 5.3.0", "cosmwasm-schema", "cosmwasm-std", "cw-dex-test-contract", @@ -1038,13 +1038,13 @@ dependencies = [ [[package]] name = "cw-dex-astroport" -version = "0.2.0-rc.2" +version = "0.2.0-rc.3" dependencies = [ "apollo-cw-asset", "apollo-cw-multi-test", "apollo-utils", "astroport 2.9.5", - "astroport 5.2.0", + "astroport 5.3.0", "cosmwasm-schema", "cosmwasm-std", "cw-dex", @@ -1062,7 +1062,7 @@ dependencies = [ [[package]] name = "cw-dex-osmosis" -version = "0.1.1" +version = "0.1.1-rc.1" dependencies = [ "apollo-cw-asset", "apollo-utils", @@ -1096,7 +1096,7 @@ dependencies = [ "apollo-cw-asset", "apollo-utils", "astroport 2.9.5", - "astroport 5.2.0", + "astroport 5.3.0", "astroport-test-contract", "cosmwasm-std", "cw-dex-test-contract", @@ -1107,15 +1107,15 @@ dependencies = [ [[package]] name = "cw-it" -version = "0.4.0-rc.6" +version = "0.4.0-rc.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed8f3a9a26df6e91a693259b0964cd38b9697a0d28b2ece1abc25de9104b54f0" +checksum = "f21068abf1b4e3835127f170ab5d0c20c543eab14c8472ffa1e1ba5fd9a541e4" dependencies = [ "anyhow", "apollo-cw-multi-test", "apollo-utils", "astroport 2.9.5", - "astroport 5.2.0", + "astroport 5.3.0", "astroport-factory", "astroport-incentives", "astroport-liquidity-manager", diff --git a/Cargo.toml b/Cargo.toml index 2153be4..1925909 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,10 +26,10 @@ serde = { version = "1.0.145", default-features = false, features = ["derive"] } thiserror = { version = "1.0.31" } apollo-cw-asset = "0.1.1" osmosis-std = "0.22.0" -cw-it = { version = "0.4.0-rc.6", features = ["multi-test"]} +cw-it = { version = "0.4.0-rc.8", features = ["multi-test"]} apollo-utils = "0.1.0" -astroport = "2.9.0" -astroport_v5 = { package = "astroport", version = "5.2.0" } +astroport_v2 = { package = "astroport", version = "2.9.0" } +astroport = { package = "astroport", version = "5.2.0" } test-case = "3.0.0" proptest = "1.0.0" cw-multi-test = "=1.2.0" @@ -37,8 +37,8 @@ apollo-cw-multi-test = { version = "0.19.0-rc.1" ,features = ["stargate"] } # Workspace packages cw-dex = { path = "cw-dex", version = "0.5.4-rc.1" } -cw-dex-astroport = { path = "cw-dex-astroport", version = "0.2.0-rc.2" } -cw-dex-osmosis = { path = "cw-dex-osmosis", version = "0.1.0" } +cw-dex-astroport = { path = "cw-dex-astroport", version = "0.2.0-rc.3" } +cw-dex-osmosis = { path = "cw-dex-osmosis", version = "0.1.1-rc.1" } cw-dex-test-contract = { path = "test-contracts/package" } astroport-test-contract = { path = "test-contracts/astroport-test-contract" } cw-dex-test-helpers = { path = "test-helpers" } diff --git a/cw-dex-astroport/CHANGELOG.md b/cw-dex-astroport/CHANGELOG.md index 3bea2f5..d46ab3a 100644 --- a/cw-dex-astroport/CHANGELOG.md +++ b/cw-dex-astroport/CHANGELOG.md @@ -5,12 +5,12 @@ 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.2.0-rc.2] - 2024-05-01 +# [0.2.0-rc.3] - 2024-08-22 ### Changed - Added support for Astroport native LP tokens. -- Bumped `astroport_v3` dependency alias of `astroport` package to `5.0.0-rc.1-tokenfactory` and renamed it to `astroport_v5`. +- Bumped `astroport_v3` dependency alias of `astroport` package to `5.0.0-rc.1-tokenfactory` and renamed it to `astroport`. Renamed `astroport` to `astroport_v2`. - Changed `AstroportStaking` field `lp_token_addr: Addr` to `lp_token: AssetInfo`. - Changed `AstroportPool` field `lp_token_addr: Addr` to `lp_token: AssetInfo`. - Changed `AstroportPool` field `liquidity_manager: Addr` to `liquidity_manager: Option`. diff --git a/cw-dex-astroport/Cargo.toml b/cw-dex-astroport/Cargo.toml index 57c2165..a3bf4da 100644 --- a/cw-dex-astroport/Cargo.toml +++ b/cw-dex-astroport/Cargo.toml @@ -5,7 +5,7 @@ description = "Implementation of the cw-dex API for the Astroport AMM" edition = "2021" license = "MPL-2.0" repository = "https://github.com/apollodao/cw-dex" -version = "0.2.0-rc.2" +version = "0.2.0-rc.3" readme = "README.md" [features] @@ -28,7 +28,7 @@ apollo-utils = { workspace = true } # Astroport astroport = { workspace = true } -astroport_v5 = { workspace = true } +astroport_v2 = { workspace = true } cw2 = { workspace = true } [dev-dependencies] diff --git a/cw-dex-astroport/src/lib.rs b/cw-dex-astroport/src/lib.rs index a08ad11..dc3466e 100644 --- a/cw-dex-astroport/src/lib.rs +++ b/cw-dex-astroport/src/lib.rs @@ -6,7 +6,7 @@ mod staking; pub use pool::AstroportPool; pub use staking::AstroportStaking; -pub use {astroport, astroport_v5}; +pub use {astroport, astroport_v2}; /// Re-export `cw-dex` for convenience pub use cw_dex; diff --git a/cw-dex-astroport/src/pool.rs b/cw-dex-astroport/src/pool.rs index 0db1c82..a30a4ca 100644 --- a/cw-dex-astroport/src/pool.rs +++ b/cw-dex-astroport/src/pool.rs @@ -4,7 +4,7 @@ use std::str::FromStr; use apollo_cw_asset::{Asset, AssetInfo, AssetInfoBase, AssetList}; use apollo_utils::iterators::IntoElementwise; -use astroport::liquidity_manager; +use astroport_v2::liquidity_manager; use cosmwasm_schema::cw_serde; use cosmwasm_std::{ coins, to_json_binary, wasm_execute, Addr, CosmosMsg, Decimal, Deps, Env, Event, @@ -14,7 +14,7 @@ use cw20::Cw20ExecuteMsg; use cw_utils::Expiration; use apollo_utils::assets::separate_natives_and_cw20s; -use astroport::asset::Asset as AstroAsset; +use astroport::asset::{Asset as AstroAsset, AssetInfo as AstroAssetInfo, PairInfo}; use astroport::factory::PairType; use astroport::pair::{ Cw20HookMsg as PairCw20HookMsg, ExecuteMsg as PairExecuteMsg, PoolResponse, @@ -47,14 +47,11 @@ impl AstroportPool { pub fn new(deps: Deps, pair_addr: Addr, liquidity_manager: Option) -> StdResult { let pair_info = deps .querier - .query_wasm_smart::( - pair_addr.clone(), - &PairQueryMsg::Pair {}, - )?; + .query_wasm_smart::(pair_addr.clone(), &PairQueryMsg::Pair {})?; // Validate pair type. We only support XYK, stable swap, and PCL pools match &pair_info.pair_type { - astroport_v5::factory::PairType::Custom(t) => match t.as_str() { + PairType::Custom(t) => match t.as_str() { "concentrated" => Ok(()), "astroport-pair-xyk-sale-tax" => Ok(()), @@ -86,7 +83,7 @@ impl AstroportPool { .into_iter() .map(astroport_v5_assetinfo_to_assetinfo) .collect(), - pair_type: astroport_v5_pairtype_to_astroport_v2_pairtype(pair_info.pair_type), + pair_type: pair_info.pair_type, liquidity_manager, }) } @@ -218,7 +215,7 @@ impl Pool for AstroportPool { msg: to_json_binary(&liquidity_manager::ExecuteMsg::ProvideLiquidity { pair_addr: self.pair_addr.to_string(), min_lp_to_receive: Some(min_out), - pair_msg: astroport::pair::ExecuteMsg::ProvideLiquidity { + pair_msg: astroport_v2::pair::ExecuteMsg::ProvideLiquidity { assets: assets_vec.into_elementwise(), slippage_tolerance: Some(Decimal::from_str(MAX_ALLOWED_SLIPPAGE)?), auto_stake: Some(false), @@ -229,7 +226,7 @@ impl Pool for AstroportPool { }), None => CosmosMsg::Wasm(WasmMsg::Execute { contract_addr: self.pair_addr.to_string(), - msg: to_json_binary(&astroport_v5::pair::ExecuteMsg::ProvideLiquidity { + msg: to_json_binary(&PairExecuteMsg::ProvideLiquidity { assets: assets_vec.iter().map(asset_to_astroport_v5_asset).collect(), slippage_tolerance: Some(Decimal::from_str(MAX_ALLOWED_SLIPPAGE)?), auto_stake: Some(false), @@ -274,7 +271,7 @@ impl Pool for AstroportPool { contract: liquidity_manager.to_string(), amount: asset.amount, msg: to_json_binary(&liquidity_manager::Cw20HookMsg::WithdrawLiquidity { - pair_msg: astroport::pair::Cw20HookMsg::WithdrawLiquidity { + pair_msg: astroport_v2::pair::Cw20HookMsg::WithdrawLiquidity { // This field is currently not used... assets: vec![], }, @@ -306,7 +303,7 @@ impl Pool for AstroportPool { } let min_assets_to_receive = if min_out.len() > 0 { - let mut min_assets: Vec = vec![]; + let mut min_assets: Vec = vec![]; // Astroport requires min_assets_to_receive to contain all assets in the pool for asset_info in &self.pool_assets { match min_out.find(asset_info) { @@ -326,7 +323,7 @@ impl Pool for AstroportPool { let withdraw_liquidity = CosmosMsg::Wasm(WasmMsg::Execute { contract_addr: self.pair_addr.to_string(), - msg: to_json_binary(&astroport_v5::pair::ExecuteMsg::WithdrawLiquidity { + msg: to_json_binary(&PairExecuteMsg::WithdrawLiquidity { assets: vec![], min_assets_to_receive, })?, @@ -359,20 +356,17 @@ impl Pool for AstroportPool { // returns at least `min_out`. let belief_price = Some(Decimal::from_ratio(offer_asset.amount, min_out)); let swap_msg = match &offer_asset.info { - AssetInfo::Native(_) => { - let asset = offer_asset.clone().into(); - wasm_execute( - self.pair_addr.to_string(), - &PairExecuteMsg::Swap { - offer_asset: asset, - belief_price, - max_spread: Some(Decimal::zero()), - to: Some(env.contract.address.to_string()), - ask_asset_info: Some(ask_asset_info.to_owned().into()), - }, - vec![offer_asset.clone().try_into()?], - ) - } + AssetInfo::Native(_) => wasm_execute( + self.pair_addr.to_string(), + &PairExecuteMsg::Swap { + offer_asset: asset_to_astroport_v5_asset(&offer_asset), + belief_price, + max_spread: Some(Decimal::zero()), + to: Some(env.contract.address.to_string()), + ask_asset_info: Some(asset_info_to_astroport_v5_assetinfo(&ask_asset_info)), + }, + vec![offer_asset.clone().try_into()?], + ), AssetInfo::Cw20(addr) => wasm_execute( addr.to_string(), &Cw20ExecuteMsg::Send { @@ -382,7 +376,7 @@ impl Pool for AstroportPool { belief_price, max_spread: Some(Decimal::zero()), to: Some(env.contract.address.to_string()), - ask_asset_info: Some(ask_asset_info.to_owned().into()), + ask_asset_info: Some(asset_info_to_astroport_v5_assetinfo(&ask_asset_info)), })?, }, vec![], @@ -398,7 +392,7 @@ impl Pool for AstroportPool { fn get_pool_liquidity(&self, deps: Deps) -> Result { let resp = self.query_pool_info(&deps.querier)?; - Ok(resp.assets.to_vec().into()) + Ok(astroport_v5_vec_asset_to_assetlist(resp.assets)) } fn simulate_provide_liquidity( @@ -412,7 +406,7 @@ impl Pool for AstroportPool { liquidity_manager.to_string(), &liquidity_manager::QueryMsg::SimulateProvide { pair_addr: self.pair_addr.to_string(), - pair_msg: astroport::pair::ExecuteMsg::ProvideLiquidity { + pair_msg: astroport_v2::pair::ExecuteMsg::ProvideLiquidity { assets: assets.into(), slippage_tolerance: Some(Decimal::from_str(MAX_ALLOWED_SLIPPAGE)?), auto_stake: Some(false), @@ -430,7 +424,7 @@ impl Pool for AstroportPool { } else { let amount: Uint128 = deps.querier.query_wasm_smart( self.pair_addr.to_string(), - &astroport_v5::pair::QueryMsg::SimulateProvide { + &PairQueryMsg::SimulateProvide { assets: assets.iter().map(asset_to_astroport_v5_asset).collect(), slippage_tolerance: Some(Decimal::from_str(MAX_ALLOWED_SLIPPAGE)?), }, @@ -461,13 +455,13 @@ impl Pool for AstroportPool { } else { deps.querier.query_wasm_smart( self.pair_addr.to_string(), - &astroport_v5::pair::QueryMsg::SimulateWithdraw { + &PairQueryMsg::SimulateWithdraw { lp_amount: lp_token.amount, }, )? }; - Ok(assets.into()) + Ok(astroport_v5_vec_asset_to_assetlist(assets)) } fn simulate_swap( @@ -481,8 +475,8 @@ impl Pool for AstroportPool { .query::(&QueryRequest::Wasm(WasmQuery::Smart { contract_addr: self.pair_addr.to_string(), msg: to_json_binary(&PairQueryMsg::Simulation { - offer_asset: offer_asset.into(), - ask_asset_info: Some(ask_asset_info.into()), + offer_asset: asset_to_astroport_v5_asset(&offer_asset), + ask_asset_info: Some(asset_info_to_astroport_v5_assetinfo(&ask_asset_info)), })?, }))? .return_amount) @@ -497,32 +491,49 @@ impl Pool for AstroportPool { } } -pub fn astroport_v5_assetinfo_to_assetinfo(asset: astroport_v5::asset::AssetInfo) -> AssetInfo { +pub fn astroport_v5_assetinfo_to_assetinfo(asset: AstroAssetInfo) -> AssetInfo { match asset { - astroport_v5::asset::AssetInfo::NativeToken { denom } => AssetInfo::native(denom), - astroport_v5::asset::AssetInfo::Token { contract_addr } => AssetInfo::cw20(contract_addr), + AstroAssetInfo::NativeToken { denom } => AssetInfo::native(denom), + AstroAssetInfo::Token { contract_addr } => AssetInfo::cw20(contract_addr), } } -pub fn asset_to_astroport_v5_asset(asset: &Asset) -> astroport_v5::asset::Asset { - match &asset.info { - AssetInfoBase::Native(denom) => astroport_v5::asset::Asset::native(denom, asset.amount), - AssetInfo::Cw20(contract_addr) => { - astroport_v5::asset::Asset::cw20(contract_addr.clone(), asset.amount) +pub fn astroport_v5_asset_to_asset(asset: AstroAsset) -> Asset { + match asset.info { + AstroAssetInfo::NativeToken { denom } => Asset::new(AssetInfo::native(denom), asset.amount), + AstroAssetInfo::Token { contract_addr } => { + Asset::new(AssetInfo::cw20(contract_addr), asset.amount) } } } -pub fn astroport_v5_pairtype_to_astroport_v2_pairtype( - pair_type: astroport_v5::factory::PairType, -) -> PairType { - match pair_type { - astroport_v5::factory::PairType::Xyk {} => PairType::Xyk {}, - astroport_v5::factory::PairType::Stable {} => PairType::Stable {}, - astroport_v5::factory::PairType::Custom(pair_type) => PairType::Custom(pair_type), +pub fn asset_to_astroport_v5_asset(asset: &Asset) -> AstroAsset { + match &asset.info { + AssetInfoBase::Native(denom) => AstroAsset::native(denom, asset.amount), + AssetInfo::Cw20(contract_addr) => AstroAsset::cw20(contract_addr.clone(), asset.amount), } } +pub fn asset_info_to_astroport_v5_assetinfo(asset: &AssetInfo) -> AstroAssetInfo { + match asset { + AssetInfo::Native(denom) => AstroAssetInfo::NativeToken { + denom: denom.clone(), + }, + AssetInfo::Cw20(contract_addr) => AstroAssetInfo::Token { + contract_addr: contract_addr.clone(), + }, + } +} + +pub fn astroport_v5_vec_asset_to_assetlist(assets: Vec) -> AssetList { + AssetList::from( + assets + .into_iter() + .map(astroport_v5_asset_to_asset) + .collect::>(), + ) +} + fn parse_address(input_string: &str) -> Result { let parts: Vec<&str> = input_string.split('/').collect(); diff --git a/cw-dex-astroport/src/staking.rs b/cw-dex-astroport/src/staking.rs index 5b3b1e0..f00f298 100644 --- a/cw-dex-astroport/src/staking.rs +++ b/cw-dex-astroport/src/staking.rs @@ -11,6 +11,8 @@ use cw20::Cw20ExecuteMsg; use cw_dex::traits::{Rewards, Stake, Staking, Unstake}; use cw_dex::CwDexError; +use crate::pool::astroport_v5_vec_asset_to_assetlist; + /// Represents staking of tokens on Astroport #[cw_serde] pub struct AstroportStaking { @@ -30,7 +32,7 @@ impl Stake for AstroportStaking { msg: to_json_binary(&Cw20ExecuteMsg::Send { contract: self.incentives.to_string(), amount, - msg: to_json_binary(&astroport_v5::incentives::Cw20Msg::Deposit { + msg: to_json_binary(&astroport::incentives::Cw20Msg::Deposit { recipient: None, })?, })?, @@ -38,7 +40,7 @@ impl Stake for AstroportStaking { }), AssetInfo::Native(denom) => CosmosMsg::Wasm(WasmMsg::Execute { contract_addr: self.incentives.to_string(), - msg: to_json_binary(&astroport_v5::incentives::ExecuteMsg::Deposit { + msg: to_json_binary(&astroport::incentives::ExecuteMsg::Deposit { recipient: None, })?, funds: coins(amount.into(), denom), @@ -68,7 +70,7 @@ impl Rewards for AstroportStaking { let claim_rewards_msg = CosmosMsg::Wasm(WasmMsg::Execute { contract_addr: self.incentives.to_string(), - msg: to_json_binary(&astroport_v5::incentives::ExecuteMsg::ClaimRewards { + msg: to_json_binary(&astroport::incentives::ExecuteMsg::ClaimRewards { lp_tokens: vec![self.lp_token.to_string()], })?, funds: vec![], @@ -102,7 +104,9 @@ impl Rewards for AstroportStaking { msg: to_json_binary(&cw20::Cw20ExecuteMsg::Send { contract: wrapper_contract.to_string(), amount: cw20.amount, - msg: to_json_binary(&astroport::native_coin_wrapper::Cw20HookMsg::Unwrap {})?, + msg: to_json_binary( + &astroport_v2::native_coin_wrapper::Cw20HookMsg::Unwrap {}, + )?, })?, funds: vec![], }); @@ -120,7 +124,7 @@ impl Rewards for AstroportStaking { let pending_rewards: Vec = querier .query::>(&QueryRequest::Wasm(WasmQuery::Smart { contract_addr: self.incentives.to_string(), - msg: to_json_binary(&astroport_v5::incentives::QueryMsg::PendingRewards { + msg: to_json_binary(&astroport::incentives::QueryMsg::PendingRewards { lp_token: self.lp_token.to_string(), user: user.to_string(), })?, @@ -129,7 +133,7 @@ impl Rewards for AstroportStaking { .filter(|asset| !asset.amount.is_zero()) //TODO: Is this necessary? .collect(); - Ok(pending_rewards.into()) + Ok(astroport_v5_vec_asset_to_assetlist(pending_rewards)) } } @@ -137,7 +141,7 @@ impl Unstake for AstroportStaking { fn unstake(&self, _deps: Deps, _env: &Env, amount: Uint128) -> Result { let unstake_msg = CosmosMsg::Wasm(WasmMsg::Execute { contract_addr: self.incentives.to_string(), - msg: to_json_binary(&astroport_v5::incentives::ExecuteMsg::Withdraw { + msg: to_json_binary(&astroport::incentives::ExecuteMsg::Withdraw { lp_token: self.lp_token.to_string(), amount, })?, diff --git a/cw-dex-astroport/tests/astroport_tests.rs b/cw-dex-astroport/tests/astroport_tests.rs index d476e03..4e79cc5 100644 --- a/cw-dex-astroport/tests/astroport_tests.rs +++ b/cw-dex-astroport/tests/astroport_tests.rs @@ -3,9 +3,9 @@ mod tests { use apollo_utils::assets::separate_natives_and_cw20s; use apollo_utils::coins::coin_from_str; use apollo_utils::submessages::{find_event, parse_attribute_value}; + use astroport::asset::{Asset as AstroportAsset, PairInfo}; use astroport::factory::PairType; - use astroport_v5::asset::{Asset as AstroportAsset, PairInfo}; - use astroport_v5::pair::{PoolResponse, QueryMsg as PairQueryMsg}; + use astroport::pair::{PoolResponse, QueryMsg as PairQueryMsg}; use cosmwasm_std::{assert_approx_eq, coin, coins, Addr, Coin, Empty, SubMsgResponse, Uint128}; use cw_dex_astroport::AstroportPool; use cw_dex_test_contract::msg::{AstroportExecuteMsg, ExecuteMsg, QueryMsg}; @@ -612,7 +612,7 @@ mod tests { for (incentive, periods) in incentives.clone() { // Increase allowance for cw20 incentives and construct funds let funds = match incentive.info.clone() { - astroport_v5::asset::AssetInfo::Token { contract_addr } => { + astroport::asset::AssetInfo::Token { contract_addr } => { // Increase allowance for incentives contract wasm.execute( contract_addr.as_str(), @@ -627,15 +627,15 @@ mod tests { .unwrap(); vec![] } - astroport_v5::asset::AssetInfo::NativeToken { denom } => { + astroport::asset::AssetInfo::NativeToken { denom } => { vec![coin(incentive.amount.u128(), &denom)] } }; wasm.execute( &astroport_contracts.incentives.address, - &astroport_v5::incentives::ExecuteMsg::Incentivize { + &astroport::incentives::ExecuteMsg::Incentivize { lp_token: lp_token_denom.clone(), - schedule: astroport_v5::incentives::InputSchedule { + schedule: astroport::incentives::InputSchedule { reward: incentive, duration_periods: periods, }, @@ -662,7 +662,7 @@ mod tests { let pending_rewards: Vec = wasm .query( &astroport_contracts.incentives.address, - &astroport_v5::incentives::QueryMsg::PendingRewards { + &astroport::incentives::QueryMsg::PendingRewards { lp_token: lp_token_denom.clone(), user: testing_contract_addr.clone(), }, @@ -681,10 +681,10 @@ mod tests { for asset in pending_rewards.clone() { // Convert astroport asset info to asset info let asset_info = match asset.info { - astroport_v5::asset::AssetInfo::Token { contract_addr } => { + astroport::asset::AssetInfo::Token { contract_addr } => { AssetInfo::Cw20(contract_addr) } - astroport_v5::asset::AssetInfo::NativeToken { denom } => AssetInfo::Native(denom), + astroport::asset::AssetInfo::NativeToken { denom } => AssetInfo::Native(denom), }; let amount = cw_dex_pending_rewards.find(&asset_info).unwrap().amount; diff --git a/cw-dex/src/implementations/astroport/pool.rs b/cw-dex/src/implementations/astroport/pool.rs index 1c0606a..39f6fb7 100644 --- a/cw-dex/src/implementations/astroport/pool.rs +++ b/cw-dex/src/implementations/astroport/pool.rs @@ -4,7 +4,7 @@ use std::str::FromStr; use apollo_cw_asset::{Asset, AssetInfo, AssetInfoBase, AssetList}; use apollo_utils::iterators::IntoElementwise; -use astroport::liquidity_manager; +use astroport_v2::liquidity_manager; use cosmwasm_schema::cw_serde; use cosmwasm_std::{ to_json_binary, wasm_execute, Addr, CosmosMsg, Decimal, Deps, Env, Event, QuerierWrapper, @@ -16,13 +16,13 @@ use cw_utils::Expiration; use crate::traits::Pool; use crate::CwDexError; use apollo_utils::assets::separate_natives_and_cw20s; -use astroport::asset::{Asset as AstroAsset, PairInfo}; -use astroport::factory::PairType; -use astroport::pair::{ +use astroport_v2::asset::{Asset as AstroAsset, PairInfo}; +use astroport_v2::factory::PairType; +use astroport_v2::pair::{ Cw20HookMsg as PairCw20HookMsg, ExecuteMsg as PairExecuteMsg, PoolResponse, QueryMsg as PairQueryMsg, SimulationResponse, MAX_ALLOWED_SLIPPAGE, }; -use astroport::querier::query_supply; +use astroport_v2::querier::query_supply; /// Represents an AMM pool on Astroport #[cw_serde] diff --git a/test-helpers/Cargo.toml b/test-helpers/Cargo.toml index 50f5241..2f639a5 100644 --- a/test-helpers/Cargo.toml +++ b/test-helpers/Cargo.toml @@ -37,7 +37,6 @@ cw-dex-test-contract = { workspace = true } astroport-test-contract = { workspace = true, optional = true } cw-it = { workspace = true } astroport = { workspace = true } -astroport_v5 = { workspace = true } +astroport_v2 = { workspace = true } cw20 = { workspace = true } cw20-base = { workspace = true } - diff --git a/test-helpers/src/astroport.rs b/test-helpers/src/astroport.rs index 529ca7c..fb0b922 100644 --- a/test-helpers/src/astroport.rs +++ b/test-helpers/src/astroport.rs @@ -3,7 +3,6 @@ use apollo_utils::assets::separate_natives_and_cw20s; use astroport::asset::{Asset as AstroAsset, AssetInfo as AstroAssetInfo}; use astroport::factory::PairType; use astroport::pair::{ExecuteMsg as PairExecuteMsg, StablePoolParams}; -use astroport_v5::factory::PairType as AstroportV5PairType; use cosmwasm_std::{to_json_binary, Addr, Coin, Decimal, Uint128}; use cw20::{Cw20ExecuteMsg, MinterResponse}; use cw20_base::msg::InstantiateMsg as Cw20InstantiateMsg; @@ -214,16 +213,11 @@ pub fn setup_pool_and_test_contract<'a>( }, _ => None, }; - let astroport_v5_pair_type = match &pool_type { - PairType::Xyk {} => AstroportV5PairType::Xyk {}, - PairType::Stable {} => AstroportV5PairType::Stable {}, - PairType::Custom(t) => AstroportV5PairType::Custom(t.to_string()), - }; let (pair_addr, lp_token) = create_astroport_pair( runner, &astroport_contracts.factory.address, - astroport_v5_pair_type, + pool_type, [astro_asset_infos[0].clone(), astro_asset_infos[1].clone()], init_params, admin, @@ -251,6 +245,7 @@ pub fn setup_pool_and_test_contract<'a>( slippage_tolerance: Some(Decimal::from_str("0.02").unwrap()), auto_stake: Some(false), receiver: None, + min_lp_to_receive: None, }; let (native_coins, _) = separate_natives_and_cw20s(&asset_list); let res = wasm diff --git a/test-helpers/src/helpers.rs b/test-helpers/src/helpers.rs index 349b936..db130da 100644 --- a/test-helpers/src/helpers.rs +++ b/test-helpers/src/helpers.rs @@ -75,7 +75,7 @@ pub fn cw20_transfer<'a, R: Runner<'a>>( ) } -/// Sen a cw_asset::Asset to a recipient +/// Send a cw_asset::Asset to a recipient pub fn send_asset<'a, R: Runner<'a>>( runner: &'a R, asset: Asset, @@ -173,5 +173,6 @@ pub fn common_pcl_params() -> ConcentratedPoolParams { price_scale: Decimal::one(), ma_half_time: 600, track_asset_balances: None, + fee_share: None, } }