To interact with the system, users have to send messages containing orders they wish to execute. The following order types are currently supported:

• Limit Order, declaring intent to sell a certain amount of a certain asset in exchange for a different asset at a certain ratio. One of the assets must be the collateral

• Conditional Transfer, requesting collateral to be transferred from one vault to another if some on-chain event was recorded.

• Transfer, requesting collateral to be transferred from one vault to another.

• Withdrawal, requesting collateral to move from the L2 state to L1

The transaction is sent directly to the application through an interface exposed there, and the validity of the signature over all the fields is verified by the proof system.

# Withdrawal

For withdrawal, the signature is constructed as follows:

$ECDSA(H(collateral\_asset\_id, w), k_{private})$

Where ECDSA is the regular elliptic curve digital signature algorithm, $H$ is the Pedersen hash function, $k_{private}$ is the user’s private key, collateral_asset_id is the collateral assetId (USDC) and the world w is packed as follows:

       +----+-----------------+---------+-----------+---------+------------+#bits  | 10 |       64        |   32    |    32     |    32   |     49     |        +----+-----------------+---------+-----------+---------+------------+label    A           B            C         D             E          F

When $w$ is defined as follows:

A: WITHDRAWAL type (6) B: The id of the vault to withdraw the funds from C: Nonce, generated randomly for each request D: Amount: how many USDC units to withdraw (when "1" represents $10^6$USDC) E: Expiration timestamp - until which time (seconds since epoch) the request is valid F: Padding of zeroes.

# Limit Order

For limit order, the signature is constructed as follows:

$ECDSA(H(H(H(H(asset\_id\_sell, asset\_id\_buy),asset\_id\_fee), w_1), w_2), k_{private})$

When $w_1$is defined as follows:

         +-------+--------------+--------------+--------------+--------+#bits    | 27    |   64         |   64 .       |      64      |   32   |         +-------+--------------+--------------+--------------+--------+label      A               B            C                 D .     E

A: padding of zeroes B: amount sell C: amount buy D: amount fee E: nonce And $w_2$is defined as follows:

         +---+--------------+--------------+--------------+-----+-----+#bits    | 10|   64         |   64 .       |         64   | 32  |  17 |         +---+--------------+--------------+--------------+-----+-----+label      A      B            C                 D .         E     F

A: LIMIT ORDER type (3) B, C and D: The vault id that initiated the limit order (written three times) E: expiration timestamp F: padding of zeroes

# Transfer

For transfer, the signature is constructed as follows:

$ECDSA(H(H(H(H(asset\_id, asset\_id\_fee),receiver\_public\_key), w_1), w_2), k_{private})$

When $w_1$is defined as follows:

         +-------+--------------+--------------+--------------+--------+#bits    | 27    |   64         |   64 .       |      64      |   32   |         +-------+--------------+--------------+--------------+--------+label      A               B            C                 D .     E

A: padding of zeroes B: sender position id C: receiver position id D: fee position id E: nonce And $w_2$is defined as follows:

         +---+--------------+--------------+--------+-----------------+#bits    | 10|   64         |   64 .       |   32   |       81        |         +---+--------------+--------------+--------+-----------------+label      A      B            C                 D           E

A: TRANSFER type (4) B: amount to transfer C: maximal fee D: expiration timestamp E: padding of zeroes

# Conditional Transfer

For conditional transfer, the signature is constructed as follows:

$ECDSA(H(H(H(H(H(asset\_id, asset\_id\_fee),receiver\_public\_key), condition) , w_1), w_2), k_{private})$

When $w_1,w_2$are defined as in transfer, except for the fact that $w_2$ starts with CONDITIONAL TRANSFER type (5), and condition is the Perdersen hash of the contract address and fact

Edit on GitHub