Depositing and withdrawing onchain
Depositing to an onchain account
To send funds to a L1 vault, use the corresponding function, as follows:
-
depositEthToVault
(ETH) -
depositERC20ToVault
(ERC-20) -
depositERC1155ToVault
(ERC-1155)
Include the following parameters:
-
assetId
(ETH, ERC-20, ERC-1155) -
vaultId
(ETH, ERC-20, ERC-1155) -
quantizedAmount
to deposit (ERC-20, ERC-1155)
Unlike offchain accounts, which can contain NFTs (ERC-721 tokens), onchain accounts can only contain ETH, ERC-20 tokens, or ERC-1155 tokens. |
As part of the deposit flow, the funds are automatically locked for the period defined by defaultVaultWithdrawalLock
. Funds cannot be withdrawn from a locked vault. See Trade for the full explanation of why locks are needed.
Withdrawing from an onchain account
To withdraw funds from a L1 vault, use the corresponding function, as follows:
-
withdrawFromVault
(ETH, ERC-20) -
withdrawErc1155FromVault
(ERC-1155)
Include the following parameters:
-
assetId
(ETH, ERC-20, ERC-1155) -
vaultId
(ETH, ERC-20, ERC-1155) -
quantizedAmount
to deposit (ETH, ERC-20, ERC-1155)
The function verifies the following conditions are true:
-
The vault specified under
msg.sender
contains at least the specified amount of the specified asset. -
The funds are not locked.
If both conditions are true, the account owner receives their funds, and the amount is deducted from the onchain account balance.