When we shipped YourPlus the flow was one screen: you say what you want to receive, you get options, you send. That part shipped a while ago and it still works. It is not the part that took the engineering.
The hard question sits one layer down: which of those options actually exist?
A catalogue is a list of tickers — DOGE, ADA, LINK, PEPE, a hundred-plus of them. But a ticker is not an asset. The same ticker on different chains is a different thing, and whether an asset is executable on a given provider at a given moment is data nobody publishes. So the aggregator's temptation is to show a spot mid-market number, call it a rate, and let the user discover the difference after the funds have left. Two to five percent between quote and arrival is the usual outcome — when the route existed at all. A "best rate" screen is a promise the exchange cannot keep.
We wanted a screen where every option is real. What follows is what that took.
What we built instead of live polling
The obvious approach is to ask every provider about everything on every request. We tried it. Polling a hundred-plus assets across the executable provider set produced stampedes, 429s, and quotes stale by the time they were drawn — and a stale quote is not a quote.
So we inverted it. Instead of the product pulling the world, the world pushes one small file once a day and the product loads it only when someone actually asks:
- a GitHub Action builds the catalogue and uploads it to a private GCS bucket;
- the Mini App loads it on the first request, then revalidates on a 24-hour TTL or on an explicit miss;
- nothing polls on a timer, which matters: Cloud Run instances freeze without traffic, so a
setIntervalis a lie about liveness; - a fallback catalogue is baked into the binary, so a cold start never has an empty screen.
Architecture: one JSON file, loaded on demand
┌─────────────┐ daily ┌──────────────┐ on request ┌──────────────┐
│ GH Actions │ ─────────────► │ GCS Bucket │ ◄────────────────── │ Cloud Run │
│ (WIF auth) │ catalog.json │ (private) │ 24h TTL / initData │ Mini App │
└─────────────┘ └──────────────┘ └──────────────┘
-
scripts/refresh-curated-pairs.tsruns daily (Workload Identity Federation → GCS, no long-lived keys) -
CuratedRouteDiscoveryAdapterloads on first request and revalidates after 24h or on explicit miss - fallback catalogue in the binary for cold starts
The rotation itself is fifteen owner-approved assets — USDT, BTC, ETH, TON, SOL, XRP, BNB, USDC, TRX, DOGE, NOT, ADA, LINK, AVAX and PEPE — posted one pair per two-hour window. The rotation is the ticker list we publish; it is not the catalogue's size, and the point of holding it at fifteen is that these are the routes we can defend rather than a hundred we cannot.
The bug that taught us what an asset actually is
ChangeNOW lists DOGE twice: doge, native Dogecoin, and dogeerc20, an ERC-20 token carrying the same ticker at a wildly different price. Our defaultReceiveNetwork("DOGE") returned ethereum. The engine then did its job flawlessly on the wrong asset — off by about three orders of magnitude — and nothing downstream was in a position to object, because a wrong-network token with the right ticker is a perfectly well-formed row.
The fix was a network map, not a special case:
- DOGE →
doge(native) - ADA →
ada(native Cardano) - AVAX →
cchain(Avalanche C-Chain) - NOT →
ton(Notcoin on TON)
It lives in src/app/address-rules.ts and src/adapters/changenow-networks.ts, and in the script that builds the catalogue. The rule we took from it: we guarantee the network, not the symbol.
The long tail needs mids, not just a price list
The product sells a plus against a baseline — roughly what the same amount would fetch on a CEX right now. That baseline needs a USD mid per asset, and it needs it for the tail, not only the majors. The COINGECKO_IDS map covered ten majors; DOGE, NOT, ADA, LINK, AVAX and PEPE were absent, which silently disabled both the baseline and the spot guard exactly where the tail lives.
// src/adapters/spot-mid.ts
export const COINGECKO_IDS: Record<string, string> = {
// ... majors ...
DOGE: "dogecoin",
NOT: "notcoin",
ADA: "cardano",
LINK: "chainlink",
AVAX: "avalanche-2",
PEPE: "pepe",
};
Two gates now run across the whole wave. In practice this is the difference between a rate claim you can check and a rate claim you decorate.
A quote engine that has to converge
For some pairs the provider has to be walked toward the answer rather than asked once. ChangeNOW's reverse estimated-amount oscillates near the provider minimum:
Iteration 0: 12.73 USDT → 94.59 DOGE (under)
Iteration 1: 13.55 USDT → 105.61 DOGE (over)
Iteration 2: 12.82 USDT → 95.80 DOGE (under)
... oscillates, never lands in ±1.5%
The interesting part is why it never converged, because it was not the probing. The engine already rejects any fill that undershoots the request by more than 1% or overshoots the ask by more than 5%. The adapter's own acceptance window was far wider than that — it treated a probe landing several percent over as a valid answer, handed it to the engine, and the engine threw the route away. The adapter then re-probed from a different angle and the cycle repeated.
Narrowing the adapter's window to [desired×0.995, desired×1.015] — strictly inside the engine's window — was the whole fix. A probe that the adapter accepts is now a probe the engine keeps:
// src/adapters/changenow-adapter.ts
if (got >= desired * 0.995 && got <= desired * 1.015) {
return { ok: true, value: outcome.value };
}
That is the general lesson of this build: two components that each have a tolerance are not compatible just because both tolerances exist. The inner one has to be narrow enough that nothing it accepts can be rejected downstream.
Results
- 15/15 curated assets executable at rotation amounts
- rotation 9 → 15 entries, one pair per two-hour window
- request-driven catalogue load with a 24h TTL and a baked-in cold-start fallback
- typecheck ✅ · 234/234 tests ✅ · build ✅
Try it: https://t.me/YourPlus_app_bot


Top comments (0)