diff --git a/.github/workflows/cc.yml b/.github/workflows/cc.yml index e9e3aee..cf7c23e 100644 --- a/.github/workflows/cc.yml +++ b/.github/workflows/cc.yml @@ -16,4 +16,4 @@ jobs: uses: actions/checkout@v3 - name: Check all commit messages for adherence - uses: bilalshaikh42/action-conventional-commits@v2.0.1 + uses: webiny/action-conventional-commits@v1.3.0 diff --git a/Cargo.lock b/Cargo.lock index 14e143b..91cfe2e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -887,12 +887,11 @@ dependencies = [ [[package]] name = "cw-dex" -version = "0.5.2" +version = "0.5.3" dependencies = [ "apollo-cw-asset", "apollo-utils", "astroport 2.9.0", - "astroport 3.11.1", "cosmwasm-schema", "cosmwasm-std", "cw-dex-test-contract", @@ -910,7 +909,7 @@ dependencies = [ [[package]] name = "cw-dex-astroport" -version = "0.1.0" +version = "0.1.1" dependencies = [ "apollo-cw-asset", "apollo-utils", @@ -976,9 +975,9 @@ dependencies = [ [[package]] name = "cw-it" -version = "0.3.0-rc.4" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8323a657163a204179a9a7a4a418794aa71f9c789b58b8c91974e2691f7db408" +checksum = "e1bd88c423ae22eefe99b1b008c8b2d7936def56cfb0c65f6ccf634a0988d7b0" dependencies = [ "anyhow", "apollo-cw-multi-test", @@ -1642,9 +1641,9 @@ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "hermit-abi" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0c62115964e08cb8039170eb33c1d0e2388a256930279edca206fff675f82c3" +checksum = "bd5256b483761cd23699d0da46cc6fd2ee3be420bbe6d020ae4a091e70b7e9fd" [[package]] name = "hex" diff --git a/Cargo.toml b/Cargo.toml index ab15557..f4a2de1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,7 +26,7 @@ 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 = "0.3.0-rc.4" +cw-it = "0.3.0" apollo-utils = "0.1.0" astroport = "2.9.0" astroport_v3 = { package = "astroport", version = "3.11.1" } @@ -34,8 +34,8 @@ test-case = "3.0.0" proptest = "1.0.0" # Workspace packages -cw-dex = { path = "cw-dex", version = "0.5.2" } -cw-dex-astroport = { path = "cw-dex-astroport", version = "0.1.0" } +cw-dex = { path = "cw-dex", version = "0.5.3" } +cw-dex-astroport = { path = "cw-dex-astroport", version = "0.1.1" } cw-dex-osmosis = { path = "cw-dex-osmosis", version = "0.1.0" } cw-dex-test-contract = { path = "test-contracts/package" } astroport-test-contract = { path = "test-contracts/astroport-test-contract" } diff --git a/cw-dex-astroport/Cargo.toml b/cw-dex-astroport/Cargo.toml index 47fa60b..4122a02 100644 --- a/cw-dex-astroport/Cargo.toml +++ b/cw-dex-astroport/Cargo.toml @@ -5,12 +5,12 @@ 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.1.0" +version = "0.1.1" readme = "README.md" [features] default = [] -osmosis-test-tube = ["cw-it/osmosis-test-tube", "cw-dex-test-helpers/osmosis-test-tube"] +osmosis-test-tube = ["cw-it/osmosis-test-tube"] # backtraces = ["cosmwasm-std/backtraces", "osmosis-std/backtraces"] [package.metadata.docs.rs] @@ -35,7 +35,7 @@ cw2 = { workspace = true } cw-it = { workspace = true, features = ["astroport", "multi-test", "astroport-multi-test"] } test-case = { workspace = true } cw-dex-test-contract = { workspace = true } -cw-dex-test-helpers = { workspace = true, features = ["astroport"] } +cw-dex-test-helpers = { workspace = true, features = ["astroport", "osmosis-test-tube"] } proptest = { workspace = true } cw20-base = { workspace = true } cw20 = { workspace = true } diff --git a/cw-dex-astroport/README.md b/cw-dex-astroport/README.md new file mode 100644 index 0000000..a40aed4 --- /dev/null +++ b/cw-dex-astroport/README.md @@ -0,0 +1,3 @@ +# cw-dex-astroport + +This crate contains [cw-dex](https://crates.io/crates/cw-dex) implementations for Astroport. diff --git a/cw-dex/Cargo.toml b/cw-dex/Cargo.toml index ab29b55..81022c8 100644 --- a/cw-dex/Cargo.toml +++ b/cw-dex/Cargo.toml @@ -5,14 +5,14 @@ edition = "2021" license = "MPL-2.0" name = "cw-dex" repository = "https://github.com/apollodao/cw-dex" -version = "0.5.2" +version = "0.5.3" readme = "README.md" [features] default = [] osmosis = ["osmosis-std", "osmosis-test-tube", "cw-it/osmosis"] osmosis-test-tube = ["cw-it/osmosis-test-tube"] -astroport = ["dep:astroport", "dep:astroport_v3", "apollo-cw-asset/astroport", "dep:cw2", "cw-it/astroport", "cw-it/astroport-multi-test"] +astroport = ["dep:astroport", "apollo-cw-asset/astroport", "dep:cw2", "cw-it/astroport", "cw-it/astroport-multi-test"] # backtraces = ["cosmwasm-std/backtraces", "osmosis-std/backtraces"] [package.metadata.docs.rs] @@ -33,7 +33,6 @@ osmosis-std = { version = "0.19.2", optional = true } # Astroport astroport = { workspace = true, optional = true } -astroport_v3 = { workspace = true, optional = true } cw2 = { workspace = true, optional = true } [dev-dependencies] diff --git a/cw-dex/src/implementations/astroport/staking.rs b/cw-dex/src/implementations/astroport/staking.rs index 28bf9e9..7e10529 100644 --- a/cw-dex/src/implementations/astroport/staking.rs +++ b/cw-dex/src/implementations/astroport/staking.rs @@ -8,11 +8,11 @@ use cosmwasm_std::{ }; use cw20::Cw20ExecuteMsg; -use apollo_cw_asset::AssetList; +use apollo_cw_asset::{Asset, AssetInfo, AssetList}; use astroport::asset::Asset as AstroAsset; -use astroport_v3::incentives::{ - Cw20Msg as IncentivesCw20Msg, ExecuteMsg as IncentivesExecuteMsg, - QueryMsg as IncentivesQueryMsg, +use astroport::generator::{ + Cw20HookMsg as GeneratorCw20HookMsg, ExecuteMsg as GeneratorExecuteMsg, PendingTokenResponse, + QueryMsg as GeneratorQueryMsg, }; use crate::traits::{Rewards, Stake, Staking, Unstake}; @@ -23,8 +23,10 @@ use crate::CwDexError; pub struct AstroportStaking { /// The address of the associated LP token contract pub lp_token_addr: Addr, - /// The address of the astroport incentives contract - pub incentives: Addr, + /// The address of the associated generator contract + pub generator_addr: Addr, + /// The address of the ASTRO token contract + pub astro_token: AssetInfo, } impl Staking for AstroportStaking {} @@ -34,9 +36,9 @@ impl Stake for AstroportStaking { let stake_msg = CosmosMsg::Wasm(WasmMsg::Execute { contract_addr: self.lp_token_addr.to_string(), msg: to_json_binary(&Cw20ExecuteMsg::Send { - contract: self.incentives.to_string(), + contract: self.generator_addr.to_string(), amount, - msg: to_json_binary(&IncentivesCw20Msg::Deposit { recipient: None })?, + msg: to_json_binary(&GeneratorCw20HookMsg::Deposit {})?, })?, funds: vec![], }); @@ -44,7 +46,7 @@ impl Stake for AstroportStaking { let event = Event::new("apollo/cw-dex/stake") .add_attribute("type", "astroport_staking") .add_attribute("asset", self.lp_token_addr.to_string()) - .add_attribute("incentives contract address", self.incentives.to_string()); + .add_attribute("generator_address", self.generator_addr.to_string()); Ok(Response::new().add_message(stake_msg).add_event(event)) } @@ -63,8 +65,8 @@ impl Rewards for AstroportStaking { } let claim_rewards_msg = CosmosMsg::Wasm(WasmMsg::Execute { - contract_addr: self.incentives.to_string(), - msg: to_json_binary(&IncentivesExecuteMsg::ClaimRewards { + contract_addr: self.generator_addr.to_string(), + msg: to_json_binary(&GeneratorExecuteMsg::ClaimRewards { lp_tokens: vec![self.lp_token_addr.to_string()], })?, funds: vec![], @@ -113,17 +115,25 @@ impl Rewards for AstroportStaking { querier: &QuerierWrapper, user: &Addr, ) -> Result { - let pending_rewards: Vec = querier - .query::>(&QueryRequest::Wasm(WasmQuery::Smart { - contract_addr: self.incentives.to_string(), - msg: to_json_binary(&IncentivesQueryMsg::PendingRewards { - lp_token: self.lp_token_addr.to_string(), - user: user.to_string(), - })?, - }))? + let PendingTokenResponse { + pending: pending_astro, + pending_on_proxy, + } = querier.query(&QueryRequest::Wasm(WasmQuery::Smart { + contract_addr: self.generator_addr.to_string(), + msg: to_json_binary(&GeneratorQueryMsg::PendingToken { + lp_token: self.lp_token_addr.to_string(), + user: user.to_string(), + })?, + }))?; + + let pending_rewards: Vec = pending_on_proxy + .unwrap_or_default() .into_iter() - .filter(|asset| !asset.amount.is_zero()) //TODO: Is this necessary? - .collect(); + .chain(vec![ + Asset::new(self.astro_token.clone(), pending_astro).into() + ]) + .filter(|asset| !asset.amount.is_zero()) + .collect::>(); Ok(pending_rewards.into()) } @@ -132,8 +142,8 @@ impl Rewards for AstroportStaking { 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(&IncentivesExecuteMsg::Withdraw { + contract_addr: self.generator_addr.to_string(), + msg: to_json_binary(&GeneratorExecuteMsg::Withdraw { lp_token: self.lp_token_addr.to_string(), amount, })?, diff --git a/test-contracts/astroport-test-contract/src/contract.rs b/test-contracts/astroport-test-contract/src/contract.rs index b2c2a86..c6608e5 100644 --- a/test-contracts/astroport-test-contract/src/contract.rs +++ b/test-contracts/astroport-test-contract/src/contract.rs @@ -29,7 +29,6 @@ pub fn instantiate( deps.storage, &AstroportStaking { lp_token_addr: Addr::unchecked(msg.lp_token_addr), - incentives: Addr::unchecked(msg.incentives_addr), }, )?;