Skip to content

feat(composable): add JIT poller SDK support - #927

Open
igorroncevic wants to merge 3 commits into
mainfrom
feat/composable-cow-poller-sdk
Open

feat(composable): add JIT poller SDK support#927
igorroncevic wants to merge 3 commits into
mainfrom
feat/composable-cow-poller-sdk

Conversation

@igorroncevic

@igorroncevic igorroncevic commented Jul 15, 2026

Copy link
Copy Markdown

What and why

Add JIT Poller support to @cowprotocol/sdk-composable: the contract ABI, schedule types, schedule ID derivation, and calldata encoders for register, pollFunds, and revoke.

The ABI matches the CowShed-aware contract in ComposableCoW #128. Applications provide the deployed Poller address and may submit register and revoke directly or through the funder’s canonical CowShed.

Related: https://linear.app/cowswap/project/twap-for-eoas-07d3dae536ea/overview

Test

pnpm --filter @cowprotocol/sdk-composable test

Summary by CodeRabbit

  • New Features
    • Added JIT poller utilities for generating schedule IDs and register, funding, and revoke calldata.
    • Added typed funding schedule definitions and contract interface support.
    • Exposed the new poller functionality through the composable SDK package.
  • Documentation
    • Added usage instructions and examples for configuring JIT-funded TWAP schedules.
  • Tests
    • Added coverage for multi-adapter consistency, calldata generation, schedule IDs, and contract interface details.

@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds typed Composable Cow poller schedules, a contract ABI, schedule ID derivation, calldata encoders, package exports, multi-adapter tests, and JIT poller documentation.

Changes

Composable Cow JIT Poller

Layer / File(s) Summary
Poller schedule contracts and ABI
packages/composable/src/types.ts, packages/composable/src/abis/ComposableCowPollerAbi.ts
Defines schedule key and schedule types, plus the ComposableCowPoller ABI including functions, events, errors, and constructor metadata.
Schedule IDs and calldata encoding
packages/composable/src/ComposableCowPoller.ts, packages/composable/src/index.ts
Derives schedule IDs from funder, handler, owner, and salt; encodes register, pollFunds, and revoke calls; and re-exports the utilities.
Poller validation and usage example
packages/composable/tests/ComposableCowPoller.spec.ts, packages/composable/README.md
Tests deterministic IDs, adapter-consistent calldata, and ABI entries, and documents JIT poller calldata construction.

Estimated code review effort: 2 (Simple) | ~15 minutes

Suggested reviewers: danziger, shoom3301

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding JIT poller SDK support in the composable package.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/composable-cow-poller-sdk

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@github-actions

github-actions Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

📦 GitHub Packages Published

Last updated: Jul 28, 2026, 11:07:04 AM UTC

The following packages have been published to GitHub Packages with pre-release version pr-927-90ee3de4:

  • @cowprotocol/cow-sdk@9.2.4-pr-927-90ee3de4.0
  • @cowprotocol/sdk-app-data@5.3.2-pr-927-90ee3de4.0
  • @cowprotocol/sdk-bridging@4.3.1-pr-927-90ee3de4.0
  • @cowprotocol/sdk-common@0.12.0-pr-927-90ee3de4.0
  • @cowprotocol/sdk-composable@1.2.1-pr-927-90ee3de4.0
  • @cowprotocol/sdk-config@2.3.1-pr-927-90ee3de4.0
  • @cowprotocol/sdk-contracts-ts@3.3.1-pr-927-90ee3de4.0
  • @cowprotocol/sdk-cow-shed@0.4.3-pr-927-90ee3de4.0
  • @cowprotocol/sdk-ethers-v5-adapter@0.4.10-pr-927-90ee3de4.0
  • @cowprotocol/sdk-ethers-v6-adapter@0.4.10-pr-927-90ee3de4.0
  • @cowprotocol/sdk-flash-loans@3.3.1-pr-927-90ee3de4.0
  • @cowprotocol/sdk-order-book@4.0.1-pr-927-90ee3de4.0
  • @cowprotocol/sdk-order-signing@1.1.4-pr-927-90ee3de4.0
  • @cowprotocol/sdk-subgraph@1.2.0-pr-927-90ee3de4.0
  • @cowprotocol/sdk-trading@2.2.4-pr-927-90ee3de4.0
  • @cowprotocol/sdk-viem-adapter@0.3.25-pr-927-90ee3de4.0
  • @cowprotocol/sdk-weiroll@0.2.1-pr-927-90ee3de4.0

Installation

These packages require authentication to install from GitHub Packages. First, create a .npmrc file:

