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 11, 2024
1 parent bbcee81 commit c6534b5
Showing 1 changed file with 106 additions and 52 deletions.
158 changes: 106 additions & 52 deletions src/astroport/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,34 @@ 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;
use osmosis_std::types::osmosis::tokenfactory::v1beta1::{
MsgCreateDenom, MsgCreateDenomResponse, MsgMint, MsgMintResponse, QueryParamsRequest,
QueryParamsResponse,
};
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,
VestingSchedule, VestingSchedulePoint,
};
use astroport_v5::staking::InstantiateMsg as StakingInstantiateMsg;
use cosmwasm_schema::cw_serde;
use cosmwasm_std::{to_json_binary, Addr, Binary, Coin, Event, Uint128, Uint64};
use cosmwasm_std::{to_json_binary, Addr, Binary, Coin, Event, Uint128};
use cw20::{BalanceResponse, Cw20Coin, Cw20ExecuteMsg, Cw20QueryMsg, MinterResponse};
use test_tube::{Account, Bank, Module, Runner, SigningAccount, Wasm};

Expand All @@ -39,21 +45,22 @@ pub fn astroport_asset_info_to_astroport_v5_asset_info(
}
}

pub const ASTROPORT_CONTRACT_NAMES: [&str; 13] = [
pub const ASTROPORT_CONTRACT_NAMES: [&str; 12] = [
"astroport_token",
"astroport_native_coin_registry",
"astroport_factory",
"astroport_generator",
// "astroport_generator",
"astroport_maker",
"astroport_pair_stable",
"astroport_pair",
"astroport_router",
"astroport_staking",
"astroport_vesting",
"astroport_whitelist",
// "astroport_whitelist",
// "astroport_liquidity_manager",
"astroport_pair_concentrated",
"astroport_incentives",
"astroport_tokenfactory_tracker",
];

#[cw_serde]
Expand All @@ -72,15 +79,15 @@ impl Contract {
pub struct AstroportContracts {
pub factory: Contract,
pub coin_registry: Contract,
pub generator: 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 whitelist: Contract,
// pub liquidity_manager: Contract,
pub incentives: Contract,
}
Expand Down Expand Up @@ -205,7 +212,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,
},
Expand Down Expand Up @@ -256,34 +264,34 @@ where
.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 generator ...");
// let generator = wasm
// .instantiate(
// code_ids["astroport_generator"],
// &GeneratorInstantiateMsg {
// owner: admin.address(),
// // whitelist_code_id: code_ids["astroport_whitelist"],
// whitelist_code_id: 0,
// 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
Expand All @@ -299,10 +307,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
Expand All @@ -314,7 +322,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,
Expand All @@ -325,17 +333,64 @@ where
)
.unwrap();

// Instantiate tracker
println!("Uploading tracker...");
let tracker_code_id = code_ids.get("astroport_tokenfactory_tracker");
// 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,
// deposit_token_denom: todo!(),
// tracking_admin: todo!(),
// tracking_code_id: todo!(),
// token_factory_addr: todo!(),
// },
// 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<MsgCreateDenomResponse> =
app.execute(msg, MsgCreateDenom::TYPE_URL, &admin).unwrap();

let staking_denom = res.data.new_token_denom;
let msg = MsgMint {
sender: admin.address(),
amount: Some(Coin {
denom: staking_denom,
amount: 1e18,
}),
mint_to_address: admin.address(),
};
let res: ExecuteResponse<MsgMintResponse> =
app.execute(msg, MsgMint::TYPE_URL, &admin).unwrap();

println!("res: {:?}", res);
// 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,
deposit_token_denom: "factory/astro".to_string(),
tracking_admin: admin.address(),
tracking_code_id: code_ids["astroport_tokenfactory_tracker"],
token_factory_addr: "tokenfactory1".to_string(),
},
Some(&admin.address()), // contract admin used for migration
Some("Astroport Staking"), // contract label
Expand Down Expand Up @@ -402,7 +457,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,
Expand All @@ -418,7 +473,7 @@ where

AstroportContracts {
factory: Contract::new(factory, code_ids["astroport_factory"]),
generator: Contract::new(generator, code_ids["astroport_generator"]),
// 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"]),
Expand All @@ -427,7 +482,7 @@ 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"]),
// whitelist: Contract::new(String::from(""), code_ids["astroport_whitelist"]),
// liquidity_manager: Contract::new(
// liquidity_manager,
// code_ids["astroport_liquidity_manager"],
Expand Down Expand Up @@ -699,12 +754,11 @@ pub fn get_astroport_multitest_contracts() -> HashMap<String, ContractType> {
"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_generator",
"astroport_staking",
"astroport_factory",
"astroport_pair_stable",
Expand Down

0 comments on commit c6534b5

Please sign in to comment.