Withdraw

Withdraw process sequence diagram
Withdraw process step-by-step:
- External user sends withdrawal request to the Vault via enjoyoors.xyz.
- The Vault emits a corresponding event.
- The Relayer reads the emitted event from Vault.
- The Relayer reaches consensus.
- The Relayer signs and transmits a message containing withdrawal details to the gigaCDP.
- The gigaCDP adds withdrawal request to the queue.
- The gigaCDP processes the queue in the next epoch and closes / updates a collateralized debt position (CDP).
- The gigaCDP aggregates CDPs to calculate actual and target circulating supply of gigaAssets.
- The gigaCDP emits corresponding event.
- The PMS reads the emitted event from gigaCDP.
- The PMS recalculates portfolio allocations to target protocols and AMM pools based on the new circulating supply of gigaAssets.
- The PMS decides on gigaAssets liquidity rebalancing base on new portfolio allocation details.
- The PMS emits corresponding event.
- The Relayer reads the emitted event from PMS.
- The Relayer reaches consensus.
- The Relayer signs and transmits a message containing rebalancing details to the gigaAsset Manager.
- The External user requests a claim voucher from the gigaCDP. The claim voucher allows External user to redeem his assets from the Vault.
- If the External user has debt External user will receive message from gigaCDP with claim rejection and debt details.
- The External user goes to AMM Pool and buys gigaAsset to repay the debt.
- The External user repays debt in gigaCDP.
- If the External user doesn’t have debt he receives claim voucher from gigaCDP.
- The External user receives assets from Vault by using claim voucher.
@startuml
autonumber
actor "External user"
participant Vault
participant Relayer
participant "AMM Pool"
participant "gigaCDP"
participant PMS
== Epoch 1 ==
"External user" -> Vault: Send withdraw request
Vault -> Vault: Emit event
Relayer -> Vault: Listen to events
Relayer -> Relayer: Reach consensus
Relayer -> "gigaCDP": Broadcast signed transaction
"gigaCDP" -> "gigaCDP": Add the request to the queue
== Epoch 2 ==
"gigaCDP" -> "gigaCDP": Close / update CDP
"gigaCDP" -> "gigaCDP": Calculate actual and target level of gigaAssets
"gigaCDP" -> "gigaCDP": Emit event
PMS -> "gigaCDP": Get actual and target level of gigaAssets
PMS -> PMS: Recalculate portfolio weights
PMS -> PMS: Decide on gigaAssets liquidity rebalancing
PMS -> PMS: Emit event
Relayer -> PMS: Listen to events
Relayer -> Relayer: Reach consensus
Relayer -> "gigaAsset Manager": Broadcast signed transaction
"External user" -> gigaCDP: Try to receive claim voucher
alt External user bad debt > 0
"gigaCDP" -> "External user": Return reject message with debt details
"External user" -> "AMM Pool": Buy gigaAssets
"External user" -> "gigaCDP": Repay debt
else bad debt = 0
"gigaCDP" -> "External user": Return claim voucher
end
"External user" -> Vault: Claim assets
@enduml