Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
294 changes: 294 additions & 0 deletions artifacts/apidocs/market_data_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1258,6 +1258,300 @@ LITE ENDPOINT: lite/v1/currency
```
</section>
<hr class="solid">
### Get Margin Rules
```
FULL ENDPOINT: full/v1/margin_rules
LITE ENDPOINT: lite/v1/margin_rules
```

=== "Request"
<section markdown="1" style="float: left; width: 70%; padding-right: 10px;">
-8<- "docs/schemas/api_get_margin_rules_request.md"
</section>
<section markdown="1" style="float: right; width: 30%;">
!!! question "Query"
**Full Request**
``` { .json .copy }
{
"instrument": "BTC_USDT_Perp"
}
```
**Lite Request**
``` { .json .copy }
{
"i": "BTC_USDT_Perp"
}
```
</section>
=== "Response"
<section markdown="1" style="float: left; width: 70%; padding-right: 10px;">
-8<- "docs/schemas/api_get_margin_rules_response.md"
</section>
<section markdown="1" style="float: right; width: 30%;">
!!! success
**Full Response**
``` { .json .copy }
{
"instrument": "BTC_USDT_Perp",
"max_position_size": "100.0",
"risk_brackets": [{
"tier": 1,
"notional_floor": "0",
"notional_cap": "600000",
"maintenance_margin_rate": "0.01",
"initial_margin_rate": "0.02",
"max_leverage": 50,
"cumulative_maintenance_amount": "0"
}]
}
```
**Lite Response**
``` { .json .copy }
{
"i": "BTC_USDT_Perp",
"mp": "100.0",
"rb": [{
"t": 1,
"nf": "0",
"nc": "600000",
"mm": "0.01",
"im": "0.02",
"ml": 50,
"cm": "0"
}]
}
```
</section>
=== "Errors"
<section markdown="1" style="float: left; width: 70%; padding-right: 10px;">
!!! info "Error Codes"
|Code|HttpStatus| Description |
|-|-|-|
|1002|500|Internal Server Error|
|1003|400|Request could not be processed due to malformed syntax|
|3000|400|Instrument is invalid|
|1004|404|Data Not Found|
|1006|429|You have surpassed the allocated rate limit for your tier|
</section>
<section markdown="1" style="float: right; width: 30%;">
!!! failure
**Full Error Response**
``` { .json .copy }
{
"request_id":1,
"code":1002,
"message":"Internal Server Error",
"status":500
}
```
**Lite Error Response**
``` { .json .copy }
{
"ri":1,
"c":1002,
"m":"Internal Server Error",
"s":500
}
```
</section>
=== "Try it out"
=== "DEV"
<section markdown="1" style="float: left; width: 50%; padding-right: 10px;">
!!! example "REST Full"
``` { .bash .copy }
curl --location 'https://market-data.dev.gravitymarkets.io/full/v1/margin_rules' \
--data '{
"instrument": "BTC_USDT_Perp"
}
'
```
!!! example "JSONRPC Full"
``` { .bash .copy }
wscat -c "wss://market-data.dev.gravitymarkets.io/ws/full" \
-x '
{
"jsonrpc": "2.0",
"method": "v1/margin_rules",
"params": {
"instrument": "BTC_USDT_Perp"
},
"id": 123
}
' -w 360
```
</section>
<section markdown="1" style="float: right; width: 50%;">
!!! example "REST Lite"
``` { .bash .copy }
curl --location 'https://market-data.dev.gravitymarkets.io/lite/v1/margin_rules' \
--data '{
"i": "BTC_USDT_Perp"
}
'
```
!!! example "JSONRPC Lite"
``` { .bash .copy }
wscat -c "wss://market-data.dev.gravitymarkets.io/ws/lite" \
-x '
{
"j": "2.0",
"m": "v1/margin_rules",
"p": {
"i": "BTC_USDT_Perp"
},
"i": 123
}
' -w 360
```
</section>
=== "STAGING"
<section markdown="1" style="float: left; width: 50%; padding-right: 10px;">
!!! example "REST Full"
``` { .bash .copy }
curl --location 'https://market-data.staging.gravitymarkets.io/full/v1/margin_rules' \
--data '{
"instrument": "BTC_USDT_Perp"
}
'
```
!!! example "JSONRPC Full"
``` { .bash .copy }
wscat -c "wss://market-data.staging.gravitymarkets.io/ws/full" \
-x '
{
"jsonrpc": "2.0",
"method": "v1/margin_rules",
"params": {
"instrument": "BTC_USDT_Perp"
},
"id": 123
}
' -w 360
```
</section>
<section markdown="1" style="float: right; width: 50%;">
!!! example "REST Lite"
``` { .bash .copy }
curl --location 'https://market-data.staging.gravitymarkets.io/lite/v1/margin_rules' \
--data '{
"i": "BTC_USDT_Perp"
}
'
```
!!! example "JSONRPC Lite"
``` { .bash .copy }
wscat -c "wss://market-data.staging.gravitymarkets.io/ws/lite" \
-x '
{
"j": "2.0",
"m": "v1/margin_rules",
"p": {
"i": "BTC_USDT_Perp"
},
"i": 123
}
' -w 360
```
</section>
=== "TESTNET"
<section markdown="1" style="float: left; width: 50%; padding-right: 10px;">
!!! example "REST Full"
``` { .bash .copy }
curl --location 'https://market-data.testnet.grvt.io/full/v1/margin_rules' \
--data '{
"instrument": "BTC_USDT_Perp"
}
'
```
!!! example "JSONRPC Full"
``` { .bash .copy }
wscat -c "wss://market-data.testnet.grvt.io/ws/full" \
-x '
{
"jsonrpc": "2.0",
"method": "v1/margin_rules",
"params": {
"instrument": "BTC_USDT_Perp"
},
"id": 123
}
' -w 360
```
</section>
<section markdown="1" style="float: right; width: 50%;">
!!! example "REST Lite"
``` { .bash .copy }
curl --location 'https://market-data.testnet.grvt.io/lite/v1/margin_rules' \
--data '{
"i": "BTC_USDT_Perp"
}
'
```
!!! example "JSONRPC Lite"
``` { .bash .copy }
wscat -c "wss://market-data.testnet.grvt.io/ws/lite" \
-x '
{
"j": "2.0",
"m": "v1/margin_rules",
"p": {
"i": "BTC_USDT_Perp"
},
"i": 123
}
' -w 360
```
</section>
=== "PROD"
<section markdown="1" style="float: left; width: 50%; padding-right: 10px;">
!!! example "REST Full"
``` { .bash .copy }
curl --location 'https://market-data.grvt.io/full/v1/margin_rules' \
--data '{
"instrument": "BTC_USDT_Perp"
}
'
```
!!! example "JSONRPC Full"
``` { .bash .copy }
wscat -c "wss://market-data.grvt.io/ws/full" \
-x '
{
"jsonrpc": "2.0",
"method": "v1/margin_rules",
"params": {
"instrument": "BTC_USDT_Perp"
},
"id": 123
}
' -w 360
```
</section>
<section markdown="1" style="float: right; width: 50%;">
!!! example "REST Lite"
``` { .bash .copy }
curl --location 'https://market-data.grvt.io/lite/v1/margin_rules' \
--data '{
"i": "BTC_USDT_Perp"
}
'
```
!!! example "JSONRPC Lite"
``` { .bash .copy }
wscat -c "wss://market-data.grvt.io/ws/lite" \
-x '
{
"j": "2.0",
"m": "v1/margin_rules",
"p": {
"i": "BTC_USDT_Perp"
},
"i": 123
}
' -w 360
```
</section>
<hr class="solid">
## Ticker
### Mini Ticker
```
Expand Down
5 changes: 4 additions & 1 deletion artifacts/apidocs/schemas/aggregated_account_summary.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
|total_equity<br>`te` |string|True|Total equity of the main (+ sub) account, denominated in USD|
|spot_balances<br>`sb` |[SpotBalance]|True|The list of spot assets owned by this main (+ sub) account, and their balances|
|vault_investments<br>`vi` |[VaultInvestment]|True|The list of vault investments held by this main account|
|total_sub_account_balance<br>`ts` |string|True|Total balance of the sub accounts, denominated in USD|
|total_sub_account_balance<br>`ts` |string|True|Deprecated: Use totalSubAccountEquity instead|
|total_sub_account_equity<br>`ts1` |string|True|Total equity of the sub accounts, denominated in USD|
|total_vault_investments_balance<br>`tv` |string|True|Total amount of the vault investments, denominated in USD|
|total_sub_account_available_balance<br>`ts2` |string|True|Total available balance of the main account, denominated in USD|
??? info "[SpotBalance](/../../schemas/spot_balance)"
|Name<br>`Lite`|Type|Required<br>`Default`| Description |
|-|-|-|-|
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
!!! info "[ApiAddIsolatedPositionMarginRequest](/../../schemas/api_add_isolated_position_margin_request)"
The request to add margin to a isolated position<br>

