Skip to content

Add integrator fee#72

Open
UnDeleteRU wants to merge 15 commits into
masterfrom
feature/PT9-759-add-integrator-fee
Open

Add integrator fee#72
UnDeleteRU wants to merge 15 commits into
masterfrom
feature/PT9-759-add-integrator-fee

Conversation

@UnDeleteRU

Copy link
Copy Markdown

Change Summary

What does this PR change?
Add integrator fee

Related Issue/Ticket:
https://1inch.atlassian.net/browse/PT9-759

Testing & Verification

How was this tested?

  • Unit tests
  • Integration tests
  • Manual testing (describe steps)
  • Verified on staging

Risk Assessment

Risk Level:

  • Low - Minor changes, no operational impact
  • Medium - Moderate changes, limited impact, standard rollback available
  • High - Significant changes, potential operational impact, complex rollback

Comment thread src/sdk/integrator-fee.util.ts Outdated
Comment thread src/sdk/sdk.ts
Comment thread src/bps.ts
Comment thread src/sdk/sdk.spec.ts Outdated
Comment thread src/api/api.ts Outdated
Comment thread src/sdk/integrator-fee.util.ts Outdated
Comment thread src/bps.ts
Comment thread src/sdk/sdk.ts

@rharutyunyan rharutyunyan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed and verified locally on the PR head (a617b36): pnpm test (67/67), pnpm lint:ci and tsc --noEmit are all clean.

Also re-derived the load-bearing fixtures independently:

  • id('my-dapp') → 0xaba10994, id('aba10994') → 0xb5e948e6 — the bare-hex API source really does get keccak-hashed (not used verbatim), exactly as the tests pin and the README warns.
  • extractTrackCode zero-pads to 8 hex chars (0x00000000 for empty track).
  • Bps.fromSharePercent(84.45) → 8445, 0.125 → 12 (truncation), negatives rejected — README claims match the implementation.
  • Missing integratorFeeSharePercent with fee > 0 → IntegratorFee.ZERO, which is compatible with the IntegratorFee/Fees constructor invariants (explicit share: 0 is still honored as "all to protocol").
  • The explicit-salt path checks out: verifySalt passes because both orders share the same extension hash, and track bits [224, 256) can never collide with the extension-hash lower 160 bits, so setSource after LimitOrderWithFee construction is safe.

Nothing blocking — a few small nits inline.

Comment thread src/sdk/sdk.ts
const order = new LimitOrderWithFee(orderInfo, makerTraits, feeExt)

// Apply API-resolved track code when salt is auto-built
if (orderInfo.salt === undefined) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Tiny edge-case inconsistency: this check is === undefined, but the LimitOrder constructor treats the salt as falsy (orderInfo.salt || LimitOrder.buildSalt(...)). So for salt: 0n the order silently gets a fresh random salt, yet the API source is not applied (0n !== undefined) — neither the caller's salt nor the track code wins. if (!orderInfo.salt) would match the constructor's semantics. Non-blocking, salt: 0n is a pathological input.

Comment thread src/bps.ts
* E.g. 84.45% → 8445 bps
*/
public static fromSharePercent(val: number | string, base = 1n): Bps {
const normalized = typeof val === 'number' ? val.toString() : val.trim()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Since this is now public API accepting strings, note it parses malformed input silently: '1.2.3' → 120 bps, '' → 0 bps. And numbers that stringify to scientific notation (1e-7, 1e21) surface as a raw SyntaxError: Cannot convert 1e-7 to a BigInt instead of the invalid bps assert. A shape check up front would tighten both, e.g. assert(/^\d+(\.\d+)?$/.test(normalized), ...) — it also subsumes the negative check. Non-blocking: the SDK call sites only pass API numbers.

Comment thread package.json
{
"name": "@1inch/limit-order-sdk",
"version": "5.3.1",
"version": "5.3.2-rc.0",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Semver nit: this ships new public API (LimitOrder.getTrackCode, Bps.fromSharePercent, new FeeInfoDTO fields) and changes Sdk.createOrder output for keys with portal fee config — that reads as 5.4.0-rc.0 rather than a patch. A minor bump also makes the behavior change harder to miss for integrators skimming upgrade diffs.

uses: actions/setup-node@v3
with:
node-version: 20
node-version: 22

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

CI now runs Node 22 only, while engines still advertises >=20.9.0 (and volta pins 20.9.0) — the minimum supported version is no longer exercised. Either keep a 20.x job (matrix) or bump engines. Related: pnpm@11.0.0-rc.1 below is an RC pin for the audit step — worth a TODO to move to stable pnpm 11 once released.

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