Use order-snapshotted uiFeeFactor in existing-order fee estimations (FEDEV-3968)#2632
Draft
divhead wants to merge 1 commit into
Draft
Use order-snapshotted uiFeeFactor in existing-order fee estimations (FEDEV-3968)#2632divhead wants to merge 1 commit into
divhead wants to merge 1 commit into
Conversation
Since v2.2c contracts snapshot uiFeeFactor at order creation and charge the snapshot at execution (updateOrder never re-snapshots it). Parse the field from Reader responses, expose it on the Order type, and prefer it over the live factor in max-leverage checks and OrderEditor previews. API-sourced orders carry undefined until gmx-api serves the field and fall back to the live factor.
Deploying gmx-interface with
|
| Latest commit: |
8ccf2b2
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://f73dfe8c.gmx-interface.pages.dev |
| Branch Preview URL: | https://fedev-3968-sdk-uifeefactor.gmx-interface.pages.dev |
Deploying gmx-interface-home with
|
| Latest commit: |
8ccf2b2
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://dc736c48.gmx-interface-home.pages.dev |
| Branch Preview URL: | https://fedev-3968-sdk-uifeefactor.gmx-interface-home.pages.dev |
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.
What
Parse the snapshotted
uiFeeFactorfrom Reader order responses, expose it on theOrdertype, and use it instead of the live factor when estimating execution outcomes for existing orders.Part of FEDEV-3968 (SDK slice). Targets
qwinndev/update-v22c-contracts— the ABI there already carries the field; this PR makes the client consume it.Why
Since v2.2c (gmx-synthetics
ce3cc0ae) contracts snapshotuiFeeFactorat order creation and charge the snapshot at execution.updateOrdernever re-snapshots it (verified:OrderHandler.updateOrdermutates only size/prices/minOutput/validFrom/autoCancel/executionFee, andce3cc0aetouched no update path). Estimating an existing order with the live factor can diverge from what execution will actually charge.Changes
sdk/src/utils/orders/types.ts—uiFeeFactor: bigint | undefinedonOrder(0n = snapshotted as zero, incl. pre-upgrade orders; undefined = data source doesn't provide it).sdk/src/clients/v1/modules/orders/utils.ts,src/domain/synthetics/orders/useOrders.ts— extract the field fromorder.numbersin both Reader parsers (the decoded tuple already carries it via the updated ABI).src/domain/synthetics/orders/useOrders.ts— API-fallback orders get an explicituiFeeFactor: undefinedplaced before the spread, so the field flows automatically once gmx-api starts serving it.src/domain/synthetics/orders/utils.tsx—getIsMaxLeverageErrorsimulates the collateral swap withorder.uiFeeFactor ?? live.src/context/SyntheticsStateContext/selectors/orderEditorSelectors.ts— OrderEditor previews (swap fees / increase / decrease amounts) prefer the order's snapshot; nullish coalescing keeps a legitimate0nsnapshot (no falsy-zero loss).sdk/src/clients/v1/modules/orders/utils.spec.ts— offline unit spec for the parser: value round-trip and0npreservation.New-order previews (TradeBox, TP/SL sidecar, LP deposits) intentionally keep the live factor — the contract snapshots the current value at creation, so live is the correct estimate there.
Checks
yarn build-sdk,yarn tscheck:ci,yarn lint:ci,yarn test:ci, targetedvitest run sdk/.../orders/utils.spec.ts— all green.Out of scope (rest of FEDEV-3968)
/orders(then the API-fallback path picks it up automatically).