|Name<br>`Lite`|Type|Required<br>`Default`| Description |
|-|-|-|-|
|sub_account_id<br>`sa` |string|True|The sub account ID to add isolated margin in or remove margin from|
|instrument<br>`i` |string|True|The instrument to add margin into, or remove margin from|
|amount<br>`a` |string|True|The amount of margin to add to the position, positive to add, negative to remove, expressed in quote asset decimal units|
|signature<br>`s` |Signature|True|The signature of this operation|
??? info "[Signature](/../../schemas/signature)"
|Name<br>`Lite`|Type|Required<br>`Default`| Description |
|-|-|-|-|
|signer<br>`s` |string|True|The address (public key) of the wallet signing the payload|
|r<br>`r` |string|True|Signature R|
|s<br>`s1` |string|True|Signature S|
|v<br>`v` |integer|True|Signature V|
|expiration<br>`e` |string|True|Timestamp after which this signature expires, expressed in unix nanoseconds. Must be capped at 30 days|
|nonce<br>`n` |integer|True|Users can randomly generate this value, used as a signature deconflicting key.<br>ie. You can send the same exact instruction twice with different nonces.<br>When the same nonce is used, the same payload will generate the same signature.<br>Our system will consider the payload a duplicate, and ignore it.|
|chain_id<br>`ci` |string|True|Chain ID used in EIP-712 domain. Zero value fallbacks to GRVT Chain ID.|
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
!!! info "[ApiAddIsolatedPositionMarginResponse](/../../schemas/api_add_isolated_position_margin_response)"
The response to add margin to a isolated position<br>

