@oracle-agent/oracle 0.13.1 → 0.14.0
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 +168 -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 +241 -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 +257 -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,174 @@
|
|
|
1
|
+
// 1inch Swap API v6 — requires ONEINCH_API_KEY (Bearer).
|
|
2
|
+
|
|
3
|
+
import { httpJson } from "../http.mjs";
|
|
4
|
+
import { attachAutoSlippage, bindAutoSlippageGuardToCall, resolveAutoSlippage } from "../../auto-slippage.mjs";
|
|
5
|
+
import { resolveProviderEndpoint, credentialedHeaders } from "../provider-endpoint.mjs";
|
|
6
|
+
import { stampPrepared } from "../../prepare-envelope.mjs";
|
|
7
|
+
|
|
8
|
+
export const ONEINCH_API = "https://api.1inch.dev/swap/v6.0";
|
|
9
|
+
|
|
10
|
+
function endpoint(opts = {}) {
|
|
11
|
+
return resolveProviderEndpoint({
|
|
12
|
+
provider: "oneinch",
|
|
13
|
+
defaultUrl: ONEINCH_API,
|
|
14
|
+
hosts: ["api.1inch.dev"],
|
|
15
|
+
url: opts.baseUrl || process.env.ONEINCH_API_URL,
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function base(opts = {}) {
|
|
20
|
+
return endpoint(opts).baseUrl;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function apiKey(opts = {}) {
|
|
24
|
+
return opts.apiKey || process.env.ONEINCH_API_KEY || process.env.ONE_INCH_API_KEY || "";
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function headers(opts = {}) {
|
|
28
|
+
const k = apiKey(opts);
|
|
29
|
+
return credentialedHeaders(
|
|
30
|
+
{ accept: "application/json" },
|
|
31
|
+
{ Authorization: k ? `Bearer ${k}` : "" },
|
|
32
|
+
endpoint(opts).trusted
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export async function oneinchHealth(opts = {}) {
|
|
37
|
+
if (!apiKey(opts)) {
|
|
38
|
+
return { ok: false, configured: false, error: "ONEINCH_API_KEY not set" };
|
|
39
|
+
}
|
|
40
|
+
try {
|
|
41
|
+
const q = await oneinchQuote(
|
|
42
|
+
{
|
|
43
|
+
chainId: 8453,
|
|
44
|
+
src: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
|
|
45
|
+
dst: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
|
|
46
|
+
amount: "1000000000000000",
|
|
47
|
+
},
|
|
48
|
+
opts
|
|
49
|
+
);
|
|
50
|
+
return { ok: true, configured: true, dstAmount: q.dstAmount };
|
|
51
|
+
} catch (e) {
|
|
52
|
+
return { ok: false, configured: true, error: String(e.message || e).slice(0, 160) };
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export async function oneinchQuote(q = {}, opts = {}) {
|
|
57
|
+
if (!apiKey(opts)) throw new Error("ONEINCH_API_KEY required for 1inch");
|
|
58
|
+
const chainId = Number(q.chainId ?? 1);
|
|
59
|
+
const { src, dst, amount } = q;
|
|
60
|
+
if (!src || !dst || !amount) throw new Error("oneinchQuote requires src, dst, amount");
|
|
61
|
+
const params = new URLSearchParams({
|
|
62
|
+
src,
|
|
63
|
+
dst,
|
|
64
|
+
amount: String(amount),
|
|
65
|
+
});
|
|
66
|
+
const result = await httpJson(`${base(opts)}/${chainId}/quote?${params}`, {
|
|
67
|
+
headers: headers(opts),
|
|
68
|
+
fetchImpl: opts.fetchImpl,
|
|
69
|
+
timeoutMs: opts.timeoutMs ?? 15_000,
|
|
70
|
+
});
|
|
71
|
+
if (!result?.dstAmount) return result;
|
|
72
|
+
return attachAutoSlippage(result, {
|
|
73
|
+
chainId,
|
|
74
|
+
venue: "1inch-quote",
|
|
75
|
+
amountOut: result.dstAmount,
|
|
76
|
+
liquidityUsd: q.liquidityUsd,
|
|
77
|
+
priceChange5m: q.priceChange5m,
|
|
78
|
+
requestedCapBps: q.maxSlippageBps ?? q.slippageBps,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function isNative(value) {
|
|
83
|
+
return /^(eth|native|0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee)$/i.test(String(value || ""));
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export async function oneinchApproveSpender(q = {}, opts = {}) {
|
|
87
|
+
if (!apiKey(opts)) throw new Error("ONEINCH_API_KEY required for 1inch");
|
|
88
|
+
const chainId = Number(q.chainId ?? 1);
|
|
89
|
+
return httpJson(`${base(opts)}/${chainId}/approve/spender`, {
|
|
90
|
+
headers: headers(opts),
|
|
91
|
+
fetchImpl: opts.fetchImpl,
|
|
92
|
+
timeoutMs: opts.timeoutMs ?? 15_000,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export async function oneinchPrepare(q = {}, opts = {}) {
|
|
97
|
+
if (!apiKey(opts)) throw new Error("ONEINCH_API_KEY required for 1inch");
|
|
98
|
+
const chainId = Number(q.chainId ?? 1);
|
|
99
|
+
const { src, dst, amount } = q;
|
|
100
|
+
const from = q.from || q.fromAddress || q.userAddress || q.taker;
|
|
101
|
+
if (!src || !dst || !amount || !from) throw new Error("oneinchPrepare requires src, dst, amount, from");
|
|
102
|
+
const selected = resolveAutoSlippage({
|
|
103
|
+
liquidityUsd: q.liquidityUsd,
|
|
104
|
+
priceChange5m: q.priceChange5m,
|
|
105
|
+
requestedCapBps: q.maxSlippageBps ?? q.slippageBps,
|
|
106
|
+
});
|
|
107
|
+
if (!selected.executable) {
|
|
108
|
+
throw new Error(`1inch: route requires ${selected.requiredBps} bps above cap ${selected.capBps}`);
|
|
109
|
+
}
|
|
110
|
+
const params = new URLSearchParams({
|
|
111
|
+
src,
|
|
112
|
+
dst,
|
|
113
|
+
amount: String(amount),
|
|
114
|
+
from,
|
|
115
|
+
// 1inch Classic Swap API expresses slippage as percentage points.
|
|
116
|
+
slippage: String(selected.selectedBps / 100),
|
|
117
|
+
});
|
|
118
|
+
if (q.receiver) params.set("receiver", q.receiver);
|
|
119
|
+
if (q.referrer) params.set("referrer", q.referrer);
|
|
120
|
+
if (q.disableEstimate != null) params.set("disableEstimate", String(Boolean(q.disableEstimate)));
|
|
121
|
+
if (q.allowPartialFill != null) params.set("allowPartialFill", String(Boolean(q.allowPartialFill)));
|
|
122
|
+
if (q.includeProtocols) params.set("includeProtocols", String(q.includeProtocols));
|
|
123
|
+
if (q.excludeProtocols) params.set("excludeProtocols", String(q.excludeProtocols));
|
|
124
|
+
const raw = await httpJson(`${base(opts)}/${chainId}/swap?${params}`, {
|
|
125
|
+
headers: headers(opts),
|
|
126
|
+
fetchImpl: opts.fetchImpl,
|
|
127
|
+
timeoutMs: opts.timeoutMs ?? 25_000,
|
|
128
|
+
});
|
|
129
|
+
const tx = raw?.tx;
|
|
130
|
+
if (!tx?.to || !tx?.data) throw new Error("1inch: swap returned no executable tx");
|
|
131
|
+
if (tx.from && String(tx.from).toLowerCase() !== String(from).toLowerCase()) {
|
|
132
|
+
throw new Error("1inch: transaction sender mismatch");
|
|
133
|
+
}
|
|
134
|
+
const amountOut = raw?.dstAmount || raw?.toTokenAmount || raw?.buyAmount;
|
|
135
|
+
if (!amountOut) throw new Error("1inch: swap response missing dstAmount");
|
|
136
|
+
const quote = attachAutoSlippage(raw, {
|
|
137
|
+
chainId,
|
|
138
|
+
venue: tx.to,
|
|
139
|
+
amountOut,
|
|
140
|
+
liquidityUsd: q.liquidityUsd,
|
|
141
|
+
priceChange5m: q.priceChange5m,
|
|
142
|
+
requestedCapBps: q.maxSlippageBps ?? q.slippageBps,
|
|
143
|
+
});
|
|
144
|
+
let requiresApproval = null;
|
|
145
|
+
if (!isNative(src)) {
|
|
146
|
+
const spender = raw?.spender || raw?.approvalAddress || (await oneinchApproveSpender({ chainId }, opts))?.address;
|
|
147
|
+
if (!spender) throw new Error("1inch: ERC-20 route missing approval spender");
|
|
148
|
+
requiresApproval = { token: src, spender, amount: String(amount) };
|
|
149
|
+
}
|
|
150
|
+
return stampPrepared({
|
|
151
|
+
provider: "oneinch",
|
|
152
|
+
calldataReady: true,
|
|
153
|
+
// NOT executable authority. The bytes are assembled but nothing is signed:
|
|
154
|
+
// the user's wallet is still the only thing that can authorize this. The
|
|
155
|
+
// previous `executionReady: true` read as "cleared to execute" and trained
|
|
156
|
+
// agents to treat a quote as permission.
|
|
157
|
+
requiresUserSignature: true,
|
|
158
|
+
signingReady: false,
|
|
159
|
+
broadcastReady: false,
|
|
160
|
+
chainId,
|
|
161
|
+
quote,
|
|
162
|
+
autoSlippage: quote.autoSlippage,
|
|
163
|
+
requiresApproval,
|
|
164
|
+
transaction: {
|
|
165
|
+
chainId,
|
|
166
|
+
from: tx.from || from,
|
|
167
|
+
to: tx.to,
|
|
168
|
+
data: tx.data,
|
|
169
|
+
value: tx.value ?? "0x0",
|
|
170
|
+
...(tx.gas != null ? { gasLimit: tx.gas } : {}),
|
|
171
|
+
slippageGuard: bindAutoSlippageGuardToCall(quote.autoSlippage, { chainId, venue: tx.to, data: tx.data }),
|
|
172
|
+
},
|
|
173
|
+
}, { provider: "oneinch", kind: "oneinch-tx" });
|
|
174
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
// OpenSea multi-chain NFT scanner.
|
|
2
|
+
//
|
|
3
|
+
// OpenSea v2 indexes NFTs across every chain it supports, keyed by a chain slug.
|
|
4
|
+
// This module is the ONE place Oracle resolves an NFT contract on ANY chain, so
|
|
5
|
+
// a user can paste a bare contract address and get back what it actually is
|
|
6
|
+
// before deciding to buy.
|
|
7
|
+
//
|
|
8
|
+
// Reads only. Nothing here signs or broadcasts.
|
|
9
|
+
|
|
10
|
+
import { httpJson } from "../http.mjs";
|
|
11
|
+
|
|
12
|
+
// OpenSea chain slugs -> EVM chainId. The slug is what the v2 API wants in the
|
|
13
|
+
// path; the chainId is what the rest of Oracle speaks.
|
|
14
|
+
export const OPENSEA_CHAINS = Object.freeze({
|
|
15
|
+
ethereum: 1,
|
|
16
|
+
matic: 137,
|
|
17
|
+
base: 8453,
|
|
18
|
+
arbitrum: 42161,
|
|
19
|
+
arbitrum_nova: 42170,
|
|
20
|
+
optimism: 10,
|
|
21
|
+
avalanche: 43114,
|
|
22
|
+
klaytn: 8217,
|
|
23
|
+
zora: 7777777,
|
|
24
|
+
blast: 81457,
|
|
25
|
+
sei: 1329,
|
|
26
|
+
b3: 8333,
|
|
27
|
+
ape_chain: 33139,
|
|
28
|
+
ronin: 2020,
|
|
29
|
+
soneium: 1868,
|
|
30
|
+
unichain: 130,
|
|
31
|
+
berachain: 80094,
|
|
32
|
+
flow: 747,
|
|
33
|
+
abstract: 2741,
|
|
34
|
+
gravity: 1625,
|
|
35
|
+
xai: 660279,
|
|
36
|
+
bsc: 56,
|
|
37
|
+
solana: null, // non-EVM; OpenSea indexes it but there is no chainId
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
export const CHAIN_ID_TO_OPENSEA = Object.freeze(
|
|
41
|
+
Object.fromEntries(
|
|
42
|
+
Object.entries(OPENSEA_CHAINS)
|
|
43
|
+
.filter(([, id]) => id != null)
|
|
44
|
+
.map(([slug, id]) => [id, slug])
|
|
45
|
+
)
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
/** All chains Oracle can scan for NFTs. */
|
|
49
|
+
export function openseaSupportedChains() {
|
|
50
|
+
return Object.entries(OPENSEA_CHAINS).map(([slug, chainId]) => ({ slug, chainId }));
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function openseaChainSlug(chain) {
|
|
54
|
+
if (chain == null) return null;
|
|
55
|
+
const text = String(chain).trim().toLowerCase();
|
|
56
|
+
if (OPENSEA_CHAINS[text] !== undefined) return text;
|
|
57
|
+
const asId = Number(text);
|
|
58
|
+
if (Number.isFinite(asId) && CHAIN_ID_TO_OPENSEA[asId]) return CHAIN_ID_TO_OPENSEA[asId];
|
|
59
|
+
throw new Error(`opensea: unsupported chain ${chain} — try one of: ${Object.keys(OPENSEA_CHAINS).slice(0, 8).join(", ")}…`);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function evmContract(value) {
|
|
63
|
+
const text = String(value ?? "").trim();
|
|
64
|
+
if (!/^0x[0-9a-fA-F]{40}$/.test(text)) throw new Error("opensea: contract must be a 0x-prefixed 20-byte address");
|
|
65
|
+
return text.toLowerCase();
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Resolve a bare contract address on ONE chain.
|
|
70
|
+
* Returns null when the chain has no such collection, so callers can fan out.
|
|
71
|
+
*/
|
|
72
|
+
export async function openseaContractOnChain(contract, chain, { headers, base, fetchImpl, timeoutMs } = {}) {
|
|
73
|
+
const slug = openseaChainSlug(chain);
|
|
74
|
+
const address = evmContract(contract);
|
|
75
|
+
try {
|
|
76
|
+
const raw = await httpJson(`${base}/chain/${slug}/contract/${address}`, {
|
|
77
|
+
headers,
|
|
78
|
+
fetchImpl,
|
|
79
|
+
timeoutMs: timeoutMs ?? 12_000,
|
|
80
|
+
});
|
|
81
|
+
if (!raw || !raw.collection) return null;
|
|
82
|
+
return {
|
|
83
|
+
chain: slug,
|
|
84
|
+
chainId: OPENSEA_CHAINS[slug],
|
|
85
|
+
contract: address,
|
|
86
|
+
collection: raw.collection,
|
|
87
|
+
name: raw.name ?? null,
|
|
88
|
+
tokenStandard: raw.contract_standard ?? raw.token_standard ?? null,
|
|
89
|
+
supply: raw.supply ?? null,
|
|
90
|
+
};
|
|
91
|
+
} catch (err) {
|
|
92
|
+
// 400/404 simply means "not on this chain" during a fan-out.
|
|
93
|
+
const status = err?.status;
|
|
94
|
+
if (status === 400 || status === 404) return null;
|
|
95
|
+
throw err;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Find which chain(s) a contract address lives on.
|
|
101
|
+
*
|
|
102
|
+
* Someone pasting an address rarely knows the chain, and guessing wrong is how
|
|
103
|
+
* people buy the wrong asset. Scan the supported set and report every hit.
|
|
104
|
+
*/
|
|
105
|
+
export async function openseaFindContract(args = {}, ctx = {}) {
|
|
106
|
+
const address = evmContract(args.contract || args.address);
|
|
107
|
+
const chains = args.chains
|
|
108
|
+
? args.chains.map(openseaChainSlug)
|
|
109
|
+
: Object.entries(OPENSEA_CHAINS)
|
|
110
|
+
.filter(([, id]) => id != null)
|
|
111
|
+
.map(([slug]) => slug);
|
|
112
|
+
|
|
113
|
+
const results = [];
|
|
114
|
+
const concurrency = Math.max(1, Math.min(Number(args.concurrency) || 6, 12));
|
|
115
|
+
let cursor = 0;
|
|
116
|
+
async function worker() {
|
|
117
|
+
while (cursor < chains.length) {
|
|
118
|
+
const slug = chains[cursor++];
|
|
119
|
+
try {
|
|
120
|
+
const hit = await openseaContractOnChain(address, slug, ctx);
|
|
121
|
+
if (hit) results.push(hit);
|
|
122
|
+
} catch {
|
|
123
|
+
/* one chain failing must not abort the scan */
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
await Promise.all(Array.from({ length: Math.min(concurrency, chains.length) }, worker));
|
|
128
|
+
|
|
129
|
+
return {
|
|
130
|
+
provider: "opensea",
|
|
131
|
+
contract: address,
|
|
132
|
+
chainsScanned: chains.length,
|
|
133
|
+
found: results.length,
|
|
134
|
+
matches: results.sort((a, b) => a.chain.localeCompare(b.chain)),
|
|
135
|
+
};
|
|
136
|
+
}
|
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
// OpenSea NFT floors — uses OPENSEA_API_KEY from env or ~/.config/locals-only/opensea.env
|
|
2
|
+
|
|
3
|
+
import { readFileSync, existsSync } from "node:fs";
|
|
4
|
+
import { getAddress } from "ethers";
|
|
5
|
+
import { httpJson } from "../http.mjs";
|
|
6
|
+
import { resolveProviderEndpoint, credentialedHeaders } from "../provider-endpoint.mjs";
|
|
7
|
+
import { stampPrepared } from "../../prepare-envelope.mjs";
|
|
8
|
+
|
|
9
|
+
export const OPENSEA_API = "https://api.opensea.io/api/v2";
|
|
10
|
+
|
|
11
|
+
export const OPENSEA_ACCOUNT_CHAINS = Object.freeze([
|
|
12
|
+
"blast",
|
|
13
|
+
"base",
|
|
14
|
+
"ethereum",
|
|
15
|
+
"zora",
|
|
16
|
+
"arbitrum",
|
|
17
|
+
"sei",
|
|
18
|
+
"avalanche",
|
|
19
|
+
"polygon",
|
|
20
|
+
"optimism",
|
|
21
|
+
"ape_chain",
|
|
22
|
+
"flow",
|
|
23
|
+
"b3",
|
|
24
|
+
"soneium",
|
|
25
|
+
"ronin",
|
|
26
|
+
"bera_chain",
|
|
27
|
+
"solana",
|
|
28
|
+
"shape",
|
|
29
|
+
"unichain",
|
|
30
|
+
"gunzilla",
|
|
31
|
+
"abstract",
|
|
32
|
+
"animechain",
|
|
33
|
+
"hyperevm",
|
|
34
|
+
"somnia",
|
|
35
|
+
"monad",
|
|
36
|
+
"hyperliquid",
|
|
37
|
+
"megaeth",
|
|
38
|
+
"ink",
|
|
39
|
+
"robinhood",
|
|
40
|
+
"stablechain",
|
|
41
|
+
]);
|
|
42
|
+
|
|
43
|
+
const OPENSEA_CHAIN_SET = new Set(OPENSEA_ACCOUNT_CHAINS);
|
|
44
|
+
const OPENSEA_NON_EVM_CHAINS = new Set(["solana", "flow"]);
|
|
45
|
+
const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
46
|
+
|
|
47
|
+
function loadKeyFromDisk() {
|
|
48
|
+
const p = process.env.OPENSEA_ENV_FILE || `${process.env.HOME || ""}/.config/locals-only/opensea.env`;
|
|
49
|
+
if (!existsSync(p)) return "";
|
|
50
|
+
try {
|
|
51
|
+
for (const ln of readFileSync(p, "utf8").split("\n")) {
|
|
52
|
+
const m = ln.match(/^\s*OPENSEA_API_KEY\s*=\s*(.+)\s*$/);
|
|
53
|
+
if (m) return m[1].replace(/^["']|["']$/g, "").trim();
|
|
54
|
+
}
|
|
55
|
+
} catch {
|
|
56
|
+
/* ignore */
|
|
57
|
+
}
|
|
58
|
+
return "";
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function apiKey(opts = {}) {
|
|
62
|
+
return opts.apiKey || process.env.OPENSEA_API_KEY || process.env.OPEN_SEA_API_KEY || loadKeyFromDisk();
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function endpoint(opts = {}) {
|
|
66
|
+
return resolveProviderEndpoint({
|
|
67
|
+
provider: "opensea",
|
|
68
|
+
defaultUrl: OPENSEA_API,
|
|
69
|
+
hosts: ["api.opensea.io", "testnets-api.opensea.io"],
|
|
70
|
+
url: opts.baseUrl || process.env.OPENSEA_API_URL,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function base(opts = {}) {
|
|
75
|
+
return endpoint(opts).baseUrl;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function headers(opts = {}) {
|
|
79
|
+
// x-api-key is attached only for a pinned OpenSea host.
|
|
80
|
+
return credentialedHeaders({ accept: "application/json" }, { "x-api-key": apiKey(opts) }, endpoint(opts).trusted);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function accountChain(value) {
|
|
84
|
+
const chain = String(value || "ethereum").trim().toLowerCase();
|
|
85
|
+
if (!OPENSEA_CHAIN_SET.has(chain)) throw new Error(`opensea: unsupported account chain ${chain}`);
|
|
86
|
+
return chain;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function evmAddress(value, label = "address") {
|
|
90
|
+
try {
|
|
91
|
+
return getAddress(String(value || "").trim().toLowerCase());
|
|
92
|
+
} catch {
|
|
93
|
+
throw new Error(`opensea: invalid ${label}`);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function accountAddress(value, chain = null) {
|
|
98
|
+
const address = String(value || "").trim();
|
|
99
|
+
if (!address) throw new Error("opensea: account address required");
|
|
100
|
+
if (chain && !OPENSEA_NON_EVM_CHAINS.has(chain)) return evmAddress(address, "account address");
|
|
101
|
+
if (!chain && /^0x[0-9a-fA-F]{40}$/.test(address)) return evmAddress(address, "account address");
|
|
102
|
+
if (!/^[1-9A-HJ-NP-Za-km-z]{32,64}$/.test(address)) throw new Error("opensea: invalid account address");
|
|
103
|
+
return address;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function positiveDecimal(value, label) {
|
|
107
|
+
const text = String(value ?? "").trim();
|
|
108
|
+
if (!/^(?:0|[1-9]\d*)(?:\.\d+)?$/.test(text) || Number(text) <= 0) {
|
|
109
|
+
throw new Error(`opensea: ${label} must be a positive plain decimal`);
|
|
110
|
+
}
|
|
111
|
+
return text;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function positiveInteger(value, label) {
|
|
115
|
+
const n = Number(value);
|
|
116
|
+
if (!Number.isSafeInteger(n) || n <= 0) throw new Error(`opensea: ${label} must be a positive integer`);
|
|
117
|
+
return n;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function isoTime(value, label) {
|
|
121
|
+
const text = String(value || "").trim();
|
|
122
|
+
const ms = Date.parse(text);
|
|
123
|
+
if (!text || !Number.isFinite(ms)) throw new Error(`opensea: ${label} must be an ISO 8601 timestamp`);
|
|
124
|
+
return { text: new Date(ms).toISOString(), ms };
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function normalizeAccountNft(raw = {}, chain, owner) {
|
|
128
|
+
return {
|
|
129
|
+
chain,
|
|
130
|
+
owner,
|
|
131
|
+
contract: raw.contract || null,
|
|
132
|
+
tokenId: raw.identifier == null ? null : String(raw.identifier),
|
|
133
|
+
tokenStandard: raw.token_standard || null,
|
|
134
|
+
collection: raw.collection || null,
|
|
135
|
+
name: raw.name || null,
|
|
136
|
+
description: raw.description || null,
|
|
137
|
+
imageUrl: raw.display_image_url || raw.image_url || raw.original_image_url || null,
|
|
138
|
+
originalImageUrl: raw.original_image_url || raw.image_url || null,
|
|
139
|
+
animationUrl: raw.display_animation_url || raw.original_animation_url || null,
|
|
140
|
+
metadataUrl: raw.metadata_url || null,
|
|
141
|
+
marketplaceUrl: raw.opensea_url || null,
|
|
142
|
+
estimatedValueUsd: raw.estimated_value_usd != null && Number.isFinite(Number(raw.estimated_value_usd))
|
|
143
|
+
? Number(raw.estimated_value_usd)
|
|
144
|
+
: null,
|
|
145
|
+
spam: raw.is_disabled === true || raw.is_nsfw === true,
|
|
146
|
+
disabled: raw.is_disabled === true,
|
|
147
|
+
nsfw: raw.is_nsfw === true,
|
|
148
|
+
traits: Array.isArray(raw.traits) ? raw.traits : [],
|
|
149
|
+
updatedAt: raw.updated_at || null,
|
|
150
|
+
acquisitionCost: null,
|
|
151
|
+
itemPnl: {
|
|
152
|
+
status: "unavailable",
|
|
153
|
+
reason: "OpenSea account inventory does not expose trustworthy per-item acquisition cost",
|
|
154
|
+
},
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/** Shared request context for the multichain scanner. */
|
|
159
|
+
export function openseaContext(opts = {}) {
|
|
160
|
+
return {
|
|
161
|
+
base: base(opts),
|
|
162
|
+
headers: headers(opts),
|
|
163
|
+
fetchImpl: opts.fetchImpl,
|
|
164
|
+
timeoutMs: opts.timeoutMs,
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export async function openseaHealth(opts = {}) {
|
|
169
|
+
if (!apiKey(opts)) {
|
|
170
|
+
return { ok: false, configured: false, error: "OPENSEA_API_KEY not set" };
|
|
171
|
+
}
|
|
172
|
+
try {
|
|
173
|
+
const c = await openseaCollection("boredapeyachtclub", opts);
|
|
174
|
+
return { ok: true, configured: true, name: c.name || c.collection };
|
|
175
|
+
} catch (e) {
|
|
176
|
+
return { ok: false, configured: true, error: String(e.message || e).slice(0, 160) };
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export async function openseaCollection(slug, opts = {}) {
|
|
181
|
+
if (!slug) throw new Error("collection slug required");
|
|
182
|
+
if (!apiKey(opts)) throw new Error("OPENSEA_API_KEY required");
|
|
183
|
+
return httpJson(`${base(opts)}/collections/${encodeURIComponent(slug)}`, {
|
|
184
|
+
headers: headers(opts),
|
|
185
|
+
fetchImpl: opts.fetchImpl,
|
|
186
|
+
timeoutMs: opts.timeoutMs ?? 15_000,
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/** Best-effort floor from collection stats / collection payload. */
|
|
191
|
+
export async function openseaFloor(slug, opts = {}) {
|
|
192
|
+
const c = await openseaCollection(slug, opts);
|
|
193
|
+
const stats = c.stats || c.total || {};
|
|
194
|
+
const floor =
|
|
195
|
+
c.floor_price ??
|
|
196
|
+
c.floorPrice ??
|
|
197
|
+
stats.floor_price ??
|
|
198
|
+
stats.floorPrice ??
|
|
199
|
+
null;
|
|
200
|
+
return {
|
|
201
|
+
slug: c.collection || slug,
|
|
202
|
+
name: c.name || null,
|
|
203
|
+
floor,
|
|
204
|
+
totalSupply: c.total_supply ?? stats.total_supply ?? null,
|
|
205
|
+
numOwners: c.num_owners ?? stats.num_owners ?? null,
|
|
206
|
+
raw: {
|
|
207
|
+
contracts: c.contracts,
|
|
208
|
+
fees: c.fees,
|
|
209
|
+
category: c.category,
|
|
210
|
+
},
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/** Paginated account NFT inventory for one OpenSea-supported chain. */
|
|
215
|
+
export async function openseaAccountNfts(args = {}, opts = {}) {
|
|
216
|
+
if (!apiKey(opts)) throw new Error("OPENSEA_API_KEY required");
|
|
217
|
+
const chain = accountChain(args.chain);
|
|
218
|
+
const owner = accountAddress(args.address || args.owner, chain);
|
|
219
|
+
const pageSize = Math.min(Math.max(Number(args.pageSize ?? args.limit ?? 200) || 200, 1), 200);
|
|
220
|
+
const maxPages = Math.min(Math.max(Number(args.maxPages ?? 5) || 5, 1), 25);
|
|
221
|
+
const nfts = [];
|
|
222
|
+
let next = args.next ? String(args.next) : null;
|
|
223
|
+
let pages = 0;
|
|
224
|
+
|
|
225
|
+
do {
|
|
226
|
+
const url = new URL(`${base(opts)}/chain/${encodeURIComponent(chain)}/account/${encodeURIComponent(owner)}/nfts`);
|
|
227
|
+
url.searchParams.set("limit", String(pageSize));
|
|
228
|
+
if (args.collection) url.searchParams.set("collection", String(args.collection));
|
|
229
|
+
if (next) url.searchParams.set("next", next);
|
|
230
|
+
const raw = await httpJson(url.toString(), {
|
|
231
|
+
headers: headers(opts),
|
|
232
|
+
fetchImpl: opts.fetchImpl,
|
|
233
|
+
timeoutMs: opts.timeoutMs ?? 20_000,
|
|
234
|
+
});
|
|
235
|
+
for (const item of Array.isArray(raw?.nfts) ? raw.nfts : []) {
|
|
236
|
+
nfts.push(normalizeAccountNft(item, chain, owner));
|
|
237
|
+
}
|
|
238
|
+
next = raw?.next ? String(raw.next) : null;
|
|
239
|
+
pages += 1;
|
|
240
|
+
} while (next && pages < maxPages);
|
|
241
|
+
|
|
242
|
+
return {
|
|
243
|
+
provider: "opensea-nft",
|
|
244
|
+
source: "opensea-account-inventory",
|
|
245
|
+
chain,
|
|
246
|
+
owner,
|
|
247
|
+
count: nfts.length,
|
|
248
|
+
pages,
|
|
249
|
+
complete: !next,
|
|
250
|
+
next,
|
|
251
|
+
nfts,
|
|
252
|
+
exec: false,
|
|
253
|
+
readOnly: true,
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/** OpenSea-indexed account PnL. This is account-level, not per-NFT cost basis. */
|
|
258
|
+
export async function openseaAccountPnl(args = {}, opts = {}) {
|
|
259
|
+
if (!apiKey(opts)) throw new Error("OPENSEA_API_KEY required");
|
|
260
|
+
const address = accountAddress(args.address || args.owner);
|
|
261
|
+
const raw = await httpJson(`${base(opts)}/account/${encodeURIComponent(address)}/pnl`, {
|
|
262
|
+
headers: headers(opts),
|
|
263
|
+
fetchImpl: opts.fetchImpl,
|
|
264
|
+
timeoutMs: opts.timeoutMs ?? 20_000,
|
|
265
|
+
});
|
|
266
|
+
return {
|
|
267
|
+
provider: "opensea-nft",
|
|
268
|
+
source: "opensea-indexed-account-pnl",
|
|
269
|
+
address,
|
|
270
|
+
scope: "OpenSea-indexed account trading PnL across supported currencies, not per-item NFT cost basis",
|
|
271
|
+
methodology: "provider-indexed",
|
|
272
|
+
realizedPnlUsd: raw?.realized_pnl_usd ?? null,
|
|
273
|
+
unrealizedPnlUsd: raw?.unrealized_pnl_usd ?? null,
|
|
274
|
+
totalPnlUsd: raw?.total_pnl_usd ?? null,
|
|
275
|
+
netInvestedUsd: raw?.net_invested_usd ?? null,
|
|
276
|
+
currentValueUsd: raw?.current_value_usd ?? null,
|
|
277
|
+
returnPercentage: raw?.return_percentage ?? null,
|
|
278
|
+
itemLevelPnlAvailable: false,
|
|
279
|
+
raw,
|
|
280
|
+
exec: false,
|
|
281
|
+
readOnly: true,
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
function normalizeListingItem(raw = {}) {
|
|
286
|
+
const chain = accountChain(raw.chain);
|
|
287
|
+
if (OPENSEA_NON_EVM_CHAINS.has(chain)) {
|
|
288
|
+
throw new Error("opensea: listing actions currently require an EVM NFT chain");
|
|
289
|
+
}
|
|
290
|
+
const start = raw.startTime || raw.start_time
|
|
291
|
+
? isoTime(raw.startTime || raw.start_time, "startTime")
|
|
292
|
+
: { text: new Date().toISOString(), ms: Date.now() };
|
|
293
|
+
const end = isoTime(raw.endTime || raw.end_time, "endTime");
|
|
294
|
+
if (end.ms <= start.ms) throw new Error("opensea: endTime must be after startTime");
|
|
295
|
+
const tokenId = String(raw.tokenId ?? raw.token_id ?? "").trim();
|
|
296
|
+
if (!/^\d+$/.test(tokenId)) throw new Error("opensea: tokenId must be an unsigned integer string");
|
|
297
|
+
return {
|
|
298
|
+
chain,
|
|
299
|
+
contract: evmAddress(raw.contract, "NFT contract"),
|
|
300
|
+
token_id: tokenId,
|
|
301
|
+
quantity: positiveInteger(raw.quantity ?? 1, "quantity"),
|
|
302
|
+
price: {
|
|
303
|
+
amount: positiveDecimal(raw.price?.amount ?? raw.amount ?? raw.priceAmount, "price amount"),
|
|
304
|
+
currency: evmAddress(raw.price?.currency ?? raw.currency ?? ZERO_ADDRESS, "price currency"),
|
|
305
|
+
},
|
|
306
|
+
start_time: start.text,
|
|
307
|
+
end_time: end.text,
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
function containsApprovalStep(steps = []) {
|
|
312
|
+
return steps.some((step) => /approv|setapprovalforall/i.test(JSON.stringify(step)));
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* Ask OpenSea for approval and Seaport signing actions. Nothing is signed,
|
|
317
|
+
* submitted, or broadcast. The user's wallet handles every returned action.
|
|
318
|
+
*/
|
|
319
|
+
export async function openseaPrepareList(args = {}, opts = {}) {
|
|
320
|
+
if (!apiKey(opts)) throw new Error("OPENSEA_API_KEY required");
|
|
321
|
+
if (args.userConfirmed !== true) {
|
|
322
|
+
throw new Error("opensea: userConfirmed=true required after NFT, marketplace, price, currency, and expiry review");
|
|
323
|
+
}
|
|
324
|
+
const seller = evmAddress(args.seller || args.address || args.owner, "seller");
|
|
325
|
+
const sourceItems = Array.isArray(args.items) && args.items.length ? args.items : [args];
|
|
326
|
+
if (sourceItems.length > 50) throw new Error("opensea: at most 50 listing items per preparation");
|
|
327
|
+
const items = sourceItems.map(normalizeListingItem);
|
|
328
|
+
const chains = new Set(items.map((item) => item.chain));
|
|
329
|
+
if (chains.size !== 1) throw new Error("opensea: all prepared listing items must be on one chain");
|
|
330
|
+
const useCreatorFee = args.useCreatorFee !== false;
|
|
331
|
+
const request = {
|
|
332
|
+
address: seller,
|
|
333
|
+
items,
|
|
334
|
+
use_creator_fee: useCreatorFee,
|
|
335
|
+
};
|
|
336
|
+
if (args.taker) request.taker = evmAddress(args.taker, "taker");
|
|
337
|
+
|
|
338
|
+
const raw = await httpJson(`${base(opts)}/listings/actions`, {
|
|
339
|
+
method: "POST",
|
|
340
|
+
headers: headers(opts),
|
|
341
|
+
body: request,
|
|
342
|
+
fetchImpl: opts.fetchImpl,
|
|
343
|
+
timeoutMs: opts.timeoutMs ?? 25_000,
|
|
344
|
+
retries: 0,
|
|
345
|
+
dedupe: false,
|
|
346
|
+
});
|
|
347
|
+
const steps = Array.isArray(raw?.steps) ? raw.steps : [];
|
|
348
|
+
if (!steps.length) throw new Error("opensea: listing action response contained no wallet steps");
|
|
349
|
+
|
|
350
|
+
return stampPrepared({
|
|
351
|
+
provider: "opensea-nft",
|
|
352
|
+
marketplace: "opensea",
|
|
353
|
+
chain: items[0].chain,
|
|
354
|
+
kind: "nft-list-actions",
|
|
355
|
+
prepareReady: true,
|
|
356
|
+
executionReady: false,
|
|
357
|
+
signingReady: false,
|
|
358
|
+
broadcastReady: false,
|
|
359
|
+
requiresUserSignature: true,
|
|
360
|
+
requiresSeparateApproval: containsApprovalStep(steps),
|
|
361
|
+
seller,
|
|
362
|
+
items,
|
|
363
|
+
useCreatorFee,
|
|
364
|
+
taker: request.taker || null,
|
|
365
|
+
feeDisclosure: useCreatorFee
|
|
366
|
+
? "Creator fees requested. Inspect the returned Seaport consideration recipients and wallet simulation before signing."
|
|
367
|
+
: "Creator fees disabled by explicit request. Marketplace protocol fees may still apply and must be inspected before signing.",
|
|
368
|
+
steps,
|
|
369
|
+
note: "Execute approvals separately, then sign the Seaport order in the user's wallet. Oracle does not submit or broadcast the listing.",
|
|
370
|
+
});
|
|
371
|
+
}
|