Skip to content

Agents quote: fix best-rate pick and TAO->BTC conversion#92

Merged
anderdc merged 1 commit into
testfrom
fix/agents-quote-rate-conversion
May 13, 2026
Merged

Agents quote: fix best-rate pick and TAO->BTC conversion#92
anderdc merged 1 commit into
testfrom
fix/agents-quote-rate-conversion

Conversation

@LandynDev
Copy link
Copy Markdown
Collaborator

Summary

  • Step 3 on /agents (RateQuoteHelper) treated counterRate as if it were "BTC per 1 TAO" and always picked the highest value as "best". Both rate and counterRate are actually in TAO per 1 BTC (canonical_dest per 1 canonical_source — see Miner model docs and allways/utils/rate.py). Result: selecting TAO->BTC at 1 TAO would display something like "1 TAO -> 324 BTC", which is the opposite of reality.
  • Fix: pick MAX rate for BTC->TAO, MIN counterRate for TAO->BTC. Compute output as btc_in * rate for forward and tao_in / counterRate for reverse. Display the effective rate (dest per source) so the units in the UI match the math.
  • Update the curl + jq snippet so its sort flips with direction (descending for forward, ascending for reverse).
  • Add a short rate-semantics note in the agent markdown bundle so LLM consumers reading GET /miners don't repeat the same misinterpretation.

No API change required — the das-allways /miners payload already carries both rates in their canonical TAO-per-BTC form (Miner.entity.ts, model docstring in allways-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 --noEmit clean (passes locally)
  • npx eslint clean on changed files (passes locally)
  • Manual: visit /agents, switch to TAO -> BTC, enter 1, verify output is a small fraction of a BTC (e.g. ~0.00309 BTC for a ~324 TAO/BTC quote) and Rate row reads BTC/TAO.
  • Manual: switch back to BTC -> TAO, enter 0.01, verify output is several TAO and Rate row reads TAO/BTC.
  • Manual: copy the curl + jq line in each direction and confirm the sort flag is -(.rate | tonumber) for forward and (.rate | tonumber) for reverse.

…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.
@xiao-xiao-mao xiao-xiao-mao Bot added the bug Something isn't working label May 13, 2026
@anderdc anderdc merged commit 2e2ae7b into test May 13, 2026
2 checks passed
@anderdc anderdc deleted the fix/agents-quote-rate-conversion branch May 13, 2026 21:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants