withdrawal flow

Step 1: Off-Chain Withdrawal Request Initiated by the User

The user submits a withdrawal signed request to the off-chain application, in order to ensure a malicious operator can’t use this flow in order to steal the maintenance margin.

Step 2: Off-Chain Withdrawal Transaction

The off-chain app checks the validity of the withdrawal request according to its business logic and the relevant positionId state. If it is valid, it sends the off-chain withdrawal transaction to the StarkEx service.

Step 3: Withdrawal Included in a Batch

StarkEx verifies that the withdrawal request is valid, according to the relevant business logic statement to be proved, and the relevant positionId state. If the withdrawal is valid, it is aggregated to a batch to be submitted on-chain along with a validity proof.

Step 4: Funds Move to the Withdrawal Area

Upon performing state update, the StarkEx smart contract moves the relevant funds to the withdrawal area, under the user identity that appears in the withdrawn L2 position.

Step 5: On-Chain Withdrawal Transaction

Once the funds are in the withdrawal area, the user the funds are belonged to under can make an on-chain call to withdraw the funds to any recipient. For more info, see withdrawals‚Äč