EverToTip3

With this smart contract you can swap evers to Tip3 tokens.

Smart contract responsible for swapping evers to Tip3 tokens.

Derives following classes and interfaces: IAcceptTokensMintCallback, IAcceptTokensTransferCallback, IAcceptTokensBurnCallback, IEverTip3SwapEvents.

constructor

constructor() public

Deploys wallet with EverToTip3 contract address.

buildExchangePayload

function buildExchangePayload(uint64 id, uint128 amount, address pair, uint128 expectedAmount, uint128 deployWalletValue) external pure returns (TvmCell)

Creates payload constructor for swap between Ever and Tip-3 token - takes id, amount, pair address, expectedAmount, deployWalletValue from params and store those values to the TVMBuilder instance.

Parameters:

Return Value:

Swap

swapEvers

function swapEvers(address user, TvmCell payload) external

Takes user address and payload as params if there are enough EVERs swap them with Tip-3 token, if not cancel.

Parameters:

Callbacks

onWeverWallet

function onWeverWallet(address _weverWallet) external

Deploys Wever wallet for the contract using _weverWallet address from the function params.

Parameters:

onAcceptTokensMint

function onAcceptTokensMint(address /*tokenRoot*/, uint128 amount, address user, TvmCell payload) override external

Checks if weverWallet is the message sender and message sender value is greater than 0, if value is ge then SWAP_EVER_TO_TIP_3_MIN_VALUE, if so emit SwapEverToTip3WeverMint event, create success, cancel and result payload, transfer the amount from the function params of tokens from EverToTip3 wallet to the pair’s address, else transfer to the weverVault address (burn Wevers).

Parameters:

onAcceptTokensTransfer

function onAcceptTokensTransfer(address /*tokenRoot*/, uint128 amount, address sender, address /*senderWallet*/, address user, TvmCell payload) override external

If operationStatus is cancel, burn WEVERs (transfer them to weverVault address), if it is SUCCESS call the callback function for swapping evers to tip 3 (onSwapEversToTip3Success), emit SwapEversToTip3SuccessTransfer event and send tip 3 tokens to the user using TokenWallet’s transfer function. If it’s not SUCCESS or CANCEL set needCancel var to true and transfer the amount back to the sender.

Parameters:

onAcceptTokensBurn

function onAcceptTokensBurn(uint128 /*amount*/, address /*walletOwner*/, address /*wallet*/, address user, TvmCell payload) override external

Callback function used when swap is canceled. Emit SwapEverToTip3CancelTransfer and call callback function onSwapEverToTip3CancelTransfer.

Parameters:

Key Events

SwapEverToTip3WeverMint

SwapEverToTip3WeverMint(uint64 id, uint128 amount, address pair, uint128 expectedAmount, uint128 deployWalletValue);

Emitted inside onAcceptTokensMint callback.

SwapEverToTip3SuccessTransfer

SwapEverToTip3SuccessTransfer(address user, uint64 id);

Emitted inside onAcceptTokensTransfer callback when EVERs are successfully swapped to Tip3 tokens.

SwapEverToTip3CancelTransfer

SwapEverToTip3CancelTransfer(address user, uint64 id);

Emitted inside of the onAcceptTokensBurn when swap is canceled .

Last updated