Agents quote: fix best-rate pick and TAO->BTC conversion#92
Merged
Conversation
…quote Both rate (BTC->TAO) and counterRate (TAO->BTC) are stored as TAO per 1 BTC, so the "best" miner flips by direction: forward picks the highest rate (most TAO out per BTC in), reverse picks the lowest counterRate (least TAO in per BTC out). The helper picked max in both cases and always multiplied amount by rate, which produced absurd outputs like "1 TAO -> 324 BTC". Display the effective rate (dest per source) and divide for the reverse leg. Update the curl + jq snippet so its sort direction matches, and add a rate-semantics note to the agent markdown so LLM consumers don't repeat the mistake.
anderdc
approved these changes
May 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
/agents(RateQuoteHelper) treatedcounterRateas if it were "BTC per 1 TAO" and always picked the highest value as "best". BothrateandcounterRateare actually in TAO per 1 BTC (canonical_dest per 1 canonical_source — seeMinermodel docs andallways/utils/rate.py). Result: selecting TAO->BTC at 1 TAO would display something like "1 TAO -> 324 BTC", which is the opposite of reality.ratefor BTC->TAO, MINcounterRatefor TAO->BTC. Compute output asbtc_in * ratefor forward andtao_in / counterRatefor reverse. Display the effective rate (dest per source) so the units in the UI match the math.GET /minersdon't repeat the same misinterpretation.No API change required — the
das-allways/minerspayload already carries both rates in their canonical TAO-per-BTC form (Miner.entity.ts, model docstring inallways-ui/src/api/models/Miners.ts), and the bug was purely in the UI's interpretation.Test plan
npm run build(passes locally)npx tsc --noEmitclean (passes locally)npx eslintclean on changed files (passes locally)/agents, switch to TAO -> BTC, enter1, verify output is a small fraction of a BTC (e.g.~0.00309 BTCfor a ~324 TAO/BTC quote) and Rate row readsBTC/TAO.0.01, verify output is several TAO and Rate row readsTAO/BTC.-(.rate | tonumber)for forward and(.rate | tonumber)for reverse.