@oracle-agent/oracle 0.14.0 → 0.15.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/README.md +2 -2
- package/SETUP.md +4 -4
- package/dist/action-receipts.mjs +1 -0
- package/dist/action-semantics.mjs +1 -0
- package/dist/address-book.mjs +2 -0
- package/dist/bin/desk-server.mjs +59 -0
- package/dist/bin/oracle-data-mcp.mjs +8 -0
- package/dist/bin/oracle-equities.mjs +20 -0
- package/dist/bin/oracle-init.mjs +24 -0
- package/dist/bin/oracle-public-server.mjs +5 -0
- package/dist/bin/oracle-route.mjs +22 -0
- package/dist/bin/oracle-scan.mjs +18 -0
- package/dist/bin/oracle-upgrade.mjs +21 -0
- package/dist/bin/oracle.mjs +61 -0
- package/dist/chains.mjs +1 -0
- package/dist/cli/commands/auth.mjs +16 -0
- package/dist/cli/commands/bootstrap.mjs +18 -0
- package/dist/cli/commands/chain.mjs +21 -0
- package/dist/cli/commands/chat.mjs +45 -0
- package/dist/cli/commands/credential.mjs +1 -0
- package/dist/cli/commands/data-mcp.mjs +2 -0
- package/dist/cli/commands/data.mjs +12 -0
- package/dist/cli/commands/doctor.mjs +5 -0
- package/dist/cli/commands/equities.mjs +15 -0
- package/dist/cli/commands/farm.mjs +59 -0
- package/dist/cli/commands/fees.mjs +10 -0
- package/dist/cli/commands/follow.mjs +28 -0
- package/dist/cli/commands/harness.mjs +15 -0
- package/dist/cli/commands/help.mjs +1 -0
- package/dist/cli/commands/init.mjs +3 -0
- package/dist/cli/commands/mcp.mjs +36 -0
- package/dist/cli/commands/model.mjs +54 -0
- package/dist/cli/commands/plugins.mjs +43 -0
- package/dist/cli/commands/prepare.mjs +2 -0
- package/dist/cli/commands/public.mjs +3 -0
- package/dist/cli/commands/resolve.mjs +23 -0
- package/dist/cli/commands/route.mjs +2 -0
- package/dist/cli/commands/runner.mjs +1 -0
- package/dist/cli/commands/scan.mjs +2 -0
- package/dist/cli/commands/setup.mjs +34 -0
- package/dist/cli/commands/sign.mjs +4 -0
- package/dist/cli/commands/signer.mjs +1 -0
- package/dist/cli/commands/swap.mjs +36 -0
- package/dist/cli/commands/upgrade.mjs +2 -0
- package/dist/cli/commands/vault.mjs +1 -0
- package/dist/cli/commands/version.mjs +2 -0
- package/dist/data/desk-data.mjs +55 -0
- package/dist/data/names.mjs +2 -0
- package/dist/data/providers/farming.mjs +2 -0
- package/dist/equities/index.mjs +1 -0
- package/dist/index.mjs +60 -0
- package/dist/nft-gas-war-guard.mjs +1 -0
- package/dist/onboarding/harness-configs.mjs +4 -0
- package/dist/portfolio-risk.mjs +1 -0
- package/dist/prepare-envelope.mjs +1 -0
- package/dist/public-api/agent-grants.mjs +3 -0
- package/dist/public-control/policy-schema.mjs +1 -0
- package/dist/router/index.mjs +2 -0
- package/dist/scanner/index.mjs +4 -0
- package/dist/signals/index.mjs +1 -0
- package/dist/watch-preferences.mjs +1 -0
- package/package.json +32 -78
- package/public/oracle-splash/_variants/ice.html +5 -18
- package/public/oracle-splash/_variants/ivory.html +5 -18
- package/public/oracle-splash/index.html +114 -34
- package/CONTRIBUTING.md +0 -99
- package/bin/desk-server.mjs +0 -473
- package/bin/oracle-data-mcp.mjs +0 -1252
- package/bin/oracle-equities.mjs +0 -168
- package/bin/oracle-init.mjs +0 -525
- package/bin/oracle-public-server.mjs +0 -36
- package/bin/oracle-route.mjs +0 -254
- package/bin/oracle-scan.mjs +0 -192
- package/bin/oracle-upgrade.mjs +0 -42
- package/bin/oracle.mjs +0 -34
- package/docs/adding-a-chain.md +0 -229
- package/docs/architecture.md +0 -139
- package/docs/buzz-integration.md +0 -115
- package/docs/cli.md +0 -143
- package/docs/connectors.md +0 -13
- package/docs/hyperliquid-builder-code.md +0 -50
- package/docs/locals-only-fee-waiver.md +0 -34
- package/docs/oracle-pack-standard.md +0 -29
- package/docs/profiles.md +0 -151
- package/docs/public-surface.md +0 -206
- package/examples/add-a-chain.mjs +0 -65
- package/examples/oracle-pack-template.mjs +0 -38
- package/examples/research-a-token.mjs +0 -70
- package/plugins/oracle-owner-gate/__init__.py +0 -288
- package/plugins/oracle-owner-gate/plugin.yaml +0 -9
- package/protocols/templates/safe-erc20/SECURITY.md +0 -16
- package/protocols/templates/safe-erc20/foundry.toml +0 -12
- package/protocols/templates/safe-erc20/remappings.txt +0 -2
- package/protocols/templates/safe-erc20/src/SafeERC20.sol +0 -53
- package/protocols/templates/safe-erc20/test/SafeERC20.t.sol +0 -72
- package/scripts/adversarial-bench.mjs +0 -114
- package/scripts/build-dist.mjs +0 -119
- package/scripts/build-inscription.py +0 -230
- package/scripts/check-doc-drift.mjs +0 -123
- package/scripts/check-test-count.mjs +0 -105
- package/scripts/e2e-hl-markets.mjs +0 -21
- package/scripts/e2e-hl-perps.mjs +0 -48
- package/scripts/e2e-hypercore-staking.mjs +0 -128
- package/scripts/e2e-solana-bitcoin.mjs +0 -183
- package/scripts/guard-publish.mjs +0 -22
- package/scripts/protocol-template-gate.mjs +0 -15
- package/scripts/public-api-scan.mjs +0 -23
- package/scripts/publish-dist.mjs +0 -67
- package/scripts/record-hero-cli.sh +0 -80
- package/scripts/secret-scan.mjs +0 -168
- package/scripts/smoke-dist-bins.mjs +0 -89
- package/scripts/verify-dist.mjs +0 -29
- package/scripts/verify-v3-venues.mjs +0 -233
- package/skins/oracle.yaml +0 -56
- package/src/action-receipts.mjs +0 -265
- package/src/action-semantics.mjs +0 -62
- package/src/address-book.mjs +0 -208
- package/src/agent-auth.mjs +0 -206
- package/src/approval-guard.mjs +0 -282
- package/src/attestation-secret.mjs +0 -94
- package/src/audit-log.mjs +0 -196
- package/src/auth/oauth.mjs +0 -672
- package/src/auto-slippage.mjs +0 -378
- package/src/capability-posture.mjs +0 -125
- package/src/cards.mjs +0 -422
- package/src/chains.mjs +0 -62
- package/src/cli/chain-catalog.mjs +0 -215
- package/src/cli/chain-state.mjs +0 -74
- package/src/cli/commands/auth.mjs +0 -193
- package/src/cli/commands/bootstrap.mjs +0 -87
- package/src/cli/commands/chain.mjs +0 -143
- package/src/cli/commands/chat.mjs +0 -465
- package/src/cli/commands/credential.mjs +0 -9
- package/src/cli/commands/data-mcp.mjs +0 -18
- package/src/cli/commands/data.mjs +0 -75
- package/src/cli/commands/doctor.mjs +0 -136
- package/src/cli/commands/equities.mjs +0 -41
- package/src/cli/commands/farm.mjs +0 -129
- package/src/cli/commands/fees.mjs +0 -109
- package/src/cli/commands/follow.mjs +0 -130
- package/src/cli/commands/harness.mjs +0 -63
- package/src/cli/commands/help.mjs +0 -7
- package/src/cli/commands/init.mjs +0 -27
- package/src/cli/commands/mcp.mjs +0 -154
- package/src/cli/commands/model.mjs +0 -106
- package/src/cli/commands/plugins.mjs +0 -241
- package/src/cli/commands/prepare.mjs +0 -12
- package/src/cli/commands/public.mjs +0 -20
- package/src/cli/commands/resolve.mjs +0 -64
- package/src/cli/commands/route.mjs +0 -12
- package/src/cli/commands/runner.mjs +0 -9
- package/src/cli/commands/scan.mjs +0 -12
- package/src/cli/commands/setup.mjs +0 -294
- package/src/cli/commands/sign.mjs +0 -21
- package/src/cli/commands/signer.mjs +0 -9
- package/src/cli/commands/swap.mjs +0 -102
- package/src/cli/commands/upgrade.mjs +0 -12
- package/src/cli/commands/vault.mjs +0 -9
- package/src/cli/commands/version.mjs +0 -22
- package/src/cli/first-run.mjs +0 -23
- package/src/cli/kernel.mjs +0 -262
- package/src/cli/mcp-targets/chatgpt.mjs +0 -51
- package/src/cli/mcp-targets/claude-code.mjs +0 -39
- package/src/cli/mcp-targets/claude-desktop.mjs +0 -24
- package/src/cli/mcp-targets/codex.mjs +0 -41
- package/src/cli/mcp-targets/cursor.mjs +0 -32
- package/src/cli/mcp-targets/shared.mjs +0 -71
- package/src/cli/mcp-targets/vscode.mjs +0 -39
- package/src/cli/messaging-platforms.mjs +0 -217
- package/src/cli/model-config.mjs +0 -78
- package/src/cli/operator-dispatch.mjs +0 -257
- package/src/cli/oracle-harness.py +0 -415
- package/src/cli/paths.mjs +0 -107
- package/src/cli/runtime.mjs +0 -351
- package/src/cli/setup-state.mjs +0 -168
- package/src/cli/spawn-child.mjs +0 -43
- package/src/data/catalog.mjs +0 -858
- package/src/data/desk-data.mjs +0 -877
- package/src/data/http.mjs +0 -253
- package/src/data/names.mjs +0 -188
- package/src/data/provider-endpoint.mjs +0 -94
- package/src/data/providers/aave-v3.mjs +0 -139
- package/src/data/providers/across-bridge.mjs +0 -41
- package/src/data/providers/aerodrome.mjs +0 -245
- package/src/data/providers/aevo.mjs +0 -33
- package/src/data/providers/approval-indexer.mjs +0 -133
- package/src/data/providers/approvals.mjs +0 -594
- package/src/data/providers/babylon-staking.mjs +0 -149
- package/src/data/providers/balancer.mjs +0 -209
- package/src/data/providers/beefy-yields.mjs +0 -45
- package/src/data/providers/birdeye-tokens.mjs +0 -33
- package/src/data/providers/bisq-markets.mjs +0 -145
- package/src/data/providers/bitcoin-esplora.mjs +0 -216
- package/src/data/providers/bitcoin-meta.mjs +0 -378
- package/src/data/providers/blockscout.mjs +0 -14
- package/src/data/providers/bob-rootstock.mjs +0 -198
- package/src/data/providers/braiins-insights.mjs +0 -103
- package/src/data/providers/bridge-aggregator.mjs +0 -259
- package/src/data/providers/bridges.mjs +0 -242
- package/src/data/providers/bungee.mjs +0 -29
- package/src/data/providers/celestia-da.mjs +0 -38
- package/src/data/providers/changenow.mjs +0 -135
- package/src/data/providers/compound.mjs +0 -32
- package/src/data/providers/connext.mjs +0 -28
- package/src/data/providers/convex.mjs +0 -30
- package/src/data/providers/cow-protocol.mjs +0 -110
- package/src/data/providers/cowswap.mjs +0 -415
- package/src/data/providers/curve.mjs +0 -201
- package/src/data/providers/das-assets.mjs +0 -59
- package/src/data/providers/debridge.mjs +0 -109
- package/src/data/providers/defillama.mjs +0 -88
- package/src/data/providers/dexscreener.mjs +0 -43
- package/src/data/providers/drift.mjs +0 -32
- package/src/data/providers/dydx.mjs +0 -41
- package/src/data/providers/evm-rpc.mjs +0 -225
- package/src/data/providers/farming.mjs +0 -291
- package/src/data/providers/geckoterminal.mjs +0 -34
- package/src/data/providers/gmx.mjs +0 -496
- package/src/data/providers/hiro-stacks.mjs +0 -150
- package/src/data/providers/hl-assets.mjs +0 -165
- package/src/data/providers/hl-info.mjs +0 -108
- package/src/data/providers/hl-markets.mjs +0 -210
- package/src/data/providers/hl-outcome.mjs +0 -61
- package/src/data/providers/hl-perps.mjs +0 -419
- package/src/data/providers/hl-staking.mjs +0 -353
- package/src/data/providers/hl-ws.mjs +0 -119
- package/src/data/providers/hyperevm-dex.mjs +0 -49
- package/src/data/providers/jito-mev.mjs +0 -117
- package/src/data/providers/jupiter-venues.mjs +0 -119
- package/src/data/providers/jupiter.mjs +0 -315
- package/src/data/providers/kamino-strategies.mjs +0 -143
- package/src/data/providers/l2beat-tvl.mjs +0 -42
- package/src/data/providers/lifi.mjs +0 -166
- package/src/data/providers/liquid-esplora.mjs +0 -152
- package/src/data/providers/magiceden-ordinals.mjs +0 -141
- package/src/data/providers/magiceden-sol.mjs +0 -406
- package/src/data/providers/mempool-lightning.mjs +0 -144
- package/src/data/providers/mempool-mining.mjs +0 -142
- package/src/data/providers/meteora-dlmm.mjs +0 -168
- package/src/data/providers/morpho.mjs +0 -177
- package/src/data/providers/nft-gallery.mjs +0 -163
- package/src/data/providers/nft-portfolio.mjs +0 -494
- package/src/data/providers/odos.mjs +0 -156
- package/src/data/providers/ondo.mjs +0 -31
- package/src/data/providers/oneinch.mjs +0 -174
- package/src/data/providers/opensea-multichain.mjs +0 -136
- package/src/data/providers/opensea-nft.mjs +0 -371
- package/src/data/providers/orca.mjs +0 -29
- package/src/data/providers/ordinals-runes.mjs +0 -180
- package/src/data/providers/pancakeswap.mjs +0 -28
- package/src/data/providers/paraswap.mjs +0 -125
- package/src/data/providers/pendle.mjs +0 -188
- package/src/data/providers/poly-clob.mjs +0 -283
- package/src/data/providers/poly-public.mjs +0 -96
- package/src/data/providers/poly-ws.mjs +0 -103
- package/src/data/providers/polygon-staking.mjs +0 -227
- package/src/data/providers/portfolio-history.mjs +0 -394
- package/src/data/providers/portfolio.mjs +0 -600
- package/src/data/providers/pyth-price-feeds.mjs +0 -172
- package/src/data/providers/raydium.mjs +0 -35
- package/src/data/providers/relayscan-mev.mjs +0 -72
- package/src/data/providers/rfq.mjs +0 -15
- package/src/data/providers/rh-agent.mjs +0 -59
- package/src/data/providers/sanctum-lst.mjs +0 -180
- package/src/data/providers/satflow.mjs +0 -341
- package/src/data/providers/signed-material-guard.mjs +0 -108
- package/src/data/providers/solana-rpc.mjs +0 -197
- package/src/data/providers/solend-lending.mjs +0 -166
- package/src/data/providers/spark-lend.mjs +0 -42
- package/src/data/providers/squid-router.mjs +0 -29
- package/src/data/providers/stargate.mjs +0 -29
- package/src/data/providers/sushiswap.mjs +0 -30
- package/src/data/providers/symbiotic-restaking.mjs +0 -41
- package/src/data/providers/thorchain.mjs +0 -36
- package/src/data/providers/traderjoe.mjs +0 -28
- package/src/data/providers/twap.mjs +0 -152
- package/src/data/providers/uniswap-v3.mjs +0 -457
- package/src/data/providers/uniswap-v4.mjs +0 -414
- package/src/data/providers/vertex.mjs +0 -41
- package/src/data/providers/wallet-watch.mjs +0 -264
- package/src/data/providers/wormhole.mjs +0 -28
- package/src/data/providers/yearn.mjs +0 -31
- package/src/data/providers/zerox.mjs +0 -167
- package/src/data/public-api-scan.mjs +0 -61
- package/src/data/quote-placeholder.mjs +0 -31
- package/src/desk/swap-prepare.mjs +0 -194
- package/src/equities/bridge.mjs +0 -388
- package/src/equities/fixtures/bridge_routes.json +0 -159
- package/src/equities/fixtures/dst_transitions.json +0 -29
- package/src/equities/fixtures/equity_dex_pools.json +0 -154
- package/src/equities/fixtures/hip3_l2books.json +0 -2711
- package/src/equities/fixtures/nyse_holidays.json +0 -1
- package/src/equities/fixtures/oracles.json +0 -100
- package/src/equities/fixtures/rh_pool_state.json +0 -244
- package/src/equities/fixtures/solana_xstocks.json +0 -704
- package/src/equities/fixtures/ton_xstocks.json +0 -35
- package/src/equities/fixtures/universe.json +0 -411
- package/src/equities/fixtures/venues.json +0 -3542
- package/src/equities/fixtures.mjs +0 -405
- package/src/equities/funding.mjs +0 -142
- package/src/equities/index.mjs +0 -166
- package/src/equities/liveness.mjs +0 -148
- package/src/equities/marketHours.mjs +0 -249
- package/src/equities/normalize.mjs +0 -295
- package/src/equities/num.mjs +0 -146
- package/src/equities/prepare.mjs +0 -95
- package/src/equities/rank.mjs +0 -260
- package/src/equities/sourceNum.mjs +0 -69
- package/src/equities/types.mjs +0 -220
- package/src/equities/venues/arcus-perp.mjs +0 -84
- package/src/equities/venues/arcus-spot.mjs +0 -105
- package/src/equities/venues/hyperliquid-hip3.mjs +0 -224
- package/src/equities/venues/rh-uniswap.mjs +0 -216
- package/src/equities/venues/solana-xstocks.mjs +0 -139
- package/src/equities/venues/ton-stonfi.mjs +0 -139
- package/src/exact-integer.mjs +0 -72
- package/src/exec-policy.mjs +0 -419
- package/src/flags.mjs +0 -15
- package/src/fresh-window.mjs +0 -76
- package/src/gmx-attestation.mjs +0 -176
- package/src/index.mjs +0 -107
- package/src/licensing/locals-only.mjs +0 -25
- package/src/nft-gas-war-guard.mjs +0 -139
- package/src/onboarding/agent-keys.mjs +0 -161
- package/src/onboarding/harness-configs.mjs +0 -102
- package/src/onboarding/index.mjs +0 -18
- package/src/onboarding/tiers.mjs +0 -139
- package/src/oracle-env.mjs +0 -55
- package/src/package-manifest.mjs +0 -42
- package/src/plugins/agent-plugin-loader.mjs +0 -225
- package/src/portfolio-risk.mjs +0 -170
- package/src/prepare-envelope.mjs +0 -204
- package/src/profile-upgrade.mjs +0 -277
- package/src/protocol-execution.mjs +0 -84
- package/src/protocol-templates/gate.mjs +0 -179
- package/src/protocol-templates/prepare-deploy.mjs +0 -81
- package/src/public-api/agent-grants.mjs +0 -57
- package/src/public-api/buzz-integration.mjs +0 -267
- package/src/public-api/connect-agent.mjs +0 -424
- package/src/public-api/grants.mjs +0 -142
- package/src/public-api/http.mjs +0 -707
- package/src/public-api/metering.mjs +0 -111
- package/src/public-control/aa-adapter.mjs +0 -402
- package/src/public-control/build-registry.mjs +0 -227
- package/src/public-control/bundler-client.mjs +0 -357
- package/src/public-control/grant-indexer.mjs +0 -296
- package/src/public-control/policy-render.mjs +0 -69
- package/src/public-control/policy-schema.mjs +0 -322
- package/src/public-control/runtime-config.mjs +0 -275
- package/src/public-control/session-key-model.mjs +0 -379
- package/src/public-control/session-orchestrator.mjs +0 -418
- package/src/rfq/intent.mjs +0 -180
- package/src/rfq/sources.mjs +0 -181
- package/src/route-attestation.mjs +0 -132
- package/src/router/best-execution.mjs +0 -326
- package/src/router/index.mjs +0 -250
- package/src/router/integrator-fee.mjs +0 -135
- package/src/router/prepare-bridge.mjs +0 -293
- package/src/router/prepare-route.mjs +0 -398
- package/src/router/proposal.mjs +0 -311
- package/src/router/risk-classifier.mjs +0 -119
- package/src/router/route-sources.mjs +0 -364
- package/src/scanner/chains.config.mjs +0 -543
- package/src/scanner/contract.mjs +0 -270
- package/src/scanner/evm-scanner.mjs +0 -394
- package/src/scanner/index.mjs +0 -9
- package/src/scanner/v2-venue.mjs +0 -351
- package/src/scanner/v3-venue.mjs +0 -308
- package/src/scopes.mjs +0 -44
- package/src/sell-simulation.mjs +0 -167
- package/src/signals/engine.mjs +0 -146
- package/src/signals/index.mjs +0 -1
- package/src/token-transfer-guard.mjs +0 -188
- package/src/tui/app.mjs +0 -438
- package/src/tui/backend.mjs +0 -215
- package/src/tui/format.mjs +0 -272
- package/src/tui/gateway-client.mjs +0 -177
- package/src/tui/input.mjs +0 -501
- package/src/tui/memory.mjs +0 -105
- package/src/tui/meta-learn.mjs +0 -85
- package/src/tui/renderer.mjs +0 -443
- package/src/tui/scheduler.mjs +0 -205
- package/src/tui/skills-loader.mjs +0 -140
- package/src/tui/standalone-client.mjs +0 -752
- package/src/tui/theme.mjs +0 -81
- package/src/vault-attestation.mjs +0 -146
- package/src/venues.mjs +0 -206
- package/src/watch-preferences.mjs +0 -85
- /package/{profiles → dist/assets/profiles}/_template/SOUL.md +0 -0
- /package/{profiles → dist/assets/profiles}/_template/profile.json +0 -0
- /package/{profiles → dist/assets/profiles}/bitcoin-agent/SOUL.md +0 -0
- /package/{profiles → dist/assets/profiles}/bitcoin-agent/profile.json +0 -0
- /package/{profiles → dist/assets/profiles}/hyperliquid-agent/SOUL.md +0 -0
- /package/{profiles → dist/assets/profiles}/hyperliquid-agent/profile.json +0 -0
- /package/{profiles → dist/assets/profiles}/oracle/SOUL.md +0 -0
- /package/{profiles → dist/assets/profiles}/oracle/profile.json +0 -0
- /package/{profiles → dist/assets/profiles}/polymarket-agent/SOUL.md +0 -0
- /package/{profiles → dist/assets/profiles}/polymarket-agent/profile.json +0 -0
- /package/{profiles → dist/assets/profiles}/profile.schema.json +0 -0
- /package/{profiles → dist/assets/profiles}/protocol-builder/SOUL.md +0 -0
- /package/{profiles → dist/assets/profiles}/protocol-builder/profile.json +0 -0
- /package/{profiles → dist/assets/profiles}/robinhood-agent/SOUL.md +0 -0
- /package/{profiles → dist/assets/profiles}/robinhood-agent/profile.json +0 -0
- /package/{profiles → dist/assets/profiles}/solana-agent/SOUL.md +0 -0
- /package/{profiles → dist/assets/profiles}/solana-agent/profile.json +0 -0
- /package/{profiles → dist/assets/profiles}/stable-agent/SOUL.md +0 -0
- /package/{profiles → dist/assets/profiles}/stable-agent/profile.json +0 -0
- /package/{skills → dist/assets/skills}/balance/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/bitcoin-l1.md +0 -0
- /package/{skills → dist/assets/skills}/chain-defi-ecosystem-profiling.md +0 -0
- /package/{skills → dist/assets/skills}/evm-contract-research.md +0 -0
- /package/{skills → dist/assets/skills}/hyperliquid.md +0 -0
- /package/{skills → dist/assets/skills}/multichain-exec-desk.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-action-semantics/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-best-execution/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-best-execution.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-bitcoin/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-chain-graphs-telegram-cards/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-chat/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-chat/chain.SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-chat/setup.SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-circuit-breaker/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-contract-research/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-desk/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-desk.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-dex-launch/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-equities/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-grants/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-hypercore-staking/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-hyperliquid/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-meme-token-sniper/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-multichain-nft-launch/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-multichain-token-launch/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-nft-gacha-launch/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-nft-mint-gas-war/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-polymarket/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-protocol-builder/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-protocol-security/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-public-product/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-receipts/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-receipts.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-rfq-tokenized-assets/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-smart-wallet-scanner/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-solana/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-solana-nft/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/oracle-token-research/SKILL.md +0 -0
- /package/{skills → dist/assets/skills}/solana.md +0 -0
package/src/equities/rank.mjs
DELETED
|
@@ -1,260 +0,0 @@
|
|
|
1
|
-
// Net-of-cost ranking engine.
|
|
2
|
-
//
|
|
3
|
-
// Ranks quotes after fees, gas, and impact at the requested size. Missing costs
|
|
4
|
-
// force rankedOn: "gross" for that comparison and are never silently treated as
|
|
5
|
-
// zero. Default mode segments by instrument (spot table vs perp table). Horizon
|
|
6
|
-
// mode merges via funding carry and reports the breakeven hold duration.
|
|
7
|
-
//
|
|
8
|
-
// bestPreparable is independent of the overall winner so a quote-only best price
|
|
9
|
-
// is never presented as actionable.
|
|
10
|
-
|
|
11
|
-
import { filterQuotes } from './liveness.mjs';
|
|
12
|
-
import { carryForQuote } from './funding.mjs';
|
|
13
|
-
import { sessionState } from './marketHours.mjs';
|
|
14
|
-
import {
|
|
15
|
-
add,
|
|
16
|
-
cmp,
|
|
17
|
-
div,
|
|
18
|
-
fromScaledInteger,
|
|
19
|
-
mul,
|
|
20
|
-
parseDecimal,
|
|
21
|
-
sub,
|
|
22
|
-
toString,
|
|
23
|
-
} from './num.mjs';
|
|
24
|
-
import { validateRankResult } from './types.mjs';
|
|
25
|
-
|
|
26
|
-
function priceOf(quote) {
|
|
27
|
-
return quote.mid ?? quote.mark ?? quote.ask ?? quote.bid ?? null;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function netScore(quote) {
|
|
31
|
-
// Lower is better for a buy (you pay less). Higher is better for a sell.
|
|
32
|
-
// We normalize to a "cost to buy one unit" score so sorting is consistent.
|
|
33
|
-
const px = priceOf(quote);
|
|
34
|
-
if (px === null) return null;
|
|
35
|
-
|
|
36
|
-
let costAccounted = quote.costAccounted === true;
|
|
37
|
-
let extras = parseDecimal('0');
|
|
38
|
-
|
|
39
|
-
if (quote.fees !== null) {
|
|
40
|
-
// fees is a fraction of notional when from fee tier; when it's absolute we
|
|
41
|
-
// still add it. Adapters emit fee as a rate fraction or absolute; treat as
|
|
42
|
-
// absolute addend for v1 when scale suggests a small number.
|
|
43
|
-
extras = add(extras, quote.fees);
|
|
44
|
-
} else {
|
|
45
|
-
costAccounted = false;
|
|
46
|
-
}
|
|
47
|
-
if (quote.priceImpact !== null) {
|
|
48
|
-
extras = add(extras, quote.priceImpact);
|
|
49
|
-
} else if (quote.requestedSize && quote.requestedSize.mantissa > 0n) {
|
|
50
|
-
costAccounted = false;
|
|
51
|
-
}
|
|
52
|
-
if (quote.gasEstimate === null) {
|
|
53
|
-
costAccounted = false;
|
|
54
|
-
} else {
|
|
55
|
-
extras = add(extras, quote.gasEstimate);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// For a buy, net = price * (1 + feeRate-ish) + impact. We approximate by
|
|
59
|
-
// price + extras when extras are absolute fractions of 1 (fee rates).
|
|
60
|
-
// fee rates like 0.003 are added to 1 then multiplied.
|
|
61
|
-
// Detect rate-like fees (value < 1) vs absolute.
|
|
62
|
-
let net;
|
|
63
|
-
if (quote.fees !== null && cmp(quote.fees, parseDecimal('1')) < 0 && cmp(quote.fees, parseDecimal('0')) >= 0) {
|
|
64
|
-
const onePlus = add(parseDecimal('1'), quote.fees);
|
|
65
|
-
net = mul(px, onePlus);
|
|
66
|
-
if (quote.priceImpact !== null) net = add(net, mul(px, quote.priceImpact));
|
|
67
|
-
} else {
|
|
68
|
-
net = add(px, extras);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return { net, costAccounted, px };
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function routeEntry(quote, score, carry = null) {
|
|
75
|
-
return {
|
|
76
|
-
venue: quote.venue,
|
|
77
|
-
chain: quote.chain,
|
|
78
|
-
instrument: quote.instrument,
|
|
79
|
-
tier: quote.tier,
|
|
80
|
-
symbol: quote.symbol,
|
|
81
|
-
symbolRaw: quote.symbolRaw,
|
|
82
|
-
side: quote.side,
|
|
83
|
-
price: score.px,
|
|
84
|
-
net: score.net,
|
|
85
|
-
costAccounted: score.costAccounted,
|
|
86
|
-
fundingHourly: quote.fundingHourly,
|
|
87
|
-
carry,
|
|
88
|
-
quote,
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
function improvementBps(winner, runner) {
|
|
93
|
-
if (!winner || !runner) return null;
|
|
94
|
-
if (!winner.costAccounted || !runner.costAccounted) return null;
|
|
95
|
-
if (winner.instrument !== runner.instrument) return null;
|
|
96
|
-
if (winner.net.mantissa === 0n) return null;
|
|
97
|
-
// For buys: how many bps cheaper is winner than runner.
|
|
98
|
-
const delta = sub(runner.net, winner.net);
|
|
99
|
-
return div(mul(delta, fromScaledInteger(10000n, 0)), runner.net, 4);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Rank a list of quotes for one symbol.
|
|
104
|
-
*
|
|
105
|
-
* @param {object[]} quotes
|
|
106
|
-
* @param {object} [opts]
|
|
107
|
-
* @param {number} [opts.horizonHours] if set, enable heterogeneous carry mode
|
|
108
|
-
* @param {number} [opts.nowMs]
|
|
109
|
-
* @param {boolean} [opts.skipLiveness]
|
|
110
|
-
*/
|
|
111
|
-
export function rank(quotes, opts = {}) {
|
|
112
|
-
if (!Array.isArray(quotes)) throw new TypeError('quotes must be an array');
|
|
113
|
-
|
|
114
|
-
const nowMs = opts.nowMs ?? (quotes[0]?.capturedAt ?? Date.now());
|
|
115
|
-
const sourcesTried = quotes.length;
|
|
116
|
-
let working = quotes;
|
|
117
|
-
let excluded = [];
|
|
118
|
-
|
|
119
|
-
if (!opts.skipLiveness) {
|
|
120
|
-
const gate = filterQuotes(quotes, { nowMs });
|
|
121
|
-
working = gate.survivors;
|
|
122
|
-
excluded = gate.excluded;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
const sourcesAnswered = quotes.length; // all inputs answered; failures come from callers
|
|
126
|
-
const failed = []; // ranking does not itself call adapters
|
|
127
|
-
|
|
128
|
-
const horizonHours = opts.horizonHours;
|
|
129
|
-
const heterogeneous = Number.isFinite(horizonHours) && horizonHours > 0;
|
|
130
|
-
|
|
131
|
-
// Score each survivor.
|
|
132
|
-
const scored = [];
|
|
133
|
-
for (const q of working) {
|
|
134
|
-
const score = netScore(q);
|
|
135
|
-
if (score === null) continue;
|
|
136
|
-
let carry = null;
|
|
137
|
-
if (heterogeneous && q.instrument === 'perp') {
|
|
138
|
-
carry = carryForQuote(q, horizonHours, { nowMs });
|
|
139
|
-
// Fold carry into net as an additive cost in price space is wrong dimensionally.
|
|
140
|
-
// Carry is in bps of notional; convert: net' = net * (1 + carryBps/10000)
|
|
141
|
-
if (carry.carryBps !== null) {
|
|
142
|
-
const factor = add(
|
|
143
|
-
parseDecimal('1'),
|
|
144
|
-
div(carry.carryBps, fromScaledInteger(10000n, 0), 12),
|
|
145
|
-
);
|
|
146
|
-
score.net = mul(score.net, factor);
|
|
147
|
-
// Carry is an estimate: never upgrade costAccounted.
|
|
148
|
-
score.costAccounted = false;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
scored.push(routeEntry(q, score, carry));
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
// Segment.
|
|
155
|
-
let pool = scored;
|
|
156
|
-
let instrumentMix = 'homogeneous';
|
|
157
|
-
if (!heterogeneous) {
|
|
158
|
-
// Default: require a single instrument class. If mixed, rank each class
|
|
159
|
-
// separately and pick the class with more routes (spot preferred on tie).
|
|
160
|
-
const spots = scored.filter((r) => r.instrument === 'spot');
|
|
161
|
-
const perps = scored.filter((r) => r.instrument === 'perp');
|
|
162
|
-
if (spots.length > 0 && perps.length > 0) {
|
|
163
|
-
pool = spots.length >= perps.length ? spots : perps;
|
|
164
|
-
instrumentMix = 'homogeneous';
|
|
165
|
-
} else {
|
|
166
|
-
pool = scored;
|
|
167
|
-
instrumentMix = 'homogeneous';
|
|
168
|
-
}
|
|
169
|
-
} else {
|
|
170
|
-
instrumentMix = 'heterogeneous';
|
|
171
|
-
pool = scored;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
// Sort ascending by net (best buy price first). Stable tie break on venue name.
|
|
175
|
-
pool.sort((a, b) => {
|
|
176
|
-
const c = cmp(a.net, b.net);
|
|
177
|
-
if (c !== 0) return c;
|
|
178
|
-
return a.venue < b.venue ? -1 : a.venue > b.venue ? 1 : 0;
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
const winner = pool[0] ?? null;
|
|
182
|
-
const runnersUp = pool.slice(1);
|
|
183
|
-
const ranked = pool;
|
|
184
|
-
|
|
185
|
-
// rankedOn: net-of-cost only when the top two both fully accounted; else gross.
|
|
186
|
-
let rankedOn = 'gross';
|
|
187
|
-
if (winner && winner.costAccounted && (runnersUp.length === 0 || runnersUp[0].costAccounted)) {
|
|
188
|
-
rankedOn = 'net-of-cost';
|
|
189
|
-
}
|
|
190
|
-
// One answering source is not a comparison.
|
|
191
|
-
const imp =
|
|
192
|
-
runnersUp.length === 0 ? null : improvementBps(winner, runnersUp[0]);
|
|
193
|
-
|
|
194
|
-
const bestPreparable =
|
|
195
|
-
scored.find((r) => r.tier === 'prepare') ?? null;
|
|
196
|
-
|
|
197
|
-
const session = sessionState(nowMs);
|
|
198
|
-
const darkWindow =
|
|
199
|
-
session === 'core'
|
|
200
|
-
? null
|
|
201
|
-
: {
|
|
202
|
-
session,
|
|
203
|
-
warning:
|
|
204
|
-
session === 'dark'
|
|
205
|
-
? 'market is dark; marks are not real price discovery'
|
|
206
|
-
: 'extended session; thinner books and higher staleness risk',
|
|
207
|
-
};
|
|
208
|
-
|
|
209
|
-
// Breakeven horizon between best spot and best perp (heterogeneous diagnostic).
|
|
210
|
-
let breakEvenHorizonHours = null;
|
|
211
|
-
if (heterogeneous) {
|
|
212
|
-
breakEvenHorizonHours = estimateBreakeven(scored);
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
const result = {
|
|
216
|
-
rankedOn,
|
|
217
|
-
ranked,
|
|
218
|
-
winner,
|
|
219
|
-
runnersUp,
|
|
220
|
-
improvementBps: imp === null ? null : Number(toString(imp)),
|
|
221
|
-
sourcesAnswered,
|
|
222
|
-
sourcesTried,
|
|
223
|
-
failed,
|
|
224
|
-
excluded,
|
|
225
|
-
darkWindow,
|
|
226
|
-
instrumentMix,
|
|
227
|
-
bestPreparable,
|
|
228
|
-
carry: winner?.carry ?? null,
|
|
229
|
-
breakEvenHorizonHours,
|
|
230
|
-
};
|
|
231
|
-
|
|
232
|
-
return validateRankResult(result);
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
function estimateBreakeven(scored) {
|
|
236
|
-
const bestSpot = scored
|
|
237
|
-
.filter((r) => r.instrument === 'spot')
|
|
238
|
-
.sort((a, b) => cmp(a.net, b.net))[0];
|
|
239
|
-
const bestPerp = scored
|
|
240
|
-
.filter((r) => r.instrument === 'perp')
|
|
241
|
-
.sort((a, b) => cmp(a.net, b.net))[0];
|
|
242
|
-
if (!bestSpot || !bestPerp || bestPerp.fundingHourly === null) return null;
|
|
243
|
-
|
|
244
|
-
// Entry gap in price space. Carry closes the gap at rate funding * price per hour.
|
|
245
|
-
// breakEvenHours ~= entryGap / (fundingHourly * perpPrice)
|
|
246
|
-
const gap = sub(bestSpot.net, bestPerp.net); // positive if spot more expensive
|
|
247
|
-
if (gap.mantissa === 0n) return 0;
|
|
248
|
-
// If perp is more expensive at entry and funding is positive (longs pay), gap never closes for a long.
|
|
249
|
-
const hourlyCarry = mul(bestPerp.fundingHourly, bestPerp.price);
|
|
250
|
-
if (hourlyCarry.mantissa === 0n) return null;
|
|
251
|
-
// hours = gap / hourlyCarry (only meaningful when signs agree)
|
|
252
|
-
try {
|
|
253
|
-
const hours = div(gap, hourlyCarry, 4);
|
|
254
|
-
const h = Number(toString(hours));
|
|
255
|
-
if (!Number.isFinite(h) || h < 0) return null;
|
|
256
|
-
return h;
|
|
257
|
-
} catch {
|
|
258
|
-
return null;
|
|
259
|
-
}
|
|
260
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
// Source numbers arrive from venue JSON as IEEE 754 doubles. The numeric core in
|
|
2
|
-
// src/num.mjs deliberately refuses JavaScript numbers, so every adapter needs one
|
|
3
|
-
// audited crossing point from approximate source data into exact fixed point.
|
|
4
|
-
//
|
|
5
|
-
// This module is that crossing point. It exists so the conversion is written once
|
|
6
|
-
// and tested once, rather than six adapters each inventing their own.
|
|
7
|
-
//
|
|
8
|
-
// Honesty boundary: converting a double to fixed point does NOT make it exact. It
|
|
9
|
-
// makes it EXACTLY REPRESENTED. The value still carries whatever error the venue
|
|
10
|
-
// and JSON parsing already introduced. Nothing here may be read as a precision
|
|
11
|
-
// upgrade. See docs/NUMERIC.md.
|
|
12
|
-
|
|
13
|
-
import { parseDecimal } from './num.mjs';
|
|
14
|
-
|
|
15
|
-
// Number.prototype.toString gives the shortest string that round trips back to the
|
|
16
|
-
// same double, which is the closest thing to source truth we can recover after
|
|
17
|
-
// JSON.parse. Its one problem is exponent notation, which parseDecimal rejects on
|
|
18
|
-
// purpose. So we expand it here rather than loosening the parser.
|
|
19
|
-
export function numberToDecimalString(value) {
|
|
20
|
-
if (typeof value !== 'number' || !Number.isFinite(value)) {
|
|
21
|
-
throw new TypeError('value must be a finite number');
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const text = String(value);
|
|
25
|
-
if (!text.includes('e') && !text.includes('E')) return text;
|
|
26
|
-
|
|
27
|
-
const [mantissaText, exponentText] = text.split(/[eE]/);
|
|
28
|
-
const exponent = Number(exponentText);
|
|
29
|
-
const negative = mantissaText.startsWith('-');
|
|
30
|
-
const unsigned = negative ? mantissaText.slice(1) : mantissaText;
|
|
31
|
-
const [whole, fraction = ''] = unsigned.split('.');
|
|
32
|
-
const digits = `${whole}${fraction}`;
|
|
33
|
-
// Decimal point currently sits after the whole part, then shifts by the exponent.
|
|
34
|
-
const pointIndex = whole.length + exponent;
|
|
35
|
-
|
|
36
|
-
let out;
|
|
37
|
-
if (pointIndex <= 0) {
|
|
38
|
-
out = `0.${'0'.repeat(-pointIndex)}${digits}`;
|
|
39
|
-
} else if (pointIndex >= digits.length) {
|
|
40
|
-
out = `${digits}${'0'.repeat(pointIndex - digits.length)}`;
|
|
41
|
-
} else {
|
|
42
|
-
out = `${digits.slice(0, pointIndex)}.${digits.slice(pointIndex)}`;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
return `${negative ? '-' : ''}${out}`;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// Convert an approximate source number to fixed point. Returns null for null,
|
|
49
|
-
// undefined, and non finite input so a missing venue field stays MISSING and
|
|
50
|
-
// forces costAccounted false downstream. A missing number must never become zero.
|
|
51
|
-
export function fromSourceNumber(value) {
|
|
52
|
-
if (value === null || value === undefined) return null;
|
|
53
|
-
if (typeof value === 'string') {
|
|
54
|
-
// Some venues publish decimal strings. Those are source truth, use them directly.
|
|
55
|
-
return parseDecimal(value);
|
|
56
|
-
}
|
|
57
|
-
if (typeof value !== 'number' || !Number.isFinite(value)) return null;
|
|
58
|
-
return parseDecimal(numberToDecimalString(value));
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// Same as fromSourceNumber but throws instead of returning null. Use only where a
|
|
62
|
-
// field is structurally guaranteed by the fixture shape check.
|
|
63
|
-
export function requireSourceNumber(value, label) {
|
|
64
|
-
const parsed = fromSourceNumber(value);
|
|
65
|
-
if (parsed === null) {
|
|
66
|
-
throw new TypeError(`${label} must be a finite source number`);
|
|
67
|
-
}
|
|
68
|
-
return parsed;
|
|
69
|
-
}
|
package/src/equities/types.mjs
DELETED
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
const INSTRUMENTS = new Set(['spot', 'perp']);
|
|
2
|
-
const TIERS = new Set(['read-only', 'quote-only', 'prepare', 'intent']);
|
|
3
|
-
const SIDES = new Set(['buy', 'sell']);
|
|
4
|
-
const RANKED_ON = new Set(['net-of-cost', 'gross']);
|
|
5
|
-
const INSTRUMENT_MIXES = new Set(['homogeneous', 'heterogeneous']);
|
|
6
|
-
const PRICE_FIELDS = ['bid', 'ask', 'mid', 'mark'];
|
|
7
|
-
const COST_FIELDS = ['fees', 'gasEstimate', 'priceImpact', 'fundingHourly'];
|
|
8
|
-
const MACHINE_REASON = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;
|
|
9
|
-
|
|
10
|
-
function fail(path, message) {
|
|
11
|
-
throw new TypeError(`${path} ${message}`);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
function isRecord(value) {
|
|
15
|
-
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function requireRecord(value, path) {
|
|
19
|
-
if (!isRecord(value)) fail(path, 'must be an object');
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function requireOwn(value, key, path) {
|
|
23
|
-
if (!Object.hasOwn(value, key)) fail(`${path}.${key}`, 'is required');
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function requireString(value, path) {
|
|
27
|
-
if (typeof value !== 'string' || value.length === 0) {
|
|
28
|
-
fail(path, 'must be a nonempty string');
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function requireEnum(value, allowed, path) {
|
|
33
|
-
if (!allowed.has(value)) {
|
|
34
|
-
fail(path, `must be one of ${[...allowed].join(', ')}`);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function requireCount(value, path) {
|
|
39
|
-
if (!Number.isSafeInteger(value) || value < 0) {
|
|
40
|
-
fail(path, 'must be a nonnegative safe integer');
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function requireFixed(value, path, nullable = false) {
|
|
45
|
-
if (value === null && nullable) return;
|
|
46
|
-
if (!isRecord(value)) fail(path, 'must be a fixed point value');
|
|
47
|
-
if (typeof value.mantissa !== 'bigint') fail(`${path}.mantissa`, 'must be a bigint');
|
|
48
|
-
if (!Number.isSafeInteger(value.scale) || value.scale < 0) {
|
|
49
|
-
fail(`${path}.scale`, 'must be a nonnegative safe integer');
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function requireRoute(value, path, nullable = false) {
|
|
54
|
-
if (value === null && nullable) return;
|
|
55
|
-
requireRecord(value, path);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function validateOutcomeEntry(entry, path) {
|
|
59
|
-
requireRecord(entry, path);
|
|
60
|
-
requireString(entry.venue, `${path}.venue`);
|
|
61
|
-
requireString(entry.reason, `${path}.reason`);
|
|
62
|
-
if (!MACHINE_REASON.test(entry.reason)) {
|
|
63
|
-
fail(`${path}.reason`, 'must be a machine readable lower case code');
|
|
64
|
-
}
|
|
65
|
-
if (Object.hasOwn(entry, 'symbol') && entry.symbol !== null) {
|
|
66
|
-
requireString(entry.symbol, `${path}.symbol`);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export function validateQuote(quote) {
|
|
71
|
-
requireRecord(quote, 'quote');
|
|
72
|
-
|
|
73
|
-
for (const key of [
|
|
74
|
-
'venue',
|
|
75
|
-
'chain',
|
|
76
|
-
'instrument',
|
|
77
|
-
'tier',
|
|
78
|
-
'symbolRaw',
|
|
79
|
-
'symbol',
|
|
80
|
-
'side',
|
|
81
|
-
'requestedSize',
|
|
82
|
-
...COST_FIELDS,
|
|
83
|
-
'costAccounted',
|
|
84
|
-
'capturedAt',
|
|
85
|
-
'blockOrSeq',
|
|
86
|
-
'raw',
|
|
87
|
-
]) {
|
|
88
|
-
requireOwn(quote, key, 'quote');
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
requireString(quote.venue, 'quote.venue');
|
|
92
|
-
if (
|
|
93
|
-
!(typeof quote.chain === 'string' && quote.chain.length > 0) &&
|
|
94
|
-
!(Number.isSafeInteger(quote.chain) && quote.chain >= 0)
|
|
95
|
-
) {
|
|
96
|
-
fail('quote.chain', 'must be a nonempty string or nonnegative chain id');
|
|
97
|
-
}
|
|
98
|
-
requireEnum(quote.instrument, INSTRUMENTS, 'quote.instrument');
|
|
99
|
-
requireEnum(quote.tier, TIERS, 'quote.tier');
|
|
100
|
-
requireString(quote.symbolRaw, 'quote.symbolRaw');
|
|
101
|
-
requireString(quote.symbol, 'quote.symbol');
|
|
102
|
-
requireEnum(quote.side, SIDES, 'quote.side');
|
|
103
|
-
requireFixed(quote.requestedSize, 'quote.requestedSize');
|
|
104
|
-
if (quote.requestedSize.mantissa < 0n) {
|
|
105
|
-
fail('quote.requestedSize', 'must not be negative');
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
let pricesFound = 0;
|
|
109
|
-
for (const field of PRICE_FIELDS) {
|
|
110
|
-
if (Object.hasOwn(quote, field)) {
|
|
111
|
-
requireFixed(quote[field], `quote.${field}`);
|
|
112
|
-
pricesFound += 1;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
if (pricesFound === 0) {
|
|
116
|
-
fail('quote', 'must contain at least one of bid, ask, mid, mark');
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
for (const field of COST_FIELDS) {
|
|
120
|
-
requireFixed(quote[field], `quote.${field}`, true);
|
|
121
|
-
}
|
|
122
|
-
if (typeof quote.costAccounted !== 'boolean') {
|
|
123
|
-
fail('quote.costAccounted', 'must be a boolean');
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
if (quote.costAccounted) {
|
|
127
|
-
for (const field of ['fees', 'gasEstimate', 'priceImpact']) {
|
|
128
|
-
if (quote[field] === null) {
|
|
129
|
-
fail(`quote.${field}`, 'cannot be unknown when costAccounted is true');
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
if (quote.instrument === 'perp' && quote.fundingHourly === null) {
|
|
133
|
-
fail('quote.fundingHourly', 'cannot be unknown when costAccounted is true for a perp');
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
if (quote.instrument === 'spot' && quote.fundingHourly !== null) {
|
|
137
|
-
fail('quote.fundingHourly', 'must be null for a spot quote');
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
requireCount(quote.capturedAt, 'quote.capturedAt');
|
|
141
|
-
if (
|
|
142
|
-
quote.blockOrSeq !== null &&
|
|
143
|
-
!(typeof quote.blockOrSeq === 'string' && quote.blockOrSeq.length > 0) &&
|
|
144
|
-
!(Number.isSafeInteger(quote.blockOrSeq) && quote.blockOrSeq >= 0)
|
|
145
|
-
) {
|
|
146
|
-
fail('quote.blockOrSeq', 'must be null, a nonempty string, or a nonnegative safe integer');
|
|
147
|
-
}
|
|
148
|
-
requireRecord(quote.raw, 'quote.raw');
|
|
149
|
-
|
|
150
|
-
return quote;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
export function validateRankResult(result) {
|
|
154
|
-
requireRecord(result, 'rankResult');
|
|
155
|
-
|
|
156
|
-
for (const key of [
|
|
157
|
-
'rankedOn',
|
|
158
|
-
'ranked',
|
|
159
|
-
'winner',
|
|
160
|
-
'runnersUp',
|
|
161
|
-
'improvementBps',
|
|
162
|
-
'sourcesAnswered',
|
|
163
|
-
'sourcesTried',
|
|
164
|
-
'failed',
|
|
165
|
-
'excluded',
|
|
166
|
-
'darkWindow',
|
|
167
|
-
'instrumentMix',
|
|
168
|
-
'bestPreparable',
|
|
169
|
-
]) {
|
|
170
|
-
requireOwn(result, key, 'rankResult');
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
requireEnum(result.rankedOn, RANKED_ON, 'rankResult.rankedOn');
|
|
174
|
-
if (!Array.isArray(result.ranked)) fail('rankResult.ranked', 'must be an array');
|
|
175
|
-
result.ranked.forEach((route, index) => requireRoute(route, `rankResult.ranked[${index}]`));
|
|
176
|
-
|
|
177
|
-
requireRoute(result.winner, 'rankResult.winner', true);
|
|
178
|
-
if (result.ranked.length === 0 && result.winner !== null) {
|
|
179
|
-
fail('rankResult.winner', 'must be null when ranked is empty');
|
|
180
|
-
}
|
|
181
|
-
if (result.ranked.length > 0 && result.winner === null) {
|
|
182
|
-
fail('rankResult.winner', 'must be present when ranked is not empty');
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
if (!Array.isArray(result.runnersUp)) fail('rankResult.runnersUp', 'must be an array');
|
|
186
|
-
result.runnersUp.forEach((route, index) =>
|
|
187
|
-
requireRoute(route, `rankResult.runnersUp[${index}]`),
|
|
188
|
-
);
|
|
189
|
-
|
|
190
|
-
if (
|
|
191
|
-
result.improvementBps !== null &&
|
|
192
|
-
!(typeof result.improvementBps === 'number' && Number.isFinite(result.improvementBps))
|
|
193
|
-
) {
|
|
194
|
-
fail('rankResult.improvementBps', 'must be a finite number or null');
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
requireCount(result.sourcesAnswered, 'rankResult.sourcesAnswered');
|
|
198
|
-
requireCount(result.sourcesTried, 'rankResult.sourcesTried');
|
|
199
|
-
if (result.sourcesAnswered > result.sourcesTried) {
|
|
200
|
-
fail('rankResult.sourcesAnswered', 'must not exceed sourcesTried');
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
if (!Array.isArray(result.failed)) fail('rankResult.failed', 'must be an array');
|
|
204
|
-
result.failed.forEach((entry, index) => validateOutcomeEntry(entry, `failed[${index}]`));
|
|
205
|
-
|
|
206
|
-
if (!Array.isArray(result.excluded)) fail('rankResult.excluded', 'must be an array');
|
|
207
|
-
result.excluded.forEach((entry, index) => validateOutcomeEntry(entry, `excluded[${index}]`));
|
|
208
|
-
|
|
209
|
-
if (result.darkWindow !== null) {
|
|
210
|
-
requireRecord(result.darkWindow, 'rankResult.darkWindow');
|
|
211
|
-
}
|
|
212
|
-
requireEnum(result.instrumentMix, INSTRUMENT_MIXES, 'rankResult.instrumentMix');
|
|
213
|
-
requireRoute(result.bestPreparable, 'rankResult.bestPreparable', true);
|
|
214
|
-
|
|
215
|
-
if (Object.hasOwn(result, 'carry') && result.carry !== null) {
|
|
216
|
-
requireRecord(result.carry, 'rankResult.carry');
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
return result;
|
|
220
|
-
}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
// Arcus perpetual markets on Robinhood Chain 4663.
|
|
2
|
-
// Tier: quote-only. Reports mark, oracle, funding, RTH flags, and margin fractions
|
|
3
|
-
// exactly as the fixture captured them. Dark-window funding is locked to the SOFR
|
|
4
|
-
// + 0.5% hourly constant; that constant is surfaceable from the fixture so
|
|
5
|
-
// funding.mjs can apply it without re-deriving SOFR.
|
|
6
|
-
|
|
7
|
-
import { getVenues } from '../fixtures.mjs';
|
|
8
|
-
import { fromSourceNumber, requireSourceNumber } from '../sourceNum.mjs';
|
|
9
|
-
import { parseDecimal } from '../num.mjs';
|
|
10
|
-
import { validateQuote } from '../types.mjs';
|
|
11
|
-
|
|
12
|
-
export const VENUE = 'arcus_perp';
|
|
13
|
-
export const CHAIN = 'robinhood-4663';
|
|
14
|
-
export const TIER = 'quote-only';
|
|
15
|
-
|
|
16
|
-
// Locked dark-window hourly funding: SOFR + 0.5% annualized, held constant.
|
|
17
|
-
// Verified exact string round trip through the fixed point core.
|
|
18
|
-
export const DARK_WINDOW_FUNDING_HOURLY = '0.00000480324074074';
|
|
19
|
-
|
|
20
|
-
function arcus() {
|
|
21
|
-
return getVenues().venues.arcus;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function listMarkets() {
|
|
25
|
-
return Object.keys(arcus().markets).sort();
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export function quote({ symbol, side = 'buy', sizeUsd = null } = {}) {
|
|
29
|
-
if (typeof symbol !== 'string' || symbol.length === 0) return null;
|
|
30
|
-
// Accept both NVDA and NVDA-USD forms.
|
|
31
|
-
const bare = symbol.endsWith('-USD') ? symbol.slice(0, -4) : symbol;
|
|
32
|
-
const market = arcus().markets[bare];
|
|
33
|
-
if (!market) return null;
|
|
34
|
-
|
|
35
|
-
const mark = requireSourceNumber(market.mark, `${bare}.mark`);
|
|
36
|
-
const oracle = fromSourceNumber(market.oracle);
|
|
37
|
-
const funding = fromSourceNumber(market.fundingHourly);
|
|
38
|
-
const requested = sizeUsd === null ? parseDecimal('0') : sizeUsd;
|
|
39
|
-
|
|
40
|
-
const q = {
|
|
41
|
-
venue: VENUE,
|
|
42
|
-
chain: CHAIN,
|
|
43
|
-
instrument: 'perp',
|
|
44
|
-
tier: TIER,
|
|
45
|
-
symbolRaw: symbol,
|
|
46
|
-
symbol: bare,
|
|
47
|
-
side,
|
|
48
|
-
requestedSize: requested,
|
|
49
|
-
mark,
|
|
50
|
-
fees: null,
|
|
51
|
-
gasEstimate: null,
|
|
52
|
-
priceImpact: null,
|
|
53
|
-
fundingHourly: funding,
|
|
54
|
-
costAccounted: false,
|
|
55
|
-
capturedAt: getVenues().capturedAt * 1000,
|
|
56
|
-
blockOrSeq: null,
|
|
57
|
-
raw: {
|
|
58
|
-
fixture: 'fixtures/venues.json#venues.arcus',
|
|
59
|
-
oraclePrice: market.oracle,
|
|
60
|
-
vol24h: market.vol24h,
|
|
61
|
-
oi: market.oi,
|
|
62
|
-
fundingAnnPct: market.fundingAnnPct,
|
|
63
|
-
category: market.category,
|
|
64
|
-
isOutsideRth: market.isOutsideRth === true,
|
|
65
|
-
rth: market.rth,
|
|
66
|
-
// Surface the locked dark-window constant so funding.mjs does not re-derive it.
|
|
67
|
-
darkWindowFundingHourly: DARK_WINDOW_FUNDING_HOURLY,
|
|
68
|
-
// Margin fractions are not always in the fixture. Surface when present.
|
|
69
|
-
initialMarginFraction: market.initialMarginFraction ?? null,
|
|
70
|
-
offHoursInitialMarginFraction: market.offHoursInitialMarginFraction ?? null,
|
|
71
|
-
reasonCostUnknown: 'fees, gas, and impact at size not captured for Arcus perps',
|
|
72
|
-
},
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
if (oracle !== null) q.raw.oracleFixed = oracle;
|
|
76
|
-
|
|
77
|
-
return validateQuote(q);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export function quoteAll({ side = 'buy', sizeUsd = null } = {}) {
|
|
81
|
-
return listMarkets()
|
|
82
|
-
.map((symbol) => quote({ symbol, side, sizeUsd }))
|
|
83
|
-
.filter((q) => q !== null);
|
|
84
|
-
}
|