Unless otherwise indicated, the PP contract only deals with ERC-20s. Currently, we support WETH only.
Stake WETH
Users can stake WETH to share the protocol’s earnings when profits are made from transaction fees and auctions. However, users cannot withdraw this deposit until the lockup period has passed. They may suffer from losses if there were defaulted positions liquidated at losses.
After staking WETH, users receive ERC-721s that denotes the following stake data:
structStakeData {// @notice The time when the staking expiresuint256 expireTime;// @notice The amount of underlying token stakeduint256 stakedUnderlying;// @notice The virtual amount that keeps tracks the proportional underlying token share of this staking unituint256 virtualBalance;// @notice The duration of this staking unituint256 duration;}
To stake WETH, users have to specify a lock duration and amount:
// @notice This function allows a user to stake 'amount' of underlying token for 'time' duration// @param amount The amount of underlying token to be staked// @param time The duration of the staking unit// @return The provisioningPool Nft tokenId mintedfunctionstake(uint256 amount,uint256 duration) externaloverridenonReentrantreturns (uint256)
Unstake WETH
After the lockup period, users can unstake WETH and earn the accumulated protocol fee and auction profits. The total redeemable from a PP ERC-721 is calculated by:
redeemable=virtual balance/exchange rat
To obtain the exchange rate:
// @notice This function returns the current exchange rate between totalVirtualSupply vs underlying token balance// @return Current exchange rate, scaled by 1e18functiongetExchangeRateMantissa() publicviewoverridereturns (uint256)
To unstake:
// @notice This function allows a user to unstake underlying tokens from the provisioningPool, given an array of provsisioningPool Nft tokenIds// @param tokenIds An array of provisioningPool tokenIds// @return The total amount of underlying tokens unstakedfunctionunstake(uint256[] calldata tokenIds) externaloverridenonReentrantreturns (uint256)
Helper functions
The following functions are helpful in getting the maximum redeemable WETH after lockups.
// @notice This function returns the total claimable underlying token of an account// if the user has multiple staking units (pp Nft), it will return the sum// @param account The account whose total claimable underlying token is to be calculated// @return total claimable underlying token of an accountfunctiongetMaxClaimableUnderlying(address account) publicviewoverridereturns (uint256)