Escaping from a frozen application smart contract

Once the application’s smart contract is frozen, the escape operation enables any user to withdraw their funds and leave the application.

  1. The user obtains a Merkle path of a position to be evicted with respect to the frozen position tree root. Typically, once the application is frozen, such data should be made public or obtainable from an application API, depending on the application’s data availability approach.

  2. The user calls the verifyEscape function with the Merkle proof for the position to be evicted.

    For information on the structure of the proof, see Escape verifier

    A valid proof results in the registration of the following fact:
    keccak256(starkKey, assetId, quantizedAmount, vaultRoot, height, vaultId).

  3. The user calls the escape function with the same parameters submitted to the Escape verifier.

    If a proof was accepted for the same parameters by the Escape verifier, and no prior escape call was made for the position, the contract adds the position balance to an on-chain pending withdrawals account under the public Stark key of the position owner and the appropriate asset ID.

  4. The user withdraws this amount from the operator’s pending withdrawals account by calling the operator’s normal on-chain withdrawal function to transfer the funds to their ETH or ERC-20 account, depending on the type of token.

While anyone can perform the initial steps of the escape operation, including the operator, for example, only the position owner can perform the final step of transferring the funds.