Internal User Balances
Overview
The Vault is capable of tracking user asset balances internally, allowing users to leverage the Vault's feature to exchange assets without effectively executing token transfers.
API
Arguments
ops
- An array of UserBalanceOps, explained belowkind
- Enum of typeUserBalanceOpKind
asset
- The token you are movingamount
- The amount of the asset to movesender
- Address sending tokens or internal balancerecipient
- Address receiving tokens or internal balance
Enums Explained
DEPOSIT_INTERNAL
Increases the Internal Balance of the
recipient
account by transferring tokens from the correspondingsender
. The sender must have allowed the Vault to use their tokens viaIERC20.approve()
. ETH can be used by passing the ETH sentinel value (the zero address) as the asset and forwarding ETH in the call: it will be wrapped and deposited as WETH. Any ETH amount remaining will be sent back to the caller (not the sender, which is relevant for relayers). Emits anInternalBalanceChanged
event.
WITHDRAW_INTERNAL
Decreases the Internal Balance of the
sender
account by transferring tokens to therecipient
. ETH can be used by passing the ETH sentinel value (the zero address) as the asset. This will deduct WETH instead, unwrap it and sendit to the recipient as ETH. Emits an
InternalBalanceChanged
event.
TRANSFER_INTERNAL
Transfers tokens from the Internal Balance of the
sender
account to the Internal Balance ofrecipient
. Reverts if the ETH sentinel value (the zero address) is passed. Emits anInternalBalanceChanged
event.
TRANSFER_EXTERNAL
Transfers tokens from
sender
torecipient
, using the Vault's ERC20 allowance. This is typically used by relayers, as it lets them reuse a user's Vault allowance. Reverts if the ETH sentinel value (the zero address) is passed. Emits anExternalBalanceTransfer
event.
Last updated