Skip to content

Feat/twap#231

Merged
andriy-shymkiv merged 23 commits intomasterfrom
feat/twap
Apr 15, 2026
Merged

Feat/twap#231
andriy-shymkiv merged 23 commits intomasterfrom
feat/twap

Conversation

@andriy-shymkiv
Copy link
Copy Markdown
Member

@andriy-shymkiv andriy-shymkiv commented Mar 24, 2026

closes FRNT-1290


Note

Medium Risk
Adds new TWAP Delta order flows (typed-data building/signing, API posting, pre-signing, and on-chain cancellation), plus updates shared amount/slippage typings; mistakes could cause incorrect order encoding or transaction calls.

Overview
Adds first-class TWAP Delta order support (sell and buy) across the SDK: new builders produce EIP-712 typed data, new sign/post/pre-sign helpers submit and manage TWAP orders, and constructAllDeltaOrdersHandlers/public exports now expose submitTWAPDeltaOrder and related functions.

Extends the Delta token module with cancelTWAPAndWithdraw and cancelTWAPBuyAndWithdraw contract calls, including TWAP order sanitization before signing/transacting.

Refactors slippage/amount typing by renaming AmountsWithSlippage to DeltaAmountsWithSlippage (and variants), exports DeltaAuctionTransaction, and updates snapshots; bumps package version to 9.5.0.

Reviewed by Cursor Bugbot for commit dc32f22. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 24, 2026

size-limit report 📦

Path Size
dist/sdk.cjs.production.min.js 18 KB (0%)
dist/sdk.esm.js 17.89 KB (0%)

@linear
Copy link
Copy Markdown

linear Bot commented Mar 26, 2026

FRNT-1290

@andriy-shymkiv
Copy link
Copy Markdown
Member Author

@cursor review

Comment thread src/methods/delta/buildTWAPDeltaOrder.ts
Comment thread src/methods/delta/postTWAPDeltaOrder.ts
@andriy-shymkiv andriy-shymkiv marked this pull request as ready for review March 27, 2026 14:28
@andriy-shymkiv
Copy link
Copy Markdown
Member Author

@cursor review

Comment thread src/methods/delta/helpers/buildTWAPOrderData.ts Outdated
Copy link
Copy Markdown
Member

@Velenir Velenir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't really say if this whole thing works without tests, or testing in UI/WIdget, but looks alright.

Please, if not tests right away, add an example with the happy path and a readme

Comment thread src/methods/delta/helpers/misc.ts
Comment thread src/methods/delta/buildTWAPDeltaOrder.ts
Comment thread src/methods/delta/preSignTWAPDeltaOrder.ts
Comment thread src/methods/delta/buildTWAPDeltaOrder.ts
Comment thread src/methods/delta/index.ts
Comment thread src/index.ts Outdated
Comment thread src/methods/delta/deltaTokenModule.ts
Comment thread src/methods/delta/deltaTokenModule.ts Outdated
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Autofix Details

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Wrong import source for TypedDataField type
    • Replaced the ethersV5 TypedDataField import with the SDK’s local TypedDataField type from ../common/orders/buildOrderData in preSignTWAPDeltaOrder.ts.

Create PR

Or push these changes by commenting:

@cursor push 0dadd97d7a
Preview (0dadd97d7a)
diff --git a/src/methods/delta/preSignTWAPDeltaOrder.ts b/src/methods/delta/preSignTWAPDeltaOrder.ts
--- a/src/methods/delta/preSignTWAPDeltaOrder.ts
+++ b/src/methods/delta/preSignTWAPDeltaOrder.ts
@@ -14,7 +14,7 @@
 import { findPrimaryType } from '../../helpers/providers/helpers';
 import { constructGetDeltaContract } from './getDeltaContract';
 import type { TWAPDeltaOrder, TWAPBuyDeltaOrder } from './helpers/types';
-import { TypedDataField } from 'ethersV5';
+import type { TypedDataField } from '../common/orders/buildOrderData';
 
 type HashTWAPDeltaOrderTypedData = (
   signableOrderData: SignableTWAPOrderData

This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.

Comment thread src/methods/delta/preSignTWAPDeltaOrder.ts Outdated
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 95e4c07. Configure here.

const deltaOrderToPost: DeltaOrderToPost<'TWAPOrder' | 'TWAPBuyOrder'> = {
...postData,
chainId,
};
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

API field sent implicitly via spread, not in type

Medium Severity

The onChainOrderType field is intentionally included in PostTWAPDeltaOrderParams and explicitly passed by callers like submitTWAPDeltaOrder, but it only reaches the API request body as an implicit side-effect of the rest spread (...postData). The DeltaOrderToPost type doesn't declare onChainOrderType, so nothing in the type system ensures this critical field survives. A future refactor that constructs the POST body property-by-property instead of using spread would silently drop onChainOrderType, potentially breaking TWAP order creation.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 95e4c07. Configure here.

Copy link
Copy Markdown
Member Author

@andriy-shymkiv andriy-shymkiv Apr 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't know how much can break after this change (most likely nothing), so let's release as is for now and change later

@andriy-shymkiv andriy-shymkiv merged commit d771cb1 into master Apr 15, 2026
2 of 4 checks passed
@andriy-shymkiv andriy-shymkiv deleted the feat/twap branch April 15, 2026 12:38
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.

3 participants