Skip to content

[codex] Add cached swap route preloading - #797

Merged
gemcoder21 merged 8 commits into
mainfrom
codex/swapper-route-preload
Jul 28, 2026
Merged

[codex] Add cached swap route preloading#797
gemcoder21 merged 8 commits into
mainfrom
codex/swapper-route-preload

Conversation

@gemcoder21

@gemcoder21 gemcoder21 commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add a shared expiring route-discovery cache used by EVM, Sui, and TON swap providers
  • preload Uniswap V3 factory pools and Uniswap V4 StateView pools without caching dynamic quotes
  • expose best-effort route preloading through Gemstone and trigger it when Android and iOS users select an ordered asset pair
  • reuse discovered paths during quoting while retaining live-RPC fallback behavior
  • batch all candidate-pool discovery calls into one JSON-RPC request per Uniswap-style provider
  • batch all filtered direct and intermediary quote calls into one JSON-RPC request per Uniswap-style provider
  • store V3 factories and V4 StateView addresses with their deployments and validate all deployment addresses

Why

Pool and route existence changes far less frequently than quote output. Repeating discovery calls on every quote adds avoidable node latency. Quote calls must remain live, but neither discovery nor quoting needs separate HTTP requests for each pair or route group.

Impact

Selecting a supported pair warms its route metadata before quote requests. Existing and missing fee tiers are reused to avoid quoting nonexistent pools. Quotes and liquidity-sensitive price calculations remain live.

For Smart Chain, Uniswap V3, PancakeSwap V3, and Uniswap V4 now each submit one discovery batch and one quote batch. The cold EVM path is reduced from 15 discovery requests plus 3 quote requests to 3 discovery requests plus 3 quote requests. A warm quote remains 3 live quote requests.

Validation

  • cargo test -p swapper — 265 passed
  • cargo clippy -p swapper --lib -- -D warnings
  • git diff --check
  • previous branch verification: Android swap tests/build, iOS SwapService build/tests, and mobile builds

cargo clippy -p swapper --all-targets -- -D warnings is currently blocked by two pre-existing boolean assertion warnings in thorchain/model.rs from the merged base branch.

@gemcoder21
gemcoder21 marked this pull request as ready for review July 28, 2026 23:33
@gemcoder21
gemcoder21 merged commit 3264fa5 into main Jul 28, 2026
5 checks passed
@gemcoder21
gemcoder21 deleted the codex/swapper-route-preload branch July 28, 2026 23:33
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