Alice sends a withdrawal request using the off-chain application.
The request is signed in order to prevent a malicious operator from issuing withdrawals at their own discretion, which might put Alice’s position below the maintenance margin, enabling the operator to liquidate the position.
The request includes Alice’s signature and Ethereum address.
The off-chain application 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 using the
add_transaction API method with the appropriate transaction type:
StarkEx Perpetual Trading v1.0:
StarkEx Perpetual Trading v2.0:
StarkEx verifies that the withdrawal request is valid, according to the relevant business logic statement to be proved, and the relevant
positionId state, ensuring the following:
The position has enough funds to withdraw.
The withdrawal execution does not put the position below the maintenance margin
The position is properly signed by the Stark key that owns the position.
If the withdrawal is valid, it is aggregated to a batch to be submitted on-chain along with a validity proof.
Upon performing a state update, the StarkEx smart contract moves the relevant funds to the withdrawal area, under the Stark key that owns the L2 position from which the funds were withdrawn.
Upon performing a state update, the StarkEx smart contract moves the relevant funds to the withdrawal area, under Alice’s Ethereum address.
Once the funds are in the withdrawal area, Alice can make an on-chain call to register her Ethereum address, using her Stark key, which enables her to reclaim her funds from the withdrawal area to her Ethereum address.
Once the funds are in the withdrawal area, every user can make an on-chain call to withdraw the funds to the Ethereum address the funds are belonged to. The
ownerKey parameter should be the Ethereum address, and not the Stark key.