Skip to content

feat(benchmark): add audit subcommand for on-chain quote validation#215

Open
kayibal wants to merge 1 commit into
mainfrom
feat/benchmark-audit
Open

feat(benchmark): add audit subcommand for on-chain quote validation#215
kayibal wants to merge 1 commit into
mainfrom
feat/benchmark-audit

Conversation

@kayibal
Copy link
Copy Markdown
Contributor

@kayibal kayibal commented May 28, 2026

Summary

  • Adds an audit subcommand to fynd-benchmark that fetches quotes from Fynd and external aggregators (KyberSwap, Nordstern, 0x) for a set of token pairs, then re-executes each quote on-chain via eth_simulateV1 to measure the real amount received
  • ERC-20 state-override support handles both standard Solidity mapping layouts (slots 0–20) and OpenZeppelin v5 namespaced storage
  • Native ETH output is validated by injecting a 10-byte EVM balance-reader contract into simulation state; zeroing sender balance and setting gasPrice=0 ensures the result equals ETH received exactly
  • Nordstern non-JSON pseudo-schema responses (returned for unsupported pairs) are treated as NoRoute instead of propagating as errors

🤖 Generated with Claude Code

Adds an `audit` subcommand that fetches quotes from Fynd and external
aggregators (KyberSwap, Nordstern, 0x) for a configurable set of token
pairs, then re-executes each quote on-chain via eth_simulateV1 to measure
the real amount received.

- audit.rs: simulation harness using eth_simulateV1 with state overrides
  for token balance and allowance; falls back to eth_call when the node
  does not support eth_simulateV1
- erc20.rs: storage-slot detection for standard Solidity mapping layouts
  (positions 0–20) and OpenZeppelin v5 namespaced storage
- aggregator.rs: quote clients for KyberSwap, Nordstern, and 0x;
  Nordstern non-JSON pseudo-schema responses are mapped to NoRoute
- pair_selector.rs: random pair selection from live Tycho pools
- Native ETH output is measured by injecting a 10-byte balance-reader
  contract into simulation state; zeroing sender balance and setting
  gasPrice=0 ensures the result equals ETH received exactly

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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