Methods

Register Strategy

function registerStrategy(
    address _strategyAddress,
    address _principalTokenAddress,
    string calldata _fTokenName,
    string calldata _fTokenSymbol
) external

With the registerStrategy method, you can register a custom strategy for Flashstaking. It takes as parameters:

  • _strategyAddress: your strategy’s smart contract address (see Flash Strategy)

  • _principalTokenAddress: your strategy’s principal token (staked and received). For example, if your strategy is used to stake DAI, _principalTokenAddress would be the DAI stablecoin’s smart contract address.

  • _fTokenName: what the fToken minted when Flashstaking/staking shall be called.

  • _fTokenSymbol: which symbol should be given to the fToken minted when Flashstaking/staking.

Naming convention must be followed to be added to the official frontend.

The naming convention for _fTokenSymbol is a function of the principal token symbol and the first four letters of your strategy - eg fDAI-0123

Stake

function stake(
    address _strategyAddress,
    uint256 _tokenAmount,
    uint256 _stakeDuration,
    address _fTokensTo,
    bool _issueNFT
) public nonReentrant returns (StakeStruct memory _stake) {

The stake method creates a new stake with a registered strategy of your choosing. Its parameters are:

  • _strategyAddress: address of a registered strategy. You have to register the strategy with the above-described registerStrategy method first before passing its address here.

  • _tokenAmount: amount (in Wei) of staked tokens.

  • _stakeDuration: total duration (in seconds) of the stake.

  • _fTokensTo: the address the minted fTokens shall be sent to.

  • _issueNFT: mint stake as NFT upfront.

Redirecting fTokens by providing a different address in the _fTokensTo address will result in only the resulting fTokens to be redirected. The Stake ownership will be retained by the caller. This also means when minting a FlashNFT, this will be retained by the caller (Staker).

Flashstake

function flashStake(
    address _strategyAddress,
    uint256 _tokenAmount,
    uint256 _stakeDuration,
    uint256 _minimumReceived,
    address _yieldTo,
    bool _mintNFT
) external {

The flashStake method is similar to stake, which it calls before burning the minted fTokens for yield. Upon staking, the fTokens minted will be held by the Flash Protocol and then immediately burned with the resulting yield being redirected to _yieldTo.

Redirecting yield by providing a different address in the _yieldTo address will result in only the resulting yield to be redirected. The Stake ownership will be retained by the caller. This also means when minting a FlashNFT, this will be retained by the caller (Staker).

Unstake

function unstake(
    uint256 _id,
    bool _isNFT,
    uint256 _fTokenToBurn
) external nonReentrant returns (uint256 _principalReturned, uint256 _fTokensBurned) {

The unstake method unstakes your Flashstake/stake, either partially or completely. Parameters:

  • _id: your stake’s ID.

  • _isNFT: true if your stake has been minted as an NFT; false otherwise.

  • _fTokenToBurn: amount of fTokens to be burnt to unstake your desired amount of principal for your stake.

Stakes that have ended should pass 0 in the _fTokenToBurn parameter.

NFTs are not burned when unstaking - that means the NFTs live forever.

Issue NFT

function issueNFT(uint256 _stakeId) public returns (uint256 _nftId) {

This methods issues an NFT from a given stake. It can be called at anytime after the stake’s creation, if an NFT wasn’t initially minted.

It returns the NFT’s ID, which is different from the stake’s ID passed as parameter.

Get stake info

function getStakeInfo(uint256 _id, bool _isNFT) external view returns (StakeStruct memory _stake) {

This method will return all the information for a given stake. The information returned is as follows:

struct StakeStruct {
    address stakerAddress; // Address of staker
    address strategyAddress; // Address of strategy being used
    uint256 stakeStartTs; // Unix timestamp of when stake started
    uint256 stakeDuration; // Time in seconds from start time until stake ends
    uint256 stakedAmount; // The amount of tokens staked
    bool active; // Stake has been removed/unstaked
    uint256 nftId; // NFT id if set
    uint256 fTokensToUser; // How many fERC20 tokens were minted
    uint256 fTokensFee; // How many fERC20 tokens were taken as fee
    uint256 totalFTokenBurned; // The total fTokens burned against this Stake (early unstaking related)
    uint256 totalStakedWithdrawn; // The total staked tokens withdrawn from this Stake (early unstaking related)
}

Set Mint Fee Info

function setMintFeeInfo(address _feeRecipient, uint96 _feePercentageBasis) external onlyOwner {
  • _feeRecipient: the address the fees will go to

  • _feePercentageBasis: the percentage of fees to take upon fToken minting

It allows the Owner to set a global fToken mint fee up to a hardcoded maximum of 20%. This means if 1,000 fTokens are minted during the Stake process and the fee is set to 20%, the user will receive 800 fTokens.

This function can only be called by the Owner.

Last updated