Add Nado documentation and examples, including new API endpoints, FAQs, and guides for using the TypeScript SDK. Update .env.example with additional configuration options.

This commit is contained in:
discountry
2025-12-19 01:38:09 +08:00
parent 624fecfa70
commit c69ea72860
148 changed files with 17031 additions and 27 deletions
@@ -0,0 +1,63 @@
# Executes
## Overview
All executes go through the following endpoint; the exact details of the execution are specified by the JSON payload.
* **Websocket**: <mark style="color:orange;">`WEBSOCKET [GATEWAY_WEBSOCKET_ENDPOINT]`</mark>
* **REST**: <mark style="color:orange;">`POST [GATEWAY_REST_ENDPOINT]/execute`</mark>
### **Signing**
All executes are signed using [EIP712](https://eips.ethereum.org/EIPS/eip-712). Each execute request contains:
1. A piece of structured data that includes the sender address
2. A signature of the hash of that structured data, signed by the sender
You can check the SDK for some examples of how to generate these signatures.
{% hint style="info" %}
See more info in the [signing](https://docs.nado.xyz/developer-resources/api/gateway/signing) page.
{% endhint %}
### **Sender Field Structure**
The sender field is a solidity <mark style="color:red;">`bytes32`</mark> . There are two components:
* an <mark style="color:red;">`address`</mark> that is a <mark style="color:red;">`bytes20`</mark>
* a subaccount identifier that is a <mark style="color:red;">`bytes12`</mark>
For example, if your address was <mark style="color:red;">`0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43`</mark>, and you wanted to use the default subaccount identifier (i.e: the word <mark style="color:red;">`default`</mark>) you can set <mark style="color:red;">`sender`</mark> to <mark style="color:red;">`0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c4364656661756c740000000000`</mark> , which sets the subaccount identifier to <mark style="color:red;">`64656661756c740000000000`</mark>.
### **Amounts**
For <mark style="color:red;">`DepositCollateral`</mark> and <mark style="color:red;">`WithdrawCollateral`</mark>, the amount specifies the physical token amount that you want to receive. `i.e.` if USDT0 has 6 decimals, and you want to deposit or withdraw 1 USDT0, you specify <mark style="color:red;">`amount = 1e6`</mark>.
For all other transactions, amount is normalized to 18 decimals, so <mark style="color:red;">`1e18`</mark> == one unit of the underlying asset. For example, if you want to buy 1 wETH, regardless of the amount of decimals the wETH contract has on chain, you specify <mark style="color:red;">`1e18`</mark> in the amount field of the order.
## API Response
All `Execute` messages return the following information:
#### Success
```json
{
"status": "success",
"signature": "{signature}",
"data"?: {data_obj},
"request_type": "{request_type}"
}
```
#### Failure
```json
{
"status": "failure",
"signature": "{signature}",
"error": "{error_msg}",
"error_code": {error_code},
"request_type": "{request_type}"
}
```
@@ -0,0 +1,116 @@
# Burn NLP
## Rate limits
* 60 burns/min or 10 burns every 10 seconds per wallet. (**weight = 10**)
{% hint style="info" %}
See more details in [API Rate limits](https://docs.nado.xyz/developer-resources/api/rate-limits).
{% endhint %}
## Request
{% tabs %}
{% tab title="Websocket" %}
**Connect**
<mark style="color:orange;">`WEBSOCKET [GATEWAY_WEBSOCKET_ENDPOINT]`</mark>
**Message**
```json
{
"burn_nlp": {
"tx": {
"sender": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43746573743000000000000000",
"nlpAmount": "10001000000000000000000"
"nonce": "1"
},
"signature": "0x"
}
}
```
{% endtab %}
{% tab title="REST" %} <mark style="color:orange;">`POST [GATEWAY_REST_ENDPOINT]/execute`</mark>
**Body**
```json
{
"burn_lp": {
"tx": {
"sender": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43746573743000000000000000",
"productId": 1,
"amount": "10001000000000000000000"
"nonce": "1"
},
"signature": "0x"
}
}
```
{% endtab %}
{% endtabs %}
## Request Parameters
<table><thead><tr><th width="190" align="center">Parameter</th><th width="114" align="center">Type</th><th width="104" align="center">Required</th><th>Description</th></tr></thead><tbody><tr><td align="center">tx</td><td align="center">object</td><td align="center">Yes</td><td>Burn NLP transaction object. See <a href="#signing">Signing</a> section for details on the transaction fields.</td></tr><tr><td align="center">tx.sender</td><td align="center">string</td><td align="center">Yes</td><td>Hex string representing the subaccount's 32 bytes (address + subaccount name) of the tx sender.</td></tr><tr><td align="center">tx.nlpAmount</td><td align="center">string</td><td align="center">Yes</td><td>Amount of NLP tokens to burn multiplied by 1e18, sent as a string.</td></tr><tr><td align="center">tx.nonce</td><td align="center">string</td><td align="center">Yes</td><td>This is an incrementing nonce, can be obtained using the <a href="../queries/nonces">Nonces</a> query.</td></tr><tr><td align="center">signature</td><td align="center">string</td><td align="center">Yes</td><td>Signed transaction. See <a href="#signing">Signing</a> section for more details.</td></tr></tbody></table>
## Signing
{% hint style="info" %}
See more details and examples in our [signing](https://docs.nado.xyz/developer-resources/api/gateway/signing) page.
{% endhint %}
The solidity typed data struct that needs to be signed is:
```solidity
struct BurnNlp {
bytes32 sender;
uint128 nlpAmount;
uint64 nonce;
}
```
<mark style="color:red;">`sender`</mark>: a <mark style="color:red;">`bytes32`</mark> sent as a hex string; includes the address and the subaccount identifier.
<mark style="color:red;">`nlpAmount`</mark>: amount of NLP tokens to burn, sent as a string. This must be positive and must be specified with 18 decimals.
<mark style="color:red;">`nonce`</mark>: the <mark style="color:red;">`tx_nonce`</mark>. This is an incrementing nonce, can be obtained using the [Nonces](https://docs.nado.xyz/developer-resources/api/gateway/queries/nonces) query.
{% hint style="warning" %}
**Note**: for signing you should always use the data type specified in the solidity struct which might be different from the type sent in the request e.g: <mark style="color:red;">`nonce`</mark> should be an <mark style="color:red;">`uint64`</mark> for **Signing** but should be sent as a <mark style="color:red;">`string`</mark> in the final payload.
{% endhint %}
## Response
```json
{
"status": "success",
}
```
#### Success
```json
{
"status": "success",
"signature": {signature},
"request_type": "execute_burn_nlp"
}
```
#### Failure
```json
{
"status": "failure",
"signature": {signature},
"error": "{error_msg}",
"error_code": {error_code},
"request_type": "execute_burn_nlp"
}
```
@@ -0,0 +1,119 @@
# Cancel And Place
## Rate limits
* The sum of [Cancel Orders](https://docs.nado.xyz/developer-resources/api/gateway/cancel-orders#rate-limits) + [Place Order](https://docs.nado.xyz/developer-resources/api/gateway/place-order#rate-limits) limits
{% hint style="info" %}
See more details in [API Rate limits](https://docs.nado.xyz/developer-resources/api/rate-limits).
{% endhint %}
## Request
{% tabs %}
{% tab title="Websocket" %}
**Connect**
<mark style="color:orange;">`WEBSOCKET [GATEWAY_WEBSOCKET_ENDPOINT]`</mark>
**Message**
```json
{
"cancel_and_place": {
"cancel_tx": {
"sender": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43746573743000000000000000",
"productIds": [2],
"digests": ["0x"],
"nonce": "1"
},
"cancel_signature": "0x",
"place_order": {
"product_id": 1,
"order": {
"sender": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43746573743000000000000000",
"priceX18": "1000000000000000000",
"amount": "1000000000000000000",
"expiration": "4294967295",
"appendix": "1537",
"nonce": "1757062078359666688"
},
"signature": "0x",
}
}
}
```
{% endtab %}
{% tab title="REST" %} <mark style="color:orange;">`POST [GATEWAY_REST_ENDPOINT]/execute`</mark>
**Body**
```json
{
"cancel_and_place": {
"cancel_tx": {
"sender": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43746573743000000000000000",
"productIds": [2],
"digests": ["0x"],
"nonce": "1"
},
"cancel_signature": "0x",
"place_order": {
"product_id": 1,
"order": {
"sender": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43746573743000000000000000",
"priceX18": "1000000000000000000",
"amount": "1000000000000000000",
"expiration": "4294967295",
"nonce": "1757062078359666688"
},
"signature": "0x",
}
}
}
```
{% endtab %}
{% endtabs %}
## Request Parameters
<table><thead><tr><th width="219" align="center">Parameter</th><th width="128" align="center">Type</th><th width="104" align="center">Required</th><th>Description</th></tr></thead><tbody><tr><td align="center">cancel_tx</td><td align="center">object</td><td align="center">Yes</td><td>Cancel order transaction object. See <a href="../cancel-orders#signing">Cancel order signing</a> for details on the transaction fields.</td></tr><tr><td align="center">cancel_tx.sender</td><td align="center">string</td><td align="center">Yes</td><td>Hex string representing the subaccount's 32 bytes (address + subaccount name) of the tx sender.</td></tr><tr><td align="center">cancel_tx.productIds</td><td align="center">number[]</td><td align="center">Yes</td><td>A list of product IDs, corresponding to the product ids of the orders in <mark style="color:red;"><code>digests</code></mark></td></tr><tr><td align="center">cancel_tx.digests</td><td align="center">string[]</td><td align="center">Yes</td><td>A list of order digests, represented as hex strings.</td></tr><tr><td align="center">cancel_tx.nonce</td><td align="center">string</td><td align="center">Yes</td><td>Used to differentiate between the same cancellation multiple times. See <a href="../cancel-orders#signing">Cancel order signing</a> section for more details.</td></tr><tr><td align="center">cancel_signature</td><td align="center">string</td><td align="center">Yes</td><td>Signed transaction. See <a href="#signing">Signing</a><a href="../cancel-orders#signing">Cancel order signing</a> for more details.</td></tr><tr><td align="center">place_order</td><td align="center">object</td><td align="center">Yes</td><td>Payload of order to be placed. See <a href="../../../trigger/executes/place-order#request-parameters">Place order request parameters</a> for payload details.</td></tr></tbody></table>
## Signing
{% hint style="warning" %}
**Note**: both <mark style="color:red;">`cancel_tx`</mark> and <mark style="color:red;">`place_order`</mark> objects must be signed using the same signer, otherwise the request will be rejected.
{% endhint %}
* See [Cancel orders signing](https://docs.nado.xyz/developer-resources/api/gateway/cancel-orders#signing) for details on how to sign the order cancellation.
* See [Place order signing](https://docs.nado.xyz/developer-resources/api/gateway/place-order#signing) for details on how to sign the order placement.
## Response
#### Success
```json
{
"status": "success",
"signature": {signature},
"data": {
"digest": {order digest}
},
"request_type": "execute_cancel_and_place"
}
```
#### Failure
```json
{
"status": "failure",
"signature": {signature}
"error": "{error_msg}"
"error_code": {error_code}
"request_type": "execute_cancel_and_place"
}
```
@@ -0,0 +1,139 @@
# Cancel Orders
## Rate limits
* When no **digests** are provided: 600 cancellations/min or 10 cancellations/sec per wallet. (**weight=1**)
* When **digests** are provided: 600/(total digests) cancellations per minute per wallet. (**weight=total digests**)
{% hint style="info" %}
See more details in [API Rate limits](https://docs.nado.xyz/developer-resources/api/rate-limits).
{% endhint %}
## Request
{% tabs %}
{% tab title="Websocket" %}
**Connect**
<mark style="color:orange;">`WEBSOCKET [GATEWAY_WEBSOCKET_ENDPOINT]`</mark>
**Message**
```json
{
"cancel_orders": {
"tx": {
"sender": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43746573743000000000000000",
"productIds": [2],
"digests": ["0x"],
"nonce": "1"
},
"signature": "0x"
}
}
```
{% endtab %}
{% tab title="REST" %} <mark style="color:orange;">`POST [GATEWAY_REST_ENDPOINT]/execute`</mark>
**Body**
```json
{
"cancel_orders": {
"tx": {
"sender": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43746573743000000000000000",
"productIds": [0],
"digests": ["0x"],
"nonce": "1"
},
"signature": "0x"
}
}
```
{% endtab %}
{% endtabs %}
## Request Parameters
<table><thead><tr><th width="156" align="center">Parameter</th><th width="128" align="center">Type</th><th width="104" align="center">Required</th><th>Description</th></tr></thead><tbody><tr><td align="center">tx</td><td align="center">object</td><td align="center">Yes</td><td>Cancel order transaction object. See <a href="#signing">Signing</a> section for details on the transaction fields.</td></tr><tr><td align="center">tx.sender</td><td align="center">string</td><td align="center">Yes</td><td>Hex string representing the subaccount's 32 bytes (address + subaccount name) of the tx sender.</td></tr><tr><td align="center">tx.productIds</td><td align="center">number[]</td><td align="center">Yes</td><td>A list of product IDs, corresponding to the product ids of the orders in <mark style="color:red;"><code>digests</code></mark></td></tr><tr><td align="center">tx.digests</td><td align="center">string[]</td><td align="center">Yes</td><td>A list of order digests, represented as hex strings.</td></tr><tr><td align="center">tx.nonce</td><td align="center">string</td><td align="center">Yes</td><td>Used to differentiate between the same cancellation multiple times. See <a href="#signing">Signing</a> section for more details.</td></tr><tr><td align="center">signature</td><td align="center">string</td><td align="center">Yes</td><td>Signed transaction. See <a href="#signing">Signing</a> section for more details.</td></tr></tbody></table>
## Signing
{% hint style="info" %}
See more details and examples in our [signing](https://docs.nado.xyz/developer-resources/api/gateway/signing) page.
{% endhint %}
The solidity typed data struct that needs to be signed is:
```solidity
struct Cancellation {
bytes32 sender;
uint32[] productIds;
bytes32[] digests;
uint64 nonce;
}
```
<mark style="color:red;">`sender`</mark>: a <mark style="color:red;">`bytes32`</mark> sent as a hex string; includes the address and the subaccount identifier
<mark style="color:red;">`productIds`</mark>: a list of product IDs, corresponding to the product ids of the orders in <mark style="color:red;">`digests`</mark>
<mark style="color:red;">`digests`</mark>: a list of order digests, represented as hex strings, for the orders you want to cancel.
<mark style="color:red;">`nonce`</mark>: used to differentiate between the same cancellation multiple times, and a user trying to place a cancellation with the same parameters twice. Sent as a string. Encodes two bit of information:
* Most significant <mark style="color:red;">`44`</mark> bits encoding the <mark style="color:red;">`recv_time`</mark> in milliseconds after which the cancellation should be ignored by the matching engine; the engine will accept cancellations where <mark style="color:red;">`current_time < recv_time <= current_time + 100000`</mark>
* Least significant <mark style="color:red;">`20`</mark> bits are a random integer used to avoid hash collisions
For example, to place a cancellation with a random integer of <mark style="color:red;">`1000`</mark>, and a discard time 50 ms from now, we would send a nonce of <mark style="color:red;">`(timestamp_ms() + 50) << 20 + 1000`</mark>
{% hint style="warning" %}
**Note**: for signing you should always use the data type specified in the solidity struct which might be different from the type sent in the request e.g: <mark style="color:red;">`nonce`</mark> should be an <mark style="color:red;">`uint64`</mark> for **Signing** but should be sent as a <mark style="color:red;">`string`</mark> in the final payload.
{% endhint %}
## Response
#### Success
```json
{
"status": "success",
"signature": {signature},
"data": {
"cancelled_orders": [
{
"product_id": 2,
"sender": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43746573743000000000000000",
"price_x18": "20000000000000000000000",
"amount": "-100000000000000000",
"expiration": "1686332748",
"order_type": "post_only",
"nonce": "1768248100142339392",
"unfilled_amount": "-100000000000000000",
"digest": "0x3195a7929feb8307edecf9c045j5ced68925108f0aa305f0ee5773854159377c",
"appendix": "1537",
"placed_at": 1686332708
},
...
]
},
"request_type": "execute_cancel_orders"
}
```
#### Failure
```json
{
"status": "failure",
"signature": {signature},
"error": "{error_msg}",
"error_code": {error_code},
"request_type": "execute_cancel_orders"
}
```
@@ -0,0 +1,135 @@
# Cancel Product Orders
## Rate limits
* When no **productIds** are provide&#x64;**:** 12 cancellations/min or 2 cancellations/sec per wallet. (**weight=50**)
* When **productIds** are provided: 600 / (5 \* total productIds) cancellations per minute per wallet. (**weight=5\*total productIds**)
{% hint style="info" %}
See more details in [API Rate limits](https://docs.nado.xyz/developer-resources/api/rate-limits).
{% endhint %}
## Request
{% tabs %}
{% tab title="Websocket" %}
**Connect**
<mark style="color:orange;">`WEBSOCKET [GATEWAY_WEBSOCKET_ENDPOINT]`</mark>
**Message**
```json
{
"cancel_product_orders": {
"tx": {
"sender": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43746573743000000000000000",
"productIds": [2],
"nonce": "1"
},
"signature": "0x",
"digest": null
}
}
```
{% endtab %}
{% tab title="REST" %} <mark style="color:orange;">`POST [GATEWAY_REST_ENDPOINT]/execute`</mark>
**Body**
```json
{
"cancel_product_orders": {
"tx": {
"sender": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43746573743000000000000000",
"productIds": [0],
"nonce": "1"
},
"signature": "0x",
"digest": "0x"
}
}
```
{% endtab %}
{% endtabs %}
## Request Parameters
<table><thead><tr><th width="178" align="center">Parameter</th><th width="142" align="center">Type</th><th width="104" align="center">Required</th><th>Description</th></tr></thead><tbody><tr><td align="center">tx</td><td align="center">object</td><td align="center">Yes</td><td>Cancel product orders transaction object. See <a href="#signing">Signing</a> section for details on transaction fields.</td></tr><tr><td align="center">tx.sender</td><td align="center">string</td><td align="center">Yes</td><td>Hex string representing the subaccount's 32 bytes (address + subaccount name) of the tx sender.</td></tr><tr><td align="center">tx.productIds</td><td align="center">number[]</td><td align="center">Yes</td><td>A list of product IDs to cancel orders for.</td></tr><tr><td align="center">tx.nonce</td><td align="center">string</td><td align="center">Yes</td><td>Used to differentiate between the same cancellation multiple times. See <a href="#signing">Signing</a> section for more details.</td></tr><tr><td align="center">signature</td><td align="center">string</td><td align="center">Yes</td><td>Signed transaction. See <a href="#signing">Signing</a> section for more details.</td></tr><tr><td align="center">digest</td><td align="center">string</td><td align="center">No</td><td>Hex string representing a hash of the <code>CancellationProducts</code> object.</td></tr></tbody></table>
## Signing
{% hint style="info" %}
See more details and examples in our [signing](https://docs.nado.xyz/developer-resources/api/gateway/signing) page.
{% endhint %}
The solidity typed data struct that needs to be signed is:
```solidity
struct CancellationProducts {
bytes32 sender;
uint32[] productIds;
uint64 nonce;
}
```
<mark style="color:red;">`sender`</mark>: a <mark style="color:red;">`bytes32`</mark> sent as a hex string; includes the address and the subaccount identifier
<mark style="color:red;">`productIds`</mark>: a list of product Ids for which to cancel all subaccount orders. When left empty, orders from all products will be cancelled.
<mark style="color:red;">`nonce`</mark>: used to differentiate between the same cancellation multiple times, and a user trying to place a cancellation with the same parameters twice. Sent as a string. Encodes two bit of information:
* Most significant <mark style="color:red;">`44`</mark> bits encoding the <mark style="color:red;">`recv_time`</mark> in milliseconds after which the cancellation should be ignored by the matching engine; the engine will accept cancellations where <mark style="color:red;">`current_time < recv_time <= current_time + 100000`</mark>
* Least significant <mark style="color:red;">`20`</mark> bits are a random integer used to avoid hash collisions
For example, to place a cancellation with a random integer of <mark style="color:red;">`1000`</mark>, and a discard time 50 ms from now, we would send a nonce of <mark style="color:red;">`(timestamp_ms() + 50) << 20 + 1000`</mark>
{% hint style="warning" %}
**Note**: for signing you should always use the data type specified in the solidity struct which might be different from the type sent in the request e.g: <mark style="color:red;">`nonce`</mark> should be an <mark style="color:red;">`uint64`</mark> for **Signing** but should be sent as a <mark style="color:red;">`string`</mark> in the final payload.
{% endhint %}
## Response
#### Success
```json
{
"status": "success",
"signature": {signature},
"data": {
"cancelled_orders": [
{
"product_id": 2,
"sender": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43746573743000000000000000",
"price_x18": "20000000000000000000000",
"amount": "-100000000000000000",
"expiration": "1686332748",
"order_type": "post_only",
"nonce": "1768248100142339392",
"unfilled_amount": "-100000000000000000",
"digest": "0x3195a7929feb8307edecf9c045j5ced68925108f0aa305f0ee5773854159377c",
"appendix": "1537",
"placed_at": 1686332708
},
...
]
},
"request_type": "execute_cancel_product_orders"
}
```
#### Failure
```json
{
"status": "failure",
"signature": {signature},
"error": "{error_msg}",
"error_code": {error_code},
"request_type": "execute_cancel_product_orders"
}
```
@@ -0,0 +1,123 @@
# Link Signer
Each subaccount can have at most one linked signer at a time. A linked signer can perform any execute on behalf of the subaccount it is linked to. Use the [Linked Signer](https://docs.nado.xyz/developer-resources/api/gateway/queries/linked-signer) query to view your current linked signer.
{% hint style="warning" %}
**Please note**:
* To enable a linked signer, your subaccount must have a minimum of **5 USDT0** worth in account value.
{% endhint %}
## Rate limits
* A max of 50 link signer requests every 7 days per subaccount. (**weight=30**). Use the [Linked Signer Rate Limit](https://docs.nado.xyz/developer-resources/api/archive-indexer/linked-signer-rate-limit) query to check a subaccount's linked signer usage and remaining wait time.
{% hint style="info" %}
See more general details in [API Rate limits](https://docs.nado.xyz/developer-resources/api/rate-limits).
{% endhint %}
## Request
{% tabs %}
{% tab title="Websocket" %}
**Connect**
<mark style="color:orange;">`WEBSOCKET [GATEWAY_WEBSOCKET_ENDPOINT]`</mark>
**Message**
```json
{
"link_signer": {
"tx": {
"sender": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43746573743000000000000000",
"signer": "0xeae27ae6412147ed6d5692fd91709dad6dbfc34264656661756c740000000000",
"nonce": "1"
},
"signature": "0x"
}
}
```
{% endtab %}
{% tab title="REST" %} <mark style="color:orange;">`POST [GATEWAY_REST_ENDPOINT]/execute`</mark>
**Body**
```json
{
"link_signer": {
"tx": {
"sender": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43746573743000000000000000",
"signer": "0xeae27ae6412147ed6d5692fd91709dad6dbfc34264656661756c740000000000",
"nonce": "1"
},
"signature": "0x"
}
}
```
{% endtab %}
{% endtabs %}
## Request Parameters
<table><thead><tr><th width="148" align="center">Parameter</th><th width="90" align="center">Type</th><th width="104" align="center">Required</th><th>Description</th></tr></thead><tbody><tr><td align="center">tx</td><td align="center">object</td><td align="center">Yes</td><td>A link signer transaction object. See <a href="#signing">Signing</a> section for details on the transaction fields.</td></tr><tr><td align="center">tx.sender</td><td align="center">string</td><td align="center">Yes</td><td>Hex string representing the subaccount's 32 bytes (address + subaccount name) of the tx sender.</td></tr><tr><td align="center">tx.signer</td><td align="center">string</td><td align="center">Yes</td><td>A <mark style="color:red;"><code>bytes32</code></mark> sent as a hex string; includes the address (first 20 bytes) that'll be used as the <mark style="color:red;"><code>sender's</code></mark> signer. the last 12 bytes can be set to anything.</td></tr><tr><td align="center">tx.nonce</td><td align="center">string</td><td align="center">Yes</td><td>This is an incrementing nonce, can be obtained using the <a href="../queries/nonces">Nonces</a> query.</td></tr><tr><td align="center">signature</td><td align="center">string</td><td align="center">Yes</td><td>Signed transaction. See <a href="#signing">Signing</a> section for more details.</td></tr></tbody></table>
## Signing
{% hint style="info" %}
See more details and examples in our [signing](https://docs.nado.xyz/developer-resources/api/gateway/signing) page.
{% endhint %}
The solidity typed data struct that needs to be signed is:
```solidity
struct LinkSigner {
bytes32 sender;
bytes32 signer;
uint64 nonce;
}
```
<mark style="color:red;">`sender`</mark>: a <mark style="color:red;">`bytes32`</mark> sent as a hex string; includes the address and the subaccount identifier of the primary subaccount to add a signer to.
<mark style="color:red;">`signer`</mark>: a <mark style="color:red;">`bytes32`</mark> sent as a hex string; includes the address (first 20 bytes) that'll be used as the <mark style="color:red;">`sender's`</mark> signer.
{% hint style="info" %}
**Notes**:
* the last 12 bytes of the <mark style="color:red;">`signer`</mark> field do not matter and can be set to anything.
* set <mark style="color:red;">`signer`</mark> to the zero address to revoke current signer on the provided <mark style="color:red;">`sender`</mark>.
{% endhint %}
<mark style="color:red;">`nonce`</mark>: the <mark style="color:red;">`tx_nonce`</mark>. This is an incrementing nonce, can be obtained using the [Nonces](https://docs.nado.xyz/developer-resources/api/gateway/queries/nonces) query.
{% hint style="warning" %}
**Note**: for signing you should always use the data type specified in the solidity struct which might be different from the type sent in the request e.g: <mark style="color:red;">`nonce`</mark> should be an <mark style="color:red;">`uint64`</mark> for **Signing** but should be sent as a <mark style="color:red;">`string`</mark> in the final payload.
{% endhint %}
## Response
#### Success
```json
{
"status": "success",
"signature": {signature},
"request_type": "execute_link_signer"
}
```
#### Failure
```json
{
"status": "failure",
"signature": {signature},
"error": "{error_msg}",
"error_code": {error_code},
"request_type": "execute_link_signer"
}
```
@@ -0,0 +1,138 @@
# Liquidate Subaccount
## Rate limits
* 30 liquidations/min or 5 liquidations every 10 seconds per wallet. (**weight=20**)
{% hint style="info" %}
See more details in [API Rate limits](https://docs.nado.xyz/developer-resources/api/rate-limits).
{% endhint %}
## Request
{% tabs %}
{% tab title="Websocket" %}
**Connect**
<mark style="color:orange;">`WEBSOCKET [GATEWAY_WEBSOCKET_ENDPOINT]`</mark>
**Message**
```json
{
"liquidate_subaccount": {
"tx": {
"sender": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43746573743000000000000000",
"liquidatee": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43746573743000000000000000",
"productId": 1,
"isEncodedSpread": false,
"amount": "1000000000000000000",
"nonce": "1"
},
"signature": "0x"
}
}
```
{% endtab %}
{% tab title="REST" %} <mark style="color:orange;">`POST [GATEWAY_REST_ENDPOINT]/execute`</mark>
**Body**
```json
{
"liquidate_subaccount": {
"tx": {
"sender": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43746573743000000000000000",
"liquidatee": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43746573743000000000000000",
"mode": 0,
"healthGroup": 1,
"amount": "1000000000000000000",
"nonce": "1"
},
"signature": "0x"
}
}
```
{% endtab %}
{% endtabs %}
## Request Parameters
<table><thead><tr><th width="220" align="center">Parameter</th><th width="92" align="center">Type</th><th width="104" align="center">Required</th><th>Description</th></tr></thead><tbody><tr><td align="center">tx</td><td align="center">object</td><td align="center">Yes</td><td>Liquidate subaccount transaction object. See <a href="#signing">Signing</a> section for details on the transaction fields.</td></tr><tr><td align="center">tx.sender</td><td align="center">string</td><td align="center">Yes</td><td>Hex string representing the subaccount's 32 bytes (address + subaccount name) of the tx sender.</td></tr><tr><td align="center">tx.liquidatee</td><td align="center">string</td><td align="center">Yes</td><td>Hex string representing the subaccount's 32 bytes (address + subaccount name) of the subaccount being liquidated.</td></tr><tr><td align="center">tx.productId</td><td align="center">number</td><td align="center">Yes</td><td><p>Perp Liquidation:</p><ul><li>A valid perp product Id.</li></ul><p>Spot Liquidation:</p><ul><li>A valid spot product Id.</li></ul><p>Spread Liquidation:</p><ul><li>An encoded perp / spot product Ids, where the lower 16 bits represent the spot product and the higher 16 bits represent the perp product. <mark style="color:red;"><code>isEncodedSpread</code></mark> must be set to <mark style="color:red;"><code>true</code></mark> for spread liquidation. See <a href="#signing">Signing</a> section for more details.</li></ul></td></tr><tr><td align="center">tx.isEncodedSpread</td><td align="center">bool</td><td align="center">Yes</td><td>When set to <mark style="color:red;"><code>true</code></mark>, the <mark style="color:red;"><code>productId</code></mark> is expected to encode a perp and spot product Ids as follows: <mark style="color:red;"><code>(perp_id &#x3C;&#x3C; 16) | spot_id</code></mark></td></tr><tr><td align="center">tx.amount</td><td align="center">string</td><td align="center">Yes</td><td>The amount to liquidate multiplied by 1e18, sent as a string.</td></tr><tr><td align="center">tx.nonce</td><td align="center">string</td><td align="center">Yes</td><td>This is an incrementing nonce, can be obtained using the <a href="../queries/nonces">Nonces</a> query.</td></tr><tr><td align="center">signature</td><td align="center">string</td><td align="center">Yes</td><td>Signed transaction. See <a href="#signing">Signing</a> section for more details.</td></tr></tbody></table>
## Signing
{% hint style="info" %}
See more details and examples in our [signing](https://docs.nado.xyz/developer-resources/api/gateway/signing) page.
{% endhint %}
The solidity typed data struct that needs to be signed is:
```solidity
struct LiquidateSubaccount {
bytes32 sender;
bytes32 liquidatee;
uint32 productId;
bool isEncodedSpread;
int128 amount;
uint64 nonce;
}
```
<mark style="color:red;">`sender`</mark>: a <mark style="color:red;">`bytes32`</mark> sent as a hex string; includes the address and the subaccount identifier.
<mark style="color:red;">`liquidatee`</mark>: a <mark style="color:red;">`bytes32`</mark> sent as a hex string; includes the address and the subaccount identifier.
<mark style="color:red;">`productId`</mark>: The product to liquidate as well as the liquidation mode.
* *Perp liquidation* ⇒ A valid <mark style="color:red;">`perp`</mark> product id is provided and <mark style="color:red;">`isEncodedSpread`</mark> is set to <mark style="color:red;">`false`</mark>.
* *Spot liquidation* ⇒ A valid <mark style="color:red;">`spot`</mark> product id is provided and <mark style="color:red;">`isEncodedSpread`</mark> is set to <mark style="color:red;">`false`</mark>
* *Spread Liquidation* => If there are perp and spot positions in different directions, liquidate both at the same time. Must be set to a 32 bits integer where the lower 16 bits represent the <mark style="color:red;">`spot`</mark> product and the higher 16 bits represent the <mark style="color:red;">`perp`</mark> product. <mark style="color:red;">`isEncodedSpread`</mark> must be set to <mark style="color:red;">`true`</mark>.
***Computing\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*&#x20;**<mark style="color:red;">**productId**</mark>**&#x20;\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*for Spread Liquidation***
```python
btc_spot = 1
btc_perp = 2
spread_product_id = (btc_perp << 16) | btc_spot
```
<mark style="color:red;">`isEncodedSpread`</mark>: indicates whether <mark style="color:red;">`productId`</mark> encodes both a <mark style="color:red;">`spot`</mark> and a <mark style="color:red;">`perp`</mark> product Id for spread liquidation.
<mark style="color:red;">`amount`</mark>: the amount to liquidate multiplied by 1e18, sent as a string. Can be positive or negative, depending on if the users balance is positive or negative.
<mark style="color:red;">`nonce`</mark>: the <mark style="color:red;">`tx_nonce`</mark>. This is an incrementing nonce, can be obtained using the [Nonces](https://docs.nado.xyz/developer-resources/api/gateway/queries/nonces) query.
{% hint style="warning" %}
**Note**: for signing you should always use the data type specified in the solidity struct which might be different from the type sent in the request e.g: <mark style="color:red;">`nonce`</mark> should be an <mark style="color:red;">`uint64`</mark> for **Signing** but should be sent as a <mark style="color:red;">`string`</mark> in the final payload.
{% endhint %}
## Response
#### Success
```json
{
"status": "success",
"signature": {signature},
"request_type": "execute_liquidate_subaccount"
}
```
#### Failure
```json
{
"status": "failure",
"signature": {signature},
"error": "{error_msg}",
"error_code": {error_code},
"request_type": "execute_liquidate_subaccount"
}
```
@@ -0,0 +1,111 @@
# Mint NLP
## Rate limits
* Wallet weight = <mark style="color:red;">`10`</mark> - allows 60 mints/min or 10 mints every 10 seconds per wallet.
{% hint style="info" %}
See more details in [API Rate limits](https://docs.nado.xyz/developer-resources/api/rate-limits).
{% endhint %}
## Request
{% tabs %}
{% tab title="Websocket" %}
**Connect**
<mark style="color:orange;">`WEBSOCKET [GATEWAY_WEBSOCKET_ENDPOINT]`</mark>
**Message**
```json
{
"mint_nlp": {
"tx": {
"sender": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43746573743000000000000000",
"quoteAmount": "1000000000000000000",
"nonce": "1"
},
"signature": "0x"
}
}
```
{% endtab %}
{% tab title="REST" %} <mark style="color:orange;">`POST [GATEWAY_REST_ENDPOINT]/execute`</mark>
**Body**
```json
{
"mint_lp": {
"tx": {
"sender": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43746573743000000000000000",
"productId": 1,
"amountBase": "1000000000000000000",
"quoteAmountLow": "10000000000000000000000",
"quoteAmountHigh": "20000000000000000000000",
"nonce": "1"
},
"signature": "0x"
}
}
```
{% endtab %}
{% endtabs %}
## Request Parameters
<table><thead><tr><th width="205" align="center">Parameter</th><th width="94" align="center">Type</th><th width="112" align="center">Required</th><th>Description</th></tr></thead><tbody><tr><td align="center">tx</td><td align="center">object</td><td align="center">Yes</td><td>Mint NLP transaction object. See <a href="#signing">Signing</a> section for details on the transaction fields.</td></tr><tr><td align="center">tx.sender</td><td align="center">string</td><td align="center">Yes</td><td>Hex string representing the subaccount's 32 bytes (address + subaccount name) of the tx sender.</td></tr><tr><td align="center">tx.quoteAmount</td><td align="center">string</td><td align="center">Yes</td><td>This amount of quote to be consumed by minting NLPs multiplied by 1e18, sent as a string.</td></tr><tr><td align="center">tx.nonce</td><td align="center">string</td><td align="center">Yes</td><td>This is an incrementing nonce, can be obtained using the <a href="../queries/nonces">Nonces</a> query.</td></tr><tr><td align="center">signature</td><td align="center">string</td><td align="center">Yes</td><td>Hex string representing hash of the <strong>signed</strong> transaction. See <a href="#signing">Signing</a> section for more details.</td></tr><tr><td align="center">spot_leverage</td><td align="center">boolean</td><td align="center">No</td><td>Indicates whether leverage should be used; when set to <mark style="color:red;"><code>false</code></mark> , the mint fails if the transaction causes a borrow on the subaccount. Defaults to <mark style="color:red;"><code>true</code></mark>.</td></tr></tbody></table>
## Signing
{% hint style="info" %}
See more details and examples in our [signing](https://docs.nado.xyz/developer-resources/api/gateway/signing) page.
{% endhint %}
The solidity typed data struct that needs to be signed is:
```solidity
struct MintNlp {
bytes32 sender;
uint128 quoteAmount;
uint64 nonce;
}
```
<mark style="color:red;">`sender`</mark>: a <mark style="color:red;">`bytes32`</mark> sent as a hex string; includes the address and the subaccount identifier.
<mark style="color:red;">`quoteAmount`</mark>: this is the amount of quote to be consumed by minting NLPs, sent as a string. This must be positive and must be specified with 18 decimals.
<mark style="color:red;">`nonce`</mark>: the <mark style="color:red;">`tx_nonce`</mark>. This is an incrementing nonce, can be obtained using the [Nonces](https://docs.nado.xyz/developer-resources/api/gateway/queries/nonces) query.
{% hint style="warning" %}
**Note**: for signing you should always use the data type specified in the solidity struct which might be different from the type sent in the request e.g: <mark style="color:red;">`nonce`</mark> should be an <mark style="color:red;">`uint64`</mark> for **Signing** but should be sent as a <mark style="color:red;">`string`</mark> in the final payload.
{% endhint %}
## Response
#### Success
```json
{
"status": "success",
"signature": {signature},
"request_type": "execute_mint_nlp"
}
```
#### Failure
```json
{
"status": "failure",
"signature": {signature},
"error": "{error_msg}",
"error_code": {error_code},
"request_type": "execute_min_nlp"
}
```
@@ -0,0 +1,185 @@
# Place Order
## Rate limits
* With spot leverage: 600 orders/minute or 10 orders/sec per wallet. (**weight=1**)
* Without spot leverage: 30 orders/min or 5 orders every 10 seconds per wallet. (**weight = 20**)
{% hint style="info" %}
See more details in [API Rate limits](https://docs.nado.xyz/developer-resources/api/rate-limits).
{% endhint %}
## Request
{% tabs %}
{% tab title="Websocket" %}
**Connect**
<mark style="color:orange;">`WEBSOCKET [GATEWAY_WEBSOCKET_ENDPOINT]`</mark>
**Message**
```json
{
"place_order": {
"product_id": 1,
"order": {
"sender": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43746573743000000000000000",
"priceX18": "1000000000000000000",
"amount": "1000000000000000000",
"expiration": "4294967295",
"nonce": "1757062078359666688",
"appendix": "1"
},
"signature": "0x",
"id": 100
}
}
```
{% endtab %}
{% tab title="REST" %} <mark style="color:orange;">`POST [GATEWAY_REST_ENDPOINT]/execute`</mark>
**Body**
```json
{
"place_order": {
"product_id": 1,
"order": {
"sender": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43746573743000000000000000",
"priceX18": "1000000000000000000",
"amount": "1000000000000000000",
"expiration": "4294967295",
"nonce": "1757062078359666688"
},
"signature": "0x",
"id": 100
}
}
```
{% endtab %}
{% endtabs %}
## Request Parameters
<table><thead><tr><th width="180" align="center">Parameter</th><th width="94" align="center">Type</th><th width="112" align="center">Required</th><th>Description</th></tr></thead><tbody><tr><td align="center">product_id</td><td align="center">number</td><td align="center">Yes</td><td>Id of spot / perp product for which to place order. Use <a href="../queries/all-products">All products</a> query to retrieve all valid product ids.</td></tr><tr><td align="center">order</td><td align="center">object</td><td align="center">Yes</td><td>Order object, see <a href="#signing">Signing</a> section for details on each order field.</td></tr><tr><td align="center">order.sender</td><td align="center">string</td><td align="center">Yes</td><td>Hex string representing the subaccount's 32 bytes (address + subaccount name) of the tx sender.</td></tr><tr><td align="center">order.priceX18</td><td align="center">string</td><td align="center">Yes</td><td>Price of the order multiplied by 1e18.</td></tr><tr><td align="center">order.amount</td><td align="center">string</td><td align="center">Yes</td><td>Quantity of the order multiplied by 1e18.</td></tr><tr><td align="center">order.expiration</td><td align="center">string</td><td align="center">Yes</td><td>A time after which the order should automatically be cancelled, as a timestamp in seconds after the unix epoch.</td></tr><tr><td align="center">order.nonce</td><td align="center">string</td><td align="center">Yes</td><td>Used to differentiate between the same order multiple times. See <a href="#signing">Signing</a> section for more details.</td></tr><tr><td align="center">order.appendix</td><td align="center">string</td><td align="center">Yes</td><td>Encodes various order properties including execution types, isolated positions, TWAP parameters, and trigger types. See order appendix section for more details.</td></tr><tr><td align="center">signature</td><td align="center">string</td><td align="center">Yes</td><td>Hex string representing hash of the <strong>signed</strong> order. See <a href="#signing">Signing</a> section for more details.</td></tr><tr><td align="center">digest</td><td align="center">string</td><td align="center">No</td><td>Hex string representing a hash of the order.</td></tr><tr><td align="center">spot_leverage</td><td align="center">boolean</td><td align="center">No</td><td>Indicates whether leverage should be used; when set to <mark style="color:red;"><code>false</code></mark> , placing the order fails if the transaction causes a borrow on the subaccount. Defaults to <mark style="color:red;"><code>true</code></mark>.</td></tr><tr><td align="center">id</td><td align="center">number</td><td align="center">No</td><td>An optional id that when provided is returned as part of <mark style="color:red;"><code>Fill</code></mark> and <mark style="color:red;"><code>OrderUpdate</code></mark> stream events. See <a href="../../subscriptions">subscriptions</a> for more details.<br><br><strong>NOTE</strong>: The client <mark style="color:red;"><code>id</code></mark> should not be used to differentiate orders, as it is not included in the order hash (i.e., the order <mark style="color:red;"><code>digest</code></mark>). Instead, use the last 20 bits of the order nonce to distinguish between similar orders. For more details, refer to <a href="#order-nonce">Order Nonce</a>.</td></tr></tbody></table>
## Signing
{% hint style="info" %}
See more details and examples in our [signing](https://docs.nado.xyz/developer-resources/api/gateway/signing) page.
{% endhint %}
The solidity typed data struct that needs to be signed is:
```solidity
struct Order {
bytes32 sender;
int128 priceX18;
int128 amount;
uint64 expiration;
uint64 nonce;
uint128 appendix;
}
```
<mark style="color:red;">`sender`</mark>: a <mark style="color:red;">`bytes32`</mark> sent as a hex string; includes the address and the subaccount identifier
<mark style="color:red;">`priceX18`</mark>: an <mark style="color:red;">`int128`</mark> representing the price of the order multiplied by 1e18, sent as a string. For example, a price of 1 USDT0 would be sent as <mark style="color:red;">`"1000000000000000000"`</mark>
<mark style="color:red;">`amount`</mark>: an <mark style="color:red;">`int128`</mark> representing the quantity of the order multiplied by 1e18, sent as a string. A positive amount means that this is a buy order, and a negative amount means this is a sell order.
<mark style="color:red;">`expiration`</mark>: a time after which the order should automatically be cancelled, as a timestamp in seconds after the unix epoch, sent as a string.
### Order Nonce
<mark style="color:red;">`nonce`</mark>: used to differentiate between the same order multiple times, and a user trying to place an order with the same parameters twice. Sent as a string. Encodes two bit of information:
* Most significant <mark style="color:red;">`44`</mark> bits encoding the time in milliseconds (a `recv_time`) after which the order should be ignored by the matching engine
* Least significant <mark style="color:red;">`20`</mark> bits are a random integer used to avoid hash collisions
For example, to place an order with a random integer of <mark style="color:red;">`1000`</mark>, and a discard time 50 ms from now, we would send a nonce of <mark style="color:red;">`((timestamp_ms() + 50) << 20) + 1000)`</mark>
```python
import time
unix_epoch_ms = int(time.time()) * 1000
nonce = ((unix_epoch_ms + 50) << 20) + 1000
```
{% hint style="warning" %}
**Note**: for signing you should always use the data type specified in the solidity struct which might be different from the type sent in the request e.g: <mark style="color:red;">`nonce`</mark> should be an <mark style="color:red;">`uint64`</mark> for **Signing** but should be sent as a <mark style="color:red;">`string`</mark> in the final payload.
{% endhint %}
## Order Appendix
{% hint style="info" %}
See more details and examples in our [Order Appendix](https://docs.nado.xyz/developer-resources/api/order-appendix) page.
{% endhint %}
<mark style="color:red;">`appendix`</mark>: is a 128-bit integer that encodes extra order parameters like execution type, isolated margin, and trigger type.
### Bit Layout
```json
| value | reserved | trigger | reduce only | order type | isolated | version |
| 64 bits | 50 bits | 2 bits | 1 bit | 2 bits | 1 bit | 8 bits |
| 127..64 | 63..14 | 13..12 | 11 | 10..9 | 8 | 7..0 |
```
**Fields (from LSB to MSB):**
* <mark style="color:red;">**Version (8 bits, 07)**</mark> protocol version (currently `1`)
* <mark style="color:red;">**Isolated (1 bit, 8)**</mark> whether the order uses isolated margin
* <mark style="color:red;">**Order Type (2 bits, 910)**</mark> 0 = DEFAULT, 1 = IOC, 2 = FOK, 3 = POST\_ONLY
* <mark style="color:red;">`0`</mark> - <mark style="color:red;">`DEFAULT`</mark>: Standard limit order behavior
* <mark style="color:red;">`1`</mark> - <mark style="color:red;">`IOC (Immediate or Cancel)`</mark>: Execute immediately, cancel unfilled portion
* <mark style="color:red;">`2`</mark> - <mark style="color:red;">`FOK (Fill or Kill)`</mark>: Execute completely or cancel entire order
* <mark style="color:red;">`3`</mark> - <mark style="color:red;">`POST_ONLY`</mark>: Only add liquidity, reject if would take liquidity
* <mark style="color:red;">**Reduce Only (1 bit, 11)**</mark> only decreases an existing position.
* <mark style="color:red;">**Trigger Type (2 bits, 1213)**</mark> 0 = NONE, 1 = PRICE, 2 = TWAP, 3 = TWAP\_CUSTOM\_AMOUNTS
* <mark style="color:red;">**Reserved (50 bits, 1463)**</mark> future use
* <mark style="color:red;">**Value (64 bits, 64127)**</mark> extra data (isolated margin or TWAP parameters)
* if <mark style="color:red;">`trigger`</mark> is <mark style="color:red;">`2`</mark> or <mark style="color:red;">`3`</mark> ⇒ <mark style="color:red;">`value`</mark> represents how many times the TWAP order will execute and the maximum acceptable slippage. Encoded as:
```json
| times | slippage_x6 |
| 32 bits| 32 bits |
```
* <mark style="color:red;">`times`</mark> : Number of TWAP executions.
* <mark style="color:red;">`slippage_x6`</mark>: Maximum slippage × 1,000,000 (6 decimal precision).
* if <mark style="color:red;">`isolated`</mark> is <mark style="color:red;">`1`</mark> ⇒ <mark style="color:red;">`value`</mark> represents <mark style="color:red;">`margin_x6`</mark> (in x6 precision, 6 decimals) to be transferred to the isolated subaccount when the order gets its first match.
* otherwise, <mark style="color:red;">`value`</mark> is <mark style="color:red;">`0`</mark>.
## Response
#### Success
```json
{
"status": "success",
"signature": {signature},
"data": {
"digest": {order digest}
},
"request_type": "execute_place_order"
"id": 100
}
```
#### Failure
```json
{
"status": "failure",
"signature": {signature},
"error": "{error_msg}",
"error_code": {error_code},
"request_type": "execute_place_order"
}
```
@@ -0,0 +1,193 @@
# Place Orders
Place multiple orders in a single request. This is more efficient than placing orders individually and allows for better control over batch order placement.
## Rate limits
* With spot leverage: 600 orders/minute or 10 orders/sec per wallet. (**weight=1 per order**)
* Without spot leverage: 30 orders/min or 5 orders every 10 seconds per wallet. (**weight = 20 per order**)
{% hint style="info" %}
See more details in [API Rate limits](https://docs.nado.xyz/developer-resources/api/rate-limits).
{% endhint %}
{% hint style="warning" %}
**Note**: There is a 50ms processing penalty for each `place_orders` request to ensure fair sequencing and prevent gaming of the matching engine.
{% endhint %}
## Request
{% tabs %}
{% tab title="Websocket" %}
**Connect**
<mark style="color:orange;">`WEBSOCKET [GATEWAY_WEBSOCKET_ENDPOINT]`</mark>
**Message**
```json
{
"place_orders": {
"orders": [
{
"product_id": 2,
"order": {
"sender": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43746573743000000000000000",
"priceX18": "100000000000000000000000",
"amount": "1000000000000000000",
"expiration": "4294967295",
"nonce": "1757062078359666688",
"appendix": "1"
},
"signature": "0x...",
"id": 100
},
{
"product_id": 3,
"order": {
"sender": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43746573743000000000000000",
"priceX18": "3800000000000000000000",
"amount": "2000000000000000000",
"expiration": "4294967295",
"nonce": "1757062078359666689",
"appendix": "1"
},
"signature": "0x...",
"id": 101
}
],
"stop_on_failure": false
}
}
```
{% endtab %}
{% tab title="REST" %} <mark style="color:orange;">`POST [GATEWAY_REST_ENDPOINT]/execute`</mark>
**Body**
```json
{
"place_orders": {
"orders": [
{
"product_id": 2,
"order": {
"sender": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43746573743000000000000000",
"priceX18": "100000000000000000000000",
"amount": "1000000000000000000",
"expiration": "4294967295",
"nonce": "1757062078359666688",
"appendix": "1"
},
"signature": "0x...",
"id": 100
},
{
"product_id": 3,
"order": {
"sender": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43746573743000000000000000",
"priceX18": "3800000000000000000000",
"amount": "2000000000000000000",
"expiration": "4294967295",
"nonce": "1757062078359666689",
"appendix": "1"
},
"signature": "0x...",
"id": 101
}
],
"stop_on_failure": false
}
}
```
{% endtab %}
{% endtabs %}
## Request Parameters
<table><thead><tr><th width="200" align="center">Parameter</th><th width="94" align="center">Type</th><th width="112" align="center">Required</th><th>Description</th></tr></thead><tbody><tr><td align="center">orders</td><td align="center">array</td><td align="center">Yes</td><td>Array of order objects to place. Each order follows the same structure as <a href="place-order">Place Order</a>.</td></tr><tr><td align="center">orders[].product_id</td><td align="center">number</td><td align="center">Yes</td><td>Id of spot / perp product for which to place order.</td></tr><tr><td align="center">orders[].order</td><td align="center">object</td><td align="center">Yes</td><td>Order object (same structure as single order placement).</td></tr><tr><td align="center">orders[].signature</td><td align="center">string</td><td align="center">Yes</td><td>Hex string representing hash of the <strong>signed</strong> order.</td></tr><tr><td align="center">orders[].digest</td><td align="center">string</td><td align="center">No</td><td>Hex string representing a hash of the order.</td></tr><tr><td align="center">orders[].spot_leverage</td><td align="center">boolean</td><td align="center">No</td><td>Indicates whether leverage should be used for this order. Defaults to <mark style="color:red;"><code>true</code></mark>.</td></tr><tr><td align="center">orders[].id</td><td align="center">number</td><td align="center">No</td><td>An optional id returned in <mark style="color:red;"><code>Fill</code></mark> and <mark style="color:red;"><code>OrderUpdate</code></mark> events.</td></tr><tr><td align="center">stop_on_failure</td><td align="center">boolean</td><td align="center">No</td><td>If <mark style="color:red;"><code>true</code></mark>, stops processing remaining orders when the first order fails. Already successfully placed orders are NOT cancelled. Defaults to <mark style="color:red;"><code>false</code></mark>.</td></tr></tbody></table>
## Response
```json
{
"status": "success",
"data": {
"place_orders": [
{
"digest": "0x1234...",
"error": null
},
{
"digest": null,
"error": "insufficient margin"
}
]
}
}
```
### Response Fields
<table><thead><tr><th width="200">Field</th><th>Description</th></tr></thead><tbody><tr><td>digest</td><td>Order digest (32-byte hash) if successfully placed, <mark style="color:red;"><code>null</code></mark> if failed.</td></tr><tr><td>error</td><td>Error message if order failed, <mark style="color:red;"><code>null</code></mark> if successful.</td></tr></tbody></table>
## Behavior
* **Partial Success**: By default, orders are processed independently. Some orders may succeed while others fail.
* **Stop on Failure**: Set `stop_on_failure: true` to stop processing remaining orders when the first order fails. Already successfully placed orders remain on the book.
* **Order Signing**: Each order must be individually signed using EIP712 (see [Signing](https://docs.nado.xyz/developer-resources/api/gateway/signing) for details).
* **Rate Limits**: Rate limit weight is calculated per order (1 per order with leverage, 20 per order without).
## Use Cases
* **Spread Trading**: Place both legs of a spread trade in one request
* **Multiple Markets**: Open positions across multiple products in one request
## Example
Placing BTC and ETH perp orders simultaneously:
```javascript
const placeOrdersParams = {
orders: [
{
product_id: 2, // BTC-PERP
order: {
sender: subaccount,
priceX18: toX18(100000), // $100k
amount: toX18(0.1),
expiration: getExpiration(OrderType.DEFAULT),
nonce: genOrderNonce(),
appendix: buildAppendix()
},
signature: await signOrder(btcOrder),
id: 1
},
{
product_id: 3, // ETH-PERP
order: {
sender: subaccount,
priceX18: toX18(3800), // $3.8k
amount: toX18(1),
expiration: getExpiration(OrderType.DEFAULT),
nonce: genOrderNonce(),
appendix: buildAppendix()
},
signature: await signOrder(ethOrder),
id: 2
}
],
stop_on_failure: false
};
const response = await client.execute({ place_orders: placeOrdersParams });
```
## See Also
* [Place Order](https://docs.nado.xyz/developer-resources/api/gateway/executes/place-order) - Single order placement
* [Cancel And Place](https://docs.nado.xyz/developer-resources/api/gateway/executes/cancel-and-place) - Atomic cancel and place
* [Signing](https://docs.nado.xyz/developer-resources/api/gateway/signing) - EIP712 order signing
@@ -0,0 +1,132 @@
# Transfer Quote
## Fees
Transfers between subaccounts incur a network fee:
* **Standard transfers**: 1 USDT0
* **Isolated subaccount transfers**: 0.1 USDT0 (when either sender or recipient is an isolated subaccount)
The fee is automatically deducted from the sender's balance.
## Rate limits
* 60 transfer quotes/min or 10 every 10 seconds per wallet. (**weight=10**)
* A max of 5 transfer quotes to new recipients (subaccounts) every 24hrs.
* **Note**: Transferring quote to a subaccount that doesn't exist, creates the subaccount.
{% hint style="info" %}
See more details in [API Rate limits](https://docs.nado.xyz/developer-resources/api/rate-limits).
{% endhint %}
## Request
{% tabs %}
{% tab title="Websocket" %}
**Connect**
<mark style="color:orange;">`WEBSOCKET [GATEWAY_WEBSOCKET_ENDPOINT]`</mark>
**Message**
```json
{
"transfer_quote": {
"tx": {
"sender": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43746573743000000000000000",
"recipient": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43746573743100000000000000",
"amount": "10000000000000000000",
"nonce": "1"
},
"signature": "0x"
}
}
```
{% endtab %}
{% tab title="REST" %} <mark style="color:orange;">`POST [GATEWAY_REST_ENDPOINT]/execute`</mark>
**Body**
```json
{
"transfer_quote": {
"tx": {
"sender": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43746573743000000000000000",
"recipient": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43746573743100000000000000",
"amount": "10000000000000000000",
"nonce": "1"
},
"signature": "0x"
}
}
```
{% endtab %}
{% endtabs %}
## Request Parameters
<table><thead><tr><th width="154" align="center">Parameter</th><th width="94" align="center">Type</th><th width="112" align="center">Required</th><th>Description</th></tr></thead><tbody><tr><td align="center">tx</td><td align="center">object</td><td align="center">Yes</td><td>Transfer Quote transaction object. See <a href="#signing">Signing</a> section for details on the transaction fields.</td></tr><tr><td align="center">tx.sender</td><td align="center">string</td><td align="center">Yes</td><td>Hex string representing the subaccount's 32 bytes (address + subaccount name) of the tx sender.</td></tr><tr><td align="center">tx.recipient</td><td align="center">string</td><td align="center">Yes</td><td>Hex string representing the subaccount's 32 bytes (address + subaccount name) of the quote recipient.</td></tr><tr><td align="center">tx.amount</td><td align="center">string</td><td align="center">Yes</td><td>The amount of USDT0 to transfer, denominated in <code>x18</code>. Transfr amount must be <mark style="color:red;"><code>>= 5 USDT0</code></mark> . See <a href="#signing">Signing</a> section for more details.</td></tr><tr><td align="center">tx.nonce</td><td align="center">string</td><td align="center">Yes</td><td>This is an incrementing nonce, can be obtained using the <a href="../queries/nonces">Nonces</a> query.</td></tr><tr><td align="center">signature</td><td align="center">string</td><td align="center">Yes</td><td>Hex string representing hash of the <strong>signed</strong> transaction. See <a href="#signing">Signing</a> section for more details.</td></tr></tbody></table>
## Signing
{% hint style="info" %}
See more details and examples in our [signing](https://docs.nado.xyz/developer-resources/api/gateway/signing) page.
{% endhint %}
The solidity typed data struct that needs to be signed is:
```solidity
struct TransferQuote {
bytes32 sender;
bytes32 recipient;
uint128 amount;
uint64 nonce;
}
```
<mark style="color:red;">`sender`</mark>: a <mark style="color:red;">`bytes32`</mark> sent as a hex string; includes the address and the subaccount identifier.
<mark style="color:red;">`recipient`</mark>: a <mark style="color:red;">`bytes32`</mark> sent as a hex string; includes the address and the subaccount identifier.
<mark style="color:red;">`amount`</mark>: the amount of quote to transfer, sent as an `x18` string.
{% hint style="warning" %}
**Notes:**
* If you are transferring <mark style="color:red;">`5 USDT0`</mark>, must specify <mark style="color:red;">`5000000000000000000`</mark> i.e 5 USDT0 \* 1e18.
* Transfer amount should be <mark style="color:red;">>= 5 USDT0.</mark>
{% endhint %}
<mark style="color:red;">`nonce`</mark>: the <mark style="color:red;">`tx_nonce`</mark>. This is an incrementing nonce, can be obtained using the [Nonces](https://docs.nado.xyz/developer-resources/api/gateway/queries/nonces) query.
{% hint style="warning" %}
**Note**: for signing you should always use the data type specified in the solidity struct which might be different from the type sent in the request e.g: <mark style="color:red;">`nonce`</mark> should be an <mark style="color:red;">`uint64`</mark> for **Signing** but should be sent as a <mark style="color:red;">`string`</mark> in the final payload.
{% endhint %}
## Response
#### Success
```json
{
"status": "success",
"signature": {signature},
"request_type": "execute_transfer_quote"
}
```
#### Failure
```json
{
"status": "failure",
"signature": {signature},
"error": "{error_msg}",
"error_code": {error_code},
"request_type": "execute_transfer_quote"
}
```
@@ -0,0 +1,120 @@
# Withdraw Collateral
{% hint style="info" %}
**Note**: use the [max withdrawable](https://docs.nado.xyz/developer-resources/api/gateway/queries/max-withdrawable) query to determine the max amount you can withdraw for a given spot product.
{% endhint %}
## Rate limits
* With spot leverage: 60 withdrawals/min or 10 withdrawals every 10 seconds per wallet. (**weight = 10**)
* Without spot leverage: 30 withdrawals/min or 5 withdrawals every 10 seconds per wallet. (**weight=20**)
{% hint style="info" %}
See more details in [API Rate limits](https://docs.nado.xyz/developer-resources/api/rate-limits).
{% endhint %}
## Request
{% tabs %}
{% tab title="Websocket" %}
**Connect**
<mark style="color:orange;">`WEBSOCKET [GATEWAY_WEBSOCKET_ENDPOINT]`</mark>
**Message**
```json
{
"withdraw_collateral": {
"tx": {
"sender": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43746573743000000000000000",
"productId": 1,
"amount": "1000000000000000000",
"nonce": "1"
},
"signature": "0x"
}
}
```
{% endtab %}
{% tab title="REST" %} <mark style="color:orange;">`POST [GATEWAY_REST_ENDPOINT]/execute`</mark>
**Body**
```json
{
"withdraw_collateral": {
"tx": {
"sender": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43746573743000000000000000",
"productId": 1,
"amount": "1000000000000000000",
"nonce": "1"
},
"signature": "0x"
}
}
```
{% endtab %}
{% endtabs %}
## Request Parameters
<table><thead><tr><th width="154" align="center">Parameter</th><th width="94" align="center">Type</th><th width="112" align="center">Required</th><th>Description</th></tr></thead><tbody><tr><td align="center">tx</td><td align="center">object</td><td align="center">Yes</td><td>Withdraw collateral transaction object. See <a href="#signing">Signing</a> section for details on the transaction fields.</td></tr><tr><td align="center">tx.sender</td><td align="center">string</td><td align="center">Yes</td><td>Hex string representing the subaccount's 32 bytes (address + subaccount name) of the tx sender.</td></tr><tr><td align="center">tx.productId</td><td align="center">number</td><td align="center">Yes</td><td>A spot product ID to withdraw from.</td></tr><tr><td align="center">tx.amount</td><td align="center">string</td><td align="center">Yes</td><td>The amount of the asset to withdraw, denominated in the base ERC20 token of the specified product e.g: USDT0 (product=0) has 6 decimals whereas wETH (product=3) has 18. See <a href="#signing">Signing</a> section for more details.</td></tr><tr><td align="center">tx.nonce</td><td align="center">string</td><td align="center">Yes</td><td>This is an incrementing nonce, can be obtained using the <a href="../queries/nonces">Nonces</a> query.</td></tr><tr><td align="center">signature</td><td align="center">string</td><td align="center">Yes</td><td>Hex string representing hash of the <strong>signed</strong> transaction. See <a href="#signing">Signing</a> section for more details.</td></tr><tr><td align="center">spot_leverage</td><td align="center">boolean</td><td align="center">No</td><td>Indicates whether leverage should be used; when set to <mark style="color:red;"><code>false</code></mark> , the withdrawal fails if the transaction causes a borrow on the subaccount. Defaults to <mark style="color:red;"><code>true</code></mark>.</td></tr></tbody></table>
## Signing
{% hint style="info" %}
See more details and examples in our [signing](https://docs.nado.xyz/developer-resources/api/gateway/signing) page.
{% endhint %}
The solidity typed data struct that needs to be signed is:
```solidity
struct WithdrawCollateral {
bytes32 sender;
uint32 productId;
uint128 amount;
uint64 nonce;
}
```
<mark style="color:red;">`sender`</mark>: a <mark style="color:red;">`bytes32`</mark> sent as a hex string; includes the address and the subaccount identifier.
<mark style="color:red;">`productId`</mark>: a <mark style="color:red;">`uint32`</mark> that specifies the product youd like to withdraw collateral from; must be for a spot product.
<mark style="color:red;">`amount`</mark>: the amount of asset to withdraw, sent as a string. Note that this is different from the amounts provided in transactions that arent <mark style="color:red;">`depositCollateral`</mark>. This is the raw amount of the ERC20 token you want to receive, i.e. if USDT0 has 6 decimals and you want to withdraw 1 USDT0, specify 1e6; if wETH has 18 decimals and you want to withdraw 1 wETH, specify 1e18. Use [all products](https://docs.nado.xyz/developer-resources/api/gateway/queries/all-products) query to view the token address of the corresponding product which can be used to determine the correct decimals to use.
<mark style="color:red;">`nonce`</mark>: the <mark style="color:red;">`tx_nonce`</mark>. This is an incrementing nonce, can be obtained using the [Nonces](https://docs.nado.xyz/developer-resources/api/gateway/queries/nonces) query.
{% hint style="warning" %}
**Note**: for signing you should always use the data type specified in the solidity struct which might be different from the type sent in the request e.g: <mark style="color:red;">`nonce`</mark> should be an <mark style="color:red;">`uint64`</mark> for **Signing** but should be sent as a <mark style="color:red;">`string`</mark> in the final payload.
{% endhint %}
## Response
#### Success
```json
{
"status": "success",
"signature": {signature},
"request_type": "execute_withdraw_collateral"
}
```
#### Failure
```json
{
"status": "failure",
"signature": {signature},
"error": "{error_msg}",
"error_code": {error_code},
"request_type": "execute_withdraw_collateral"
}
```
@@ -0,0 +1,28 @@
# Queries
All queries go through the following endpoint; the exact details of the query are specified by query params or `Websocket` messages.
* **Websocket**: <mark style="color:orange;">`WEBSOCKET [GATEWAY_WEBSOCKET_ENDPOINT]`</mark>
* **REST**: <mark style="color:green;">`GET [GATEWAY_REST_ENDPOINT]/query`</mark> or <mark style="color:orange;">`POST [GATEWAY_REST_ENDPOINT]/query`</mark>
## Overview
### **Amounts and Prices**
In general, amounts come back normalized to 18 decimal places. Meaning that for a balance of 1 USDT0, regardless of the number of decimals USDT0 has on-chain, a value of 1e18 will be returned.
Prices are in <mark style="color:red;">`x18`</mark>, so if the price of one wBTC is $20,000, regardless of the number of decimals wBTC has on-chain, the price will be returned as <mark style="color:red;">`20,000 * 1e18`</mark>.
## API Response
All `queries` return in the format:
```json
{
"status": "success" | "failure",
"data"?: {data},
"error"?: "{error_msg}",
"error_code"?: {error_code},
"request_type": "{request_type}"
}
```
@@ -0,0 +1,155 @@
# All Products
## Rate limits
* 480 requests/min or 8 requests/sec per IP address. (**weight = 5**)
{% hint style="info" %}
See more details in [API Rate limits](https://docs.nado.xyz/developer-resources/api/rate-limits)
{% endhint %}
## Request
{% tabs %}
{% tab title="Websocket" %}
**Connect**
<mark style="color:orange;">`WEBSOCKET [GATEWAY_WEBSOCKET_ENDPOINT]`</mark>
**Message**
```json
{
"type": "all_products"
}
```
{% endtab %}
{% tab title="REST (GET)" %} <mark style="color:green;">**GET**</mark> `[GATEWAY_REST_ENDPOINT]/query?type=all_products`
{% endtab %}
{% tab title="REST (POST)" %} <mark style="color:orange;">`POST [GATEWAY_REST_ENDPOINT]/query`</mark>
**Body**
```json
{
"type": "all_products"
}
```
{% endtab %}
{% endtabs %}
## Response
{% hint style="info" %}
**Note**:
* A product is some asset / position an account can take on.
* A market is a venue for a product against USDT0.
* All products have a market quoted against USDT0, except for product 0.
* Product 0 is the USDT0 asset itself.
* You can retrieve product symbols via [symbols](https://docs.nado.xyz/developer-resources/api/symbols "mention") query.Body
{% endhint %}
```json
{
"status": "success",
"data": {
"spot_products": [
{
"product_id": 0,
"oracle_price_x18": "1000000000000000000",
"risk": {
"long_weight_initial_x18": "1000000000000000000",
"short_weight_initial_x18": "1000000000000000000",
"long_weight_maintenance_x18": "1000000000000000000",
"short_weight_maintenance_x18": "1000000000000000000",
"price_x18": "1000000000000000000"
},
"config": {
"token": "0x5f65358d61a9a281ea3bb930d05889aca21e3f4f",
"interest_inflection_util_x18": "800000000000000000",
"interest_floor_x18": "10000000000000000",
"interest_small_cap_x18": "40000000000000000",
"interest_large_cap_x18": "1000000000000000000",
"withdraw_fee_x18": "1000000000000000000",
"min_deposit_rate_x18": "0"
},
"state": {
"cumulative_deposits_multiplier_x18": "1000000000025524653",
"cumulative_borrows_multiplier_x18": "1000347390837434279",
"total_deposits_normalized": "20001011744258817298755054194662",
"total_borrows_normalized": "1617724891363505323532211"
},
"book_info": {
"size_increment": "0",
"price_increment_x18": "0",
"min_size": "0",
"collected_fees": "0"
}
},
{
"product_id": 1,
"oracle_price_x18": "115575316424148798147115",
"risk": {
"long_weight_initial_x18": "900000000000000000",
"short_weight_initial_x18": "1100000000000000000",
"long_weight_maintenance_x18": "950000000000000000",
"short_weight_maintenance_x18": "1050000000000000000",
"price_x18": "115575316424148798147115"
},
"config": {
"token": "0xc57c1c64561a37ac9e8f9039cb6deab7539d99fc",
"interest_inflection_util_x18": "800000000000000000",
"interest_floor_x18": "10000000000000000",
"interest_small_cap_x18": "40000000000000000",
"interest_large_cap_x18": "1000000000000000000",
"withdraw_fee_x18": "40000000000000",
"min_deposit_rate_x18": "0"
},
"state": {
"cumulative_deposits_multiplier_x18": "1000000000000318713",
"cumulative_borrows_multiplier_x18": "1000347390679880473",
"total_deposits_normalized": "9000399823280682696107190850",
"total_borrows_normalized": "9580268570661550719"
},
"book_info": {
"size_increment": "1000000000000000",
"price_increment_x18": "1000000000000000000",
"min_size": "4000000000000000",
"collected_fees": "0"
}
}
],
"perp_products": [
{
"product_id": 2,
"oracle_price_x18": "115432187703236794231754",
"risk": {
"long_weight_initial_x18": "950000000000000000",
"short_weight_initial_x18": "1050000000000000000",
"long_weight_maintenance_x18": "970000000000000000",
"short_weight_maintenance_x18": "1030000000000000000",
"price_x18": "115432187703236794231754"
},
"state": {
"cumulative_funding_long_x18": "-394223711772447555304",
"cumulative_funding_short_x18": "-394223711772447555304",
"available_settle": "20092193239667417956947",
"open_interest": "113605000000000000000"
},
"book_info": {
"size_increment": "1000000000000000",
"price_increment_x18": "1000000000000000000",
"min_size": "4000000000000000",
"collected_fees": "0"
}
}
]
},
"request_type": "query_all_products"
}
```
@@ -0,0 +1,62 @@
# Contracts
## Rate limits
* 2400 requests/min or 40 requests/sec per IP address. (**weight = 1**)
{% hint style="info" %}
See more details in [API Rate limits](https://docs.nado.xyz/developer-resources/api/rate-limits)
{% endhint %}
## Request
{% tabs %}
{% tab title="Websocket" %}
**Connect**
<mark style="color:orange;">`WEBSOCKET [GATEWAY_WEBSOCKET_ENDPOINT]`</mark>
**Message**
```json
{
"type": "contracts"
}
```
{% endtab %}
{% tab title="REST (GET)" %} <mark style="color:green;">**GET**</mark> `[GATEWAY_REST_ENDPOINT]/query?type=contracts`
{% endtab %}
{% tab title="REST (POST)" %} <mark style="color:orange;">`POST [GATEWAY_REST_ENDPOINT]/query`</mark>
**Body**
```json
{
"type": "contracts"
}
```
{% endtab %}
{% endtabs %}
## Response
```json
{
"status": "success",
"data": {
"chain_id": "763373",
"endpoint_addr": "0xf8963f7860af7de9b94893edb9a3b5c155e1fc0c"
},
"request_type": "query_contracts"
}
```
{% hint style="info" %}
**Note:**
* <mark style="color:red;">`endpoint_addr`</mark> is the address of the Nado endpoint contracts. Deposits are sent to the endpoint address; **this to used sign every request except&#x20;**<mark style="color:red;">**`PlaceOrder`**</mark>
{% endhint %}
@@ -0,0 +1,160 @@
# Edge All Products
## Rate limits
* 480 requests/min or 8 requests/sec per IP address. (**weight = 5**)
{% hint style="info" %}
See more details in [API Rate limits](https://docs.nado.xyz/developer-resources/api/rate-limits)
{% endhint %}
## Request
{% tabs %}
{% tab title="Websocket" %}
**Connect**
<mark style="color:orange;">`WEBSOCKET [GATEWAY_WEBSOCKET_ENDPOINT]`</mark>
**Message**
```json
{
"type": "edge_all_products"
}
```
{% endtab %}
{% tab title="REST (GET)" %} <mark style="color:green;">**GET**</mark> `[GATEWAY_REST_ENDPOINT]/query?type=edge_all_products`
{% endtab %}
{% tab title="REST (POST)" %} <mark style="color:orange;">`POST [GATEWAY_REST_ENDPOINT]/query`</mark>
**Body**
```json
{
"type": "edge_all_products"
}
```
{% endtab %}
{% endtabs %}
## Response
{% hint style="info" %}
**Note**:
* A product is some asset / position an account can take on.
* A market is a venue for a product against USDT0.
* All products have a market quoted against USDT0, except for product 0.
* Product 0 is the USDT0 asset itself.
* You can retrieve product symbols via [symbols](https://docs.nado.xyz/developer-resources/api/symbols "mention") query.Body
* Returns a mapping of <mark style="color:orange;">`chain_id -> all_products`</mark>
{% endhint %}
```json
{
"status": "success",
"data": {
"edge_all_products": {
"763373": {
"spot_products": [
{
"product_id": 0,
"oracle_price_x18": "1000000000000000000",
"risk": {
"long_weight_initial_x18": "1000000000000000000",
"short_weight_initial_x18": "1000000000000000000",
"long_weight_maintenance_x18": "1000000000000000000",
"short_weight_maintenance_x18": "1000000000000000000",
"price_x18": "1000000000000000000"
},
"config": {
"token": "0x5f65358d61a9a281ea3bb930d05889aca21e3f4f",
"interest_inflection_util_x18": "800000000000000000",
"interest_floor_x18": "10000000000000000",
"interest_small_cap_x18": "40000000000000000",
"interest_large_cap_x18": "1000000000000000000",
"withdraw_fee_x18": "1000000000000000000",
"min_deposit_rate_x18": "0"
},
"state": {
"cumulative_deposits_multiplier_x18": "1000000000025524653",
"cumulative_borrows_multiplier_x18": "1000347390837434279",
"total_deposits_normalized": "20001011744258817298755054194662",
"total_borrows_normalized": "1617724891363505323532211"
},
"book_info": {
"size_increment": "0",
"price_increment_x18": "0",
"min_size": "0",
"collected_fees": "0"
}
},
{
"product_id": 1,
"oracle_price_x18": "115575316424148798147115",
"risk": {
"long_weight_initial_x18": "900000000000000000",
"short_weight_initial_x18": "1100000000000000000",
"long_weight_maintenance_x18": "950000000000000000",
"short_weight_maintenance_x18": "1050000000000000000",
"price_x18": "115575316424148798147115"
},
"config": {
"token": "0xc57c1c64561a37ac9e8f9039cb6deab7539d99fc",
"interest_inflection_util_x18": "800000000000000000",
"interest_floor_x18": "10000000000000000",
"interest_small_cap_x18": "40000000000000000",
"interest_large_cap_x18": "1000000000000000000",
"withdraw_fee_x18": "40000000000000",
"min_deposit_rate_x18": "0"
},
"state": {
"cumulative_deposits_multiplier_x18": "1000000000000318713",
"cumulative_borrows_multiplier_x18": "1000347390679880473",
"total_deposits_normalized": "9000399823280682696107190850",
"total_borrows_normalized": "9580268570661550719"
},
"book_info": {
"size_increment": "1000000000000000",
"price_increment_x18": "1000000000000000000",
"min_size": "4000000000000000",
"collected_fees": "0"
}
}
],
"perp_products": [
{
"product_id": 2,
"oracle_price_x18": "115432187703236794231754",
"risk": {
"long_weight_initial_x18": "950000000000000000",
"short_weight_initial_x18": "1050000000000000000",
"long_weight_maintenance_x18": "970000000000000000",
"short_weight_maintenance_x18": "1030000000000000000",
"price_x18": "115432187703236794231754"
},
"state": {
"cumulative_funding_long_x18": "-394223711772447555304",
"cumulative_funding_short_x18": "-394223711772447555304",
"available_settle": "20092193239667417956947",
"open_interest": "113605000000000000000"
},
"book_info": {
"size_increment": "1000000000000000",
"price_increment_x18": "1000000000000000000",
"min_size": "4000000000000000",
"collected_fees": "0"
}
}
]
}
}
},
"request_type": "query_edge_all_products"
}
```
@@ -0,0 +1,93 @@
# Fee Rates
## Rate limits
* 1200 requests/min or 20 requests/sec per IP address. (**weight = 2**)
{% hint style="info" %}
See more details in [API Rate limits](https://docs.nado.xyz/developer-resources/api/rate-limits)
{% endhint %}
## Request
{% tabs %}
{% tab title="Websocket" %}
**Connect**
<mark style="color:orange;">`WEBSOCKET [GATEWAY_WEBSOCKET_ENDPOINT]`</mark>
**Message**
```json
{
"type": "fee_rates",
"sender": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43000000000000000000000000"
}
```
{% endtab %}
{% tab title="REST (GET)" %} <mark style="color:green;">**GET**</mark> `[GATEWAY_REST_ENDPOINT]/query?type=fee_rates&sender={sender}`
{% endtab %}
{% tab title="REST (POST)" %} <mark style="color:orange;">`POST [GATEWAY_REST_ENDPOINT]/query`</mark>
**Message**
```json
{
"type": "fee_rates",
"sender": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43000000000000000000000000"
}
```
{% endtab %}
{% endtabs %}
## Request Parameters
<table><thead><tr><th width="140" align="center">Parameter</th><th width="97" align="center">Type</th><th width="104" align="center">Required</th><th>Description</th></tr></thead><tbody><tr><td align="center">sender</td><td align="center">string</td><td align="center">Yes</td><td>A <mark style="color:red;"><code>bytes32</code></mark> sent as a hex string; includes the address and the subaccount identifier.</td></tr></tbody></table>
## Response
```json
{
"status": "success",
"data": {
"taker_fee_rates_x18": [
"0",
"300000000000000",
"200000000000000",
"300000000000000",
"200000000000000"
],
"maker_fee_rates_x18": [
"0",
"0",
"0",
"0",
"0"
],
"liquidation_sequencer_fee": "250000000000000000",
"health_check_sequencer_fee": "100000000000000000",
"taker_sequencer_fee": "25000000000000000",
"withdraw_sequencer_fees": [
"10000000000000000",
"40000000000000",
"0",
"600000000000000",
"0"
]
},
"request_type": "query_fee_rates",
}
```
{% hint style="info" %}
* <mark style="color:red;">`taker_fee_rates_x18`</mark>: taker fee associated with a given product indexed by `product_id`. **Note**: this fee represents the basis point (BPS) on a taker order in <mark style="color:red;">`x18`</mark>.
* <mark style="color:red;">`maker_fee_rates_x18`</mark>: maker fee associated with a given produced indexed by <mark style="color:red;">`product_id`</mark>`.`
* <mark style="color:red;">`withdraw_sequencer_fees`</mark>: withdraw fees associated with a given product indexed by <mark style="color:red;">`product_id`</mark>. **Note**: this fee represents a fixed amount of product to be deducted as fee in <mark style="color:red;">`x18`</mark>.
{% endhint %}
See our [fees](https://github.com/nadohq/nado-docs/blob/main/docs/basics/fees.md) page for details about current fee rates.
@@ -0,0 +1,69 @@
# Health Groups
{% hint style="info" %}
**Note**: a health group is a perp and spot product whose health is calculated together (e.g. BTC and BTC-PERP).
{% endhint %}
## Rate limits
* 1200 requests/min or 20 requests/sec per IP address. (**weight = 2**)
{% hint style="info" %}
See more details in [API Rate limits](https://docs.nado.xyz/developer-resources/api/rate-limits)
{% endhint %}
## Request
{% tabs %}
{% tab title="Websocket" %}
**Connect**
<mark style="color:orange;">`WEBSOCKET [GATEWAY_WEBSOCKET_ENDPOINT]`</mark>
**Message**
```json
{
"type": "health_groups"
}
```
{% endtab %}
{% tab title="REST (GET)" %} <mark style="color:green;">**GET**</mark> `[GATEWAY_REST_ENDPOINT]/query?type=health_groups`
{% endtab %}
{% tab title="REST (POST)" %} <mark style="color:orange;">`POST [GATEWAY_REST_ENDPOINT]/query`</mark>
**Message**
```json
{
"type": "health_groups"
}
```
{% endtab %}
{% endtabs %}
## Response
```json
{
"status": "success",
"data": {
"health_groups": [
[
1,
2
]
]
},
"request_type": "query_health_groups"
}
```
{% hint style="info" %}
* <mark style="color:red;">`health_groups`</mark>: list of all available health groups. **Note**: <mark style="color:red;">`health_groups[i]`</mark> is the spot / perp product pair of health group <mark style="color:red;">`i`</mark> where <mark style="color:red;">`health_groups[i][0]`</mark> is the spot <mark style="color:red;">`product_id`</mark> and <mark style="color:red;">`health_groups[i][1]`</mark> is the perp <mark style="color:red;">`product_id`</mark>. Additionally, it is possible for a health group to only have either a spot or perp product, in which case, the product that doesnt exist is set to <mark style="color:red;">`0`</mark>.
{% endhint %}
@@ -0,0 +1,55 @@
# Insurance
## Rate limits
* 1200 requests/min or 20 requests/sec per IP address. (**weight = 2**)
{% hint style="info" %}
See more details in [API Rate limits](https://docs.nado.xyz/developer-resources/api/rate-limits)
{% endhint %}
## Request
{% tabs %}
{% tab title="Websocket" %}
**Connect**
<mark style="color:orange;">`WEBSOCKET [GATEWAY_WEBSOCKET_ENDPOINT]`</mark>
**Message**
```json
{
"type": "insurance"
}
```
{% endtab %}
{% tab title="REST (GET)" %} <mark style="color:green;">**GET**</mark> `[GATEWAY_REST_ENDPOINT]/query?type=insurance`
{% endtab %}
{% tab title="REST (POST)" %} <mark style="color:orange;">`POST [GATEWAY_REST_ENDPOINT]/query`</mark>
**Message**
```json
{
"type": "insurance"
}
```
{% endtab %}
{% endtabs %}
## Response
```json
{
"status": "success",
"data": {
"insurance": "552843342443351553629462"
},
"request_type": "query_insurance"
}
```
@@ -0,0 +1,171 @@
# Isolated Positions
## Rate limits
* 240 requests/min or 40 requests every 10 seconds per IP address. (**weight = 10**)
{% hint style="info" %}
See more details in [API Rate limits](https://docs.nado.xyz/developer-resources/api/rate-limits)
{% endhint %}
## Request
{% tabs %}
{% tab title="Websocket" %}
**Connect**
<mark style="color:orange;">`WEBSOCKET [GATEWAY_WEBSOCKET_ENDPOINT]`</mark>
**Message**
```json
{
"type": "isolated_positions",
"subaccount": "0xeae27ae6412147ed6d5692fd91709dad6dbfc34264656661756c740000000000"
}
```
{% endtab %}
{% tab title="REST (GET)" %} <mark style="color:green;">**GET**</mark> `[GATEWAY_REST_ENDPOINT]/query?type=isolated_positions&subaccount={subaccount}`
{% endtab %}
{% tab title="REST (POST)" %} <mark style="color:orange;">`POST [GATEWAY_REST_ENDPOINT]/query`</mark>
**Message**
```json
{
"type": "isolated_positions",
"subaccount": "0xeae27ae6412147ed6d5692fd91709dad6dbfc34264656661756c740000000000"
}
```
{% endtab %}
{% endtabs %}
## Request Parameters
<table><thead><tr><th width="140" align="center">Parameter</th><th width="100" align="center">Type</th><th width="104" align="center">Required</th><th>Description</th></tr></thead><tbody><tr><td align="center">subaccount</td><td align="center">string</td><td align="center">Yes</td><td>A <mark style="color:red;"><code>bytes32</code></mark> sent as a hex string; includes the address and the subaccount identifier. See <a href="../../executes#sender-field-structure">sender field structure</a> for details.</td></tr></tbody></table>
## Response
{% hint style="info" %}
**Note**:
* <mark style="color:red;">`isolated_positions[i].subaccount`</mark>: is the isolated subaccount for the base product.
* <mark style="color:red;">`healths`</mark>:
* <mark style="color:red;">`healths[0]`</mark>: info about your initial health, which is weighted by `long_weight_initial_x18` and `short_weight_initial_x18.`
* <mark style="color:red;">`healths[1]`</mark>: info about your maintenance health, which is weighted by `long_weight_maintenance_x18` and `short_weight_maintenance_x18.`
* <mark style="color:red;">`healths[2]`</mark>: info about your unweighted health.
{% endhint %}
```json
{
"status": "success",
"data": {
"isolated_positions": [
{
"subaccount": "0xeae27ae6412147ed6d5692fd91709dad6dbfc34200000000000000280269736f",
"quote_balance": {
"product_id": 0,
"balance": {
"amount": "200044412311089295472"
}
},
"base_balance": {
"product_id": 40,
"balance": {
"amount": "1720000000000000000000",
"v_quote_balance": "-800854578334374649165",
"last_cumulative_funding_x18": "85496772388082947"
}
},
"quote_product": {
"product_id": 0,
"oracle_price_x18": "1000000000000000000",
"risk": {
"long_weight_initial_x18": "1000000000000000000",
"short_weight_initial_x18": "1000000000000000000",
"long_weight_maintenance_x18": "1000000000000000000",
"short_weight_maintenance_x18": "1000000000000000000",
"price_x18": "1000000000000000000"
},
"config": {
"token": "0x5f65358d61a9a281ea3bb930d05889aca21e3f4f",
"interest_inflection_util_x18": "800000000000000000",
"interest_floor_x18": "10000000000000000",
"interest_small_cap_x18": "40000000000000000",
"interest_large_cap_x18": "1000000000000000000",
"withdraw_fee_x18": "1000000000000000000",
"min_deposit_rate_x18": "0"
},
"state": {
"cumulative_deposits_multiplier_x18": "1000000000025524653",
"cumulative_borrows_multiplier_x18": "1000347390837434279",
"total_deposits_normalized": "20001011744258817298755054194662",
"total_borrows_normalized": "1617724891363505323532211"
},
"book_info": {
"size_increment": "0",
"price_increment_x18": "0",
"min_size": "0",
"collected_fees": "0"
}
},
"base_product": {
"product_id": 2,
"oracle_price_x18": "115596528090565357611177",
"risk": {
"long_weight_initial_x18": "950000000000000000",
"short_weight_initial_x18": "1050000000000000000",
"long_weight_maintenance_x18": "970000000000000000",
"short_weight_maintenance_x18": "1030000000000000000",
"price_x18": "115596528090565357611177"
},
"state": {
"cumulative_funding_long_x18": "-394223711772447555304",
"cumulative_funding_short_x18": "-394223711772447555304",
"available_settle": "20092193239667417956947",
"open_interest": "113605000000000000000"
},
"book_info": {
"size_increment": "1000000000000000",
"price_increment_x18": "1000000000000000000",
"min_size": "4000000000000000",
"collected_fees": "0"
}
},
"quote_healths": [
"200044412311089295472",
"200044412311089295472",
"200044412311089295472"
],
"base_healths": [
"-109839746873700492625",
"-71450034014774150595",
"-33060321155847808565"
],
"healths": [
{
"assets": "200044412311089295472",
"liabilities": "109839746873700492625",
"health": "90204665437388802847"
},
{
"assets": "200044412311089295472",
"liabilities": "71450034014774150595",
"health": "128594378296315144877"
},
{
"assets": "200044412311089295472",
"liabilities": "33060321155847808565",
"health": "166984091155241486907"
}
]
}
]
},
"request_type": "query_isolated_positions"
}
```
@@ -0,0 +1,63 @@
# Linked Signer
## Rate limits
* 480 requests/min or 8 requests/sec per IP address. (**weight = 5**)
{% hint style="info" %}
See more details in [API Rate limits](https://docs.nado.xyz/developer-resources/api/rate-limits)
{% endhint %}
## Request
{% tabs %}
{% tab title="Websocket" %}
**Connect**
<mark style="color:orange;">`WEBSOCKET [GATEWAY_WEBSOCKET_ENDPOINT]`</mark>
**Message**
```json
{
"type": "linked_signer",
"subaccount": "0x9b9989a4E0b260B84a5f367d636298a8bfFb7a9b42544353504f540000000000"
}
```
{% endtab %}
{% tab title="REST (GET)" %} <mark style="color:green;">**GET**</mark> `[GATEWAY_REST_ENDPOINT]/query?type=linked_signer&subaccount=0x9b9989a4E0b260B84a5f367d636298a8bfFb7a9b42544353504f540000000000`
{% endtab %}
{% tab title="REST (POST)" %} <mark style="color:orange;">`POST [GATEWAY_REST_ENDPOINT]/query`</mark>
**Message**
```json
{
"type": "linked_signer",
"subaccount": "0x9b9989a4E0b260B84a5f367d636298a8bfFb7a9b42544353504f540000000000"
}
```
{% endtab %}
{% endtabs %}
## Response
```json
{
"status": "success",
"data": {
"linked_signer": "0x0000000000000000000000000000000000000000"
},
"request_type": "query_linked_signer",
}
```
{% hint style="info" %}
**Notes**:
* <mark style="color:red;">`linked_signer`</mark>: the current linked signer address (20 bytes) associated to the provided `subaccount`. It returns the zero address when no signer is linked.
{% endhint %}
@@ -0,0 +1,91 @@
# Market Liquidity
## Rate limits
* 2400 requests/min or 40 requests/sec per IP address. (**weight = 1**)
{% hint style="info" %}
See more details in [API Rate limits](https://docs.nado.xyz/developer-resources/api/rate-limits)
{% endhint %}
## Request
{% tabs %}
{% tab title="Websocket" %}
**Connect**
<mark style="color:orange;">`WEBSOCKET [GATEWAY_WEBSOCKET_ENDPOINT]`</mark>
**Message**
```json
{
"type": "market_liquidity",
"product_id": 1,
"depth": 10
}
```
{% endtab %}
{% tab title="REST (GET)" %} <mark style="color:green;">**GET**</mark> `[GATEWAY_REST_ENDPOINT]/query?type=market_liquidity&product_id={product_id}&depth={depth}`
{% endtab %}
{% tab title="REST (POST)" %} <mark style="color:orange;">`POST [GATEWAY_REST_ENDPOINT]/query`</mark>
**Body**
```json
{
"type": "market_liquidity",
"product_id": 1,
"depth": 10
}
```
{% endtab %}
{% endtabs %}
## Request Parameters
<table><thead><tr><th width="140" align="center">Parameter</th><th width="97" align="center">Type</th><th width="104" align="center">Required</th><th>Description</th></tr></thead><tbody><tr><td align="center">product_id</td><td align="center">number</td><td align="center">Yes</td><td>Id of spot / perp product for which to retrieve market liquidity.</td></tr><tr><td align="center">depth</td><td align="center">number</td><td align="center">Yes</td><td>Number of price levels to retrieve. (<mark style="color:red;"><code>max: 100</code></mark>)</td></tr></tbody></table>
## Response
```json
{
"status": "success",
"data": {
"bids": [
[
"30234000000000000000000",
"663000000000000000"
],
[
"30170000000000000000000",
"24623000000000000000"
]
],
"asks": [
[
"30245000000000000000000",
"664000000000000000"
],
[
"30252000000000000000000",
"4646000000000000000"
]
],
"timestamp": "1681850046966693400",
"product_id": 1
},
"request_type": "query_market_liquidity"
}
```
{% hint style="info" %}
**Note:**
* Each entry inside bids and asks is an array of price and size respectively. **Note**: that price is represented using fixed point, so it is <mark style="color:red;">`1e18`</mark> times greater than the decimal price.
* <mark style="color:red;">`timestamp`</mark> is in nanoseconds.
{% endhint %}
@@ -0,0 +1,131 @@
# Market Prices
## Rate limits
* 2400 requests/min or 40 requests/sec per IP address. (**weight = 1**) or length of <mark style="color:red;">`product_ids`</mark> for [multi-product markets](#multiple-products) query.
{% hint style="info" %}
See more details in [API Rate limits](https://docs.nado.xyz/developer-resources/api/rate-limits)
{% endhint %}
## Single Product
### Request
{% tabs %}
{% tab title="Websocket" %}
**Connect**
<mark style="color:orange;">`WEBSOCKET [GATEWAY_WEBSOCKET_ENDPOINT]`</mark>
**Message**
```json
{
"type": "market_price",
"product_id": 1
}
```
{% endtab %}
{% tab title="REST (GET)" %} <mark style="color:green;">**GET**</mark> `[GATEWAY_REST_ENDPOINT]/query?type=market_price&product_id={product_id}`
{% endtab %}
{% tab title="REST (POST)" %} <mark style="color:orange;">`POST [GATEWAY_REST_ENDPOINT]/query`</mark>
**Body**
```json
{
"type": "market_price",
"product_id": 1
}
```
{% endtab %}
{% endtabs %}
### Request Parameters
<table><thead><tr><th width="140" align="center">Parameter</th><th width="97" align="center">Type</th><th width="104" align="center">Required</th><th>Description</th></tr></thead><tbody><tr><td align="center">product_id</td><td align="center">number</td><td align="center">Yes</td><td>Id of spot / perp product for which to retrieve market price data.</td></tr></tbody></table>
### Response
```json
{
"status": "success",
"data": {
"product_id": 1,
"bid_x18": "24224000000000000000000",
"ask_x18": "24243000000000000000000"
},
"request_type": "query_market_price",
}
```
{% hint style="info" %}
**Note**: that price is represented using fixed point, so it is <mark style="color:red;">`1e18`</mark> times greater than the decimal price.
{% endhint %}
## Multiple Products
### Request
{% tabs %}
{% tab title="Websocket" %}
**Connect**
<mark style="color:orange;">`WEBSOCKET [CORE_WEBSOCKET_ENDPOINT]`</mark>
**Message**
```json
{
"type": "market_prices",
"product_ids": [1, 2]
}
```
{% endtab %}
{% tab title="REST" %} <mark style="color:orange;">`POST /query`</mark>
**Body**
```json
{
"type": "market_prices",
"product_ids": [1, 2]
}
```
{% endtab %}
{% endtabs %}
### Request Parameters
<table><thead><tr><th width="140" align="center">Parameter</th><th width="118" align="center">Type</th><th width="135.125" align="center">Required</th><th>Description</th></tr></thead><tbody><tr><td align="center">product_ids</td><td align="center">number[]</td><td align="center">Yes</td><td>List of spot / perp products for which to retrieve market price data.</td></tr></tbody></table>
### Response
```json
{
"status": "success",
"data": {
"market_prices": [
{
"product_id": 1,
"bid_x18": "31315000000000000000000",
"ask_x18": "31326000000000000000000"
},
{
"product_id": 2,
"bid_x18": "31291000000000000000000",
"ask_x18": "31301000000000000000000"
},
]
},
"request_type": "query_market_prices"
}
```
@@ -0,0 +1,61 @@
# Max NLP Burnable
## Rate limits
* 120 requests/min or 20 requests every 10 seconds per IP address. (**weight = 20**)
{% hint style="info" %}
See more details in [API Rate limits](https://docs.nado.xyz/developer-resources/api/rate-limits)
{% endhint %}
## Request
{% tabs %}
{% tab title="Websocket" %}
**Connect**
<mark style="color:orange;">`WEBSOCKET [GATEWAY_WEBSOCKET_ENDPOINT]`</mark>
**Message**
```json
{
"type": "max_nlp_burnable",
"sender": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43000000000000000000000000"
}
```
{% endtab %}
{% tab title="REST (GET)" %} <mark style="color:green;">**GET**</mark> `[GATEWAY_REST_ENDPOINT]/query?type=max_nlp_burnable&sender={sender}`
{% endtab %}
{% tab title="REST (POST)" %} <mark style="color:orange;">`POST [GATEWAY_REST_ENDPOINT]/query`</mark>
**Body**
```json
{
"type": "max_nlp_burnable",
"sender": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43000000000000000000000000"
}
```
{% endtab %}
{% endtabs %}
## Request Parameters
<table><thead><tr><th width="154" align="center">Parameter</th><th width="97" align="center">Type</th><th width="87" align="center">Required</th><th>Description</th></tr></thead><tbody><tr><td align="center">sender</td><td align="center">string</td><td align="center">Yes</td><td>A <mark style="color:red;"><code>bytes32</code></mark> sent as a hex string; includes the address and the subaccount identifier.</td></tr></tbody></table>
## Response
```json
{
"status": "success",
"data": {
"max_nlp_amount": "34250782930221490366619"
},
"request_type": "query_max_nlp_burnable",
}
```
@@ -0,0 +1,63 @@
# Max NLP Mintable
## Rate limits
* 120 requests/min or 20 requests every 10 seconds per IP address. (**weight = 20**)
{% hint style="info" %}
See more details in [API Rate limits](https://docs.nado.xyz/developer-resources/api/rate-limits)
{% endhint %}
## Request
{% tabs %}
{% tab title="Websocket" %}
**Connect**
<mark style="color:orange;">`WEBSOCKET [GATEWAY_WEBSOCKET_ENDPOINT]`</mark>
**Message**
```json
{
"type": "max_nlp_mintable",
"sender": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43000000000000000000000000",
"spot_leverage": "true"
}
```
{% endtab %}
{% tab title="REST (GET)" %} <mark style="color:green;">**GET**</mark> `[GATEWAY_REST_ENDPOINT]/query?type=max_nlp_mintable&sender={sender}`
{% endtab %}
{% tab title="REST (POST)" %} <mark style="color:orange;">`POST [GATEWAY_REST_ENDPOINT]/query`</mark>
**Body**
```json
{
"type": "max_nlp_mintable",
"sender": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43000000000000000000000000",
"spot_leverage": "true"
}
```
{% endtab %}
{% endtabs %}
## Request Parameters
<table><thead><tr><th width="154" align="center">Parameter</th><th width="97" align="center">Type</th><th width="87" align="center">Required</th><th>Description</th></tr></thead><tbody><tr><td align="center">sender</td><td align="center">string</td><td align="center">Yes</td><td>A <mark style="color:red;"><code>bytes32</code></mark> sent as a hex string; includes the address and the subaccount identifier.</td></tr><tr><td align="center">spot_leverage</td><td align="center">boolean</td><td align="center">No</td><td>Boolean sent as a string. indicates whether leverage should be used; when set to <mark style="color:red;"><code>false</code></mark> , returns the max amount of base LP mintable possible without borrow. Defaults to <mark style="color:red;"><code>true</code></mark></td></tr></tbody></table>
## Response
```json
{
"status": "success",
"data": {
"max_quote_amount": "34250782930221490366619"
},
"request_type": "query_max_nlp_mintable",
}
```
@@ -0,0 +1,73 @@
# Max Order Size
## Rate limits
* 480 requests/min or 80 requests every 10 seconds per IP address. (**weight = 5**)
{% hint style="info" %}
See more details in [API Rate limits](https://docs.nado.xyz/developer-resources/api/rate-limits)
{% endhint %}
## Request
{% tabs %}
{% tab title="Websocket" %}
**Connect**
<mark style="color:orange;">`WEBSOCKET [GATEWAY_WEBSOCKET_ENDPOINT]`</mark>
**Message**
```json
{
"type": "max_order_size",
"product_id": 1,
"sender": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43000000000000000000000000",
"price_x18": "23000000000000000000000",
"direction": "short",
"spot_leverage": "true",
"reduce_only": "false",
"isolated": "false"
}
```
{% endtab %}
{% tab title="REST (GET)" %} <mark style="color:green;">**GET**</mark> `[GATEWAY_REST_ENDPOINT]/query?type=max_order_size&product_id={product_id}&sender={sender}&price_x18={price_x18}&direction={direction}`
{% endtab %}
{% tab title="REST (POST)" %} <mark style="color:orange;">`POST [GATEWAY_REST_ENDPOINT]/query`</mark>
**Body**
```json
{
"type": "max_order_size",
"product_id": 1,
"sender": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43000000000000000000000000",
"price_x18": "23000000000000000000000",
"direction": "short",
"spot_leverage": "true",
"reduce_only": "false",
"isolated": "false"
}
```
{% endtab %}
{% endtabs %}
## Request Parameters
<table><thead><tr><th width="158" align="center">Parameter</th><th width="97" align="center">Type</th><th width="104" align="center">Required</th><th>Description</th></tr></thead><tbody><tr><td align="center">sender</td><td align="center">string</td><td align="center">Yes</td><td>A <mark style="color:red;"><code>bytes32</code></mark> sent as a hex string; includes the address and the subaccount identifier.</td></tr><tr><td align="center">product_id</td><td align="center">number</td><td align="center">Yes</td><td>Id of spot / perp product for which to retrieve max order size.</td></tr><tr><td align="center">price_x18</td><td align="center">string</td><td align="center">Yes</td><td>An <mark style="color:red;"><code>int128</code></mark> representing the price of the order multiplied by 1e18, sent as a string. For example, a price of 1 USDT0 would be sent as <code>"1000000000000000000"</code></td></tr><tr><td align="center">direction</td><td align="center">string</td><td align="center">Yes</td><td><mark style="color:red;"><code>long</code></mark> for max bid or <mark style="color:red;"><code>short</code></mark> for max ask.</td></tr><tr><td align="center">spot_leverage</td><td align="center">string</td><td align="center">No</td><td>Boolean sent as a string. Indicates whether leverage should be used; when set to <mark style="color:red;"><code>false</code></mark> , returns the max order possible without borrow. Defaults to <mark style="color:red;"><code>true</code></mark></td></tr><tr><td align="center">reduce_only</td><td align="center">string</td><td align="center">No</td><td>Boolean sent as a string. Indicates wether to retrieve the max order size to close / reduce a position. Defaults to <mark style="color:red;"><code>false</code></mark></td></tr><tr><td align="center">isolated</td><td align="center">string</td><td align="center">No</td><td>Boolean sent as a string. When set to <mark style="color:red;"><code>true</code></mark>, calculates max order size for an isolated margin position. Defaults to <mark style="color:red;"><code>false</code></mark>. See <a href="https://github.com/nadohq/nado-docs/blob/main/docs/basics/isolated-margin.md">Isolated Margin</a> to learn more.</td></tr></tbody></table>
## Response
```json
{
"status": "success",
"data": {
"max_order_size": "137847520631947079935"
},
"request_type": "query_max_order_size",
}
```
@@ -0,0 +1,65 @@
# Max Withdrawable
## Rate limits
* 480 requests/min or 80 requests every 10 seconds per IP address. (**weight = 5**)
{% hint style="info" %}
See more details in [API Rate limits](https://docs.nado.xyz/developer-resources/api/rate-limits)
{% endhint %}
## Request
{% tabs %}
{% tab title="Websocket" %}
**Connect**
<mark style="color:orange;">`WEBSOCKET [GATEWAY_WEBSOCKET_ENDPOINT]`</mark>
**Message**
```json
{
"type": "max_withdrawable",
"product_id": 1,
"sender": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43000000000000000000000000",
"spot_leverage": "true"
}
```
{% endtab %}
{% tab title="REST (GET)" %} <mark style="color:green;">**GET**</mark> `[GATEWAY_REST_ENDPOINT]/query?type=max_withdrawable&product_id={product_id}&sender={sender}`
{% endtab %}
{% tab title="REST (POST)" %} <mark style="color:orange;">`POST [GATEWAY_REST_ENDPOINT]/query`</mark>
**Message**
```json
{
"type": "max_withdrawable",
"product_id": 1,
"sender": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43000000000000000000000000",
"spot_leverage": "true"
}
```
{% endtab %}
{% endtabs %}
## Request Parameters
<table><thead><tr><th width="154" align="center">Parameter</th><th width="97" align="center">Type</th><th width="104" align="center">Required</th><th>Description</th></tr></thead><tbody><tr><td align="center">sender</td><td align="center">string</td><td align="center">Yes</td><td>A <mark style="color:red;"><code>bytes32</code></mark> sent as a hex string; includes the address and the subaccount identifier.</td></tr><tr><td align="center">product_id</td><td align="center">number</td><td align="center">Yes</td><td>Id of spot / perp product for which to retrieve max withdrawable amount.</td></tr><tr><td align="center">spot_leverage</td><td align="center">string</td><td align="center">No</td><td>Boolean sent as a string. Indicates whether leverage should be used; when set to <mark style="color:red;"><code>false</code></mark> , returns the max withdrawable amount possible without borrow. Defaults to <mark style="color:red;"><code>true</code></mark></td></tr></tbody></table>
## Response
```json
{
"status": "success",
"data": {
"max_withdrawable": "7968557932297078268650"
},
"request_type": "query_max_withdrawable",
}
```
@@ -0,0 +1,117 @@
# NLP Locked Balances
## Rate limits
* 120 requests/min or 20 requests every 10 seconds per IP address. (**weight = 20**)
{% hint style="info" %}
See more details in [API Rate limits](https://docs.nado.xyz/developer-resources/api/rate-limits)
{% endhint %}
## Request
{% tabs %}
{% tab title="Websocket" %}
**Connect**
<mark style="color:orange;">`WEBSOCKET [GATEWAY_WEBSOCKET_ENDPOINT]`</mark>
**Message**
```json
{
"type": "nlp_locked_balances",
"subaccount": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43000000000000000000000000"
}
```
{% endtab %}
{% tab title="REST (GET)" %} <mark style="color:green;">**GET**</mark> `[GATEWAY_REST_ENDPOINT]/query?type=nlp_locked_balances&subaccount={subaccount}`
{% endtab %}
{% tab title="REST (POST)" %} <mark style="color:orange;">`POST [GATEWAY_REST_ENDPOINT]/query`</mark>
**Body**
```json
{
"type": "nlp_locked_balances",
"subaccount": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43000000000000000000000000"
}
```
{% endtab %}
{% endtabs %}
## Request Parameters
<table><thead><tr><th width="154" align="center">Parameter</th><th width="97" align="center">Type</th><th width="87" align="center">Required</th><th>Description</th></tr></thead><tbody><tr><td align="center">subaccount</td><td align="center">string</td><td align="center">Yes</td><td>A <mark style="color:red;"><code>bytes32</code></mark> sent as a hex string; includes the address and the subaccount identifier.</td></tr></tbody></table>
## Response
```json
{
"status": "success",
"data": {
"balance_locked": {
"product_id": 0,
"balance": {
"amount": "1000000000000000000000",
"last_cumulative_funding_x18": "0"
}
},
"balance_unlocked": {
"product_id": 0,
"balance": {
"amount": "500000000000000000000",
"last_cumulative_funding_x18": "0"
}
},
"locked_balances": [
{
"balance": {
"product_id": 0,
"balance": {
"amount": "250000000000000000000",
"last_cumulative_funding_x18": "0"
}
},
"unlocked_at": "1735689600"
},
{
"balance": {
"product_id": 0,
"balance": {
"amount": "750000000000000000000",
"last_cumulative_funding_x18": "0"
}
},
"unlocked_at": "1736035200"
}
]
},
"request_type": "query_nlp_locked_balances"
}
```
## Response Fields
### NLP Locked Balances Response
<table><thead><tr><th width="263">Field name</th><th>Description</th></tr></thead><tbody><tr><td>balance_locked</td><td>Total balance that is currently locked (SpotBalance object)</td></tr><tr><td>balance_unlocked</td><td>Total balance that is currently unlocked and available (SpotBalance object)</td></tr><tr><td>locked_balances</td><td>Array of individual locked balance entries with their unlock times</td></tr></tbody></table>
### Locked Balance Entry
<table><thead><tr><th width="263">Field name</th><th>Description</th></tr></thead><tbody><tr><td>balance</td><td>SpotBalance object containing the locked amount</td></tr><tr><td>unlocked_at</td><td>Unix epoch timestamp (in seconds) when this balance will unlock</td></tr></tbody></table>
### SpotBalance Object
<table><thead><tr><th width="263">Field name</th><th>Description</th></tr></thead><tbody><tr><td>product_id</td><td>The product ID (typically 0 for USDT0/quote asset)</td></tr><tr><td>balance</td><td>Balance details object</td></tr><tr><td>balance.amount</td><td>The balance amount in x18 format (string)</td></tr><tr><td>balance.last_cumulative_funding_x18</td><td>Last cumulative funding value in x18 format (string)</td></tr></tbody></table>
## Notes
* NLP positions have a 4-day lock period after minting before they can be burned (withdrawn)
* The `locked_balances` array shows individual lock entries, each with their own unlock timestamp
* `balance_locked` is the sum of all locked balances
* `balance_unlocked` represents balances that have passed their lock period and can be withdrawn
@@ -0,0 +1,89 @@
# NLP Pool Info
## Rate limits
* 120 requests/min or 20 requests every 10 seconds per IP address. (**weight = 20**)
{% hint style="info" %}
See more details in [API Rate limits](https://docs.nado.xyz/developer-resources/api/rate-limits)
{% endhint %}
## Request
{% tabs %}
{% tab title="Websocket" %}
**Connect**
<mark style="color:orange;">`WEBSOCKET [GATEWAY_WEBSOCKET_ENDPOINT]`</mark>
**Message**
```json
{
"type": "nlp_pool_info"
}
```
{% endtab %}
{% tab title="REST (GET)" %} <mark style="color:green;">**GET**</mark> `[GATEWAY_REST_ENDPOINT]/query?type=nlp_pool_info`
{% endtab %}
{% tab title="REST (POST)" %} <mark style="color:orange;">`POST [GATEWAY_REST_ENDPOINT]/query`</mark>
**Body**
```json
{
"type": "nlp_pool_info"
}
```
{% endtab %}
{% endtabs %}
## Request Parameters
This query does not require any parameters.
## Response
```json
{
"status": "success",
"data": {
"nlp_pools": [
{
"pool_id": 1,
"subaccount": "0x0000000000000000000000000000000000000000000000000000000000000002",
"owner": "0x1234567890123456789012345678901234567890",
"balance_weight_x18": "500000000000000000",
"subaccount_info": {
"subaccount": "0x0000000000000000000000000000000000000000000000000000000000000002",
"exists": true,
"health": {
"assets": "1000000000000000000000",
"liabilities": "500000000000000000000",
"initial_health": "250000000000000000000",
"maintenance_health": "100000000000000000000"
},
"spot_balances": [],
"perp_balances": []
},
"open_orders": []
}
]
},
"request_type": "query_nlp_pool_info"
}
```
## Response Fields
### NLP Pool Info
<table><thead><tr><th width="263">Field name</th><th>Description</th></tr></thead><tbody><tr><td>nlp_pools</td><td>Array of NLP pool objects</td></tr></tbody></table>
### NLP Pool Object
<table><thead><tr><th width="263">Field name</th><th>Description</th></tr></thead><tbody><tr><td>pool_id</td><td>Unique identifier for the pool</td></tr><tr><td>subaccount</td><td>The subaccount address associated with this pool (bytes32 hex string)</td></tr><tr><td>owner</td><td>The owner address of the pool (bytes20 hex string)</td></tr><tr><td>balance_weight_x18</td><td>Weight of this pool's balance in x18 format (string representation of u128)</td></tr><tr><td>subaccount_info</td><td>Complete subaccount information including health, balances, and positions</td></tr><tr><td>open_orders</td><td>Array of currently open orders for this pool</td></tr></tbody></table>
@@ -0,0 +1,66 @@
# Nonces
## Rate limits
* 1200 requests/min or 20 requests/sec per IP address. (**weight = 2**)
{% hint style="info" %}
See more details in [API Rate limits](https://docs.nado.xyz/developer-resources/api/rate-limits)
{% endhint %}
## Request
{% tabs %}
{% tab title="Websocket" %}
**Connect**
<mark style="color:orange;">`WEBSOCKET [GATEWAY_WEBSOCKET_ENDPOINT]`</mark>
**Message**
```json
{
"type": "nonces",
"address": "0x0000000000000000000000000000000000000000"
}
```
{% endtab %}
{% tab title="REST (GET)" %} <mark style="color:green;">**GGET**</mark> `[GATEWAY_REST_ENDPOINT]/query?type=nonces&address={address}`
{% endtab %}
{% tab title="REST (POST)" %} <mark style="color:orange;">`POST [GATEWAY_REST_ENDPOINT]/query`</mark>
**Body**
```json
{
"type": "nonces",
"address": "0x0000000000000000000000000000000000000000"
}
```
{% endtab %}
{% endtabs %}
## Request Parameters
<table><thead><tr><th width="134" align="center">Parameter</th><th width="86" align="center">Type</th><th width="104" align="center">Required</th><th>Description</th></tr></thead><tbody><tr><td align="center">address</td><td align="center">string</td><td align="center">Yes</td><td>A <mark style="color:red;"><code>bytes20</code></mark> sent as a hex string representing the wallet address.</td></tr></tbody></table>
## Response
```json
{
"status":"success",
"data":{
"tx_nonce": 0,
"order_nonce": 1753048133299863552
},
"request_type": "query_nonces",
}
```
{% hint style="info" %}
**Note**: when doing any execute that is not <mark style="color:red;">`place_orders`</mark>, i.e. <mark style="color:red;">`withdraw_collateral`</mark>, <mark style="color:red;">`liquidate_subaccount`</mark>, you want to use <mark style="color:red;">`tx_nonce`</mark> as the nonce. <mark style="color:red;">`tx_nonce`</mark> increments by one each time a successful execute goes through. <mark style="color:red;">`order_nonce`</mark> is a historical artifact for the frontend, and simply returns the current timestamp in milliseconds plus 100000 multiplied by 2\*\*20.
{% endhint %}
@@ -0,0 +1,77 @@
# Order
## Rate limits
* 2400 requests/min or 40 requests/sec per IP address. (**weight = 1**)
{% hint style="info" %}
See more details in [API Rate limits](https://docs.nado.xyz/developer-resources/api/rate-limits)
{% endhint %}
## Request
{% tabs %}
{% tab title="Websocket" %}
**Connect**
<mark style="color:orange;">`WEBSOCKET [GATEWAY_WEBSOCKET_ENDPOINT]`</mark>
**Message**
```json
{
"type": "order",
"product_id": 1,
"digest": "0x0000000000000000000000000000000000000000000000000000000000000000"
}
```
{% endtab %}
{% tab title="REST (GET)" %} <mark style="color:green;">**GET**</mark> `[GATEWAY_REST_ENDPOINT]/query?type=order&product_id={product_id}&digest={digest}`
{% endtab %}
{% tab title="REST (POST)" %} <mark style="color:orange;">`POST [GATEWAY_REST_ENDPOINT]/query`</mark>
**Body**
```json
{
"type": "order",
"product_id": 1,
"digest": "0x0000000000000000000000000000000000000000000000000000000000000000"
}
```
{% endtab %}
{% endtabs %}
## Request Parameters
<table><thead><tr><th width="140" align="center">Parameter</th><th width="97" align="center">Type</th><th width="104" align="center">Required</th><th>Description</th></tr></thead><tbody><tr><td align="center">product_id</td><td align="center">number</td><td align="center">Yes</td><td>Id of spot / perp product for which to retrieve order.</td></tr><tr><td align="center">digest</td><td align="center">string</td><td align="center">Yes</td><td>Order digest to retrieve.</td></tr></tbody></table>
## Response
```json
{
"status": "success",
"data": {
"product_id": 1,
"sender": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43000000000000000000000000",
"price_x18": "1000000000000000000",
"amount": "1000000000000000000",
"expiration": "2000000000",
"nonce": "1",
"unfilled_amount": "1000000000000000000",
"digest": "0x0000000000000000000000000000000000000000000000000000000000000000",
"placed_at": 1681951347,
"appendix": "1537",
"order_type": "ioc"
},
"request_type": "query_order",
}
```
{% hint style="info" %}
**Note**: that side of the order (buy/sell) is included in the sign of <mark style="color:red;">`amount`</mark> and <mark style="color:red;">`unfilled_amount`</mark> . They are positive if the order is a buy order, otherwise negative.
{% endhint %}
@@ -0,0 +1,162 @@
# Orders
## Rate limits
* 1200 requests/min or 20 requests/sec per IP address. (**weight = 2**) or 2 \* length of <mark style="color:red;">`product_ids`</mark> for [multi-product orders](#multiple-products) query.
{% hint style="info" %}
See more details in [API Rate limits](https://docs.nado.xyz/developer-resources/api/rate-limits)
{% endhint %}
## Single Product
### Request
{% tabs %}
{% tab title="Websocket" %}
**Connect**
<mark style="color:orange;">`WEBSOCKET [GATEWAY_WEBSOCKET_ENDPOINT]`</mark>
**Message**
```json
{
"type": "subaccount_orders",
"sender": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43000000000000000000000000",
"product_id": 1
}
```
{% endtab %}
{% tab title="REST (GET)" %} <mark style="color:green;">**GET**</mark> `[GATEWAY_REST_ENDPOINT]/query?type=subaccount_orders&sender={sender}&product_id={product_id}`
{% endtab %}
{% tab title="REST (POST)" %} <mark style="color:orange;">`POST [GATEWAY_REST_ENDPOINT]/query`</mark>
**Body**
```json
{
"type": "subaccount_orders",
"sender": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43000000000000000000000000",
"product_id": 1
}
```
{% endtab %}
{% endtabs %}
### Request Parameters
<table><thead><tr><th width="140" align="center">Parameter</th><th width="97" align="center">Type</th><th width="104" align="center">Required</th><th>Description</th></tr></thead><tbody><tr><td align="center">sender</td><td align="center">string</td><td align="center">Yes</td><td>A <mark style="color:red;"><code>bytes32</code></mark> sent as a hex string; includes the address and the subaccount identifier.</td></tr><tr><td align="center">product_id</td><td align="center">number</td><td align="center">Yes</td><td>Id of spot / perp product for which to retrieve subaccount orders.</td></tr></tbody></table>
### Response
```json
{
"status": "success",
"data": {
"sender": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43000000000000000000000000",
"product_id": 1,
"orders": [
{
"product_id": 1,
"sender": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43000000000000000000000000",
"price_x18": "1000000000000000000",
"amount": "1000000000000000000",
"expiration": "2000000000",
"nonce": "1",
"unfilled_amount": "1000000000000000000",
"digest": "0x0000000000000000000000000000000000000000000000000000000000000000",
"placed_at": 1682437739,
"appendix": "1537",
"order_type": "ioc"
}
]
},
"request_type": "query_subaccount_orders"
}
```
{% hint style="info" %}
**Note**: that side of the order (buy/sell) is included in the sign of <mark style="color:red;">`amount`</mark> and <mark style="color:red;">`unfilled_amount`</mark> . They are positive if the order is a buy order, otherwise negative.
{% endhint %}
## Multiple Products
### Request
{% tabs %}
{% tab title="Websocket" %}
**Connect**
<mark style="color:orange;">`WEBSOCKET [CORE_WEBSOCKET_ENDPOINT]`</mark>
**Message**
```json
{
"type": "orders",
"sender": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43000000000000000000000000",
"product_ids": [1, 2, 3]
}
```
{% endtab %}
{% tab title="REST (POST)" %} <mark style="color:orange;">`POST /query`</mark>
**Body**
```json
{
"type": "orders",
"sender": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43000000000000000000000000",
"product_ids": [1, 2, 3]
}
```
{% endtab %}
{% endtabs %}
### Request Parameters
<table><thead><tr><th width="140" align="center">Parameter</th><th width="109" align="center">Type</th><th width="104" align="center">Required</th><th>Description</th></tr></thead><tbody><tr><td align="center">sender</td><td align="center">string</td><td align="center">Yes</td><td>A <mark style="color:red;"><code>bytes32</code></mark> sent as a hex string; includes the address and the subaccount identifier.</td></tr><tr><td align="center">product_ids</td><td align="center">number[]</td><td align="center">Yes</td><td>List of spot / perp products for which to retrieve open orders.</td></tr></tbody></table>
### Response
```json
{
"status": "success",
"data": {
"sender": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43000000000000000000000000",
"product_orders": [
{
"product_id": 1,
"orders": [
{
"product_id": 1,
"sender": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43000000000000000000000000",
"price_x18": "1000000000000000000",
"amount": "1000000000000000000",
"expiration": "2000000000",
"nonce": "1",
"unfilled_amount": "1000000000000000000",
"digest": "0x0000000000000000000000000000000000000000000000000000000000000000",
"appendix": "1537",
"placed_at": 1682437739,
"order_type": "ioc"
}
]
},
{
"product_id": 2,
"orders": []
}
]
},
"request_type": "query_orders"
}
```
@@ -0,0 +1,60 @@
# Status
## Rate limits
* 2400 requests/min or 40 requests/sec per IP address. (**weight = 1**)
{% hint style="info" %}
See more details in [API Rate limits](https://docs.nado.xyz/developer-resources/api/rate-limits)
{% endhint %}
## Request
{% tabs %}
{% tab title="Websocket" %}
**Connect**
<mark style="color:orange;">`WEBSOCKET [GATEWAY_WEBSOCKET_ENDPOINT]`</mark>
**Message**
```json
{
"type": "status"
}
```
{% endtab %}
{% tab title="REST (GET)" %} <mark style="color:green;">**GET**</mark> `[GATEWAY_REST_ENDPOINT]/query?type=status`
{% endtab %}
{% tab title="REST (POST)" %} <mark style="color:orange;">`POST [GATEWAY_REST_ENDPOINT]/query`</mark>
**Body**
```json
{
"type": "status"
}
```
{% endtab %}
{% endtabs %}
## Response
```json
{
"status": "success",
"data": "active",
"request_type": "query_status",
}
```
{% hint style="info" %}
The offchain sequencer could be in any of the following statuses:
* <mark style="color:red;">`active`</mark>: accepting incoming executes.
* <mark style="color:red;">`failed`</mark>: sequencer is in a failed state.
{% endhint %}
@@ -0,0 +1,353 @@
# Subaccount Info
## Rate limits
The rate limit weight varies based on the request parameters:
* **Basic query** (no `txns`): **weight = 2**
* 1200 requests/min or 200 requests every 10 seconds per IP address
* **With simulation** (`txns` provided): **weight = 10**
* 240 requests/min or 40 requests every 10 seconds per IP address
* **With simulation + pre\_state** (`txns` and `pre_state="true"`): **weight = 15**
* 160 requests/min or \~26 requests every 10 seconds per IP address
{% hint style="info" %}
See more details in [API Rate limits](https://docs.nado.xyz/developer-resources/api/rate-limits)
{% endhint %}
## Request
{% tabs %}
{% tab title="Websocket" %}
**Connect**
<mark style="color:orange;">`WEBSOCKET [GATEWAY_WEBSOCKET_ENDPOINT]`</mark>
**Message**
```json
{
"type": "subaccount_info",
"subaccount": "0xeae27ae6412147ed6d5692fd91709dad6dbfc34264656661756c740000000000",
"txns": "[{\"apply_delta\":{\"product_id\":4,\"subaccount\":\"0xeae27ae6412147ed6d5692fd91709dad6dbfc34264656661756c740000000000\",\"amount_delta\":\"10790000000000000000\",\"v_quote_delta\":\"-35380410000000000000000\"}}]"
}
```
{% endtab %}
{% tab title="REST (GET)" %} <mark style="color:green;">**GET**</mark> `[GATEWAY_REST_ENDPOINT]/query?type=subaccount_info&subaccount={subaccount}&txns=[{"apply_delta":{"product_id":2,"subaccount":"0xeae27ae6412147ed6d5692fd91709dad6dbfc34264656661756c740000000000","amount_delta":"100000000000000000","v_quote_delta":"3033500000000000000000"}}]`
{% endtab %}
{% tab title="REST (POST)" %} <mark style="color:orange;">`POST [GATEWAY_REST_ENDPOINT]/query`</mark>
**Message**
```json
{
"type": "subaccount_info",
"subaccount": "0xeae27ae6412147ed6d5692fd91709dad6dbfc34264656661756c740000000000",
"txns": "[{\"apply_delta\":{\"product_id\":4,\"subaccount\":\"0xeae27ae6412147ed6d5692fd91709dad6dbfc34264656661756c740000000000\",\"amount_delta\":\"10790000000000000000\",\"v_quote_delta\":\"-35380410000000000000000\"}}]"
}
```
{% endtab %}
{% endtabs %}
## Request Parameters
<table><thead><tr><th width="140" align="center">Parameter</th><th width="100" align="center">Type</th><th width="104" align="center">Required</th><th>Description</th></tr></thead><tbody><tr><td align="center">subaccount</td><td align="center">string</td><td align="center">Yes</td><td>A <mark style="color:red;"><code>bytes32</code></mark> sent as a hex string; includes the address and the subaccount identifier. See <a href="../../executes#sender-field-structure">sender field structure</a> for details.</td></tr><tr><td align="center">txns</td><td align="center">string</td><td align="center">no</td><td>A list of transactions to get an estimated/simulated view. see more info below.</td></tr><tr><td align="center">pre_state</td><td align="center">string</td><td align="center">no</td><td>When <mark style="color:red;"><code>"true"</code></mark> and <mark style="color:red;"><code>txns</code></mark> are provided, returns the subaccount state before the transactions were applied in the <mark style="color:red;"><code>pre_state</code></mark> field. Defaults to <mark style="color:red;"><code>"false"</code></mark>.</td></tr></tbody></table>
### Supported txs for an estimated subaccount info
The following are the supported <mark style="color:red;">`txns`</mark> you can provide to get an estimated view of your subaccount.
{% hint style="info" %}
**Note**: these <mark style="color:red;">`txns`</mark> are only used to simulate what your subaccount would look like if they were executed.
{% endhint %}
#### ApplyDelta
Updates internal balances for the <mark style="color:red;">`product_id`</mark> and amount deltas provided.
```json
{
"apply_delta": {
"product_id": 2,
"subaccount": "0xeae27ae6412147ed6d5692fd91709dad6dbfc34264656661756c740000000000",
"amount_delta": "100000000000000000",
"v_quote_delta": "3033500000000000000000"
}
}
```
## Response
{% hint style="info" %}
**Note**:
* <mark style="color:red;">`healths`</mark>:
* <mark style="color:red;">`healths[0]`</mark>: info about your initial health, which is weighted by `long_weight_initial_x18` and `short_weight_initial_x18.`
* <mark style="color:red;">`healths[1]`</mark>: info about your maintenance health, which is weighted by `long_weight_maintenance_x18` and `short_weight_maintenance_x18.`
* <mark style="color:red;">`healths[2]`</mark>: info about your unweighted health.
* <mark style="color:red;">`health_contributions`</mark> is indexed by <mark style="color:red;">product\_id</mark> and represents the contribution of the corresponding product to the final health.
* <mark style="color:red;">`health_contributions[product_id][0]`</mark>`: contribution to healths[0]`
* <mark style="color:red;">`health_contributions[product_id][1]`</mark>`: contribution to healths[1]`
* <mark style="color:red;">`health_contributions[product_id][2]`</mark>`: contribution to healths[2]`
* <mark style="color:red;">`pre_state`</mark>: (Optional) When <mark style="color:red;">`pre_state="true"`</mark> is provided with <mark style="color:red;">`txns`</mark>, this field contains the subaccount state **before** the simulated transactions were applied. This allows you to compare the before/after states when simulating transactions.
* <mark style="color:red;">`pre_state.healths`</mark>: Same structure as the main `healths` field, but reflecting the state before transactions
* <mark style="color:red;">`pre_state.health_contributions`</mark>: Health contributions before transactions
* <mark style="color:red;">`pre_state.spot_balances`</mark>: Spot balances before transactions
* <mark style="color:red;">`pre_state.perp_balances`</mark>: Perpetual balances before transactions
{% endhint %}
```json
{
"status": "success",
"data": {
"subaccount": "0x8d7d64d6cf1d4f018dd101482ac71ad49e30c56064656661756c740000000000",
"exists": true,
"healths": [
{
"assets": "456895621098158389211471",
"liabilities": "76286259844766495292488",
"health": "380609361253391893918983"
},
{
"assets": "456895621098158389211471",
"liabilities": "72818702579095290924243",
"health": "384076918519063098287228"
},
{
"assets": "456895621098158389211471",
"liabilities": "69351145313424086671554",
"health": "387544475784734302539917"
}
],
"health_contributions": [
[
"456895621098158389211471",
"456895621098158389211471",
"456895621098158389211471"
],
[
"-76286259844766495292488",
"-72818702579095290924243",
"-69351145313424086671554"
],
[
"0",
"0",
"0"
]
],
"spot_count": 2,
"perp_count": 1,
"spot_balances": [
{
"product_id": 0,
"balance": {
"amount": "456895621098158389211471"
}
},
{
"product_id": 1,
"balance": {
"amount": "-600152323366021154"
}
}
],
"perp_balances": [
{
"product_id": 2,
"balance": {
"amount": "0",
"v_quote_balance": "0",
"last_cumulative_funding_x18": "-394223711772447555304"
}
}
],
"spot_products": [
{
"product_id": 0,
"oracle_price_x18": "1000000000000000000",
"risk": {
"long_weight_initial_x18": "1000000000000000000",
"short_weight_initial_x18": "1000000000000000000",
"long_weight_maintenance_x18": "1000000000000000000",
"short_weight_maintenance_x18": "1000000000000000000",
"price_x18": "1000000000000000000"
},
"config": {
"token": "0x5f65358d61a9a281ea3bb930d05889aca21e3f4f",
"interest_inflection_util_x18": "800000000000000000",
"interest_floor_x18": "10000000000000000",
"interest_small_cap_x18": "40000000000000000",
"interest_large_cap_x18": "1000000000000000000",
"withdraw_fee_x18": "1000000000000000000",
"min_deposit_rate_x18": "0"
},
"state": {
"cumulative_deposits_multiplier_x18": "1000000000025524653",
"cumulative_borrows_multiplier_x18": "1000347390837434279",
"total_deposits_normalized": "20001011744258817298755054194662",
"total_borrows_normalized": "1617724891363505323532211"
},
"book_info": {
"size_increment": "0",
"price_increment_x18": "0",
"min_size": "0",
"collected_fees": "0"
}
},
{
"product_id": 1,
"oracle_price_x18": "115555905748161505821744",
"risk": {
"long_weight_initial_x18": "900000000000000000",
"short_weight_initial_x18": "1100000000000000000",
"long_weight_maintenance_x18": "950000000000000000",
"short_weight_maintenance_x18": "1050000000000000000",
"price_x18": "115555905748161505821744"
},
"config": {
"token": "0xc57c1c64561a37ac9e8f9039cb6deab7539d99fc",
"interest_inflection_util_x18": "800000000000000000",
"interest_floor_x18": "10000000000000000",
"interest_small_cap_x18": "40000000000000000",
"interest_large_cap_x18": "1000000000000000000",
"withdraw_fee_x18": "40000000000000",
"min_deposit_rate_x18": "0"
},
"state": {
"cumulative_deposits_multiplier_x18": "1000000000000318713",
"cumulative_borrows_multiplier_x18": "1000347390679880473",
"total_deposits_normalized": "9000399823280682696107190850",
"total_borrows_normalized": "9580268570661550719"
},
"book_info": {
"size_increment": "1000000000000000",
"price_increment_x18": "1000000000000000000",
"min_size": "4000000000000000",
"collected_fees": "0"
}
}
],
"perp_products": [
{
"product_id": 2,
"oracle_price_x18": "115596528090565357611177",
"risk": {
"long_weight_initial_x18": "950000000000000000",
"short_weight_initial_x18": "1050000000000000000",
"long_weight_maintenance_x18": "970000000000000000",
"short_weight_maintenance_x18": "1030000000000000000",
"price_x18": "115596528090565357611177"
},
"state": {
"cumulative_funding_long_x18": "-394223711772447555304",
"cumulative_funding_short_x18": "-394223711772447555304",
"available_settle": "20092193239667417956947",
"open_interest": "113605000000000000000"
},
"book_info": {
"size_increment": "1000000000000000",
"price_increment_x18": "1000000000000000000",
"min_size": "4000000000000000",
"collected_fees": "0"
}
}
]
},
"request_type": "query_subaccount_info"
}
```
### Example with `pre_state`
When you want to simulate transactions and compare the before/after states, you can use the `pre_state` parameter:
#### Request
{% tabs %}
{% tab title="REST (GET)" %} <mark style="color:green;">**GET**</mark> `[GATEWAY_REST_ENDPOINT]/query?type=subaccount_info&subaccount={subaccount}&txns=[{"apply_delta":{"product_id":2,"subaccount":"0xeae27ae6412147ed6d5692fd91709dad6dbfc34264656661756c740000000000","amount_delta":"100000000000000000","v_quote_delta":"3033500000000000000000"}}]&pre_state="true"`
{% endtab %}
{% tab title="REST (POST)" %} <mark style="color:orange;">`POST [GATEWAY_REST_ENDPOINT]/query`</mark>
```json
{
"type": "subaccount_info",
"subaccount": "0xeae27ae6412147ed6d5692fd91709dad6dbfc34264656661756c740000000000",
"txns": "[{\"apply_delta\":{\"product_id\":2,\"subaccount\":\"0xeae27ae6412147ed6d5692fd91709dad6dbfc34264656661756c740000000000\",\"amount_delta\":\"100000000000000000\",\"v_quote_delta\":\"3033500000000000000000\"}}]",
"pre_state": "true"
}
```
{% endtab %}
{% endtabs %}
#### Response
The response will now include a `pre_state` field showing the state before the simulated transactions:
```json
{
"status": "success",
"data": {
"subaccount": "0x8d7d64d6cf1d4f018dd101482ac71ad49e30c56064656661756c740000000000",
"exists": true,
"healths": [
{
"assets": "460000000000000000000000",
"liabilities": "80000000000000000000000",
"health": "380000000000000000000000"
}
],
"health_contributions": [...],
"spot_balances": [...],
"perp_balances": [
{
"product_id": 2,
"balance": {
"amount": "100000000000000000",
"v_quote_balance": "3033500000000000000000",
"last_cumulative_funding_x18": "-394223711772447555304"
}
}
],
"spot_products": [...],
"perp_products": [...],
"pre_state": {
"healths": [
{
"assets": "456895621098158389211471",
"liabilities": "76286259844766495292488",
"health": "380609361253391893918983"
}
],
"health_contributions": [...],
"spot_balances": [...],
"perp_balances": [
{
"product_id": 2,
"balance": {
"amount": "0",
"v_quote_balance": "0",
"last_cumulative_funding_x18": "-394223711772447555304"
}
}
]
}
},
"request_type": "query_subaccount_info"
}
```
{% hint style="success" %}
**Use Case**: The `pre_state` feature is particularly useful for:
* **Position Simulation**: Preview how a potential trade would affect your health and balances
* **Risk Analysis**: Compare health metrics before and after simulated transactions
* **UI/UX**: Display "before → after" views to users when they're about to execute trades
* **Testing**: Validate transaction impacts without executing them on-chain
{% endhint %}
@@ -0,0 +1,103 @@
# Symbols
## Rate limits
* 1200 requests/min or 20 requests/sec per IP address. (**weight = 2**)
{% hint style="info" %}
See more details in [API Rate limits](https://docs.nado.xyz/developer-resources/api/rate-limits)
{% endhint %}
## Request
{% tabs %}
{% tab title="Websocket" %}
**Connect**
<mark style="color:orange;">`WEBSOCKET [GATEWAY_WEBSOCKET_ENDPOINT]`</mark>
**Message**
```json
{
"type": "symbols",
"product_ids": [1, 2]
}
```
{% endtab %}
{% tab title="REST (GET)" %} <mark style="color:green;">**GET**</mark> `[GATEWAY_REST_ENDPOINT]/query?type=symbols&product_type=spot`
{% endtab %}
{% tab title="REST (POST)" %} <mark style="color:orange;">`POST [GATEWAY_REST_ENDPOINT]/query`</mark>
**Message**
```json
{
"type": "symbols",
"product_ids": [1, 2, 3, 4],
"product_type": "spot"
}
```
{% endtab %}
{% endtabs %}
## Request Parameters
<table><thead><tr><th width="155" align="center">Parameter</th><th width="108" align="center">Type</th><th width="132.125" align="center">Required</th><th>Description</th></tr></thead><tbody><tr><td align="center">product_ids</td><td align="center">number[]</td><td align="center">No</td><td>An array of product ids. Only available for POST and WS requests.</td></tr><tr><td align="center">product_type</td><td align="center">string</td><td align="center">No</td><td>Type of products to return, must be:<br>"spot" | "perp".</td></tr></tbody></table>
## Response
{% hint style="info" %}
**Note**:
* All products have are quoted against USDT0, except for product 0.
{% endhint %}
```json
{
"status": "success",
"data": {
"symbols": {
"WBTC": {
"type": "spot",
"product_id": 1,
"symbol": "WBTC",
"price_increment_x18": "1000000000000000000",
"size_increment": "1000000000000000",
"min_size": "4000000000000000",
"maker_fee_rate_x18": "0",
"taker_fee_rate_x18": "200000000000000",
"long_weight_initial_x18": "900000000000000000",
"long_weight_maintenance_x18": "950000000000000000",
"max_open_interest_x18": null
},
"BTC-PERP": {
"type": "perp",
"product_id": 2,
"symbol": "BTC-PERP",
"price_increment_x18": "1000000000000000000",
"size_increment": "1000000000000000",
"min_size": "4000000000000000",
"maker_fee_rate_x18": "0",
"taker_fee_rate_x18": "200000000000000",
"long_weight_initial_x18": "950000000000000000",
"long_weight_maintenance_x18": "970000000000000000",
"max_open_interest_x18": null
}
}
},
"request_type": "query_symbols"
}
```
## Response fields
### Symbols
All numerical values are returned as strings and scaled by 1e18.
<table><thead><tr><th width="318">Field name</th><th>Description</th></tr></thead><tbody><tr><td>type</td><td>Product type, "spot" or "perp"</td></tr><tr><td>product_id</td><td>Product id</td></tr><tr><td>symbol</td><td>Product symbol</td></tr><tr><td>price_increment_x18</td><td>Price increment, a.k.a tick size</td></tr><tr><td>size_increment</td><td>Size increment, in base units</td></tr><tr><td>min_size</td><td>Minimum order size, in base units</td></tr><tr><td>maker_fee_rate_x18</td><td>Maker fee rate, given as decimal rate</td></tr><tr><td>taker_fee_rate_x18</td><td>Taker fee rate, given as decimal rate</td></tr><tr><td>long_weight_initial_x18</td><td>Long initial margin weight, given as decimal</td></tr><tr><td>long_weight_maintenance_x18</td><td>Long maintenance margin weight, given as decimal</td></tr><tr><td>max_open_interest_x18</td><td>Maximum open interest, null if no limit</td></tr></tbody></table>
@@ -0,0 +1,326 @@
# Signing
All executes are signed using [EIP712](https://eips.ethereum.org/EIPS/eip-712). Each execute request contains:
1. A piece of structured data that includes the sender address i.e: the <mark style="color:red;">`primaryType`</mark> that needs to be signed.
2. A signature of the hash of that structured data, signed by the sender.
## Domain
The following is the domain required as part of the EIP712 structure:
```json
{
name: 'Nado',
version: '0.0.1',
chainId: chainId,
verifyingContract: contractAddress
}
```
You can retrieve the corresponding chain id and verifying contract via the [contracts](https://docs.nado.xyz/developer-resources/api/gateway/queries/contracts) query.
{% hint style="warning" %}
**Note**: make sure to use the correct verifying contract for each execute:
* For place order: should use `address(producId)` i.e: the 20 bytes hex representation of the `productId` for the order. For example, the verify contract of product `18` is `0x0000000000000000000000000000000000000012` .
* For everything else: should use the endpoint address.
See more details in the [contracts](https://docs.nado.xyz/developer-resources/api/gateway/queries/contracts) query page.
{% endhint %}
```python
def gen_order_verifying_contract(product_id: int) -> str:
"""
Generates the order verifying contract address based on the product ID.
Args:
product_id (int): The product ID for which to generate the verifying contract address.
Returns:
str: The generated order verifying contract address in hexadecimal format.
"""
be_bytes = product_id.to_bytes(20, byteorder="big", signed=False)
return "0x" + be_bytes.hex()
```
## EIP712 Types
See below the EIP712 type for each execute:
{% hint style="info" %}
See more details in the **Signing** section of each execute's page.
{% endhint %}
### [Place Order](https://docs.nado.xyz/developer-resources/api/gateway/executes/place-order)
**Primary Type**: <mark style="color:red;">`Order`</mark>
Solidity struct that needs to be signed:
```solidity
struct Order {
bytes32 sender;
int128 priceX18;
int128 amount;
uint64 expiration;
uint64 nonce;
uint128 appendix;
}
```
**JSON representation:**
```typescript
{
Order: [
{ name: 'sender', type: 'bytes32' },
{ name: 'priceX18', type: 'int128' },
{ name: 'amount', type: 'int128' },
{ name: 'expiration', type: 'uint64' },
{ name: 'nonce', type: 'uint64' },
{ name: 'appendix', type: 'uint128' }
],
}
```
### [Cancel Orders](https://docs.nado.xyz/developer-resources/api/gateway/executes/cancel-orders)
**Primary Type:** <mark style="color:red;">`Cancellation`</mark>
Solidity struct that needs to be signed:
```solidity
struct Cancellation {
bytes32 sender;
uint32[] productIds;
bytes32[] digests;
uint64 nonce;
}
```
**JSON representation:**
```typescript
{
Cancellation: [
{ name: 'sender', type: 'bytes32' },
{ name: 'productIds', type: 'uint32[]' },
{ name: 'digests', type: 'bytes32[]' },
{ name: 'nonce', type: 'uint64' },
],
}
```
### [Cancel Product Orders](https://docs.nado.xyz/developer-resources/api/gateway/executes/cancel-product-orders)
**Primary Type**: <mark style="color:red;">`CancellationProducts`</mark>
Solidity struct that needs to be signed:
```solidity
struct CancellationProducts {
bytes32 sender;
uint32[] productIds;
uint64 nonce;
}
```
**JSON representation:**
```typescript
{
CancellationProducts: [
{ name: 'sender', type: 'bytes32' },
{ name: 'productIds', type: 'uint32[]' },
{ name: 'nonce', type: 'uint64' },
],
}
```
### [Withdraw Collateral](https://docs.nado.xyz/developer-resources/api/gateway/executes/withdraw-collateral)
**Primary Type:** <mark style="color:red;">`WithdrawCollateral`</mark>
Solidity struct that needs to be signed:
```solidity
struct WithdrawCollateral {
bytes32 sender;
uint32 productId;
uint128 amount;
uint64 nonce;
}
```
**JSON representation:**
```typescript
{
WithdrawCollateral: [
{ name: 'sender', type: 'bytes32' },
{ name: 'productId', type: 'uint32' },
{ name: 'amount', type: 'uint128' },
{ name: 'nonce', type: 'uint64' },
],
}
```
### [Liquidate Subaccount](https://docs.nado.xyz/developer-resources/api/gateway/executes/liquidate-subaccount)
**Primary Type:** <mark style="color:red;">`LiquidateSubaccount`</mark>
Solidity struct that needs to be signed:
```solidity
struct LiquidateSubaccount {
bytes32 sender;
bytes32 liquidatee;
uint32 productId;
bool isEncodedSpread;
int128 amount;
uint64 nonce;
}
```
**JSON representation:**
```typescript
{
LiquidateSubaccount: [
{ name: 'sender', type: 'bytes32' },
{ name: 'liquidatee', type: 'bytes32' },
{ name: 'productId', type: 'uint32' },
{ name: 'isEncodedSpread', type: 'bool' },
{ name: 'amount', type: 'int128' },
{ name: 'nonce', type: 'uint64' },
],
}
```
### [Mint NLP](https://docs.nado.xyz/developer-resources/api/gateway/executes/mint-nlp)
**Primary Type**: <mark style="color:red;">`MintNlp`</mark>
Solidity struct that needs to be signed:
```solidity
struct MintNlp {
bytes32 sender;
uint32 productId;
uint128 quoteAmount;
uint64 nonce;
}
```
**JSON representation:**
```typescript
{
MintLp: [
{ name: 'sender', type: 'bytes32' },
{ name: 'quoteAmount', type: 'uint128' },
{ name: 'nonce', type: 'uint64' },
],
}
```
## [Burn NLP](https://docs.nado.xyz/developer-resources/api/gateway/executes/burn-nlp)
**Primary Type:** <mark style="color:red;">`BurnNlp`</mark>
Solidity struct that needs to be signed:
```solidity
struct BurnLp {
bytes32 sender;
uint128 nlpAmount;
uint64 nonce;
}
```
**JSON representation:**
```typescript
{
BurnLp: [
{ name: 'sender', type: 'bytes32' },
{ name: 'nlpAmount', type: 'uint128' },
{ name: 'nonce', type: 'uint64' },
],
}
```
## [Link Signer](https://docs.nado.xyz/developer-resources/api/gateway/executes/link-signer)
**Primary Type**: <mark style="color:red;">`LinkSigner`</mark>
Solidity struct that needs to be signed:
```solidity
struct LinkSigner {
bytes32 sender;
bytes32 signer;
uint64 nonce;
}
```
**JSON representation:**
```typescript
{
LinkSigner: [
{ name: 'sender', type: 'bytes32' },
{ name: 'signer', type: 'bytes32' },
{ name: 'nonce', type: 'uint64' },
],
}
```
## [List Trigger Orders](https://docs.nado.xyz/developer-resources/api/trigger/queries/list-trigger-orders)
**Primary Type**: <mark style="color:red;">`ListTriggerOrders`</mark>
Solidity struct that needs to be signed:
```solidity
struct ListTriggerOrders {
bytes32 sender;
uint64 recvTime;
}
```
**JSON representation:**
```typescript
{
ListTriggerOrders: [
{ name: 'sender', type: 'bytes32' },
{ name: 'recvTime', type: 'uint64' },
],
}
```
## [Authenticate Subscription Streams](https://docs.nado.xyz/developer-resources/subscriptions#authentication)
**Primary Type**: <mark style="color:red;">`StreamAuthentication`</mark>
Struct that needs to be signed:
```solidity
struct StreamAuthentication {
bytes32 sender;
uint64 expiration;
}
```
**JSON representation:**
```typescript
{
StreamAuthentication: [
{ name: 'sender', type: 'bytes32' },
{ name: 'expiration', type: 'uint64' },
],
}
```
@@ -0,0 +1,376 @@
# Examples
The following are full examples of EIP12 typed data for each of Nado's executes. Each execute includes a <mark style="color:red;">`sender`</mark> field which is a solidity <mark style="color:red;">`bytes32`</mark> . There are two components to this field:
* an <mark style="color:red;">`address`</mark> that is a <mark style="color:red;">`bytes20`</mark>
* a subaccount identifier that is a <mark style="color:red;">`bytes12`</mark>
For example, if your address was <mark style="color:red;">`0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43`</mark>, and you wanted to use the default subaccount identifier (i.e: an empty identifier `""`) you can set <mark style="color:red;">`sender`</mark> to <mark style="color:red;">`0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43000000000000000000000000`</mark> , which sets all bytes of the subaccount identifier to <mark style="color:red;">`0`</mark>.
{% hint style="info" %}
**Note**: a <mark style="color:red;">`bytes32`</mark> representation of the sender must used when signing the request.
{% endhint %}
See below a sample util to convert a hex to a **bytes32**:
{% tabs %}
{% tab title="Python" %}
```python
def hex_to_bytes32(hex_string):
if hex_string.startswith("0x"):
hex_string = hex_string[2:]
data_bytes = bytes.fromhex(hex_string)
padded_data = data_bytes + b"\x00" * (32 - len(data_bytes))
return padded_data
sender = hex_to_bytes32('0x841fe4876763357975d60da128d8a54bb045d76a64656661756c740000000000')
```
{% endtab %}
{% tab title="Typescript" %}
```typescript
import { arrayify } from 'ethers/lib/utils';
export function hexToBytes32(subaccount: string) {
const subaccountBytes = arrayify(subaccount);
const bytes32 = new Uint8Array(32);
for (let i = 0; i < Math.min(subaccountBytes.length, 32); i++) {
bytes32[i] = subaccountBytes[i];
}
return bytes32;
}
const sender = hexToBytes32('0x841fe4876763357975d60da128d8a54bb045d76a64656661756c740000000000')
```
{% endtab %}
{% endtabs %}
## EIP712 Typed data examples
{% tabs %}
{% tab title="Place Order" %}
```python
{
'types': {
'EIP712Domain': [
{'name': 'name', 'type': 'string'},
{'name': 'version', 'type': 'string'},
{'name': 'chainId', 'type': 'uint256'},
{'name': 'verifyingContract', 'type': 'address'}
],
'Order': [
{'name': 'sender', 'type': 'bytes32'},
{'name': 'priceX18', 'type': 'int128'},
{'name': 'amount', 'type': 'int128'},
{'name': 'expiration', 'type': 'uint64'},
{'name': 'nonce', 'type': 'uint64'},
{'name': 'appendix', 'type': 'uint128'},
],
},
'primaryType': 'Order',
'domain': {
'name': 'Nado',
'version': '0.0.1',
'chainId': 763373,
'verifyingContract': '0x0000000000000000000000000000000000000001'
},
'message': {
'sender': hex_to_bytes32('0x841fe4876763357975d60da128d8a54bb045d76a64656661756c740000000000'),
'priceX18': 28898000000000000000000,
'amount': -10000000000000000,
'expiration': 4611687701117784255,
'appendix': 1537, # Version 1, POST_ONLY order
'nonce': 1764428860167815857,
},
}
```
{% endtab %}
{% tab title="Cancel Orders" %}
```python
{
'types': {
'EIP712Domain': [
{'name': 'name', 'type': 'string'},
{'name': 'version', 'type': 'string'},
{'name': 'chainId', 'type': 'uint256'},
{'name': 'verifyingContract', 'type': 'address'}
],
'Cancellation': [
{ 'name': 'sender', 'type': 'bytes32' },
{ 'name': 'productIds', 'type': 'uint32[]'},
{ 'name': 'digests', 'type': 'bytes32[]'},
{ 'name': 'nonce', 'type': 'uint64'},
],
},
'primaryType': 'Cancellation',
'domain': {
'name': 'Nado',
'version': '0.0.1',
'chainId': 763373,
'verifyingContract': '0xbf16e41fb4ac9922545bfc1500f67064dc2dcc3b'
},
'message': {
'sender': hex_to_bytes32('0x841fe4876763357975d60da128d8a54bb045d76a64656661756c740000000000'),
'productIds': [4],
'digests': [hex_to_bytes32('0x51ba8762bc5f77957a4e896dba34e17b553b872c618ffb83dba54878796f2821')],
'nonce': 1,
},
}
```
{% endtab %}
{% tab title="Cancel Product orders" %}
```python
{
'types': {
'EIP712Domain': [
{'name': 'name', 'type': 'string'},
{'name': 'version', 'type': 'string'},
{'name': 'chainId', 'type': 'uint256'},
{'name': 'verifyingContract', 'type': 'address'}
],
'CancellationProducts': [
{'name': 'sender', 'type': 'bytes32'},
{'name': 'productIds', 'type': 'uint32[]'},
{'name': 'nonce', 'type': 'uint64'},
],
},
'primaryType': 'CancellationProducts',
'domain': {
'name': 'Nado',
'version': '0.0.1',
'chainId': 763373,
'verifyingContract': '0xbf16e41fb4ac9922545bfc1500f67064dc2dcc3b'
},
'message': {
'sender': hex_to_bytes32('0x841fe4876763357975d60da128d8a54bb045d76a64656661756c740000000000'),
'productIds': [1, 2],
'nonce': 1,
},
}
```
{% endtab %}
{% tab title="Link Signer" %}
```python
{
'types': {
'EIP712Domain': [
{'name': 'name', 'type': 'string'},
{'name': 'version', 'type': 'string'},
{'name': 'chainId', 'type': 'uint256'},
{'name': 'verifyingContract', 'type': 'address'}
],
'LinkSigner': [
{'name': 'sender', 'type': 'bytes32'},
{'name': 'signer', 'type': 'bytes32'},
{'name': 'nonce', 'type': 'uint64'},
],
},
'primaryType': 'LinkSigner',
'domain': {
'name': 'Nado',
'version': '0.0.1',
'chainId': 763373,
'verifyingContract': '0xbf16e41fb4ac9922545bfc1500f67064dc2dcc3b'
},
'message': {
'sender': hex_to_bytes32('0x841fe4876763357975d60da128d8a54bb045d76a64656661756c740000000000'),
'signer': hex_to_bytes32('0x12a0b4888021576eb10a67616dd3dd3d9ce206b664656661756c740000000000'),
'nonce': 1,
},
}
```
{% endtab %}
{% endtabs %}
{% tabs %}
{% tab title="Withdraw Collateral" %}
```python
{
'types': {
'EIP712Domain': [
{'name': 'name', 'type': 'string'},
{'name': 'version', 'type': 'string'},
{'name': 'chainId', 'type': 'uint256'},
{'name': 'verifyingContract', 'type': 'address'}
],
'WithdrawCollateral': [
{'name': 'sender', 'type': 'bytes32'},
{'name': 'productId', 'type': 'uint32'},
{'name': 'amount', 'type': 'uint128'},
{'name': 'nonce', 'type': 'uint64'},
],
},
'primaryType': 'WithdrawCollateral',
'domain': {
'name': 'Nado',
'version': '0.0.1',
'chainId': 763373,
'verifyingContract': '0xbf16e41fb4ac9922545bfc1500f67064dc2dcc3b'
},
'message': {
'sender': hex_to_bytes32('0x841fe4876763357975d60da128d8a54bb045d76a64656661756c740000000000'),
'productId': 2,
'amount': 10000000000000000,
'nonce': 1
},
}
```
{% endtab %}
{% tab title="Liquidate Subaccount" %}
```python
{
'types': {
'EIP712Domain': [
{'name': 'name', 'type': 'string'},
{'name': 'version', 'type': 'string'},
{'name': 'chainId', 'type': 'uint256'},
{'name': 'verifyingContract', 'type': 'address'}
],
'LiquidateSubaccount': [
{'name': 'sender', 'type': 'bytes32'},
{'name': 'liquidatee', 'type': 'bytes32'},
{'name': 'productId', 'type': 'uint32'},
{'name': 'isEncodedSpread', 'type': 'bool'},
{'name': 'amount', 'type': 'int128'},
{'name': 'nonce', 'type': 'uint64'},
],
},
'primaryType': 'LiquidateSubaccount',
'domain': {
'name': 'Nado',
'version': '0.0.1',
'chainId': 763373,
'verifyingContract': '0xbf16e41fb4ac9922545bfc1500f67064dc2dcc3b'
},
'message': {
'sender': hex_to_bytes32('0x841fe4876763357975d60da128d8a54bb045d76a64656661756c740000000000'),
'liquidatee': hex_to_bytes32('0x12a0b4888021576eb10a67616dd3dd3d9ce206b664656661756c740000000000'),
'productId': 1,
'isEncodedSpread': false,
'amount': 10000000000000000,
'nonce': 1,
},
}
```
{% endtab %}
{% tab title="Mint NLP" %}
```python
{
'types': {
'EIP712Domain': [
{'name': 'name', 'type': 'string'},
{'name': 'version', 'type': 'string'},
{'name': 'chainId', 'type': 'uint256'},
{'name': 'verifyingContract', 'type': 'address'}
],
'MintLp': [
{'name': 'sender', 'type': 'bytes32' },
{'name': 'quoteAmount', 'type': 'uint128'},
{'name': 'nonce', 'type': 'uint64' },
],
},
'primaryType': 'MintNlp',
'domain': {
'name': 'Nado',
'version': '0.0.1',
'chainId': 763373,
'verifyingContract': '0xbf16e41fb4ac9922545bfc1500f67064dc2dcc3b'
},
'message': {
'sender': hex_to_bytes32('0x841fe4876763357975d60da128d8a54bb045d76a64656661756c740000000000'),
'quoteAmount': 20000000000000000000000,
'nonce': 1,
},
}
```
{% endtab %}
{% tab title="Burn NLP" %}
```python
{
'types': {
'EIP712Domain': [
{'name': 'name', 'type': 'string'},
{'name': 'version', 'type': 'string'},
{'name': 'chainId', 'type': 'uint256'},
{'name': 'verifyingContract', 'type': 'address'}
],
'BurnLp': [
{'name': 'sender', 'type': 'bytes32'},
{'name': 'nlpAmount', 'type': 'uint128'},
{'name': 'nonce', 'type': 'uint64'},
],
},
'primaryType': 'BurnNlp',
'domain': {
'name': 'Nado',
'version': '0.0.1',
'chainId': 763373,
'verifyingContract': '0xbf16e41fb4ac9922545bfc1500f67064dc2dcc3b'
},
'message': {
'sender': hex_to_bytes32('0x841fe4876763357975d60da128d8a54bb045d76a64656661756c740000000000'),
'nlpAmount': 1000000000000000000,
'nonce': 1,
},
}
```
{% endtab %}
{% tab title="List Trigger Orders" %}
```python
{
'types': {
'EIP712Domain': [
{'name': 'name', 'type': 'string'},
{'name': 'version', 'type': 'string'},
{'name': 'chainId', 'type': 'uint256'},
{'name': 'verifyingContract', 'type': 'address'}
],
'ListTriggerOrders': [
{'name': 'sender', 'type': 'bytes32' },
{'name': 'recvTime', 'type': 'uint64' }
],
},
'primaryType': 'WithdrawCollateral',
'domain': {
'name': 'Nado',
'version': '0.0.1',
'chainId': 763373,
'verifyingContract': '0xbf16e41fb4ac9922545bfc1500f67064dc2dcc3b'
},
'message': {
'sender': hex_to_bytes32('0x841fe4876763357975d60da128d8a54bb045d76a64656661756c740000000000'),
'recvTime': 1688939576000
},
}
```
{% endtab %}
{% endtabs %}
@@ -0,0 +1,49 @@
# Q\&A
### Q: **What is Nado's EIP712 domain?**
```json
{
name: 'Nado',
version: '0.0.1',
chainId: chainId,
verifyingContract: contractAddress
}
```
{% hint style="info" %}
See [signing](https://docs.nado.xyz/developer-resources/api/gateway/signing/..#domain) for more details.
{% endhint %}
### Q: How can i retrieve the verifying contracts to use?
* Via the [contracts](https://docs.nado.xyz/developer-resources/api/gateway/queries/contracts) query for all executes except place orders.
### Q: Which contract should I use for each execute?
* For place orders: must be computed as <mark style="color:red;">`address(productId)`</mark>. For example, the verify contract of product <mark style="color:red;">`18`</mark> is <mark style="color:red;">`0x0000000000000000000000000000000000000012`</mark>.
* For everything else: use the endpoint contract from the contracts query.
{% hint style="info" %}
See the [contracts](https://docs.nado.xyz/developer-resources/api/queries/contracts#response) query for more details.
{% endhint %}
### Q: I am running into signature errors, how to fix?
Signature errors can arise for several reasons:
* **An invalid struct**: confirm you are signing the correct struct. See the [Signing](https://docs.nado.xyz/developer-resources/api/gateway/signing) page to verify the struct of each execute request.
* **An invalid chain id**: confirm you have the correct chain id for the network you are on.
* **An invalid verifying contract**: confirm you have the correct verifying contract address for the network and execute you are signing. i.e: confirm you are using the correct orderbook address for place orders and endpoint address for everything else.
### Q: Is any other signing standard supported?
No, only [EIP712](https://eips.ethereum.org/EIPS/eip-712).
### Q: Are there any examples you can provide?
See [examples](https://docs.nado.xyz/developer-resources/api/gateway/signing/examples).
### Q: What is the PrimaryType of execute X?
All primary types are listed in our [signing](https://docs.nado.xyz/developer-resources/api/gateway/signing) page.