Skip to content

Feat/delta v2#242

Open
andriy-shymkiv wants to merge 99 commits into
masterfrom
feat/delta-v2
Open

Feat/delta v2#242
andriy-shymkiv wants to merge 99 commits into
masterfrom
feat/delta-v2

Conversation

@andriy-shymkiv

@andriy-shymkiv andriy-shymkiv commented Jun 3, 2026

Copy link
Copy Markdown
Member

Note

High Risk
Large breaking change to Delta trading flows (build/sign/post, types, statuses, and URLs) plus removed limit/NFT public exports—integrators must migrate carefully to avoid failed or mis-signed orders.

Overview
This PR migrates the SDK’s Delta surface to v2: order construction is server-side via POST /v2/delta/orders/build, returning a BuiltDeltaOrder (toSign, orderHash) that a single signDeltaOrder signs for Standard, External, and TWAP families. Submit/build params shift from deltaPrice + token amounts to route, side, and slippage (or limitAmount).

Read/write API changes include /v2/delta/prices (route-based DeltaPrice), paginated getDeltaOrders, integrator statuses like COMPLETED (replacing custom EXECUTED/bridge polling), getBridgeRoutes instead of getBridgeInfo, cancel via /v2/delta/orders/cancel with renamed methods, and getAgentsList. Local helpers for partner fee/amount resolution and DEFAULT_BRIDGE are removed from the build path; EIP-712 producers remain for on-chain pre-sign flows.

OrderHelpers is reworked around the v2 auction envelope (input/output, transactions, explicit side) with guards for ProductiveOrder / FillableOrder (read-only / non-buildable).

Public package changes: src/index.ts drops limit and NFT order exports in favor of OTC modules; examples and README/DELTA/EXTERNAL docs are rewritten for v2. Adds @types/node dev dependency.

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

Comment thread src/methods/delta/helpers/orders.ts
Comment thread src/methods/delta/helpers/orders.ts Outdated
).toString(),
};
if (isTWAPOrder(auction.order) && auction.order.numSlices > 0) {
return total / auction.order.numSlices;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This doesn't look correct.
See this TWAPOrder, 4 txs, 25% filled each, total = sum(txs) /slices = 4 * 25 / 4 ?

Not to mention if you did this for filledPercent in TWAP, why didn't you do the same for tx.receivedAmount in getTransactionAmounts. Doesn't make sense

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good eye! Now this helper should work as before -- dbefdca

Comment thread src/methods/delta/helpers/orders.ts

@cursor cursor Bot left a comment

Copy link
Copy Markdown

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 2 potential issues.

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 8c5ad7c. Configure here.

return scalingFactor < 0
? amount / base ** BigInt(-scalingFactor)
: amount * base ** BigInt(scalingFactor);
return total;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

TWAP fill percent not normalized

High Severity

For TWAP auctions, getFilledPercent sums each transaction’s slice-level filledPercent and returns that total. Because those values are per-slice (0–100), a fully filled multi-slice order can report well over 100%, which breaks isPartiallyExecutedAuction, unified order data, and any UI that treats the result as overall order progress.

Fix in Cursor Fix in Web

Triggered by learned rule: Understand Delta cross-chain auction execution model in OrderHelpers

Reviewed by Cursor Bugbot for commit 8c5ad7c. Configure here.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

they are not per slice, that was a mistake
@andriy-shymkiv maybe we have it left somewhere still? in a comment?

Comment thread src/methods/delta/helpers/orders.ts
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.

2 participants