Skip to content

Commit

Permalink
Fix astro deps in incentives. (#395)
Browse files Browse the repository at this point in the history
  • Loading branch information
piobab authored Jun 4, 2024
1 parent 9ee7d28 commit 96715dd
Show file tree
Hide file tree
Showing 19 changed files with 750 additions and 25 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ anyhow = "1.0.80"
apollo-cw-asset = { version = "0.1.2", features = ["astroport"] }
apollo-utils = "0.1.2"
astroport = "2.8.0"
# TODO: update with official release once ready
astroport-v5 = { package = "astroport", version = "=5.0.0-rc.1-tokenfactory" }
bech32 = "0.9.1"
cosmwasm-schema = "1.5.3"
cosmwasm-std = "1.5.4"
Expand Down
3 changes: 1 addition & 2 deletions contracts/incentives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,12 @@ crate-type = ["cdylib", "rlib"]
doctest = false

[features]
astroport = ["cw-it/astroport"]
# for more explicit tests, cargo test --features=backtraces
backtraces = ["cosmwasm-std/backtraces", "mars-testing/backtraces", "mars-utils/backtraces", "mars-red-bank/backtraces"]
library = []

[dependencies]
astroport = "=5.0.0-rc.1-tokenfactory"
astroport-v5 = { workspace = true }
cosmwasm-schema = { workspace = true }
cosmwasm-std = { workspace = true }
cw2 = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion contracts/incentives/src/astroport_incentives.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::collections::HashMap;

use astroport::incentives::ExecuteMsg;
use astroport_v5::incentives::ExecuteMsg;
use cosmwasm_std::{
ensure_eq, to_json_binary, BankMsg, Coin, CosmosMsg, Decimal, DepsMut, Env, Event, MessageInfo,
Order::Ascending, Response, StdResult, Storage, Uint128, WasmMsg,
Expand Down
2 changes: 1 addition & 1 deletion contracts/incentives/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::{
collections::HashMap,
};

use astroport::incentives::ExecuteMsg;
use astroport_v5::incentives::ExecuteMsg;
use cosmwasm_std::{
coin, to_json_binary, Addr, BlockInfo, Coin, CosmosMsg, Decimal, Deps, MessageInfo, Order,
OverflowError, OverflowOperation, QuerierWrapper, StdError, StdResult, Storage, Uint128,
Expand Down
4 changes: 2 additions & 2 deletions contracts/incentives/src/query.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::collections::HashMap;

use astroport::asset::Asset;
use astroport_v5::asset::Asset;
use cosmwasm_std::{
Addr, Coin, Coins, Decimal, Deps, Env, Order, Order::Ascending, StdResult, Uint128,
};
Expand Down Expand Up @@ -102,7 +102,7 @@ pub fn query_unclaimed_astroport_rewards(
) -> Result<Vec<Coin>, ContractError> {
let result: Vec<Asset> = deps.querier.query_wasm_smart(
astroport_incentives_addr,
&astroport::incentives::QueryMsg::PendingRewards {
&astroport_v5::incentives::QueryMsg::PendingRewards {
lp_token: lp_denom.to_string(),
user: mars_incentives_addr.to_string(),
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use astroport_v5::asset::Asset;
use cosmwasm_std::{
testing::{mock_env, mock_info, MockApi},
Addr, Coin, Deps, DepsMut, Env, MemoryStorage, OwnedDeps, Response, Uint128,
};
use cw_it::astroport::astroport_v3::asset::Asset;
use mars_incentives::{contract::execute, query, state::ASTRO_TOTAL_LP_DEPOSITS, ContractError};
use mars_testing::{assert_eq_vec, MarsMockQuerier};
use mars_types::{
Expand Down
3 changes: 1 addition & 2 deletions contracts/v2-zapper/astroport/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ library = []
[dependencies]
apollo-cw-asset = { workspace = true }
apollo-utils = { workspace = true }
# TODO: update with official release once ready
astroport = "=5.0.0-rc.1-tokenfactory"
astroport-v5 = { workspace = true }
cosmwasm-std = { workspace = true }
cw2 = { workspace = true }
cw-dex = { workspace = true }
Expand Down
10 changes: 5 additions & 5 deletions contracts/v2-zapper/astroport/src/lp_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::str::FromStr;

use apollo_cw_asset::{Asset, AssetInfo, AssetInfoBase, AssetList};
use apollo_utils::assets::assert_only_native_coins;
use astroport::{
use astroport_v5::{
asset::{Asset as AstroAsset, AssetInfo as AstroAssetInfo, PairInfo},
factory::PairType,
pair::{PoolResponse, QueryMsg as PairQueryMsg, MAX_ALLOWED_SLIPPAGE},
Expand Down Expand Up @@ -133,7 +133,7 @@ impl Pool for AstroportLpPool {
// Create the provide liquidity message
let provide_liquidity_msg = CosmosMsg::Wasm(WasmMsg::Execute {
contract_addr: self.pair_addr.to_string(),
msg: to_json_binary(&astroport::pair::ExecuteMsg::ProvideLiquidity {
msg: to_json_binary(&astroport_v5::pair::ExecuteMsg::ProvideLiquidity {
assets: astro_assets,
slippage_tolerance: Some(Decimal::from_str(MAX_ALLOWED_SLIPPAGE)?),
auto_stake: Some(false),
Expand Down Expand Up @@ -163,7 +163,7 @@ impl Pool for AstroportLpPool {

let withdraw_liquidity = CosmosMsg::Wasm(WasmMsg::Execute {
contract_addr: self.pair_addr.to_string(),
msg: to_json_binary(&astroport::pair::ExecuteMsg::WithdrawLiquidity {
msg: to_json_binary(&astroport_v5::pair::ExecuteMsg::WithdrawLiquidity {
// This field is currently not used...
assets: vec![],
min_assets_to_receive: Some(astro_assets),
Expand Down Expand Up @@ -211,7 +211,7 @@ impl Pool for AstroportLpPool {

let amount: Uint128 = deps.querier.query_wasm_smart(
self.pair_addr.to_string(),
&astroport::pair::QueryMsg::SimulateProvide {
&astroport_v5::pair::QueryMsg::SimulateProvide {
assets: astro_assets,
slippage_tolerance: Some(Decimal::from_str(MAX_ALLOWED_SLIPPAGE)?),
},
Expand All @@ -232,7 +232,7 @@ impl Pool for AstroportLpPool {
) -> Result<AssetList, CwDexError> {
let assets: Vec<AstroAsset> = deps.querier.query_wasm_smart(
self.pair_addr.to_string(),
&astroport::pair::QueryMsg::SimulateWithdraw {
&astroport_v5::pair::QueryMsg::SimulateWithdraw {
lp_amount: lp_token.amount,
},
)?;
Expand Down
1 change: 1 addition & 0 deletions packages/testing/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ osmosis-test-tube = ["cw-it/osmosis-test-tube"]
[dependencies]
anyhow = { workspace = true }
astroport = { workspace = true, optional = true }
astroport-v5 = { workspace = true }
cosmwasm-std = { workspace = true }
cosmwasm-schema = { workspace = true }
cw721 = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion packages/testing/src/astroport_incentives_querier.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::collections::HashMap;

use astroport_v5::{asset::Asset, incentives::QueryMsg};
use cosmwasm_std::{to_json_binary, Addr, Binary, ContractResult, QuerierResult, Uint128};
use cw_it::astroport::astroport_v3::{asset::Asset, incentives::QueryMsg};

pub struct AstroportIncentivesQuerier {
/// Holds mock rewards, key is (user, lp_token_denom)
Expand Down
2 changes: 1 addition & 1 deletion packages/testing/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

extern crate core;

#[cfg(feature = "astroport")]
pub mod astroport_incentives_querier;
#[cfg(feature = "astroport")]
pub mod astroport_swapper;
mod cosmwasm_pool_querier;
/// cosmwasm_std::testing overrides and custom test helpers
Expand Down
4 changes: 2 additions & 2 deletions packages/testing/src/mars_mock_querier.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use astroport_v5::asset::Asset;
use cosmwasm_std::{
from_json,
testing::{MockQuerier, MOCK_CONTRACT_ADDR},
Addr, Coin, Decimal, Empty, Querier, QuerierResult, QueryRequest, StdResult, SystemError,
SystemResult, Uint128, WasmQuery,
};
use cw_it::astroport::{astroport_v3, astroport_v3::asset::Asset};
use ica_oracle::msg::RedemptionRateResponse;
use mars_oracle_osmosis::DowntimeDetector;
use mars_types::{address_provider, incentives, oracle, params::AssetParams, red_bank};
Expand Down Expand Up @@ -259,7 +259,7 @@ impl MarsMockQuerier {

// Astroport Incentive Queries
if let Ok(astroport_incentives_query) =
from_json::<astroport_v3::incentives::QueryMsg>(msg)
from_json::<astroport_v5::incentives::QueryMsg>(msg)
{
return self
.astroport_incentives_querier
Expand Down
35 changes: 35 additions & 0 deletions schemas/mars-address-provider/mars-address-provider.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,13 @@
"enum": [
"swapper"
]
},
{
"description": "Astroport incentives contract",
"type": "string",
"enum": [
"astroport_incentives"
]
}
]
},
Expand Down Expand Up @@ -312,6 +319,13 @@
"enum": [
"swapper"
]
},
{
"description": "Astroport incentives contract",
"type": "string",
"enum": [
"astroport_incentives"
]
}
]
}
Expand Down Expand Up @@ -384,6 +398,13 @@
"enum": [
"swapper"
]
},
{
"description": "Astroport incentives contract",
"type": "string",
"enum": [
"astroport_incentives"
]
}
]
}
Expand Down Expand Up @@ -459,6 +480,13 @@
"enum": [
"swapper"
]
},
{
"description": "Astroport incentives contract",
"type": "string",
"enum": [
"astroport_incentives"
]
}
]
}
Expand Down Expand Up @@ -534,6 +562,13 @@
"enum": [
"swapper"
]
},
{
"description": "Astroport incentives contract",
"type": "string",
"enum": [
"astroport_incentives"
]
}
]
}
Expand Down
Loading

0 comments on commit 96715dd

Please sign in to comment.