@oracle-agent/oracle 0.35.49 → 0.35.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -2
- package/artifacts/specialist-packs/oracle-full-crypto.json +11 -0
- package/dist/agent-sessions.mjs +19 -19
- package/dist/artifacts/token-dashboard.mjs +1 -1
- package/dist/assets/profiles/near-agent/SOUL.md +46 -0
- package/dist/assets/profiles/near-agent/profile.json +30 -0
- package/dist/assets/profiles/oracle/SOUL.md +1 -0
- package/dist/assets/skills/oracle-desk-product/SKILL.md +1 -1
- package/dist/assets/skills/oracle-near/SKILL.md +66 -0
- package/dist/automation-plan.mjs +1 -1
- package/dist/bin/desk-server.mjs +33 -33
- package/dist/bin/oracle-data-mcp.mjs +16 -16
- package/dist/bin/oracle-gateway.mjs +3 -3
- package/dist/bin/oracle-launch-radar-shadow.mjs +3 -3
- package/dist/bin/oracle-mev-arb-shadow.mjs +4 -4
- package/dist/bin/oracle-mev-shadow.mjs +4 -4
- package/dist/bin/oracle-public-server.mjs +5 -5
- package/dist/bin/oracle-route.mjs +27 -27
- package/dist/bin/oracle-scan.mjs +3 -3
- package/dist/bin/oracle-telegram-mcp.mjs +1 -1
- package/dist/chains.mjs +1 -1
- package/dist/cli/commands/account.mjs +22 -22
- package/dist/cli/commands/agent-session.mjs +23 -23
- package/dist/cli/commands/auth.mjs +16 -15
- package/dist/cli/commands/chain.mjs +5 -5
- package/dist/cli/commands/chat.mjs +310 -228
- package/dist/cli/commands/data.mjs +37 -37
- package/dist/cli/commands/doctor.mjs +5 -5
- package/dist/cli/commands/eval.mjs +249 -167
- package/dist/cli/commands/farm.mjs +1 -1
- package/dist/cli/commands/follow.mjs +4 -4
- package/dist/cli/commands/harness.mjs +5 -5
- package/dist/cli/commands/mint.mjs +11 -11
- package/dist/cli/commands/model.mjs +313 -231
- package/dist/cli/commands/project.mjs +8 -7
- package/dist/cli/commands/quickstart.mjs +2 -2
- package/dist/cli/commands/receipt.mjs +2 -2
- package/dist/cli/commands/resolve.mjs +4 -4
- package/dist/cli/commands/session-vault.mjs +4 -4
- package/dist/cli/commands/setup.mjs +53 -52
- package/dist/cli/commands/snipe.mjs +13 -13
- package/dist/cli/commands/strategy.mjs +5 -5
- package/dist/cli/commands/swap.mjs +11 -11
- package/dist/cli/commands/telegram.mjs +7 -7
- package/dist/cli/commands/venues.mjs +1 -1
- package/dist/cli/project-access.mjs +4 -3
- package/dist/data/desk-data.mjs +31 -31
- package/dist/data/holder-table.mjs +2 -2
- package/dist/data/market-tape.mjs +1 -1
- package/dist/data/names.mjs +3 -3
- package/dist/data/providers/farming.mjs +2 -2
- package/dist/data/providers/lp-destination-discovery.mjs +4 -4
- package/dist/index.mjs +49 -49
- package/dist/launch-radar/index.mjs +5 -5
- package/dist/lp/index.mjs +4 -4
- package/dist/nft/universal-mint-router.mjs +4 -4
- package/dist/notifications/index.mjs +1 -1
- package/dist/router/index.mjs +3 -3
- package/dist/router/prepare-bridge.mjs +2 -2
- package/dist/router/prepare-route.mjs +3 -3
- package/dist/scanner/index.mjs +3 -3
- package/dist/strategy/index.mjs +4 -4
- package/dist/task.mjs +1 -1
- package/dist/teams/index.mjs +6 -6
- package/dist/telegram/chart-card.mjs +5 -5
- package/dist/telegram/market-commands.mjs +1 -1
- package/dist/tui/standalone-client.mjs +179 -97
- package/package.json +2 -2
- package/public/oracle-splash/assets/desktop-app.jpg +0 -0
- package/public/oracle-splash/docs/browser-and-web/index.html +2 -2
- package/public/oracle-splash/docs/connectors/index.html +2 -2
- package/public/oracle-splash/docs/getting-started/index.html +2 -2
- package/public/oracle-splash/docs/index.html +3 -3
- package/public/oracle-splash/docs/reference/index.html +2 -2
- package/public/oracle-splash/docs/security/index.html +2 -2
- package/public/oracle-splash/docs/using-oracle/index.html +2 -2
- package/public/oracle-splash/download/index.html +219 -5
- package/public/oracle-splash/downloads/index.html +1 -1
- package/public/oracle-splash/eval/index.html +19 -19
- package/public/oracle-splash/eval/releases/oracle-0.35.49.json +852 -0
- package/public/oracle-splash/index.html +262 -37
- package/public/oracle-splash/pricing/index.html +215 -1
- package/public/oracle-splash/security/index.html +215 -1
- package/public/oracle-splash/what-it-does/index.html +215 -1
- package/public/oracle-splash/where-it-works/index.html +215 -1
- package/server.json +2 -2
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{AsyncLocalStorage as ee}from"node:async_hooks";var pe=new ee;var Se=Object.getOwnPropertyDescriptor(AbortSignal.prototype,"aborted")?.get,xe=Object.getOwnPropertyDescriptor(AbortSignal.prototype,"reason")?.get,Ae=AbortSignal.prototype.throwIfAborted,Ie=EventTarget.prototype.addEventListener,ke=EventTarget.prototype.removeEventListener,Ce=typeof AbortSignal.any=="function"?AbortSignal.any.bind(AbortSignal):null;var Oe=64*1024,Ne=Object.freeze({depth:32,nodes:1e4,fields:1e4,arrayLength:1e4,bytes:1024*1024});var q={robinhood:{chainId:4663,name:"Robinhood Chain",rpcEnv:["RH_CHAIN_RPC"],evm:!0},ethereum:{chainId:1,name:"Ethereum",rpcEnv:["ETH_RPC_URL","ETHEREUM_RPC_URL","MAINNET_RPC_URL"],evm:!0},polygon:{chainId:137,name:"Polygon",rpcEnv:["POLYGON_RPC_URL","POLYGON_RPC"],evm:!0},arbitrum:{chainId:42161,name:"Arbitrum One",rpcEnv:["ARBITRUM_RPC_URL","ARB_RPC_URL"],evm:!0},base:{chainId:8453,name:"Base",rpcEnv:["BASE_RPC_URL"],evm:!0},hyperevm:{chainId:999,name:"HyperEVM",rpcEnv:["HYPEREVM_RPC_URL","HYPER_EVM_RPC"],evm:!0},bsc:{chainId:56,name:"BNB Smart Chain",rpcEnv:["BSC_RPC_URL","BNB_RPC_URL"],evm:!0},avalanche:{chainId:43114,name:"Avalanche C-Chain",rpcEnv:["AVALANCHE_RPC_URL","AVAX_RPC_URL"],evm:!0},optimism:{chainId:10,name:"OP Mainnet",rpcEnv:["OPTIMISM_RPC_URL","OP_RPC_URL"],evm:!0},abstract:{chainId:2741,name:"Abstract",rpcEnv:["ABSTRACT_RPC_URL","ABS_RPC_URL"],evm:!0},stable:{chainId:988,name:"Stable Mainnet",rpcEnv:["STABLE_RPC_URL","STABLE_RPC"],evm:!0}};var Pe=new Map(Object.values(q).map(e=>[e.chainId,e]));import{Interface as re,getAddress as Me}from"ethers";var je=new re(["function allowance(address owner,address spender) view returns (uint256)","function balanceOf(address account) view returns (uint256)"]);var We=Object.freeze({1:"ethereum",10:"optimism",56:"bsc",137:"polygon",8453:"base",42161:"arbitrum",43114:"avalanche",999:"hyperevm",4663:"robinhood"});var Qe=Object.freeze(["blockNumber","nativeBalance","tokenBalance","resolveToken","resolvePools","scanBlocks","scoreRisk","quote","sellSimulation","prepareUnsignedTx"]),U=Object.freeze({LIVE:"LIVE",CACHED:"CACHED",STALE:"STALE",UNKNOWN:"UNKNOWN",UNAVAILABLE:"UNAVAILABLE"}),F=Object.freeze({PASS:"PASS",CAUTION:"CAUTION",FAIL:"FAIL",UNKNOWN:"UNKNOWN"});var M=Object.freeze([{key:"ethereum",chainId:1,name:"Ethereum",rpcEnv:["ETH_RPC_URL","ETHEREUM_RPC_URL","MAINNET_RPC_URL"],nativeCurrency:{symbol:"ETH",decimals:18},explorer:"https://etherscan.io",dexscreenerSlug:"ethereum",venueKind:"uniswap-v3",wrappedNative:"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",stableQuoteAssets:["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48","0xdAC17F958D2ee523a2206206994597C13D831ec7"],venues:[{kind:"quoter",address:"0x61fFE014bA17989E743c5F6cB21bF9697530B21e",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WETH->USDC fee 500 quoted 1908.71 USDC). A contract that correctly prices a known pair IS a working V3 quoter",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:1}},{kind:"router",address:"0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode on this chain and the paired quoter at the same deployment passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:1}}]},{key:"optimism",chainId:10,name:"OP Mainnet",rpcEnv:["OPTIMISM_RPC_URL","OP_RPC_URL"],nativeCurrency:{symbol:"ETH",decimals:18},explorer:"https://optimistic.etherscan.io",dexscreenerSlug:"optimism",venueKind:"uniswap-v3",wrappedNative:"0x4200000000000000000000000000000000000006",stableQuoteAssets:["0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85","0x94b008aA00579c1307B0EF2c499aD98a8ce58e58"],venues:[{kind:"quoter",address:"0x61fFE014bA17989E743c5F6cB21bF9697530B21e",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WETH->USDC fee 500 quoted 1905.23 USDC). A contract that correctly prices a known pair IS a working V3 quoter",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:10}},{kind:"router",address:"0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode on this chain and the paired quoter at the same deployment passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:10}}]},{key:"bsc",chainId:56,name:"BNB Smart Chain",rpcEnv:["BSC_RPC_URL","BNB_RPC_URL"],nativeCurrency:{symbol:"BNB",decimals:18},explorer:"https://bscscan.com",dexscreenerSlug:"bsc",venueKind:"uniswap-v3",wrappedNative:"0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c",stableQuoteAssets:["0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d","0x55d398326f99059fF775485246999027B3197955"],venues:[{kind:"quoter",address:"0x78D78E420Da98ad378D7799bE8f4AF69033EB077",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WBNB->USDC fee 500 quoted 413.86 USDC). A contract that correctly prices a known pair IS a working V3 quoter",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:56}},{kind:"router",address:"0xB971eF87ede563556b2ED4b1C0b0019111Dd85d2",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode on this chain and the paired quoter at the same deployment passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:56}}]},{key:"polygon",chainId:137,name:"Polygon",rpcEnv:["POLYGON_RPC_URL","POLYGON_RPC"],nativeCurrency:{symbol:"POL",decimals:18},explorer:"https://polygonscan.com",dexscreenerSlug:"polygon",venueKind:"uniswap-v3",wrappedNative:"0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270",stableQuoteAssets:["0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359","0xc2132D05D31c914a87C6611C10748AEb04B58e8F"],venues:[{kind:"quoter",address:"0x61fFE014bA17989E743c5F6cB21bF9697530B21e",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WMATIC->USDC fee 500 quoted 0.0720 USDC). A contract that correctly prices a known pair IS a working V3 quoter",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:137}},{kind:"router",address:"0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode on this chain and the paired quoter at the same deployment passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:137}}]},{key:"stable",chainId:988,name:"Stable Mainnet",rpcEnv:["STABLE_RPC_URL","STABLE_RPC"],nativeCurrency:{symbol:"USDT0",decimals:18},venueKind:"uniswap-v3",wrappedNative:"0x5d442b349590a6048Eb2dC0eC346cAA5F47A9ab5",venues:[{kind:"quoter",address:"0xb070179E7032CdA868b53e6C1742F80c9e940d1A",label:"Uniswap V3 QuoterV2 (canonical)",verified:{method:"Stable is on the OFFICIAL Uniswap v3 Deployments List (governance-recognised 2026-05-12, UAC process completed 2026-04, deployed by Protofire), so this is a canonical deployment rather than a fork. eth_getCode returned 8273 bytes, the same size as the canonical quoter on the seven already-verified chains. Functional probe on a live pool (TOAST -> USDT0, fee 10000): 100 in -> 0.000003, 1000 -> 0.000031, 10000 -> 0.000319 USDT0. Output scales monotonically with input, which is a working quoter answering, not a revert. Two of three sampled pools carry non-zero liquidity. NOTE: the pools discovered so far are thin, so real routing size is limited -- the venue is proved, deep liquidity is not.",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-08-05",chainId:988}},{kind:"router",address:"0x32eaf9B5d5F2CD7361c5012890C943D7de84C22a",label:"Uniswap SwapRouter02 (canonical)",verified:{method:"eth_getCode returned 24497 bytes. Cross-checked on-chain rather than trusted from docs: router.factory() returns 0x88f0a512ef09175d456bc9547f914f48c013e4aa, the same v3 core factory that created the pools quoted above, and router.WETH9() returns the wrappedNative recorded on this chain entry. Address published in the Stable docs DEX reference and the Uniswap deployments list.",source:"docs.stable.xyz/en/reference/dexes + on-chain factory()/WETH9() round-trip",date:"2026-08-05",chainId:988}}]},{key:"hyperevm",chainId:999,name:"HyperEVM",rpcEnv:["HYPEREVM_RPC_URL","HYPER_EVM_RPC"],nativeCurrency:{symbol:"HYPE",decimals:18},dexscreenerSlug:"hyperevm",venueKind:"uniswap-v3",wrappedNative:"0x5555555555555555555555555555555555555555",venues:[{kind:"quoter",address:"0x03A918028f22D9E1473B7959C927AD7425A45C7C",label:"HyperSwap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle(1 WHYPE -> USDT0) returned live output on all four fee tiers (100: 57.3385, 500: 57.4187, 3000: 57.3237, 10000: 56.1963 USDT0). Decimals read on-chain: WHYPE 18, USDT0 6. Best tier checked against an INDEPENDENT control the same minute -- Hyperliquid allMids put HYPE at 57.3205, so the pool is 0.171% from the perp mid, which is the right shape for fee plus impact rather than a wrong contract or a decimals bug.",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-08-05",chainId:999}},{kind:"router",address:"0x4E2960a8cd19B467b82d26D83fAcb0fAE26b094D",label:"HyperSwap V3 SwapRouter",verified:{method:"eth_getCode returned 12070 bytes, and it is the router paired with the quoter proved above -- the same pair already shipped in UNI_V3_VENUES[999].hyperswap, which is the map the quote/prepare path actually routes through.",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-08-05",chainId:999}}]},{key:"abstract",chainId:2741,name:"Abstract",rpcEnv:["ABSTRACT_RPC_URL","ABS_RPC_URL"],nativeCurrency:{symbol:"ETH",decimals:18},venueKind:"uniswap-v3",wrappedNative:"0x3439153EB7AF838Ad19d56E1571FBD09333C2809",venues:[{kind:"quoter",address:"0x728BD3eC25D5EDBafebB84F3d67367Cd9EBC7693",label:"Uniswap V3 QuoterV2 (Abstract deployment)",verified:{method:"Abstract is a ZK-stack chain, so CREATE2 addresses differ and the canonical Uniswap addresses are NOT valid here -- probing them returns codesize 0, which is what previously made this chain look like it had no V3 at all. Found the real deployment from live traffic instead: scanned recent Swap(...) logs, took the busiest pool, read pool.factory() = 0xa1160e73b63f322ae88cc2d8e700833e71d0b2a1, then enumerated that factory's deployer (0xf3d63166F0Ca56C3c1A3508FcE03Ff0Cf3Fb691e) and probed each of its 56 contracts with a real quoteExactInputSingle call. Exactly one answered: 1 WETH -> 1846.475731 USDC.e at fee 500. Independent sanity check: the pool's own slot0() spot price is 1873.11 USDC.e per WETH, so the quoter sits ~1.4% below spot, the right shape for fee plus price impact on this size.",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-08-05",chainId:2741}},{kind:"router",address:"0x7712FA47387542819d4E35A23f8116C90C18767C",label:"Uniswap SwapRouter02 (Abstract deployment)",verified:{method:"eth_getCode returned 167392 bytes and the runtime contains the exactInputSingle selector. router.factory() matches the factory proved above and router.WETH9() matches the wrappedNative on this entry. Chosen over its byte-identical twin (0xfD6257F4...) because this is the address real users actually route through: it appeared as tx.to on live swaps against the WETH/USDC.e pool.",source:"on-chain factory()/WETH9() round-trip + live swap tx.to sampling",date:"2026-08-05",chainId:2741}}]},{key:"robinhood",chainId:4663,name:"Robinhood Chain",rpcEnv:["RH_CHAIN_RPC","ROBINHOOD_RPC_URL"],nativeCurrency:{symbol:"ETH",decimals:18},dexscreenerSlug:"robinhood",venueKind:"uniswap-v3",wrappedNative:"0x0bd7d308f8e1639fab988df18a8011f41eacad73",stableQuoteAssets:["0x5fc5360d0400a0fd4f2af552add042d716f1d168"],venues:[{kind:"quoter",address:"0x33e885ed0ec9bf04ecfb19341582aadcb4c8a9e7",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WETH->USDG fee 100 quoted 1866.58 USDG, and USDG->CASHCAT fee 10000 quoted a live amount). A contract that correctly prices known pairs IS a working V3 quoter",source:"live eth_call against rpc.mainnet.chain.robinhood.com",date:"2026-07-31",chainId:4663}},{kind:"router",address:"0xcaf681a66d020601342297493863e78c959e5cb2",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode (24497 bytes) on this chain and the paired quoter at the same deployment passed a live functional quote",source:"live eth_getCode against rpc.mainnet.chain.robinhood.com",date:"2026-07-31",chainId:4663}},{kind:"factory",address:"0x1f7d7550b1b028f7571e69a784071f0205fd2efa",label:"Uniswap V3 Factory",verified:{method:"eth_getCode returned real bytecode (24535 bytes) and a PoolCreated log scan over this factory returned 76 pools in ~9000 recent blocks",source:"live eth_getLogs against rpc.mainnet.chain.robinhood.com",date:"2026-07-31",chainId:4663}}]},{key:"base",chainId:8453,name:"Base",rpcEnv:["BASE_RPC_URL"],nativeCurrency:{symbol:"ETH",decimals:18},explorer:"https://basescan.org",dexscreenerSlug:"base",venueKind:"uniswap-v3",wrappedNative:"0x4200000000000000000000000000000000000006",stableQuoteAssets:["0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"],venues:[{kind:"quoter",address:"0x3d4e44Eb1374240CE5F1B871ab261CD16335B76a",label:"Uniswap V3 QuoterV2 (Base)",verified:{method:"functional probe: quoteExactInputSingle returned WETH->USDC at fee 500 = 1908.44 USDC, a live sane price. The canonical mainnet quoter address also has bytecode on Base but does NOT price this pair, which is exactly the false positive a codesize-only check accepts",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:8453}},{kind:"router",address:"0x2626664c2603336E57B271c5C0b26F421741e481",label:"Uniswap V3 SwapRouter02 (Base)",verified:{method:"eth_getCode returned real bytecode and the paired Base quoter passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:8453}},{kind:"router-v2",address:"0x4752ba5DBc23f44D87826276BF6Fd6b1C372aD24",label:"Uniswap V2 Router02 (Base)",verified:{method:"eth_getCode returned 17891 bytes; live getAmountsOut on WETH->USDC round-tripped to 98.75% (2x0.30% fee + impact)",source:"https://docs.uniswap.org/contracts/v2/reference/smart-contracts/v2-deployments",date:"2026-07-30",chainId:8453}}]},{key:"arbitrum",chainId:42161,name:"Arbitrum One",rpcEnv:["ARBITRUM_RPC_URL","ARB_RPC_URL"],nativeCurrency:{symbol:"ETH",decimals:18},explorer:"https://arbiscan.io",dexscreenerSlug:"arbitrum",venueKind:"uniswap-v3",wrappedNative:"0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",stableQuoteAssets:["0xaf88d065e77c8cC2239327C5EDb3A432268e5831","0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9"],venues:[{kind:"quoter",address:"0x61fFE014bA17989E743c5F6cB21bF9697530B21e",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WETH->USDC fee 500 quoted 1908.72 USDC). A contract that correctly prices a known pair IS a working V3 quoter",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:42161}},{kind:"router",address:"0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode on this chain and the paired quoter at the same deployment passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:42161}}]},{key:"avalanche",chainId:43114,name:"Avalanche C-Chain",rpcEnv:["AVALANCHE_RPC_URL","AVAX_RPC_URL"],nativeCurrency:{symbol:"AVAX",decimals:18},explorer:"https://snowtrace.io",dexscreenerSlug:"avalanche",venueKind:"uniswap-v3",wrappedNative:"0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7",stableQuoteAssets:["0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E"],venues:[{kind:"quoter",address:"0xbe0F5544EC67e9B3b2D979aaA43f18Fd87E6257F",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WAVAX->USDC fee 500 quoted 6.48 USDC). A contract that correctly prices a known pair IS a working V3 quoter",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:43114}},{kind:"router",address:"0xbb00FF08d01D300023C629E8fFfFcb65A5a578cE",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode on this chain and the paired quoter at the same deployment passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:43114}}]}]);import{AbiCoder as oe,Interface as j,getAddress as Mt,isAddress as jt,keccak256 as Ht}from"ethers";var Pt=300*1e3,Lt=(()=>{let e=Number(process.env.ORACLE_PREPARE_HARD_MAX_AGE_MS);return Number.isFinite(e)&&e>0?e:1800*1e3})();var Gt=oe.defaultAbiCoder();var z={1:{name:"ethereum",poolManager:"0x000000000004444c5dc75cB358380D2e3dE08A90",quoter:"0x52f0e24d1c21c8a0cb1e5a5dd6198556bd9e1203",stateView:"0x7ffe42c4a5deea5b0fec41c94c136cf115597227",universalRouter:"0x66a9893cc07d91d95644aedd05d03f95e1dba8af",weth:"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",usdc:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"},10:{name:"optimism",poolManager:"0x9a13f98cb987694c9f086b1f5eb990eea8264ec3",quoter:"0x1f3131a13296fb91c90870043742c3cdbff1a8d7",stateView:"0xc18a3169788f4f75a170290584eca6395c75ecdb",universalRouter:"0x851116d9223fabed8e56c0e6b8ad0c31d98b3507",weth:"0x4200000000000000000000000000000000000006",usdc:"0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85"},56:{name:"bsc",poolManager:"0x28e2ea090877bf75740558f6bfb36a5ffee9e9df",quoter:"0x9f75dd27d6664c475b90e105573e550ff69437b0",stateView:"0xd13dd3d6e93f276fafc9db9e6bb47c1180aee0c4",universalRouter:"0x1906c1d672b88cd1b9ac7593301ca990f94eae07",weth:"0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c",usdc:"0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d"},137:{name:"polygon",poolManager:"0x67366782805870060151383f4bbff9dab53e5cd6",quoter:"0xb3d5c3dfc3a7aebff71895a7191796bffc2c81b9",stateView:"0x5ea1bd7974c8a611cbab0bdcafcb1d9cc9b3ba5a",universalRouter:"0x1095692a6237d83c6a72f3f5efedb9a670c49223",weth:"0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270",usdc:"0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359"},8453:{name:"base",poolManager:"0x498581fF718922c3f8e6A244956aF099B2652b2b",quoter:"0x0d5e0f971ed27fbff6c2837bf31316121532048d",stateView:"0xa3c0c9b65bad0b08107aa264b0f3db444b867a71",universalRouter:"0x6ff5693b99212da76ad316178a184ab56d299b43",weth:"0x4200000000000000000000000000000000000006",usdc:"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"},42161:{name:"arbitrum",poolManager:"0x360e68faccca8ca495c1b759fd9eee466db9fb32",quoter:"0x3972c00f7ed4885e145823eb7c655375d275a1c5",stateView:"0x76fd297e2d437cd7f76d50f01afe6160f86e9990",universalRouter:"0xa51afafe0263b40edaef0df8781ea9aa03e381a3",weth:"0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",usdc:"0xaf88d065e77c8cC2239327C5EDb3A432268e5831"},43114:{name:"avalanche",poolManager:"0x06380c0e0912312b5150364b9dc4542ba0dbbc85",quoter:"0xbe40675bb704506a3c2ccfb762dcfd1e979845c2",stateView:"0xc3c9e198c735a4b97e3e683f391ccbdd60b69286",universalRouter:"0x94b75331ae8d42c1b61065089b7d48fe14aa73b7",weth:"0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7",usdc:"0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E"},4663:{name:"robinhood",poolManager:"0x8366a39cc670b4001a1121b8f6a443a643e40951",quoter:"0x8dc178efb8111bb0973dd9d722ebeff267c98f94",stateView:"0xf3334192d15450cdd385c8b70e03f9a6bd9e673b",universalRouter:"0x8876789976dEcBfCbBbe364623C63652db8C0904",weth:"0x0bd7d308f8e1639fab988df18a8011f41eacad73",usdc:"0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168"}};var Qt=new j(["function quoteExactInputSingle(((address currency0,address currency1,uint24 fee,int24 tickSpacing,address hooks) poolKey,bool zeroForOne,uint128 exactAmount,bytes hookData) params) returns (uint256 amountOut, uint256 gasEstimate)","function quoteExactOutputSingle(((address currency0,address currency1,uint24 fee,int24 tickSpacing,address hooks) poolKey,bool zeroForOne,uint128 exactAmount,bytes hookData) params) returns (uint256 amountIn, uint256 gasEstimate)"]),Xt=new j(["function execute(bytes commands,bytes[] inputs,uint256 deadline) payable"]),Yt=new j(["function getSlot0(bytes32 poolId) view returns (uint160 sqrtPriceX96,int24 tick,uint24 protocolFee,uint24 lpFee)","function getLiquidity(bytes32 poolId) view returns (uint128 liquidity)"]),Jt=Object.freeze([[13,"beforeInitialize"],[12,"afterInitialize"],[11,"beforeAddLiquidity"],[10,"afterAddLiquidity"],[9,"beforeRemoveLiquidity"],[8,"afterRemoveLiquidity"],[7,"beforeSwap"],[6,"afterSwap"],[5,"beforeDonate"],[4,"afterDonate"],[3,"beforeSwapReturnsDelta"],[2,"afterSwapReturnsDelta"],[1,"afterAddLiquidityReturnsDelta"],[0,"afterRemoveLiquidityReturnsDelta"]]),Zt=(1n<<14n)-1n;function K(e){let r=0;for(let i of e){let a=Number(i);a>=0&&(r+=a*a)}return r}var f="unknown",H="0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",N="0x0000000000000000000000000000000000000000",W=`0x${"0".repeat(64)}`,sr=Object.freeze(["eoa","pool","poolManager","router","lp","bridge","dead","contract",f]),se=Object.freeze(new Set(["pool","poolManager","router","lp","bridge","dead"])),ie=Object.freeze([N,"0x000000000000000000000000000000000000dead"]);function v(e){return String(e??"").trim().toLowerCase()}function $(e){return/^0x[0-9a-f]{40}$/.test(v(e))}function L(e){if(e==null||e===""||e===f)return null;try{if(typeof e=="bigint")return e;if(typeof e=="number")return!Number.isFinite(e)||e<0?null:BigInt(Math.trunc(e));let r=String(e).trim();return/^0x[0-9a-f]+$/i.test(r)||/^\d+$/.test(r)?BigInt(r):null}catch{return null}}function P(e,r){return r==null||r<=0n||e==null?f:Number(e*1000000n/r)/1e4}function ae(e){return Math.round(e*1e4)/1e4}function ce(e,r={}){let i=Number(e),a=new Map,p=(t,w,l)=>{let m=v(t);!$(m)||a.has(m)||a.set(m,{tag:w,tagSource:l})};for(let t of ie)p(t,"dead","known:dead");let c=z[i];c?.poolManager&&p(c.poolManager,"poolManager","config:uniswap-v4.poolManager"),c?.universalRouter&&p(c.universalRouter,"router","config:uniswap-v4.universalRouter");let u=M.find(t=>Number(t.chainId)===i);for(let t of u?.venues??[])(t.kind==="router"||t.kind==="router-v2")&&p(t.address,"router",`config:chains.config.${t.kind}`);for(let t of r.pools??[])p(t,"pool","caller:pools");for(let t of r.lps??[])p(t,"lp","caller:lps");for(let t of r.bridges??[])p(t,"bridge","caller:bridges");for(let t of r.routers??[])p(t,"router","caller:routers");for(let t of r.dead??[])p(t,"dead","caller:dead");return Object.freeze({chainId:i,chainKey:u?.key??null,known:a,hasPoolManager:!!c?.poolManager})}function G(e){let r=v(e);return/^0x0{36,}[0-9a-f]{1,4}$/.test(r)?"heuristic:zero-prefix-sink":/^0x([0-9a-f])\1{39}$/.test(r)&&r!==N?"heuristic:repeated-nibble":null}async function ue({chainId:e,token:r,address:i,reader:a,registry:p}){let c=v(i),u=p.known.get(c);if(u)return{...u};let t=null,w=!1;if(typeof a?.getCode=="function")try{t=await a.getCode({chainId:e,address:c}),w=typeof t=="string"}catch{w=!1}if(w){if(!(t!=="0x"&&t.length>4)){let s=G(c);return s?{tag:"dead",tagSource:s}:{tag:"eoa",tagSource:"getCode:empty"}}if(typeof a?.pairTokens=="function")try{let s=await a.pairTokens({chainId:e,address:c});if(Array.isArray(s)&&s.some(b=>v(b)===v(r)))return{tag:"pool",tagSource:"heuristic:pairTokens-includes-token"}}catch{}return{tag:"contract",tagSource:"getCode:bytecode"}}let l=G(c);return l?{tag:"dead",tagSource:l}:{tag:f,tagSource:"no-getCode"}}async function ir({chainId:e,token:r,reader:i,supply:a,top:p=20,known:c={}}={}){let u=Number(e);if(!Number.isInteger(u)||u<=0)throw new Error("buildHolderTable requires integer chainId");if(!$(r))throw new Error("buildHolderTable requires token address");if(!i||typeof i.holders!="function")throw new Error("buildHolderTable requires reader.holders");let t=Math.max(1,Math.min(200,Number(p)||20)),w=v(r),l=[],m=ce(u,c);m.hasPoolManager||l.push(`no Uniswap V4 PoolManager in config for chain ${u}; poolManager tag unavailable`);let s=L(a),b=s!=null?"caller":f;if(s==null&&typeof i.totalSupply=="function")try{s=L(await i.totalSupply({chainId:u,token:w,blockTag:"latest"})),s!=null&&(b="reader.totalSupply")}catch(n){l.push(`totalSupply read failed: ${String(n?.message||n).slice(0,120)}`)}s!=null&&s<=0n&&(s=null,b=f,l.push("totalSupply returned 0; treating as unknown")),s==null&&l.push("supply unknown: percentages and concentration are unknown, not zero");let o=[],x=!0;try{let n=await i.holders({chainId:u,token:w,top:t});o=Array.isArray(n)?n:Array.isArray(n?.holders)?n.holders:[],n&&typeof n=="object"&&!Array.isArray(n)&&n.complete===!1&&(x=!1,l.push("holder list incomplete (reader reported partial)"))}catch(n){x=!1,l.push(`holders read failed: ${String(n?.message||n).slice(0,120)}`)}let A=new Map;for(let n of o){let h=v(n?.address),g=L(n?.balance);!$(h)||g==null||g<=0n||A.set(h,(A.get(h)??0n)+g)}let S=[...A.entries()].sort((n,h)=>h[1]>n[1]?1:h[1]<n[1]?-1:0).slice(0,t),k=[],T=[],I=[];for(let[n,h]of S){let{tag:g,tagSource:O}=await ue({chainId:u,token:w,address:n,reader:i,registry:m}),R=O.startsWith("heuristic:"),V=se.has(g);g===f&&T.push(n),R&&I.push(n),k.push(Object.freeze({address:n,balance:h.toString(),pct:P(h,s),tag:g,tagSource:O,machine:V,heuristic:R}))}let E=f,_=f,d=f,y=f,C=!1;if(s!=null&&k.length){let n=0n,h=0n;for(let[O,R]of S)n+=R,k.find(Z=>Z.address===O)?.machine&&(h+=R);E=P(n,s),d=P(h,s),_=P(n-h,s);let g=S.map(([,O])=>Number(O*1000000n/s)/1e6);y=ae(K(g)),C=!0}return Object.freeze({ok:!0,execution:"read-only",exec:!1,chainId:u,chainKey:m.chainKey,token:w,top:t,supply:s==null?f:s.toString(),supplySource:b,holders:Object.freeze(k),headlineConcentrationPct:E,strippedConcentrationPct:_,machinesPct:d,herfindahl:y,herfindahlEstimate:C,unknown:Object.freeze(T),heuristics:Object.freeze(I),complete:x,notes:Object.freeze(l)})}function Q(e){let r=String(e??"").toLowerCase();return/^0x[0-9a-f]{64}$/.test(r)?`0x${r.slice(26)}`:null}function le(e){return Array.isArray(e)?{logs:e,complete:!0,error:null}:e&&typeof e=="object"?{logs:Array.isArray(e.logs)?e.logs:Array.isArray(e.result)?e.result:[],complete:e.complete!==!1&&!e.error,error:e.error??null}:{logs:[],complete:!1,error:"reader.getLogs returned nothing"}}async function ar({chainId:e,token:r,reader:i,fromBlock:a,toBlock:p}={}){let c=Number(e);if(!Number.isInteger(c)||c<=0)throw new Error("supplyAudit requires integer chainId");if(!$(r))throw new Error("supplyAudit requires token address");if(!Number.isInteger(a)||!Number.isInteger(p)||p<a)throw new Error("supplyAudit requires integer fromBlock <= toBlock");if(!i||typeof i.getLogs!="function")throw new Error("supplyAudit requires reader.getLogs");let u=v(r),t=[],w=async d=>{try{return le(await i.getLogs({chainId:c,address:u,topics:d,fromBlock:a,toBlock:p}))}catch(y){return{logs:[],complete:!1,error:String(y?.message||y).slice(0,160)}}},[l,m]=await Promise.all([w([H,W,null]),w([H,null,W])]);l.error&&t.push(`mint scan: ${l.error}`),m.error&&t.push(`burn scan: ${m.error}`);let s=l.complete&&m.complete;s||t.push("log scan incomplete: counts are a lower bound");let b=0n,o=0n,x=0,A=0,S=0,k=new Set,T=d=>{let y=`${d?.transactionHash??""}:${d?.logIndex??""}`;if(y!==":"&&k.has(y))return;k.add(y);let C=Array.isArray(d?.topics)?d.topics:[];if(v(C[0])!==H||C.length<3){S+=1;return}if(d?.address&&v(d.address)!==u)return;let n=Q(C[1]),h=Q(C[2]),g=L(d?.data);if(n==null||h==null||g==null){S+=1;return}n===N&&h===N||(n===N?(b+=g,x+=1):h===N&&(o+=g,A+=1))};for(let d of l.logs)T(d);for(let d of m.logs)T(d);S&&t.push(`${S} log(s) not decodable as ERC-20 Transfer (non-indexed or malformed)`);let I=b-o,E=null;if(typeof i.totalSupply=="function")try{E=L(await i.totalSupply({chainId:c,token:u,blockTag:a}))}catch(d){t.push(`totalSupply@${a} failed: ${String(d?.message||d).slice(0,120)}`)}E!=null&&E<=0n&&(E=null);let _=f;if(E!=null){let d=I<0n?-I:I,y=P(d,E);_=I<0n?-y:y}else t.push("supply at fromBlock unknown: deltaPct unknown");return Object.freeze({ok:!0,execution:"read-only",exec:!1,chainId:c,token:u,fromBlock:a,toBlock:p,mints:b.toString(),burns:o.toString(),mintCount:x,burnCount:A,netSupplyDelta:I.toString(),supplyAtFromBlock:E==null?f:E.toString(),deltaPct:_,complete:s,notes:Object.freeze(t)})}var X=3500;function Y(e){return`${e.slice(0,6)}\u2026${e.slice(-4)}`}function B(e,{estimate:r=!1}={}){if(e===f||e==null)return"unknown";let i=`${Number(e).toFixed(2)}%`;return r?`~${i}`:i}function J(e){return String(e).replaceAll("**","")}function cr(e,r={}){let i=Math.min(X,Number(r.maxChars)||X),a=r.symbol?J(r.symbol):Y(e.token),p=e.chainKey??`chain ${e.chainId}`,c=[`Holders \u2014 ${a} on ${p} (top ${e.holders.length}/${e.top})`,`Supply: ${e.supply===f?"unknown":e.supply} (${e.supplySource})`,`Top-N headline: ${B(e.headlineConcentrationPct)}`,`Machines removed: ${B(e.strippedConcentrationPct)} (machines ${B(e.machinesPct)})`,`HHI (top-N, lower bound): ${e.herfindahl===f?"unknown":`~${e.herfindahl}`}`];e.complete||c.push("Holder list incomplete.");let u=e.holders.map((o,x)=>{let A=o.heuristic?`~${o.tag}`:o.tag,S=o.machine?" [m]":"";return`${String(x+1).padStart(2," ")}. ${Y(o.address)} ${B(o.pct)} ${A}${S}`}),t=[];if(e.unknown.length&&t.push(`Unknown (no getCode evidence): ${e.unknown.length}`),e.heuristics.length&&t.push(`~ = heuristic tag, not verified identity: ${e.heuristics.length}`),r.audit){let o=r.audit;t.push(`Supply audit ${o.fromBlock}\u2192${o.toBlock}: mints ${o.mintCount} (${o.mints}), burns ${o.burnCount} (${o.burns}), net ${o.netSupplyDelta}, delta ${o.deltaPct===f?"unknown":`${o.deltaPct>0?"+":""}${Number(o.deltaPct).toFixed(2)}%`}${o.complete?"":" (partial)"}`)}for(let o of e.notes)t.push(`note: ${o}`);t.push("read-only \xB7 tags from bytecode + config, never names");let w=[...c,"",...t].join(`
|
|
2
|
-
`).length+1,l=[],m=
|
|
1
|
+
import{AsyncLocalStorage as ee}from"node:async_hooks";var pe=new ee;var Se=Object.getOwnPropertyDescriptor(AbortSignal.prototype,"aborted")?.get,xe=Object.getOwnPropertyDescriptor(AbortSignal.prototype,"reason")?.get,Ae=AbortSignal.prototype.throwIfAborted,Ie=EventTarget.prototype.addEventListener,ke=EventTarget.prototype.removeEventListener,Ce=typeof AbortSignal.any=="function"?AbortSignal.any.bind(AbortSignal):null;var Oe=64*1024,Ne=Object.freeze({depth:32,nodes:1e4,fields:1e4,arrayLength:1e4,bytes:1024*1024});var q={robinhood:{chainId:4663,name:"Robinhood Chain",rpcEnv:["RH_CHAIN_RPC"],evm:!0},ethereum:{chainId:1,name:"Ethereum",rpcEnv:["ETH_RPC_URL","ETHEREUM_RPC_URL","MAINNET_RPC_URL"],evm:!0},polygon:{chainId:137,name:"Polygon",rpcEnv:["POLYGON_RPC_URL","POLYGON_RPC"],evm:!0},arbitrum:{chainId:42161,name:"Arbitrum One",rpcEnv:["ARBITRUM_RPC_URL","ARB_RPC_URL"],evm:!0},base:{chainId:8453,name:"Base",rpcEnv:["BASE_RPC_URL"],evm:!0},hyperevm:{chainId:999,name:"HyperEVM",rpcEnv:["HYPEREVM_RPC_URL","HYPER_EVM_RPC"],evm:!0},bsc:{chainId:56,name:"BNB Smart Chain",rpcEnv:["BSC_RPC_URL","BNB_RPC_URL"],evm:!0},avalanche:{chainId:43114,name:"Avalanche C-Chain",rpcEnv:["AVALANCHE_RPC_URL","AVAX_RPC_URL"],evm:!0},optimism:{chainId:10,name:"OP Mainnet",rpcEnv:["OPTIMISM_RPC_URL","OP_RPC_URL"],evm:!0},abstract:{chainId:2741,name:"Abstract",rpcEnv:["ABSTRACT_RPC_URL","ABS_RPC_URL"],evm:!0},stable:{chainId:988,name:"Stable Mainnet",rpcEnv:["STABLE_RPC_URL","STABLE_RPC"],evm:!0},elysium:{chainId:1339,name:"Elysium",rpcEnv:["ELYSIUM_RPC_URL"],evm:!0,readOnly:!0}};var Pe=new Map(Object.values(q).map(e=>[e.chainId,e]));import{Interface as re,getAddress as Me}from"ethers";var je=new re(["function allowance(address owner,address spender) view returns (uint256)","function balanceOf(address account) view returns (uint256)"]);var We=Object.freeze({1:"ethereum",10:"optimism",56:"bsc",137:"polygon",8453:"base",42161:"arbitrum",43114:"avalanche",999:"hyperevm",4663:"robinhood"});var Qe=Object.freeze(["blockNumber","nativeBalance","tokenBalance","resolveToken","resolvePools","scanBlocks","scoreRisk","quote","sellSimulation","prepareUnsignedTx"]),U=Object.freeze({LIVE:"LIVE",CACHED:"CACHED",STALE:"STALE",UNKNOWN:"UNKNOWN",UNAVAILABLE:"UNAVAILABLE"}),F=Object.freeze({PASS:"PASS",CAUTION:"CAUTION",FAIL:"FAIL",UNKNOWN:"UNKNOWN"});var M=Object.freeze([{key:"ethereum",chainId:1,name:"Ethereum",rpcEnv:["ETH_RPC_URL","ETHEREUM_RPC_URL","MAINNET_RPC_URL"],nativeCurrency:{symbol:"ETH",decimals:18},explorer:"https://etherscan.io",dexscreenerSlug:"ethereum",venueKind:"uniswap-v3",wrappedNative:"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",stableQuoteAssets:["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48","0xdAC17F958D2ee523a2206206994597C13D831ec7"],venues:[{kind:"quoter",address:"0x61fFE014bA17989E743c5F6cB21bF9697530B21e",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WETH->USDC fee 500 quoted 1908.71 USDC). A contract that correctly prices a known pair IS a working V3 quoter",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:1}},{kind:"router",address:"0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode on this chain and the paired quoter at the same deployment passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:1}}]},{key:"optimism",chainId:10,name:"OP Mainnet",rpcEnv:["OPTIMISM_RPC_URL","OP_RPC_URL"],nativeCurrency:{symbol:"ETH",decimals:18},explorer:"https://optimistic.etherscan.io",dexscreenerSlug:"optimism",venueKind:"uniswap-v3",wrappedNative:"0x4200000000000000000000000000000000000006",stableQuoteAssets:["0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85","0x94b008aA00579c1307B0EF2c499aD98a8ce58e58"],venues:[{kind:"quoter",address:"0x61fFE014bA17989E743c5F6cB21bF9697530B21e",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WETH->USDC fee 500 quoted 1905.23 USDC). A contract that correctly prices a known pair IS a working V3 quoter",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:10}},{kind:"router",address:"0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode on this chain and the paired quoter at the same deployment passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:10}}]},{key:"bsc",chainId:56,name:"BNB Smart Chain",rpcEnv:["BSC_RPC_URL","BNB_RPC_URL"],nativeCurrency:{symbol:"BNB",decimals:18},explorer:"https://bscscan.com",dexscreenerSlug:"bsc",venueKind:"uniswap-v3",wrappedNative:"0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c",stableQuoteAssets:["0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d","0x55d398326f99059fF775485246999027B3197955"],venues:[{kind:"quoter",address:"0x78D78E420Da98ad378D7799bE8f4AF69033EB077",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WBNB->USDC fee 500 quoted 413.86 USDC). A contract that correctly prices a known pair IS a working V3 quoter",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:56}},{kind:"router",address:"0xB971eF87ede563556b2ED4b1C0b0019111Dd85d2",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode on this chain and the paired quoter at the same deployment passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:56}}]},{key:"polygon",chainId:137,name:"Polygon",rpcEnv:["POLYGON_RPC_URL","POLYGON_RPC"],nativeCurrency:{symbol:"POL",decimals:18},explorer:"https://polygonscan.com",dexscreenerSlug:"polygon",venueKind:"uniswap-v3",wrappedNative:"0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270",stableQuoteAssets:["0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359","0xc2132D05D31c914a87C6611C10748AEb04B58e8F"],venues:[{kind:"quoter",address:"0x61fFE014bA17989E743c5F6cB21bF9697530B21e",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WMATIC->USDC fee 500 quoted 0.0720 USDC). A contract that correctly prices a known pair IS a working V3 quoter",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:137}},{kind:"router",address:"0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode on this chain and the paired quoter at the same deployment passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:137}}]},{key:"stable",chainId:988,name:"Stable Mainnet",rpcEnv:["STABLE_RPC_URL","STABLE_RPC"],nativeCurrency:{symbol:"USDT0",decimals:18},venueKind:"uniswap-v3",wrappedNative:"0x5d442b349590a6048Eb2dC0eC346cAA5F47A9ab5",venues:[{kind:"quoter",address:"0xb070179E7032CdA868b53e6C1742F80c9e940d1A",label:"Uniswap V3 QuoterV2 (canonical)",verified:{method:"Stable is on the OFFICIAL Uniswap v3 Deployments List (governance-recognised 2026-05-12, UAC process completed 2026-04, deployed by Protofire), so this is a canonical deployment rather than a fork. eth_getCode returned 8273 bytes, the same size as the canonical quoter on the seven already-verified chains. Functional probe on a live pool (TOAST -> USDT0, fee 10000): 100 in -> 0.000003, 1000 -> 0.000031, 10000 -> 0.000319 USDT0. Output scales monotonically with input, which is a working quoter answering, not a revert. Two of three sampled pools carry non-zero liquidity. NOTE: the pools discovered so far are thin, so real routing size is limited -- the venue is proved, deep liquidity is not.",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-08-05",chainId:988}},{kind:"router",address:"0x32eaf9B5d5F2CD7361c5012890C943D7de84C22a",label:"Uniswap SwapRouter02 (canonical)",verified:{method:"eth_getCode returned 24497 bytes. Cross-checked on-chain rather than trusted from docs: router.factory() returns 0x88f0a512ef09175d456bc9547f914f48c013e4aa, the same v3 core factory that created the pools quoted above, and router.WETH9() returns the wrappedNative recorded on this chain entry. Address published in the Stable docs DEX reference and the Uniswap deployments list.",source:"docs.stable.xyz/en/reference/dexes + on-chain factory()/WETH9() round-trip",date:"2026-08-05",chainId:988}}]},{key:"hyperevm",chainId:999,name:"HyperEVM",rpcEnv:["HYPEREVM_RPC_URL","HYPER_EVM_RPC"],nativeCurrency:{symbol:"HYPE",decimals:18},dexscreenerSlug:"hyperevm",venueKind:"uniswap-v3",wrappedNative:"0x5555555555555555555555555555555555555555",venues:[{kind:"quoter",address:"0x03A918028f22D9E1473B7959C927AD7425A45C7C",label:"HyperSwap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle(1 WHYPE -> USDT0) returned live output on all four fee tiers (100: 57.3385, 500: 57.4187, 3000: 57.3237, 10000: 56.1963 USDT0). Decimals read on-chain: WHYPE 18, USDT0 6. Best tier checked against an INDEPENDENT control the same minute -- Hyperliquid allMids put HYPE at 57.3205, so the pool is 0.171% from the perp mid, which is the right shape for fee plus impact rather than a wrong contract or a decimals bug.",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-08-05",chainId:999}},{kind:"router",address:"0x4E2960a8cd19B467b82d26D83fAcb0fAE26b094D",label:"HyperSwap V3 SwapRouter",verified:{method:"eth_getCode returned 12070 bytes, and it is the router paired with the quoter proved above -- the same pair already shipped in UNI_V3_VENUES[999].hyperswap, which is the map the quote/prepare path actually routes through.",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-08-05",chainId:999}}]},{key:"abstract",chainId:2741,name:"Abstract",rpcEnv:["ABSTRACT_RPC_URL","ABS_RPC_URL"],nativeCurrency:{symbol:"ETH",decimals:18},venueKind:"uniswap-v3",wrappedNative:"0x3439153EB7AF838Ad19d56E1571FBD09333C2809",venues:[{kind:"quoter",address:"0x728BD3eC25D5EDBafebB84F3d67367Cd9EBC7693",label:"Uniswap V3 QuoterV2 (Abstract deployment)",verified:{method:"Abstract is a ZK-stack chain, so CREATE2 addresses differ and the canonical Uniswap addresses are NOT valid here -- probing them returns codesize 0, which is what previously made this chain look like it had no V3 at all. Found the real deployment from live traffic instead: scanned recent Swap(...) logs, took the busiest pool, read pool.factory() = 0xa1160e73b63f322ae88cc2d8e700833e71d0b2a1, then enumerated that factory's deployer (0xf3d63166F0Ca56C3c1A3508FcE03Ff0Cf3Fb691e) and probed each of its 56 contracts with a real quoteExactInputSingle call. Exactly one answered: 1 WETH -> 1846.475731 USDC.e at fee 500. Independent sanity check: the pool's own slot0() spot price is 1873.11 USDC.e per WETH, so the quoter sits ~1.4% below spot, the right shape for fee plus price impact on this size.",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-08-05",chainId:2741}},{kind:"router",address:"0x7712FA47387542819d4E35A23f8116C90C18767C",label:"Uniswap SwapRouter02 (Abstract deployment)",verified:{method:"eth_getCode returned 167392 bytes and the runtime contains the exactInputSingle selector. router.factory() matches the factory proved above and router.WETH9() matches the wrappedNative on this entry. Chosen over its byte-identical twin (0xfD6257F4...) because this is the address real users actually route through: it appeared as tx.to on live swaps against the WETH/USDC.e pool.",source:"on-chain factory()/WETH9() round-trip + live swap tx.to sampling",date:"2026-08-05",chainId:2741}}]},{key:"robinhood",chainId:4663,name:"Robinhood Chain",rpcEnv:["RH_CHAIN_RPC","ROBINHOOD_RPC_URL"],nativeCurrency:{symbol:"ETH",decimals:18},dexscreenerSlug:"robinhood",venueKind:"uniswap-v3",wrappedNative:"0x0bd7d308f8e1639fab988df18a8011f41eacad73",stableQuoteAssets:["0x5fc5360d0400a0fd4f2af552add042d716f1d168"],venues:[{kind:"quoter",address:"0x33e885ed0ec9bf04ecfb19341582aadcb4c8a9e7",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WETH->USDG fee 100 quoted 1866.58 USDG, and USDG->CASHCAT fee 10000 quoted a live amount). A contract that correctly prices known pairs IS a working V3 quoter",source:"live eth_call against rpc.mainnet.chain.robinhood.com",date:"2026-07-31",chainId:4663}},{kind:"router",address:"0xcaf681a66d020601342297493863e78c959e5cb2",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode (24497 bytes) on this chain and the paired quoter at the same deployment passed a live functional quote",source:"live eth_getCode against rpc.mainnet.chain.robinhood.com",date:"2026-07-31",chainId:4663}},{kind:"factory",address:"0x1f7d7550b1b028f7571e69a784071f0205fd2efa",label:"Uniswap V3 Factory",verified:{method:"eth_getCode returned real bytecode (24535 bytes) and a PoolCreated log scan over this factory returned 76 pools in ~9000 recent blocks",source:"live eth_getLogs against rpc.mainnet.chain.robinhood.com",date:"2026-07-31",chainId:4663}}]},{key:"base",chainId:8453,name:"Base",rpcEnv:["BASE_RPC_URL"],nativeCurrency:{symbol:"ETH",decimals:18},explorer:"https://basescan.org",dexscreenerSlug:"base",venueKind:"uniswap-v3",wrappedNative:"0x4200000000000000000000000000000000000006",stableQuoteAssets:["0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"],venues:[{kind:"quoter",address:"0x3d4e44Eb1374240CE5F1B871ab261CD16335B76a",label:"Uniswap V3 QuoterV2 (Base)",verified:{method:"functional probe: quoteExactInputSingle returned WETH->USDC at fee 500 = 1908.44 USDC, a live sane price. The canonical mainnet quoter address also has bytecode on Base but does NOT price this pair, which is exactly the false positive a codesize-only check accepts",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:8453}},{kind:"router",address:"0x2626664c2603336E57B271c5C0b26F421741e481",label:"Uniswap V3 SwapRouter02 (Base)",verified:{method:"eth_getCode returned real bytecode and the paired Base quoter passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:8453}},{kind:"router-v2",address:"0x4752ba5DBc23f44D87826276BF6Fd6b1C372aD24",label:"Uniswap V2 Router02 (Base)",verified:{method:"eth_getCode returned 17891 bytes; live getAmountsOut on WETH->USDC round-tripped to 98.75% (2x0.30% fee + impact)",source:"https://docs.uniswap.org/contracts/v2/reference/smart-contracts/v2-deployments",date:"2026-07-30",chainId:8453}}]},{key:"arbitrum",chainId:42161,name:"Arbitrum One",rpcEnv:["ARBITRUM_RPC_URL","ARB_RPC_URL"],nativeCurrency:{symbol:"ETH",decimals:18},explorer:"https://arbiscan.io",dexscreenerSlug:"arbitrum",venueKind:"uniswap-v3",wrappedNative:"0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",stableQuoteAssets:["0xaf88d065e77c8cC2239327C5EDb3A432268e5831","0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9"],venues:[{kind:"quoter",address:"0x61fFE014bA17989E743c5F6cB21bF9697530B21e",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WETH->USDC fee 500 quoted 1908.72 USDC). A contract that correctly prices a known pair IS a working V3 quoter",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:42161}},{kind:"router",address:"0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode on this chain and the paired quoter at the same deployment passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:42161}}]},{key:"avalanche",chainId:43114,name:"Avalanche C-Chain",rpcEnv:["AVALANCHE_RPC_URL","AVAX_RPC_URL"],nativeCurrency:{symbol:"AVAX",decimals:18},explorer:"https://snowtrace.io",dexscreenerSlug:"avalanche",venueKind:"uniswap-v3",wrappedNative:"0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7",stableQuoteAssets:["0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E"],venues:[{kind:"quoter",address:"0xbe0F5544EC67e9B3b2D979aaA43f18Fd87E6257F",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WAVAX->USDC fee 500 quoted 6.48 USDC). A contract that correctly prices a known pair IS a working V3 quoter",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:43114}},{kind:"router",address:"0xbb00FF08d01D300023C629E8fFfFcb65A5a578cE",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode on this chain and the paired quoter at the same deployment passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:43114}}]}]);import{AbiCoder as oe,Interface as j,getAddress as Mt,isAddress as jt,keccak256 as Ht}from"ethers";var Pt=300*1e3,Lt=(()=>{let e=Number(process.env.ORACLE_PREPARE_HARD_MAX_AGE_MS);return Number.isFinite(e)&&e>0?e:1800*1e3})();var Gt=oe.defaultAbiCoder();var z={1:{name:"ethereum",poolManager:"0x000000000004444c5dc75cB358380D2e3dE08A90",quoter:"0x52f0e24d1c21c8a0cb1e5a5dd6198556bd9e1203",stateView:"0x7ffe42c4a5deea5b0fec41c94c136cf115597227",universalRouter:"0x66a9893cc07d91d95644aedd05d03f95e1dba8af",weth:"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",usdc:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"},10:{name:"optimism",poolManager:"0x9a13f98cb987694c9f086b1f5eb990eea8264ec3",quoter:"0x1f3131a13296fb91c90870043742c3cdbff1a8d7",stateView:"0xc18a3169788f4f75a170290584eca6395c75ecdb",universalRouter:"0x851116d9223fabed8e56c0e6b8ad0c31d98b3507",weth:"0x4200000000000000000000000000000000000006",usdc:"0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85"},56:{name:"bsc",poolManager:"0x28e2ea090877bf75740558f6bfb36a5ffee9e9df",quoter:"0x9f75dd27d6664c475b90e105573e550ff69437b0",stateView:"0xd13dd3d6e93f276fafc9db9e6bb47c1180aee0c4",universalRouter:"0x1906c1d672b88cd1b9ac7593301ca990f94eae07",weth:"0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c",usdc:"0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d"},137:{name:"polygon",poolManager:"0x67366782805870060151383f4bbff9dab53e5cd6",quoter:"0xb3d5c3dfc3a7aebff71895a7191796bffc2c81b9",stateView:"0x5ea1bd7974c8a611cbab0bdcafcb1d9cc9b3ba5a",universalRouter:"0x1095692a6237d83c6a72f3f5efedb9a670c49223",weth:"0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270",usdc:"0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359"},8453:{name:"base",poolManager:"0x498581fF718922c3f8e6A244956aF099B2652b2b",quoter:"0x0d5e0f971ed27fbff6c2837bf31316121532048d",stateView:"0xa3c0c9b65bad0b08107aa264b0f3db444b867a71",universalRouter:"0x6ff5693b99212da76ad316178a184ab56d299b43",weth:"0x4200000000000000000000000000000000000006",usdc:"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"},42161:{name:"arbitrum",poolManager:"0x360e68faccca8ca495c1b759fd9eee466db9fb32",quoter:"0x3972c00f7ed4885e145823eb7c655375d275a1c5",stateView:"0x76fd297e2d437cd7f76d50f01afe6160f86e9990",universalRouter:"0xa51afafe0263b40edaef0df8781ea9aa03e381a3",weth:"0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",usdc:"0xaf88d065e77c8cC2239327C5EDb3A432268e5831"},43114:{name:"avalanche",poolManager:"0x06380c0e0912312b5150364b9dc4542ba0dbbc85",quoter:"0xbe40675bb704506a3c2ccfb762dcfd1e979845c2",stateView:"0xc3c9e198c735a4b97e3e683f391ccbdd60b69286",universalRouter:"0x94b75331ae8d42c1b61065089b7d48fe14aa73b7",weth:"0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7",usdc:"0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E"},4663:{name:"robinhood",poolManager:"0x8366a39cc670b4001a1121b8f6a443a643e40951",quoter:"0x8dc178efb8111bb0973dd9d722ebeff267c98f94",stateView:"0xf3334192d15450cdd385c8b70e03f9a6bd9e673b",universalRouter:"0x8876789976dEcBfCbBbe364623C63652db8C0904",weth:"0x0bd7d308f8e1639fab988df18a8011f41eacad73",usdc:"0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168"}};var Qt=new j(["function quoteExactInputSingle(((address currency0,address currency1,uint24 fee,int24 tickSpacing,address hooks) poolKey,bool zeroForOne,uint128 exactAmount,bytes hookData) params) returns (uint256 amountOut, uint256 gasEstimate)","function quoteExactOutputSingle(((address currency0,address currency1,uint24 fee,int24 tickSpacing,address hooks) poolKey,bool zeroForOne,uint128 exactAmount,bytes hookData) params) returns (uint256 amountIn, uint256 gasEstimate)"]),Xt=new j(["function execute(bytes commands,bytes[] inputs,uint256 deadline) payable"]),Yt=new j(["function getSlot0(bytes32 poolId) view returns (uint160 sqrtPriceX96,int24 tick,uint24 protocolFee,uint24 lpFee)","function getLiquidity(bytes32 poolId) view returns (uint128 liquidity)"]),Jt=Object.freeze([[13,"beforeInitialize"],[12,"afterInitialize"],[11,"beforeAddLiquidity"],[10,"afterAddLiquidity"],[9,"beforeRemoveLiquidity"],[8,"afterRemoveLiquidity"],[7,"beforeSwap"],[6,"afterSwap"],[5,"beforeDonate"],[4,"afterDonate"],[3,"beforeSwapReturnsDelta"],[2,"afterSwapReturnsDelta"],[1,"afterAddLiquidityReturnsDelta"],[0,"afterRemoveLiquidityReturnsDelta"]]),Zt=(1n<<14n)-1n;function K(e){let r=0;for(let i of e){let a=Number(i);a>=0&&(r+=a*a)}return r}var f="unknown",H="0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",N="0x0000000000000000000000000000000000000000",W=`0x${"0".repeat(64)}`,sr=Object.freeze(["eoa","pool","poolManager","router","lp","bridge","dead","contract",f]),se=Object.freeze(new Set(["pool","poolManager","router","lp","bridge","dead"])),ie=Object.freeze([N,"0x000000000000000000000000000000000000dead"]);function v(e){return String(e??"").trim().toLowerCase()}function B(e){return/^0x[0-9a-f]{40}$/.test(v(e))}function L(e){if(e==null||e===""||e===f)return null;try{if(typeof e=="bigint")return e;if(typeof e=="number")return!Number.isFinite(e)||e<0?null:BigInt(Math.trunc(e));let r=String(e).trim();return/^0x[0-9a-f]+$/i.test(r)||/^\d+$/.test(r)?BigInt(r):null}catch{return null}}function P(e,r){return r==null||r<=0n||e==null?f:Number(e*1000000n/r)/1e4}function ae(e){return Math.round(e*1e4)/1e4}function ce(e,r={}){let i=Number(e),a=new Map,p=(t,g,l)=>{let m=v(t);!B(m)||a.has(m)||a.set(m,{tag:g,tagSource:l})};for(let t of ie)p(t,"dead","known:dead");let c=z[i];c?.poolManager&&p(c.poolManager,"poolManager","config:uniswap-v4.poolManager"),c?.universalRouter&&p(c.universalRouter,"router","config:uniswap-v4.universalRouter");let u=M.find(t=>Number(t.chainId)===i);for(let t of u?.venues??[])(t.kind==="router"||t.kind==="router-v2")&&p(t.address,"router",`config:chains.config.${t.kind}`);for(let t of r.pools??[])p(t,"pool","caller:pools");for(let t of r.lps??[])p(t,"lp","caller:lps");for(let t of r.bridges??[])p(t,"bridge","caller:bridges");for(let t of r.routers??[])p(t,"router","caller:routers");for(let t of r.dead??[])p(t,"dead","caller:dead");return Object.freeze({chainId:i,chainKey:u?.key??null,known:a,hasPoolManager:!!c?.poolManager})}function G(e){let r=v(e);return/^0x0{36,}[0-9a-f]{1,4}$/.test(r)?"heuristic:zero-prefix-sink":/^0x([0-9a-f])\1{39}$/.test(r)&&r!==N?"heuristic:repeated-nibble":null}async function ue({chainId:e,token:r,address:i,reader:a,registry:p}){let c=v(i),u=p.known.get(c);if(u)return{...u};let t=null,g=!1;if(typeof a?.getCode=="function")try{t=await a.getCode({chainId:e,address:c}),g=typeof t=="string"}catch{g=!1}if(g){if(!(t!=="0x"&&t.length>4)){let s=G(c);return s?{tag:"dead",tagSource:s}:{tag:"eoa",tagSource:"getCode:empty"}}if(typeof a?.pairTokens=="function")try{let s=await a.pairTokens({chainId:e,address:c});if(Array.isArray(s)&&s.some(b=>v(b)===v(r)))return{tag:"pool",tagSource:"heuristic:pairTokens-includes-token"}}catch{}return{tag:"contract",tagSource:"getCode:bytecode"}}let l=G(c);return l?{tag:"dead",tagSource:l}:{tag:f,tagSource:"no-getCode"}}async function ir({chainId:e,token:r,reader:i,supply:a,top:p=20,known:c={}}={}){let u=Number(e);if(!Number.isInteger(u)||u<=0)throw new Error("buildHolderTable requires integer chainId");if(!B(r))throw new Error("buildHolderTable requires token address");if(!i||typeof i.holders!="function")throw new Error("buildHolderTable requires reader.holders");let t=Math.max(1,Math.min(200,Number(p)||20)),g=v(r),l=[],m=ce(u,c);m.hasPoolManager||l.push(`no Uniswap V4 PoolManager in config for chain ${u}; poolManager tag unavailable`);let s=L(a),b=s!=null?"caller":f;if(s==null&&typeof i.totalSupply=="function")try{s=L(await i.totalSupply({chainId:u,token:g,blockTag:"latest"})),s!=null&&(b="reader.totalSupply")}catch(n){l.push(`totalSupply read failed: ${String(n?.message||n).slice(0,120)}`)}s!=null&&s<=0n&&(s=null,b=f,l.push("totalSupply returned 0; treating as unknown")),s==null&&l.push("supply unknown: percentages and concentration are unknown, not zero");let o=[],x=!0;try{let n=await i.holders({chainId:u,token:g,top:t});o=Array.isArray(n)?n:Array.isArray(n?.holders)?n.holders:[],n&&typeof n=="object"&&!Array.isArray(n)&&n.complete===!1&&(x=!1,l.push("holder list incomplete (reader reported partial)"))}catch(n){x=!1,l.push(`holders read failed: ${String(n?.message||n).slice(0,120)}`)}let A=new Map;for(let n of o){let h=v(n?.address),w=L(n?.balance);!B(h)||w==null||w<=0n||A.set(h,(A.get(h)??0n)+w)}let S=[...A.entries()].sort((n,h)=>h[1]>n[1]?1:h[1]<n[1]?-1:0).slice(0,t),k=[],T=[],I=[];for(let[n,h]of S){let{tag:w,tagSource:O}=await ue({chainId:u,token:g,address:n,reader:i,registry:m}),R=O.startsWith("heuristic:"),V=se.has(w);w===f&&T.push(n),R&&I.push(n),k.push(Object.freeze({address:n,balance:h.toString(),pct:P(h,s),tag:w,tagSource:O,machine:V,heuristic:R}))}let E=f,_=f,d=f,y=f,C=!1;if(s!=null&&k.length){let n=0n,h=0n;for(let[O,R]of S)n+=R,k.find(Z=>Z.address===O)?.machine&&(h+=R);E=P(n,s),d=P(h,s),_=P(n-h,s);let w=S.map(([,O])=>Number(O*1000000n/s)/1e6);y=ae(K(w)),C=!0}return Object.freeze({ok:!0,execution:"read-only",exec:!1,chainId:u,chainKey:m.chainKey,token:g,top:t,supply:s==null?f:s.toString(),supplySource:b,holders:Object.freeze(k),headlineConcentrationPct:E,strippedConcentrationPct:_,machinesPct:d,herfindahl:y,herfindahlEstimate:C,unknown:Object.freeze(T),heuristics:Object.freeze(I),complete:x,notes:Object.freeze(l)})}function Q(e){let r=String(e??"").toLowerCase();return/^0x[0-9a-f]{64}$/.test(r)?`0x${r.slice(26)}`:null}function le(e){return Array.isArray(e)?{logs:e,complete:!0,error:null}:e&&typeof e=="object"?{logs:Array.isArray(e.logs)?e.logs:Array.isArray(e.result)?e.result:[],complete:e.complete!==!1&&!e.error,error:e.error??null}:{logs:[],complete:!1,error:"reader.getLogs returned nothing"}}async function ar({chainId:e,token:r,reader:i,fromBlock:a,toBlock:p}={}){let c=Number(e);if(!Number.isInteger(c)||c<=0)throw new Error("supplyAudit requires integer chainId");if(!B(r))throw new Error("supplyAudit requires token address");if(!Number.isInteger(a)||!Number.isInteger(p)||p<a)throw new Error("supplyAudit requires integer fromBlock <= toBlock");if(!i||typeof i.getLogs!="function")throw new Error("supplyAudit requires reader.getLogs");let u=v(r),t=[],g=async d=>{try{return le(await i.getLogs({chainId:c,address:u,topics:d,fromBlock:a,toBlock:p}))}catch(y){return{logs:[],complete:!1,error:String(y?.message||y).slice(0,160)}}},[l,m]=await Promise.all([g([H,W,null]),g([H,null,W])]);l.error&&t.push(`mint scan: ${l.error}`),m.error&&t.push(`burn scan: ${m.error}`);let s=l.complete&&m.complete;s||t.push("log scan incomplete: counts are a lower bound");let b=0n,o=0n,x=0,A=0,S=0,k=new Set,T=d=>{let y=`${d?.transactionHash??""}:${d?.logIndex??""}`;if(y!==":"&&k.has(y))return;k.add(y);let C=Array.isArray(d?.topics)?d.topics:[];if(v(C[0])!==H||C.length<3){S+=1;return}if(d?.address&&v(d.address)!==u)return;let n=Q(C[1]),h=Q(C[2]),w=L(d?.data);if(n==null||h==null||w==null){S+=1;return}n===N&&h===N||(n===N?(b+=w,x+=1):h===N&&(o+=w,A+=1))};for(let d of l.logs)T(d);for(let d of m.logs)T(d);S&&t.push(`${S} log(s) not decodable as ERC-20 Transfer (non-indexed or malformed)`);let I=b-o,E=null;if(typeof i.totalSupply=="function")try{E=L(await i.totalSupply({chainId:c,token:u,blockTag:a}))}catch(d){t.push(`totalSupply@${a} failed: ${String(d?.message||d).slice(0,120)}`)}E!=null&&E<=0n&&(E=null);let _=f;if(E!=null){let d=I<0n?-I:I,y=P(d,E);_=I<0n?-y:y}else t.push("supply at fromBlock unknown: deltaPct unknown");return Object.freeze({ok:!0,execution:"read-only",exec:!1,chainId:c,token:u,fromBlock:a,toBlock:p,mints:b.toString(),burns:o.toString(),mintCount:x,burnCount:A,netSupplyDelta:I.toString(),supplyAtFromBlock:E==null?f:E.toString(),deltaPct:_,complete:s,notes:Object.freeze(t)})}var X=3500;function Y(e){return`${e.slice(0,6)}\u2026${e.slice(-4)}`}function $(e,{estimate:r=!1}={}){if(e===f||e==null)return"unknown";let i=`${Number(e).toFixed(2)}%`;return r?`~${i}`:i}function J(e){return String(e).replaceAll("**","")}function cr(e,r={}){let i=Math.min(X,Number(r.maxChars)||X),a=r.symbol?J(r.symbol):Y(e.token),p=e.chainKey??`chain ${e.chainId}`,c=[`Holders \u2014 ${a} on ${p} (top ${e.holders.length}/${e.top})`,`Supply: ${e.supply===f?"unknown":e.supply} (${e.supplySource})`,`Top-N headline: ${$(e.headlineConcentrationPct)}`,`Machines removed: ${$(e.strippedConcentrationPct)} (machines ${$(e.machinesPct)})`,`HHI (top-N, lower bound): ${e.herfindahl===f?"unknown":`~${e.herfindahl}`}`];e.complete||c.push("Holder list incomplete.");let u=e.holders.map((o,x)=>{let A=o.heuristic?`~${o.tag}`:o.tag,S=o.machine?" [m]":"";return`${String(x+1).padStart(2," ")}. ${Y(o.address)} ${$(o.pct)} ${A}${S}`}),t=[];if(e.unknown.length&&t.push(`Unknown (no getCode evidence): ${e.unknown.length}`),e.heuristics.length&&t.push(`~ = heuristic tag, not verified identity: ${e.heuristics.length}`),r.audit){let o=r.audit;t.push(`Supply audit ${o.fromBlock}\u2192${o.toBlock}: mints ${o.mintCount} (${o.mints}), burns ${o.burnCount} (${o.burns}), net ${o.netSupplyDelta}, delta ${o.deltaPct===f?"unknown":`${o.deltaPct>0?"+":""}${Number(o.deltaPct).toFixed(2)}%`}${o.complete?"":" (partial)"}`)}for(let o of e.notes)t.push(`note: ${o}`);t.push("read-only \xB7 tags from bytecode + config, never names");let g=[...c,"",...t].join(`
|
|
2
|
+
`).length+1,l=[],m=g,s=0;for(let o of u){if(m+o.length+1>i-24){s+=1;continue}l.push(o),m+=o.length+1}s&&l.push(`\u2026+${s} more`);let b=[...c,...l,"",...t].join(`
|
|
3
3
|
`);return b=J(b),b.length>i&&(b=`${b.slice(0,i-1)}\u2026`),b}export{ie as DEAD_ADDRESSES,sr as HOLDER_TAGS,se as MACHINE_TAGS,X as TELEGRAM_MAX,H as TRANSFER_TOPIC,f as UNKNOWN,ir as buildHolderTable,ce as machineRegistry,cr as renderHolderTable,ar as supplyAudit};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var ce=Object.freeze(["blockNumber","nativeBalance","tokenBalance","resolveToken","resolvePools","scanBlocks","scoreRisk","quote","sellSimulation","prepareUnsignedTx"]),g=Object.freeze({LIVE:"LIVE",CACHED:"CACHED",STALE:"STALE",UNKNOWN:"UNKNOWN",UNAVAILABLE:"UNAVAILABLE"}),v=Object.freeze({PASS:"PASS",CAUTION:"CAUTION",FAIL:"FAIL",UNKNOWN:"UNKNOWN"});var $=new Map;function I(e){return $.get(Number(e))||null}import{AsyncLocalStorage as H}from"node:async_hooks";var de=new H;var Ee=Object.getOwnPropertyDescriptor(AbortSignal.prototype,"aborted")?.get,Se=Object.getOwnPropertyDescriptor(AbortSignal.prototype,"reason")?.get,xe=AbortSignal.prototype.throwIfAborted,Ae=EventTarget.prototype.addEventListener,Te=EventTarget.prototype.removeEventListener,Ce=typeof AbortSignal.any=="function"?AbortSignal.any.bind(AbortSignal):null;var Ie=64*1024,ke=Object.freeze({depth:32,nodes:1e4,fields:1e4,arrayLength:1e4,bytes:1024*1024});var E={robinhood:{chainId:4663,name:"Robinhood Chain",rpcEnv:["RH_CHAIN_RPC"],evm:!0},ethereum:{chainId:1,name:"Ethereum",rpcEnv:["ETH_RPC_URL","ETHEREUM_RPC_URL","MAINNET_RPC_URL"],evm:!0},polygon:{chainId:137,name:"Polygon",rpcEnv:["POLYGON_RPC_URL","POLYGON_RPC"],evm:!0},arbitrum:{chainId:42161,name:"Arbitrum One",rpcEnv:["ARBITRUM_RPC_URL","ARB_RPC_URL"],evm:!0},base:{chainId:8453,name:"Base",rpcEnv:["BASE_RPC_URL"],evm:!0},hyperevm:{chainId:999,name:"HyperEVM",rpcEnv:["HYPEREVM_RPC_URL","HYPER_EVM_RPC"],evm:!0},bsc:{chainId:56,name:"BNB Smart Chain",rpcEnv:["BSC_RPC_URL","BNB_RPC_URL"],evm:!0},avalanche:{chainId:43114,name:"Avalanche C-Chain",rpcEnv:["AVALANCHE_RPC_URL","AVAX_RPC_URL"],evm:!0},optimism:{chainId:10,name:"OP Mainnet",rpcEnv:["OPTIMISM_RPC_URL","OP_RPC_URL"],evm:!0},abstract:{chainId:2741,name:"Abstract",rpcEnv:["ABSTRACT_RPC_URL","ABS_RPC_URL"],evm:!0},stable:{chainId:988,name:"Stable Mainnet",rpcEnv:["STABLE_RPC_URL","STABLE_RPC"],evm:!0}};var _e=new Map(Object.values(E).map(e=>[e.chainId,e]));import{Interface as j,getAddress as $e}from"ethers";var He=new j(["function allowance(address owner,address spender) view returns (uint256)","function balanceOf(address account) view returns (uint256)"]);var We=Object.freeze({1:"ethereum",10:"optimism",56:"bsc",137:"polygon",8453:"base",42161:"arbitrum",43114:"avalanche",999:"hyperevm",4663:"robinhood"});var S=Object.freeze([{key:"ethereum",chainId:1,name:"Ethereum",rpcEnv:["ETH_RPC_URL","ETHEREUM_RPC_URL","MAINNET_RPC_URL"],nativeCurrency:{symbol:"ETH",decimals:18},explorer:"https://etherscan.io",dexscreenerSlug:"ethereum",venueKind:"uniswap-v3",wrappedNative:"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",stableQuoteAssets:["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48","0xdAC17F958D2ee523a2206206994597C13D831ec7"],venues:[{kind:"quoter",address:"0x61fFE014bA17989E743c5F6cB21bF9697530B21e",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WETH->USDC fee 500 quoted 1908.71 USDC). A contract that correctly prices a known pair IS a working V3 quoter",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:1}},{kind:"router",address:"0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode on this chain and the paired quoter at the same deployment passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:1}}]},{key:"optimism",chainId:10,name:"OP Mainnet",rpcEnv:["OPTIMISM_RPC_URL","OP_RPC_URL"],nativeCurrency:{symbol:"ETH",decimals:18},explorer:"https://optimistic.etherscan.io",dexscreenerSlug:"optimism",venueKind:"uniswap-v3",wrappedNative:"0x4200000000000000000000000000000000000006",stableQuoteAssets:["0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85","0x94b008aA00579c1307B0EF2c499aD98a8ce58e58"],venues:[{kind:"quoter",address:"0x61fFE014bA17989E743c5F6cB21bF9697530B21e",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WETH->USDC fee 500 quoted 1905.23 USDC). A contract that correctly prices a known pair IS a working V3 quoter",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:10}},{kind:"router",address:"0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode on this chain and the paired quoter at the same deployment passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:10}}]},{key:"bsc",chainId:56,name:"BNB Smart Chain",rpcEnv:["BSC_RPC_URL","BNB_RPC_URL"],nativeCurrency:{symbol:"BNB",decimals:18},explorer:"https://bscscan.com",dexscreenerSlug:"bsc",venueKind:"uniswap-v3",wrappedNative:"0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c",stableQuoteAssets:["0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d","0x55d398326f99059fF775485246999027B3197955"],venues:[{kind:"quoter",address:"0x78D78E420Da98ad378D7799bE8f4AF69033EB077",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WBNB->USDC fee 500 quoted 413.86 USDC). A contract that correctly prices a known pair IS a working V3 quoter",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:56}},{kind:"router",address:"0xB971eF87ede563556b2ED4b1C0b0019111Dd85d2",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode on this chain and the paired quoter at the same deployment passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:56}}]},{key:"polygon",chainId:137,name:"Polygon",rpcEnv:["POLYGON_RPC_URL","POLYGON_RPC"],nativeCurrency:{symbol:"POL",decimals:18},explorer:"https://polygonscan.com",dexscreenerSlug:"polygon",venueKind:"uniswap-v3",wrappedNative:"0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270",stableQuoteAssets:["0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359","0xc2132D05D31c914a87C6611C10748AEb04B58e8F"],venues:[{kind:"quoter",address:"0x61fFE014bA17989E743c5F6cB21bF9697530B21e",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WMATIC->USDC fee 500 quoted 0.0720 USDC). A contract that correctly prices a known pair IS a working V3 quoter",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:137}},{kind:"router",address:"0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode on this chain and the paired quoter at the same deployment passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:137}}]},{key:"stable",chainId:988,name:"Stable Mainnet",rpcEnv:["STABLE_RPC_URL","STABLE_RPC"],nativeCurrency:{symbol:"USDT0",decimals:18},venueKind:"uniswap-v3",wrappedNative:"0x5d442b349590a6048Eb2dC0eC346cAA5F47A9ab5",venues:[{kind:"quoter",address:"0xb070179E7032CdA868b53e6C1742F80c9e940d1A",label:"Uniswap V3 QuoterV2 (canonical)",verified:{method:"Stable is on the OFFICIAL Uniswap v3 Deployments List (governance-recognised 2026-05-12, UAC process completed 2026-04, deployed by Protofire), so this is a canonical deployment rather than a fork. eth_getCode returned 8273 bytes, the same size as the canonical quoter on the seven already-verified chains. Functional probe on a live pool (TOAST -> USDT0, fee 10000): 100 in -> 0.000003, 1000 -> 0.000031, 10000 -> 0.000319 USDT0. Output scales monotonically with input, which is a working quoter answering, not a revert. Two of three sampled pools carry non-zero liquidity. NOTE: the pools discovered so far are thin, so real routing size is limited -- the venue is proved, deep liquidity is not.",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-08-05",chainId:988}},{kind:"router",address:"0x32eaf9B5d5F2CD7361c5012890C943D7de84C22a",label:"Uniswap SwapRouter02 (canonical)",verified:{method:"eth_getCode returned 24497 bytes. Cross-checked on-chain rather than trusted from docs: router.factory() returns 0x88f0a512ef09175d456bc9547f914f48c013e4aa, the same v3 core factory that created the pools quoted above, and router.WETH9() returns the wrappedNative recorded on this chain entry. Address published in the Stable docs DEX reference and the Uniswap deployments list.",source:"docs.stable.xyz/en/reference/dexes + on-chain factory()/WETH9() round-trip",date:"2026-08-05",chainId:988}}]},{key:"hyperevm",chainId:999,name:"HyperEVM",rpcEnv:["HYPEREVM_RPC_URL","HYPER_EVM_RPC"],nativeCurrency:{symbol:"HYPE",decimals:18},dexscreenerSlug:"hyperevm",venueKind:"uniswap-v3",wrappedNative:"0x5555555555555555555555555555555555555555",venues:[{kind:"quoter",address:"0x03A918028f22D9E1473B7959C927AD7425A45C7C",label:"HyperSwap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle(1 WHYPE -> USDT0) returned live output on all four fee tiers (100: 57.3385, 500: 57.4187, 3000: 57.3237, 10000: 56.1963 USDT0). Decimals read on-chain: WHYPE 18, USDT0 6. Best tier checked against an INDEPENDENT control the same minute -- Hyperliquid allMids put HYPE at 57.3205, so the pool is 0.171% from the perp mid, which is the right shape for fee plus impact rather than a wrong contract or a decimals bug.",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-08-05",chainId:999}},{kind:"router",address:"0x4E2960a8cd19B467b82d26D83fAcb0fAE26b094D",label:"HyperSwap V3 SwapRouter",verified:{method:"eth_getCode returned 12070 bytes, and it is the router paired with the quoter proved above -- the same pair already shipped in UNI_V3_VENUES[999].hyperswap, which is the map the quote/prepare path actually routes through.",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-08-05",chainId:999}}]},{key:"abstract",chainId:2741,name:"Abstract",rpcEnv:["ABSTRACT_RPC_URL","ABS_RPC_URL"],nativeCurrency:{symbol:"ETH",decimals:18},venueKind:"uniswap-v3",wrappedNative:"0x3439153EB7AF838Ad19d56E1571FBD09333C2809",venues:[{kind:"quoter",address:"0x728BD3eC25D5EDBafebB84F3d67367Cd9EBC7693",label:"Uniswap V3 QuoterV2 (Abstract deployment)",verified:{method:"Abstract is a ZK-stack chain, so CREATE2 addresses differ and the canonical Uniswap addresses are NOT valid here -- probing them returns codesize 0, which is what previously made this chain look like it had no V3 at all. Found the real deployment from live traffic instead: scanned recent Swap(...) logs, took the busiest pool, read pool.factory() = 0xa1160e73b63f322ae88cc2d8e700833e71d0b2a1, then enumerated that factory's deployer (0xf3d63166F0Ca56C3c1A3508FcE03Ff0Cf3Fb691e) and probed each of its 56 contracts with a real quoteExactInputSingle call. Exactly one answered: 1 WETH -> 1846.475731 USDC.e at fee 500. Independent sanity check: the pool's own slot0() spot price is 1873.11 USDC.e per WETH, so the quoter sits ~1.4% below spot, the right shape for fee plus price impact on this size.",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-08-05",chainId:2741}},{kind:"router",address:"0x7712FA47387542819d4E35A23f8116C90C18767C",label:"Uniswap SwapRouter02 (Abstract deployment)",verified:{method:"eth_getCode returned 167392 bytes and the runtime contains the exactInputSingle selector. router.factory() matches the factory proved above and router.WETH9() matches the wrappedNative on this entry. Chosen over its byte-identical twin (0xfD6257F4...) because this is the address real users actually route through: it appeared as tx.to on live swaps against the WETH/USDC.e pool.",source:"on-chain factory()/WETH9() round-trip + live swap tx.to sampling",date:"2026-08-05",chainId:2741}}]},{key:"robinhood",chainId:4663,name:"Robinhood Chain",rpcEnv:["RH_CHAIN_RPC","ROBINHOOD_RPC_URL"],nativeCurrency:{symbol:"ETH",decimals:18},dexscreenerSlug:"robinhood",venueKind:"uniswap-v3",wrappedNative:"0x0bd7d308f8e1639fab988df18a8011f41eacad73",stableQuoteAssets:["0x5fc5360d0400a0fd4f2af552add042d716f1d168"],venues:[{kind:"quoter",address:"0x33e885ed0ec9bf04ecfb19341582aadcb4c8a9e7",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WETH->USDG fee 100 quoted 1866.58 USDG, and USDG->CASHCAT fee 10000 quoted a live amount). A contract that correctly prices known pairs IS a working V3 quoter",source:"live eth_call against rpc.mainnet.chain.robinhood.com",date:"2026-07-31",chainId:4663}},{kind:"router",address:"0xcaf681a66d020601342297493863e78c959e5cb2",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode (24497 bytes) on this chain and the paired quoter at the same deployment passed a live functional quote",source:"live eth_getCode against rpc.mainnet.chain.robinhood.com",date:"2026-07-31",chainId:4663}},{kind:"factory",address:"0x1f7d7550b1b028f7571e69a784071f0205fd2efa",label:"Uniswap V3 Factory",verified:{method:"eth_getCode returned real bytecode (24535 bytes) and a PoolCreated log scan over this factory returned 76 pools in ~9000 recent blocks",source:"live eth_getLogs against rpc.mainnet.chain.robinhood.com",date:"2026-07-31",chainId:4663}}]},{key:"base",chainId:8453,name:"Base",rpcEnv:["BASE_RPC_URL"],nativeCurrency:{symbol:"ETH",decimals:18},explorer:"https://basescan.org",dexscreenerSlug:"base",venueKind:"uniswap-v3",wrappedNative:"0x4200000000000000000000000000000000000006",stableQuoteAssets:["0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"],venues:[{kind:"quoter",address:"0x3d4e44Eb1374240CE5F1B871ab261CD16335B76a",label:"Uniswap V3 QuoterV2 (Base)",verified:{method:"functional probe: quoteExactInputSingle returned WETH->USDC at fee 500 = 1908.44 USDC, a live sane price. The canonical mainnet quoter address also has bytecode on Base but does NOT price this pair, which is exactly the false positive a codesize-only check accepts",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:8453}},{kind:"router",address:"0x2626664c2603336E57B271c5C0b26F421741e481",label:"Uniswap V3 SwapRouter02 (Base)",verified:{method:"eth_getCode returned real bytecode and the paired Base quoter passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:8453}},{kind:"router-v2",address:"0x4752ba5DBc23f44D87826276BF6Fd6b1C372aD24",label:"Uniswap V2 Router02 (Base)",verified:{method:"eth_getCode returned 17891 bytes; live getAmountsOut on WETH->USDC round-tripped to 98.75% (2x0.30% fee + impact)",source:"https://docs.uniswap.org/contracts/v2/reference/smart-contracts/v2-deployments",date:"2026-07-30",chainId:8453}}]},{key:"arbitrum",chainId:42161,name:"Arbitrum One",rpcEnv:["ARBITRUM_RPC_URL","ARB_RPC_URL"],nativeCurrency:{symbol:"ETH",decimals:18},explorer:"https://arbiscan.io",dexscreenerSlug:"arbitrum",venueKind:"uniswap-v3",wrappedNative:"0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",stableQuoteAssets:["0xaf88d065e77c8cC2239327C5EDb3A432268e5831","0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9"],venues:[{kind:"quoter",address:"0x61fFE014bA17989E743c5F6cB21bF9697530B21e",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WETH->USDC fee 500 quoted 1908.72 USDC). A contract that correctly prices a known pair IS a working V3 quoter",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:42161}},{kind:"router",address:"0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode on this chain and the paired quoter at the same deployment passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:42161}}]},{key:"avalanche",chainId:43114,name:"Avalanche C-Chain",rpcEnv:["AVALANCHE_RPC_URL","AVAX_RPC_URL"],nativeCurrency:{symbol:"AVAX",decimals:18},explorer:"https://snowtrace.io",dexscreenerSlug:"avalanche",venueKind:"uniswap-v3",wrappedNative:"0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7",stableQuoteAssets:["0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E"],venues:[{kind:"quoter",address:"0xbe0F5544EC67e9B3b2D979aaA43f18Fd87E6257F",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WAVAX->USDC fee 500 quoted 6.48 USDC). A contract that correctly prices a known pair IS a working V3 quoter",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:43114}},{kind:"router",address:"0xbb00FF08d01D300023C629E8fFfFcb65A5a578cE",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode on this chain and the paired quoter at the same deployment passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:43114}}]}]);var z=/[\u200B-\u200F\u202A-\u202E\u2060-\u2064\uFEFF]/g,W=/[<>&`*_~[\]()|\\]/g,K=/[\u0000-\u001F\u007F]/g;function N(e,{max:t=32,fallback:s=""}={}){return e==null?s:String(e).normalize("NFKC").replace(z,"").replace(K,"").replace(W,"").replace(/\s+/g," ").trim().slice(0,t).trim()||s}var b="unknown",L="0xd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d822",U="0xc42079f94a6350d7e6235f29174924f928cc2ac818eb64fed8004e115fbcca67",G=2e4,x=Object.freeze({1:300,10:1800,56:1200,137:1700,8453:1800,42161:14400,43114:1800,4663:1800,unknown:1800});function y(e){return x[Number(e)]??x.unknown}function R(e){return BigInt(e)}function w(e){return`0x${String(e).slice(-40)}`.toLowerCase()}function Q(e){let t=R(e);return t>=1n<<255n?t-(1n<<256n):t}function O(e){let t=String(e).replace(/^0x/,""),s=[];for(let a=0;a+64<=t.length;a+=64)s.push(`0x${t.slice(a,a+64)}`);return s}function B(e){let t=String(e.topics?.[0]||"").toLowerCase(),s=String(e.address||"").toLowerCase();if(t===L){let[a,c,i,u]=O(e.data).map(R);return{kind:"v2",pool:s,token0Delta:a-i,token1Delta:c-u,sender:w(e.topics[1]),recipient:w(e.topics[2]),txHash:e.transactionHash,blockNumber:Number(e.blockNumber)}}if(t===U){let[a,c]=O(e.data).map(Q);return{kind:"v3",pool:s,token0Delta:a,token1Delta:c,sender:w(e.topics[1]),recipient:w(e.topics[2]),txHash:e.transactionHash,blockNumber:Number(e.blockNumber)}}return null}function P(e,t){let s=e<0n,a=s?-e:e,c=10n**BigInt(t),i=Number(a/c)+Number(a%c)/Number(c);return s?-i:i}function q(e,t,{nativePriceUsd:s=null}={}){if(!e||!t)return null;let{token0:a,token1:c}=t,i=a.role==="stable"||a.role==="wrapped-native",u=c.role==="stable"||c.role==="wrapped-native";if(i===u)return null;let[n,r,d,f]=i?[a,c,e.token0Delta,e.token1Delta]:[c,a,e.token1Delta,e.token0Delta],h=f<0n?"buy":"sell",p=Math.abs(P(d,n.decimals)),o=Math.abs(P(f,r.decimals)),l=b,m=!1;return n.role==="stable"?l=p:typeof s=="number"&&Number.isFinite(s)&&(l=p*s,m=!0),{side:h,pool:e.pool,kind:e.kind,txHash:e.txHash,blockNumber:e.blockNumber,trader:e.recipient,token:r.address,tokenSymbol:r.symbol,tokenAmount:o,quote:n.address,quoteSymbol:n.symbol,quoteAmount:p,usd:l,estimated:m,priceQuote:o>0?p/o:b}}async function A({chainId:e,reader:t,windowBlocks:s,maxLogs:a=G}){let c=await t.head(),i=Math.max(0,c-s),u=await t.logs({fromBlock:i,toBlock:c,topics:[[L,U]]}),n=(u?.logs||[]).slice(0,a),r=(u?.logs||[]).length>a||u?.complete===!1,d=typeof t.nativePriceUsd=="function"?await t.nativePriceUsd().catch(()=>null):null,f=new Map,h=[];for(let p of n){let o=B(p);if(!o)continue;let l=f.get(o.pool);l===void 0&&(l=await t.poolMeta(o.pool).catch(()=>null),f.set(o.pool,l));let m=q(o,l,{nativePriceUsd:d});m&&h.push(m)}return{chainId:e,fromBlock:i,toBlock:c,trades:h,truncated:r,nativePriceUsd:d,observedAt:Date.now(),source:t.source||"rpc"}}async function Y({chainId:e,reader:t,windowBlocks:s,limit:a=10,minUsd:c=0}={}){let i=await A({chainId:e,reader:t,windowBlocks:s??t.blocksPerHour??y(e)}),u=i.trades.filter(r=>r.side==="buy"&&typeof r.usd=="number"&&r.usd>=c).sort((r,d)=>d.usd-r.usd).slice(0,a),n=i.trades.filter(r=>r.side==="buy"&&r.usd===b).length;return{...i,rows:u,unpriced:n}}async function X({chainId:e,reader:t,windowBlocks:s,limit:a=10}={}){let c=await A({chainId:e,reader:t,windowBlocks:s??t.blocksPerHour??y(e)}),i=new Map;for(let n of c.trades){let r=i.get(n.token)||{token:n.token,symbol:n.tokenSymbol,swaps:0,buys:0,sells:0,buyUsd:0,sellUsd:0,unpriced:0,traders:new Set};r.swaps+=1,n.side==="buy"?r.buys+=1:r.sells+=1,typeof n.usd=="number"?n.side==="buy"?r.buyUsd+=n.usd:r.sellUsd+=n.usd:r.unpriced+=1,r.traders.add(n.trader),i.set(n.token,r)}let u=[...i.values()].map(n=>({...n,traders:n.traders.size,netUsd:n.buyUsd-n.sellUsd})).sort((n,r)=>r.swaps-n.swaps).slice(0,a);return{...c,rows:u}}async function J({chainId:e,reader:t,token:s,windowBlocks:a,limit:c=8}={}){let i=String(s||"").toLowerCase();if(!/^0x[0-9a-f]{40}$/.test(i))throw new TypeError("tokenDetail needs a 0x token address (resolve symbols first)");let u=await A({chainId:e,reader:t,windowBlocks:a??t.blocksPerHour??y(e)}),n=u.trades.filter(o=>o.token===i),r=new Map;for(let o of n){let l=r.get(o.trader)||{trader:o.trader,buyUsd:0,sellUsd:0,buys:0,sells:0,unpriced:0};o.side==="buy"?l.buys+=1:l.sells+=1,typeof o.usd=="number"?o.side==="buy"?l.buyUsd+=o.usd:l.sellUsd+=o.usd:l.unpriced+=1,r.set(o.trader,l)}let d=[...r.values()].map(o=>({...o,netUsd:o.buyUsd-o.sellUsd})),f=d.filter(o=>o.netUsd>0).sort((o,l)=>l.netUsd-o.netUsd).slice(0,c),h=d.filter(o=>o.netUsd<0).sort((o,l)=>o.netUsd-l.netUsd).slice(0,c),p=n[n.length-1];return{...u,token:i,symbol:p?.tokenSymbol||b,swaps:n.length,buyUsd:n.filter(o=>o.side==="buy"&&typeof o.usd=="number").reduce((o,l)=>o+l.usd,0),sellUsd:n.filter(o=>o.side==="sell"&&typeof o.usd=="number").reduce((o,l)=>o+l.usd,0),unpriced:n.filter(o=>o.usd===b).length,lastPriceQuote:p?p.priceQuote:b,lastQuoteSymbol:p?p.quoteSymbol:b,ins:f,outs:h}}var Z="0x0dfe1681",ee="0xd21220a7",te="0x313ce567",re="0x95d89b41",F=/^0x[0-9a-f]{40}$/;function T(e){return String(e||"").replace(/^0x/i,"").toLowerCase()}function _(e){let t=T(e);if(t.length<64)return null;let s=`0x${t.slice(24,64)}`;return F.test(s)&&s!==`0x${"0".repeat(40)}`?s:null}function ne(e){let t=T(e);if(t.length<64)return null;let s=Number(BigInt(`0x${t.slice(0,64)}`));return Number.isInteger(s)&&s>=0&&s<=77?s:null}function oe(e){let t=T(e);if(t.length<64)return null;let s=i=>{let u=i.replace(/(00)+$/,"");if(u.length%2)return"";let n=new Uint8Array(u.length/2);for(let r=0;r<u.length;r+=2)n[r/2]=parseInt(u.slice(r,r+2),16);return new TextDecoder("utf-8",{fatal:!1}).decode(n)},a=null;if(t.length===64)a=s(t);else{let i=Number(BigInt(`0x${t.slice(0,64)}`))*2;if(Number.isInteger(i)&&i+64<=t.length){let u=Number(BigInt(`0x${t.slice(i,i+64)}`))*2,n=i+64;Number.isInteger(u)&&u>=0&&n+u<=t.length&&(a=s(t.slice(n,n+u)))}a==null&&(a=s(t.slice(0,64)))}return N(a,{max:32,fallback:""})||null}function se(e){return S.find(t=>Number(t.chainId)===Number(e))||null}function ae(e,t){let s=se(e),a=String(t||"").toLowerCase();return s&&(s.stableQuoteAssets||[]).some(c=>String(c).toLowerCase()===a)?"stable":s&&String(s.wrappedNative||"").toLowerCase()===a?"wrapped-native":"token"}function D(e,t,{cache:s=new Map,tokenCache:a=new Map}={}){if(typeof t!="function")throw new TypeError("defaultPoolMeta needs rpcCall(chainId, method, params)");let c=Number(e),i=(n,r)=>t(c,"eth_call",[{to:n,data:r},"latest"]);async function u(n){let r=String(n).toLowerCase();if(a.has(r))return a.get(r);let d=(async()=>{let[f,h]=await Promise.all([i(r,te),i(r,re).catch(()=>null)]),p=ne(f);if(p==null)return null;let o=oe(h)||`${r.slice(0,6)}\u2026${r.slice(-4)}`;return{address:r,symbol:o,decimals:p,role:ae(c,r)}})().catch(()=>null);return a.set(r,d),d}return async function(r){let d=String(r||"").toLowerCase();if(!F.test(d))return null;if(s.has(d))return s.get(d);let f=(async()=>{let[h,p]=await Promise.all([i(d,Z),i(d,ee)]),o=_(h),l=_(p);if(!o||!l||o===l)return null;let[m,C]=await Promise.all([u(o),u(l)]);return!m||!C?null:{pool:d,token0:m,token1:C}})().catch(()=>null);return s.set(d,f),f}}function ie(e,{rpcCall:t,poolMeta:s,nativePriceUsd:a,blocksPerHour:c}={}){let i=I(Number(e));if(!i)throw new Error(`market-tape: no scanner registered for chain ${e}`);let u=s||(typeof t=="function"?D(e,t):async()=>null);return{source:`rpc ${e}`,blocksPerHour:c??i.blocksPerHour??y(e),async head(){let n=await t(Number(e),"eth_blockNumber",[]);return Number(BigInt(n))},async logs({fromBlock:n,toBlock:r,topics:d}){return i.scanBlocks({fromBlock:n,toBlock:r,topics:d,chunkSize:2e3})},poolMeta:u,nativePriceUsd:a||(async()=>null)}}var It={whalesLastHour:Y,topTokens:X,tokenDetail:J,decodeSwapLog:B,swapToTrade:q,defaultTapeReader:ie,defaultPoolMeta:D,BLOCKS_PER_HOUR:x,blocksPerHourFor:y};export{x as BLOCKS_PER_HOUR,te as SEL_DECIMALS,re as SEL_SYMBOL,Z as SEL_TOKEN0,ee as SEL_TOKEN1,b as UNKNOWN,L as V2_SWAP_TOPIC,U as V3_SWAP_TOPIC,y as blocksPerHourFor,_ as decodeAddressReturn,B as decodeSwapLog,oe as decodeSymbolReturn,ne as decodeUintReturn,It as default,D as defaultPoolMeta,ie as defaultTapeReader,q as swapToTrade,J as tokenDetail,ae as tokenRole,X as topTokens,Y as whalesLastHour};
|
|
1
|
+
var ce=Object.freeze(["blockNumber","nativeBalance","tokenBalance","resolveToken","resolvePools","scanBlocks","scoreRisk","quote","sellSimulation","prepareUnsignedTx"]),g=Object.freeze({LIVE:"LIVE",CACHED:"CACHED",STALE:"STALE",UNKNOWN:"UNKNOWN",UNAVAILABLE:"UNAVAILABLE"}),v=Object.freeze({PASS:"PASS",CAUTION:"CAUTION",FAIL:"FAIL",UNKNOWN:"UNKNOWN"});var D=new Map;function I(e){return D.get(Number(e))||null}import{AsyncLocalStorage as H}from"node:async_hooks";var de=new H;var Ee=Object.getOwnPropertyDescriptor(AbortSignal.prototype,"aborted")?.get,Se=Object.getOwnPropertyDescriptor(AbortSignal.prototype,"reason")?.get,xe=AbortSignal.prototype.throwIfAborted,Ae=EventTarget.prototype.addEventListener,Te=EventTarget.prototype.removeEventListener,Ce=typeof AbortSignal.any=="function"?AbortSignal.any.bind(AbortSignal):null;var Ie=64*1024,Ne=Object.freeze({depth:32,nodes:1e4,fields:1e4,arrayLength:1e4,bytes:1024*1024});var E={robinhood:{chainId:4663,name:"Robinhood Chain",rpcEnv:["RH_CHAIN_RPC"],evm:!0},ethereum:{chainId:1,name:"Ethereum",rpcEnv:["ETH_RPC_URL","ETHEREUM_RPC_URL","MAINNET_RPC_URL"],evm:!0},polygon:{chainId:137,name:"Polygon",rpcEnv:["POLYGON_RPC_URL","POLYGON_RPC"],evm:!0},arbitrum:{chainId:42161,name:"Arbitrum One",rpcEnv:["ARBITRUM_RPC_URL","ARB_RPC_URL"],evm:!0},base:{chainId:8453,name:"Base",rpcEnv:["BASE_RPC_URL"],evm:!0},hyperevm:{chainId:999,name:"HyperEVM",rpcEnv:["HYPEREVM_RPC_URL","HYPER_EVM_RPC"],evm:!0},bsc:{chainId:56,name:"BNB Smart Chain",rpcEnv:["BSC_RPC_URL","BNB_RPC_URL"],evm:!0},avalanche:{chainId:43114,name:"Avalanche C-Chain",rpcEnv:["AVALANCHE_RPC_URL","AVAX_RPC_URL"],evm:!0},optimism:{chainId:10,name:"OP Mainnet",rpcEnv:["OPTIMISM_RPC_URL","OP_RPC_URL"],evm:!0},abstract:{chainId:2741,name:"Abstract",rpcEnv:["ABSTRACT_RPC_URL","ABS_RPC_URL"],evm:!0},stable:{chainId:988,name:"Stable Mainnet",rpcEnv:["STABLE_RPC_URL","STABLE_RPC"],evm:!0},elysium:{chainId:1339,name:"Elysium",rpcEnv:["ELYSIUM_RPC_URL"],evm:!0,readOnly:!0}};var Le=new Map(Object.values(E).map(e=>[e.chainId,e]));import{Interface as j,getAddress as De}from"ethers";var He=new j(["function allowance(address owner,address spender) view returns (uint256)","function balanceOf(address account) view returns (uint256)"]);var We=Object.freeze({1:"ethereum",10:"optimism",56:"bsc",137:"polygon",8453:"base",42161:"arbitrum",43114:"avalanche",999:"hyperevm",4663:"robinhood"});var S=Object.freeze([{key:"ethereum",chainId:1,name:"Ethereum",rpcEnv:["ETH_RPC_URL","ETHEREUM_RPC_URL","MAINNET_RPC_URL"],nativeCurrency:{symbol:"ETH",decimals:18},explorer:"https://etherscan.io",dexscreenerSlug:"ethereum",venueKind:"uniswap-v3",wrappedNative:"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",stableQuoteAssets:["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48","0xdAC17F958D2ee523a2206206994597C13D831ec7"],venues:[{kind:"quoter",address:"0x61fFE014bA17989E743c5F6cB21bF9697530B21e",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WETH->USDC fee 500 quoted 1908.71 USDC). A contract that correctly prices a known pair IS a working V3 quoter",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:1}},{kind:"router",address:"0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode on this chain and the paired quoter at the same deployment passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:1}}]},{key:"optimism",chainId:10,name:"OP Mainnet",rpcEnv:["OPTIMISM_RPC_URL","OP_RPC_URL"],nativeCurrency:{symbol:"ETH",decimals:18},explorer:"https://optimistic.etherscan.io",dexscreenerSlug:"optimism",venueKind:"uniswap-v3",wrappedNative:"0x4200000000000000000000000000000000000006",stableQuoteAssets:["0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85","0x94b008aA00579c1307B0EF2c499aD98a8ce58e58"],venues:[{kind:"quoter",address:"0x61fFE014bA17989E743c5F6cB21bF9697530B21e",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WETH->USDC fee 500 quoted 1905.23 USDC). A contract that correctly prices a known pair IS a working V3 quoter",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:10}},{kind:"router",address:"0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode on this chain and the paired quoter at the same deployment passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:10}}]},{key:"bsc",chainId:56,name:"BNB Smart Chain",rpcEnv:["BSC_RPC_URL","BNB_RPC_URL"],nativeCurrency:{symbol:"BNB",decimals:18},explorer:"https://bscscan.com",dexscreenerSlug:"bsc",venueKind:"uniswap-v3",wrappedNative:"0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c",stableQuoteAssets:["0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d","0x55d398326f99059fF775485246999027B3197955"],venues:[{kind:"quoter",address:"0x78D78E420Da98ad378D7799bE8f4AF69033EB077",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WBNB->USDC fee 500 quoted 413.86 USDC). A contract that correctly prices a known pair IS a working V3 quoter",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:56}},{kind:"router",address:"0xB971eF87ede563556b2ED4b1C0b0019111Dd85d2",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode on this chain and the paired quoter at the same deployment passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:56}}]},{key:"polygon",chainId:137,name:"Polygon",rpcEnv:["POLYGON_RPC_URL","POLYGON_RPC"],nativeCurrency:{symbol:"POL",decimals:18},explorer:"https://polygonscan.com",dexscreenerSlug:"polygon",venueKind:"uniswap-v3",wrappedNative:"0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270",stableQuoteAssets:["0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359","0xc2132D05D31c914a87C6611C10748AEb04B58e8F"],venues:[{kind:"quoter",address:"0x61fFE014bA17989E743c5F6cB21bF9697530B21e",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WMATIC->USDC fee 500 quoted 0.0720 USDC). A contract that correctly prices a known pair IS a working V3 quoter",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:137}},{kind:"router",address:"0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode on this chain and the paired quoter at the same deployment passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:137}}]},{key:"stable",chainId:988,name:"Stable Mainnet",rpcEnv:["STABLE_RPC_URL","STABLE_RPC"],nativeCurrency:{symbol:"USDT0",decimals:18},venueKind:"uniswap-v3",wrappedNative:"0x5d442b349590a6048Eb2dC0eC346cAA5F47A9ab5",venues:[{kind:"quoter",address:"0xb070179E7032CdA868b53e6C1742F80c9e940d1A",label:"Uniswap V3 QuoterV2 (canonical)",verified:{method:"Stable is on the OFFICIAL Uniswap v3 Deployments List (governance-recognised 2026-05-12, UAC process completed 2026-04, deployed by Protofire), so this is a canonical deployment rather than a fork. eth_getCode returned 8273 bytes, the same size as the canonical quoter on the seven already-verified chains. Functional probe on a live pool (TOAST -> USDT0, fee 10000): 100 in -> 0.000003, 1000 -> 0.000031, 10000 -> 0.000319 USDT0. Output scales monotonically with input, which is a working quoter answering, not a revert. Two of three sampled pools carry non-zero liquidity. NOTE: the pools discovered so far are thin, so real routing size is limited -- the venue is proved, deep liquidity is not.",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-08-05",chainId:988}},{kind:"router",address:"0x32eaf9B5d5F2CD7361c5012890C943D7de84C22a",label:"Uniswap SwapRouter02 (canonical)",verified:{method:"eth_getCode returned 24497 bytes. Cross-checked on-chain rather than trusted from docs: router.factory() returns 0x88f0a512ef09175d456bc9547f914f48c013e4aa, the same v3 core factory that created the pools quoted above, and router.WETH9() returns the wrappedNative recorded on this chain entry. Address published in the Stable docs DEX reference and the Uniswap deployments list.",source:"docs.stable.xyz/en/reference/dexes + on-chain factory()/WETH9() round-trip",date:"2026-08-05",chainId:988}}]},{key:"hyperevm",chainId:999,name:"HyperEVM",rpcEnv:["HYPEREVM_RPC_URL","HYPER_EVM_RPC"],nativeCurrency:{symbol:"HYPE",decimals:18},dexscreenerSlug:"hyperevm",venueKind:"uniswap-v3",wrappedNative:"0x5555555555555555555555555555555555555555",venues:[{kind:"quoter",address:"0x03A918028f22D9E1473B7959C927AD7425A45C7C",label:"HyperSwap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle(1 WHYPE -> USDT0) returned live output on all four fee tiers (100: 57.3385, 500: 57.4187, 3000: 57.3237, 10000: 56.1963 USDT0). Decimals read on-chain: WHYPE 18, USDT0 6. Best tier checked against an INDEPENDENT control the same minute -- Hyperliquid allMids put HYPE at 57.3205, so the pool is 0.171% from the perp mid, which is the right shape for fee plus impact rather than a wrong contract or a decimals bug.",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-08-05",chainId:999}},{kind:"router",address:"0x4E2960a8cd19B467b82d26D83fAcb0fAE26b094D",label:"HyperSwap V3 SwapRouter",verified:{method:"eth_getCode returned 12070 bytes, and it is the router paired with the quoter proved above -- the same pair already shipped in UNI_V3_VENUES[999].hyperswap, which is the map the quote/prepare path actually routes through.",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-08-05",chainId:999}}]},{key:"abstract",chainId:2741,name:"Abstract",rpcEnv:["ABSTRACT_RPC_URL","ABS_RPC_URL"],nativeCurrency:{symbol:"ETH",decimals:18},venueKind:"uniswap-v3",wrappedNative:"0x3439153EB7AF838Ad19d56E1571FBD09333C2809",venues:[{kind:"quoter",address:"0x728BD3eC25D5EDBafebB84F3d67367Cd9EBC7693",label:"Uniswap V3 QuoterV2 (Abstract deployment)",verified:{method:"Abstract is a ZK-stack chain, so CREATE2 addresses differ and the canonical Uniswap addresses are NOT valid here -- probing them returns codesize 0, which is what previously made this chain look like it had no V3 at all. Found the real deployment from live traffic instead: scanned recent Swap(...) logs, took the busiest pool, read pool.factory() = 0xa1160e73b63f322ae88cc2d8e700833e71d0b2a1, then enumerated that factory's deployer (0xf3d63166F0Ca56C3c1A3508FcE03Ff0Cf3Fb691e) and probed each of its 56 contracts with a real quoteExactInputSingle call. Exactly one answered: 1 WETH -> 1846.475731 USDC.e at fee 500. Independent sanity check: the pool's own slot0() spot price is 1873.11 USDC.e per WETH, so the quoter sits ~1.4% below spot, the right shape for fee plus price impact on this size.",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-08-05",chainId:2741}},{kind:"router",address:"0x7712FA47387542819d4E35A23f8116C90C18767C",label:"Uniswap SwapRouter02 (Abstract deployment)",verified:{method:"eth_getCode returned 167392 bytes and the runtime contains the exactInputSingle selector. router.factory() matches the factory proved above and router.WETH9() matches the wrappedNative on this entry. Chosen over its byte-identical twin (0xfD6257F4...) because this is the address real users actually route through: it appeared as tx.to on live swaps against the WETH/USDC.e pool.",source:"on-chain factory()/WETH9() round-trip + live swap tx.to sampling",date:"2026-08-05",chainId:2741}}]},{key:"robinhood",chainId:4663,name:"Robinhood Chain",rpcEnv:["RH_CHAIN_RPC","ROBINHOOD_RPC_URL"],nativeCurrency:{symbol:"ETH",decimals:18},dexscreenerSlug:"robinhood",venueKind:"uniswap-v3",wrappedNative:"0x0bd7d308f8e1639fab988df18a8011f41eacad73",stableQuoteAssets:["0x5fc5360d0400a0fd4f2af552add042d716f1d168"],venues:[{kind:"quoter",address:"0x33e885ed0ec9bf04ecfb19341582aadcb4c8a9e7",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WETH->USDG fee 100 quoted 1866.58 USDG, and USDG->CASHCAT fee 10000 quoted a live amount). A contract that correctly prices known pairs IS a working V3 quoter",source:"live eth_call against rpc.mainnet.chain.robinhood.com",date:"2026-07-31",chainId:4663}},{kind:"router",address:"0xcaf681a66d020601342297493863e78c959e5cb2",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode (24497 bytes) on this chain and the paired quoter at the same deployment passed a live functional quote",source:"live eth_getCode against rpc.mainnet.chain.robinhood.com",date:"2026-07-31",chainId:4663}},{kind:"factory",address:"0x1f7d7550b1b028f7571e69a784071f0205fd2efa",label:"Uniswap V3 Factory",verified:{method:"eth_getCode returned real bytecode (24535 bytes) and a PoolCreated log scan over this factory returned 76 pools in ~9000 recent blocks",source:"live eth_getLogs against rpc.mainnet.chain.robinhood.com",date:"2026-07-31",chainId:4663}}]},{key:"base",chainId:8453,name:"Base",rpcEnv:["BASE_RPC_URL"],nativeCurrency:{symbol:"ETH",decimals:18},explorer:"https://basescan.org",dexscreenerSlug:"base",venueKind:"uniswap-v3",wrappedNative:"0x4200000000000000000000000000000000000006",stableQuoteAssets:["0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"],venues:[{kind:"quoter",address:"0x3d4e44Eb1374240CE5F1B871ab261CD16335B76a",label:"Uniswap V3 QuoterV2 (Base)",verified:{method:"functional probe: quoteExactInputSingle returned WETH->USDC at fee 500 = 1908.44 USDC, a live sane price. The canonical mainnet quoter address also has bytecode on Base but does NOT price this pair, which is exactly the false positive a codesize-only check accepts",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:8453}},{kind:"router",address:"0x2626664c2603336E57B271c5C0b26F421741e481",label:"Uniswap V3 SwapRouter02 (Base)",verified:{method:"eth_getCode returned real bytecode and the paired Base quoter passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:8453}},{kind:"router-v2",address:"0x4752ba5DBc23f44D87826276BF6Fd6b1C372aD24",label:"Uniswap V2 Router02 (Base)",verified:{method:"eth_getCode returned 17891 bytes; live getAmountsOut on WETH->USDC round-tripped to 98.75% (2x0.30% fee + impact)",source:"https://docs.uniswap.org/contracts/v2/reference/smart-contracts/v2-deployments",date:"2026-07-30",chainId:8453}}]},{key:"arbitrum",chainId:42161,name:"Arbitrum One",rpcEnv:["ARBITRUM_RPC_URL","ARB_RPC_URL"],nativeCurrency:{symbol:"ETH",decimals:18},explorer:"https://arbiscan.io",dexscreenerSlug:"arbitrum",venueKind:"uniswap-v3",wrappedNative:"0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",stableQuoteAssets:["0xaf88d065e77c8cC2239327C5EDb3A432268e5831","0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9"],venues:[{kind:"quoter",address:"0x61fFE014bA17989E743c5F6cB21bF9697530B21e",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WETH->USDC fee 500 quoted 1908.72 USDC). A contract that correctly prices a known pair IS a working V3 quoter",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:42161}},{kind:"router",address:"0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode on this chain and the paired quoter at the same deployment passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:42161}}]},{key:"avalanche",chainId:43114,name:"Avalanche C-Chain",rpcEnv:["AVALANCHE_RPC_URL","AVAX_RPC_URL"],nativeCurrency:{symbol:"AVAX",decimals:18},explorer:"https://snowtrace.io",dexscreenerSlug:"avalanche",venueKind:"uniswap-v3",wrappedNative:"0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7",stableQuoteAssets:["0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E"],venues:[{kind:"quoter",address:"0xbe0F5544EC67e9B3b2D979aaA43f18Fd87E6257F",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WAVAX->USDC fee 500 quoted 6.48 USDC). A contract that correctly prices a known pair IS a working V3 quoter",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:43114}},{kind:"router",address:"0xbb00FF08d01D300023C629E8fFfFcb65A5a578cE",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode on this chain and the paired quoter at the same deployment passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:43114}}]}]);var z=/[\u200B-\u200F\u202A-\u202E\u2060-\u2064\uFEFF]/g,W=/[<>&`*_~[\]()|\\]/g,K=/[\u0000-\u001F\u007F]/g;function k(e,{max:t=32,fallback:s=""}={}){return e==null?s:String(e).normalize("NFKC").replace(z,"").replace(K,"").replace(W,"").replace(/\s+/g," ").trim().slice(0,t).trim()||s}var b="unknown",_="0xd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d822",U="0xc42079f94a6350d7e6235f29174924f928cc2ac818eb64fed8004e115fbcca67",G=2e4,x=Object.freeze({1:300,10:1800,56:1200,137:1700,8453:1800,42161:14400,43114:1800,4663:1800,unknown:1800});function y(e){return x[Number(e)]??x.unknown}function R(e){return BigInt(e)}function w(e){return`0x${String(e).slice(-40)}`.toLowerCase()}function Q(e){let t=R(e);return t>=1n<<255n?t-(1n<<256n):t}function O(e){let t=String(e).replace(/^0x/,""),s=[];for(let a=0;a+64<=t.length;a+=64)s.push(`0x${t.slice(a,a+64)}`);return s}function B(e){let t=String(e.topics?.[0]||"").toLowerCase(),s=String(e.address||"").toLowerCase();if(t===_){let[a,c,i,u]=O(e.data).map(R);return{kind:"v2",pool:s,token0Delta:a-i,token1Delta:c-u,sender:w(e.topics[1]),recipient:w(e.topics[2]),txHash:e.transactionHash,blockNumber:Number(e.blockNumber)}}if(t===U){let[a,c]=O(e.data).map(Q);return{kind:"v3",pool:s,token0Delta:a,token1Delta:c,sender:w(e.topics[1]),recipient:w(e.topics[2]),txHash:e.transactionHash,blockNumber:Number(e.blockNumber)}}return null}function P(e,t){let s=e<0n,a=s?-e:e,c=10n**BigInt(t),i=Number(a/c)+Number(a%c)/Number(c);return s?-i:i}function q(e,t,{nativePriceUsd:s=null}={}){if(!e||!t)return null;let{token0:a,token1:c}=t,i=a.role==="stable"||a.role==="wrapped-native",u=c.role==="stable"||c.role==="wrapped-native";if(i===u)return null;let[n,r,d,f]=i?[a,c,e.token0Delta,e.token1Delta]:[c,a,e.token1Delta,e.token0Delta],h=f<0n?"buy":"sell",p=Math.abs(P(d,n.decimals)),o=Math.abs(P(f,r.decimals)),l=b,m=!1;return n.role==="stable"?l=p:typeof s=="number"&&Number.isFinite(s)&&(l=p*s,m=!0),{side:h,pool:e.pool,kind:e.kind,txHash:e.txHash,blockNumber:e.blockNumber,trader:e.recipient,token:r.address,tokenSymbol:r.symbol,tokenAmount:o,quote:n.address,quoteSymbol:n.symbol,quoteAmount:p,usd:l,estimated:m,priceQuote:o>0?p/o:b}}async function A({chainId:e,reader:t,windowBlocks:s,maxLogs:a=G}){let c=await t.head(),i=Math.max(0,c-s),u=await t.logs({fromBlock:i,toBlock:c,topics:[[_,U]]}),n=(u?.logs||[]).slice(0,a),r=(u?.logs||[]).length>a||u?.complete===!1,d=typeof t.nativePriceUsd=="function"?await t.nativePriceUsd().catch(()=>null):null,f=new Map,h=[];for(let p of n){let o=B(p);if(!o)continue;let l=f.get(o.pool);l===void 0&&(l=await t.poolMeta(o.pool).catch(()=>null),f.set(o.pool,l));let m=q(o,l,{nativePriceUsd:d});m&&h.push(m)}return{chainId:e,fromBlock:i,toBlock:c,trades:h,truncated:r,nativePriceUsd:d,observedAt:Date.now(),source:t.source||"rpc"}}async function Y({chainId:e,reader:t,windowBlocks:s,limit:a=10,minUsd:c=0}={}){let i=await A({chainId:e,reader:t,windowBlocks:s??t.blocksPerHour??y(e)}),u=i.trades.filter(r=>r.side==="buy"&&typeof r.usd=="number"&&r.usd>=c).sort((r,d)=>d.usd-r.usd).slice(0,a),n=i.trades.filter(r=>r.side==="buy"&&r.usd===b).length;return{...i,rows:u,unpriced:n}}async function X({chainId:e,reader:t,windowBlocks:s,limit:a=10}={}){let c=await A({chainId:e,reader:t,windowBlocks:s??t.blocksPerHour??y(e)}),i=new Map;for(let n of c.trades){let r=i.get(n.token)||{token:n.token,symbol:n.tokenSymbol,swaps:0,buys:0,sells:0,buyUsd:0,sellUsd:0,unpriced:0,traders:new Set};r.swaps+=1,n.side==="buy"?r.buys+=1:r.sells+=1,typeof n.usd=="number"?n.side==="buy"?r.buyUsd+=n.usd:r.sellUsd+=n.usd:r.unpriced+=1,r.traders.add(n.trader),i.set(n.token,r)}let u=[...i.values()].map(n=>({...n,traders:n.traders.size,netUsd:n.buyUsd-n.sellUsd})).sort((n,r)=>r.swaps-n.swaps).slice(0,a);return{...c,rows:u}}async function J({chainId:e,reader:t,token:s,windowBlocks:a,limit:c=8}={}){let i=String(s||"").toLowerCase();if(!/^0x[0-9a-f]{40}$/.test(i))throw new TypeError("tokenDetail needs a 0x token address (resolve symbols first)");let u=await A({chainId:e,reader:t,windowBlocks:a??t.blocksPerHour??y(e)}),n=u.trades.filter(o=>o.token===i),r=new Map;for(let o of n){let l=r.get(o.trader)||{trader:o.trader,buyUsd:0,sellUsd:0,buys:0,sells:0,unpriced:0};o.side==="buy"?l.buys+=1:l.sells+=1,typeof o.usd=="number"?o.side==="buy"?l.buyUsd+=o.usd:l.sellUsd+=o.usd:l.unpriced+=1,r.set(o.trader,l)}let d=[...r.values()].map(o=>({...o,netUsd:o.buyUsd-o.sellUsd})),f=d.filter(o=>o.netUsd>0).sort((o,l)=>l.netUsd-o.netUsd).slice(0,c),h=d.filter(o=>o.netUsd<0).sort((o,l)=>o.netUsd-l.netUsd).slice(0,c),p=n[n.length-1];return{...u,token:i,symbol:p?.tokenSymbol||b,swaps:n.length,buyUsd:n.filter(o=>o.side==="buy"&&typeof o.usd=="number").reduce((o,l)=>o+l.usd,0),sellUsd:n.filter(o=>o.side==="sell"&&typeof o.usd=="number").reduce((o,l)=>o+l.usd,0),unpriced:n.filter(o=>o.usd===b).length,lastPriceQuote:p?p.priceQuote:b,lastQuoteSymbol:p?p.quoteSymbol:b,ins:f,outs:h}}var Z="0x0dfe1681",ee="0xd21220a7",te="0x313ce567",re="0x95d89b41",$=/^0x[0-9a-f]{40}$/;function T(e){return String(e||"").replace(/^0x/i,"").toLowerCase()}function L(e){let t=T(e);if(t.length<64)return null;let s=`0x${t.slice(24,64)}`;return $.test(s)&&s!==`0x${"0".repeat(40)}`?s:null}function ne(e){let t=T(e);if(t.length<64)return null;let s=Number(BigInt(`0x${t.slice(0,64)}`));return Number.isInteger(s)&&s>=0&&s<=77?s:null}function oe(e){let t=T(e);if(t.length<64)return null;let s=i=>{let u=i.replace(/(00)+$/,"");if(u.length%2)return"";let n=new Uint8Array(u.length/2);for(let r=0;r<u.length;r+=2)n[r/2]=parseInt(u.slice(r,r+2),16);return new TextDecoder("utf-8",{fatal:!1}).decode(n)},a=null;if(t.length===64)a=s(t);else{let i=Number(BigInt(`0x${t.slice(0,64)}`))*2;if(Number.isInteger(i)&&i+64<=t.length){let u=Number(BigInt(`0x${t.slice(i,i+64)}`))*2,n=i+64;Number.isInteger(u)&&u>=0&&n+u<=t.length&&(a=s(t.slice(n,n+u)))}a==null&&(a=s(t.slice(0,64)))}return k(a,{max:32,fallback:""})||null}function se(e){return S.find(t=>Number(t.chainId)===Number(e))||null}function ae(e,t){let s=se(e),a=String(t||"").toLowerCase();return s&&(s.stableQuoteAssets||[]).some(c=>String(c).toLowerCase()===a)?"stable":s&&String(s.wrappedNative||"").toLowerCase()===a?"wrapped-native":"token"}function F(e,t,{cache:s=new Map,tokenCache:a=new Map}={}){if(typeof t!="function")throw new TypeError("defaultPoolMeta needs rpcCall(chainId, method, params)");let c=Number(e),i=(n,r)=>t(c,"eth_call",[{to:n,data:r},"latest"]);async function u(n){let r=String(n).toLowerCase();if(a.has(r))return a.get(r);let d=(async()=>{let[f,h]=await Promise.all([i(r,te),i(r,re).catch(()=>null)]),p=ne(f);if(p==null)return null;let o=oe(h)||`${r.slice(0,6)}\u2026${r.slice(-4)}`;return{address:r,symbol:o,decimals:p,role:ae(c,r)}})().catch(()=>null);return a.set(r,d),d}return async function(r){let d=String(r||"").toLowerCase();if(!$.test(d))return null;if(s.has(d))return s.get(d);let f=(async()=>{let[h,p]=await Promise.all([i(d,Z),i(d,ee)]),o=L(h),l=L(p);if(!o||!l||o===l)return null;let[m,C]=await Promise.all([u(o),u(l)]);return!m||!C?null:{pool:d,token0:m,token1:C}})().catch(()=>null);return s.set(d,f),f}}function ie(e,{rpcCall:t,poolMeta:s,nativePriceUsd:a,blocksPerHour:c}={}){let i=I(Number(e));if(!i)throw new Error(`market-tape: no scanner registered for chain ${e}`);let u=s||(typeof t=="function"?F(e,t):async()=>null);return{source:`rpc ${e}`,blocksPerHour:c??i.blocksPerHour??y(e),async head(){let n=await t(Number(e),"eth_blockNumber",[]);return Number(BigInt(n))},async logs({fromBlock:n,toBlock:r,topics:d}){return i.scanBlocks({fromBlock:n,toBlock:r,topics:d,chunkSize:2e3})},poolMeta:u,nativePriceUsd:a||(async()=>null)}}var It={whalesLastHour:Y,topTokens:X,tokenDetail:J,decodeSwapLog:B,swapToTrade:q,defaultTapeReader:ie,defaultPoolMeta:F,BLOCKS_PER_HOUR:x,blocksPerHourFor:y};export{x as BLOCKS_PER_HOUR,te as SEL_DECIMALS,re as SEL_SYMBOL,Z as SEL_TOKEN0,ee as SEL_TOKEN1,b as UNKNOWN,_ as V2_SWAP_TOPIC,U as V3_SWAP_TOPIC,y as blocksPerHourFor,L as decodeAddressReturn,B as decodeSwapLog,oe as decodeSymbolReturn,ne as decodeUintReturn,It as default,F as defaultPoolMeta,ie as defaultTapeReader,q as swapToTrade,J as tokenDetail,ae as tokenRole,X as topTokens,Y as whalesLastHour};
|
package/dist/data/names.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{keccak_256 as de}from"@noble/hashes/sha3.js";import{createHash as rt}from"node:crypto";import{types as H}from"node:util";import{AsyncLocalStorage as Ye}from"node:async_hooks";var We=new Ye,Xe=["http","retry","shared"],Ke=512;function Z(t){let e=We.getStore();if(!e||e.closed||!Xe.includes(t))return null;if(e.spans.length>=Ke)return e.droppedSpans++,null;let r={stage:t,startMs:e.now()-e.start,durationMs:null,outcome:"pending",status:null};return e.spans.push(r),(n,s=null)=>{e.closed||r.durationMs!==null||(r.durationMs=Math.max(0,e.now()-e.start-r.startMs),r.outcome=n==="succeeded"?"succeeded":"failed",r.status=Number.isInteger(s)&&s>=100&&s<=599?s:null)}}import $ from"node:net";import Ze from"node:dns";var qe=new Set(["localhost","metadata.google.internal","metadata.goog"]);function q(t){let e=String(t).toLowerCase().split("%")[0];if((e.match(/::/g)||[]).length>1)return null;let r=o=>{if(!o)return[];let p=o.split(":"),T=p.at(-1);if(T?.includes(".")){let l=T.split(".").map(Number);if(l.length!==4||l.some(c=>!Number.isInteger(c)||c<0||c>255))return null;p.splice(p.length-1,1,(l[0]<<8|l[1]).toString(16),(l[2]<<8|l[3]).toString(16))}return p.some(l=>!/^[0-9a-f]{1,4}$/.test(l))?null:p.map(l=>Number.parseInt(l,16))},[n,s]=e.split("::"),u=r(n),a=r(s);if(!u||!a)return null;let d=e.includes("::"),i=8-u.length-a.length;if(!d&&i!==0||d&&i<1)return null;let h=[...u,...Array(Math.max(0,i)).fill(0),...a];return h.length!==8?null:Uint8Array.from(h.flatMap(o=>[o>>8,o&255]))}function ne(t,e,r){let n=Math.floor(r/8),s=r%8;for(let a=0;a<n;a+=1)if(t[a]!==e[a])return!1;if(!s)return!0;let u=255<<8-s;return(t[n]&u)===(e[n]&u)}function oe(t){if($.isIPv4(t)){let e=t.split(".").map(Number);return!(e[0]===0||e[0]===10||e[0]===127||e[0]>=224||e[0]===100&&e[1]>=64&&e[1]<=127||e[0]===169&&e[1]===254||e[0]===172&&e[1]>=16&&e[1]<=31||e[0]===192&&(e[1]===0||e[1]===2||e[1]===168)||e[0]===192&&e[1]===88&&e[2]===99||e[0]===198&&(e[1]===18||e[1]===19||e[1]===51)||e[0]===203&&e[1]===0&&e[2]===113)}if($.isIPv6(t)){let e=q(t);if(!e)return!1;let r=q("::ffff:0:0");return ne(e,r,96)?oe([...e.slice(12)].join(".")):ne(e,q("2000::"),3)?![["2001::",23],["2001:db8::",32],["2001:10::",28],["2001:2::",48],["2002::",16],["3fff::",20]].some(([s,u])=>ne(e,q(s),u)):!1}return!1}function Qe(t){let e;try{e=new URL(String(t))}catch{return{ok:!1,error:`not a valid URL: ${String(t).slice(0,120)}`}}if(e.protocol!=="http:"&&e.protocol!=="https:")return{ok:!1,error:`refused protocol ${e.protocol} (only http/https)`};let r=e.hostname.toLowerCase().replace(/^\[|\]$/g,"").replace(/\.+$/,"");if(qe.has(r)||r.endsWith(".localhost")||r.endsWith(".internal"))return{ok:!1,error:`refused internal host ${r}`};let n=$.isIP(r);return n!==0&&!oe(r)?{ok:!1,error:`refused private address ${r}`}:{ok:!0,url:e,host:r,isLiteralIp:n!==0}}async function se(t,{lookupFn:e=Ze.promises.lookup}={}){let r=Qe(t);if(!r.ok)return r;if(r.isLiteralIp)return{ok:!0,url:r.url,addresses:[{address:r.host,family:$.isIPv6(r.host)?6:4}]};let n;if(process.env.ORACLE_HOSTED_EGRESS_PROXY)return{ok:!0,url:r.url,addresses:[]};try{n=await e(r.host,{all:!0,verbatim:!0})}catch{return{ok:!1,error:`refused: ${r.host} did not resolve`}}return!Array.isArray(n)||n.length===0||n.some(s=>!oe(s.address))?{ok:!1,error:`refused: ${r.host} resolves to a non-public address`}:{ok:!0,url:r.url,addresses:n}}function et(t=process.env){let e=t.ORACLE_HOSTED_EGRESS_PROXY||"";if(!e)return null;let r;try{r=new URL(e)}catch{throw new Error("egress-guard: ORACLE_HOSTED_EGRESS_PROXY is not a URL")}if(r.protocol!=="http:"||!["127.0.0.1","::1","localhost","[::1]"].includes(r.hostname)||!r.port||r.username||r.password)throw new Error("egress-guard: egress proxy must be an exact loopback http origin");let n=t.ORACLE_HOSTED_EGRESS_TOKEN||"";if(!/^[A-Za-z0-9_-]{43}$/.test(n))throw new Error("egress-guard: egress proxy token is missing");return{uri:r.origin,token:n}}async function ae({requireUndici:t=!1,importUndici:e=()=>import("undici")}={}){let r,n,s;try{s=await e(),r=s.Agent,n=s.fetch}catch(l){if(t)throw new Error(`egress-guard: untrustedUrl pinning requires the undici package, which failed to load: ${l?.message||l}`);return null}if(typeof r!="function"||typeof n!="function"){if(t)throw new Error("egress-guard: untrustedUrl pinning requires undici's Agent and fetch exports, which were not found on the imported module");return null}let u=l=>String(l).toLowerCase().replace(/^\[|\]$/g,"").replace(/\.+$/,""),a=new Map,d=l=>(Array.isArray(l)?l:[l]).map(c=>typeof c=="string"?{address:c}:c).filter(c=>c&&c.address).map(c=>({address:c.address,family:c.family||($.isIPv6(c.address)?6:4)})),i=(l,c,g)=>{a.set(u(l),d(typeof c=="string"?[{address:c,family:g}]:c))},h=l=>{let c=u(l);if($.isIP(c))return[{address:c,family:$.isIPv6(c)?6:4}];let g=a.get(c);if(!g||!g.length)throw new Error(`refused: unpinned host ${l} during pinned fetch`);return g},o=et(),p=o&&typeof s.ProxyAgent=="function"?new s.ProxyAgent({uri:o.uri,token:`Bearer ${o.token}`,connectTimeout:1e4}):new r({connect:{lookup(l,c,g){let m;try{m=h(l)}catch(O){return g(O)}return c?.all?g(null,m):g(null,m[0].address,m[0].family)}}}),T=tt((l,c={})=>n(l,{...c,dispatcher:p}),i);return{dispatcher:p,fetch:T,pin:i,resolve:h,async close(){try{await p.destroy()}catch{}}}}var ie=Symbol.for("oracle.egressGuard.pinCapableFetch");function tt(t,e){if(typeof t!="function")throw new Error("markPinCapableFetch: fetchImpl must be a function");if(typeof e!="function")throw new Error("markPinCapableFetch: pin must be a function");return t[ie]=Object.freeze({pin:e}),t}function ce(t){return typeof t=="function"&&typeof t[ie]?.pin=="function"}function Oe(t,e,r){if(!ce(t))throw new Error("pinFetchToAddresses: fetchImpl is not pin-capable");t[ie].pin(e,r)}var nt=new Set([408,425,429,500,502,503,504]),Se=new Set(["GET","HEAD","OPTIONS","PUT","DELETE"]),ot=2,Pe=4e3,st=Object.getOwnPropertyDescriptor(AbortSignal.prototype,"aborted")?.get,at=Object.getOwnPropertyDescriptor(AbortSignal.prototype,"reason")?.get,it=AbortSignal.prototype.throwIfAborted,ct=EventTarget.prototype.addEventListener,Re=EventTarget.prototype.removeEventListener,xe=typeof AbortSignal.any=="function"?AbortSignal.any.bind(AbortSignal):null,W=t=>t?st.call(t):!1,ut=t=>t?at.call(t):void 0,lt=new Set([301,302,303,307,308]),ee=3,rr=64*1024,k=Object.freeze({depth:32,nodes:1e4,fields:1e4,arrayLength:1e4,bytes:1024*1024});function E(t){return N(`HTTP JSON body refused: ${t}`)}function ft(t){return["isArgumentsObject","isArrayBuffer","isAnyArrayBuffer","isArrayBufferView","isBoxedPrimitive","isDataView","isDate","isExternal","isGeneratorObject","isKeyObject","isCryptoKey","isMap","isMapIterator","isModuleNamespaceObject","isNativeError","isPromise","isRegExp","isSet","isSetIterator","isTypedArray","isWeakMap","isWeakSet"].some(e=>typeof H[e]=="function"&&H[e](t))}function dt(t){let e=[],r=0,n=0,s=0,u=0,a=new WeakSet,d=o=>{if(r+=Buffer.byteLength(o,"utf8"),r>k.bytes)throw E("serialized byte limit exceeded");e.push(o)},i=o=>{if(Buffer.byteLength(o,"utf8")>k.bytes)throw E("serialized byte limit exceeded");return JSON.stringify(o)},h=(o,p)=>{if(n+=1,n>k.nodes)throw E("node limit exceeded");if(p>k.depth)throw E("depth limit exceeded");if(o===null){d("null");return}if(typeof o=="string"){d(i(o));return}if(typeof o=="boolean"){d(o?"true":"false");return}if(typeof o=="number"){if(!Number.isFinite(o))throw E("non-finite number");d(Object.is(o,-0)?"0":String(o));return}if(typeof o!="object")throw E("unsupported non-JSON value");if(H.isProxy(o))throw E("proxy value");if(ft(o))throw E("unsupported exotic object");if(a.has(o))throw E("cyclic value");a.add(o);try{if(Object.getOwnPropertySymbols(o).length>0)throw E("symbol-keyed fields are unsupported");if(Array.isArray(o)){let c=Object.getPrototypeOf(o),g=0;for(;c!==null;){if(H.isProxy(c))throw E("proxy array prototype");if(g+=1,g>k.depth)throw E("array prototype depth limit exceeded");c=Object.getPrototypeOf(c)}if(o.length>k.arrayLength)throw E("array length limit exceeded");for(let O=0;O<o.length;O+=1){let L=Object.getOwnPropertyDescriptor(o,String(O));if(!L||!Object.hasOwn(L,"value")||L.enumerable!==!0)throw E("array entries must be dense enumerable own data")}let m=0;for(let O in o){if(u+=1,u>k.fields)throw E("enumeration limit exceeded");if(Object.hasOwn(o,O)&&(m+=1,m>o.length))throw E("named array fields are unsupported")}if(m!==o.length)throw E("array entries must be dense enumerable own data");d("[");for(let O=0;O<o.length;O+=1)O&&d(","),h(Object.getOwnPropertyDescriptor(o,String(O)).value,p+1);d("]");return}let T=Object.getPrototypeOf(o);if(T!==Object.prototype&&T!==null)throw E("non-plain object");let l=[];for(let c in o){if(u+=1,u>k.fields)throw E("enumeration limit exceeded");if(!Object.hasOwn(o,c))continue;if(s+=1,s>k.fields)throw E("field limit exceeded");let g=Object.getOwnPropertyDescriptor(o,c);if(!g||!Object.hasOwn(g,"value")||g.enumerable!==!0)throw E("object fields must be enumerable own data");l.push([c,g.value])}d("{");for(let c=0;c<l.length;c+=1)c&&d(","),d(i(l[c][0])),d(":"),h(l[c][1],p+1);d("}")}finally{a.delete(o)}};return h(t,0),e.join("")}function pt(t){let e=Object.create(null);if(t==null)return e;if(typeof t!="object"&&typeof t!="function")throw new TypeError("HTTP headers must be an object");if(H.isProxy(t))throw new TypeError("HTTP headers must not be a proxy");if(Object.getOwnPropertySymbols(t).length>0)throw new TypeError("HTTP headers must not contain symbol fields");let r=new Set;for(let n of Object.keys(t)){if(!/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/u.test(n))throw new TypeError("HTTP header names must be valid tokens");let s=n.toLowerCase();if(r.has(s))throw new TypeError("HTTP headers contain a duplicate canonical name");r.add(s);let u=Object.getOwnPropertyDescriptor(t,n);if(!u||!Object.hasOwn(u,"value"))throw new TypeError("HTTP headers must contain own data properties");let a=u.value;if(a==null||["object","function","symbol"].includes(typeof a))throw new TypeError("HTTP header values must be scalar");e[n]=String(a)}return e}function ht(){return Object.assign(Object.create(null),{Accept:"application/json"})}function mt(t,e){if(!t)throw new Error(`HTTP redirect from ${e} missing Location`);let r=new URL(String(t),String(e));if(r.protocol!=="http:"&&r.protocol!=="https:")throw new Error(`HTTP redirect from ${e} used unsupported protocol ${r.protocol}`);return r.toString()}function yt(t,e){return new URL(String(t)).origin===new URL(String(e)).origin}var ue=new Map,Ae=new WeakMap,_e=1;function Q(t){if((typeof t!="object"||t===null)&&typeof t!="function")return`${typeof t}:${String(t)}`;let e=Ae.get(t);return e||(e=_e,_e+=1,Ae.set(t,e)),`reference:${e}`}var wt=new Set(["eth_blockNumber","eth_call","eth_chainId","eth_estimateGas","getHealth","minimumLedgerSlot","net_version","simulateTransaction","web3_clientVersion"]),bt=new Set(["allMids","l2Book","outcomeMeta","spotClearinghouseState","userFills","meta","metaAndAssetCtxs","perpDexs","candleSnapshot","fundingHistory","openOrders","frontendOpenOrders","clearinghouseState","spotMeta","validatorSummaries","delegatorSummary","delegations","delegatorRewards","delegatorHistory","maxBuilderFee"]);function ve(t){if(!t||typeof t!="object"||Array.isArray(t)||!Object.hasOwn(t,"jsonrpc")||!Object.hasOwn(t,"method")||t.jsonrpc!=="2.0")return!1;let e=typeof t.method=="string"?t.method:"";return e?wt.has(e)||/^get[A-Z0-9_]/u.test(e)||/^is[A-Z0-9_]/u.test(e)||/^eth_get[A-Z0-9_]/u.test(e):!1}function Ie(t,e){if(t==="GET"&&e==null)return!0;if(t!=="POST"||e==null)return!1;let r=e;if(typeof e=="string")try{r=JSON.parse(e)}catch{return!1}if(Array.isArray(r))return r.length>0&&r.every(ve);if(!r||typeof r!="object")return!1;if(Object.hasOwn(r,"jsonrpc")||Object.hasOwn(r,"method"))return ve(r);let n=Object.hasOwn(r,"type")?r.type:null;return typeof n=="string"&&bt.has(n)&&(!Object.hasOwn(r,"action")||r.action==null)&&(!Object.hasOwn(r,"signature")||r.signature==null)&&(!Object.hasOwn(r,"nonce")||r.nonce==null)}function gt(t,e,r,n={},s=null){let u=rt("sha256"),a=(i,h)=>{let o=String(h);u.update(String(Buffer.byteLength(i,"utf8"))).update(":").update(i),u.update("=").update(String(Buffer.byteLength(o,"utf8"))).update(":").update(o).update(`
|
|
2
|
-
`)};a("method",t),a("url",e),Object.keys(r||{}).map((i,h)=>({name:i.toLowerCase(),order:h,value:String(r[i])})).sort((i,h)=>i.name.localeCompare(h.name)||i.order-h.order).forEach((i,h)=>{a(`header-name-${h}`,i.name),a(`header-value-${h}`,i.value)}),a("body",s??"-");for(let i of["untrustedUrl","maxResponseBytes","sameOriginRedirectsOnly","redirectPolicy","maxRedirects","timeoutMs","retries","fetchImpl","realFetch","lookupFn","importUndici","validateResponse"])a(`context-${i}`,n[i]??"-");return u.digest("hex")}function Tt(t,e){let r=Number(e);return Number.isFinite(r)&&r>0?Math.min(r*1e3,Pe):Math.min(250*2**t,Pe)+Math.floor(Math.random()*100)}var Et=t=>new Promise(e=>setTimeout(e,t));function N(t,e={}){let r=new Error(t);return r.retryable=!1,Object.assign(r,e),r}function le(t,e,r){return N(`HTTP response from ${t} exceeded maxResponseBytes ${r} (${e})`,{oversize:!0})}function B(t){try{let e=t?.body?.cancel?.();e&&typeof e.then=="function"&&e.catch(()=>{})}catch{}}function Ot(t){return t?t.byteLength??t.length??0:0}async function St(t,e,{url:r,truncate:n=!1,onOversize:s}={}){if(e==null)return await t.text();let u=Number(t.headers?.get?.("content-length"));if(Number.isFinite(u)&&u>e&&(B(t),!n))throw le(r,`content-length ${u}`,e);let a=t.body?.getReader?.();if(!a){let p=await t.text(),T=Buffer.byteLength(p,"utf8");if(T>e){if(!n)throw le(r,`body ${T} bytes`,e);return Buffer.from(p,"utf8").subarray(0,e).toString("utf8")}return p}let d=[],i=0,h=!1;try{for(;;){let{value:p,done:T}=await a.read();if(T)break;if(p&&(d.push(Buffer.from(p)),i+=Ot(p),i>e)){h=!0;break}}}finally{if(h)try{await a.cancel()}catch{}try{a.releaseLock?.()}catch{}}if(h&&(typeof s=="function"&&s(),!n))throw le(r,`streamed ${i} bytes`,e);let o=Buffer.concat(d);return(h?o.subarray(0,e):o).toString("utf8")}function Pt(t){if(!t)return null;try{return JSON.parse(t)}catch{return null}}async function Rt(t,{fetchImpl:e,method:r,headers:n,body:s,timeoutMs:u,lookupFn:a,realFetch:d,untrustedUrl:i=!1,maxResponseBytes:h=null,sameOriginRedirectsOnly:o=!1,importUndici:p,validateResponse:T,signal:l,redirectPolicy:c="follow",maxRedirects:g=ee}){let m=null,O=e,L=a?{lookupFn:a}:{};if(i&&!d&&!ce(O))throw N(`HTTP refused ${t}: untrustedUrl requires a pin-capable fetchImpl (see markPinCapableFetch in egress-guard.mjs) or no fetchImpl override so Oracle can pin the connection itself`);let A=new AbortController,I=setTimeout(()=>A.abort(),u),z=l?xe?xe([l,A.signal]):l:A.signal,G=async(y,{status:P=null}={})=>{let R=await se(y,L);if(!R.ok)throw N(P==null?`HTTP refused ${y}: ${R.error}`:`HTTP redirect to ${y} ${R.error}`,P==null?{}:{status:P});let M=new URL(y).hostname;if(d){if(m&&(await m.close(),m=null),!m)try{m=await ae({requireUndici:!0,...p?{importUndici:p}:{}})}catch(f){throw N(P==null?`HTTP refused ${y}: ${f?.message||f}`:`HTTP redirect to ${y} refused: ${f?.message||f}`,P==null?{}:{status:P})}m.pin(M,R.addresses),O=m.fetch}else Oe(O,M,R.addresses);return R};try{let y=String(t),P=Object.assign(Object.create(null),n||{});i&&await G(y);for(let R=0;R<=g;R+=1){let M=Object.assign(Object.create(null),{method:r,headers:P,body:s,signal:z,redirect:"manual",dispatcher:void 0}),f=await O(y,M);if((c==="error"||g===0)&&f.status>=300&&f.status<400)throw B(f),N(`HTTP ${f.status} ${r} redirect refused`,{status:f.status,redirectRefused:!0});if(lt.has(f.status)){let _=o===!0&&r==="POST"&&[307,308].includes(f.status)&&Ie(r,s);if(r!=="GET"&&r!=="HEAD"&&!_){B(f);let S=new Error(`HTTP ${f.status} ${r} ${y} redirected non-idempotent request`);throw S.status=f.status,S}if(R===g)throw B(f),N(`HTTP ${f.status} ${r} redirect budget exhausted`,{status:f.status,redirectRefused:!0});let we=f.headers?.get?.("location"),v;try{v=mt(we,y)}catch(S){throw B(f),S}let j=!yt(v,y);if(B(f),j&&r==="POST"){let S=new Error(`HTTP ${f.status} ${r} cross-origin redirect refused`);throw S.status=f.status,S}if(j&&o){let S=new Error(`HTTP ${f.status} ${r} cross-origin redirect refused`);throw S.status=f.status,S.retryable=!1,S}if(j&&(P=ht(P)),i)await G(v,{status:f.status});else if(j){let S=await se(v,L);if(!S.ok){let b=new Error(`HTTP redirect from ${y} ${S.error}`);throw b.status=f.status,b.retryable=!1,b}d&&S.addresses?.length&&(m||(m=await ae(p?{importUndici:p}:{})),m&&(m.pin(new URL(v).hostname,S.addresses),O=m.fetch))}y=v;continue}if(typeof T=="function")try{await T(f,{url:y})}catch(_){throw B(f),N(_?.message||String(_))}let x=await St(f,h,{url:y,onOversize:()=>A.abort()}),V=Pt(x);if(!f.ok){let _=new Error(`HTTP ${f.status} ${r} ${y}`);throw _.status=f.status,_.retryAfter=f.headers?.get?.("retry-after")??null,_.body=V??x.slice(0,300),_}return V??x}throw new Error(`HTTP redirect loop for ${t}`)}catch(y){if(A.signal.aborted&&!W(l)){let P=y&&(typeof y=="object"||typeof y=="function")&&!H.isProxy(y)?y:null,R=P?Object.getOwnPropertyDescriptor(P,"oversize"):null;if(!(R&&Object.hasOwn(R,"value")&&R.value===!0))try{if(!P)throw new TypeError("unsafe rejection");Object.defineProperties(P,{oracleTimeout:{value:!0,enumerable:!1},retryable:{value:!1,enumerable:!1}})}catch{let f=new Error("HTTP request timed out");throw Object.defineProperties(f,{oracleTimeout:{value:!0,enumerable:!1},retryable:{value:!1,enumerable:!1}}),f}}throw y}finally{clearTimeout(I),m&&await m.close()}}async function Ce(t,e={}){if(e!=null&&typeof e!="object"&&typeof e!="function")throw new TypeError("HTTP options must be an object");if(e!=null&&H.isProxy(e))throw new TypeError("HTTP options must not be a proxy");let r=new Set(["body","dedupe","fetchImpl","headers","importUndici","lookupFn","maxRedirects","maxResponseBytes","method","redirectPolicy","retries","sameOriginRedirectsOnly","signal","timeoutMs","untrustedUrl","validateResponse"]);if(e!=null){if(Object.getOwnPropertySymbols(e).length>0)throw new TypeError("HTTP options contain unknown fields");for(let b of Object.getOwnPropertyNames(e)){let w=Object.getOwnPropertyDescriptor(e,b);if(!(b==="toJSON"&&w&&Object.hasOwn(w,"value")&&w.value===void 0)){if(!r.has(b))throw new TypeError("HTTP options contain unknown fields");if(!w||!w.enumerable||!Object.hasOwn(w,"value"))throw new TypeError("HTTP options must contain enumerable own data properties")}}}let n=b=>{if(e==null||!Object.hasOwn(e,b))return;let w=Object.getOwnPropertyDescriptor(e,b);if(!w||!Object.hasOwn(w,"value"))throw new TypeError("HTTP options must contain own data properties");return w.value};if(typeof t!="string"||t.length===0||t.length>8192)throw new TypeError("HTTP URL must be a bounded string");let s=n("method");if(s!==void 0&&(typeof s!="string"||!/^[A-Za-z]+$/u.test(s)))throw new TypeError("HTTP method must be a string token");let u=n("timeoutMs");if(u!==void 0&&(!Number.isInteger(u)||u<1||u>12e4))throw new TypeError("HTTP timeoutMs must be a bounded integer");let a=n("retries");if(a!==void 0&&(!Number.isInteger(a)||a<0||a>10))throw new TypeError("HTTP retries must be a bounded integer");let d=n("redirectPolicy");if(d!==void 0&&d!=="follow"&&d!=="error")throw new TypeError('HTTP redirectPolicy must be "follow" or "error"');let i=n("maxRedirects");if(i!==void 0&&(!Number.isInteger(i)||i<0||i>ee))throw new TypeError(`HTTP maxRedirects must be an integer from 0 through ${ee}`);if(d==="error"&&i!==void 0&&i!==0)throw new TypeError('HTTP redirectPolicy "error" requires maxRedirects 0 when supplied');let h=d??"follow",o=h==="error"?0:i??ee;for(let b of["dedupe","untrustedUrl","sameOriginRedirectsOnly"]){let w=n(b);if(w!==void 0&&typeof w!="boolean")throw new TypeError(`HTTP ${b} must be boolean`)}let p=n("maxResponseBytes");if(p!==void 0&&(!Number.isInteger(p)||p<1||p>64*1024*1024))throw new TypeError("HTTP maxResponseBytes must be a bounded integer");let T=n("signal");if(T!==void 0){if(H.isProxy(T)||!(T instanceof AbortSignal))throw new TypeError("HTTP signal must be a native AbortSignal");try{W(T)}catch{throw new TypeError("HTTP signal must be a native AbortSignal")}}for(let b of["importUndici","lookupFn","validateResponse"]){let w=n(b);if(w!==void 0&&typeof w!="function")throw new TypeError(`HTTP ${b} must be a function`)}let l=n("fetchImpl"),c=l||globalThis.fetch;if(typeof c!="function")throw new Error("fetch unavailable \u2014 pass opts.fetchImpl");let g=u??12e3,m=(s||"GET").toUpperCase(),O=n("headers"),L=pt(O),A=Object.assign(Object.create(null),L);Object.keys(A).some(b=>b.toLowerCase()==="accept")||(A.Accept="application/json");let I=n("body");I!=null&&typeof I!="string"&&(Object.keys(A).find(w=>w.toLowerCase()==="content-type")||(A["Content-Type"]="application/json"),I=dt(I));let z=a??ot,G=n("lookupFn"),y=!l,P=n("untrustedUrl")===!0,R=n("sameOriginRedirectsOnly")===!0,M=n("importUndici"),f=n("validateResponse"),x=T,V=p??null,_=async()=>{let b;for(let w=0;w<=z;w++){x&&it.call(x);let be=Z("http");try{let C=await Rt(t,{fetchImpl:c,method:m,headers:A,body:I,timeoutMs:g,lookupFn:G,realFetch:y,untrustedUrl:P,maxResponseBytes:V,sameOriginRedirectsOnly:R,importUndici:M,validateResponse:f,signal:x,redirectPolicy:h,maxRedirects:o});return be?.("succeeded"),C}catch(C){b=C;let F=re=>{if(!C||typeof C!="object"&&typeof C!="function"||H.isProxy(C))return;let J=Object.getOwnPropertyDescriptor(C,re);return J&&Object.hasOwn(J,"value")?J.value:void 0},K=F("status");be?.("failed",K);let ze=F("oracleTimeout")===!0||F("name")==="AbortError"||F("name")==="TimeoutError"||W(x),Ge=new Set([408,425,429]),Ve=F("retryable")===!1?!1:K!=null?Ge.has(K)||nt.has(K)&&Se.has(m):!ze&&Se.has(m);if(w===z||!Ve)throw C;let ge=Tt(w,F("retryAfter")),Je=Z("retry"),Te=!1;try{x?await new Promise((re,J)=>{let Ee,Y=()=>{clearTimeout(Ee),Re.call(x,"abort",Y),J(ut(x)||new DOMException("Aborted","AbortError"))};if(W(x)){Y();return}Ee=setTimeout(()=>{Re.call(x,"abort",Y),re()},ge),ct.call(x,"abort",Y,{once:!0}),W(x)&&Y()}):await Et(ge),Te=!0}finally{Je?.(Te?"succeeded":"failed")}}}throw b};if(!(n("dedupe")!==!1&&!x&&Ie(m,I)))return _();let v=gt(m,t,A,{untrustedUrl:P,maxResponseBytes:V,sameOriginRedirectsOnly:R,redirectPolicy:h,maxRedirects:o,timeoutMs:g,retries:z,fetchImpl:Q(c),realFetch:y,lookupFn:Q(G),importUndici:Q(M),validateResponse:Q(f)},I),j=ue.get(v);if(j){let b=Z("shared");try{let w=await j;return b?.("succeeded"),w}catch(w){throw b?.("failed"),w}}let S=_().finally(()=>ue.delete(v));return ue.set(v,S),S}var fe={robinhood:{chainId:4663,name:"Robinhood Chain",rpcEnv:["RH_CHAIN_RPC"],evm:!0},ethereum:{chainId:1,name:"Ethereum",rpcEnv:["ETH_RPC_URL","ETHEREUM_RPC_URL","MAINNET_RPC_URL"],evm:!0},polygon:{chainId:137,name:"Polygon",rpcEnv:["POLYGON_RPC_URL","POLYGON_RPC"],evm:!0},arbitrum:{chainId:42161,name:"Arbitrum One",rpcEnv:["ARBITRUM_RPC_URL","ARB_RPC_URL"],evm:!0},base:{chainId:8453,name:"Base",rpcEnv:["BASE_RPC_URL"],evm:!0},hyperevm:{chainId:999,name:"HyperEVM",rpcEnv:["HYPEREVM_RPC_URL","HYPER_EVM_RPC"],evm:!0},bsc:{chainId:56,name:"BNB Smart Chain",rpcEnv:["BSC_RPC_URL","BNB_RPC_URL"],evm:!0},avalanche:{chainId:43114,name:"Avalanche C-Chain",rpcEnv:["AVALANCHE_RPC_URL","AVAX_RPC_URL"],evm:!0},optimism:{chainId:10,name:"OP Mainnet",rpcEnv:["OPTIMISM_RPC_URL","OP_RPC_URL"],evm:!0},abstract:{chainId:2741,name:"Abstract",rpcEnv:["ABSTRACT_RPC_URL","ABS_RPC_URL"],evm:!0},stable:{chainId:988,name:"Stable Mainnet",rpcEnv:["STABLE_RPC_URL","STABLE_RPC"],evm:!0}};var xt=new Map(Object.values(fe).map(t=>[t.chainId,t]));function ke(t){return xt.get(Number(t))||null}function He(t,e=process.env){let r=ke(t);if(!r)return null;for(let n of r.rpcEnv){let s=(e[n]||"").trim();if(s)return s}return null}import{Interface as At,getAddress as fr}from"ethers";var dr=new At(["function allowance(address owner,address spender) view returns (uint256)","function balanceOf(address account) view returns (uint256)"]);var _t={1:"https://ethereum.publicnode.com",137:"https://polygon-bor-rpc.publicnode.com",42161:"https://arbitrum-one-rpc.publicnode.com",8453:"https://base-rpc.publicnode.com",10:"https://optimism-rpc.publicnode.com",988:"https://rpc.stable.xyz",56:"https://bsc-rpc.publicnode.com",43114:"https://avalanche-c-chain-rpc.publicnode.com",999:"https://rpc.hyperliquid.xyz/evm",2741:"https://api.mainnet.abs.xyz",4663:"https://rpc.mainnet.chain.robinhood.com"};function vt(t,{rpcUrl:e,env:r=process.env}={}){if(e)return e;let n=He(t,r);return n||_t[Number(t)]||null}var It=/^(?:eth_(?:call|blocknumber|chainid|get[a-z0-9]+|feehistory|gasprice|maxpriorityfeepergas|syncing|protocolversion|estimategas|createaccesslist)|net_(?:version|listening|peercount)|web3_(?:clientversion|sha3))$/;function Ct(t){let e=String(t||""),r=e.toLowerCase();if(e!==e.trim()||!/^[a-zA-Z0-9_]+$/.test(e)||!It.test(r))throw new Error(`evm-rpc: ${e} refused \u2014 @oracle-agent/oracle is prepare-only (read RPC only; no broadcast/sign)`);return r}var X=new Map,Le=new Map;function kt(t){let e=new Error(t?.message||JSON.stringify(t));return e.code=t?.code,e}function Ht(t){if(t?.error)throw kt(t.error);return t?.result}function Lt(t,e,r){return`${t}
|
|
1
|
+
import{keccak_256 as de}from"@noble/hashes/sha3.js";import{createHash as rt}from"node:crypto";import{types as N}from"node:util";import{AsyncLocalStorage as Je}from"node:async_hooks";var We=new Je,Xe=["http","retry","shared"],Ke=512;function Z(t){let e=We.getStore();if(!e||e.closed||!Xe.includes(t))return null;if(e.spans.length>=Ke)return e.droppedSpans++,null;let r={stage:t,startMs:e.now()-e.start,durationMs:null,outcome:"pending",status:null};return e.spans.push(r),(n,s=null)=>{e.closed||r.durationMs!==null||(r.durationMs=Math.max(0,e.now()-e.start-r.startMs),r.outcome=n==="succeeded"?"succeeded":"failed",r.status=Number.isInteger(s)&&s>=100&&s<=599?s:null)}}import $ from"node:net";import Ze from"node:dns";var qe=new Set(["localhost","metadata.google.internal","metadata.goog"]);function q(t){let e=String(t).toLowerCase().split("%")[0];if((e.match(/::/g)||[]).length>1)return null;let r=o=>{if(!o)return[];let p=o.split(":"),T=p.at(-1);if(T?.includes(".")){let l=T.split(".").map(Number);if(l.length!==4||l.some(c=>!Number.isInteger(c)||c<0||c>255))return null;p.splice(p.length-1,1,(l[0]<<8|l[1]).toString(16),(l[2]<<8|l[3]).toString(16))}return p.some(l=>!/^[0-9a-f]{1,4}$/.test(l))?null:p.map(l=>Number.parseInt(l,16))},[n,s]=e.split("::"),u=r(n),a=r(s);if(!u||!a)return null;let d=e.includes("::"),i=8-u.length-a.length;if(!d&&i!==0||d&&i<1)return null;let h=[...u,...Array(Math.max(0,i)).fill(0),...a];return h.length!==8?null:Uint8Array.from(h.flatMap(o=>[o>>8,o&255]))}function ne(t,e,r){let n=Math.floor(r/8),s=r%8;for(let a=0;a<n;a+=1)if(t[a]!==e[a])return!1;if(!s)return!0;let u=255<<8-s;return(t[n]&u)===(e[n]&u)}function oe(t){if($.isIPv4(t)){let e=t.split(".").map(Number);return!(e[0]===0||e[0]===10||e[0]===127||e[0]>=224||e[0]===100&&e[1]>=64&&e[1]<=127||e[0]===169&&e[1]===254||e[0]===172&&e[1]>=16&&e[1]<=31||e[0]===192&&(e[1]===0||e[1]===2||e[1]===168)||e[0]===192&&e[1]===88&&e[2]===99||e[0]===198&&(e[1]===18||e[1]===19||e[1]===51)||e[0]===203&&e[1]===0&&e[2]===113)}if($.isIPv6(t)){let e=q(t);if(!e)return!1;let r=q("::ffff:0:0");return ne(e,r,96)?oe([...e.slice(12)].join(".")):ne(e,q("2000::"),3)?![["2001::",23],["2001:db8::",32],["2001:10::",28],["2001:2::",48],["2002::",16],["3fff::",20]].some(([s,u])=>ne(e,q(s),u)):!1}return!1}function Qe(t){let e;try{e=new URL(String(t))}catch{return{ok:!1,error:`not a valid URL: ${String(t).slice(0,120)}`}}if(e.protocol!=="http:"&&e.protocol!=="https:")return{ok:!1,error:`refused protocol ${e.protocol} (only http/https)`};let r=e.hostname.toLowerCase().replace(/^\[|\]$/g,"").replace(/\.+$/,"");if(qe.has(r)||r.endsWith(".localhost")||r.endsWith(".internal"))return{ok:!1,error:`refused internal host ${r}`};let n=$.isIP(r);return n!==0&&!oe(r)?{ok:!1,error:`refused private address ${r}`}:{ok:!0,url:e,host:r,isLiteralIp:n!==0}}async function se(t,{lookupFn:e=Ze.promises.lookup}={}){let r=Qe(t);if(!r.ok)return r;if(r.isLiteralIp)return{ok:!0,url:r.url,addresses:[{address:r.host,family:$.isIPv6(r.host)?6:4}]};let n;if(process.env.ORACLE_HOSTED_EGRESS_PROXY)return{ok:!0,url:r.url,addresses:[]};try{n=await e(r.host,{all:!0,verbatim:!0})}catch{return{ok:!1,error:`refused: ${r.host} did not resolve`}}return!Array.isArray(n)||n.length===0||n.some(s=>!oe(s.address))?{ok:!1,error:`refused: ${r.host} resolves to a non-public address`}:{ok:!0,url:r.url,addresses:n}}function et(t=process.env){let e=t.ORACLE_HOSTED_EGRESS_PROXY||"";if(!e)return null;let r;try{r=new URL(e)}catch{throw new Error("egress-guard: ORACLE_HOSTED_EGRESS_PROXY is not a URL")}if(r.protocol!=="http:"||!["127.0.0.1","::1","localhost","[::1]"].includes(r.hostname)||!r.port||r.username||r.password)throw new Error("egress-guard: egress proxy must be an exact loopback http origin");let n=t.ORACLE_HOSTED_EGRESS_TOKEN||"";if(!/^[A-Za-z0-9_-]{43}$/.test(n))throw new Error("egress-guard: egress proxy token is missing");return{uri:r.origin,token:n}}async function ae({requireUndici:t=!1,importUndici:e=()=>import("undici")}={}){let r,n,s;try{s=await e(),r=s.Agent,n=s.fetch}catch(l){if(t)throw new Error(`egress-guard: untrustedUrl pinning requires the undici package, which failed to load: ${l?.message||l}`);return null}if(typeof r!="function"||typeof n!="function"){if(t)throw new Error("egress-guard: untrustedUrl pinning requires undici's Agent and fetch exports, which were not found on the imported module");return null}let u=l=>String(l).toLowerCase().replace(/^\[|\]$/g,"").replace(/\.+$/,""),a=new Map,d=l=>(Array.isArray(l)?l:[l]).map(c=>typeof c=="string"?{address:c}:c).filter(c=>c&&c.address).map(c=>({address:c.address,family:c.family||($.isIPv6(c.address)?6:4)})),i=(l,c,g)=>{a.set(u(l),d(typeof c=="string"?[{address:c,family:g}]:c))},h=l=>{let c=u(l);if($.isIP(c))return[{address:c,family:$.isIPv6(c)?6:4}];let g=a.get(c);if(!g||!g.length)throw new Error(`refused: unpinned host ${l} during pinned fetch`);return g},o=et(),p=o&&typeof s.ProxyAgent=="function"?new s.ProxyAgent({uri:o.uri,token:`Bearer ${o.token}`,connectTimeout:1e4}):new r({connect:{lookup(l,c,g){let m;try{m=h(l)}catch(O){return g(O)}return c?.all?g(null,m):g(null,m[0].address,m[0].family)}}}),T=tt((l,c={})=>n(l,{...c,dispatcher:p}),i);return{dispatcher:p,fetch:T,pin:i,resolve:h,async close(){try{await p.destroy()}catch{}}}}var ie=Symbol.for("oracle.egressGuard.pinCapableFetch");function tt(t,e){if(typeof t!="function")throw new Error("markPinCapableFetch: fetchImpl must be a function");if(typeof e!="function")throw new Error("markPinCapableFetch: pin must be a function");return t[ie]=Object.freeze({pin:e}),t}function ce(t){return typeof t=="function"&&typeof t[ie]?.pin=="function"}function Oe(t,e,r){if(!ce(t))throw new Error("pinFetchToAddresses: fetchImpl is not pin-capable");t[ie].pin(e,r)}var nt=new Set([408,425,429,500,502,503,504]),Se=new Set(["GET","HEAD","OPTIONS","PUT","DELETE"]),ot=2,Pe=4e3,st=Object.getOwnPropertyDescriptor(AbortSignal.prototype,"aborted")?.get,at=Object.getOwnPropertyDescriptor(AbortSignal.prototype,"reason")?.get,it=AbortSignal.prototype.throwIfAborted,ct=EventTarget.prototype.addEventListener,Re=EventTarget.prototype.removeEventListener,xe=typeof AbortSignal.any=="function"?AbortSignal.any.bind(AbortSignal):null,W=t=>t?st.call(t):!1,ut=t=>t?at.call(t):void 0,lt=new Set([301,302,303,307,308]),ee=3,rr=64*1024,k=Object.freeze({depth:32,nodes:1e4,fields:1e4,arrayLength:1e4,bytes:1024*1024});function E(t){return M(`HTTP JSON body refused: ${t}`)}function ft(t){return["isArgumentsObject","isArrayBuffer","isAnyArrayBuffer","isArrayBufferView","isBoxedPrimitive","isDataView","isDate","isExternal","isGeneratorObject","isKeyObject","isCryptoKey","isMap","isMapIterator","isModuleNamespaceObject","isNativeError","isPromise","isRegExp","isSet","isSetIterator","isTypedArray","isWeakMap","isWeakSet"].some(e=>typeof N[e]=="function"&&N[e](t))}function dt(t){let e=[],r=0,n=0,s=0,u=0,a=new WeakSet,d=o=>{if(r+=Buffer.byteLength(o,"utf8"),r>k.bytes)throw E("serialized byte limit exceeded");e.push(o)},i=o=>{if(Buffer.byteLength(o,"utf8")>k.bytes)throw E("serialized byte limit exceeded");return JSON.stringify(o)},h=(o,p)=>{if(n+=1,n>k.nodes)throw E("node limit exceeded");if(p>k.depth)throw E("depth limit exceeded");if(o===null){d("null");return}if(typeof o=="string"){d(i(o));return}if(typeof o=="boolean"){d(o?"true":"false");return}if(typeof o=="number"){if(!Number.isFinite(o))throw E("non-finite number");d(Object.is(o,-0)?"0":String(o));return}if(typeof o!="object")throw E("unsupported non-JSON value");if(N.isProxy(o))throw E("proxy value");if(ft(o))throw E("unsupported exotic object");if(a.has(o))throw E("cyclic value");a.add(o);try{if(Object.getOwnPropertySymbols(o).length>0)throw E("symbol-keyed fields are unsupported");if(Array.isArray(o)){let c=Object.getPrototypeOf(o),g=0;for(;c!==null;){if(N.isProxy(c))throw E("proxy array prototype");if(g+=1,g>k.depth)throw E("array prototype depth limit exceeded");c=Object.getPrototypeOf(c)}if(o.length>k.arrayLength)throw E("array length limit exceeded");for(let O=0;O<o.length;O+=1){let H=Object.getOwnPropertyDescriptor(o,String(O));if(!H||!Object.hasOwn(H,"value")||H.enumerable!==!0)throw E("array entries must be dense enumerable own data")}let m=0;for(let O in o){if(u+=1,u>k.fields)throw E("enumeration limit exceeded");if(Object.hasOwn(o,O)&&(m+=1,m>o.length))throw E("named array fields are unsupported")}if(m!==o.length)throw E("array entries must be dense enumerable own data");d("[");for(let O=0;O<o.length;O+=1)O&&d(","),h(Object.getOwnPropertyDescriptor(o,String(O)).value,p+1);d("]");return}let T=Object.getPrototypeOf(o);if(T!==Object.prototype&&T!==null)throw E("non-plain object");let l=[];for(let c in o){if(u+=1,u>k.fields)throw E("enumeration limit exceeded");if(!Object.hasOwn(o,c))continue;if(s+=1,s>k.fields)throw E("field limit exceeded");let g=Object.getOwnPropertyDescriptor(o,c);if(!g||!Object.hasOwn(g,"value")||g.enumerable!==!0)throw E("object fields must be enumerable own data");l.push([c,g.value])}d("{");for(let c=0;c<l.length;c+=1)c&&d(","),d(i(l[c][0])),d(":"),h(l[c][1],p+1);d("}")}finally{a.delete(o)}};return h(t,0),e.join("")}function pt(t){let e=Object.create(null);if(t==null)return e;if(typeof t!="object"&&typeof t!="function")throw new TypeError("HTTP headers must be an object");if(N.isProxy(t))throw new TypeError("HTTP headers must not be a proxy");if(Object.getOwnPropertySymbols(t).length>0)throw new TypeError("HTTP headers must not contain symbol fields");let r=new Set;for(let n of Object.keys(t)){if(!/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/u.test(n))throw new TypeError("HTTP header names must be valid tokens");let s=n.toLowerCase();if(r.has(s))throw new TypeError("HTTP headers contain a duplicate canonical name");r.add(s);let u=Object.getOwnPropertyDescriptor(t,n);if(!u||!Object.hasOwn(u,"value"))throw new TypeError("HTTP headers must contain own data properties");let a=u.value;if(a==null||["object","function","symbol"].includes(typeof a))throw new TypeError("HTTP header values must be scalar");e[n]=String(a)}return e}function ht(){return Object.assign(Object.create(null),{Accept:"application/json"})}function mt(t,e){if(!t)throw new Error(`HTTP redirect from ${e} missing Location`);let r=new URL(String(t),String(e));if(r.protocol!=="http:"&&r.protocol!=="https:")throw new Error(`HTTP redirect from ${e} used unsupported protocol ${r.protocol}`);return r.toString()}function yt(t,e){return new URL(String(t)).origin===new URL(String(e)).origin}var ue=new Map,Ae=new WeakMap,_e=1;function Q(t){if((typeof t!="object"||t===null)&&typeof t!="function")return`${typeof t}:${String(t)}`;let e=Ae.get(t);return e||(e=_e,_e+=1,Ae.set(t,e)),`reference:${e}`}var wt=new Set(["eth_blockNumber","eth_call","eth_chainId","eth_estimateGas","getHealth","minimumLedgerSlot","net_version","simulateTransaction","web3_clientVersion"]),bt=new Set(["allMids","l2Book","outcomeMeta","spotClearinghouseState","userFills","meta","metaAndAssetCtxs","perpDexs","candleSnapshot","fundingHistory","openOrders","frontendOpenOrders","clearinghouseState","spotMeta","validatorSummaries","delegatorSummary","delegations","delegatorRewards","delegatorHistory","maxBuilderFee"]);function ve(t){if(!t||typeof t!="object"||Array.isArray(t)||!Object.hasOwn(t,"jsonrpc")||!Object.hasOwn(t,"method")||t.jsonrpc!=="2.0")return!1;let e=typeof t.method=="string"?t.method:"";return e?wt.has(e)||/^get[A-Z0-9_]/u.test(e)||/^is[A-Z0-9_]/u.test(e)||/^eth_get[A-Z0-9_]/u.test(e):!1}function Ie(t,e){if(t==="GET"&&e==null)return!0;if(t!=="POST"||e==null)return!1;let r=e;if(typeof e=="string")try{r=JSON.parse(e)}catch{return!1}if(Array.isArray(r))return r.length>0&&r.every(ve);if(!r||typeof r!="object")return!1;if(Object.hasOwn(r,"jsonrpc")||Object.hasOwn(r,"method"))return ve(r);let n=Object.hasOwn(r,"type")?r.type:null;return typeof n=="string"&&bt.has(n)&&(!Object.hasOwn(r,"action")||r.action==null)&&(!Object.hasOwn(r,"signature")||r.signature==null)&&(!Object.hasOwn(r,"nonce")||r.nonce==null)}function gt(t,e,r,n={},s=null){let u=rt("sha256"),a=(i,h)=>{let o=String(h);u.update(String(Buffer.byteLength(i,"utf8"))).update(":").update(i),u.update("=").update(String(Buffer.byteLength(o,"utf8"))).update(":").update(o).update(`
|
|
2
|
+
`)};a("method",t),a("url",e),Object.keys(r||{}).map((i,h)=>({name:i.toLowerCase(),order:h,value:String(r[i])})).sort((i,h)=>i.name.localeCompare(h.name)||i.order-h.order).forEach((i,h)=>{a(`header-name-${h}`,i.name),a(`header-value-${h}`,i.value)}),a("body",s??"-");for(let i of["untrustedUrl","maxResponseBytes","sameOriginRedirectsOnly","redirectPolicy","maxRedirects","timeoutMs","retries","fetchImpl","realFetch","lookupFn","importUndici","validateResponse"])a(`context-${i}`,n[i]??"-");return u.digest("hex")}function Tt(t,e){let r=Number(e);return Number.isFinite(r)&&r>0?Math.min(r*1e3,Pe):Math.min(250*2**t,Pe)+Math.floor(Math.random()*100)}var Et=t=>new Promise(e=>setTimeout(e,t));function M(t,e={}){let r=new Error(t);return r.retryable=!1,Object.assign(r,e),r}function le(t,e,r){return M(`HTTP response from ${t} exceeded maxResponseBytes ${r} (${e})`,{oversize:!0})}function B(t){try{let e=t?.body?.cancel?.();e&&typeof e.then=="function"&&e.catch(()=>{})}catch{}}function Ot(t){return t?t.byteLength??t.length??0:0}async function St(t,e,{url:r,truncate:n=!1,onOversize:s}={}){if(e==null)return await t.text();let u=Number(t.headers?.get?.("content-length"));if(Number.isFinite(u)&&u>e&&(B(t),!n))throw le(r,`content-length ${u}`,e);let a=t.body?.getReader?.();if(!a){let p=await t.text(),T=Buffer.byteLength(p,"utf8");if(T>e){if(!n)throw le(r,`body ${T} bytes`,e);return Buffer.from(p,"utf8").subarray(0,e).toString("utf8")}return p}let d=[],i=0,h=!1;try{for(;;){let{value:p,done:T}=await a.read();if(T)break;if(p&&(d.push(Buffer.from(p)),i+=Ot(p),i>e)){h=!0;break}}}finally{if(h)try{await a.cancel()}catch{}try{a.releaseLock?.()}catch{}}if(h&&(typeof s=="function"&&s(),!n))throw le(r,`streamed ${i} bytes`,e);let o=Buffer.concat(d);return(h?o.subarray(0,e):o).toString("utf8")}function Pt(t){if(!t)return null;try{return JSON.parse(t)}catch{return null}}async function Rt(t,{fetchImpl:e,method:r,headers:n,body:s,timeoutMs:u,lookupFn:a,realFetch:d,untrustedUrl:i=!1,maxResponseBytes:h=null,sameOriginRedirectsOnly:o=!1,importUndici:p,validateResponse:T,signal:l,redirectPolicy:c="follow",maxRedirects:g=ee}){let m=null,O=e,H=a?{lookupFn:a}:{};if(i&&!d&&!ce(O))throw M(`HTTP refused ${t}: untrustedUrl requires a pin-capable fetchImpl (see markPinCapableFetch in egress-guard.mjs) or no fetchImpl override so Oracle can pin the connection itself`);let A=new AbortController,I=setTimeout(()=>A.abort(),u),z=l?xe?xe([l,A.signal]):l:A.signal,G=async(y,{status:P=null}={})=>{let R=await se(y,H);if(!R.ok)throw M(P==null?`HTTP refused ${y}: ${R.error}`:`HTTP redirect to ${y} ${R.error}`,P==null?{}:{status:P});let L=new URL(y).hostname;if(d){if(m&&(await m.close(),m=null),!m)try{m=await ae({requireUndici:!0,...p?{importUndici:p}:{}})}catch(f){throw M(P==null?`HTTP refused ${y}: ${f?.message||f}`:`HTTP redirect to ${y} refused: ${f?.message||f}`,P==null?{}:{status:P})}m.pin(L,R.addresses),O=m.fetch}else Oe(O,L,R.addresses);return R};try{let y=String(t),P=Object.assign(Object.create(null),n||{});i&&await G(y);for(let R=0;R<=g;R+=1){let L=Object.assign(Object.create(null),{method:r,headers:P,body:s,signal:z,redirect:"manual",dispatcher:void 0}),f=await O(y,L);if((c==="error"||g===0)&&f.status>=300&&f.status<400)throw B(f),M(`HTTP ${f.status} ${r} redirect refused`,{status:f.status,redirectRefused:!0});if(lt.has(f.status)){let _=o===!0&&r==="POST"&&[307,308].includes(f.status)&&Ie(r,s);if(r!=="GET"&&r!=="HEAD"&&!_){B(f);let S=new Error(`HTTP ${f.status} ${r} ${y} redirected non-idempotent request`);throw S.status=f.status,S}if(R===g)throw B(f),M(`HTTP ${f.status} ${r} redirect budget exhausted`,{status:f.status,redirectRefused:!0});let we=f.headers?.get?.("location"),v;try{v=mt(we,y)}catch(S){throw B(f),S}let j=!yt(v,y);if(B(f),j&&r==="POST"){let S=new Error(`HTTP ${f.status} ${r} cross-origin redirect refused`);throw S.status=f.status,S}if(j&&o){let S=new Error(`HTTP ${f.status} ${r} cross-origin redirect refused`);throw S.status=f.status,S.retryable=!1,S}if(j&&(P=ht(P)),i)await G(v,{status:f.status});else if(j){let S=await se(v,H);if(!S.ok){let b=new Error(`HTTP redirect from ${y} ${S.error}`);throw b.status=f.status,b.retryable=!1,b}d&&S.addresses?.length&&(m||(m=await ae(p?{importUndici:p}:{})),m&&(m.pin(new URL(v).hostname,S.addresses),O=m.fetch))}y=v;continue}if(typeof T=="function")try{await T(f,{url:y})}catch(_){throw B(f),M(_?.message||String(_))}let x=await St(f,h,{url:y,onOversize:()=>A.abort()}),V=Pt(x);if(!f.ok){let _=new Error(`HTTP ${f.status} ${r} ${y}`);throw _.status=f.status,_.retryAfter=f.headers?.get?.("retry-after")??null,_.body=V??x.slice(0,300),_}return V??x}throw new Error(`HTTP redirect loop for ${t}`)}catch(y){if(A.signal.aborted&&!W(l)){let P=y&&(typeof y=="object"||typeof y=="function")&&!N.isProxy(y)?y:null,R=P?Object.getOwnPropertyDescriptor(P,"oversize"):null;if(!(R&&Object.hasOwn(R,"value")&&R.value===!0))try{if(!P)throw new TypeError("unsafe rejection");Object.defineProperties(P,{oracleTimeout:{value:!0,enumerable:!1},retryable:{value:!1,enumerable:!1}})}catch{let f=new Error("HTTP request timed out");throw Object.defineProperties(f,{oracleTimeout:{value:!0,enumerable:!1},retryable:{value:!1,enumerable:!1}}),f}}throw y}finally{clearTimeout(I),m&&await m.close()}}async function Ce(t,e={}){if(e!=null&&typeof e!="object"&&typeof e!="function")throw new TypeError("HTTP options must be an object");if(e!=null&&N.isProxy(e))throw new TypeError("HTTP options must not be a proxy");let r=new Set(["body","dedupe","fetchImpl","headers","importUndici","lookupFn","maxRedirects","maxResponseBytes","method","redirectPolicy","retries","sameOriginRedirectsOnly","signal","timeoutMs","untrustedUrl","validateResponse"]);if(e!=null){if(Object.getOwnPropertySymbols(e).length>0)throw new TypeError("HTTP options contain unknown fields");for(let b of Object.getOwnPropertyNames(e)){let w=Object.getOwnPropertyDescriptor(e,b);if(!(b==="toJSON"&&w&&Object.hasOwn(w,"value")&&w.value===void 0)){if(!r.has(b))throw new TypeError("HTTP options contain unknown fields");if(!w||!w.enumerable||!Object.hasOwn(w,"value"))throw new TypeError("HTTP options must contain enumerable own data properties")}}}let n=b=>{if(e==null||!Object.hasOwn(e,b))return;let w=Object.getOwnPropertyDescriptor(e,b);if(!w||!Object.hasOwn(w,"value"))throw new TypeError("HTTP options must contain own data properties");return w.value};if(typeof t!="string"||t.length===0||t.length>8192)throw new TypeError("HTTP URL must be a bounded string");let s=n("method");if(s!==void 0&&(typeof s!="string"||!/^[A-Za-z]+$/u.test(s)))throw new TypeError("HTTP method must be a string token");let u=n("timeoutMs");if(u!==void 0&&(!Number.isInteger(u)||u<1||u>12e4))throw new TypeError("HTTP timeoutMs must be a bounded integer");let a=n("retries");if(a!==void 0&&(!Number.isInteger(a)||a<0||a>10))throw new TypeError("HTTP retries must be a bounded integer");let d=n("redirectPolicy");if(d!==void 0&&d!=="follow"&&d!=="error")throw new TypeError('HTTP redirectPolicy must be "follow" or "error"');let i=n("maxRedirects");if(i!==void 0&&(!Number.isInteger(i)||i<0||i>ee))throw new TypeError(`HTTP maxRedirects must be an integer from 0 through ${ee}`);if(d==="error"&&i!==void 0&&i!==0)throw new TypeError('HTTP redirectPolicy "error" requires maxRedirects 0 when supplied');let h=d??"follow",o=h==="error"?0:i??ee;for(let b of["dedupe","untrustedUrl","sameOriginRedirectsOnly"]){let w=n(b);if(w!==void 0&&typeof w!="boolean")throw new TypeError(`HTTP ${b} must be boolean`)}let p=n("maxResponseBytes");if(p!==void 0&&(!Number.isInteger(p)||p<1||p>64*1024*1024))throw new TypeError("HTTP maxResponseBytes must be a bounded integer");let T=n("signal");if(T!==void 0){if(N.isProxy(T)||!(T instanceof AbortSignal))throw new TypeError("HTTP signal must be a native AbortSignal");try{W(T)}catch{throw new TypeError("HTTP signal must be a native AbortSignal")}}for(let b of["importUndici","lookupFn","validateResponse"]){let w=n(b);if(w!==void 0&&typeof w!="function")throw new TypeError(`HTTP ${b} must be a function`)}let l=n("fetchImpl"),c=l||globalThis.fetch;if(typeof c!="function")throw new Error("fetch unavailable \u2014 pass opts.fetchImpl");let g=u??12e3,m=(s||"GET").toUpperCase(),O=n("headers"),H=pt(O),A=Object.assign(Object.create(null),H);Object.keys(A).some(b=>b.toLowerCase()==="accept")||(A.Accept="application/json");let I=n("body");I!=null&&typeof I!="string"&&(Object.keys(A).find(w=>w.toLowerCase()==="content-type")||(A["Content-Type"]="application/json"),I=dt(I));let z=a??ot,G=n("lookupFn"),y=!l,P=n("untrustedUrl")===!0,R=n("sameOriginRedirectsOnly")===!0,L=n("importUndici"),f=n("validateResponse"),x=T,V=p??null,_=async()=>{let b;for(let w=0;w<=z;w++){x&&it.call(x);let be=Z("http");try{let C=await Rt(t,{fetchImpl:c,method:m,headers:A,body:I,timeoutMs:g,lookupFn:G,realFetch:y,untrustedUrl:P,maxResponseBytes:V,sameOriginRedirectsOnly:R,importUndici:L,validateResponse:f,signal:x,redirectPolicy:h,maxRedirects:o});return be?.("succeeded"),C}catch(C){b=C;let F=re=>{if(!C||typeof C!="object"&&typeof C!="function"||N.isProxy(C))return;let Y=Object.getOwnPropertyDescriptor(C,re);return Y&&Object.hasOwn(Y,"value")?Y.value:void 0},K=F("status");be?.("failed",K);let ze=F("oracleTimeout")===!0||F("name")==="AbortError"||F("name")==="TimeoutError"||W(x),Ge=new Set([408,425,429]),Ve=F("retryable")===!1?!1:K!=null?Ge.has(K)||nt.has(K)&&Se.has(m):!ze&&Se.has(m);if(w===z||!Ve)throw C;let ge=Tt(w,F("retryAfter")),Ye=Z("retry"),Te=!1;try{x?await new Promise((re,Y)=>{let Ee,J=()=>{clearTimeout(Ee),Re.call(x,"abort",J),Y(ut(x)||new DOMException("Aborted","AbortError"))};if(W(x)){J();return}Ee=setTimeout(()=>{Re.call(x,"abort",J),re()},ge),ct.call(x,"abort",J,{once:!0}),W(x)&&J()}):await Et(ge),Te=!0}finally{Ye?.(Te?"succeeded":"failed")}}}throw b};if(!(n("dedupe")!==!1&&!x&&Ie(m,I)))return _();let v=gt(m,t,A,{untrustedUrl:P,maxResponseBytes:V,sameOriginRedirectsOnly:R,redirectPolicy:h,maxRedirects:o,timeoutMs:g,retries:z,fetchImpl:Q(c),realFetch:y,lookupFn:Q(G),importUndici:Q(L),validateResponse:Q(f)},I),j=ue.get(v);if(j){let b=Z("shared");try{let w=await j;return b?.("succeeded"),w}catch(w){throw b?.("failed"),w}}let S=_().finally(()=>ue.delete(v));return ue.set(v,S),S}var fe={robinhood:{chainId:4663,name:"Robinhood Chain",rpcEnv:["RH_CHAIN_RPC"],evm:!0},ethereum:{chainId:1,name:"Ethereum",rpcEnv:["ETH_RPC_URL","ETHEREUM_RPC_URL","MAINNET_RPC_URL"],evm:!0},polygon:{chainId:137,name:"Polygon",rpcEnv:["POLYGON_RPC_URL","POLYGON_RPC"],evm:!0},arbitrum:{chainId:42161,name:"Arbitrum One",rpcEnv:["ARBITRUM_RPC_URL","ARB_RPC_URL"],evm:!0},base:{chainId:8453,name:"Base",rpcEnv:["BASE_RPC_URL"],evm:!0},hyperevm:{chainId:999,name:"HyperEVM",rpcEnv:["HYPEREVM_RPC_URL","HYPER_EVM_RPC"],evm:!0},bsc:{chainId:56,name:"BNB Smart Chain",rpcEnv:["BSC_RPC_URL","BNB_RPC_URL"],evm:!0},avalanche:{chainId:43114,name:"Avalanche C-Chain",rpcEnv:["AVALANCHE_RPC_URL","AVAX_RPC_URL"],evm:!0},optimism:{chainId:10,name:"OP Mainnet",rpcEnv:["OPTIMISM_RPC_URL","OP_RPC_URL"],evm:!0},abstract:{chainId:2741,name:"Abstract",rpcEnv:["ABSTRACT_RPC_URL","ABS_RPC_URL"],evm:!0},stable:{chainId:988,name:"Stable Mainnet",rpcEnv:["STABLE_RPC_URL","STABLE_RPC"],evm:!0},elysium:{chainId:1339,name:"Elysium",rpcEnv:["ELYSIUM_RPC_URL"],evm:!0,readOnly:!0}};var xt=new Map(Object.values(fe).map(t=>[t.chainId,t]));function ke(t){return xt.get(Number(t))||null}function Ne(t,e=process.env){let r=ke(t);if(!r)return null;for(let n of r.rpcEnv){let s=(e[n]||"").trim();if(s)return s}return null}import{Interface as At,getAddress as fr}from"ethers";var dr=new At(["function allowance(address owner,address spender) view returns (uint256)","function balanceOf(address account) view returns (uint256)"]);var _t={1:"https://ethereum.publicnode.com",137:"https://polygon-bor-rpc.publicnode.com",42161:"https://arbitrum-one-rpc.publicnode.com",8453:"https://base-rpc.publicnode.com",10:"https://optimism-rpc.publicnode.com",988:"https://rpc.stable.xyz",56:"https://bsc-rpc.publicnode.com",43114:"https://avalanche-c-chain-rpc.publicnode.com",999:"https://rpc.hyperliquid.xyz/evm",2741:"https://api.mainnet.abs.xyz",4663:"https://rpc.mainnet.chain.robinhood.com",1339:"https://rpc.elysiumchain.tech"};function vt(t,{rpcUrl:e,env:r=process.env}={}){if(e)return e;let n=Ne(t,r);return n||_t[Number(t)]||null}var It=/^(?:eth_(?:call|blocknumber|chainid|get[a-z0-9]+|feehistory|gasprice|maxpriorityfeepergas|syncing|protocolversion|estimategas|createaccesslist)|net_(?:version|listening|peercount)|web3_(?:clientversion|sha3))$/;function Ct(t){let e=String(t||""),r=e.toLowerCase();if(e!==e.trim()||!/^[a-zA-Z0-9_]+$/.test(e)||!It.test(r))throw new Error(`evm-rpc: ${e} refused \u2014 @oracle-agent/oracle is prepare-only (read RPC only; no broadcast/sign)`);return r}var X=new Map,He=new Map;function kt(t){let e=new Error(t?.message||JSON.stringify(t));return e.code=t?.code,e}function Nt(t){if(t?.error)throw kt(t.error);return t?.result}function Ht(t,e,r){return`${t}
|
|
3
3
|
${e}
|
|
4
|
-
${JSON.stringify(r??[])}`}async function
|
|
4
|
+
${JSON.stringify(r??[])}`}async function Lt(t,e,r){return Ce(t,{method:"POST",body:e,fetchImpl:r.fetchImpl,timeoutMs:r.timeoutMs??12e3,signal:r.signal})}async function Le(t,e,r=[],n={}){let s=String(e||""),u=Ct(s),a=vt(t,n);if(!a)throw new Error(`No RPC URL for chainId ${t} (set env from chain registry rpcEnv or pass rpcUrl)`);if(u==="eth_chainid"&&n.cacheChainId!==!1){let o=He.get(a);if(o!=null)return o}let i=n.dedupe!==!1&&!n.signal?Ht(a,s,r):null;if(i&&X.has(i))return X.get(i);let h=(async()=>{let o=await Lt(a,{jsonrpc:"2.0",id:1,method:e,params:r},n),p=Nt(o);return u==="eth_chainid"&&typeof p=="string"&&He.set(a,p),p})();return i&&(X.set(i,h),h.finally(()=>{X.get(i)===h&&X.delete(i)}).catch(()=>{})),h}var he=999,pe=1,Mt=8453,Me="0x1d9d87eBc14e71490bB87f1C39F65BDB979f3cb7",jt="0x4d5e4ed4D5e4A160Fa136853597cDc2eBBe66494",je="0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",$t="0xC6d566A56A1aFf6508b41f6c90ff131615583BCD",Bt=".80002105.reverse",$e=/^0x[a-fA-F0-9]{40}$/,me=new TextEncoder,Be=t=>"0x"+Buffer.from(t).toString("hex"),U=t=>Be(de(me.encode(t))).slice(0,10),Ue=t=>t.toLowerCase().replace(/^0x/,"").padStart(64,"0");function te(t){let e=new Uint8Array(32);if(t)for(let r of String(t).split(".").reverse()){let n=de(me.encode(r)),s=new Uint8Array(64);s.set(e,0),s.set(n,32),e=de(s)}return Be(e)}function ye(t){if(!t||t==="0x"||/^0x0*$/.test(t))return"";try{let e=t.slice(2),r=parseInt(e.slice(0,64),16)*2,n=parseInt(e.slice(r,r+64),16);if(!Number.isFinite(n)||n<=0)return"";let s=e.slice(r+64,r+64+n*2);return Buffer.from(s,"hex").toString("utf8")}catch{return""}}function yr(t){let e=me.encode(String(t)),r=e.length.toString(16).padStart(64,"0"),n=Buffer.from(e).toString("hex").padEnd(Math.ceil(e.length/32)*64,"0");return"0000000000000000000000000000000000000000000000000000000000000020"+r+n}async function D(t,e,r){try{return await Le(t,"eth_call",[{to:e,data:r},"latest"])}catch{return null}}async function Ut(t){let e=await D(he,Me,U("primaryName(address)")+Ue(t)),r=ye(e);return r?r.endsWith(".hl")?r:`${r}.hl`:null}async function Dt(t){let e=await D(he,jt,U("getName(address)")+Ue(t)),r=ye(e);return r?r.endsWith(".hype")?r:`${r}.hype`:null}async function De(t,e,r){let n=await D(t,r,U("name(bytes32)")+e.slice(2));return ye(n)||null}async function Ft(t){let e=te(`${t.slice(2).toLowerCase()}.addr.reverse`),r=await D(pe,je,U("resolver(bytes32)")+e.slice(2));if(!r)return null;let n="0x"+r.slice(-40);return/^0x0+$/.test(n)?null:De(pe,e,n)}async function zt(t){let e=te(t.slice(2).toLowerCase()+Bt);return De(Mt,e,$t)}var Fe=[{source:"hl",fn:Ut},{source:"hype",fn:Dt},{source:"ens",fn:Ft},{source:"basename",fn:zt}];async function wr(t){if(!$e.test(String(t||"").trim()))return null;let e=String(t).trim();return(await Promise.all(Fe.map(async({source:n,fn:s})=>{try{let u=await s(e);return u?{name:u,source:n,address:e}:null}catch{return null}}))).find(Boolean)||null}async function Gt(t){let e=te(t),r=await D(he,Me,U("ownerOf(uint256)")+e.slice(2));if(!r||r.length<66)return null;let n="0x"+r.slice(-40);return/^0x0+$/.test(n)?null:n}async function Vt(t,e,r){let n=te(e),s=await D(t,r,U("resolver(bytes32)")+n.slice(2));if(!s)return null;let u="0x"+s.slice(-40);if(/^0x0+$/.test(u))return null;let a=await D(t,u,U("addr(bytes32)")+n.slice(2));if(!a)return null;let d="0x"+a.slice(-40);return/^0x0+$/.test(d)?null:d}async function Yt(t){let e=String(t||"").trim().toLowerCase();if(!e||!e.includes("."))return null;if(e.endsWith(".hl")){let r=await Gt(e);return r?{address:r,source:"hl",name:e}:null}if(e.endsWith(".eth")){let r=await Vt(pe,e,je);return r?{address:r,source:e.endsWith(".base.eth")?"basename":"ens",name:e}:null}return null}async function br(t){let e=String(t||"").trim();return $e.test(e)?{address:e,source:"address",name:null}:Yt(e)}var gr=Fe.map(t=>t.source);export{$e as ADDRESS_RE,gr as NAME_SOURCES,ye as decodeAbiString,yr as encodeAbiString,wr as lookupName,te as namehash,Yt as resolveName,br as toAddress};
|