-
Notifications
You must be signed in to change notification settings - Fork 11
SFTM calls reference
Egor Lysenko edited this page Dec 15, 2020
·
6 revisions
// 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
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 outstanding balance is strictly smaller than user's stake amount
stakeTokenizer.mintSFTM(stakerID, {from: "0xAddress"})
stakeTokenizer.outstandingSFTM("0xAddress", stakerID)
The calls burns the SFTM tokens and decreases 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
sftm.approve(stakeTokenizer.address, amount, {from: "0xAddress"})
stakeTokenizer.redeemSFTM(stakerID, amount, {from: "0xAddress"})
Checks:
- User's outstanding balance is not smaller than the amount to redeem