ERC20VaultLockable

Contract that can hold ETH and ERC20 tokens and lock them. Instances are ownable by an NFT.

Functions

calculateLockID

Calculates lockID.

Params:

Name

Type

Description

delegate

address

Delegate that will operate on the contract.

token

address

Token on which the delegate will operate on.

Returns:

Name

Type

Description

lockID

bytes32

The calculated lockID.

getHighestBalanceLocked

Fetches the highest balance locked by a delegate for the given token.

Params:

Name

Type

Description

token

address

The locked token

Returns:

Name

Type

Description

balance

uint256

The highest locked balance

verifyERC20Balances

Sanity check to make sure that locked balance is not greater than the total balance. Rarely used.‌

Returns:

Name

Type

Description

validity

bool

​True or False

lockERC20

Params:

Lock ERC20 tokens in the vault. Access control: called by delegate with signed permission from owner State machine: anytime State scope: insert or update _locks, increase _nonce Token transfer: none

Name

Type

Description

token

address

Address of token being locked

amount

uint256

Amount of tokens being locked

permission

bytes

Permission signature payload

unlockERC20

Unlock ERC20 tokens in the vault. Access control: called by delegate with signed permission from owner State machine: after valid lock from delegate State scope: remove or update _locks, increase _nonce Token transfer: none

Params:

Name

Type

Description

token

address

Address of token being unlocked

amount

uint256

Amount of tokens being unlocked

permission

bytes

Permission signature payload

rageQuit

Forcibly cancel delegate lock. This function will attempt to notify the delegate of the rage quit using a fixed amount of gas. Access control: only owner State machine: after valid lock from delegate State scope: remove item from _locks Token transfer: none

Params:

Name

Type

Description

delegate

address

Address of delegate

token

address

Address of token being unlocked

Returns:

Name

Type

Description

notified

bool

Whether delegate contract is notified

error

string

Error string

transferERC20

Transfer ERC20 tokens out of vault. Access control: only owner State machine: when balance >= max(lock) + amount State scope: none Token transfer: transfer any token

Params:

Name

Type

Description

token

address

Address of token being transferred

to

address

Address of the recipient

amount

uint256

Amount of tokens to transfer

transferETH

Transfer ETH out of the vault.

Params:

Name

Type

Description

to

address

Address of the recipient

amount

uint256

Amount of ETH to transfer