Skip to content

Commit

Permalink
Merge branch 'main' into fix/gas-and-typo
Browse files Browse the repository at this point in the history
  • Loading branch information
ipromise2324 committed May 1, 2024
2 parents 292af99 + 526b1b4 commit 31b892f
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 15 deletions.
12 changes: 8 additions & 4 deletions contracts/kitchen.tact
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ contract Kitchen with Deployable {

// Deploy MasterChef for jetton
receive(msg: BuildJettonMasterChef) {
let ctx: Context = context();
let sendTon: Int = ctx.value - KITCHEN_FEE;
let initCode: StateInit = self.calculateJettonMasterChef(msg.owner,msg.seed);
send(SendParameters{
to: contractAddress(initCode),
value: 0,
mode: SendRemainingValue,
value: sendTon,
mode: 0,
body: SetUpJettonMC{
owner: msg.owner,
thunderMintWallet: self.owner,
Expand All @@ -37,11 +39,13 @@ contract Kitchen with Deployable {

// Deploy MasterChef for TON
receive(msg: BuildTonMasterChef) {
let ctx: Context = context();
let sendTon: Int = ctx.value - KITCHEN_FEE;
let initCode: StateInit = self.calculateTonMasterChef(msg.owner,msg.seed);
send(SendParameters{
to: contractAddress(initCode),
value: 0,
mode: SendRemainingValue,
value: sendTon,
mode: 0,
body: SetUpTonMC{
owner: msg.owner,
thunderMintWallet: self.owner,
Expand Down
3 changes: 2 additions & 1 deletion contracts/messages.tact
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,8 @@ const ACC_PRECISION: Int = pow(10, 20); // Precision for the accumulated rewar
const ZERO_ADDRESS: Address = address("0QAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACkT");
const FEE_PERCENT_FOR_DEV: Int = 3; // 0.3% of the reward will be given to the ThunderMint
const MIN_GAS_FEE: Int = ton("0.05"); // Minimum gas fee for calling send ton
const gasConsumption: Int = ton("0.0059");
const GAS_CONSUMPTION: Int = ton("0.0059");
const KITCHEN_FEE: Int = ton("0.03"); // Fee for the Kitchen

// ERROR CODES
const ERROR_POOL_NOT_FOUND: Int = 1002;
Expand Down
8 changes: 4 additions & 4 deletions contracts/mini_chef.tact
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ contract MiniChef with Deployable {
userInfo.rewardDebt = userInfo.rewardDebt + msg.rewardDebt;
self.userInfo.set(msg.lpTokenAddress, userInfo);
let ctx: Context = context();
let sendBackTon: Int = ctx.value - gasConsumption - MIN_GAS_FEE;
let sendBackTon: Int = ctx.value - GAS_CONSUMPTION - MIN_GAS_FEE;
// Send remain Ton to owner
send(SendParameters{
to: self.owner,
Expand All @@ -50,7 +50,7 @@ contract MiniChef with Deployable {

self.userInfo.set(msg.lpTokenAddress, userInfo);
let ctx: Context = context();
let sendBackTon: Int = ctx.value - gasConsumption;
let sendBackTon: Int = ctx.value - GAS_CONSUMPTION;
send(SendParameters{
to: self.masterChef,
value: sendBackTon,
Expand All @@ -77,7 +77,7 @@ contract MiniChef with Deployable {
userInfo.rewardDebt = accumulatedReward;
self.userInfo.set(msg.lpTokenAddress, userInfo);
let ctx: Context = context();
let sendBackTon: Int = ctx.value - gasConsumption;
let sendBackTon: Int = ctx.value - GAS_CONSUMPTION;
// Send pending reward ammount to MasterChef, and then MasterChef will send it to the user
send(SendParameters{
to: self.masterChef,
Expand All @@ -103,7 +103,7 @@ contract MiniChef with Deployable {
let _pendingReward: Int = accumulatedReward - userInfo.rewardDebt;

let ctx: Context = context();
let sendBackTon: Int = ctx.value - gasConsumption;
let sendBackTon: Int = ctx.value - GAS_CONSUMPTION;
if (_pendingReward <= 0) {
userInfo.amount = userInfo.amount - msg.withdrawAmount;
userInfo.rewardDebt = userInfo.rewardDebt - msg.withdrawAmount * msg.accRewardPerShare / ACC_PRECISION;
Expand Down
6 changes: 3 additions & 3 deletions contracts/packages/mock/JettonWallet.tact
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ trait JettonWallet {
balance: Int;
owner: Address;
jetton_master: Address;
virtual const gasConsumption: Int = ton("0.05");
virtual const GAS_CONSUMPTION: Int = ton("0.05");
virtual const minTonsForStorage: Int = ton("0.05");

//********************************************//
Expand Down Expand Up @@ -132,7 +132,7 @@ trait JettonWallet {
virtual inline fun _internal_transfer_estimate_remain_value(ctx: Context, msg: JettonInternalTransfer): Int {
let tonBalanceBeforeMsg: Int = myBalance() - ctx.value;
let storage_fee: Int = self.minTonsForStorage - min(tonBalanceBeforeMsg, self.minTonsForStorage);
let remain: Int = ctx.value - (storage_fee + self.gasConsumption);
let remain: Int = ctx.value - (storage_fee + self.GAS_CONSUMPTION);
if (msg.forward_ton_amount > 0) {
remain = remain - (ctx.readForwardFee() + msg.forward_ton_amount);
}
Expand Down Expand Up @@ -206,7 +206,7 @@ trait JettonWallet {
if (msg.forward_ton_amount > 0) {
fwd_count = 2;
}
require(ctx.value > fwd_count * ctx.readForwardFee() + 2 * self.gasConsumption + self.minTonsForStorage, "Not enough funds to transfer");
require(ctx.value > fwd_count * ctx.readForwardFee() + 2 * self.GAS_CONSUMPTION + self.minTonsForStorage, "Not enough funds to transfer");
}

// @dev _transfer_jetton will transfer jettons to the jetton wallet of the destination address (owner of jetton wallet)
Expand Down
4 changes: 2 additions & 2 deletions contracts/packages/utils/Estimatable.tact
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
trait Estimatable {
virtual const gasConsumption: Int = ton("0.05");
virtual const GAS_CONSUMPTION: Int = ton("0.05");
virtual const minTonsForStorage: Int = ton("0.05");

virtual fun estimate_rest_value(ctx: Context): Int {
let restValue: Int = ctx.value;
let tonBalanceBeforeMsg: Int = myBalance() - restValue;
let storageFee: Int = self.minTonsForStorage - min(tonBalanceBeforeMsg, self.minTonsForStorage);
return restValue - (storageFee + self.gasConsumption);
return restValue - (storageFee + self.GAS_CONSUMPTION);
}
}
2 changes: 1 addition & 1 deletion contracts/trait_master_chef.tact
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ trait MasterChef {
pool.lpSupply = pool.lpSupply + msg.amount;
self.totalLpSupply = self.totalLpSupply + msg.amount;
self.pools.set(ctx.sender, pool);
let sendBackTon: Int = ctx.value - gasConsumption;
let sendBackTon: Int = ctx.value - GAS_CONSUMPTION;
// Get the MiniChef init code for the user
let initCode: StateInit = self._calculateMiniChefInit(msg.sender);
send(SendParameters{
Expand Down

0 comments on commit 31b892f

Please sign in to comment.