-
Notifications
You must be signed in to change notification settings - Fork 34
SFTM calls reference
uprendis edited this page Mar 25, 2021
·
1 revision
// get a reference to the StakerTokenizer contract
stakeTokenizerAddress = sfcc.stakeTokenizerAddress()
stakeTokenizer = web3.ftm.contract(STAKE_TOKENIZER_ABI).at(stakeTokenizerAddress)
// get a reference to the SFTM contract
sftmAddress = stakeTokenizer.sFTMTokenAddress()
sftm = web3.ftm.contract(ERC20_ABI).at(sftmAddress)
The call mints SFTM tokens equal to current stake amount (either validator stake amount or delegation stake amount) minus current outstanding SFTM balance
User's stake has to be locked.
The increases the outstanding SFTM balance by the minted amount of SFTM tokens.
If user is deactivated or has started a full withdrawal, then the call with revert.
Pay attention that it's impossible to start a stake withdrawal if user has an outstanding SFTM balance.
The call can be used by both validator and delegator:
- Validator has to pass his stakerID as an argument
- Delegator has to pass validator's stakerID as an argument
Checks:
- User isn't deactivated
- User hasn't started a full withdrawal
- User's stake is locked
- User's outstanding balance is strictly smaller than user's stake amount
stakeTokenizer.mintSFTM(stakerID, {from: "0xAddress"})
stakeTokenizer.outstandingSFTM("0xAddress", stakerID)
The call burns the SFTM tokens and decreases the outstanding SFTM balance by the burnt amount.
The call can be used by both validator and delegator:
- Validator has to pass his stakerID as an argument
- Delegator has to pass validator's stakerID as an argument
sftm.approve(stakeTokenizer.address, web3.toWei("amount", "ftm"), {from: "0xAddress"})
stakeTokenizer.redeemSFTM(stakerID, web3.toWei("amount", "ftm"), {from: "0xAddress"})
Checks:
- User's outstanding balance is not smaller than the amount to redeem