Skip to content

Commit

Permalink
fix: omit astroport whitelist
Browse files Browse the repository at this point in the history
  • Loading branch information
ApolloGie committed Jun 12, 2024
1 parent bbcee81 commit 7458386
Show file tree
Hide file tree
Showing 2 changed files with 158 additions and 107 deletions.
49 changes: 25 additions & 24 deletions src/astroport/robot.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -23,7 +23,7 @@ where
admin: &SigningAccount,
code_ids: &HashMap<String, u64>,
) -> AstroportContracts {
crate::astroport::utils::instantiate_astroport(runner, admin, code_ids)
crate::astroport_v5::utils::instantiate_astroport(runner, admin, code_ids)
}

/// Uploads and instantiates the astroport contracts, returning a struct containing the
Expand All @@ -33,7 +33,7 @@ where
contracts: ContractMap,
admin: &SigningAccount,
) -> AstroportContracts {
crate::astroport::utils::setup_astroport(runner, contracts, admin)
crate::astroport_v5::utils::setup_astroport(runner, contracts, admin)
}

fn increase_cw20_allowance(
Expand Down Expand Up @@ -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;

Expand All @@ -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()
Expand All @@ -152,7 +152,7 @@ where
fn query_native_coin_registry(&self, denom: &str) -> RunnerResult<u8> {
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)
Expand All @@ -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();
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -280,13 +281,13 @@ where
pair_addr: &str,
offer_asset: Asset,
ask_asset_info: Option<AssetInfo>,
) -> 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()
}

Expand Down Expand Up @@ -321,7 +322,7 @@ where
}
};

let msg = astroport::pair::ExecuteMsg::Swap {
let msg = astroport_v5::pair::ExecuteMsg::Swap {
offer_asset,
ask_asset_info,
belief_price,
Expand All @@ -340,7 +341,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()
Expand Down Expand Up @@ -424,7 +425,7 @@ where
mod tests {
use std::str::FromStr;

use astroport::{
use astroport_v5::{
asset::{Asset, AssetInfo},
factory::PairType,
pair::StablePoolParams,
Expand All @@ -435,7 +436,7 @@ mod tests {

use super::AstroportTestRobot;
use crate::{
astroport::utils::{cw20_info, native_info, AstroportContracts},
astroport_v5::utils::{cw20_info, native_info, AstroportContracts},
robot::TestRobot,
ContractMap, OwnedTestRunner, TestRunner,
};
Expand Down Expand Up @@ -488,7 +489,7 @@ mod tests {

/// Get astroport artifacts already from disk
pub fn get_contracts(test_runner: &TestRunner) -> ContractMap {
crate::astroport::utils::get_local_contracts(
crate::astroport_v5::utils::get_local_contracts(
test_runner,
&ARTIFACTS_PATH,
APPEND_ARCH,
Expand Down
Loading

0 comments on commit 7458386

Please sign in to comment.