diff --git a/dex/interactor/src/energy_factory.rs b/dex/interactor/src/energy_factory.rs index 2764de4b8..539397a05 100644 --- a/dex/interactor/src/energy_factory.rs +++ b/dex/interactor/src/energy_factory.rs @@ -17,7 +17,7 @@ pub(crate) async fn get_energy_entry_for_user( .query() .to(dex_interact.state.current_energy_factory_address()) .typed(energy_factory_proxy::SimpleLockEnergyProxy) - .get_updated_energy_entry_for_user(ManagedAddress::from(user)) + .get_updated_energy_entry_for_user(user) .returns(ReturnsResult) .prepare_async() .run() diff --git a/dex/interactor/src/farm_locked.rs b/dex/interactor/src/farm_locked.rs index 27201a6e2..578b7c1ea 100644 --- a/dex/interactor/src/farm_locked.rs +++ b/dex/interactor/src/farm_locked.rs @@ -6,14 +6,14 @@ use multiversx_sc_snippets::imports::*; use crate::{ farm_with_locked_rewards_proxy, - structs::{extract_caller, to_rust_biguint, InteractorFarmTokenAttributes, InteractorToken}, + structs::{extract_caller, to_rust_biguint, InteractorFarmTokenAttributes, InteractorPayment}, DexInteract, }; pub(crate) async fn enter_farm( dex_interact: &mut DexInteract, - lp_token: InteractorToken, -) -> (InteractorToken, InteractorToken) { + lp_token: InteractorPayment, +) -> (InteractorPayment, InteractorPayment) { println!("Attempting to enter farm with locked rewards..."); let result_token = dex_interact @@ -25,25 +25,23 @@ pub(crate) async fn enter_farm( .current_farm_with_locked_rewards_address()) .gas(100_000_000u64) .typed(farm_with_locked_rewards_proxy::FarmProxy) - .enter_farm_endpoint(OptionalValue::Some(ManagedAddress::from( - dex_interact.wallet_address.as_address(), - ))) - .payment::>(lp_token.into()) + .enter_farm_endpoint(OptionalValue::Some(dex_interact.wallet_address.clone())) + .esdt::>(lp_token.into()) .returns(ReturnsResult) .prepare_async() .run() .await; ( - InteractorToken::from(result_token.0 .0), - InteractorToken::from(result_token.0 .1), + InteractorPayment::from(result_token.0 .0), + InteractorPayment::from(result_token.0 .1), ) } pub(crate) async fn claim_rewards( dex_interact: &mut DexInteract, - payment: Vec, + payment: Vec, opt_original_caller: Option
, -) -> (InteractorToken, InteractorToken) { +) -> (InteractorPayment, InteractorPayment) { println!("Attempting to claim rewards from farm with locked rewards..."); let payments = payment @@ -70,16 +68,16 @@ pub(crate) async fn claim_rewards( .await; ( - InteractorToken::from(result_token.0 .0), - InteractorToken::from(result_token.0 .1), + InteractorPayment::from(result_token.0 .0), + InteractorPayment::from(result_token.0 .1), ) } pub(crate) async fn exit_farm( dex_interact: &mut DexInteract, - payment: InteractorToken, + payment: InteractorPayment, opt_original_caller: Option
, -) -> (InteractorToken, InteractorToken) { +) -> (InteractorPayment, InteractorPayment) { println!("Attempting to exit farm with locked rewards..."); let caller_arg = extract_caller(dex_interact, opt_original_caller); @@ -101,16 +99,16 @@ pub(crate) async fn exit_farm( .await; ( - InteractorToken::from(result_token.0 .0), - InteractorToken::from(result_token.0 .1), + InteractorPayment::from(result_token.0 .0), + InteractorPayment::from(result_token.0 .1), ) } pub(crate) async fn merge_farm_tokens( dex_interact: &mut DexInteract, - payment: Vec, + payment: Vec, opt_original_caller: Option
, -) -> (InteractorToken, InteractorToken) { +) -> (InteractorPayment, InteractorPayment) { println!("Attempting to merge tokens in farm with locked rewards..."); let payments = payment @@ -137,15 +135,15 @@ pub(crate) async fn merge_farm_tokens( .await; ( - InteractorToken::from(result_token.0 .0), - InteractorToken::from(result_token.0 .1), + InteractorPayment::from(result_token.0 .0), + InteractorPayment::from(result_token.0 .1), ) } pub(crate) async fn claim_boosted_rewards( dex_interact: &mut DexInteract, opt_original_caller: Option
, -) -> InteractorToken { +) -> InteractorPayment { let caller_arg = extract_caller(dex_interact, opt_original_caller); let result_token = dex_interact @@ -163,7 +161,7 @@ pub(crate) async fn claim_boosted_rewards( .run() .await; - InteractorToken::from(result_token) + InteractorPayment::from(result_token) } pub(crate) async fn calculate_rewards_for_given_position( diff --git a/dex/interactor/src/farm_staking_proxy.rs b/dex/interactor/src/farm_staking_proxy.rs index b2a71fe3d..3db4bc2d9 100644 --- a/dex/interactor/src/farm_staking_proxy.rs +++ b/dex/interactor/src/farm_staking_proxy.rs @@ -7,7 +7,7 @@ use proxies::farm_staking_proxy_sc_proxy; use crate::{ structs::{ extract_caller, InteractorClaimDualYieldResult, InteractorStakeProxyResult, - InteractorToken, InteractorUnstakeResult, + InteractorPayment, InteractorUnstakeResult, }, DexInteract, }; @@ -167,7 +167,7 @@ pub(crate) async fn get_energy_factory_address(dex_interact: &mut DexInteract) - // endpoints pub(crate) async fn stake_farm_tokens( dex_interact: &mut DexInteract, - payment: Vec, + payment: Vec, opt_original_caller: Option
, ) -> InteractorStakeProxyResult { let caller_arg = extract_caller(dex_interact, opt_original_caller); @@ -196,7 +196,7 @@ pub(crate) async fn stake_farm_tokens( pub(crate) async fn claim_dual_yield( dex_interact: &mut DexInteract, - payment: InteractorToken, + payment: InteractorPayment, opt_original_caller: Option
, ) -> InteractorClaimDualYieldResult { let caller_arg = extract_caller(dex_interact, opt_original_caller); @@ -220,7 +220,7 @@ pub(crate) async fn claim_dual_yield( pub(crate) async fn unstake_farm_tokens( dex_interact: &mut DexInteract, - payment: InteractorToken, + payment: InteractorPayment, pair_first_token_min_amount: RustBigUint, pair_second_token_min_amount: RustBigUint, opt_original_caller: Option
, diff --git a/dex/interactor/src/pair.rs b/dex/interactor/src/pair.rs index 88b534526..d22a64e09 100644 --- a/dex/interactor/src/pair.rs +++ b/dex/interactor/src/pair.rs @@ -4,14 +4,14 @@ use proxies::pair_proxy; use crate::{ dex_interact_cli::{AddArgs, SwapArgs}, - structs::{InteractorAddLiquidityResultType, InteractorToken}, + structs::{InteractorAddLiquidityResultType, InteractorPayment}, DexInteract, }; pub(crate) async fn swap_tokens_fixed_input( dex_interact: &mut DexInteract, args: &SwapArgs, -) -> InteractorToken { +) -> InteractorPayment { let payment = args.as_payment(dex_interact); let first_token_id = dex_interact.state.first_token_id(); let second_token_id = dex_interact.state.second_token_id(); @@ -38,7 +38,7 @@ pub(crate) async fn swap_tokens_fixed_input( .run() .await; - InteractorToken::from(result_token) + InteractorPayment::from(result_token) } pub(crate) async fn add_liquidity( diff --git a/dex/interactor/src/structs.rs b/dex/interactor/src/structs.rs index f76a3707d..6a2ac5188 100644 --- a/dex/interactor/src/structs.rs +++ b/dex/interactor/src/structs.rs @@ -21,7 +21,7 @@ impl InteractorMultiValue3 { } } pub type InteractorAddLiquidityResultType = - InteractorMultiValue3; + InteractorMultiValue3; impl From, EsdtTokenPayment, EsdtTokenPayment>> @@ -33,9 +33,9 @@ impl let extracted = value.0; InteractorMultiValue3::new( - InteractorToken::from(extracted.0), - InteractorToken::from(extracted.1), - InteractorToken::from(extracted.2), + InteractorPayment::from(extracted.0), + InteractorPayment::from(extracted.1), + InteractorPayment::from(extracted.2), ) } } @@ -44,53 +44,53 @@ pub type RustBigInt = num_bigint::BigInt; #[allow(dead_code)] pub struct InteractorUnstakeResult { - pub other_token_payment: InteractorToken, - pub lp_farm_rewards: InteractorToken, - pub staking_rewards: InteractorToken, - pub unbond_staking_farm_token: InteractorToken, + pub other_token_payment: InteractorPayment, + pub lp_farm_rewards: InteractorPayment, + pub staking_rewards: InteractorPayment, + pub unbond_staking_farm_token: InteractorPayment, } impl From> for InteractorUnstakeResult { fn from(value: UnstakeResult) -> Self { InteractorUnstakeResult { - other_token_payment: InteractorToken::from(value.other_token_payment), - lp_farm_rewards: InteractorToken::from(value.lp_farm_rewards), - staking_rewards: InteractorToken::from(value.staking_rewards), - unbond_staking_farm_token: InteractorToken::from(value.unbond_staking_farm_token), + other_token_payment: InteractorPayment::from(value.other_token_payment), + lp_farm_rewards: InteractorPayment::from(value.lp_farm_rewards), + staking_rewards: InteractorPayment::from(value.staking_rewards), + unbond_staking_farm_token: InteractorPayment::from(value.unbond_staking_farm_token), } } } #[allow(dead_code)] pub struct InteractorStakeProxyResult { - pub dual_yield_tokens: InteractorToken, - pub staking_boosted_rewards: InteractorToken, - pub lp_farm_boosted_rewards: InteractorToken, + pub dual_yield_tokens: InteractorPayment, + pub staking_boosted_rewards: InteractorPayment, + pub lp_farm_boosted_rewards: InteractorPayment, } impl From> for InteractorStakeProxyResult { fn from(value: StakeProxyResult) -> Self { InteractorStakeProxyResult { - dual_yield_tokens: InteractorToken::from(value.dual_yield_tokens), - staking_boosted_rewards: InteractorToken::from(value.staking_boosted_rewards), - lp_farm_boosted_rewards: InteractorToken::from(value.lp_farm_boosted_rewards), + dual_yield_tokens: InteractorPayment::from(value.dual_yield_tokens), + staking_boosted_rewards: InteractorPayment::from(value.staking_boosted_rewards), + lp_farm_boosted_rewards: InteractorPayment::from(value.lp_farm_boosted_rewards), } } } #[allow(dead_code)] pub struct InteractorClaimDualYieldResult { - pub lp_farm_rewards: InteractorToken, - pub staking_farm_rewards: InteractorToken, - pub new_dual_yield_tokens: InteractorToken, + pub lp_farm_rewards: InteractorPayment, + pub staking_farm_rewards: InteractorPayment, + pub new_dual_yield_tokens: InteractorPayment, } impl From> for InteractorClaimDualYieldResult { fn from(value: ClaimDualYieldResult) -> Self { InteractorClaimDualYieldResult { - lp_farm_rewards: InteractorToken::from(value.lp_farm_rewards), - staking_farm_rewards: InteractorToken::from(value.staking_farm_rewards), - new_dual_yield_tokens: InteractorToken::from(value.new_dual_yield_tokens), + lp_farm_rewards: InteractorPayment::from(value.lp_farm_rewards), + staking_farm_rewards: InteractorPayment::from(value.staking_farm_rewards), + new_dual_yield_tokens: InteractorPayment::from(value.new_dual_yield_tokens), } } } @@ -104,7 +104,7 @@ pub struct InteractorFarmTokenAttributes { } #[derive(Debug)] -pub struct InteractorToken { +pub struct InteractorPayment { pub token_id: String, pub nonce: u64, pub amount: RustBigUint, @@ -127,9 +127,9 @@ impl From> for InteractorEnergy { } } -impl From> for InteractorToken { +impl From> for InteractorPayment { fn from(value: EsdtTokenPayment) -> Self { - InteractorToken { + InteractorPayment { token_id: value.token_identifier.to_string(), nonce: value.token_nonce, amount: to_rust_biguint(value.amount), @@ -137,8 +137,8 @@ impl From> for InteractorToken { } } -impl From for EsdtTokenPayment { - fn from(interactor_token: InteractorToken) -> Self { +impl From for EsdtTokenPayment { + fn from(interactor_token: InteractorPayment) -> Self { EsdtTokenPayment::new( TokenIdentifier::from(interactor_token.token_id.as_bytes()), interactor_token.nonce, @@ -147,8 +147,8 @@ impl From for EsdtTokenPayment { } } -impl From<&InteractorToken> for EsdtTokenPayment { - fn from(interactor_token: &InteractorToken) -> Self { +impl From<&InteractorPayment> for EsdtTokenPayment { + fn from(interactor_token: &InteractorPayment) -> Self { EsdtTokenPayment::new( TokenIdentifier::from(interactor_token.token_id.as_bytes()), interactor_token.nonce,