How to create a Uniswap V3 staking program
Learn how to configure and deploy your own Uniswap V3 staking program
By Mark Curchin
Have a suggestion?
Edit ArticleWhile the smart contracts have been up and running since the summer 2021, the Uniswap team has not provided any user interface to launch, manage or stake LP tokens. This is why we have decided to share our experience of launching the Uniswap Staking program. In this article we will walk you through the steps necessary to launch your own Uniswap v3 staking program.
Before you begin
All the examples in this guide are made using Rinkeby testnet. If you want to play directly on the Mainnet, you will need to use the Mainnet addresses listed in the Uniswap repository.
Before proceeding with staking, you must provide liquidity to your liquidity pool and receive the NFT position. To do it, head to the Uniswap application . If you don’t have a pool yet, Uniswap will automatically create one for you when you provide liquidity for the first time.
Incentive program
What is the Uniswap Staking incentive program?
The entire Uniswap v3 stake revolves around incentive programs. It represents your liquidity mining program or staking instance inside their smart contracts. An incentive program is like a pool with a limited amount of tokens to distribute in which staking takes place.
Deploying incentive program
You won't have to build your own interface to deploy an incentive program or conclude it. Since these are just administrator actions, Etherscan’s interface will be sufficient to cover the creation of the program.
Note: You can’t create multiple Incentive Programs for the same Uniswap v3 Pool Pair. To create a new one, you will have to wait for the current program to end.
To deploy an incentive program, you will need the following things prepared:
- rewardToken - y our ERC20 tokens address
- pool - Uniswap v3 pair pool address
- startTime - s tart date in Unix timestamp
- endTime - e nd date in Unix timestamp
- refundee - refundee address
- t okens on your wallet that you will transfer to your incentive program for distribution.
- Approve the amount of tokens you are about to transfer into the Staker contract.
How to find your Uniswap v3 pair pool address?
- In the Etherscan find the Uniswap v3 pool creation transaction
- Open the logs tab and search the following information
- Open the Uniswap v3 PoolFactory contract in a new tab and switch to the Read the contract
- Copy the information from Step 2 into the getPool tab
- Click Query and view the pool address
How to approve token transfer
Before you can create your Incentive program, you must approve the token transfer into the Staker contract. Otherwise, the createIncentive transaction will fail.
- Open your token contract in Etherscan and switch to Write Contract tab
- Connect your wallet
- Find the approve transaction and complete the following information
- _spender - the Staker contract address
- _value - the amount of token you want to use for the incentive program in Wei.
- Click Write and submit the transaction. Once successfully executed, you can proceed with the next step.
Create incentive
Back to the Incentive program, you’ll need to follow the next steps for successful deployment:
- Open Uniswap v3 Staker contract in Etherscan and switch to Write contract
- Connect your wallet
- Find the createIncentive tab and write the addresses you prepared in the beginning of this guide, in the following order
["REWARD_TOKEN_ADDRESS","POOL_ADDRESS",START_DATE,END_DATE,"REFUNDEE_ADDRESS"]
Make sure the addresses are written between quotation marks.
- In the reward input write the amount of tokens you want to distribute. The value must be written in Wei depending on your token decimals. Use this handy Unit Converter to convert from regular numbers into Wei.
- Click Write and follow the instructions in your wallet.
Example:
Congrats! 🎉 If you have followed our guide closely, you have successfully deployed your Incentive program.
Coming up next
In our next article, we are going to walk you through the staking process. You will learn how to query the information from the blockchain, what an interface for the users should include, and what is required to claim rewards.
Next: holdex.io/c/learn/...