@oracle-agent/oracle 0.13.1 → 0.14.1
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/CONTRIBUTING.md +99 -0
- package/README.md +20 -14
- package/SECURITY.md +6 -8
- package/SETUP.md +25 -27
- package/bin/desk-server.mjs +473 -0
- package/bin/oracle-data-mcp.mjs +1252 -0
- package/bin/oracle-equities.mjs +168 -0
- package/bin/oracle-init.mjs +525 -0
- package/bin/oracle-public-server.mjs +36 -0
- package/bin/oracle-route.mjs +254 -0
- package/bin/oracle-scan.mjs +192 -0
- package/bin/oracle-upgrade.mjs +42 -0
- package/bin/oracle.mjs +34 -0
- package/docs/adding-a-chain.md +229 -0
- package/docs/architecture.md +139 -0
- package/docs/buzz-integration.md +115 -0
- package/docs/cli.md +143 -0
- package/docs/connectors.md +13 -0
- package/docs/hyperliquid-builder-code.md +50 -0
- package/docs/locals-only-fee-waiver.md +34 -0
- package/docs/oracle-pack-standard.md +29 -0
- package/docs/profiles.md +151 -0
- package/docs/public-surface.md +206 -0
- package/examples/add-a-chain.mjs +65 -0
- package/examples/oracle-pack-template.mjs +38 -0
- package/examples/research-a-token.mjs +70 -0
- package/package.json +78 -32
- package/plugins/oracle-owner-gate/__init__.py +288 -0
- package/plugins/oracle-owner-gate/plugin.yaml +9 -0
- package/{dist/assets/profiles → profiles}/oracle/SOUL.md +0 -14
- package/protocols/templates/safe-erc20/SECURITY.md +16 -0
- package/protocols/templates/safe-erc20/foundry.toml +12 -0
- package/protocols/templates/safe-erc20/remappings.txt +2 -0
- package/protocols/templates/safe-erc20/src/SafeERC20.sol +53 -0
- package/protocols/templates/safe-erc20/test/SafeERC20.t.sol +72 -0
- package/public/oracle-splash/_variants/ice.html +3 -3
- package/public/oracle-splash/_variants/ivory.html +3 -3
- package/public/oracle-splash/downloads/index.html +34 -223
- package/public/oracle-splash/index.html +11 -11
- package/scripts/adversarial-bench.mjs +114 -0
- package/scripts/build-dist.mjs +119 -0
- package/scripts/build-inscription.py +230 -0
- package/scripts/check-doc-drift.mjs +123 -0
- package/scripts/check-test-count.mjs +105 -0
- package/scripts/e2e-hl-markets.mjs +21 -0
- package/scripts/e2e-hl-perps.mjs +48 -0
- package/scripts/e2e-hypercore-staking.mjs +128 -0
- package/scripts/e2e-solana-bitcoin.mjs +183 -0
- package/scripts/guard-publish.mjs +22 -0
- package/scripts/protocol-template-gate.mjs +15 -0
- package/scripts/public-api-scan.mjs +23 -0
- package/scripts/publish-dist.mjs +67 -0
- package/scripts/record-hero-cli.sh +80 -0
- package/scripts/secret-scan.mjs +169 -0
- package/scripts/smoke-dist-bins.mjs +89 -0
- package/scripts/verify-dist.mjs +29 -0
- package/scripts/verify-v3-venues.mjs +233 -0
- package/skins/oracle.yaml +56 -0
- package/src/action-receipts.mjs +265 -0
- package/src/action-semantics.mjs +62 -0
- package/src/address-book.mjs +208 -0
- package/src/agent-auth.mjs +206 -0
- package/src/approval-guard.mjs +282 -0
- package/src/attestation-secret.mjs +94 -0
- package/src/audit-log.mjs +196 -0
- package/src/auth/oauth.mjs +672 -0
- package/src/auto-slippage.mjs +378 -0
- package/src/capability-posture.mjs +125 -0
- package/src/cards.mjs +422 -0
- package/src/chains.mjs +62 -0
- package/src/cli/chain-catalog.mjs +215 -0
- package/src/cli/chain-state.mjs +74 -0
- package/src/cli/commands/auth.mjs +193 -0
- package/src/cli/commands/bootstrap.mjs +87 -0
- package/src/cli/commands/chain.mjs +143 -0
- package/src/cli/commands/chat.mjs +465 -0
- package/src/cli/commands/credential.mjs +9 -0
- package/src/cli/commands/data-mcp.mjs +18 -0
- package/src/cli/commands/data.mjs +75 -0
- package/src/cli/commands/doctor.mjs +136 -0
- package/src/cli/commands/equities.mjs +41 -0
- package/src/cli/commands/farm.mjs +129 -0
- package/src/cli/commands/fees.mjs +109 -0
- package/src/cli/commands/follow.mjs +130 -0
- package/src/cli/commands/harness.mjs +63 -0
- package/src/cli/commands/help.mjs +7 -0
- package/src/cli/commands/init.mjs +27 -0
- package/src/cli/commands/mcp.mjs +154 -0
- package/src/cli/commands/model.mjs +106 -0
- package/src/cli/commands/plugins.mjs +275 -0
- package/src/cli/commands/prepare.mjs +12 -0
- package/src/cli/commands/public.mjs +20 -0
- package/src/cli/commands/resolve.mjs +64 -0
- package/src/cli/commands/route.mjs +12 -0
- package/src/cli/commands/runner.mjs +9 -0
- package/src/cli/commands/scan.mjs +12 -0
- package/src/cli/commands/setup.mjs +294 -0
- package/src/cli/commands/sign.mjs +21 -0
- package/src/cli/commands/signer.mjs +9 -0
- package/src/cli/commands/swap.mjs +102 -0
- package/src/cli/commands/upgrade.mjs +12 -0
- package/src/cli/commands/vault.mjs +9 -0
- package/src/cli/commands/version.mjs +22 -0
- package/src/cli/first-run.mjs +23 -0
- package/src/cli/kernel.mjs +262 -0
- package/src/cli/mcp-targets/chatgpt.mjs +51 -0
- package/src/cli/mcp-targets/claude-code.mjs +39 -0
- package/src/cli/mcp-targets/claude-desktop.mjs +24 -0
- package/src/cli/mcp-targets/codex.mjs +41 -0
- package/src/cli/mcp-targets/cursor.mjs +32 -0
- package/src/cli/mcp-targets/shared.mjs +71 -0
- package/src/cli/mcp-targets/vscode.mjs +39 -0
- package/src/cli/messaging-platforms.mjs +217 -0
- package/src/cli/model-config.mjs +78 -0
- package/src/cli/operator-dispatch.mjs +194 -0
- package/src/cli/oracle-harness.py +415 -0
- package/src/cli/paths.mjs +107 -0
- package/src/cli/runtime.mjs +351 -0
- package/src/cli/setup-state.mjs +168 -0
- package/src/cli/spawn-child.mjs +43 -0
- package/src/data/catalog.mjs +858 -0
- package/src/data/desk-data.mjs +877 -0
- package/src/data/http.mjs +253 -0
- package/src/data/names.mjs +188 -0
- package/src/data/provider-endpoint.mjs +94 -0
- package/src/data/providers/aave-v3.mjs +139 -0
- package/src/data/providers/across-bridge.mjs +41 -0
- package/src/data/providers/aerodrome.mjs +245 -0
- package/src/data/providers/aevo.mjs +33 -0
- package/src/data/providers/approval-indexer.mjs +133 -0
- package/src/data/providers/approvals.mjs +594 -0
- package/src/data/providers/babylon-staking.mjs +149 -0
- package/src/data/providers/balancer.mjs +209 -0
- package/src/data/providers/beefy-yields.mjs +45 -0
- package/src/data/providers/birdeye-tokens.mjs +33 -0
- package/src/data/providers/bisq-markets.mjs +145 -0
- package/src/data/providers/bitcoin-esplora.mjs +216 -0
- package/src/data/providers/bitcoin-meta.mjs +378 -0
- package/src/data/providers/blockscout.mjs +14 -0
- package/src/data/providers/bob-rootstock.mjs +198 -0
- package/src/data/providers/braiins-insights.mjs +103 -0
- package/src/data/providers/bridge-aggregator.mjs +259 -0
- package/src/data/providers/bridges.mjs +242 -0
- package/src/data/providers/bungee.mjs +29 -0
- package/src/data/providers/celestia-da.mjs +38 -0
- package/src/data/providers/changenow.mjs +135 -0
- package/src/data/providers/compound.mjs +32 -0
- package/src/data/providers/connext.mjs +28 -0
- package/src/data/providers/convex.mjs +30 -0
- package/src/data/providers/cow-protocol.mjs +110 -0
- package/src/data/providers/cowswap.mjs +415 -0
- package/src/data/providers/curve.mjs +201 -0
- package/src/data/providers/das-assets.mjs +59 -0
- package/src/data/providers/debridge.mjs +109 -0
- package/src/data/providers/defillama.mjs +88 -0
- package/src/data/providers/dexscreener.mjs +43 -0
- package/src/data/providers/drift.mjs +32 -0
- package/src/data/providers/dydx.mjs +41 -0
- package/src/data/providers/evm-rpc.mjs +225 -0
- package/src/data/providers/farming.mjs +291 -0
- package/src/data/providers/geckoterminal.mjs +34 -0
- package/src/data/providers/gmx.mjs +496 -0
- package/src/data/providers/hiro-stacks.mjs +150 -0
- package/src/data/providers/hl-assets.mjs +165 -0
- package/src/data/providers/hl-info.mjs +108 -0
- package/src/data/providers/hl-markets.mjs +210 -0
- package/src/data/providers/hl-outcome.mjs +61 -0
- package/src/data/providers/hl-perps.mjs +419 -0
- package/src/data/providers/hl-staking.mjs +353 -0
- package/src/data/providers/hl-ws.mjs +119 -0
- package/src/data/providers/hyperevm-dex.mjs +49 -0
- package/src/data/providers/jito-mev.mjs +117 -0
- package/src/data/providers/jupiter-venues.mjs +119 -0
- package/src/data/providers/jupiter.mjs +315 -0
- package/src/data/providers/kamino-strategies.mjs +143 -0
- package/src/data/providers/l2beat-tvl.mjs +42 -0
- package/src/data/providers/lifi.mjs +166 -0
- package/src/data/providers/liquid-esplora.mjs +152 -0
- package/src/data/providers/magiceden-ordinals.mjs +141 -0
- package/src/data/providers/magiceden-sol.mjs +406 -0
- package/src/data/providers/mempool-lightning.mjs +144 -0
- package/src/data/providers/mempool-mining.mjs +142 -0
- package/src/data/providers/meteora-dlmm.mjs +168 -0
- package/src/data/providers/morpho.mjs +177 -0
- package/src/data/providers/nft-gallery.mjs +163 -0
- package/src/data/providers/nft-portfolio.mjs +494 -0
- package/src/data/providers/odos.mjs +156 -0
- package/src/data/providers/ondo.mjs +31 -0
- package/src/data/providers/oneinch.mjs +174 -0
- package/src/data/providers/opensea-multichain.mjs +136 -0
- package/src/data/providers/opensea-nft.mjs +371 -0
- package/src/data/providers/orca.mjs +29 -0
- package/src/data/providers/ordinals-runes.mjs +180 -0
- package/src/data/providers/pancakeswap.mjs +28 -0
- package/src/data/providers/paraswap.mjs +125 -0
- package/src/data/providers/pendle.mjs +188 -0
- package/src/data/providers/poly-clob.mjs +283 -0
- package/src/data/providers/poly-public.mjs +96 -0
- package/src/data/providers/poly-ws.mjs +103 -0
- package/src/data/providers/polygon-staking.mjs +227 -0
- package/src/data/providers/portfolio-history.mjs +394 -0
- package/src/data/providers/portfolio.mjs +600 -0
- package/src/data/providers/pyth-price-feeds.mjs +172 -0
- package/src/data/providers/raydium.mjs +35 -0
- package/src/data/providers/relayscan-mev.mjs +72 -0
- package/src/data/providers/rfq.mjs +15 -0
- package/src/data/providers/rh-agent.mjs +59 -0
- package/src/data/providers/sanctum-lst.mjs +180 -0
- package/src/data/providers/satflow.mjs +341 -0
- package/src/data/providers/signed-material-guard.mjs +108 -0
- package/src/data/providers/solana-rpc.mjs +197 -0
- package/src/data/providers/solend-lending.mjs +166 -0
- package/src/data/providers/spark-lend.mjs +42 -0
- package/src/data/providers/squid-router.mjs +29 -0
- package/src/data/providers/stargate.mjs +29 -0
- package/src/data/providers/sushiswap.mjs +30 -0
- package/src/data/providers/symbiotic-restaking.mjs +41 -0
- package/src/data/providers/thorchain.mjs +36 -0
- package/src/data/providers/traderjoe.mjs +28 -0
- package/src/data/providers/twap.mjs +152 -0
- package/src/data/providers/uniswap-v3.mjs +457 -0
- package/src/data/providers/uniswap-v4.mjs +414 -0
- package/src/data/providers/vertex.mjs +41 -0
- package/src/data/providers/wallet-watch.mjs +264 -0
- package/src/data/providers/wormhole.mjs +28 -0
- package/src/data/providers/yearn.mjs +31 -0
- package/src/data/providers/zerox.mjs +167 -0
- package/src/data/public-api-scan.mjs +61 -0
- package/src/data/quote-placeholder.mjs +31 -0
- package/src/desk/swap-prepare.mjs +194 -0
- package/src/equities/bridge.mjs +388 -0
- package/src/equities/fixtures/bridge_routes.json +159 -0
- package/src/equities/fixtures/dst_transitions.json +29 -0
- package/src/equities/fixtures/equity_dex_pools.json +154 -0
- package/src/equities/fixtures/hip3_l2books.json +2711 -0
- package/src/equities/fixtures/nyse_holidays.json +1 -0
- package/src/equities/fixtures/oracles.json +100 -0
- package/src/equities/fixtures/rh_pool_state.json +244 -0
- package/src/equities/fixtures/solana_xstocks.json +704 -0
- package/src/equities/fixtures/ton_xstocks.json +35 -0
- package/src/equities/fixtures/universe.json +411 -0
- package/src/equities/fixtures/venues.json +3542 -0
- package/src/equities/fixtures.mjs +405 -0
- package/src/equities/funding.mjs +142 -0
- package/src/equities/index.mjs +166 -0
- package/src/equities/liveness.mjs +148 -0
- package/src/equities/marketHours.mjs +249 -0
- package/src/equities/normalize.mjs +295 -0
- package/src/equities/num.mjs +146 -0
- package/src/equities/prepare.mjs +95 -0
- package/src/equities/rank.mjs +260 -0
- package/src/equities/sourceNum.mjs +69 -0
- package/src/equities/types.mjs +220 -0
- package/src/equities/venues/arcus-perp.mjs +84 -0
- package/src/equities/venues/arcus-spot.mjs +105 -0
- package/src/equities/venues/hyperliquid-hip3.mjs +224 -0
- package/src/equities/venues/rh-uniswap.mjs +216 -0
- package/src/equities/venues/solana-xstocks.mjs +139 -0
- package/src/equities/venues/ton-stonfi.mjs +139 -0
- package/src/exact-integer.mjs +72 -0
- package/src/exec-policy.mjs +419 -0
- package/src/flags.mjs +15 -0
- package/src/fresh-window.mjs +76 -0
- package/src/gmx-attestation.mjs +176 -0
- package/src/index.mjs +107 -0
- package/src/licensing/locals-only.mjs +25 -0
- package/src/nft-gas-war-guard.mjs +139 -0
- package/src/onboarding/agent-keys.mjs +161 -0
- package/src/onboarding/harness-configs.mjs +102 -0
- package/src/onboarding/index.mjs +18 -0
- package/src/onboarding/tiers.mjs +139 -0
- package/src/oracle-env.mjs +55 -0
- package/src/package-manifest.mjs +42 -0
- package/src/plugins/agent-plugin-loader.mjs +225 -0
- package/src/portfolio-risk.mjs +170 -0
- package/src/prepare-envelope.mjs +204 -0
- package/src/profile-upgrade.mjs +277 -0
- package/src/protocol-execution.mjs +84 -0
- package/src/protocol-templates/gate.mjs +179 -0
- package/src/protocol-templates/prepare-deploy.mjs +81 -0
- package/src/public-api/agent-grants.mjs +57 -0
- package/src/public-api/buzz-integration.mjs +267 -0
- package/src/public-api/connect-agent.mjs +424 -0
- package/src/public-api/grants.mjs +142 -0
- package/src/public-api/http.mjs +707 -0
- package/src/public-api/metering.mjs +111 -0
- package/src/public-control/aa-adapter.mjs +402 -0
- package/src/public-control/build-registry.mjs +227 -0
- package/src/public-control/bundler-client.mjs +357 -0
- package/src/public-control/grant-indexer.mjs +296 -0
- package/src/public-control/policy-render.mjs +69 -0
- package/src/public-control/policy-schema.mjs +322 -0
- package/src/public-control/runtime-config.mjs +275 -0
- package/src/public-control/session-key-model.mjs +379 -0
- package/src/public-control/session-orchestrator.mjs +418 -0
- package/src/rfq/intent.mjs +180 -0
- package/src/rfq/sources.mjs +181 -0
- package/src/route-attestation.mjs +132 -0
- package/src/router/best-execution.mjs +326 -0
- package/src/router/index.mjs +250 -0
- package/src/router/integrator-fee.mjs +135 -0
- package/src/router/prepare-bridge.mjs +293 -0
- package/src/router/prepare-route.mjs +398 -0
- package/src/router/proposal.mjs +311 -0
- package/src/router/risk-classifier.mjs +119 -0
- package/src/router/route-sources.mjs +364 -0
- package/src/scanner/chains.config.mjs +543 -0
- package/src/scanner/contract.mjs +270 -0
- package/src/scanner/evm-scanner.mjs +394 -0
- package/src/scanner/index.mjs +9 -0
- package/src/scanner/v2-venue.mjs +351 -0
- package/src/scanner/v3-venue.mjs +308 -0
- package/src/scopes.mjs +44 -0
- package/src/sell-simulation.mjs +167 -0
- package/src/signals/engine.mjs +146 -0
- package/src/signals/index.mjs +1 -0
- package/src/token-transfer-guard.mjs +188 -0
- package/src/tui/app.mjs +438 -0
- package/src/tui/backend.mjs +215 -0
- package/src/tui/format.mjs +272 -0
- package/src/tui/gateway-client.mjs +177 -0
- package/src/tui/input.mjs +501 -0
- package/src/tui/memory.mjs +105 -0
- package/src/tui/meta-learn.mjs +85 -0
- package/src/tui/renderer.mjs +443 -0
- package/src/tui/scheduler.mjs +205 -0
- package/src/tui/skills-loader.mjs +140 -0
- package/src/tui/standalone-client.mjs +752 -0
- package/src/tui/theme.mjs +81 -0
- package/src/vault-attestation.mjs +146 -0
- package/src/venues.mjs +206 -0
- package/src/watch-preferences.mjs +85 -0
- package/dist/action-receipts.mjs +0 -1
- package/dist/action-semantics.mjs +0 -1
- package/dist/address-book.mjs +0 -2
- package/dist/bin/desk-server.mjs +0 -59
- package/dist/bin/oracle-data-mcp.mjs +0 -8
- package/dist/bin/oracle-equities.mjs +0 -20
- package/dist/bin/oracle-init.mjs +0 -24
- package/dist/bin/oracle-public-server.mjs +0 -5
- package/dist/bin/oracle-route.mjs +0 -22
- package/dist/bin/oracle-scan.mjs +0 -18
- package/dist/bin/oracle-upgrade.mjs +0 -21
- package/dist/bin/oracle.mjs +0 -76
- package/dist/chains.mjs +0 -1
- package/dist/cli/commands/auth.mjs +0 -16
- package/dist/cli/commands/bootstrap.mjs +0 -18
- package/dist/cli/commands/chain.mjs +0 -21
- package/dist/cli/commands/chat.mjs +0 -45
- package/dist/cli/commands/credential.mjs +0 -1
- package/dist/cli/commands/data-mcp.mjs +0 -2
- package/dist/cli/commands/data.mjs +0 -12
- package/dist/cli/commands/doctor.mjs +0 -5
- package/dist/cli/commands/equities.mjs +0 -15
- package/dist/cli/commands/farm.mjs +0 -59
- package/dist/cli/commands/follow.mjs +0 -28
- package/dist/cli/commands/gate.mjs +0 -13
- package/dist/cli/commands/harness.mjs +0 -15
- package/dist/cli/commands/help.mjs +0 -1
- package/dist/cli/commands/init.mjs +0 -3
- package/dist/cli/commands/mcp.mjs +0 -60
- package/dist/cli/commands/model.mjs +0 -54
- package/dist/cli/commands/plugins.mjs +0 -38
- package/dist/cli/commands/prepare.mjs +0 -2
- package/dist/cli/commands/public.mjs +0 -3
- package/dist/cli/commands/resolve.mjs +0 -23
- package/dist/cli/commands/route.mjs +0 -2
- package/dist/cli/commands/runner.mjs +0 -1
- package/dist/cli/commands/scan.mjs +0 -2
- package/dist/cli/commands/setup.mjs +0 -34
- package/dist/cli/commands/sign.mjs +0 -21
- package/dist/cli/commands/signer.mjs +0 -1
- package/dist/cli/commands/swap.mjs +0 -36
- package/dist/cli/commands/upgrade.mjs +0 -2
- package/dist/cli/commands/vault.mjs +0 -1
- package/dist/cli/commands/version.mjs +0 -2
- package/dist/data/desk-data.mjs +0 -55
- package/dist/data/names.mjs +0 -2
- package/dist/data/providers/farming.mjs +0 -2
- package/dist/equities/index.mjs +0 -1
- package/dist/index.mjs +0 -60
- package/dist/nft-gas-war-guard.mjs +0 -1
- package/dist/onboarding/harness-configs.mjs +0 -4
- package/dist/portfolio-risk.mjs +0 -1
- package/dist/prepare-envelope.mjs +0 -1
- package/dist/public-api/agent-grants.mjs +0 -3
- package/dist/public-control/policy-schema.mjs +0 -1
- package/dist/router/index.mjs +0 -2
- package/dist/scanner/index.mjs +0 -4
- package/dist/signals/index.mjs +0 -1
- package/dist/watch-preferences.mjs +0 -1
- /package/{dist/assets/profiles → profiles}/_template/SOUL.md +0 -0
- /package/{dist/assets/profiles → profiles}/_template/profile.json +0 -0
- /package/{dist/assets/profiles → profiles}/bitcoin-agent/SOUL.md +0 -0
- /package/{dist/assets/profiles → profiles}/bitcoin-agent/profile.json +0 -0
- /package/{dist/assets/profiles → profiles}/hyperliquid-agent/SOUL.md +0 -0
- /package/{dist/assets/profiles → profiles}/hyperliquid-agent/profile.json +0 -0
- /package/{dist/assets/profiles → profiles}/oracle/profile.json +0 -0
- /package/{dist/assets/profiles → profiles}/polymarket-agent/SOUL.md +0 -0
- /package/{dist/assets/profiles → profiles}/polymarket-agent/profile.json +0 -0
- /package/{dist/assets/profiles → profiles}/profile.schema.json +0 -0
- /package/{dist/assets/profiles → profiles}/protocol-builder/SOUL.md +0 -0
- /package/{dist/assets/profiles → profiles}/protocol-builder/profile.json +0 -0
- /package/{dist/assets/profiles → profiles}/robinhood-agent/SOUL.md +0 -0
- /package/{dist/assets/profiles → profiles}/robinhood-agent/profile.json +0 -0
- /package/{dist/assets/profiles → profiles}/solana-agent/SOUL.md +0 -0
- /package/{dist/assets/profiles → profiles}/solana-agent/profile.json +0 -0
- /package/{dist/assets/profiles → profiles}/stable-agent/SOUL.md +0 -0
- /package/{dist/assets/profiles → profiles}/stable-agent/profile.json +0 -0
- /package/{dist/assets/skills → skills}/balance/SKILL.md +0 -0
- /package/{dist/assets/skills → skills}/bitcoin-l1.md +0 -0
- /package/{dist/assets/skills → skills}/chain-defi-ecosystem-profiling.md +0 -0
- /package/{dist/assets/skills → skills}/evm-contract-research.md +0 -0
- /package/{dist/assets/skills → skills}/hyperliquid.md +0 -0
- /package/{dist/assets/skills → skills}/multichain-exec-desk.md +0 -0
- /package/{dist/assets/skills → skills}/oracle-action-semantics/SKILL.md +0 -0
- /package/{dist/assets/skills → skills}/oracle-best-execution/SKILL.md +0 -0
- /package/{dist/assets/skills → skills}/oracle-best-execution.md +0 -0
- /package/{dist/assets/skills → skills}/oracle-bitcoin/SKILL.md +0 -0
- /package/{dist/assets/skills → skills}/oracle-chain-graphs-telegram-cards/SKILL.md +0 -0
- /package/{dist/assets/skills → skills}/oracle-chat/SKILL.md +0 -0
- /package/{dist/assets/skills → skills}/oracle-chat/chain.SKILL.md +0 -0
- /package/{dist/assets/skills → skills}/oracle-chat/setup.SKILL.md +0 -0
- /package/{dist/assets/skills → skills}/oracle-circuit-breaker/SKILL.md +0 -0
- /package/{dist/assets/skills → skills}/oracle-contract-research/SKILL.md +0 -0
- /package/{dist/assets/skills → skills}/oracle-desk/SKILL.md +0 -0
- /package/{dist/assets/skills → skills}/oracle-desk.md +0 -0
- /package/{dist/assets/skills → skills}/oracle-dex-launch/SKILL.md +0 -0
- /package/{dist/assets/skills → skills}/oracle-equities/SKILL.md +0 -0
- /package/{dist/assets/skills → skills}/oracle-grants/SKILL.md +0 -0
- /package/{dist/assets/skills → skills}/oracle-hypercore-staking/SKILL.md +0 -0
- /package/{dist/assets/skills → skills}/oracle-hyperliquid/SKILL.md +0 -0
- /package/{dist/assets/skills → skills}/oracle-meme-token-sniper/SKILL.md +0 -0
- /package/{dist/assets/skills → skills}/oracle-multichain-nft-launch/SKILL.md +0 -0
- /package/{dist/assets/skills → skills}/oracle-multichain-token-launch/SKILL.md +0 -0
- /package/{dist/assets/skills → skills}/oracle-nft-gacha-launch/SKILL.md +0 -0
- /package/{dist/assets/skills → skills}/oracle-nft-mint-gas-war/SKILL.md +0 -0
- /package/{dist/assets/skills → skills}/oracle-polymarket/SKILL.md +0 -0
- /package/{dist/assets/skills → skills}/oracle-protocol-builder/SKILL.md +0 -0
- /package/{dist/assets/skills → skills}/oracle-protocol-security/SKILL.md +0 -0
- /package/{dist/assets/skills → skills}/oracle-public-product/SKILL.md +0 -0
- /package/{dist/assets/skills → skills}/oracle-receipts/SKILL.md +0 -0
- /package/{dist/assets/skills → skills}/oracle-receipts.md +0 -0
- /package/{dist/assets/skills → skills}/oracle-rfq-tokenized-assets/SKILL.md +0 -0
- /package/{dist/assets/skills → skills}/oracle-smart-wallet-scanner/SKILL.md +0 -0
- /package/{dist/assets/skills → skills}/oracle-solana/SKILL.md +0 -0
- /package/{dist/assets/skills → skills}/oracle-solana-nft/SKILL.md +0 -0
- /package/{dist/assets/skills → skills}/oracle-token-research/SKILL.md +0 -0
- /package/{dist/assets/skills → skills}/solana.md +0 -0
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
// BOB and Rootstock — the two Bitcoin L2s that speak EVM — via Blockscout v2.
|
|
2
|
+
//
|
|
3
|
+
// Grouped in one module because they are the same integration: both run a
|
|
4
|
+
// Blockscout v2 instance with an identical REST schema, so one code path serves
|
|
5
|
+
// both and the only difference is the base URL.
|
|
6
|
+
//
|
|
7
|
+
// BOB chainId 60808 https://explorer.gobob.xyz
|
|
8
|
+
// Rootstock chainId 30 https://rootstock.blockscout.com
|
|
9
|
+
//
|
|
10
|
+
// Verified live:
|
|
11
|
+
// GET /api/v2/stats 200 on both
|
|
12
|
+
// GET /api/v2/addresses/{address} 200 on both (coin balance + flags)
|
|
13
|
+
// GET /api/v2/addresses/{a}/token-balances token holdings
|
|
14
|
+
//
|
|
15
|
+
// Distinct from the generic `blockscout` provider, which is registered for L1
|
|
16
|
+
// and EVM L2 rollups only — these two chains are absent from that map, and
|
|
17
|
+
// their Bitcoin-L2 framing is the reason to surface them separately.
|
|
18
|
+
//
|
|
19
|
+
// Read-only.
|
|
20
|
+
|
|
21
|
+
import { httpJson } from "../http.mjs";
|
|
22
|
+
|
|
23
|
+
export const BTC_L2_CHAINS = Object.freeze({
|
|
24
|
+
60808: { name: "bob", label: "BOB (Build on Bitcoin)", url: "https://explorer.gobob.xyz", nativeSymbol: "ETH" },
|
|
25
|
+
30: { name: "rootstock", label: "Rootstock (RSK)", url: "https://rootstock.blockscout.com", nativeSymbol: "RBTC" },
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const ALIASES = new Map([
|
|
29
|
+
["bob", 60808],
|
|
30
|
+
["rootstock", 30],
|
|
31
|
+
["rsk", 30],
|
|
32
|
+
]);
|
|
33
|
+
|
|
34
|
+
export const BTC_L2_DEFAULT_CHAIN_ID = 60808;
|
|
35
|
+
|
|
36
|
+
/** Accepts a chainId (60808/30) or a name ("bob"/"rootstock"/"rsk"). */
|
|
37
|
+
export function btcL2ChainId(value) {
|
|
38
|
+
if (value == null || value === "") return BTC_L2_DEFAULT_CHAIN_ID;
|
|
39
|
+
const asName = ALIASES.get(String(value).trim().toLowerCase());
|
|
40
|
+
if (asName) return asName;
|
|
41
|
+
const id = Number(value);
|
|
42
|
+
if (!BTC_L2_CHAINS[id]) {
|
|
43
|
+
throw new Error(`bob-rootstock: unsupported chain ${value} (supported: ${Object.keys(BTC_L2_CHAINS).join(", ")} / bob, rootstock)`);
|
|
44
|
+
}
|
|
45
|
+
return id;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function baseUrl(chainId, opts = {}) {
|
|
49
|
+
if (opts.baseUrl) return String(opts.baseUrl).replace(/\/$/, "");
|
|
50
|
+
const id = btcL2ChainId(chainId);
|
|
51
|
+
const env = id === 30 ? process.env.ROOTSTOCK_EXPLORER_URL : process.env.BOB_EXPLORER_URL;
|
|
52
|
+
return String(env || BTC_L2_CHAINS[id].url).replace(/\/$/, "");
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function evmAddress(value, label = "address") {
|
|
56
|
+
const text = String(value || "").trim();
|
|
57
|
+
// Rootstock renders EIP-1191 checksums (chain-id salted), so case is NOT
|
|
58
|
+
// validated here — only shape. Blockscout accepts either casing.
|
|
59
|
+
if (!/^0x[0-9a-fA-F]{40}$/.test(text)) throw new Error(`bob-rootstock: ${label} must be a 0x EVM address`);
|
|
60
|
+
return text;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function get(chainId, path, opts = {}) {
|
|
64
|
+
return httpJson(`${baseUrl(chainId, opts)}${path.startsWith("/") ? path : `/${path}`}`, {
|
|
65
|
+
fetchImpl: opts.fetchImpl,
|
|
66
|
+
timeoutMs: opts.timeoutMs ?? 15_000,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export async function btcL2Health(opts = {}, args = {}) {
|
|
71
|
+
// Health accepts an optional chain so a sweep can probe either instance;
|
|
72
|
+
// default is BOB.
|
|
73
|
+
let chainId;
|
|
74
|
+
try {
|
|
75
|
+
chainId = btcL2ChainId(args.chainId ?? args.chain ?? opts.chainId);
|
|
76
|
+
} catch (error) {
|
|
77
|
+
return { ok: false, provider: "bob-rootstock", error: String(error?.message || error), exec: false };
|
|
78
|
+
}
|
|
79
|
+
const meta = BTC_L2_CHAINS[chainId];
|
|
80
|
+
try {
|
|
81
|
+
const stats = await get(chainId, "/api/v2/stats", opts);
|
|
82
|
+
return {
|
|
83
|
+
ok: stats?.total_blocks != null || stats?.total_transactions != null,
|
|
84
|
+
provider: "bob-rootstock",
|
|
85
|
+
chainId,
|
|
86
|
+
chain: meta.name,
|
|
87
|
+
baseUrl: baseUrl(chainId, opts),
|
|
88
|
+
totalBlocks: stats?.total_blocks ?? null,
|
|
89
|
+
averageBlockTimeMs: stats?.average_block_time ?? null,
|
|
90
|
+
exec: false,
|
|
91
|
+
};
|
|
92
|
+
} catch (error) {
|
|
93
|
+
return {
|
|
94
|
+
ok: false,
|
|
95
|
+
provider: "bob-rootstock",
|
|
96
|
+
chainId,
|
|
97
|
+
chain: meta.name,
|
|
98
|
+
baseUrl: baseUrl(chainId, opts),
|
|
99
|
+
error: String(error?.message || error),
|
|
100
|
+
exec: false,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** Chain stats for one L2. Pass `chainId: "all"` to fan out across both. */
|
|
106
|
+
export async function btcL2Stats(args = {}, opts = {}) {
|
|
107
|
+
const which = args.chainId ?? args.chain;
|
|
108
|
+
if (String(which).trim().toLowerCase() === "all") {
|
|
109
|
+
const ids = Object.keys(BTC_L2_CHAINS).map(Number);
|
|
110
|
+
const rows = await Promise.all(
|
|
111
|
+
ids.map(async (id) => {
|
|
112
|
+
try {
|
|
113
|
+
return await btcL2Stats({ chainId: id }, opts);
|
|
114
|
+
} catch (error) {
|
|
115
|
+
return { provider: "bob-rootstock", chainId: id, chain: BTC_L2_CHAINS[id].name, error: String(error?.message || error) };
|
|
116
|
+
}
|
|
117
|
+
})
|
|
118
|
+
);
|
|
119
|
+
return { provider: "bob-rootstock", chains: rows };
|
|
120
|
+
}
|
|
121
|
+
const chainId = btcL2ChainId(which);
|
|
122
|
+
const meta = BTC_L2_CHAINS[chainId];
|
|
123
|
+
const s = await get(chainId, "/api/v2/stats", opts);
|
|
124
|
+
return {
|
|
125
|
+
provider: "bob-rootstock",
|
|
126
|
+
chainId,
|
|
127
|
+
chain: meta.name,
|
|
128
|
+
label: meta.label,
|
|
129
|
+
nativeSymbol: meta.nativeSymbol,
|
|
130
|
+
// Blockscout reports average_block_time in MILLISECONDS. Emitting seconds
|
|
131
|
+
// too because a 29409 vs 2000 comparison across these two chains is
|
|
132
|
+
// otherwise easy to misread as blocks-per-second.
|
|
133
|
+
averageBlockTimeMs: s.average_block_time ?? null,
|
|
134
|
+
averageBlockTimeSec: s.average_block_time == null ? null : Number(s.average_block_time) / 1000,
|
|
135
|
+
gasPrices: s.gas_prices ?? null,
|
|
136
|
+
gasPriceUpdatedAt: s.gas_price_updated_at ?? null,
|
|
137
|
+
gasUsedToday: s.gas_used_today ?? null,
|
|
138
|
+
coinPrice: s.coin_price ?? null,
|
|
139
|
+
coinPriceChangePct: s.coin_price_change_percentage ?? null,
|
|
140
|
+
marketCap: s.market_cap ?? null,
|
|
141
|
+
tvl: s.tvl ?? null,
|
|
142
|
+
totalBlocks: s.total_blocks ?? null,
|
|
143
|
+
totalAddresses: s.total_addresses ?? null,
|
|
144
|
+
totalTransactions: s.total_transactions ?? null,
|
|
145
|
+
transactionsToday: s.transactions_today ?? null,
|
|
146
|
+
networkUtilizationPct: s.network_utilization_percentage ?? null,
|
|
147
|
+
raw: s,
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/** Native balance + account flags for an address on either L2. */
|
|
152
|
+
export async function btcL2AddressInfo(args = {}, opts = {}) {
|
|
153
|
+
const chainId = btcL2ChainId(args.chainId ?? args.chain);
|
|
154
|
+
const address = evmAddress(args.address || args.addr, "address");
|
|
155
|
+
const meta = BTC_L2_CHAINS[chainId];
|
|
156
|
+
const a = await get(chainId, `/api/v2/addresses/${encodeURIComponent(address)}`, opts);
|
|
157
|
+
return {
|
|
158
|
+
provider: "bob-rootstock",
|
|
159
|
+
chainId,
|
|
160
|
+
chain: meta.name,
|
|
161
|
+
address,
|
|
162
|
+
nativeSymbol: meta.nativeSymbol,
|
|
163
|
+
coinBalanceWei: a.coin_balance == null ? null : String(a.coin_balance),
|
|
164
|
+
coinBalance: a.coin_balance == null ? null : Number(a.coin_balance) / 1e18,
|
|
165
|
+
isContract: a.is_contract ?? null,
|
|
166
|
+
isVerified: a.is_verified ?? null,
|
|
167
|
+
name: a.name ?? null,
|
|
168
|
+
blockNumberBalanceUpdatedAt: a.block_number_balance_updated_at ?? null,
|
|
169
|
+
raw: a,
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/** ERC-20 token holdings for an address on either L2. */
|
|
174
|
+
export async function btcL2TokenBalances(args = {}, opts = {}) {
|
|
175
|
+
const chainId = btcL2ChainId(args.chainId ?? args.chain);
|
|
176
|
+
const address = evmAddress(args.address || args.addr, "address");
|
|
177
|
+
const rows = await get(chainId, `/api/v2/addresses/${encodeURIComponent(address)}/token-balances`, opts);
|
|
178
|
+
const list = Array.isArray(rows) ? rows : [];
|
|
179
|
+
const limit = Math.min(500, Math.max(1, Number(args.limit || list.length || 1)));
|
|
180
|
+
return {
|
|
181
|
+
provider: "bob-rootstock",
|
|
182
|
+
chainId,
|
|
183
|
+
chain: BTC_L2_CHAINS[chainId].name,
|
|
184
|
+
address,
|
|
185
|
+
count: list.length,
|
|
186
|
+
tokens: list.slice(0, limit).map((t) => ({
|
|
187
|
+
symbol: t.token?.symbol ?? null,
|
|
188
|
+
name: t.token?.name ?? null,
|
|
189
|
+
address: t.token?.address ?? t.token?.address_hash ?? null,
|
|
190
|
+
type: t.token?.type ?? null,
|
|
191
|
+
decimals: t.token?.decimals ?? null,
|
|
192
|
+
rawBalance: t.value == null ? null : String(t.value),
|
|
193
|
+
balance:
|
|
194
|
+
t.value == null || t.token?.decimals == null ? null : Number(t.value) / 10 ** Number(t.token.decimals),
|
|
195
|
+
exchangeRate: t.token?.exchange_rate ?? null,
|
|
196
|
+
})),
|
|
197
|
+
};
|
|
198
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
// Braiins mining insights — BTC price stats + pool distribution, keyless.
|
|
2
|
+
//
|
|
3
|
+
// HOST NOTE (measured): use insights.braiins.com. Two traps:
|
|
4
|
+
// - pool.braiins.com/api/... returns 403 (that host is the pool dashboard,
|
|
5
|
+
// not the public insights API).
|
|
6
|
+
// - insights.braiins.com/api/v1.0/* answers 302 and redirects to
|
|
7
|
+
// learn.braiins.com/api/v1.0/*. Following redirects is required; http.mjs
|
|
8
|
+
// follows same-scheme redirects for GET, so the documented host is kept
|
|
9
|
+
// here as the entry point and the redirect resolves transparently.
|
|
10
|
+
//
|
|
11
|
+
// Verified live (after redirect):
|
|
12
|
+
// GET /api/v1.0/price-stats 200 { price, percent_change_24h, timestamp }
|
|
13
|
+
// GET /api/v1.0/pool-stats 200 [ { pool_name, blocks_mined{1d,1w,5w}, … } ]
|
|
14
|
+
//
|
|
15
|
+
// Complements mempool-mining: mempool gives block-count pool share from chain
|
|
16
|
+
// data; Braiins publishes miner-economics framing (block value, hashrate share)
|
|
17
|
+
// plus a price tick to value it against.
|
|
18
|
+
//
|
|
19
|
+
// Read-only.
|
|
20
|
+
|
|
21
|
+
import { httpJson } from "../http.mjs";
|
|
22
|
+
|
|
23
|
+
export const BRAIINS_INSIGHTS_API = "https://insights.braiins.com/api/v1.0";
|
|
24
|
+
|
|
25
|
+
function baseUrl(opts = {}) {
|
|
26
|
+
return String(opts.baseUrl || process.env.BRAIINS_INSIGHTS_URL || BRAIINS_INSIGHTS_API).replace(/\/$/, "");
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function get(path, opts = {}) {
|
|
30
|
+
return httpJson(`${baseUrl(opts)}${path.startsWith("/") ? path : `/${path}`}`, {
|
|
31
|
+
fetchImpl: opts.fetchImpl,
|
|
32
|
+
timeoutMs: opts.timeoutMs ?? 15_000,
|
|
33
|
+
headers: { Accept: "application/json" },
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export async function braiinsHealth(opts = {}) {
|
|
38
|
+
try {
|
|
39
|
+
const p = await get("/price-stats", opts);
|
|
40
|
+
const price = Number(p?.price ?? 0);
|
|
41
|
+
return {
|
|
42
|
+
ok: Number.isFinite(price) && price > 0,
|
|
43
|
+
provider: "braiins-insights",
|
|
44
|
+
baseUrl: baseUrl(opts),
|
|
45
|
+
btcUsd: Number.isFinite(price) ? price : null,
|
|
46
|
+
timestamp: p?.timestamp ?? null,
|
|
47
|
+
exec: false,
|
|
48
|
+
};
|
|
49
|
+
} catch (error) {
|
|
50
|
+
return {
|
|
51
|
+
ok: false,
|
|
52
|
+
provider: "braiins-insights",
|
|
53
|
+
baseUrl: baseUrl(opts),
|
|
54
|
+
error: String(error?.message || error),
|
|
55
|
+
exec: false,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export async function braiinsPriceStats(_args = {}, opts = {}) {
|
|
61
|
+
const p = await get("/price-stats", opts);
|
|
62
|
+
return {
|
|
63
|
+
provider: "braiins-insights",
|
|
64
|
+
btcUsd: p?.price == null ? null : Number(p.price),
|
|
65
|
+
percentChange24h: p?.percent_change_24h ?? null,
|
|
66
|
+
timestamp: p?.timestamp ?? null,
|
|
67
|
+
raw: p,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Per-pool mining stats. Braiins nests block counts by window
|
|
73
|
+
* ({ "1d": { absolute, relative_pct }, "1w": …, "5w": … }) — flattened here
|
|
74
|
+
* to the requested window so callers do not have to walk the shape.
|
|
75
|
+
*/
|
|
76
|
+
export async function braiinsPoolStats(args = {}, opts = {}) {
|
|
77
|
+
const res = await get("/pool-stats", opts);
|
|
78
|
+
const list = Array.isArray(res) ? res : Array.isArray(res?.pools) ? res.pools : [];
|
|
79
|
+
const win = String(args.window || "1w").trim().toLowerCase();
|
|
80
|
+
const pick = (row) => row?.blocks_mined?.[win] || null;
|
|
81
|
+
const rows = [...list].sort((a, b) => Number(pick(b)?.absolute || 0) - Number(pick(a)?.absolute || 0));
|
|
82
|
+
const limit = Math.min(200, Math.max(1, Number(args.limit || rows.length || 1)));
|
|
83
|
+
const windows = list.length ? Object.keys(list[0]?.blocks_mined || {}) : [];
|
|
84
|
+
if (windows.length && !windows.includes(win)) {
|
|
85
|
+
throw new Error(`braiins-insights: window must be one of ${windows.join(", ")}`);
|
|
86
|
+
}
|
|
87
|
+
return {
|
|
88
|
+
provider: "braiins-insights",
|
|
89
|
+
window: win,
|
|
90
|
+
availableWindows: windows,
|
|
91
|
+
count: rows.length,
|
|
92
|
+
pools: rows.slice(0, limit).map((r) => ({
|
|
93
|
+
name: r.pool_name ?? r.name ?? null,
|
|
94
|
+
blocksMined: pick(r)?.absolute ?? null,
|
|
95
|
+
sharePct: pick(r)?.relative_pct ?? null,
|
|
96
|
+
blockValueAvg: r.block_value_avg ?? null,
|
|
97
|
+
hashrate: r.hashrate ?? null,
|
|
98
|
+
luck: r.luck ?? null,
|
|
99
|
+
blocksMinedAllWindows: r.blocks_mined ?? null,
|
|
100
|
+
})),
|
|
101
|
+
raw: rows.slice(0, limit),
|
|
102
|
+
};
|
|
103
|
+
}
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
// Cross-chain bridge aggregator: 9 providers + revoke check.
|
|
2
|
+
// Quotes every available route in parallel, ranks by net output.
|
|
3
|
+
|
|
4
|
+
import { bestBridgeRoute } from "../../router/index.mjs";
|
|
5
|
+
import { debridgeQuote, debridgeHealth, DEBRIDGE_API } from "./debridge.mjs";
|
|
6
|
+
import { changenowQuote, changenowHealth, CHANGENOW_API } from "./changenow.mjs";
|
|
7
|
+
import { squidQuote, squidHealth, SQUID_API } from "./squid-router.mjs";
|
|
8
|
+
import { stargateQuote, stargateHealth, STARGATE_API } from "./stargate.mjs";
|
|
9
|
+
import { thorchainQuote, thorchainHealth, THORCHAIN_API } from "./thorchain.mjs";
|
|
10
|
+
import { bungeeQuote, bungeeHealth, BUNGEE_API } from "./bungee.mjs";
|
|
11
|
+
import { connextQuote, connextHealth, CONNEXT_API } from "./connext.mjs";
|
|
12
|
+
import { wormholeQuote, wormholeHealth, WORMHOLE_API } from "./wormhole.mjs";
|
|
13
|
+
import { approvalsScan } from "./approvals.mjs";
|
|
14
|
+
|
|
15
|
+
const PROVIDERS = Object.freeze(["debridge", "lifi-relay", "squid", "stargate", "thorchain", "bungee", "connext", "wormhole", "changenow"]);
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Quote all available bridge routes for a cross-chain transfer.
|
|
19
|
+
* Runs all providers concurrently; partial failures are non-fatal.
|
|
20
|
+
*
|
|
21
|
+
* @param {{ fromChainId: number, toChainId: number, tokenIn: string, tokenOut: string, amount: string, taker: string, fromSymbol?: string, toSymbol?: string, fromDecimals?: number, toDecimals?: number }} params
|
|
22
|
+
*/
|
|
23
|
+
export async function aggregateBridgeQuotes(params = {}) {
|
|
24
|
+
const {
|
|
25
|
+
fromChainId, toChainId, tokenIn, tokenOut, amount, taker,
|
|
26
|
+
fromSymbol = "?", toSymbol = "?", fromDecimals = 18, toDecimals = 18,
|
|
27
|
+
} = params;
|
|
28
|
+
|
|
29
|
+
const results = [];
|
|
30
|
+
const errors = [];
|
|
31
|
+
|
|
32
|
+
// ── deBridge ──
|
|
33
|
+
const debridgeP = debridgeQuote({
|
|
34
|
+
srcChainId: fromChainId,
|
|
35
|
+
srcChainTokenIn: tokenIn,
|
|
36
|
+
srcChainTokenInAmount: amount,
|
|
37
|
+
dstChainId: toChainId,
|
|
38
|
+
dstChainTokenOut: tokenOut,
|
|
39
|
+
}).then(r => {
|
|
40
|
+
if (r.error) { errors.push(`debridge: ${r.error}`); return null; }
|
|
41
|
+
return {
|
|
42
|
+
provider: "debridge",
|
|
43
|
+
amountOut: r.estimation?.dstChainTokenOut?.amount ?? r.estimation?.toAmount,
|
|
44
|
+
feeUsd: r.estimation?.fixFee ?? r.fixFee,
|
|
45
|
+
estimatedTime: r.estimation?.execution?.estimatedTransferTime
|
|
46
|
+
? `${r.estimation.execution.estimatedTransferTime}s`
|
|
47
|
+
: "unknown",
|
|
48
|
+
preparable: true,
|
|
49
|
+
raw: r,
|
|
50
|
+
};
|
|
51
|
+
}).catch(e => { errors.push(`debridge: ${e.message}`); return null; });
|
|
52
|
+
|
|
53
|
+
// ── LI.FI / Relay (existing bridge router) ──
|
|
54
|
+
const lifiP = bestBridgeRoute({
|
|
55
|
+
fromChainId, toChainId, tokenIn, tokenOut, amountIn: amount, taker,
|
|
56
|
+
}).then(r => {
|
|
57
|
+
if (!r || r.error) { errors.push(`lifi: ${r?.error ?? "no route"}`); return null; }
|
|
58
|
+
return {
|
|
59
|
+
provider: "lifi-relay",
|
|
60
|
+
amountOut: r.amountOut ?? r.quote?.amountOut,
|
|
61
|
+
feeUsd: r.feeUsd ?? r.totalFee,
|
|
62
|
+
estimatedTime: r.estimatedTime ?? r.duration ?? "unknown",
|
|
63
|
+
preparable: !!r.transaction,
|
|
64
|
+
raw: r,
|
|
65
|
+
};
|
|
66
|
+
}).catch(e => { errors.push(`lifi: ${e.message}`); return null; });
|
|
67
|
+
|
|
68
|
+
// ── Squid (Axelar) ──
|
|
69
|
+
const squidP = squidQuote({
|
|
70
|
+
fromChain: fromChainId, toChain: toChainId,
|
|
71
|
+
fromToken: tokenIn, toToken: tokenOut,
|
|
72
|
+
fromAmount: amount, fromAddress: taker,
|
|
73
|
+
}).then(r => {
|
|
74
|
+
if (r.error) { errors.push(`squid: ${r.error}`); return null; }
|
|
75
|
+
return {
|
|
76
|
+
provider: "squid",
|
|
77
|
+
amountOut: r.toAmount,
|
|
78
|
+
feeUsd: Array.isArray(r.fee) ? r.fee.reduce((a, b) => a + (Number(b.amountUsd) || 0), 0) : null,
|
|
79
|
+
estimatedTime: "30s - 3min",
|
|
80
|
+
preparable: false,
|
|
81
|
+
raw: r,
|
|
82
|
+
};
|
|
83
|
+
}).catch(e => { errors.push(`squid: ${e.message}`); return null; });
|
|
84
|
+
|
|
85
|
+
// ── Stargate (LayerZero) ──
|
|
86
|
+
const stargateP = stargateQuote({
|
|
87
|
+
srcChainId: fromChainId, dstChainId: toChainId,
|
|
88
|
+
token: tokenIn, amount,
|
|
89
|
+
}).then(r => {
|
|
90
|
+
if (r.error) { errors.push(`stargate: ${r.error}`); return null; }
|
|
91
|
+
return {
|
|
92
|
+
provider: "stargate",
|
|
93
|
+
amountOut: r.amountOut,
|
|
94
|
+
feeUsd: r.fee,
|
|
95
|
+
estimatedTime: r.estimatedTime || "1-5 min",
|
|
96
|
+
preparable: false,
|
|
97
|
+
raw: r,
|
|
98
|
+
};
|
|
99
|
+
}).catch(e => { errors.push(`stargate: ${e.message}`); return null; });
|
|
100
|
+
|
|
101
|
+
// ── THORChain (native swaps) ──
|
|
102
|
+
const thorchainP = thorchainQuote({
|
|
103
|
+
fromAsset: fromSymbol, toAsset: toSymbol, amount, destination: taker,
|
|
104
|
+
}).then(r => {
|
|
105
|
+
if (r.error) { errors.push(`thorchain: ${r.error}`); return null; }
|
|
106
|
+
return {
|
|
107
|
+
provider: "thorchain",
|
|
108
|
+
amountOut: r.expectedAmountOut,
|
|
109
|
+
feeUsd: r.fees?.total,
|
|
110
|
+
estimatedTime: r.estimatedTime || "10-30 min",
|
|
111
|
+
preparable: false,
|
|
112
|
+
raw: r,
|
|
113
|
+
};
|
|
114
|
+
}).catch(e => { errors.push(`thorchain: ${e.message}`); return null; });
|
|
115
|
+
|
|
116
|
+
// ── ChangeNOW ──
|
|
117
|
+
const changenowP = (async () => {
|
|
118
|
+
if (!fromSymbol || !toSymbol || fromSymbol === "?" || toSymbol === "?") {
|
|
119
|
+
errors.push("changenow: ticker symbols required, skipping");
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
try {
|
|
123
|
+
const q = await changenowQuote({ fromTicker: fromSymbol, toTicker: toSymbol, fromAmount: amount });
|
|
124
|
+
if (q.error) { errors.push(`changenow: ${q.error}`); return null; }
|
|
125
|
+
return {
|
|
126
|
+
provider: "changenow",
|
|
127
|
+
amountOut: q.toAmount,
|
|
128
|
+
feeUsd: q.networkFee,
|
|
129
|
+
estimatedTime: q.flow === "standard" ? "5-30 min" : "instant",
|
|
130
|
+
preparable: false, // CEX - user sends funds themselves
|
|
131
|
+
kycRequired: q.kycRequired,
|
|
132
|
+
raw: q,
|
|
133
|
+
};
|
|
134
|
+
} catch (e) { errors.push(`changenow: ${e.message}`); return null; }
|
|
135
|
+
})();
|
|
136
|
+
|
|
137
|
+
// ── Bungee/Socket ──
|
|
138
|
+
const bungeeP = bungeeQuote({ fromChainId, toChainId, fromToken: tokenIn, toToken: tokenOut, fromAmount: amount, userAddress: taker }).then(r => {
|
|
139
|
+
if (r.error) { errors.push(`bungee: ${r.error}`); return null; }
|
|
140
|
+
return { provider: "bungee", amountOut: r.amountOut, feeUsd: r.feeUsd, estimatedTime: r.estimatedTime, preparable: false, raw: r };
|
|
141
|
+
}).catch(e => { errors.push(`bungee: ${e.message}`); return null; });
|
|
142
|
+
|
|
143
|
+
// ── Connext ──
|
|
144
|
+
const connextP = connextQuote({ originDomain: fromChainId, destinationDomain: toChainId, originToken: tokenIn, destinationToken: tokenOut, amount }).then(r => {
|
|
145
|
+
if (r.error) { errors.push(`connext: ${r.error}`); return null; }
|
|
146
|
+
return { provider: "connext", amountOut: r.amountOut, feeUsd: r.fee, estimatedTime: r.estimatedTime || "5-20 min", preparable: false, raw: r };
|
|
147
|
+
}).catch(e => { errors.push(`connext: ${e.message}`); return null; });
|
|
148
|
+
|
|
149
|
+
// ── Wormhole ──
|
|
150
|
+
const wormholeP = wormholeQuote({ fromChain: fromChainId, toChain: toChainId, token: tokenIn, amount }).then(r => {
|
|
151
|
+
if (r.error) { errors.push(`wormhole: ${r.error}`); return null; }
|
|
152
|
+
return { provider: "wormhole", amountOut: r.amountOut, feeUsd: r.fee, estimatedTime: r.estimatedTime || "5-15 min", preparable: false, raw: r };
|
|
153
|
+
}).catch(e => { errors.push(`wormhole: ${e.message}`); return null; });
|
|
154
|
+
|
|
155
|
+
const settled = await Promise.allSettled([debridgeP, lifiP, squidP, stargateP, thorchainP, bungeeP, connextP, wormholeP, changenowP]);
|
|
156
|
+
for (const s of settled) {
|
|
157
|
+
if (s.status === "fulfilled" && s.value) results.push(s.value);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// Rank by output amount (descending). Preparable routes preferred on tie.
|
|
161
|
+
results.sort((a, b) => {
|
|
162
|
+
const aOut = Number(a.amountOut ?? 0);
|
|
163
|
+
const bOut = Number(b.amountOut ?? 0);
|
|
164
|
+
if (aOut !== bOut) return bOut - aOut;
|
|
165
|
+
if (a.preparable && !b.preparable) return -1;
|
|
166
|
+
if (!a.preparable && b.preparable) return 1;
|
|
167
|
+
return 0;
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
return {
|
|
171
|
+
providers: results.map(r => r.provider),
|
|
172
|
+
bestRoute: results[0]?.provider ?? "none",
|
|
173
|
+
winner: results[0] ?? null,
|
|
174
|
+
runnersUp: results.slice(1),
|
|
175
|
+
errors: errors.length ? errors : null,
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Check if the taker has any active ERC-20 approvals on the origin chain
|
|
181
|
+
* that should be revoked before bridging. Uses the existing approval scanner.
|
|
182
|
+
*/
|
|
183
|
+
export async function checkRevokeNeeded({ chainId, taker, tokenIn } = {}) {
|
|
184
|
+
if (!chainId || !taker) return { needsRevoke: false, note: "no wallet to check" };
|
|
185
|
+
|
|
186
|
+
try {
|
|
187
|
+
const result = await approvalsScan({ chainIds: [chainId], address: taker });
|
|
188
|
+
const approvals = result.approvals;
|
|
189
|
+
if (!approvals?.length) return { needsRevoke: false, note: "no active approvals found" };
|
|
190
|
+
|
|
191
|
+
// Token-specific: check if the token being bridged has active approvals
|
|
192
|
+
const tokenApproval = tokenIn
|
|
193
|
+
? approvals.find(a => String(a.token).toLowerCase() === String(tokenIn).toLowerCase())
|
|
194
|
+
: null;
|
|
195
|
+
|
|
196
|
+
if (tokenApproval && BigInt(tokenApproval.allowance ?? "0") > 0n) {
|
|
197
|
+
return {
|
|
198
|
+
needsRevoke: true,
|
|
199
|
+
spender: tokenApproval.spender,
|
|
200
|
+
amount: tokenApproval.allowance,
|
|
201
|
+
symbol: tokenApproval.symbol ?? "?",
|
|
202
|
+
decimals: tokenApproval.decimals ?? 18,
|
|
203
|
+
note: `approval found for ${tokenApproval.spender}, revoke before bridging`,
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
return {
|
|
208
|
+
needsRevoke: false,
|
|
209
|
+
note: `no active approval for this token (${approvals.length} total approvals on chain)`,
|
|
210
|
+
};
|
|
211
|
+
} catch (e) {
|
|
212
|
+
return { needsRevoke: false, note: `revoke check unavailable: ${String(e.message || e).slice(0, 100)}` };
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Full bridge scan: quote all routes + revoke check.
|
|
218
|
+
* Returns data shaped for the bridge card renderer.
|
|
219
|
+
*/
|
|
220
|
+
export async function scanBridgeRoutes(params = {}) {
|
|
221
|
+
const [quotes, revoke] = await Promise.all([
|
|
222
|
+
aggregateBridgeQuotes(params),
|
|
223
|
+
checkRevokeNeeded({ chainId: params.fromChainId, taker: params.taker, tokenIn: params.tokenIn }),
|
|
224
|
+
]);
|
|
225
|
+
|
|
226
|
+
const best = quotes.winner ?? {};
|
|
227
|
+
|
|
228
|
+
return {
|
|
229
|
+
kind: "bridge",
|
|
230
|
+
fromChainId: params.fromChainId,
|
|
231
|
+
toChainId: params.toChainId,
|
|
232
|
+
fromSymbol: params.fromSymbol,
|
|
233
|
+
toSymbol: params.toSymbol,
|
|
234
|
+
amount: params.amount,
|
|
235
|
+
fromDecimals: params.fromDecimals ?? 18,
|
|
236
|
+
toDecimals: params.toDecimals ?? 18,
|
|
237
|
+
bestRoute: best.provider ?? "none",
|
|
238
|
+
amountOut: best.amountOut,
|
|
239
|
+
feeUsd: best.feeUsd,
|
|
240
|
+
estimatedTime: best.estimatedTime,
|
|
241
|
+
preparable: best.preparable ? "yes" : "no (manual send)",
|
|
242
|
+
providers: quotes.providers,
|
|
243
|
+
runnersUp: quotes.runnersUp,
|
|
244
|
+
revokeCheck: revoke,
|
|
245
|
+
errors: quotes.errors,
|
|
246
|
+
confidence: quotes.providers.length >= 2 ? 0.85 : quotes.providers.length === 1 ? 0.6 : 0.1,
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Health check: verify all bridge providers are reachable.
|
|
252
|
+
*/
|
|
253
|
+
export async function bridgeAggregatorHealth() {
|
|
254
|
+
const [d, c] = await Promise.all([
|
|
255
|
+
debridgeHealth().catch(e => ({ ok: false, error: e.message })),
|
|
256
|
+
changenowHealth().catch(e => ({ ok: false, error: e.message })),
|
|
257
|
+
]);
|
|
258
|
+
return { debridge: d, changenow: c, lifi: { ok: true, note: "integrated via router" } };
|
|
259
|
+
}
|