Test - How to create a Uniswap V3 staking program

By Markely

Table of Contents

As a part of the V3 version of the protocol, Uniswap has introduced a Staking as a Service set of smart contracts to enable protocols to launch liquidity mining programs. These programs aim to boost the liquidity provided within the Uniswap V3 pair pool and reward the stakers. While the smart contracts have been up and running for more than 6 months, Uniswap has not provided an interface to launch, manage or stake the tokens. Luckily, we been there already and are happy to walk you through these steps, so you and your team can launch a staking program today.

Short about Uniswap V3 🦄

Like we all know, in V3 of Uniswap the concept of liquidity pools remained the same. What has changed, is that Liquidity providers will not receive LP tokens in proportion to the provided liquidity anymore. Instead, they introduced a new concept where the information about liquidity is stored in an NFT position (ERC721 token) that is minted upon deposit. This NFT stores information about how much liquidity has been deposited, who is the owner and what are the lower and upper price ticks. If you’d like to know more about it, make sure to check the introduction article by Uniswap.

Important notes

The links and contract addresses in this guide are for the Rinkeby network. When going into production, you will have to use Mainnet addresses.

Before proceeding with staking, you must provide liquidity to your pair 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 an incentive program?

The entire Uniswap V3 stake revolves around incentive programs. It represents your liquidity mining program or staking instance inside their smart-contracts. 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, the Etherscan’s interface will be sufficient to cover creation of the program. You can also use Remix if you are familiar with it.

ℹ️ 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 existing one to end.

To deploy an incentive program, you will need the following things prepared:

  1. Your ERC20 tokens address - rewardToken
  2. Uniswap V3 pair pool address - pool
  3. Start date in Unix timestamp - startTime
  4. End date in Unix timestamp - endTime
  5. Refundee address - refundee
  6. Tokens on your wallet that you will transfer in your Incentive program for distribution - reward
  7. Approve the amount of tokens you are about to transfer into Staker contract.

How to find your Uniswap V3 pair pool address?

1. Find the transaction responsible for the Uniswap V3 pool creation

2. Open the logs tab and search the following information

3. Open the Uniswap V3 PoolFactory contract in a new tab and switch to Read contract

4. Copy the information from Step 2 into the getPool tab

5. 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.

  1. Open your token contract in Etherscan and switch to Write Contract tab
  2. Connect your wallet
  3. Find the approve transaction and complete the following information
  4. _spender - the Staker contract address
  5. _value - the amount of token you want to use for the incentive program in Wei. Should be identical to reward amount from earlier.
  6. Click Write and submit the transaction. Once successfully executed, you can proceed with the next step.

Create incentive

Moving forward to the Incentive program, you’ll need to follow the next steps for successful deployment:

1. Open Uniswap V3 Staker contract in Etherscan and switch to Write contract

2. Connect your wallet

3. Find the createIncentive transaction 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.

4. 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.

5. 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.

Contact Us

We’d love to hear from you on discussing potential projects, intriguing ideas, and new opportunities.