Skip to content

Commit a1273be

Browse files
authored
feat: add new rust methods from V9 update, fix linter (#420)
* feat: add new rust methods from V9 update * fix: linter errors for mdx * chore: update pnpm lock
1 parent 5c99d54 commit a1273be

File tree

222 files changed

+735
-621
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

222 files changed

+735
-621
lines changed

.lintignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Files to ignore from remark linting
2+
# One pattern per line
3+
4+
# Ignore component files (TSX not MDX)
5+
docs/components/*.tsx
6+
7+
# Ignore files that have formatting issues
8+
resources.mdx
9+
docs/pages/nodes/full-node-streaming/example.mdx
10+
docs/pages/node-client/public/query_transaction.mdx
11+
docs/pages/node-client/public/query_transaction_result.mdx
12+
docs/pages/nodes/full-node-streaming/index.mdx
13+
docs/pages/interaction/endpoints.mdx
14+
docs/pages/interaction/data/market.mdx
15+
docs/pages/interaction/client/quick-start-ts.mdx
16+
docs/pages/interaction/client/quick-start-py.mdx
17+
docs/pages/interaction/client/quick-start-rs.mdx
18+
19+
# You can add more patterns here
20+
# Example patterns:
21+
# test-*.mdx
22+
# **/draft/*.mdx
23+
# docs/pages/temp/*.mdx

docs/components/Details.tsx

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import React, { useState } from 'react';
2+
3+
interface DetailsProps {
4+
title?: string;
5+
open?: boolean;
6+
children: React.ReactNode;
7+
}
8+
9+
/**
10+
* Details component - A collapsible section with a title
11+
*
12+
* Usage in MDX:
13+
* <Details title="Unification Plan">
14+
* - Content goes here
15+
* - More content
16+
* </Details>
17+
*
18+
* Or with default open state:
19+
* <Details title="Example" open>
20+
* Content that's visible by default
21+
* </Details>
22+
*/
23+
export function Details({ title, open = false, children }: DetailsProps) {
24+
const [isOpen, setIsOpen] = useState(open);
25+
26+
return (
27+
<details className="details-container" open={isOpen}>
28+
{title && (
29+
<summary
30+
className="details-summary"
31+
onClick={(e) => {
32+
e.preventDefault();
33+
setIsOpen(!isOpen);
34+
}}
35+
>
36+
{title}
37+
</summary>
38+
)}
39+
<div className="details-content">
40+
{children}
41+
</div>
42+
</details>
43+
);
44+
}
45+
46+
// Alternative syntax-friendly version without state management
47+
export function SimpleDetails({ title, children }: { title?: string; children: React.ReactNode }) {
48+
return (
49+
<details className="details-container">
50+
{title && <summary className="details-summary">{title}</summary>}
51+
<div className="details-content">
52+
{children}
53+
</div>
54+
</details>
55+
);
56+
}
57+
58+
// Export as default for easier importing in MDX
59+
export default Details;

docs/pages/concepts/architecture/oegs.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,4 @@ DOS does not (i) provide, operate, or make available the Service, (ii) exercise
8787
Without limiting the generality of the foregoing, under no circumstances shall DOS be held liable or responsible to any person or entity for any claim, demand, cause of action, damages, losses, liabilities, costs, or expenses of any kind, whether direct, indirect, incidental, punitive, special, consequential, exemplary, or otherwise, arising out of or in connection with: (a) access to, reliance upon, use of, or inability to use the Service; (b) any information or content made available through the Service; or (c) any activities, transactions, or conduct undertaken via the Service.
8888

8989
Access to and use of the Service is undertaken solely at the risk of the user and is subject exclusively to the terms, conditions, policies, and practices established and maintained by Imperator, all of which are independent of, and not reviewed, approved, or enforced by, DOS.
90-
:::
90+
:::

docs/pages/concepts/onboarding-faqs/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,4 +356,4 @@
356356

357357
- Liquidity provider rewards in v4 are not controlled by dYdX. dYdX recommends that liquidity provider rewards should cease to exist in v4. Makers could be rewarded with a maker rebate ranging from 0.5bps to 1.1bps, based on their nominal volume and volume share. The full proposed fee schedule can be found [here](/concepts/trading/rewards).
358358

359-
</details>
359+
</details>

docs/pages/concepts/trading/governance.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,4 +155,4 @@ The Community Treasury is an account controlled by governance and can be funded
155155

156156
## CosmosSDK Default Modules
157157

158-
For more information on default modules, head to the [Cosmos SDK official documentation](https://docs.cosmos.network/v0.47/modules). dYdX Chain inherits the same governance properties of any standard CosmosSDK modules that are present on dYdX Chain,
158+
For more information on default modules, head to the [Cosmos SDK official documentation](https://docs.cosmos.network/v0.47/modules). dYdX Chain inherits the same governance properties of any standard CosmosSDK modules that are present on dYdX Chain.

docs/pages/concepts/trading/isolated-markets.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,4 @@ An example of how each type of market looks when queried using the `/dydxprotoco
6464
"open_interest": "0"
6565
}
6666
}
67-
```
67+
```

docs/pages/concepts/trading/limits/equity-tier-limits.mdx

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,18 @@ Here is an example response:
3939

4040
Read as:
4141

42-
| Net Collateral | Long-term / Conditional orders |
43-
| ------------------------- | ------------------------------- |
44-
| < $20 | 0 |
45-
| >= $20 and < $100 | 10 |
46-
| >= $100 and < $1,000 | 20 |
47-
| >= $1,000 and < $10,000 | 40 |
48-
| >= $10,000 and < $100,000 | 100 |
49-
| >= $100,000 | 200 |
42+
| Net Collateral | Long-term / Conditional orders |
43+
| ------------------------- | ------------------------------ |
44+
| < $20 | 0 |
45+
| >= $20 and < $100 | 10 |
46+
| >= $100 and < $1,000 | 20 |
47+
| >= $1,000 and < $10,000 | 40 |
48+
| >= $10,000 and < $100,000 | 100 |
49+
| >= $100,000 | 200 |
5050

5151
For example up to 20 open stateful orders across all markets for a subaccount with a net collateral of $2,000.
5252

5353
Note:
54+
5455
- Short term orders, including limit `Immediate-or-Cancel`, `Fill-or-Kill`, and market orders on the frontend do not have this limitation.
55-
- Only the `stateful_order_equity_tiers` field is in effect -- short term order equity limits under the `short_term_order_equity_tiers` key are no longer in effect.
56+
- Only the `stateful_order_equity_tiers` field is in effect -- short term order equity limits under the `short_term_order_equity_tiers` key are no longer in effect.

docs/pages/concepts/trading/limits/rate-limits.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,4 @@ V4_CANDLES_CHANNEL_LIMIT: 32
6565
V4_MARKETS_CHANNEL_LIMIT: 32
6666
V4_ORDERBOOK_CHANNEL_LIMIT: 32
6767
V4_TRADES_CHANNEL_LIMIT: 32
68-
```
68+
```

docs/pages/concepts/trading/limits/withdrawal-limits.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ These rate limit parameters can be updated by governance.
1414

1515
All subaccount transfers and withdrawals will be gated for 50 blocks if a negative collateralized subaccount is seen in state and/or can't be liquidated or deleveraged
1616

17-
All subaccount transfers and withdrawals will also be gated for 50 blocks if a 5+ minute chain outage occurs.
17+
All subaccount transfers and withdrawals will also be gated for 50 blocks if a 5+ minute chain outage occurs.

docs/pages/concepts/trading/liquidations.mdx

Lines changed: 56 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -3,63 +3,70 @@
33
As part of the default settings of the v4 open source software (”dYdX Chain”), accounts whose total value falls below their maintenance margin requirement may have their positions automatically closed by the liquidation engine. Positions are closed via protocol-generated liquidation matches where a protocol-generated liquidation order uses a calculated “Fillable Price” as the limit price to match against liquidity resting on the order book.
44
Profits or losses from liquidations are taken on by the insurance fund.
55
A liquidated subaccount may have its position partially or fully closed. v4 open source software includes a liquidations configuration which — as determined by the applicable Governance Community — will determine how much of the position is liquidated.
6-
6+
77
## Liquidation Penalty
88

99
As part of the default settings of the v4 open source software, when an account is liquidated, up to the entire remaining value of the account may be taken as penalty and transferred to an insurance fund.
10-
10+
1111
The liquidation engine will attempt to leave funds in accounts of positive value where possible after they have paid the Maximum Liquidation Penalty of 1.5%. The 1.5% fee contemplated in the default v4 software will be subject to adjustments by the applicable Governance Community.
12-
13-
12+
1413
## Isolated Liquidation Price
1514

1615
This is the price at which a specific position reaches the point of liquidation.
17-
1. __Formula Explanation:__
18-
- The liquidation price `p'` is calculated using:
19-
```
20-
p' = (e - s * p) / (|s| * MMF - s)
21-
```
22-
- Here:
23-
- `e` is the current equity in the account.
24-
- `s` is the size of the position.
25-
- `p` is the original price of the position.
26-
- `MMF` is the maintenance margin fraction, a percentage that indicates the minimum equity required to keep the position open.
27-
28-
2. __Example:__
29-
- Suppose a trader deposits $1,000 (`e = 1000`).
30-
- The trader shorts 3 ETH contracts (`s = -3`) at $3,000 per contract, with a maintenance margin fraction of 5% (`MMF = 0.05`).
31-
- The formula becomes: `p' = (1000 - (-3 * 3000)) / (3 * 0.05 - (-3))`
32-
- This simplifies to: `p' = (1000 + 9000) / (0.15 + 3) = 10000 / 3.15 ≈ 3174.60`
33-
- This means if the price of ETH rises to $3,174.60, the position will reach the liquidation threshold.
34-
- At this price, the trader's remaining equity would be 5% of the notional value of the position or $476.2 based on the calculation `(3 * 3174.6 * 0.05 ≈ 476.2)`.
35-
16+
17+
1. **Formula Explanation:**
18+
19+
- The liquidation price `p'` is calculated using:
20+
21+
```
22+
p' = (e - s * p) / (|s| * MMF - s)
23+
```
24+
25+
- Here:
26+
- `e` is the current equity in the account.
27+
- `s` is the size of the position.
28+
- `p` is the original price of the position.
29+
- `MMF` is the maintenance margin fraction, a percentage that indicates the minimum equity required to keep the position open.
30+
31+
2. **Example:**
32+
33+
- Suppose a trader deposits $1,000 (`e = 1000`).
34+
- The trader shorts 3 ETH contracts (`s = -3`) at $3,000 per contract, with a maintenance margin fraction of 5% (`MMF = 0.05`).
35+
- The formula becomes: `p' = (1000 - (-3 * 3000)) / (3 * 0.05 - (-3))`
36+
- This simplifies to: `p' = (1000 + 9000) / (0.15 + 3) = 10000 / 3.15 ≈ 3174.60`
37+
- This means if the price of ETH rises to $3,174.60, the position will reach the liquidation threshold.
38+
- At this price, the trader's remaining equity would be 5% of the notional value of the position or $476.2 based on the calculation `(3 * 3174.6 * 0.05 ≈ 476.2)`.
39+
3640
## Cross Liquidation Price
3741

3842
For cross-margining (multiple positions sharing the same margin), the calculation is adjusted to account for the margin used by other positions.
3943

40-
1. __Key Terms:__
41-
- __Total Maintenance Margin Requirement (`MMR_t`):__ Calculate the maintenance margin needed for all positions at current prices: `MMR_t = |s| · p · MMF`
42-
- __Other Positions' Margin Requirement (`MMR_o`)__: Subtract the margin requirement of the position in question from MMR_t: `MMR_o = MMR_t - |s| * p * MMF`
43-
- __New Margin Requirement at Price `p'`__: Add `MMR_o` to the margin requirement of the position at the new price: `MMR_o + |s| * p' * MMF`
44-
- __Liquidation Price Formula__: Substitute into the equation to find the liquidation price for the position: `p' = (e - s * p - MMR_o) / (|s| * MMF - s)`
45-
46-
2. __Example:__
47-
- Suppose a trader deposits $1,000 (`e = 1000`).
48-
- The trader shorts 1.5 ETH (`s = -1.5`) at $3,000 and buys 1,000 STRK contracts at $1.75 (`MMF = 10%` for STRK).
49-
- __Calculate Other Positions' Margin Requirement__: `MMR_o = 1000 * 1.75 * 0.10 = 175`
50-
- Compute the Liquidation Price for ETH: `p' = (1000 - (-1.5 * 3000) - 175) / (1.5 * 0.05 + 1.5)`
51-
- This simplifies to: `p' = (1000 + 4500 - 175) / 1.575 ≈ 3380.95`.
52-
- If the ETH price reaches $3,380.95, the equity would fall to the required margin level.
53-
44+
1. **Key Terms:**
45+
46+
- **Total Maintenance Margin Requirement (`MMR_t`):** Calculate the maintenance margin needed for all positions at current prices: `MMR_t = |s| · p · MMF`
47+
- **Other Positions' Margin Requirement (`MMR_o`)**: Subtract the margin requirement of the position in question from MMR_t: `MMR_o = MMR_t - |s| * p * MMF`
48+
- **New Margin Requirement at Price `p'`**: Add `MMR_o` to the margin requirement of the position at the new price: `MMR_o + |s| * p' * MMF`
49+
- **Liquidation Price Formula**: Substitute into the equation to find the liquidation price for the position: `p' = (e - s * p - MMR_o) / (|s| * MMF - s)`
50+
51+
2. **Example:**
52+
53+
- Suppose a trader deposits $1,000 (`e = 1000`).
54+
- The trader shorts 1.5 ETH (`s = -1.5`) at $3,000 and buys 1,000 STRK contracts at $1.75 (`MMF = 10%` for STRK).
55+
- **Calculate Other Positions' Margin Requirement**: `MMR_o = 1000 * 1.75 * 0.10 = 175`
56+
- Compute the Liquidation Price for ETH: `p' = (1000 - (-1.5 * 3000) - 175) / (1.5 * 0.05 + 1.5)`
57+
- This simplifies to: `p' = (1000 + 4500 - 175) / 1.575 ≈ 3380.95`.
58+
- If the ETH price reaches $3,380.95, the equity would fall to the required margin level.
59+
5460
## “Fillable Price” for Liquidations
5561

5662
As part of the default settings of dYdX Chain, the “fillable price” (or the limit price of a liquidation order) for a position being liquidated is calculated as follows. For both short and long position:
57-
63+
5864
```
5965
Fillable Price (Short or Long) = P x (1 - ((SMMR x MMF) x (BA x (1 - Q)))
6066
```
61-
67+
6268
Where (provided as genesis parameters):
69+
6370
- `P` is the oracle price for the market
6471
- `SMMR` is the spread to maintenance margin ratio
6572
- `MMR`= `Config.FillablePriceConfig.SpreadToMaintenanceMarginRatioPpm`
@@ -68,28 +75,28 @@ Where (provided as genesis parameters):
6875
- `A` = `Config.FillablePriceConfig.BankruptcyAdjustmentPpm`. Is ≥ 1.
6976
- `Q = V / TMMR` where `V` is the total account value, and `TMMR` is the total maintenance margin requirement
7077

71-
On the other hand, the “Close Price” will be the sub-ticks of whatever maker order(s) the liquidation order matches against.
72-
78+
On the other hand, the “Close Price” will be the sub-ticks of whatever maker order(s) the liquidation order matches against.
79+
7380
For more information on Margin fractions and calculations, see [Margin](/concepts/trading/margin).
74-
81+
7582
## FAQ
7683

7784
> What price is used to determine liquidations?
7885
7986
As part of the default settings, Oracle Price is used to estimate the value of an account’s positions. If the account’s value falls below the account’s maintenance margin requirement, the account is liquidatable.
80-
87+
8188
> Who receives the liquidation fees?
8289
8390
The insurance fund would receive liquidation fees / penalty. Please note that the applicable Governance Community needs to initially fund the insurance fund from the applicable community treasury.
84-
91+
8592
> How liquidation engine works?
8693
8794
Our liquidation engine automatically closes positions that fall below the maintenance margin.
88-
95+
8996
> Does dYdX apply a penalty in the event of liquidation?
9097
91-
Yes. The liquidation engine will attempt to leave funds in accounts of positive value where possible after they have paid the Maximum Liquidation Penalty of 1.5%. The 1.5% fee contemplated in the default v4 software will be subject to adjustments by the applicable Governance Community.
92-
93-
> How to avoid liquidation?
98+
Yes. The liquidation engine will attempt to leave funds in accounts of positive value where possible after they have paid the Maximum Liquidation Penalty of 1.5%. The 1.5% fee contemplated in the default v4 software will be subject to adjustments by the applicable Governance Community.
99+
100+
> How to avoid liquidation?
94101
95-
In order to avoid liquidation, you can deposit more assets to your account, as while opening a position the key point is to have enough assets to cover the maintenance margin requirements. You can also close the part of the position and the liquidation price will change.
102+
In order to avoid liquidation, you can deposit more assets to your account, as while opening a position the key point is to have enough assets to cover the maintenance margin requirements. You can also close the part of the position and the liquidation price will change.

0 commit comments

Comments
 (0)