|
|
|
// import "@stdlib/jetton";
|
|
|
|
import "./messages";
|
|
|
|
import "./wallet";
|
|
|
|
import "./linker";
|
|
|
|
import "./jetton_trait";
|
|
|
|
import "./staking";
|
|
|
|
import "./constants";
|
|
|
|
import "./pseudostaking";
|
|
|
|
|
|
|
|
message Deposit {
|
|
|
|
amount: Int as coins;
|
|
|
|
}
|
|
|
|
|
|
|
|
message Withdraw {
|
|
|
|
amount: Int;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
contract TONB with TONBTrait {
|
|
|
|
|
|
|
|
totalSupply: Int as coins;
|
|
|
|
owner: Address;
|
|
|
|
content: Cell?;
|
|
|
|
mintable: Bool;
|
|
|
|
first_linker: Address?;
|
|
|
|
last_linker: Address?;
|
|
|
|
n_linkers: Int = 0;
|
|
|
|
staking_pool: Address?;
|
|
|
|
in_the_pool: Int = 0;
|
|
|
|
withdrawal_requests: WithdrawalRequests;
|
|
|
|
requested_withdrawal: Int = 0;
|
|
|
|
|
|
|
|
init(owner: Address, content: Cell?, staking_pool: Address?) {
|
|
|
|
self.totalSupply = 0;
|
|
|
|
self.owner = owner;
|
|
|
|
self.mintable = true;
|
|
|
|
self.content = content;
|
|
|
|
self.staking_pool = staking_pool;
|
|
|
|
self.withdrawal_requests = WithdrawalRequests {
|
|
|
|
addresses: emptyMap(),
|
|
|
|
amounts: emptyMap()
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
receive(msg: Deposit) {
|
|
|
|
let ctx: Context = context();
|
|
|
|
require(ctx.value >= deposit_gas_consumption + msg.amount + linker_credit + wallet_credit, "not enough money for deposit");
|
|
|
|
self.mint(ctx.sender, msg.amount, ctx.sender);
|
|
|
|
self.sendStake();
|
|
|
|
}
|
|
|
|
|
|
|
|
receive() {}
|
|
|
|
|
|
|
|
receive(msg: Withdraw) {
|
|
|
|
let ctx: Context = context();
|
|
|
|
require(ctx.value >= withdraw_gas_consumption, "not enough money for withdraw");
|
|
|
|
self.burn(ctx.sender, msg.amount, ctx.sender);
|
|
|
|
}
|
|
|
|
|
|
|
|
receive(msg: SetStakingPool) {
|
|
|
|
self.staking_pool = msg.staking_pool;
|
|
|
|
}
|
|
|
|
}
|