|Name<br>`Lite`|Type|Required<br>`Default`| Description |
|-|-|-|-|
|success<br>`s` |boolean|True|Whether the margin mode and leverage was set successfully|
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
|total_equity<br>`te` |string|True|Total equity of the main (+ sub) account, denominated in USD|
|spot_balances<br>`sb` |[SpotBalance]|True|The list of spot assets owned by this main (+ sub) account, and their balances|
|vault_investments<br>`vi` |[VaultInvestment]|True|The list of vault investments held by this main account|
|total_sub_account_balance<br>`ts` |string|True|Total balance of the sub accounts, denominated in USD|
|total_sub_account_balance<br>`ts` |string|True|Deprecated: Use totalSubAccountEquity instead|
|total_sub_account_equity<br>`ts1` |string|True|Total equity of the sub accounts, denominated in USD|
|total_vault_investments_balance<br>`tv` |string|True|Total amount of the vault investments, denominated in USD|
|total_sub_account_available_balance<br>`ts2` |string|True|Total available balance of the main account, denominated in USD|
??? info "[SpotBalance](/../../schemas/spot_balance)"
|Name<br>`Lite`|Type|Required<br>`Default`| Description |
|-|-|-|-|
Expand Down
6 changes: 6 additions & 0 deletions artifacts/apidocs/schemas/api_get_margin_rules_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
!!! info "[ApiGetMarginRulesRequest](/../../schemas/api_get_margin_rules_request)"
API request payload to get margin rules for a particular instrument<br>

|Name<br>`Lite`|Type|Required<br>`Default`| Description |
|-|-|-|-|
|instrument<br>`i` |string|True|The instrument to query margin rules for|
18 changes: 18 additions & 0 deletions artifacts/apidocs/schemas/api_get_margin_rules_response.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
!!! info "[ApiGetMarginRulesResponse](/../../schemas/api_get_margin_rules_response)"
API response payload for margin rules of a particular instrument<br>

|Name<br>`Lite`|Type|Required<br>`Default`| Description |
|-|-|-|-|
|instrument<br>`i` |string|True|The instrument name|
|max_position_size<br>`mp` |string|True|The maximum position size, expressed in base asset decimal units|
|risk_brackets<br>`rb` |[RiskBracket]|True|List of risk brackets defining margin requirements at different notional tiers|
??? info "[RiskBracket](/../../schemas/risk_bracket)"
|Name<br>`Lite`|Type|Required<br>`Default`| Description |
|-|-|-|-|
|tier<br>`t` |integer|True|1-indexed tier number|
|notional_floor<br>`nf` |string|True|Lower bound of notional value (inclusive) in quote currency|
|notional_cap<br>`nc` |string|True|Upper bound of notional value (exclusive) in quote currency, empty for last tier|
|maintenance_margin_rate<br>`mm` |string|True|Maintenance margin rate as a decimal (e.g., '0.01' for 1%)|
|initial_margin_rate<br>`im` |string|True|Initial margin rate as a decimal (e.g., '0.02' for 2%)|
|max_leverage<br>`ml` |integer|True|Maximum leverage allowed at this tier (floor of 1 / initial_margin_rate)|
|cumulative_maintenance_amount<br>`cm` |string|True|Cumulative maintenance margin amount in quote currency|
Loading