Kinetex Docs
Search
K
Comment on page

Withdraw collateral

Collateral withdraw overview
This sequence of actions demonstrates how the Flash Trade system handles the withdrawal of collateral. It includes the preparation for the withdrawal, the withdrawal itself, and the verification of the withdrawal.
Collateral withdraw process
  1. 1.
    Preparation:
    1. 1.
      The Resolver sends an unlocking transaction to the OrderReceiver to prepare a withdrawal.
    2. 2.
      OrderReceiver increases 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.
    3. 3.
      The OrderReceiver emits a "CollateralWithdrawPrepare" event, signaling that it is prepared for the withdrawal of collateral.
  2. 2.
    Withdrawal:
    1. 1.
      The Resolver instructs the CollateralManager to withdraw collateral.
    2. 2.
      CollateralManager checks to make sure the amount being withdrawn does not exceed the amount of locked collateral. If it does, the withdrawal is rejected.
    3. 3.
      CollateralManager verifies the proof of the "PrepareWithdraw" event. If the proof is falsified, the withdrawal is rejected.
    4. 4.
      CollateralManager decreases the total amount of collateral to reflect the withdrawal and updates its own state to reflect the new total amount.
    5. 5.
      CollateralManager emits a "CollateralWithdraw" event, signaling that the withdrawal of collateral has occurred.