Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

UnlockToken

Git Source

Inherits: CommitToken, IUnlockToken

Title: UnlockToken

CommitToken subclass that allows a vault to initiate redeem requests on behalf of users

The vault address is immutable and set at construction. The vault can act as an operator for any controller, enabling it to initiate redeem requests automatically.

Like CommitToken, this version is non-transferable for implementation simplicity. Future versions may support transferability or could be implemented as an NFT to enable transferring unlocking positions between users.

Inherits CommitToken's custom async redemption flow, which is inspired by but NOT compliant with ERC-7540.

State Variables

vault

The vault address that can act as an operator (immutable)

address public immutable vault

Functions

constructor

Constructs the UnlockToken contract

constructor(address authority_, address asset_, address vault_, uint48 unlockingDelay_, address denyList_)
    CommitToken(authority_, asset_, unlockingDelay_, denyList_, type(uint256).max);

Parameters

NameTypeDescription
authority_addressAddress of the AccessManager contract
asset_addressAddress of the underlying asset token
vault_addressAddress of the vault that can act as an operator (immutable)
unlockingDelay_uint48Cooldown period for redeem requests in seconds
denyList_addressAddress of the AddressList contract for deny list checking

onlyVault

Ensures that only the vault can call the function

modifier onlyVault() ;

name

Returns the token name: "{VaultName} Unlock Token"

Overrides CommitToken's name() which returns "{AssetName} Commit Token"

function name() public view override(ERC20, IERC20Metadata) returns (string memory);

Returns

NameTypeDescription
<none>stringThe token name

symbol

Returns the token symbol: "{AssetSymbol}unlock"

Overrides CommitToken's symbol() which returns "CT-{AssetSymbol}"

function symbol() public view override(ERC20, IERC20Metadata) returns (string memory);

Returns

NameTypeDescription
<none>stringThe token symbol

isOperator

Returns true if the operator is the controller or the vault

function isOperator(address controller, address operator)
    public
    view
    override(CommitToken, IERC7540Operator)
    returns (bool);

Parameters

NameTypeDescription
controlleraddressThe controller address
operatoraddressThe operator address to check

Returns

NameTypeDescription
<none>booltrue if operator is controller or vault, false otherwise

_deposit

Overrides CommitToken _deposit to restrict access to vault only

Only the vault can deposit assets into the UnlockToken

function _deposit(address caller, address receiver, uint256 assets, uint256 shares) internal override onlyVault;

Parameters

NameTypeDescription
calleraddressThe address to deposit from
receiveraddressThe address to deposit to
assetsuint256The amount of assets to deposit
sharesuint256The amount of shares to deposit

_requestRedeem

Overrides CommitToken _requestRedeem to restrict access to vault only

Only the vault can request redeem on behalf of users

function _requestRedeem(Request storage request, address controller, address owner, uint256 assets, uint256 shares)
    internal
    override
    onlyVault;

Parameters

NameTypeDescription
requestRequestThe redeem request storage pointer
controlleraddressAddress that will control the request
owneraddressAddress that owns the shares
assetsuint256Amount of assets to redeem
sharesuint256Amount of shares to redeem