# Create .npmrc file in your project root
echo "@cowprotocol:registry=https://npm.pkg.github.com" > .npmrc
echo "//npm.pkg.github.com/:_authToken=YOUR_GITHUB_TOKEN" >> .npmrc

To get your GitHub token:

  1. Go to https://github.com/settings/tokens
  2. Click "Generate new token (classic)"
  3. Check only the "read:packages" scope
  4. Copy the token and replace YOUR_GITHUB_TOKEN in the .npmrc file

Then install any of the packages above, either by exact version (i.e. @cowprotocol/cow-sdk@9.2.4-pr-927-90ee3de4.0) or more conveniently by using the tag (@cowprotocol/cow-sdk@pr-927):

# Yarn
yarn add npm:@cowprotocol/cow-sdk@pr-927

# pnpm
pnpm install npm:@cowprotocol/cow-sdk@pr-927

# NPM
npm install npm:@cowprotocol/cow-sdk@pr-927

Update to the latest version (only if you used the tag)

Every commit will publish a new package. To upgrade to the latest version, run:

# Yarn
yarn upgrade @cowprotocol/cow-sdk

# pnpm
pnpm update @cowprotocol/cow-sdk

# NPM
npm update @cowprotocol/cow-sdk

View Packages

You can view the published packages at: https://github.com/cowprotocol/cow-sdk/packages

@igorroncevic

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

github-actions Bot added a commit that referenced this pull request Jul 15, 2026
@igorroncevic igorroncevic changed the title feat(composable): add JIT poller helpers feat(composable): add JIT poller SDK support Jul 16, 2026
@igorroncevic
igorroncevic force-pushed the feat/composable-cow-poller-sdk branch from 5d12778 to e640f37 Compare July 23, 2026 17:43
@igorroncevic igorroncevic self-assigned this Jul 28, 2026
@igorroncevic
igorroncevic marked this pull request as ready for review July 28, 2026 11:04
@igorroncevic
igorroncevic requested a review from anxolin July 28, 2026 11:04

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
packages/composable/tests/ComposableCowPoller.spec.ts (1)

3-10: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Exercise the package entry point in this test.

These imports bypass packages/composable/src/index.ts, so the suite can pass even if the new public barrel export is broken. Import the helpers from ../src or add a dedicated root-export assertion.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/composable/tests/ComposableCowPoller.spec.ts` around lines 3 - 10,
Update the imports in ComposableCowPoller.spec.ts to consume
ComposableCowPollerAbi, encodePollFunds, encodeRegister, encodeRevoke, and
getScheduleId through the package entry point ../src instead of the
implementation module. Keep the ComposableCowPollerSchedule type import
appropriately sourced, and ensure the test exercises the public barrel exports.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/composable/tests/ComposableCowPoller.spec.ts`:
- Around line 27-52: Restore the shared global adapter after each test in the
“ComposableCowPoller - Multi-Adapter Tests” suite. Capture the current adapter
before each test and reset it in afterEach, or use an equivalent adapter-scoped
helper, while preserving the existing setGlobalAdapter calls.

---

Nitpick comments:
In `@packages/composable/tests/ComposableCowPoller.spec.ts`:
- Around line 3-10: Update the imports in ComposableCowPoller.spec.ts to consume
ComposableCowPollerAbi, encodePollFunds, encodeRegister, encodeRevoke, and
getScheduleId through the package entry point ../src instead of the
implementation module. Keep the ComposableCowPollerSchedule type import
appropriately sourced, and ensure the test exercises the public barrel exports.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 033cf80e-6b63-478c-9ce6-27ca0c99f78e

📥 Commits

Reviewing files that changed from the base of the PR and between 8d56e7d and 90ee3de.

📒 Files selected for processing (6)
  • packages/composable/README.md
  • packages/composable/src/ComposableCowPoller.ts
  • packages/composable/src/abis/ComposableCowPollerAbi.ts
  • packages/composable/src/index.ts
  • packages/composable/src/types.ts
  • packages/composable/tests/ComposableCowPoller.spec.ts

