Spot Trading

withdrawal flow

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

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

Step 2: Off-Chain Transfer Transaction

In StarkEx for spot trading, starting v4.0, there is no on-chain registration. This means that the registration of the Ethereum address must happen off-chain. This is implemented using the transfer transaction as follows:

A transfer request, signed by the user, moves the funds from the user’s Vault to another off-chain Vault, which is identified with the user’s Ethereum address instead of the starkKey.

Step 3: Off-Chain Withdrawal Transaction

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

Step 4: 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 vaultId state. If the withdrawal is valid, it is aggregated to a batch to be submitted on-chain along with a validity proof.

Step 5: 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 vault.

Step 6: On-Chain Withdrawal Transaction

Once the funds are in the withdrawal area, the user to whom the funds belong can make an on-chain call to withdraw the funds to any recipient.