# Functions

**User functions**

```rust
fund@staked_token
```

:warning: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
```

:grey\_question:Only for pools where staked\_token = rewarded\_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&#x20;

def\_staked\_token : Set the main token that will be used as payement&#x20;

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

```rust
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

<pre><code><strong>getRewardedTokens [staked_token] -> unoredered array of token identifier
</strong></code></pre>

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 :&#x20;

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 :&#x20;

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

```rust
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


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.middlestaking.fr/contracts/staking-contract/functions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
