fix(tokens): split BTCB on BSC from WBTC entry (ACX-4980)#208
fix(tokens): split BTCB on BSC from WBTC entry (ACX-4980)#208droplet-rl wants to merge 1 commit into
Conversation
The BSC address listed under WBTC was BTCB (Binance-pegged BTC), which has 18 decimals on BSC — not 8 like WBTC. Consumers resolving that address picked up the WBTC entry's `decimals: 8` and miscalculated amounts by ~10^10. Mirror the existing `USDC-BNB` / `USDT-BNB` convention: drop the BSC entry from WBTC and add a separate `WBTC-BNB` entry (decimals 18, l1TokenDecimals 8) plus a `WBTC-BNB → WBTC` equivalence remapping. Closes ACX-4980.
| decimals: 18, | ||
| addresses: { | ||
| [CHAIN_IDs.BSC]: "0x7130d2A12B9BCbFAe4f2634d864A1Ee1Ce3Ead9c", | ||
| [CHAIN_IDs.MAINNET]: "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599", |
There was a problem hiding this comment.
@droplet-rl , why is mainnet included here?
There was a problem hiding this comment.
The mainnet address mirrors the existing USDC-BNB / USDT-BNB entries — each -BNB entry carries the canonical L1 (mainnet) token address alongside the BSC address.
It is the L1 reference that l1TokenDecimals: 8 and the new WBTC-BNB → WBTC equivalence remapping resolve against: the BSC BTCB token (18 decimals) maps back to canonical L1 WBTC (0x2260…C599, 8 decimals). Drop the mainnet address and there is no L1 token to remap to, so bridge/hub-pool routing that keys off the L1 token cannot resolve it.
The mainnet address being shared with the plain WBTC entry is intentional — it is exactly the "several mappings can share the same L1 token mapping" case the comment at the bottom of TOKEN_EQUIVALENCE_REMAPPING describes, which the remapping is there to handle (same as USDC/USDC-BNB, USDT/USDT-BNB).
|
Thanks for the review @0xjorgen. You had one inline question — why the tl;dr: it mirrors the existing |
Summary
The BSC address listed under the
WBTCentry insrc/tokens.tsis0x7130d2A12B9BCbFAe4f2634d864A1Ee1Ce3Ead9c, which is BTCB (Binance-Peg BTCB Token). BTCB on BSC has 18 decimals on-chain, but theWBTCentry declaresdecimals: 8. Any consumer that resolves this BSC address gets the wrong decimals and miscalculates amounts / price impact by ~10^10 — e.g. a USDC→BTCB swap was reporting a ~-9.8B swap impact.This PR follows the existing
USDC-BNB/USDT-BNBconvention for BSC tokens with mismatched decimals:WBTC.WBTC-BNBentry withdecimals: 18,l1TokenDecimals: 8, and both BSC + MAINNET addresses.WBTC-BNB → WBTCtoTOKEN_EQUIVALENCE_REMAPPING.The misplaced address was originally introduced in #128 ("feat: add support for bnb") when BNB chain support was first added.
Test plan
yarn buildsucceeds, dist reflects the new entry.yarn eslintandprettier --check src/tokens.tspass.WBTC-BNBsymbol via the equivalence remapping the same way they already handleUSDC-BNB/USDT-BNB.WBTCsymbol — they should now resolve throughWBTC-BNB.Closes ACX-4980.