vNFT

Git Source

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

NameTypeDescription
configVNFTConfigurationThe 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

NameTypeDescription
<none>address
<none>address
tokenIduint256The token id

_onMint

Internal hook happening at each mint

To override

function _onMint(address to, uint256 tokenId) internal override;

Parameters

NameTypeDescription
toaddressThe address receiving the token
tokenIduint256The token id

_onBurn

Internal hook happening at each burn

To override

function _onBurn(uint256 tokenId) internal override;

Parameters

NameTypeDescription
tokenIduint256The token id

soulboundMode

Retrieve the soulbound mode status

if active, thansfers are disabled

function soulboundMode() external view override returns (bool);

Returns

NameTypeDescription
<none>boolThe current soulbound mode status

execLayerVault

Retrieve the exec layer vault address

function execLayerVault() external view returns (address);

Returns

NameTypeDescription
<none>addressThe current exec layer vault address

factory

Retrieve the factory address

function factory() external view returns (address);

Returns

NameTypeDescription
<none>addressThe current factory address

integrator

Retrieve the integrator address

function integrator() external view returns (address);

Returns

NameTypeDescription
<none>addressThe 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

NameTypeDescription
<none>uint256The 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

NameTypeDescription
<none>uint256The current integrator commission

extraData

Retrieve the extra data used for each deposit

function extraData() external view returns (string memory);

Returns

NameTypeDescription
<none>stringThe currently used extra data

startTokenId

Retrieve the starting token id

function startTokenId() external pure returns (uint256);

Returns

NameTypeDescription
<none>uint256The 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

NameTypeDescription
tokenIdsuint256[]The list of token ids to lookup

Returns

NameTypeDescription
validatorIdsuint256[]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

NameTypeDescription
tokenIduint256The NFT to get the user address for

Returns

NameTypeDescription
currentUseraddressThe 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

NameTypeDescription
tokenIduint256The NFT to get the user expires for

Returns

NameTypeDescription
<none>uint256The 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

NameTypeDescription
tokenIduint256Id of the vNFT

Returns

NameTypeDescription
beneficiaryaddressThe current rewards beneficiary address

uriPrefix

Retrieve the uri prefix used for all token uris

function uriPrefix() external view returns (string memory);

Returns

NameTypeDescription
<none>stringThe current uri prefix

purchasePaused

Retrieve the purchase function status

function purchasePaused() external view returns (bool);

Returns

NameTypeDescription
<none>boolTrue if the purchase function is paused or false otherwise

setIntegrator

Sets the integrator address

function setIntegrator(address newIntegrator) external onlyAdmin;

Parameters

NameTypeDescription
newIntegratoraddressThe new integrator address to use

setIntegratorCommission

Sets the integrator commission

function setIntegratorCommission(uint256 newIntegratorCommission) external onlyAdmin;

Parameters

NameTypeDescription
newIntegratorCommissionuint256The new integrator commission to use

setOperatorCommission

Sets the operator commission

function setOperatorCommission(uint256 newOperatorCommission) external onlyAdmin;

Parameters

NameTypeDescription
newOperatorCommissionuint256The new operator commission to use

isExited

Retrieve if the token is exited

function isExited(uint256 tokenId) external view returns (bool);

Parameters

NameTypeDescription
tokenIduint256The token id to lookup

Returns

NameTypeDescription
<none>boolTrue if the token is exited or false otherwise

purchasable

Retrieve the amount of purchasable validators

function purchasable() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256The currently purchasable validator amount

setName

Sets the ERC721 contract name

function setName(string calldata newName) external onlyAdmin;

Parameters

NameTypeDescription
newNamestringThe new name of the contract

setSymbol

Sets the ERC721 contract symbol

function setSymbol(string calldata newSymbol) external onlyAdmin;

Parameters

NameTypeDescription
newSymbolstringThe new symbol of the contract

setUriPrefix

Sets the uri prefix of the contract

function setUriPrefix(string calldata newUriPrefix) external onlyAdmin;

Parameters

NameTypeDescription
newUriPrefixstringThe 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

NameTypeDescription
tokenIduint256The id of the token to rent
useraddressThe new user of the NFT
expiresuint64UNIX 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

NameTypeDescription
tokenIduint256The 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

NameTypeDescription
useraddressThe user to lookup

Returns

NameTypeDescription
<none>uint256The 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

NameTypeDescription
<none>uint256[]The list of minted NFT ids

exit

Triggers an exit action on the underlying validators

function exit(uint256[] calldata tokenIds) external;

Parameters

NameTypeDescription
tokenIdsuint256[]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

NameTypeDescription
tokenIdsuint256[]The list of token ids upon which to perform the withdrawal
recipientaddressThe 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

NameTypeDescription
tokenIdsuint256[]The token ids to withdraw
recipientaddressThe recipient of the withdrawn tokens
ownerOnlyboolWhether only the owner can withdraw

Returns

NameTypeDescription
<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

NameTypeDescription
tokenIduint256The token id to get the withdrawable amount for

Returns

NameTypeDescription
<none>uint256The amount of withdrawable funds

_setFactory

Internal utility to set the factory to purchase validator on

function _setFactory(address newFactory) internal;

Parameters

NameTypeDescription
newFactoryaddressThe new factory to set

_setUriPrefix

Internal utility to set the URI prefix to use

function _setUriPrefix(string calldata newUriPrefix) internal;

Parameters

NameTypeDescription
newUriPrefixstringThe 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

NameTypeDescription
newExecLayerVaultaddressThe new exec layer vault address

_setOperatorCommission

Internal utility to set the operator commission

function _setOperatorCommission(uint256 newOperatorCommission) internal;

Parameters

NameTypeDescription
newOperatorCommissionuint256The new operator commission in bps

_setIntegratorCommission

Internal utility to set the integrator commission

function _setIntegratorCommission(uint256 newIntegratorCommission) internal;

Parameters

NameTypeDescription
newIntegratorCommissionuint256The new integrator commission in bps

_setIntegrator

Internal utility to set the integrator

function _setIntegrator(address newIntegrator) internal;

Parameters

NameTypeDescription
newIntegratoraddressThe new integrator address

_setExtraData

Internal utility to set the extra data to use upon deposits

function _setExtraData(string calldata newExtraData) internal;

Parameters

NameTypeDescription
newExtraDatastringThe new extra data to set

_setSoulboundMode

Internal utility to set the soulbound mode

function _setSoulboundMode(bool active) internal;

Parameters

NameTypeDescription
activeboolWhether 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

NameTypeDescription
<none>IvFactoryThe factory address

_userOf

Internal utility to retrieve the current user of a token

function _userOf(uint256 tokenId) internal view returns (address);

Returns

NameTypeDescription
<none>addressThe 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

NameTypeDescription
<none>addressThe 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

NameTypeDescription
<none>boolTrue 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

NameTypeDescription
spenderaddressThe address to verify
tokenIduint256The token id to verify

Returns

NameTypeDescription
<none>boolTrue if approved or user

_nextId

Internal utility to compute the next token id to mint

function _nextId() internal view returns (uint256);

Returns

NameTypeDescription
<none>uint256The next token id to mint

_currentId

Internal utility to compute the last minted token id

function _currentId() internal view returns (uint256);

Returns

NameTypeDescription
<none>uint256The last token id minted