Skip to content

Improve API performance and add v1 trades endpoints - #3

Merged
alastairong1 merged 11 commits into
mainfrom
api-improvements
Apr 5, 2026
Merged

Improve API performance and add v1 trades endpoints#3
alastairong1 merged 11 commits into
mainfrom
api-improvements

Conversation

@alastairong1

Copy link
Copy Markdown

Summary

  • add the /v1/trades endpoints and related REST API plumbing
  • batch order quote lookups per page to reduce quote RPC fan-out on /v1/orders/...
  • bring over the useful cache work from upstream PR Add in-process endpoint caching with moka ST0x-Technology/st0x.rest.api#54 for order detail and swap quote responses
  • point the deploy workflow at the larger DO host and update SSH host trust

Validation

  • nix develop -c cargo fmt --check
  • nix develop -c cargo check
  • nix develop -c cargo test
  • nix develop -c rainix-rs-static
  • benchmarked /v1/orders/token/:tokenId locally, against current prod, and on the larger DO box
  • verified GET /v1/trades/:address and GET /v1/trades/tx/:txHash on the larger DO box

Notes

  • benchmark CSV: /Users/alastairong/Desktop/orders_token_local_prod_do_xl_api_improvements_2026-04-03.csv
  • the tx-hash trades endpoint is functionally correct but still very slow and likely needs its own optimization pass

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e72328a002

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/routes/trades.rs
Comment on lines +228 to +232
let trade_results = join_all(
orders
.iter()
.map(|order| ds.get_order_trades(order, start_time, end_time)),
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Limit trade fetch fan-out to avoid upstream overload

load_trades_with_owners calls get_order_trades for every order using a single join_all, so each /v1/trades/tx/{tx_hash} request can issue one upstream request per order after fetch_all_orders scans the full registry. On deployments with many orders this creates an unbounded burst of concurrent RPC calls that can exhaust connection pools or trigger provider rate limits, causing timeouts/500s for this and other requests. Please bound concurrency (e.g., buffered stream or semaphore) when fetching per-order trades.

Useful? React with 👍 / 👎.

@alastairong1
alastairong1 merged commit 7673624 into main Apr 5, 2026
3 checks passed
@alastairong1
alastairong1 deleted the api-improvements branch April 5, 2026 15:17
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