Comment on lines +27 to +52
describe('ComposableCowPoller - Multi-Adapter Tests', () => {
const adapters = createAdapters()

test('derives the Solidity schedule ID across adapters', () => {
for (const adapter of Object.values(adapters)) {
setGlobalAdapter(adapter)
expect(getScheduleId(SCHEDULE)).toEqual(SCHEDULE_ID)
}
})

test('does not include staticInput in the schedule ID', () => {
const updatedStaticInput = { ...SCHEDULE, staticInput: '0xdeadbeef' }

for (const adapter of Object.values(adapters)) {
setGlobalAdapter(adapter)
expect(getScheduleId(updatedStaticInput)).toEqual(SCHEDULE_ID)
}
})

test('encodes final poller calls across adapters', () => {
for (const adapter of Object.values(adapters)) {
setGlobalAdapter(adapter)
expect(encodeRegister(SCHEDULE)).toEqual(REGISTER_CALLDATA)
expect(encodePollFunds(SCHEDULE_ID)).toEqual(POLL_FUNDS_CALLDATA)
expect(encodeRevoke(SCHEDULE_ID)).toEqual(REVOKE_CALLDATA)
}

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.

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Files:"
git ls-files | rg 'ComposableCowPoller\.spec\.ts|adapter|Adapter' || true

echo
echo "Target file excerpt:"
if [ -f packages/composable/tests/ComposableCowPoller.spec.ts ]; then
  sed -n '1,140p' packages/composable/tests/ComposableCowPoller.spec.ts | cat -n
fi

echo
echo "Search setGlobalAdapter definitions/usages:"
rg -n "setGlobalAdapter|getGlobalAdapter|globalAdapter|afterEach|beforeEach|describe" packages/composable -S || true

Repository: cowprotocol/cow-sdk

Length of output: 27873


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Adapter context implementation:"
cat -n packages/common/src/adapters/context.ts

echo
echo "Composable Cow Poller helper semantics:"
cat -n packages/composable/src/ComposableCowPoller.ts

echo
echo "Adjacent imports and setup files:"
fd -a 'setup\.(ts|js)$|index\.spec\.ts$|Utils\.spec\.ts$|ConditionalOrder\.spec\.ts$' packages/composable tests 2>/dev/null || true
sed -n '1,120p' packages/composable/tests/setup.ts 2>/dev/null || true
sed -n '1,80p' packages/composable/tests/index.spec.ts 2>/dev/null || true
sed -n '1,80p' packages/composable/tests/ConditionalOrder.spec.ts 2>/dev/null || true

Repository: cowprotocol/cow-sdk

Length of output: 9721


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Root/package lock adapter context version references:"
for f in package.json pnpm-lock.yaml yarn.lock package-lock.json; do
  [ -f "$f" ] && (echo "--- $f"; rg -n '"`@cowprotocol/sdk-common`"|`@cowprotocol/sdk-common`|AdapterContext|getGlobalAdapter|setGlobalAdapter' "$f" | head -80 || true)
done

echo
echo "Composable package test config and scripts:"
sed -n '1,220p' packages/composable/package.json 2>/dev/null || true
rg -n "setupFiles|testEnvironment|afterEach|jest|vitest|test:|jest:" package.json packages/composable/package.json -S || true

echo
echo "Jest/Vitest top-level adapter usages in composable tests:"
rg -n "use .beforeAll|beforeEach\(\(\) \=>|beforeAll\(\(\) \=>|afterEach\(\(\) \=>|setGlobalAdapter\(.*AdapterContext|const .*AdapterContext|AdapterContext" packages/composable/tests packages/composable/src -S || true

echo
echo "Static behavior probe for AdapterContext state mutation (data only):"
python3 - <<'PY'
from pathlib import Path
p = Path('packages/common/src/adapters/context.ts').read_text()
checks = {
    'setGlobalAdapter_overwrites_singleton': 'this.setAdapter(adapter)' in p and '_instance' in p,
    'getGlobalAdapter_returns_singleton_adapter': 'return AdapterContext.getInstance().getAdapter()' in p,
    'test_has_afterEach_hook': Path('packages/composable/tests/ComposableCowPoller.spec.ts').read_text().count('afterEach(') == 0,
    'poller_helpers_use_global_adapter': 'getGlobalAdapter()' in Path('packages/composable/src/ComposableCowPoller.ts').read_text(),
}
for k, v in checks.items():
    print(f'{k}={v}')
PY

Repository: cowprotocol/cow-sdk

Length of output: 4527


Restore the global adapter between tests.

setGlobalAdapter stores the adapter on the shared AdapterContext, so this suite leaves the last adapter installed for later tests. Capture getGlobalAdapter() before each test and restore it in afterEach, or use an adapter-scoped helper.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/composable/tests/ComposableCowPoller.spec.ts` around lines 27 - 52,
Restore the shared global adapter after each test in the “ComposableCowPoller -
Multi-Adapter Tests” suite. Capture the current adapter before each test and
reset it in afterEach, or use an equivalent adapter-scoped helper, while
preserving the existing setGlobalAdapter calls.

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.

1 participant