balancesTreeis a Merkle Tree. We refer to its leaves as "Vaults". Each Vault contains a
starkKey- a unique key that identifies the user in the off-chain state. This key is coupled through the StarkEx smart contract to the user's Ethereum address. Other elements in the vault are defined according to the business logic.
ordersTree. This is another Merkle Tree, and its goal is to prevent replayability of transactions in the system by the operator. To prevent this attack, StarkEx does the following:
ileaf of the
ordersTreeincludes the already fulfilled amount of the limit order with the hash
i. For example, if Alice signed on a transfer request with a total amount of 1000 USDC and a hash value
0xdeadbeef, StarkEx stores in leaf index
ordersTreean amount of 1000 USDC (after quantization).
0xdeadbeefis zero. Since this is not the case, this order cannot be accepted by our on-chain Cairo Verifier.
balancesTreeand the root of the
ordersTreewhich are a commitment to the off-chain state. The state is updated when the contract receives a new proof that there exists a valid sequence of transactions that when executed, moves the current state (i.e. the current tuple of Merkle roots) to a new state (i.e. - the new tuple of Merkle roots).