Skip to content

Commit

Permalink
remove redudnant share token retrieval
Browse files Browse the repository at this point in the history
  • Loading branch information
dmoka committed Oct 30, 2024
1 parent 031b86a commit 5b25201
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

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

10 changes: 5 additions & 5 deletions pallets/xyk-liquidity-mining/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -707,8 +707,9 @@ pub mod pallet {
shares_amount: Balance,
) -> DispatchResult {
let who = ensure_signed(origin)?;
let amm_share_token = T::AMM::get_share_token(asset_pair);

Self::do_deposit_shares(who, global_farm_id, yield_farm_id, asset_pair, shares_amount)?;
Self::do_deposit_shares(who, global_farm_id, yield_farm_id, asset_pair,amm_share_token, shares_amount)?;

Ok(())
}
Expand Down Expand Up @@ -738,10 +739,10 @@ pub mod pallet {
ensure!(!farm_entries.is_empty(), Error::<T>::NoFarmsSpecified);

let (global_farm_id, yield_farm_id) = farm_entries.first().ok_or(Error::<T>::NoFarmsSpecified)?;
let amm_share_token = T::AMM::get_share_token(asset_pair);
let deposit_id =
Self::do_deposit_shares(who.clone(), *global_farm_id, *yield_farm_id, asset_pair, shares_amount)?;
Self::do_deposit_shares(who.clone(), *global_farm_id, *yield_farm_id, asset_pair, amm_share_token, shares_amount)?;

let amm_share_token = T::AMM::get_share_token(asset_pair);
for (global_farm_id, yield_farm_id) in farm_entries.into_iter().skip(1) {
let (redeposited_amount, _) = T::LiquidityMiningHandler::redeposit_lp_shares(
global_farm_id,
Expand Down Expand Up @@ -1058,12 +1059,11 @@ impl<T: Config> Pallet<T> {
global_farm_id: GlobalFarmId,
yield_farm_id: YieldFarmId,
asset_pair: AssetPair,
amm_share_token: AssetId,
shares_amount: Balance,
) -> Result<DepositId, DispatchError> {
let amm_pool_id = Self::ensure_xyk(asset_pair)?;

let amm_share_token = T::AMM::get_share_token(asset_pair);

ensure!(
T::Currencies::ensure_can_withdraw(amm_share_token, &who, shares_amount).is_ok(),
Error::<T>::InsufficientXykSharesBalance
Expand Down

0 comments on commit 5b25201

Please sign in to comment.