NFTXInventoryStakingV3Upgradeable
NFTXInventoryStakingV3Upgradeable.sol
This contract allows users to stake vTokens to earn fees. Inventory staking positions are minted as xNFTs.
Table of Contents
Constants
MINIMUM_LIQUIDITY
The minimum amount of vToken required to be staked if the total vToken shares are 0 for that vault.
VTOKEN_TIMELOCK
The timelock applied to all xNFTs made by depositing vToken, even if forceTimelock
is false.
WETH
Address of WETH
contract.
PERMIT2
Address of PERMIT2 contract.
nftxVaultFactory
Address of NFTX Vault Factory.
timelockExcludeListYeah
List of addresses excluded from having timelocks enforced.
MAX_TIMELOCK
Max timelock duration possible to have set.
MAX_EARLY_WITHDRAW_PENALTY
Max early withdrawal penalty, 10e16 = 1%.
BASE
Equal to 10e18.
Variables
timelock
The timelock duration applied to a position (when minted with NFTs or with forceTimelock).
earlyWithdrawPenaltyInWei
Early withdrawal penalty. 1e16 = 1%.
positions
Inventory staking data related to each positionId.
vaultGlobal
Inventory staking data related to each vaultId.
descriptor
Contract responsible for generating tokenURI for xNFT positions.
Events
Deposit
Emitted by deposit()
.
Parameters | Type | Description |
---|---|---|
vaultId |
| ID of vault. |
positionId |
| ID of staking position. |
amount |
| Amount of vToken being deposited. |
forceTimelock |
| Whether to force a full timelock. Forcing a full timelock allows vToken inventory stakers to off-ramp to NFTs (without paying redeem fees) when they are done staking. |
DepositWithNFT
Emitted by depositWithNFF()
.
Parameters | Type | Description |
---|---|---|
vaultId |
| ID of vault. |
positionId |
| ID of staking position. |
tokenIds |
| Token IDs of NFTs being deposited. |
amounts |
| Amounts of NFTs (for ERC1155). |
CombinePositions
Emitted by combinePosition()
.
Parameters | Type | Description |
---|---|---|
parentPositionId |
| ID number of parent position. |
childPositionIds |
| ID numbers of child positions being merged into parent. |
CollectWethFees
Emitted by collectWethFees()
.
Parameters | Type | Description |
---|---|---|
positionId |
| ID of staking position. |
wethAmount |
| Amount of WETH. |
Withdraw
Emitted by withdraw()
.
Parameters | Type | Description |
---|---|---|
positionId |
| ID of staking position. |
vTokenShares |
| Amount of vToken shares subtracted from the position as a result of removing vToken. |
vTokenAmount |
| Amount of vToken returned to sender. |
wethAmount |
| Amount of WETH (fees) returned to sender. |
UpdateTimelock
Emitted by setTimelock()
.
Parameters | Type | Description |
---|---|---|
newTimelock |
| New timelock duration. In seconds. |
UpdateEarlyWithdrawPenalty
Emitted by setEarlyWithdrawPenalty()
.
Parameters | Type | Description |
---|---|---|
newEarlyWithdrawPenaltyInWei |
| New early withdrawal penalty. 1e16 = 1%. |
Write Functions
deposit
Pulls vToken from the caller and returns an xNFT inventory staking position. Uses Uniswap's Permit2 contract for vToken approval and transfer, if specified. The xNFT position will have a 1-hour (hard) timelock, during which time the position cannot be withdrawn.
If the deposit is the first deposit that the inventory staking pool has ever received, then MINIMUM_LIQUIDITY
(i.e, 1000 wei) of the vTokenShares are locked up forever to prevent front-running attacks.
If forceTimelock
is set to false, then no regular timelock is applied and the position can be increased using increasePosition()
but the owner of the position can only withdraw/off-ramp back to vToken (not NFTs).
If forceTimelock
is set to true, then a regular 3-day timelock is applied in addition to the hard 1-hour timelock. Unlike the hard 1-hour time-lock, the regular 3-day timelock allows early withdrawals by charging a fee that begins at 10% and goes down linearly to zero over the duration of the timelock. The benefit of setting forceTimelock
to true
is that the owner of the position can withdraw/off-ramp to either vToken or NFTs.
Parameters | Type | Description |
---|---|---|
vaultId |
| The vault ID of the vToken being deposited. |
amount |
| The amount of vToken to deposit. |
recipient |
| The address which will receive the xNFT. |
encodedPermit2 |
| Encoded Permit2 data: |
viaPermit2 |
| Whether to use Permit2. |
forceTimelock |
| Whether to force a full 3-day timelock. See paragraph above for more details. |
Return values | Type | Description |
---|---|---|
positionId |
| ID of the new inventory position. |
depositWithNFT
Pulls NFTs from sender, mints, and stakes vToken, and returns an xNFT inventory staking position. The xNFT position will have a 3-day timelock, during which time an early withdrawal penalty is charged in vToken if the owner of the position decides to withdraw. The early withdrawal penalty is 10% of the position and goes down linearly to zero over the duration of the timelock.
If the deposit is the first deposit that the inventory staking pool has ever received, then MINIMUM_LIQUIDITY
(i.e, 1000 wei) of the vTokenShares are locked up forever to prevent front-running attacks.
Parameters | Type | Description |
---|---|---|
vaultId |
| Vault ID of the vToken to be minted and staked. |
tokenIDs |
| Token IDs of NFTs being deposited. |
amounts |
| Amounts of NFTs (for ERC1155). |
recipient |
| Address which receives the xNFT. |
Return values | Type | Description |
---|---|---|
positionId |
| ID of the newly minted xNFT inventory position. |
increasePosition
Increases the size of an inventory staking position that was created using vToken and did not force a regular 3-day timelock. Positions can be increased more than once as long as forceTimelock
is false
. After a position is increased with forceTimelock
as true
, then it can no longer be increased. It can, however, still be combined with other positions.
Parameters | Type | Description |
---|---|---|
positionId |
| ID number of staking position. |
amount |
| Amount of vToken. |
encodedPermit2 |
| Encoded Permit2 data: |
viaPermit2 |
| Whether to use Permit2. |
forceTimelock |
| Whether to force a regular timelock. If a full timelock is enforced, then the position can not be increased again; however, it can still be combined with other positions. |
withdraw
Reduces a position's vTokenShares
and returns vToken/NFTs and ETH to the caller. Charges an early withdrawal penalty, paid in vToken, if the position has an active timelock. The penalty begins at 10% and goes down linearly to zero over the 3-day timelock duration. Early withdrawals are not possible for vToken -created positions unless they forced a full 3-day timelock,
Parameters | Type | Description |
---|---|---|
positionId |
| ID of the position. |
vTokenShares |
| Number of vTokenShares to withdraw. |
nftIds |
| NFT IDs to redeem. |
vTokenPremiumLimit |
| Max total premium fee (denominated in vToken) to be paid. |
|
| Amount of ETH to send. |
combinePositions
Merges one or more child positions into a parent position. Requires that there are no timelocks remaining on any of the child positions.
Parameters | Type | Description |
---|---|---|
parentPositionId |
| The position that child positions merge into. |
childPositionIds |
| The positions being merged into a parent position. |
collectWethFees
Claims WETH fees from one or more positions.
Parameters | Type | Description |
---|---|---|
positionIds |
| IDs of the positions. |
receiveWethRewards
Retrieves WETH rewards. Only callable by fee distributor.
Parameters | Type | Description |
---|---|---|
vaultId |
| ID number of vault. |
wethAmount |
| Amount of WETH. |
Return values | Type | Description |
---|---|---|
rewardsDistributed |
| True if function completes successfully. |
Owner Functions
setTimelock
Sets the timelock duration for future deposits.
Parameters | Type | Description |
---|---|---|
timelock_ |
| New timelock duration, in seconds. |
setEarlyWithdrawPenalty
Sets the early withdraw penalty for current and future deposits.
Parameters | Type | Description |
---|---|---|
earlyWithdrawPenaltyInWei_ |
| New early withdraw penalty. 10e16 = 1%. |
Read Functions
pricePerShareVToken
Returns the ratio of vTokens per share.
Parameters | Type | Description |
---|---|---|
vaultId |
| Vault ID of the vToken. |
Name | Type | Description |
---|---|---|
unnamed |
| vTokens per share. |
wethBalance
Returns the amount of WETH that can be claimed by the xNFT with positionId
.
Parameters | Type | Description |
---|---|---|
positionID |
| ID of position. |
Return values | Type | Description |
---|---|---|
unnamed |
| WETH balance of position. |
Last updated