Smart contract

Contract Flow

MultiTokenBurnPortal allows users to purchase fee on transfer tokens with smaller fees. Managers will create and set discounts and taxes for each fee on transfer tokens.

Example: TokenX is a fee on transfer token with 20% transfer fee. Manager adds TokenX with baseTax=2000 and specifies feeReceiver and discounts If user burns 100 tokens, his discount will be 10%, and he will be able to purchase TokenX with 18% fee If user burns 500 tokens, his discount will be 50%, and he will be able to purchase TokenX with 10% fee If user burns 1000 tokens, his discount will be 100%, and he will be able to purchase TokenX without fee

Contract functions

constructor

Creates contract

constructor(
        IWETH _WETH,
        uint16 _adminFee,
        address _adminFeeReceiver
    )

_WETH WETH address _adminFee Admin fee in basis points (10000 = 100%). This fee share will be transferred to admin fee receiver _adminFeeReceiver Receiver of admin fees

buyTokensWithBNB

Swaps BNB for Token and sends them to msg.sender

function buyTokensWithBNB(
        address router,
        uint256 amountOutMin,
        address[] calldata path,
        uint256 deadline
    ) external payable onlyApprovedRouter(router) returns(uint256 amountOut)

router Router address, that should be used for the swap amountOutMin Minimum amount of tokens to receive path Swap path deadline Deadline of swap transaction

Returns: amountOut Amount of tokens user has received

Only approved routers are allowed

buyTokensWithERC20

Swaps ERC20 for token and sends them to msg.sender

function buyTokensWithERC20(
        address router,
        uint256 amountIn,
        uint256 amountOutMin,
        address[] calldata path,
        uint256 deadline
    ) external onlyApprovedRouter(router) returns(uint256 amountOut)

router Router address, that should be used for the swap amountIn Amount tokens to spend amountOutMin Minimum amount of tokens to receive path Swap path deadline Deadline of swap transaction

Returns: amountOut Amount of tokens user has received

Only approved routers are allowed

burnTokens

Burns tokens by sending them to dead wallet

function burnTokens(address token, uint128 amount) external

token ERC20 token address to burn amount Amount of tokens to burn

setManager

Sets manager account

function setManager(address account, bool add) external onlyOwner

account Account address add true - add manager, false - remove manager

Can be called only by contract Owner

setAdminFeeSettings

Sets admin fee and admin fee receiver

function setAdminFeeSettings(
        uint16 _adminFee,
        address _adminFeeReceiver
    ) external onlyOwner

_adminFee Admin fee in basis points (10000 = 100%). This fee share will be transferred to admin fee receiver _adminFeeReceiver Receiver of admin fees

Can be called only by contract Owner

addToken

Creates a burn portal for new token

function addToken(
        address token,
        uint16 baseTax,
        address feeReceiver,
        Discount[] calldata discounts
    ) external onlyOwnerOrManager

token ERC20 token address baseTax Base tax for the token, in basis points (10000 = 100%) feeReceiver Fee receiver address for the token discounts Array of Discount structs, containing discount amount and burn amount to receive that discount

struct Discount { uint16 discount; uint112 burnAmount; }

Can be called only by contract Owner or Manager

removeToken

Removes token from Burn Portal

function removeToken(address token) external onlyOwnerOrManager

token ERC20 token address

Can be called only by contract Owner or Manager

setTokenBaseTax

Sets new base tax for the token. Should be called if token tax was updated

function setTokenBaseTax(
        address token,
        uint16 baseTax
    ) external onlyOwnerOrManager

token ERC20 token address baseTax Base tax for the token, in basis points (10000 = 100%)

Can be called only by contract Owner or Manager

setTokenFeeReceiver

Updates fee receiver address for specific token

function setTokenFeeReceiver(
        address token,
        address feeReceiver
    ) external onlyOwnerOrManager

token ERC20 token address feeReceiver Fee receiver address for the token

Can be called only by contract Owner or Manager

setTokenDiscounts

Updates discounts for specific token

function setTokenDiscounts(
        address token,
        Discount[] calldata discounts
    ) external onlyOwnerOrManager

token ERC20 token address discounts Array of Discount structs, containing discount amount and burn amount to receive that discount+

struct Discount { uint16 discount; uint112 burnAmount; }

Can be called only by contract Owner or Manager

approveTokenIn

Approves token to be swapped to Portal Token

function approveTokenIn(address token) external onlyOwner

token ERC20 token address

Can be called only by contract Owner

removeTokenIn

Remove token from the list of approved tokens In

function removeTokenIn(address token) external onlyOwner

token ERC20 token address

Can be called only by contract Owner

approveRouter

Approves Router address

function approveRouter(address router, bool approve) external onlyOwner

router Router address approve true - approve, false - forbid

Can be called only by contract Owner

emergencyWithdrawERC20

Withdraws stuck ERC20 token

function emergencyWithdrawERC20(
        IERC20 token,
        address account,
        uint256 amount
    ) external onlyOwner

token IERC20 token address account Address of receiver amount Amount of tokens to withdraw

Can be called only by contract Owner

emergencyWithdrawBNB

Withdraws stuck BNB

function emergencyWithdrawBNB(
        address account,
        uint256 amount
    ) external onlyOwner

account Address of receiver amount Amount of BNB to withdraw

Can be called only by contract Owner

getDiscounts

View function go get discounts list for specific token

function getDiscounts(address token) external view returns(Discount[] memory)

token ERC20 token address

Returns: List or discounts

getApprovedTokens

View function go get list or approved tokens IN

function getApprovedTokens() external view returns(address[] memory)

Returns: List or approved tokens

getApprovedRouters

View function go get list or approved routers

function getApprovedRouters() external view returns(address[] memory)

Returns: List or approved routers

getActiveTokens

View function go get list or active Portal Tokens

function getActiveTokens() external view returns(address[] memory)

Returns: List or active Portal Tokens

getPortalInfo

View function go collect portal info

function getPortalInfo(address token) external view returns(
        uint16 baseTax,
        address feeReceiver,
        uint128 totalBought,
        uint128 totalBurned,
        Discount[] memory discounts
    )

token Portal Token address

Returns: baseTax Token tax in basis points (10000 = 100%) feeReceiver Fee receiver for this token totalBought Amount of tokens, bought through this portal totalBurned Amount of tokens, burned with this portal discounts List of token discounts

getManagers

View function to get list or managers

function getManagers() external view returns(address[] memory)

Returns: List or managers

isManager

View function check if address is manager

function isManager(address account) external view returns(bool)

account Account address

Returns: Is account a manager?

isApprovedTokenIn

View function go determine if token is approved to be swapped to Portal Token

function isApprovedTokenIn(address token) external view returns(bool)

token ERC20 token address

Returns: Is approved to be swapped to Portal Token?

isApprovedRouter

View function go determine if Router is approved to be used to buy Portal Token

function isApprovedRouter(address router) external view returns(bool)

router Router address

Returns: Is approved router?

getPersonalDiscount

View function go get personal discount

function getPersonalDiscount(address account, address token) public view returns(uint256)

account Account address token ERC20 token address

Returns: Discount in basis points where 10_000 is 100% discount = purchase without fee