Skip to content

docs: add perpetuals, margin, liquidation, and wallets pages - #645

Open
nonso7 wants to merge 1 commit into
SO4-Markets:mainfrom
nonso7:docs/dx-069-071-073-074
Open

docs: add perpetuals, margin, liquidation, and wallets pages#645
nonso7 wants to merge 1 commit into
SO4-Markets:mainfrom
nonso7:docs/dx-069-071-073-074

Conversation

@nonso7

@nonso7 nonso7 commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Covers DX-071, DX-073, DX-074, and DX-069.

Three new pages (/concepts/perpetuals, /concepts/margin-and-leverage, /get-started/wallets) and a full rewrite of the /concepts/liquidation stub. Every worked example was computed by running the interface's own functions (estimateLiquidationPrice, calculatePnl, sizeFromCollateralAndLeverage in apps/web/src/features/trade/lib/trade-math.ts) against the stated inputs, not estimated.

Sourcing:

  • Liquidation formula and 0.5% maintenance margin: trade-math.ts:37-63 (rate at :49); duplicate estimator in liquidation.ts:16-35. Contract-side value is PositionInfo.liquidationPrice (packages/contracts/src/generated/synthetics-reader/src/index.ts:54, getAccountPositions at :337), read in usePositions.ts:57. Liquidation lifecycle from mappingHandlers.ts:203-209 and :570-596, schema.graphql:309.
  • Leverage: trade-math.ts:21,27; usePositions.ts:66; CollateralDialog.tsx:62, 77-78; LeverageSlider.tsx:12; useMarketsInfo.ts:77; LEVERAGE_TOO_HIGH in packages/contracts/src/errors.ts:24. Collateral tokens from apps/web/src/features/pools/data/markets.ts.
  • Wallets: WALLET_OPTIONS in ConnectButton.tsx:38, error string at :264, kit init in app/providers/index.tsx:78-79, signing path in lib/soroban/tx-builder.ts:23 through packages/contracts/src/clients/exchange-router.ts:139,201, session persistence in wallet-store.ts:43-44.

The Soroban contract source is not part of this repository, so the on-chain maintenance-margin threshold could not be verified against the code that enforces it. The liquidation page states that limitation directly and ships as status: beta pending maintainer review, as DX-074 requires. Partial liquidation is documented as not implemented anywhere in this repository.

Also removes the /concepts/perpetuals and /concepts/margin-and-leverage placeholder entries from link-ignore.json, now that both routes exist, and updates the quickstart sentence that described the wallet guide as planned.

Verification: check:links passes (41 pages), lint:prose reports 0 errors, and the docs script tests pass (40/40). check:content passes for these pages once committed with today's date; it still reports 10 pre-existing updated-date mismatches on pages this change does not touch. lint, typecheck, check:tokens, test, test:coverage and build all fail identically on unmodified main (verified against a clean clone of a07d258: identical typecheck errors, byte-identical check:tokens output, same three failing docs test files, same CSS budget failure with the same asset hash), so this change neither introduces nor fixes them.

Closes #581
Closes #583
Closes #585
Closes #586

Covers DX-071, DX-073, DX-074, and DX-069.

Three new pages (/concepts/perpetuals, /concepts/margin-and-leverage,
/get-started/wallets) and a full rewrite of the /concepts/liquidation stub.
Every worked example was computed by running the interface's own functions
(estimateLiquidationPrice, calculatePnl, sizeFromCollateralAndLeverage in
apps/web/src/features/trade/lib/trade-math.ts) against the stated inputs,
not estimated.

Sourcing:
- Liquidation formula and 0.5% maintenance margin: trade-math.ts:37-63
  (rate at :49); duplicate estimator in liquidation.ts:16-35. Contract-side
  value is PositionInfo.liquidationPrice
  (packages/contracts/src/generated/synthetics-reader/src/index.ts:54,
  getAccountPositions at :337), read in usePositions.ts:57. Liquidation
  lifecycle from mappingHandlers.ts:203-209 and :570-596, schema.graphql:309.
- Leverage: trade-math.ts:21,27; usePositions.ts:66; CollateralDialog.tsx:62,
  77-78; LeverageSlider.tsx:12; useMarketsInfo.ts:77; LEVERAGE_TOO_HIGH in
  packages/contracts/src/errors.ts:24. Collateral tokens from
  apps/web/src/features/pools/data/markets.ts.
- Wallets: WALLET_OPTIONS in ConnectButton.tsx:38, error string at :264,
  kit init in app/providers/index.tsx:78-79, signing path in
  lib/soroban/tx-builder.ts:23 through
  packages/contracts/src/clients/exchange-router.ts:139,201, session
  persistence in wallet-store.ts:43-44.

The Soroban contract source is not part of this repository, so the on-chain
maintenance-margin threshold could not be verified against the code that
enforces it. The liquidation page states that limitation directly and ships
as status: beta pending maintainer review, as DX-074 requires. Partial
liquidation is documented as not implemented anywhere in this repository.

Also removes the /concepts/perpetuals and /concepts/margin-and-leverage
placeholder entries from link-ignore.json, now that both routes exist, and
updates the quickstart sentence that described the wallet guide as planned.

Verification: check:links passes (41 pages), lint:prose reports 0 errors,
and the docs script tests pass (40/40). check:content passes for these pages
once committed with today's date; it still reports 10 pre-existing
updated-date mismatches on pages this change does not touch. lint,
typecheck, check:tokens, test, test:coverage and build all fail identically
on unmodified main (verified against a clean clone of a07d258: identical
typecheck errors, byte-identical check:tokens output, same three failing
docs test files, same CSS budget failure with the same asset hash), so this
change neither introduces nor fixes them.
@vercel

vercel Bot commented Sep 2, 2026

Copy link
Copy Markdown

@nonso7 is attempting to deploy a commit to the Ijai's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Sep 2, 2026

Copy link
Copy Markdown

@nonso7 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant