Withdraw collateral

This sequence of actions demonstrates how the Swaps.io system handles the withdrawal of collateral. It includes the preparation for the withdrawal, the withdrawal itself, and the verification of the withdrawal.

Preparation:
CollalteralManageremits aWithdrawReportevent, signaling that it is prepared for the withdrawal of collateral.The Intent Agent sends an unlocking transaction by calling the
reportWithdrawmethod of theCollalteralManagercontract in the receive chain to prepare a withdrawal.CollalteralManagerincreases the amount of locked collateral by the order amount. Locked collateral is the amount of collateral that is currently locked and cannot be used for other orders.
Withdrawal:
The Intent Agent instructs the
CollateralManagerto withdraw collateral, calling methodwithdrawand providingreportProof.CollateralManagerchecks to make sure the amount being withdrawn does not exceed the amount of locked collateral. If it does, the withdrawal is rejected.CollateralManager, with the help of Light Clients, verifies the proof of theWithdrawevent provided withreportProof. If the proof is falsified, the withdrawal is rejected.CollateralManagerdecreases the total amount of collateral to reflect the withdrawal and updates its own state to reflect the new total amount.CollateralManageremits aWithdrawevent, signaling that the withdrawal of collateral has occurred.
Last updated