PoolStake & Multiplier Contracts: Walk-Through

PoolStake & Multiplier Contracts: Walk-Through

Unistake

ContractA – Multiplier Contract


Purpose: To hold tokens of a user which can be locked up and use by ContractB to increase the percentage of Staking Bonuses that a person gets by joining a pool in ContractB.


ContractB – PoolStake Contract


Purpose 1: Projects (contract owner) use the contract to create incentives for liquidity providers on Uniswap.


Purpose 2: People use the contract to provide liquidity to Uniswap in return for a guaranteed bonus paid in either one or both of the tokens in the pair. When they use the contract the LP tokens from Uniswap are held in the contract for the period of time they selected and during this time they accumulate bonuses paid by the project who created the incentives.


Using the contract.


Owner Usage (A Project)


Write Functions:


1) changeTermPeriods


The first step is for the project to set the returns they wish to offer providers.


There is four terms entered in seconds. The project can add 1,2,3 or 4 terms. If entering less than 4 they will enter 0 which means there is no term.


These periods can be changed any time by the project/owner but anyone who has already joined the contract before the change will keep the same periods that were available when they joined.


2) changeReturnPercentages


The second step the project sets the maximum percentages they wish to offer. (1000 =1%)


There is 4 options for each of the pair. ETH and the Token.


These percentages can be changed any time by the project/owner but anyone who has already joined the contract before the change will keep the same percentages that were available when they joined.


When a owner sets a term, users will only be able to get the whole percentage if they are also using the Multiplier Contract (ContractA). If they do not use the Multiplier contract they will only receive 50% of the maximum percentage the owner has agreed to. (explained in more detail later)



3) addBonus


After adding the terms and percentages the project can add bonus that people will get when providing liquidity. Anyone can add bonus via this function, not just the project. This allows projects to get donations by the community. If a person donates they will not be able to take their donation back as only the contract owner can withdraw bonuses.


depending on what bonus they wish to offer they can add ETH or Tokens or both.




4) changeCap


This allows the contract owner to add a limit of the amount of liquidity any one wallet can provide into the addLiquidity function. The owner will add a ETH amount that it will allow maximum.


0 = No limit



Once these functions have been done a user can begin to provide liquidity



5) RemoveETHAndTokenBonuses


An owner can withdraw the bonus they or anyone else added if they wish to reduce the amount of liquidity they will be able to build via the contract.


They cannot remove any bonus that has already been assigned to a person who has already joined the contract.



6) allowMigration


The migration feature of the contract allows the project/owner to start an optional migration process for all users of the contract. This feature is designed for when Uniswap V3 or above is launched and it will work with a yet to be developed Unistake Migration Contract.


The Unistake Migration Contract will work as follows


a) Receive LP tokens from the PoolStake contract after the user starts migration.

b) Send the LP tokens back to Uniswap V2

c) Receive the ETH and Tokens from Uniswap

d) Send the ETH and Tokens to Uniswap V3

e) Receive the new LP tokens from Uniswap V3

d) Hold the LP tokens until the lock up period of the users PoolStake is complete.



The migration works as follows.


a) The wner adds the “Unistake Migration Contract” address to the allowMigration function


b) This allows all user already in the contract the ability to use the startMigration function.


When they use this function they will have to add the same Unistake Migration Contract address, this will then send their LP tokens held by the contract to the address.


FAIL SAFE:

Both the project and the user MUST input the same address for the Unistake Migration Contract or the LP tokens will not be able to moved. The contract will be provided and displayed by the Unistake UI and will also ensure that users are educated to check the address. This is to protect users from owners who could add the wrong address in order to collect the LP tokens for themselves.


7) transferOwnership


The owner can transfer ownership of the contract by using the transfer ownership function. This gives a new owner the ability to change terms etc.


_________________________________________________


Using the contract.


Liquidity Provider


1) addLiquidity


A person wishing to add liquidity to the pair available will use this function.


addliquidity = the amount of ETH they wish to put. This then calls Uniswap pair contract to check the correct proportions of ETH/Tokens.


Term = one of the 4 available periods that the owner created.


Multiplier = If the user wishes to use their balance from the Multiplier contract or not. If 0 is entered Multiplier will not be used, if any other number is entered it will be.


Once a person uses this function without Multiplier the following will happen:


a) The contract will ask for an approval of the amount of tokens they need to approve

b) The ETH and Tokens will be sent to Uniswap

c) The LP tokens minted by Uniswap will be sent to the contract.

d) The contract will lock the LP tokens for the selected period.

e) The user will begin to accumulate Staking Bonuses provided by the owner. They will get 50% of the maximum available percentage offered by the contract owner as they did not use Multiplier.


Once a person uses this function with Multiplier the following will happen:


a) The contract will ask for an approval of the amount of tokens they need to approve

b) The contract will check if they have approved this contract on their Multiplier

c) If approved will read the value they have in their Multiplier and add that value to the amount of liquidity the user is providing and use the combined number to calculate the Staking Bonus.

b) The contract will update the Multiplier lock up period with the time selected by the users.


If there is available bonus at the end of the term, a provider can also use this function again to add more liquidity to and join a new lock up period.


Example of Multiplier. ContractA


The Multiplier essentially gives the ability for a user to get 2X returns from any pool they join by giving them the max possible bonus.


If a user was providing 1 ETH and 1 ETH worth of tokens into the liquidity pool and the contract owner set the max return as 10% the user would also need 1 ETH worth of UNISTAKE tokens in the Multiplier to receive that 10%.


If the user only had 0.1 ETH worth of UNISTAKE in their Multiplier they would have only receive 11% (1.1x)


The same Multiplier Balance can be used on unlimited pools, but the user must approve the contract first so the contract they join has permission to edit the lock up period. Each lock up period longer than the last overwrites the previous.


2) withdrawUserBonus


The user bonus comes from the tokens or ETH that was added via the addBonus function. Bonuses can be withdrawn by the user of the contract who is providing liquidity. Bonuses are accumulated pro-rata over the term that the user selected to have their LP tokens locked for.


Bonuses can be withdrawn any time along the term, multiple times or just once at the end.


When a user wishes to withdraw bonus they need to pay a fee in the UNISTAKE token equal to 10% of the total bonuses they are receiving. This is worked out by checking the current price of the UNISTAKE token against ETH on Uniswap and working it out accordantly based on the bonus they are withdrawing.



3) withdrawLiquidity


The user must have withdrawn all Staking Bonuses prior to using this function.


Once the lock up term selected by the user at the start has ended the user can call this function to withdraw their liquidity from Uniswap. They can withdraw some or all with this function.


The following will happen:


a) The contract will send the LP tokens back to Uniswap

b) The ETH and Tokens will be send to the users address.



4) withdrawUserLP


The user must have withdrawn all Staking Bonuses prior to using this function.


If a user does not wish to stop providing liquidity the user can use this function to withdraw the LP tokens directly to their wallet.


5) relockLiquidity


The user must have withdrawn all Staking Bonuses prior to using this function.


If there is available staking bonuses provided the user can relock their LP tokens for a new term.


6) startmigration


Explained above.


Report Page