Skip to content

feat(margin): maintenance margin and liquidation keeper fields when creating or editing an order - #420

Open
rroland10 wants to merge 1 commit into
masterfrom
feat/lender-protection-fields
Open

rroland10 wants to merge 1 commit into
masterfrom
feat/lender-protection-fields

Conversation

@rroland10

Copy link
Copy Markdown

Problem

Lender protection (monday 13490194650) added two per-order settings to the margin module in Dex223-contracts #182: a maintenance margin (10–50%) and a liquidation keeper that may complete loss liquidations during the 24-hour lender window. Lenders had no way to set them.

Change

Implements the approved Figma design (page 11, "New lending order Step 3: lender protection", node 158:1886).

  • hooks/useLenderProtection.ts: useOrderLenderProtection(orderId?) reads orderMaintenanceMarginBps / orderLiquidationKeeper; supported is false where the getters revert (modules deployed before Remove the stale package-lock.json so test-app builds with yarn #182). encodeLenderProtection(...) builds the call (10% → 0 = contract default; empty keeper → zero address).
  • LenderProtectionConfig in Step 3 (create and edit share it): margin field with the leverage it allows (1 + 100/margin), keeper field, info alert about the 24-hour window when either is changed. Yup: margin 10–50, keeper empty or a valid address.
  • Create: when supported and not at defaults, reads orderIndex and appends orderSetLenderProtection(orderIndex, bps, keeper) to the existing [addTokenlist, createOrder] multicall. If another order lands in between, the call reverts (not the owner) and so does the whole multicall: no order with the wrong settings.
  • Edit: form starts from the on-chain settings (initialisation waits for the read); the call is always appended when supported, so a field can be cleared. (modifyOrder already requires no open positions, so the margin is always changeable here.)
  • ABI: orderSetLenderProtection, orderMaintenanceMarginBps, orderLiquidationKeeper, positionUnderwaterSince. Strings in all 7 locales.

Verified

Open

…reating or editing an order

Step 3 of the lending-order wizard gets the two lender-protection settings added to the margin
module in Dex223-contracts #182 (Figma page 11, "New lending order Step 3: lender protection"):
- Maintenance margin (%), 10-50, default 10, with the leverage it allows.
- Liquidation keeper (optional address) that may complete loss liquidations for the lender
  during the contract's 24-hour lender window.
An info alert explains the window when either is changed. On Create, orderSetLenderProtection
is appended to the create multicall when a setting differs from the defaults (the new id is the
current orderIndex; a race reverts the whole multicall). On Edit, the form starts from the
on-chain settings and the call is always sent, so a field can be returned to its default.
The fields only appear where the deployed module has the getters (useOrderLenderProtection):
hidden on the current Sepolia v4 module, shown after the pre-launch redeploy.
@vercel

vercel Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
dex223-ui-blog Ready Ready Preview Nov 7, 2026 9:38am UTC
dex223-ui-web Ready Ready Preview Nov 7, 2026 9:38am UTC

Request Review

This branch was successfully deployed

2 active deployments
Preview – dex223-ui-web — 68c5e14b Deployed Nov 7, 2026 by vercel[bot]
Preview – dex223-ui-blog — 68c5e14b Deployed Nov 7, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant