LP tokens are ERC20 tokens you receive by providing liquidity on exchanges suchs as Uniswap or Sushiswap.
Projects that incentivizes you adding liquidity, will offer you with high yield opportunities if you deposit your LP tokens into their "staking contracts".
Today, when more than 1 project benefits from you adding liquidity, you can only get yield from one staking contract at the same time.
With WRAP LP you can take advantage of multiple high yield opportunities from different staking contracts at the same time by providing liquidity one time.
Also WRAP LP offers more safety for users as they don't have to trust multiple projects in handling correctly their LP tokens. Your NFT holding the LP tokens stays in your hand and is always exchangeable for your initial tokens.
WRAP LP is a simple contract (inspired by WETH) that will let you wrap your ERC20 tokens and give you an ERC721 NFT representation of your deposited tokens.
WRAP LP's keep track of the LP token address, amount and the block height you wrapped your original LP tokens.
Staking contracts can check the NFT you own and it's details and give you yield without you depositing your NFTs (or LP tokens) into their staking contract.
When you want to pull liquidity you just deposit the NFT back to the WRAP LP contract, the NFT gets burned and you get your LP tokens back.
This scheme creates a secure trustless way of getting yield from different staking contracts at the same time.
// Register your wrapped lp tokens NFT to DuckChef for $YIELD allocation.
function register(uint256 _pid, uint256 _nftId) public {
PoolInfo storage pool = poolInfo[_pid];
(address _erc20address, uint256 _amount, ) = wrapLp.getNFTInfo(_nftId);
require(_erc20address == address(pool.lpToken), "NFT don't match pool");
require(wrapLp.ownerOf(_nftId) == msg.sender, "!owner");
NftInfo storage nft = nftInfo[_nftId];
require(nft.amount == 0, "Can't register twice");
updatePool(_pid);
nft.amount = _amount;
emit Deposit(msg.sender, _pid, _nftId);
}
// Withdraw yield from previously registerd NT.
function withdraw(uint256 _pid, uint256 _nftId) public {
PoolInfo storage pool = poolInfo[_pid];
// does nft token match pool?
(address _erc20address, , ) = wrapLp.getNFTInfo(_nftId);
require(_erc20address == address(pool.lpToken), "NFT don't match pool");
require(wrapLp.ownerOf(_nftId) == msg.sender, "!owner");
NftInfo storage nft = nftInfo[_nftId];
updatePool(_pid);
uint256 pending =
nft.amount.mul(pool.accTokenPerShare).div(1e12).sub(nft.rewardDebt);
if (pending > 0) {
safeTokenTransfer(msg.sender, pending);
}
// delete/unregister this NFT as it is paying off all earnings up until this point.
//User can register it again if he wishes to restart getting yield
delete nftInfo[_nftId];
emit Withdraw(msg.sender, _pid, _nftId);
}
We created WRAP LP as a solution for our NFT DEX to use it in prod starting Jan 15th.
We have examples of incentivizer (check out DuckChef.sol) contracts on our Github and all our code is open sourced under MIT License. Feel free to contact us if you need help implementing WRAP LP in your project.
WRAP LP was created by @jdourlens and @surfcoderepeat from VeryNifty.