Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

farm supply on claim fix for farm with locked rewards #939

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 6 additions & 17 deletions dex/farm-with-locked-rewards/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,30 +127,19 @@ pub trait Farm:

self.migrate_old_farm_positions(&orig_caller);

let payments = self.call_value().all_esdt_transfers().clone_value();
let base_claim_rewards_result =
self.claim_rewards_base::<NoMintWrapper<Self>>(orig_caller.clone(), payments);
let output_farm_token_payment = base_claim_rewards_result.new_farm_token.payment.clone();
self.send_payment_non_zero(&caller, &output_farm_token_payment);
let claim_rewards_result = self.claim_rewards::<NoMintWrapper<Self>>(orig_caller.clone());

let rewards_payment = base_claim_rewards_result.rewards;
self.send_payment_non_zero(&caller, &claim_rewards_result.new_farm_token);

let rewards_payment = claim_rewards_result.rewards;
let locked_rewards_payment = self.send_to_lock_contract_non_zero(
rewards_payment.token_identifier,
rewards_payment.amount,
caller,
orig_caller.clone(),
);

self.emit_claim_rewards_event::<_, FarmTokenAttributes<Self::Api>>(
&orig_caller,
base_claim_rewards_result.context,
base_claim_rewards_result.new_farm_token,
locked_rewards_payment.clone(),
base_claim_rewards_result.created_with_merge,
base_claim_rewards_result.storage_cache,
orig_caller,
);

(output_farm_token_payment, locked_rewards_payment).into()
(claim_rewards_result.new_farm_token, locked_rewards_payment).into()
}

#[payable("*")]
Expand Down
Loading