Skip to content

Commit

Permalink
feat: withdrawAndHarvest msg only send WithdrawAndHarvestReply back t…
Browse files Browse the repository at this point in the history
…o MasterChef

* fix(JettonMasterChefCosts.txt): update Deposit Cost for Jetton MasterChef
* fix(JettonMasterChefCosts.txt): update Withdraw & Harvest Cost for Jetton MasterChef
* fix(TONMasterChefCosts.txt): update Deposit Cost for TON MasterChef
* fix(TONMasterChefCosts.txt): update Withdraw & Harvest Cost for TON MasterChef
* fix(jetton_master_chef.tact): add condition to send reward only if rewardAmount > 0
* fix(mini_chef.tact): update body of WithdrawAndHarvestReply to include withdrawAmount and sender
* fix(ton_master_chef.tact): add condition to send reward only if rewardAmount > 0
  • Loading branch information
ipromise2324 committed Apr 26, 2024
1 parent 9446a05 commit 0347506
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 12 deletions.
4 changes: 2 additions & 2 deletions JettonMasterChefCosts.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Jetton MasterChef Costs in each operation:
Deposit Cost: 0.0337932 TON
Deposit Cost: 0.0338092 TON
Harvest Cost: 0.0155238059 TON
Withdraw Cost: 0.0159530001 TON
Withdraw & Harvest Cost: 0.0259807059 TON
Withdraw & Harvest Cost: 0.0259967059 TON
4 changes: 2 additions & 2 deletions TONMasterChefCosts.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
TON MasterChef Costs in each operation:
Deposit Cost: 0.0332019 TON
Deposit Cost: 0.0332179 TON
Harvest Cost: 0.0052698059 TON
Withdraw Cost: 0.0157856006 TON
Withdraw & Harvest Cost: 0.0172036059 TON
Withdraw & Harvest Cost: 0.0172196059 TON
7 changes: 4 additions & 3 deletions contracts/jetton_master_chef.tact
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,10 @@ contract JettonMasterChef with Deployable, MasterChef {
require(expectedSender == sender(), "unexpected sender");

let ctx: Context = context();

// Send Reward to the beneficiary
self.sendJetton(self.mcRewardJettonWallet, ctx.value / 2, msg.rewardAmount, msg.beneficiary, msg.beneficiary, 0);
if (msg.rewardAmount > 0) {
// Send Reward to the beneficiary
self.sendJetton(self.mcRewardJettonWallet, ctx.value / 2, msg.rewardAmount, msg.beneficiary, msg.beneficiary, 0);
}

if(msg.withdrawAmount > 0) {
// Withdraw lpToken to msg.beneficiary
Expand Down
7 changes: 4 additions & 3 deletions contracts/mini_chef.tact
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,12 @@ contract MiniChef with Deployable {
to: self.masterChef,
value: 0,
mode: SendRemainingValue,
body: WithdrawInternalReply{
body: WithdrawAndHarvestReply{
queryId: msg.queryId,
lpTokenAddress: msg.lpTokenAddress,
amount: msg.withdrawAmount,
sender: msg.sender,
rewardAmount: 0,
withdrawAmount: msg.withdrawAmount,
sender: self.owner,
beneficiary: msg.beneficiary
}.toCell()
});
Expand Down
6 changes: 4 additions & 2 deletions contracts/ton_master_chef.tact
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,10 @@ contract TonMasterChef with Deployable, MasterChef {
let ctx: Context = context();
let sendTon: Int = ctx.value;

// Send Reward to the user
self.sendTon(msg.beneficiary, msg.rewardAmount, SendIgnoreErrors);
if (msg.rewardAmount > 0) {
// Send Reward to the user
self.sendTon(msg.beneficiary, msg.rewardAmount, SendIgnoreErrors);
}

if(msg.withdrawAmount > 0) {
// Withdraw to msg.beneficiary
Expand Down

0 comments on commit 0347506

Please sign in to comment.