diff --git a/Cargo.lock b/Cargo.lock index 7fc3ff2..5dcfa23 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -988,7 +988,7 @@ dependencies = [ [[package]] name = "cw-it" -version = "0.4.0-rc.5" +version = "0.4.0-rc.6" dependencies = [ "anyhow", "apollo-cw-multi-test", diff --git a/Cargo.toml b/Cargo.toml index 5324957..389a61c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw-it" -version = "0.4.0-rc.5" +version = "0.4.0-rc.6" authors = ["Pacman ", "Sturdy "] edition = "2021" license = "MPL-2.0" diff --git a/src/astroport/robot.rs b/src/astroport/robot.rs index 536e9ae..40d7088 100644 --- a/src/astroport/robot.rs +++ b/src/astroport/robot.rs @@ -229,7 +229,7 @@ where signer: &SigningAccount, initial_liquidity: Option<&[u128; 2]>, decimals: Option<&[u8; 2]>, - ) -> (String, String, String) { + ) -> (String, String) { let factory_addr = &self.astroport_contracts().factory.address; // If decimals are provided, add native coins to registry @@ -259,8 +259,7 @@ where .unwrap(); // Get pair and lp_token addresses from event - let (pair_addr, lp_token_addr, token_denom) = - parse_astroport_create_pair_events(&res.events); + let (pair_addr, lp_token) = parse_astroport_create_pair_events(&res.events); if let Some(initial_liquidity) = initial_liquidity { let assets = asset_infos @@ -274,7 +273,7 @@ where self.provide_liquidity(&pair_addr, assets, signer); } - (pair_addr, lp_token_addr, token_denom) + (pair_addr, lp_token) } fn query_simulate_swap( @@ -582,7 +581,7 @@ mod tests { let asset_infos = get_asset_infos(asset_info_choice, &contracts.astro_token.address); - let (pair_addr, _lp_token_addr, lp_token_denom) = robot.create_astroport_pair( + let (pair_addr, lp_token_denom) = robot.create_astroport_pair( pair_type.clone(), &asset_infos, init_params, @@ -634,7 +633,7 @@ mod tests { let asset_infos = get_asset_infos(asset_info_choice, &contracts.astro_token.address); let initial_liquidity = Some(&[420420u128, 696969u128]); - let (pair_addr, _lp_token_addr, _lp_token_denom) = robot.create_astroport_pair( + let (pair_addr, _lp_token_denom) = robot.create_astroport_pair( pair_type, &asset_infos, init_params, diff --git a/src/astroport/utils.rs b/src/astroport/utils.rs index e856f79..cc484bd 100644 --- a/src/astroport/utils.rs +++ b/src/astroport/utils.rs @@ -408,7 +408,7 @@ pub fn create_astroport_pair<'a, R>( signer: &SigningAccount, initial_liquidity: Option<[Uint128; 2]>, denom_creation_fee: &[Coin], -) -> (String, String, String) +) -> (String, String) where R: Runner<'a>, { @@ -428,7 +428,7 @@ where .unwrap(); // Get pair and lp_token addresses from event - let (pair_addr, lp_token_addr, token_denom) = parse_astroport_create_pair_events(&res.events); + let (pair_addr, lp_token) = parse_astroport_create_pair_events(&res.events); if let Some(initial_liquidity) = initial_liquidity { let assets = asset_infos @@ -439,13 +439,13 @@ where provide_liquidity(app, &pair_addr, assets, signer); } - (pair_addr, lp_token_addr, token_denom) + (pair_addr, lp_token) } -pub fn parse_astroport_create_pair_events(events: &[Event]) -> (String, String, String) { +pub fn parse_astroport_create_pair_events(events: &[Event]) -> (String, String) { let mut pair_addr = String::from(""); - let mut lp_token = String::from(""); - let mut token_denom = String::from(""); + let mut lp_token_addr = String::from(""); + let mut lp_token_denom = String::from(""); for event in events { if event.ty == "wasm" { @@ -455,15 +455,22 @@ pub fn parse_astroport_create_pair_events(events: &[Event]) -> (String, String, pair_addr.clone_from(&attr.value); } if attr.key == "liquidity_token_addr" { - lp_token.clone_from(&attr.value); + lp_token_addr.clone_from(&attr.value); } if attr.key == "lp_denom" { - token_denom.clone_from(&attr.value); + lp_token_denom.clone_from(&attr.value); } } } } - (pair_addr, lp_token, token_denom) + + let lp_token = if lp_token_denom.is_empty() { + lp_token_addr + } else { + lp_token_denom + }; + + (pair_addr, lp_token) } pub fn get_lp_token_balance<'a, R>( @@ -946,20 +953,16 @@ mod tests { contract_addr: Addr::unchecked(&contracts.astro_token.address), }, ]; - let (uluna_astro_pair_addr, uluna_astro_lp_token, uluna_astro_denom) = - create_astroport_pair( - &app, - &contracts.factory.address, - astroport_v5::factory::PairType::Xyk {}, - asset_infos, - None, - admin, - None, - &[], - ); - - println!("uluna_astro_pair_addr: {:?}", uluna_astro_pair_addr); - println!("uluna_astro_lp_token: {:?}", uluna_astro_lp_token); + let (uluna_astro_pair_addr, uluna_astro_lp_token) = create_astroport_pair( + &app, + &contracts.factory.address, + astroport_v5::factory::PairType::Xyk {}, + asset_infos, + None, + admin, + None, + &[], + ); // Increase allowance of astro token let increase_allowance_msg = Cw20ExecuteMsg::IncreaseAllowance { @@ -1018,12 +1021,10 @@ mod tests { admin, ); - println!("uluna_astro_denom {:?}", uluna_astro_denom); - let lp_token_balance = bank .query_balance(&QueryBalanceRequest { address: admin.address(), - denom: uluna_astro_denom, + denom: uluna_astro_lp_token, }) .unwrap();