In order to guarantee self custody of funds, thereby preventing censorship, StarkEx enables a user to perform a forced request at any point in time. The user initiates a forced request with an on-chain transaction. If you, the operator, do not serve the request within a specific time frame, the user can freeze the contract, and thus the exchange, and withdraw directly from the frozen contract.
StarkEx supports the following forced operations:
Forced operation flows
The syntax and business logic of forced operations vary depending on the specific application StarkEx serves. However, in general, there are two possible flows, based on how you, the operator, respond to the forced request:
You serve the forced operation.
You do not serve the forced operation.
The operator serves the forced operation
The application sends the forced operation to StarkEx and StarkEx decides whether the on-chain request is valid based on the identity of the exact request and the business logic involved.
Alice sends a request to withdraw 1000 USDC from a specific off-chain position that she claims to own.
The application determines if the forced operation is valid.
1000 USDC is deducted from Alice’s off-chain balance, and registered on-chain as belonging to Alice.
If either of the following is true, StarkEx proves the request is not valid, and does not move any funds on-chain:
Alice can withdraw at most 500 USDC, according to the application’s business logic.
Alice’s public Stark key does not match the Stark key registered with the position .
Whether the request is valid or invalid, after the proof for this request is submitted, the request is removed from the pending forced operations area in the StarkEx contract, so it can no longer justify any future request to freeze the contract.
The operator does not serve the forced operation.
If the freeze grace period has passed, and the forced operation is still in the pending forced operations area, the user can call the
freezeRequest function, with the public Stark key and the
id they used in the ignored forced operation.
As a result, the exchange becomes frozen, and it can accept no further state updates. Withdrawals of on-chain funds are still possible.
For information on the frozen state of the smart contract, see Forced actions and escape hatch