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

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

• Limit Order with Fees, 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 with Fees, requesting collateral to be transferred from one vault to another if some on-chain event was recorded.

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

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.

In the case of Withdrawal, the signature is constructed as follows:

$ECDSA(H(w_1, w_5), k_{private})$

In the case of Limit Order/Transfer/Conditional Transfer with Fees, the signature is constructed as follows:

$ECDSA(H(H(H(H(w_1, w_2), w_3),w_4),w_5), 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, and the words $w_1$,$w_2$,$w_3$,$w_4$, $w_5$and$w_6$are 252-bit words containing the data required for the signature, as described in the next section.

Withdrawal

For withdrawal, the signature is constructed as follows:

$w_1$is the withdrawn `assetId`
$w_5$is defined as follows:

```       +----+-----------------+---------+-----------+---------+------------+
#bits  | 10 |       64        |   32    |    32     |    32   |     49     |
+----+-----------------+---------+-----------+---------+------------+
label    A           B            C         D             E          F```
• `A`: order type

• 6 for a Withdrawal

• `B`: `positionId` from which the user wants to take funds.

• `C`: `nonce` for the transaction.

• `D`: `quantizedAmount` to be withdrawn

• `E`: `expirationTimestamp`, in hours since the Unix epoch. For example, for the order to expire 24 hours from the beginning of the current hour, set the timestamp to$⌊\frac{𝑡_{𝑢𝑛𝑖𝑥}}{3600}⌋+24$

• `F`: padding of zeros

Limit Order with Fees

For limit order with fees, the signature is constructed as follows:

$ECDSA(H(H(H(H(w_1, w_2), w_3),w_4),w_5), k_{private})$

$w_1$ is the `assetId` to be sold
$w_2$is the `assetId` to be bought.
$w_3$is the `assetId` used to pay the fee.
$w_4$is defined as follows:

```         +-------+--------------+--------------+--------------+--------+
#bits    | 27    |   64         |   64 .       |      64      |   32   |
+-------+--------------+--------------+--------------+--------+
label      A               B            C                 D       E```
• `A`: padding of zeros

• `B`: `quantizedAmount` to be sold.

• `C`: `quantizedAmount` to be bought

• `D`: `quantizedAmount` to pay fees

• `E`: `nonce` for the transaction.

$w_5$is defined as follows:

```         +---+--------------+--------------+--------------+-----+-----+
#bits    | 10|   64         |   64 .       |         64   | 32  |  17 |
+---+--------------+--------------+--------------+-----+-----+
label      A      B            C                 D           E     F```
• `A`: order type

• 3 for a Limit Order with Fees

• `B`: `positionId` from which the user wants to take funds.

• `C`: `positionId` from which the user wants to take funds.

• `D`: `positionId` from which the user wants to take funds.

• `E`: `expirationTimestamp`, in hours since the Unix epoch. For example, for the order to expire 24 hours from the beginning of the current hour, set the timestamp to$⌊\frac{𝑡_{𝑢𝑛𝑖𝑥}}{3600}⌋+24$

• `F`: padding of zeros

Transfer with Fees/Conditional Transfer with Fees

For transfer with fees, the signature is constructed as follows:

For Transfer with Fees, the encoding is as follows

$ECDSA(H(H(H(H(w_1, w_2), w_3),w_4),w_5), k_{private})$

For Conditional Transfer with Fees, the encoding is as follows

$ECDSA(H(H(H(H(H(w_1, w_2), w_3),w_6),w_4),w_5), k_{private})$

$w_1$is the `assetId` to be sold
$w_2$is the `assetId` used to pay the fee.
$w_3$is the `receiver_starkKey` used to pay the fee.
$w_4$is defined as follows

```         +-------+--------------+--------------+--------------+--------+
#bits    | 27    |   64         |   64 .       |      64      |   32   |
+-------+--------------+--------------+--------------+--------+
label      A               B            C                 D       E```
• `A`: padding of zeros

• `B`: sender`positionId`

• `C`: receiver `positionId`

• `D`: fee `positionId`

• `E`: `nonce` for the transaction.

$w_5$is defined as follows:

```         +---+--------------+--------------+--------+-----------------+
#bits    | 10|   64         |   64         |   32   |       81        |
+---+--------------+--------------+--------+-----------------+
label      A      B            C                 D           E```
• `A`: order type

• 4 for Transfer with Fees

• 5 for Conditional Transfer with Fees

• `B`: `quantizedAmount` to transfer

• `C`: `quantizedAmount` to limit the max fee

• `D`: `expirationTimestamp`, in hours since the Unix epoch. For example, for the order to expire 24 hours from the beginning of the current hour, set the timestamp to$⌊\frac{𝑡_{𝑢𝑛𝑖𝑥}}{3600}⌋+24$

• `E`: padding of zeros

$w_6$ is the `condition` defined as Perdersen hash of the contract address and fact.