Function: executeWithdrawAction(EventTypes.WithdrawData withdraw, uint64 eventId)
This allows to withdraw previously deposited funds. The vault in the destination chain should contain enough liquidity to withdraw from.
Inputs
withdraw
Control: Full control by operator.
Constraints: Balance of
accountId
is enough, thebrokerId
andtoken
is allowed, and the balance oftoken
in the destinationchainId
is enough. ThewithdrawNonce
should not be less than the last nonce.Impact: The funds of the tokens from
accountId
will be transferred to thereceiver
inchainId
.
eventId
Control: Full control by operator.
Constraints: There are not any checks.
Impact: The unique ID of withdraw action.
Branches and code coverage
Intended branches
Check if the branch has test coverage.
Include function calls.
End sentences with periods.
Negative behavior
Sender is not related to the
accountId
.Untrusted
brokerId
.Untrusted
tokenSymbol
.The
withdrawNonce
is less than the last.tokenAmount
is more thanaccountId
balance.tokenAmount
is more than Vault balance inchainId
.receiver
is the zero address.The
frozenBalance
ofaccountId
is not zero.The
frozenBalance
ofaccountId
is not zero.
Function call analysis
vaultManager.getAllowedBroker(brokerHash)
External/Internal? External.
Argument control?
brokerHash
is controlled by operator.Impact: Return true if the
brokerHash
is allowed.
vaultManager.getAllowedChainToken(tokenHash, withdraw.chainId)
External/Internal? External.
Argument control?
tokenHash
is calculated;withdraw.chainId
is controlled by operator.Impact: Return true if the
tokenHash
inchainId
is allowed.
vaultManager.getMaxWithdrawFee(tokenHash)
External/Internal? External.
Argument control?
tokenHash
is calculated.Impact: Return the max fee value for
tokenHash
.
vaultManager.getBalance(tokenHash, withdraw.chainId)
External/Internal? External.
Argument control?
tokenHash
is calculated;withdraw.chainId
is controlled by operator.Impact: Return the balance of all deposited funds for
tokenHash
inchainId
.
Signature.verifyWithdraw(withdraw.sender, withdraw)
External/Internal? Internal.
Argument control? All arguments are controlled by operator.
Impact: Verify that sender has signed the withdraw data.
account.frozenBalance(withdraw.withdrawNonce, tokenHash, withdraw.tokenAmount)
External/Internal? Internal.
Argument control? All arguments are controlled by operator.
Impact: Decrease the balance of
accountId
and increase the frozen balance.
vaultManager.frozenBalance(tokenHash, withdraw.chainId, withdraw.tokenAmount - withdraw.fee)
External/Internal? External.
Argument control? All arguments are controlled by operator.
Impact: Increase the frozen balance of
tokenHash
inchainId
.
ILedgerCrossChainManager(crossChainManagerAddress).withdraw(withdraw)
External/Internal? External.
Argument control?
withdraw
is controlled by operator.Impact: Send cross-chain LayerZero message to perform withdraw action in Vault in destination chain.