Repository navigation
feat(margin): maintenance margin and liquidation keeper fields when creating or editing an order - #420
Open
rroland10 wants to merge 1 commit into
Open
feat(margin): maintenance margin and liquidation keeper fields when creating or editing an order#420rroland10 wants to merge 1 commit into
rroland10 wants to merge 1 commit into
Conversation
…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.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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?)readsorderMaintenanceMarginBps/orderLiquidationKeeper;supportedis 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).LenderProtectionConfigin 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.orderIndexand appendsorderSetLenderProtection(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.modifyOrderalready requires no open positions, so the margin is always changeable here.)orderSetLenderProtection,orderMaintenanceMarginBps,orderLiquidationKeeper,positionUnderwaterSince. Strings in all 7 locales.Verified
tsc --noEmitclean outsidecomponents/trading-chart;node tests/swapReceipt.test.cjs20/20.orderMaintenanceMarginBps(0)reverts on the current v4 module (0x0cc1…) → fields hidden there;orderIndex()reads fine.Open