Skip to content

feat: add taker filters to getTrades#2571

Open
findolor wants to merge 1 commit into
arda/get-trades-token-filterfrom
feature/rai-529-add-taker-address-filters-to-raindex-gettrades-sdk
Open

feat: add taker filters to getTrades#2571
findolor wants to merge 1 commit into
arda/get-trades-token-filterfrom
feature/rai-529-add-taker-address-filters-to-raindex-gettrades-sdk

Conversation

@findolor
Copy link
Copy Markdown
Collaborator

@findolor findolor commented May 12, 2026

Related Issue

Dependent PRs

Motivation

Consumers need the SDK-level getTrades API to support filtering by taker address. The REST API work identifies the taker address as the trade event sender, which is available in the raindex local DB and subgraph trade models.

For the local DB path, the taker predicate also needs to be applied before the trade reconstruction CTEs expand and hydrate rows. Filtering only after the normalized trade result forces SQLite to build a much larger intermediate result set before returning the requested page.

Solution

  • Add takers to the existing GetTradesFilters SDK filter shape.
  • Map takers into local FetchTradesArgs and push the SQL predicate into the source CTEs: take_orders.sender IN (...) and clear_v3_events.sender IN (...).
  • Add sender/time indexes for take_orders and clear_v3_events to support the new taker lookup path.
  • Add local DB getTrades fetch/count tracing with filter counts, parameter count, row/count results, and duration.
  • Add a subgraph TradeEvent_filter binding and map takers to tradeEvent_: { sender_in: [...] }.
  • Preserve the existing getTrades pagination, time, owner, order hash, orderbook, and token filter behavior.
  • Add focused tests for local SQL generation and subgraph filter mapping.

Checks

By submitting this for review, I confirm I have done the following:

  • made this PR as small as possible
  • unit-tested any new functionality
  • linked any relevant issues or PRs
  • included screenshots (if this involves a front-end change)

Additional validation run:

  • cargo fmt --all
  • nix develop -c cargo test -p rain_orderbook_common fetch_trades
  • nix develop -c cargo test -p rain_orderbook_common -p rain_orderbook_subgraph_client
  • nix develop -c cargo test --workspace

@linear
Copy link
Copy Markdown

linear Bot commented May 12, 2026

RAI-529

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 12, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: d515565c-748e-4779-aa57-456dc057d5f7

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/rai-529-add-taker-address-filters-to-raindex-gettrades-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 and usage tips.

Copy link
Copy Markdown
Collaborator Author

findolor commented May 12, 2026

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more


How to use the Graphite Merge Queue

Add the label Raindex-queue to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@findolor findolor force-pushed the feature/rai-529-add-taker-address-filters-to-raindex-gettrades-sdk branch from c621884 to 7d24eb3 Compare May 12, 2026 12:08
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