Skip to content

Feat/Delta -- depositNativeAndPreSign#223

Open
andriy-shymkiv wants to merge 18 commits intomasterfrom
feat/delta_depositNativeAndPreSign
Open

Feat/Delta -- depositNativeAndPreSign#223
andriy-shymkiv wants to merge 18 commits intomasterfrom
feat/delta_depositNativeAndPreSign

Conversation

@andriy-shymkiv
Copy link
Contributor

@andriy-shymkiv andriy-shymkiv commented Feb 16, 2026

@Velenir, wdyt about keeping CLAUDE.md for further sessions with Claude?


Note

Medium Risk
Adds new on-chain transaction methods (payable deposit + withdrawal/cancel flows) and wires them into the public SDK surface, so incorrect ABI/args/overrides could cause failed or unintended transactions.

Overview
Adds a new Delta on-chain constructDeltaTokenModule exposing cancelAndWithdrawDeltaOrder, withdrawDeltaNative, and depositNativeAndPreSign (plus a helper that hashes SignableDeltaOrderData and calls the deposit+presign flow with value).

Wires the module into constructAllDeltaOrdersHandlers, constructPartialSDK TxResponse inference, and src/index.ts exports; also moves DEFAULT_BRIDGE into a dedicated delta/constants.ts and bumps package version to 9.3.4-dev.1 (plus adds CLAUDE.md architecture notes).

Written by Cursor Bugbot for commit ac55dd9. This will update automatically on new commits. Configure here.

@github-actions
Copy link

github-actions bot commented Feb 16, 2026

size-limit report 📦

Path Size
dist/sdk.cjs.production.min.js 16.38 KB (+3.45% 🔺)
dist/sdk.esm.js 16.33 KB (+3.73% 🔺)

andriy-shymkiv and others added 6 commits February 17, 2026 15:30
@andriy-shymkiv andriy-shymkiv marked this pull request as ready for review February 20, 2026 09:19
@andriy-shymkiv
Copy link
Contributor Author

@cursor review

Copy link

@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.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

Comment on lines 40 to 41
// returns whatever `contractCaller` returns
// to allow for better versatility
Copy link
Member

Choose a reason for hiding this comment

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

No it doesn't.
For signCancel it returns the signed message string.
For post it obviously returns POERST Response


## Composable Constructor Pattern

Every feature module exports a `constructXxx(options) => XxxFunctions` factory:
Copy link
Member

Choose a reason for hiding this comment

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

What prompt did you use to generate this?
Describe the repo and conventions or something?

Copy link
Member

Choose a reason for hiding this comment

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

Why don't you ask Claud to fill in instructions for all other methods based on what it already wrote

Copy link
Contributor Author

Choose a reason for hiding this comment

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

asked 3dc09e1

Copy link
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.

Would be great to add some tests.
Can be done last though

Comment on lines 321 to 331
> = async (signableOrderData, overrides = {}, requestParams) => {
// types allow to pass OrderData & extra_stuff, but tx will break like that
const typedDataOnly: SignableDeltaOrderData = {
...signableOrderData,
data: sanitizeDeltaOrderData(signableOrderData.data),
};

const orderHash = produceDeltaOrderHash(typedDataOnly);
const res = await depositNativeAndPreSign(
orderHash,
overrides,
Copy link
Member

Choose a reason for hiding this comment

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

It's very not obvious that deposit amount should be in overrides.value.
Better make it a separate input in the first param

const { getDeltaContract } = constructGetDeltaContract(options);

const cancelAndWithdrawDeltaOrder: CancelAndWithdrawDeltaOrder<T> = async (
{ order, signature, bridgeOverride, cosignature, isFillable },
Copy link
Member

Choose a reason for hiding this comment

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

In most cases neither we nor users will have bridgeOverride, cosignature, isFillable.
Make them optional and provide defaults

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree on both this comment and the comment above
Changed 4ac84b3

Copy link
Member

Choose a reason for hiding this comment

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

I have a concern that it may be hard to cancel Orders with modified bridge (selectBridge option).
I don't think we can fetch that data from API and that forces users to keep track of what Order was created with what bridge

This may be a problem for BE to solve

Copy link
Member

Choose a reason for hiding this comment

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

If we can count on API to return order.bridge stuff necessary, then we are still left without signature, unless it was saver on user side. It is never returned from API.

This makes it impossible to cancel ETH Orders unless they were made with 0x signature.
Currently that's how they will be made, exclusively. With depositAndPreSign.
But soon we'll want to reuse the available dETH balance to create ETH Orders with signTypedData only


## Composable Constructor Pattern

Every feature module exports a `constructXxx(options) => XxxFunctions` factory:
Copy link
Member

Choose a reason for hiding this comment

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

Why don't you ask Claud to fill in instructions for all other methods based on what it already wrote

@andriy-shymkiv
Copy link
Contributor Author

Would be great to add some tests.

@Velenir, I'll add tests after we agree on the core changes. Please review 🙏🏻

Comment on lines +264 to +268
order,
signature,
bridgeOverride = {
protocolData: DEFAULT_BRIDGE.protocolData,
protocolSelector: DEFAULT_BRIDGE.protocolSelector,
Copy link
Member

Choose a reason for hiding this comment

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

Why not

order,
signature,
bridgeOverride = {
  protocolData: order.bridge.protocolData,
  protocolSelector: order.bridge.protocolSelector,

Why even have a separate bridgeOverride param?
Can order.bridge (if returned from API as part of DeltaOrderFromAPI) not match the bridgeOverride needed?

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