vNFT
Inherits: IvNFT, NFT, IERC4907, Administrable, Initializable, Implementation, WithdrawRecipientLike
Author: mortimr @ Kiln
Mint or Purchase 1 NFT = own 1 validator
State Variables
$uriPrefix
URI prefix used when return the token URI
Slot: keccak256(bytes("nft.1.uriPrefix")) - 1
types.String internal constant $uriPrefix = types.String.wrap(0xb23e3bb81f905722c3794f66661b6f02d2c6087f3a9f12bd1009a955eaad6308);
$users
Internal mapping of ERC4907 users of the vNFTs
Type: mapping(uint256 => User4907)
Slot: keccak256(bytes("nft.1.users")) - 1
victypes.User4907Mapping internal constant $users =
victypes.User4907Mapping.wrap(0x063e58580d7c13f4d3c3ec935e3940c26f6f92139f3a108a5c025f3c3da5f8f9);
$debts
Internal mapping that holds the users claimable amounts
Type: mapping(address => uint256)
Slot: keccak256(bytes("nft.1.debts")) - 1
types.Mapping internal constant $debts = types.Mapping.wrap(0xcf62cc6e8953d10a2b46e09153848eaa59d6d313efd4ecd09e2b83409cc17e35);
$exited
Mapping of exited validators
Type: mapping(uint256 => bool)
Slot: keccak256(bytes("nft.1.exited")) - 1
types.Mapping internal constant $exited = types.Mapping.wrap(0xdc21987bff09d5261da331a08f03af33a49a1c9fe4e372e05137aed79ab72b33);
$factory
The address of the vFactory on which to purchase validators
Slot: keccak256(bytes("nft.1.factory")) - 1
types.Address internal constant $factory = types.Address.wrap(0x69fff1d77a01147a75b9614d339245cc8f1075258f85be20988953987e69783a);
$execLayerVault
The address of the exec layer vault
Slot: keccak256(bytes("nft.1.execLayerVault")) - 1
types.Address internal constant $execLayerVault = types.Address.wrap(0x504c75548da90f3ba5db2f94526211f0da12946a5d5ab4a7b787b3270210514a);
$operatorCommission
The amount of commission for the operator in BPS
Slot: keccak256(bytes("nft.1.operatorCommission")) - 1
types.Uint256 internal constant $operatorCommission = types.Uint256.wrap(0x3ecd15633a9e1be6395424838175447849914b9f35caa0570337a2a0396911ca);
$integratorCommission
The amount of commission for the integrator in BPS
Slot: keccak256(bytes("nft.1.integratorCommission")) - 1
types.Uint256 internal constant $integratorCommission =
types.Uint256.wrap(0x19c4145f70cb99496e96425cc5375ced77e11a35c610c19bd5aec35915951c0e);
$integrator
The address of the integrator
Slot: keccak256(bytes("nft.1.integrator")) - 1
types.Address internal constant $integrator = types.Address.wrap(0xa223bf738f821902c37d691cd3d2245a32d29a94501405b450683b11b37651a9);
$extraData
The extra data to use on deposit
Slot: keccak256(bytes("nft.1.extraData")) - 1
types.String internal constant $extraData = types.String.wrap(0x86632fa758a836bd2779078b54de6c13be658e32417419da0cc171a4d5e3da1f);
$purchasePaused
True if purchase is paused
Slot: keccak256(bytes("nft.1.purchasePaused")) - 1
types.Bool internal constant $purchasePaused = types.Bool.wrap(0xb36aa111209ed0d56f6cc61559fc12c9e3dafc7aed648c08f210659bebb89843);
$soulboundMode
True if soulbound mode is active
Slot: keccak256(bytes("nft.1.soulboundMode")) - 1
types.Bool internal constant $soulboundMode = types.Bool.wrap(0x1fbbb393c185a82e26c2092a2238ba94403f2971f3ed9bcb79897a3b64dc200a);
$internalIds
The mapping of externals ids to internals ids
Type: mapping(uint256 => uint256)
Slot: keccak256(bytes("nft.1.internalsIds")) - 1
types.Mapping internal constant $internalIds = types.Mapping.wrap(0x11b9d9a342fd6e66f51a8fc0110e510978d892e0c91d751b16aeafd1e6e42304);
WITHDRAWAL_CHANNEL
The withdrawal channel to use when purchasing validators from the factory
bytes32 private constant WITHDRAWAL_CHANNEL = bytes32(0);
FACTORY
uint8 private constant FACTORY = 0;
EXEC_LAYER_VAULT
uint8 private constant EXEC_LAYER_VAULT = 1;
OWNER
uint8 private constant OWNER = 2;
INTEGRATOR
uint8 private constant INTEGRATOR = 3;
Functions
notPaused
Check that purchase is not paused
modifier notPaused();
initialize
function initialize(VNFTConfiguration calldata config) external init(0);
Parameters
| Name | Type | Description |
|---|---|---|
config | VNFTConfiguration | The configuration for the vNFT |
tokenURI
function tokenURI(uint256 tokenId) external view override(IERC721Metadata, NFT) returns (string memory);
_onTransfer
Internal hook happening at each transfer
To override
function _onTransfer(address, address, uint256 tokenId) internal view override;
Parameters
| Name | Type | Description |
|---|---|---|
<none> | address | |
<none> | address | |
tokenId | uint256 | The token id |
_onMint
Internal hook happening at each mint
To override
function _onMint(address to, uint256 tokenId) internal override;
Parameters
| Name | Type | Description |
|---|---|---|
to | address | The address receiving the token |
tokenId | uint256 | The token id |
_onBurn
Internal hook happening at each burn
To override
function _onBurn(uint256 tokenId) internal override;
Parameters
| Name | Type | Description |
|---|---|---|
tokenId | uint256 | The token id |
soulboundMode
Retrieve the soulbound mode status
if active, thansfers are disabled
function soulboundMode() external view override returns (bool);
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | The current soulbound mode status |
execLayerVault
Retrieve the exec layer vault address
function execLayerVault() external view returns (address);
Returns
| Name | Type | Description |
|---|---|---|
<none> | address | The current exec layer vault address |
factory
Retrieve the factory address
function factory() external view returns (address);
Returns
| Name | Type | Description |
|---|---|---|
<none> | address | The current factory address |
integrator
Retrieve the integrator address
function integrator() external view returns (address);
Returns
| Name | Type | Description |
|---|---|---|
<none> | address | The current integrator address |
operatorCommission
Retrieve the operator commission
This value is not used inside the contract but only in the off-chain accounting engine building the exec layer vault merkle tree
function operatorCommission() external view returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The current operator commission |
integratorCommission
Retrieve the integrator commission
This value is not used inside the contract but only in the off-chain accounting engine building the exec layer vault merkle tree
function integratorCommission() external view returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The current integrator commission |
extraData
Retrieve the extra data used for each deposit
function extraData() external view returns (string memory);
Returns
| Name | Type | Description |
|---|---|---|
<none> | string | The currently used extra data |
startTokenId
Retrieve the starting token id
function startTokenId() external pure returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The starting token id |
resolve
Retrieve the associated validator ids for the given token ids
function resolve(uint256[] calldata tokenIds) external view returns (uint256[] memory validatorIds);
Parameters
| Name | Type | Description |
|---|---|---|
tokenIds | uint256[] | The list of token ids to lookup |
Returns
| Name | Type | Description |
|---|---|---|
validatorIds | uint256[] | The list of associated validator ids |
userOf
Get the user address of an NFT
The zero address indicates that there is no user or the user is expired
function userOf(uint256 tokenId) external view returns (address currentUser);
Parameters
| Name | Type | Description |
|---|---|---|
tokenId | uint256 | The NFT to get the user address for |
Returns
| Name | Type | Description |
|---|---|---|
currentUser | address | The user address for this NFT |
userExpires
Get the user expires of an NFT
The zero value indicates that there is no user
function userExpires(uint256 tokenId) external view returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
tokenId | uint256 | The NFT to get the user expires for |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The user expires for this NFT |
beneficiaryOf
Retriver the current beneficiary of EL and CL rewards
function beneficiaryOf(uint256 tokenId) external view returns (address beneficiary);
Parameters
| Name | Type | Description |
|---|---|---|
tokenId | uint256 | Id of the vNFT |
Returns
| Name | Type | Description |
|---|---|---|
beneficiary | address | The current rewards beneficiary address |
uriPrefix
Retrieve the uri prefix used for all token uris
function uriPrefix() external view returns (string memory);
Returns
| Name | Type | Description |
|---|---|---|
<none> | string | The current uri prefix |
purchasePaused
Retrieve the purchase function status
function purchasePaused() external view returns (bool);
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | True if the purchase function is paused or false otherwise |
setIntegrator
Sets the integrator address
function setIntegrator(address newIntegrator) external onlyAdmin;
Parameters
| Name | Type | Description |
|---|---|---|
newIntegrator | address | The new integrator address to use |
setIntegratorCommission
Sets the integrator commission
function setIntegratorCommission(uint256 newIntegratorCommission) external onlyAdmin;
Parameters
| Name | Type | Description |
|---|---|---|
newIntegratorCommission | uint256 | The new integrator commission to use |
setOperatorCommission
Sets the operator commission
function setOperatorCommission(uint256 newOperatorCommission) external onlyAdmin;
Parameters
| Name | Type | Description |
|---|---|---|
newOperatorCommission | uint256 | The new operator commission to use |
isExited
Retrieve if the token is exited
function isExited(uint256 tokenId) external view returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
tokenId | uint256 | The token id to lookup |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | True if the token is exited or false otherwise |
purchasable
Retrieve the amount of purchasable validators
function purchasable() external view returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The currently purchasable validator amount |
setName
Sets the ERC721 contract name
function setName(string calldata newName) external onlyAdmin;
Parameters
| Name | Type | Description |
|---|---|---|
newName | string | The new name of the contract |
setSymbol
Sets the ERC721 contract symbol
function setSymbol(string calldata newSymbol) external onlyAdmin;
Parameters
| Name | Type | Description |
|---|---|---|
newSymbol | string | The new symbol of the contract |
setUriPrefix
Sets the uri prefix of the contract
function setUriPrefix(string calldata newUriPrefix) external onlyAdmin;
Parameters
| Name | Type | Description |
|---|---|---|
newUriPrefix | string | The new uri prefix to use |
pausePurchase
Pause the purchase function
function pausePurchase() external onlyAdmin;
unpausePurchase
Unpause the purchase function
function unpausePurchase() external onlyAdmin;
setUser
Set the user and expires of an NFT. Once the rent is defined, only the rentee can edit or revoke the rent
The address defined as user will remain the user until the clearUsership method is called
function setUser(uint256 tokenId, address user, uint64 expires) external;
Parameters
| Name | Type | Description |
|---|---|---|
tokenId | uint256 | The id of the token to rent |
user | address | The new user of the NFT |
expires | uint64 | UNIX timestamp, The new user could use the NFT before expires |
clearUsership
Withdraw rewards if any for the user and clears the usership
function clearUsership(uint256 tokenId) external returns (uint256 newId);
Parameters
| Name | Type | Description |
|---|---|---|
tokenId | uint256 | The token id to clear the usership for |
claimDebt
Claim the rewards due to the user
function claimDebt() external;
debt
Retrieve the debt due to an user
function debt(address user) external view returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
user | address | The user to lookup |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The debt due to the user |
purchase
Purchase one or several validators
The msg.value should be a multiple of 32 ETH > 0
function purchase() external payable notPaused returns (uint256[] memory);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256[] | The list of minted NFT ids |
exit
Triggers an exit action on the underlying validators
function exit(uint256[] calldata tokenIds) external;
Parameters
| Name | Type | Description |
|---|---|---|
tokenIds | uint256[] | The list of token ids upon which to perform the exits |
withdraw
Triggers a withdrawal action on the underlying validators
function withdraw(uint256[] calldata tokenIds, address recipient) external returns (uint256[] memory);
Parameters
| Name | Type | Description |
|---|---|---|
tokenIds | uint256[] | The list of token ids upon which to perform the withdrawal |
recipient | address | The address that should receive the pulled funds |
_withdraw
Internal utility to withdraw
function _withdraw(uint256[] memory tokenIds, address recipient, bool ownerOnly) internal returns (uint256[] memory);
Parameters
| Name | Type | Description |
|---|---|---|
tokenIds | uint256[] | The token ids to withdraw |
recipient | address | The recipient of the withdrawn tokens |
ownerOnly | bool | Whether only the owner can withdraw |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256[] | validatorIds The validator ids that were withdrawn |
withdrawCallback
function withdrawCallback(uint256 _id, bytes memory _publicKey, uint256 _amount) external payable;
_solveId
Internal utility to solve the token id
function _solveId(uint256 externalId) internal view returns (uint256);
_getWithdrawableAmount
Internal utility to get the amount of withdrawable funds for a given token id
function _getWithdrawableAmount(uint256 tokenId) internal view returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
tokenId | uint256 | The token id to get the withdrawable amount for |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The amount of withdrawable funds |
_setFactory
Internal utility to set the factory to purchase validator on
function _setFactory(address newFactory) internal;
Parameters
| Name | Type | Description |
|---|---|---|
newFactory | address | The new factory to set |
_setUriPrefix
Internal utility to set the URI prefix to use
function _setUriPrefix(string calldata newUriPrefix) internal;
Parameters
| Name | Type | Description |
|---|---|---|
newUriPrefix | string | The new uri prefix to set |
_setExecLayerVault
Internal utility to set the exec layer vault to point our validators to
function _setExecLayerVault(address newExecLayerVault) internal;
Parameters
| Name | Type | Description |
|---|---|---|
newExecLayerVault | address | The new exec layer vault address |
_setOperatorCommission
Internal utility to set the operator commission
function _setOperatorCommission(uint256 newOperatorCommission) internal;
Parameters
| Name | Type | Description |
|---|---|---|
newOperatorCommission | uint256 | The new operator commission in bps |
_setIntegratorCommission
Internal utility to set the integrator commission
function _setIntegratorCommission(uint256 newIntegratorCommission) internal;
Parameters
| Name | Type | Description |
|---|---|---|
newIntegratorCommission | uint256 | The new integrator commission in bps |
_setIntegrator
Internal utility to set the integrator
function _setIntegrator(address newIntegrator) internal;
Parameters
| Name | Type | Description |
|---|---|---|
newIntegrator | address | The new integrator address |
_setExtraData
Internal utility to set the extra data to use upon deposits
function _setExtraData(string calldata newExtraData) internal;
Parameters
| Name | Type | Description |
|---|---|---|
newExtraData | string | The new extra data to set |
_setSoulboundMode
Internal utility to set the soulbound mode
function _setSoulboundMode(bool active) internal;
Parameters
| Name | Type | Description |
|---|---|---|
active | bool | Whether or not the soulbound mode is enabled |
_castedFactory
Internal utility to retrieve the factory address casted to its interface
function _castedFactory() internal view returns (IvFactory);
Returns
| Name | Type | Description |
|---|---|---|
<none> | IvFactory | The factory address |
_userOf
Internal utility to retrieve the current user of a token
function _userOf(uint256 tokenId) internal view returns (address);
Returns
| Name | Type | Description |
|---|---|---|
<none> | address | The current user address or null address if not set |
_beneficiaryOf
Internal utility to retrieve the current rewards beneficiary of a token
function _beneficiaryOf(uint256 tokenId) internal view returns (address);
Returns
| Name | Type | Description |
|---|---|---|
<none> | address | The current user address or owner address if no user is set |
_isExited
Internal utility to check the exit status of a validator
function _isExited(uint256 tokenId) internal view returns (bool);
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | True if the validator is exited, false otherwise |
getApproved
function getApproved(uint256 tokenId) public view virtual override(IERC721, NFT) returns (address);
_approve
function _approve(address to, address owner, uint256 tokenId) internal virtual override;
_isApprovedOrUser
Internal utility to check if the specified address is either approved by the user or the user for the given token id
function _isApprovedOrUser(address spender, uint256 tokenId) internal view virtual returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
spender | address | The address to verify |
tokenId | uint256 | The token id to verify |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | True if approved or user |
_nextId
Internal utility to compute the next token id to mint
function _nextId() internal view returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The next token id to mint |
_currentId
Internal utility to compute the last minted token id
function _currentId() internal view returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The last token id minted |