Perpetual Trading (v2.0)

withdrawal flow

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

The user submits a WithdrawalToAddress request to the off-chain application.

This request includes the user’s ethereumAddress in addition to the user’s signature.

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 ethereumAddress.

Step 5: On-Chain Withdrawal Transaction

Once the funds are in the withdrawal area, every user can make an on-chain call to withdraw the funds to the ethereumAddress the funds are belonged to. The ownerKey parameter should be the ethereum address, and not the stark key. For more info, see withdrawals‚Äč.