Supplying ETH (fixed duration)

Provisioning Pool (PP) Contract
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:
struct StakeData {
// @notice The time when the staking expires
uint256 expireTime;
// @notice The amount of underlying token staked
uint256 stakedUnderlying;
// @notice The virtual amount that keeps tracks the proportional underlying token share of this staking unit
uint256 virtualBalance;
// @notice The duration of this staking unit
uint256 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 minted
function stake(uint256 amount, uint256 duration) external override nonReentrant returns (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\text{redeemable} = \text{virtual balance} / \text{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 1e18
function getExchangeRateMantissa() public view override returns (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 unstaked
function unstake(uint256[] calldata tokenIds) external override nonReentrant returns (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 account
function getMaxClaimableUnderlying(address account) public view override returns (uint256)