Middle Staking Docs
  • 👋Welcome
    • Presentation
    • Stake Unstake Rewards
    • Deposit
      • Deposit fees
  • 🪙MID TOKEN
    • Distribution
    • Staking rewards
    • Buy & Sell
    • Use cases
  • 📔CONTRACTS
    • Staking Contract
      • Details
      • Functions
    • Swap contract
      • Details
      • Liquidity
      • Swap
    • NFT/SFT Staking Contract
      • Details
  • Liquidity & swap
Powered by GitBook
On this page
  1. CONTRACTS
  2. Staking Contract

Functions

Here is a summary of views and functions

PreviousDetailsNextSwap contract

Last updated 1 year ago

User functions

fund@staked_token

Once funded, the rewarded_token cannot be removed from a pool.

Must be called under ESDTTransfer function.

Transferred token will be set as reward (rewarded_token).

The staked_token define what token users will have to stake to harvest rewards

This function have a 10% default deposit fee for new pools. Fees can be cut forever on a pool with a $MID payment with removePoolFees function

stake@rewarded_token

Must be called under ESDTTransfer function.

Transferred token will be set as a staked_token.

User will have to choose the rewarded_token he want as reward

unstake@staked_token@rewarded_token@opt_unstake_amount

Allow to remove staked_token from a pool.

Time spent in pool will be reseted and calculated rewards harvested.

If opt_unstake_amount is not set the unstaked amount will be set to user max user position.

claimRewards@staked_token@rewarded_token

Will calculate rewards from the pool for user and send them to his wallet.

Time spent in pool will be reseted

stakeRewards@staked_token

Will calculate rewards from the pool. But instead to send rewards to user's wallet his position will be compounded.

Time spent in pool will be reseted

removePoolFees@staked_token@rewarded_token

Must be called under ESDTTransfer function.

This function will set to 0% the fees deposit of tokens in a pool. It can be called before the first deposit. The payment will be added to MID:MID pool as a staking rewards minus the fees set in MID:MID pool.

Owner functions

setFees@staked_token@rewarded_token@fees@burn@opt_blocks_to_max

Edit the configuration of a pool :

fees : Percentage of deposited token redirected to the "fee_wallet"

burn : Percentage of deposited token redirected to the "burn_wallet"

blocks_to_max : Configure the pool speed. Allowing to slow down or speed up rewards distribution of the pool.

setConfig@def_staked_token@fee_wallet@burn_wallet@remove_fees_price

Edit configuration

def_staked_token : Set the main token that will be used as payement

fee_wallet : set the wallet that will receive fees tokens

burn_wallet : set the wallet that will receive burn tokens

remove_fees_price : define price in main token to remove fees from a pool

pause
unPause

Pause functions of contract : fund, stake, stakeRewards, removePoolFees

Users can still unstake and claimRewards from all pools

pausePool@staked_token@rewarded_token
unpausePool@staked_token@rewarded_token

Pause main functions of a specific pool : fund, stake, stakeRewards, removePoolFees

Users can still unstake and claimRewards from the pool

close_pool@staked_token@rewarded_token

If a pool did not received any new fund after one year and is paused. This function allow to remove the pool from the contract and send all staked tokens to respective users. if some rewards are still in the pool, they will first be distributed to removed users based on their share and time spent in pool. The very last remaining tokens will then be sent to the burn wallet.

View functions

getDefTokenIdentifier -> Token identifier for payment
getRemoveFeesPrice -> Price to remove deposit fees
getBurnWallet -> Wallet address
getFeeWallet -> Wallet address
getStakedTokens -> unoredered array of token identifier

This array represent the list of tokens that can be staked in contract to get rewards

getRewardedTokens [staked_token] -> unoredered array of token identifier

This array represent the list of tokens that can be harvested for a specific staked token creating a staking pool from a pair staked_token:rewarded_token

getStakedAddresses [staked_token, rewarded_token]
-> unordered array of address

This array return the address list of participants in a specific pool

getTokenPosition [staked_token, rewarded_token]

Return pool information :

balance : Tokens availaibles as reward

total_stake : Tokens staked by users

total_rewarded : All time rewarded since the first fund

fee_percentage : Fund percentage (default 10%)

burn_percentage : "Burn" percentage (default 0%)

last_fund_block : Block of the last fund deposit

paused : Is the pool fund/stake/stakeRewards paused ?

blocks_to_max : Number of blocks a user has to stay in pool to claim 100% of his pool share. (default 5 256 000 ~one year)

getStakingPosition [ user_address, staked_token, rewarded_token]

Return user participation information in pool :

stake_amout : The amount of token staked by user

last_action_block : Last block since the user has called one of the stake/unstake/claimRewards/stakeRewards function

calculateRewardsForUser [ user_address, staked_token, rewarded_token]

Compute the current theoretical available rewards for user in pool.

{stake_amout} * {%} / {total_stake} * {balance} / {%} * {last_action_block} / {blocks_to_max} = theoretical rewards

Only for pools where staked_token = rewarded_token

📔
⚠️
❔