Skip to content

feat(encoding): measure Hashflow signed quotes against price levels - #600

Open
Troshchk wants to merge 6 commits into
mainfrom
kt/rfq-simulation-label
Open

Troshchk wants to merge 6 commits into
mainfrom
kt/rfq-simulation-label

Conversation

@Troshchk

@Troshchk Troshchk commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Measures how far each Hashflow leg's signed quote lands from the price levels it was solved on.

The encoder requests each Hashflow leg's signed quote itself and keeps only the calldata. Hashflow's executor data carries the signed amounts, packed as base_token | quote_token | base_token_amount | quote_token_amount, and encode_quotes now reads them back out.

  • rfq_signed_quote_deviation_bps{protocol} records the signed rate against the price-level rate for every Hashflow leg of every encoded quote, including legs inside longer routes and gaps wide enough to revert. Negative means the maker signed for less than its levels advertised.
  • A fynd::rfq_signed_quote debug line adds the order, component, pair, and the level and signed amounts.
  • rfq_signed_quote_unread_total counts a leg whose data is not found. It is what shows the packing has changed.
  • test_encoded_hashflow_leg_carries_signed_amounts encodes a Hashflow leg through the real tycho-execution router encoder and reads the amounts back.
  • src/serve.rs gives the histogram the signed bps buckets quote_simulation_deviation_bps uses.

🤖 Generated with Claude Code

Ksenia Troshchenkova and others added 3 commits September 30, 2026 20:36
A route that is one RFQ swap executes the maker's signed quote and
nothing else, so its simulated output against the quoted output is the
gap between the price levels it was solved on and what the maker signed.
Neither metric could separate those routes from the rest.

quote_simulations_total and quote_simulation_deviation_bps now carry
rfq=none|single_leg|mixed, and the simulation outcome log carries the
same field. A gap wider than the request's slippage shows as a revert
rather than as a deviation.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The deviation histogram shows how far signed RFQ quotes land from their
price levels, but not for which pair or at what size. A successful
simulation of a single-leg RFQ route now logs its protocol, component,
token pair, amount in, the quoted and simulated amounts after fees, and
the deviation, under the fynd::simulation_outcome target.

quoted_after_fees is split out of deviation_bps so the log states the
same quoted amount the deviation compares against.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The encoder requests each Hashflow leg's signed quote itself and keeps
only the calldata, so how far the maker signs from the price levels the
leg was solved on was visible nowhere. Hashflow's executor data carries
the signed amounts, packed as base_token | quote_token |
base_token_amount | quote_token_amount, so encode_quotes now reads them
back from the encoded transaction.

- rfq_signed_quote_deviation_bps{protocol} records the signed rate
  against the price-level rate, for every Hashflow leg of every encoded
  quote, in every deployment
- a fynd::rfq_signed_quote debug line adds the order, component, pair,
  and the level and signed amounts
- rfq_signed_quote_unread_total counts a leg whose data is not found,
  which is what shows the packing has changed
- a test encodes a Hashflow leg through the real tycho-execution router
  encoder and reads the amounts back

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@Troshchk Troshchk changed the title feat(simulation): label simulation outcomes by RFQ route feat: measure RFQ signed quotes against price levels Oct 1, 2026
Ksenia Troshchenkova and others added 2 commits October 1, 2026 11:29
rfq_signed_quote_deviation_bps reads every Hashflow leg's signed quote
from the calldata, including legs inside longer routes and gaps wide
enough to revert, in every deployment. The simulation label measured
only single-swap routes, only where simulation runs, and lost every gap
that reverted, so it is removed with its log line, IndicativeSim and
quoted_after_fees.

Reverts 48ff496 and e2d8d89.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@Troshchk Troshchk changed the title feat: measure RFQ signed quotes against price levels feat(encoding): measure Hashflow signed quotes against price levels Oct 1, 2026
A route that splits a pair between Hashflow and an AMM leg holds the
pair back to back twice: a Uniswap V3 swap packs token_in | token_out |
fee | receiver. The reader took the first occurrence and read the AMM
leg's fee and address bytes as signed amounts, which recorded gaps of
billions of bps on dev.

A match now counts only when the two amounts after it fit below 2^128
and the next word is a unix time, as Hashflow's quote_expiry is;
otherwise the search moves on.

Co-Authored-By: Claude Opus 5.5 (1M context) <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