Staking Pools
In the following subsections, we will detail the functions related to staking tokens and farming liquidity pool tokens that have been defined in the Infinity Protocol.
There is a factory that creates the pools similar to the trading pairs factory, however there is no router so any interaction should be directly with an individual pool other than for the functions createPool and distributeReward which interact with the factory.
The stakeWithPermit function allows the wallet to sign an off-chain approval message to be sent with the stake. This saves the user gas and time over the standard method of having to first push an approval transaction before staking.
Anyone can create a pool or distribute a reward by calling these functions in the factory, (the ability to create a staking pool will be built into the Infinity Crypto interface in a future release, allowing anyone to easily create a reward pool for staking or yield farming):

createPool

Anyone can use this function to create a new staking or farming pool for tokens or liquidity pool tokens without needing to add the rewards on creation.
1
function createPool(
2
address rewardsToken,
3
address stakingToken
4
)
5
6
returns (address pool)
Copied!
The createPool function accepts these parameters:
Type
Parameter
Description
rewardsToken
address
The address of the token or liquidity pool token for rewards
stakingToken
address
The address of the token or liquidity pool token to stake

distributeReward

Anyone can use this function to add rewards and set the duration of rewards for a staking or farming pool, or to top-up an existing active or inactive pool.
If you use this function and the staking or farming pool does not yet exist then it will automatically create the pool and add the rewards in the same call.
All pools are infinitely reusable and anyone can add rewards or extend the duration. The rewards are protected from manipulation as explained in the Core Concepts section for Staking & Farming.
1
function distributeReward(
2
address rewardsToken,
3
address stakingToken,
4
uint duration,
5
uint extraReward
6
)
Copied!
The distributeReward function accepts these parameters:
Type
Parameter
Description
rewardsToken
address
The address of the token or liquidity pool token to rewards
stakingToken
address
The address of the token or liquidity pool token to stake
duration
uint
The duration in seconds to distribute the rewards over
extraReward
uint
The amount of rewards you want to deposit to the staking or yield farming

stake

This function allows a wallet to stake a token or liquidity pool token for a specific reward pool.
Use the functions below directly by interacting with the individual rewards pool address.
1
function stake(
2
uint amount
3
)
Copied!
The stake function accepts these parameters:
Type
Parameter
Description
amount
uint
The amount to stake

stakeWithPermit

This function allows the wallet to sign an off-chain approval message to be sent with the stake transaction of a token or liquidity pool token for a specific reward pool.
Use the functions below directly by interacting with the individual rewards pool address.
1
function stakeWithPermit(
2
uint amount,
3
uint deadline,
4
bool approveMax,
5
uint8 v,
6
bytes32 r,
7
bytes32 s
8
)
Copied!
The stakeWithPermit function accepts these parameters:
Type
Parameter
Description
amount
uint
The amount to stake
deadline
uint
The Unix-time deadline for which the transaction must be confirmed before.
approveMax
bool
Whether or not the approval amount in the signature is for amount or uint(-1)
v
uint8
The v component of the permit signature.
r
bytes32
The r component of the permit signature.
s
bytes32
The s component of the permit signature.

withdraw

By calling this function it will withdraw ("Unstake") an amount of staked tokens or liquidity pool tokens that a wallet is staking in a reward pool.
Use the functions below directly by interacting with the individual rewards pool address.
1
function withdraw(
2
uint amount
3
)
Copied!
The withdraw function accepts these parameters:
Type
Parameter
Description
amount
uint
The amount to unstake

getReward

By calling this function it will claim a wallets current accumulated rewards from a reward pool.
Use the functions below directly by interacting with the individual rewards pool address.
1
function getReward()
Copied!

exit

By calling this function it will claim a wallets current accumulated rewards and then withdraw ("Unstake") the total amount of staked tokens or liquidity pool tokens that the wallet has in the reward pool.
Use the functions below directly by interacting with the individual rewards pool address.
1
function exit()
Copied!
Last modified 5mo ago