mirror of
https://github.com/luxfi/price.git
synced 2026-10-30 15:21:24 +00:00
Two defects in the default maps, both invisible because pkg/source is documented
as never imported — nothing asked it a question, so nothing noticed the answers.
KRAKEN WAS DEAD FOR EVERY MULTI-ASSET QUERY. "polygon" mapped to MATICUSD;
Polygon renamed the token and Kraken delisted that pair. Kraken's Fetch sends all
pairs in ONE request, and Kraken answers a single unknown pair with
EQuery:Unknown asset pair for the WHOLE batch — so one stale symbol returned
nothing at all, for every asset, including the fourteen it knows perfectly well.
Mapped to POLUSD, which quotes. Note this contradicts the Source contract as
written ("Tokens the source does not know about are silently dropped ... they are
not an error"): for Kraken an unknown token is fatal to the entire call, so the
map is load-bearing in a way the interface does not admit.
TON WAS ABSENT FROM BOTH MAPS while every other major was present. Added as TON
(Coinbase) and TONUSD (Kraken) — no X/Z prefix, it is not a legacy major.
Tests. TestBothVenuesCoverTheSameAssets enforces the rule defaults.go already
states and nothing checked ("Keep the two maps over the SAME key set"), because a
key in one map and not the other is a venue silently dropping an asset.
TestLiveVenuesKnowEveryAsset asks BOTH venues about EVERY id, which is the only
check that goes stale loudly — it is what caught MATICUSD, and a map is only as
true as the venue still agrees with. Guarded by PRICE_LIVE=1.
Found while evaluating this package as the estate's price source for crediting
native BTC/XRP/TON deposits.
Co-authored-by: Hanzo Dev <[email protected]>
76 lines
2.9 KiB
Go
76 lines
2.9 KiB
Go
// Copyright (C) 2020-2026, Lux Industries Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
package source
|
|
|
|
// defaults.go — the canonical ID → exchange-symbol seed maps used when a
|
|
// Source is constructed with a nil override. Keys are lowercase canonical
|
|
// asset IDs (CoinGecko convention, e.g. "bitcoin"); the lookup paths in
|
|
// coinbase.go / kraken.go lowercase the incoming ID before indexing, so
|
|
// every key here MUST be lowercase. One map per venue because the two
|
|
// exchanges name the same asset differently:
|
|
//
|
|
// - Coinbase: spot endpoint is /v2/prices/{TICKER}-USD/spot, so the
|
|
// value is the bare base ticker ("BTC").
|
|
// - Kraken: /Ticker?pair={CODE}, so the value is Kraken's bespoke pair
|
|
// code ("XXBTZUSD"); legacy majors carry the X-base/Z-quote prefixes.
|
|
//
|
|
// Keep the two maps over the SAME key set so both venues quote the same
|
|
// universe; a caller wanting more assets passes an explicit override.
|
|
|
|
// DefaultSymbolMap maps canonical asset IDs to Coinbase base tickers.
|
|
func DefaultSymbolMap() map[string]string {
|
|
return map[string]string{
|
|
"bitcoin": "BTC",
|
|
"ethereum": "ETH",
|
|
"solana": "SOL",
|
|
"cardano": "ADA",
|
|
"avalanche": "AVAX",
|
|
"polkadot": "DOT",
|
|
"chainlink": "LINK",
|
|
"litecoin": "LTC",
|
|
"bitcoin-cash": "BCH",
|
|
"ripple": "XRP",
|
|
"dogecoin": "DOGE",
|
|
"uniswap": "UNI",
|
|
"polygon": "MATIC",
|
|
"usd-coin": "USDC",
|
|
"tether": "USDT",
|
|
// TON was absent from BOTH maps while every other major was present,
|
|
// which is the kind of gap a never-imported package keeps: nothing asked
|
|
// for it, so nothing noticed. Verified live on this endpoint.
|
|
"the-open-network": "TON",
|
|
}
|
|
}
|
|
|
|
// DefaultKrakenPairs maps canonical asset IDs to Kraken USD pair codes.
|
|
func DefaultKrakenPairs() map[string]string {
|
|
return map[string]string{
|
|
"bitcoin": "XXBTZUSD",
|
|
"ethereum": "XETHZUSD",
|
|
"solana": "SOLUSD",
|
|
"cardano": "ADAUSD",
|
|
"avalanche": "AVAXUSD",
|
|
"polkadot": "DOTUSD",
|
|
"chainlink": "LINKUSD",
|
|
"litecoin": "XLTCZUSD",
|
|
"bitcoin-cash": "BCHUSD",
|
|
"ripple": "XXRPZUSD",
|
|
"dogecoin": "XDGUSD",
|
|
"uniswap": "UNIUSD",
|
|
// POL, not MATIC: Polygon renamed the token and Kraken DELISTED the old
|
|
// pair. This one stale symbol had made Kraken useless for every
|
|
// multi-asset query — its Fetch sends all pairs in ONE request, and
|
|
// Kraken answers a single unknown pair with EQuery:Unknown asset pair for
|
|
// the WHOLE batch. So it returned nothing at all, for every asset,
|
|
// including the ones it knows perfectly well.
|
|
"polygon": "POLUSD",
|
|
"usd-coin": "USDCUSD",
|
|
"tether": "USDTZUSD",
|
|
// Kraken lists TON with no X/Z prefix — it is not one of the legacy
|
|
// majors. Kept over the same key set as DefaultSymbolMap, as the doc
|
|
// above requires, so both venues quote the same universe.
|
|
"the-open-network": "TONUSD",
|
|
}
|
|
}
|