perp-cli 0.14.3 → 0.16.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.ja.md +243 -0
- package/README.ko.md +243 -0
- package/README.md +138 -405
- package/README.zh.md +243 -0
- package/dist/agent-wallet/store.d.ts +3 -2
- package/dist/agent-wallet/store.js +2 -2
- package/dist/api/public/hyperliquid.js +4 -0
- package/dist/api/public/lighter.d.ts +5 -0
- package/dist/api/public/lighter.js +5 -0
- package/dist/api/public/pacifica.js +85 -15
- package/dist/api/public/urls.d.ts +2 -0
- package/dist/api/public/urls.js +3 -0
- package/dist/arb/sizing.js +4 -2
- package/dist/arb/state.d.ts +6 -0
- package/dist/arb/utils.d.ts +1 -2
- package/dist/arb/utils.js +1 -2
- package/dist/balance-by-address.d.ts +39 -0
- package/dist/balance-by-address.js +44 -0
- package/dist/bot/apex/pulse.js +3 -0
- package/dist/bot/apex/radar.js +2 -1
- package/dist/bot/engine.d.ts +10 -1
- package/dist/bot/engine.js +14 -6
- package/dist/bot/indicators.d.ts +7 -0
- package/dist/bot/indicators.js +16 -0
- package/dist/bot/perp-order.d.ts +4 -4
- package/dist/bot/perp-order.js +5 -5
- package/dist/bot/quarantine.d.ts +1 -1
- package/dist/bot/quarantine.js +1 -1
- package/dist/bot/quote-rules.js +1 -1
- package/dist/bot/strategies/apex-strategy.js +3 -2
- package/dist/bot/strategies/engine-mm.js +6 -5
- package/dist/bot/strategies/funding-arb-strategy.js +12 -5
- package/dist/bot/strategies/funding-arb-utils.d.ts +15 -3
- package/dist/bot/strategies/funding-arb-utils.js +53 -20
- package/dist/bot/strategies/funding-auto.js +2 -2
- package/dist/bot/strategies/liquidation-mm.d.ts +1 -0
- package/dist/bot/strategies/liquidation-mm.js +8 -2
- package/dist/bot/strategies/momentum-breakout.d.ts +1 -0
- package/dist/bot/strategies/momentum-breakout.js +11 -3
- package/dist/bot/strategies/spot-perp-arb-strategy.d.ts +1 -1
- package/dist/bot/strategies/spot-perp-arb-strategy.js +6 -4
- package/dist/bot/strategies/spot-perp-executor.d.ts +1 -1
- package/dist/bot/strategies/spot-perp-executor.js +3 -3
- package/dist/bot/strategy-types.d.ts +2 -1
- package/dist/bot/tui/BotDashboard.d.ts +1 -1
- package/dist/bot/tui/BotDashboard.js +1 -1
- package/dist/cache.js +12 -6
- package/dist/cli-program.d.ts +15 -0
- package/dist/cli-program.js +126 -6
- package/dist/commands/account.js +168 -24
- package/dist/commands/agent-import.d.ts +7 -0
- package/dist/commands/agent-import.js +30 -1
- package/dist/commands/agent.d.ts +6 -3
- package/dist/commands/agent.js +160 -12
- package/dist/commands/arb/index.js +23 -81
- package/dist/commands/arb-auto.d.ts +24 -0
- package/dist/commands/arb-auto.js +175 -97
- package/dist/commands/arb.d.ts +20 -0
- package/dist/commands/arb.js +107 -163
- package/dist/commands/backtest.js +23 -21
- package/dist/commands/bot.js +1 -1
- package/dist/commands/builder.js +1 -1
- package/dist/commands/funds.js +113 -3
- package/dist/commands/init.d.ts +1 -1
- package/dist/commands/init.js +27 -7
- package/dist/commands/manage.js +23 -21
- package/dist/commands/market.d.ts +48 -0
- package/dist/commands/market.js +395 -100
- package/dist/commands/options.d.ts +14 -0
- package/dist/commands/options.js +151 -0
- package/dist/commands/pacifica-earn.d.ts +5 -0
- package/dist/commands/pacifica-earn.js +455 -0
- package/dist/commands/pacifica-orders.d.ts +14 -0
- package/dist/commands/pacifica-orders.js +142 -0
- package/dist/commands/portfolio.d.ts +16 -0
- package/dist/commands/portfolio.js +83 -55
- package/dist/commands/rebalance.d.ts +1 -0
- package/dist/commands/rebalance.js +15 -0
- package/dist/commands/risk.d.ts +11 -2
- package/dist/commands/risk.js +39 -44
- package/dist/commands/trade.d.ts +1 -0
- package/dist/commands/trade.js +67 -62
- package/dist/commands/wallet.js +1 -1
- package/dist/config.d.ts +2 -2
- package/dist/config.js +15 -4
- package/dist/constants.js +6 -0
- package/dist/cross-chain-margin.d.ts +3 -1
- package/dist/cross-chain-margin.js +4 -2
- package/dist/dashboard/server.js +3 -3
- package/dist/dashboard/ui.js +9 -6
- package/dist/errors.d.ts +29 -1
- package/dist/errors.js +35 -3
- package/dist/exchanges/address.d.ts +8 -0
- package/dist/exchanges/address.js +47 -0
- package/dist/exchanges/arcus/adapter.d.ts +16 -12
- package/dist/exchanges/arcus/adapter.js +45 -18
- package/dist/exchanges/arcus/agent.d.ts +1 -1
- package/dist/exchanges/arcus/agent.js +1 -1
- package/dist/exchanges/arcus/client.js +1 -1
- package/dist/exchanges/arcus/public.js +3 -2
- package/dist/exchanges/arcus/signing.d.ts +2 -3
- package/dist/exchanges/arcus/signing.js +1 -1
- package/dist/exchanges/arcus/spot-chain.d.ts +1 -1
- package/dist/exchanges/arcus/spot-chain.js +1 -1
- package/dist/exchanges/arcus/spot-router.d.ts +1 -1
- package/dist/exchanges/arcus/spot-router.js +2 -2
- package/dist/exchanges/arcus/spot.d.ts +2 -3
- package/dist/exchanges/arcus/spot.js +2 -3
- package/dist/exchanges/aster-spot.d.ts +3 -3
- package/dist/exchanges/aster-spot.js +6 -9
- package/dist/exchanges/aster-typed-data.d.ts +1 -1
- package/dist/exchanges/aster-typed-data.js +1 -1
- package/dist/exchanges/aster.d.ts +30 -10
- package/dist/exchanges/aster.js +153 -53
- package/dist/exchanges/builder-fee.d.ts +1 -1
- package/dist/exchanges/builder-fee.js +13 -2
- package/dist/exchanges/canonical-symbols.d.ts +8 -2
- package/dist/exchanges/canonical-symbols.js +46 -2
- package/dist/exchanges/capabilities.d.ts +2 -0
- package/dist/exchanges/capabilities.js +2 -1
- package/dist/exchanges/derive/client.d.ts +37 -0
- package/dist/exchanges/derive/client.js +135 -0
- package/dist/exchanges/derive/options.d.ts +73 -0
- package/dist/exchanges/derive/options.js +379 -0
- package/dist/exchanges/extended/adapter.d.ts +96 -0
- package/dist/exchanges/extended/adapter.js +241 -0
- package/dist/exchanges/extended/client.d.ts +38 -0
- package/dist/exchanges/extended/client.js +88 -0
- package/dist/exchanges/extended/public.d.ts +133 -0
- package/dist/exchanges/extended/public.js +436 -0
- package/dist/exchanges/grvt/adapter.d.ts +100 -0
- package/dist/exchanges/grvt/adapter.js +283 -0
- package/dist/exchanges/grvt/client.d.ts +25 -0
- package/dist/exchanges/grvt/client.js +86 -0
- package/dist/exchanges/grvt/public.d.ts +151 -0
- package/dist/exchanges/grvt/public.js +438 -0
- package/dist/exchanges/hyperliquid-outcome.d.ts +2 -0
- package/dist/exchanges/hyperliquid-outcome.js +29 -1
- package/dist/exchanges/hyperliquid-spot.d.ts +9 -1
- package/dist/exchanges/hyperliquid-spot.js +24 -16
- package/dist/exchanges/hyperliquid.d.ts +199 -22
- package/dist/exchanges/hyperliquid.js +550 -202
- package/dist/exchanges/index.d.ts +1 -1
- package/dist/exchanges/index.js +1 -1
- package/dist/exchanges/interface.d.ts +157 -13
- package/dist/exchanges/interface.js +47 -0
- package/dist/exchanges/ioc-outcome.d.ts +1 -1
- package/dist/exchanges/ioc-outcome.js +1 -1
- package/dist/exchanges/legacy-trading-v2.d.ts +2 -2
- package/dist/exchanges/legacy-trading-v2.js +7 -2
- package/dist/exchanges/lighter-public.d.ts +67 -12
- package/dist/exchanges/lighter-public.js +250 -82
- package/dist/exchanges/lighter-signer.d.ts +1 -1
- package/dist/exchanges/lighter-signer.js +1 -1
- package/dist/exchanges/lighter-spot.d.ts +10 -5
- package/dist/exchanges/lighter-spot.js +105 -97
- package/dist/exchanges/lighter.d.ts +80 -21
- package/dist/exchanges/lighter.js +312 -105
- package/dist/exchanges/ondo/adapter.d.ts +38 -13
- package/dist/exchanges/ondo/adapter.js +86 -27
- package/dist/exchanges/ondo/agent.d.ts +1 -1
- package/dist/exchanges/ondo/agent.js +1 -1
- package/dist/exchanges/ondo/client.d.ts +1 -1
- package/dist/exchanges/ondo/client.js +2 -2
- package/dist/exchanges/ondo/public.d.ts +35 -3
- package/dist/exchanges/ondo/public.js +75 -32
- package/dist/exchanges/ondo/spot.d.ts +2 -2
- package/dist/exchanges/ondo/spot.js +3 -3
- package/dist/exchanges/options-interface.d.ts +158 -0
- package/dist/exchanges/options-interface.js +17 -0
- package/dist/exchanges/options-venues.d.ts +12 -0
- package/dist/exchanges/options-venues.js +35 -0
- package/dist/exchanges/outcome-interface.d.ts +4 -0
- package/dist/exchanges/pacifica-atomic.d.ts +211 -0
- package/dist/exchanges/pacifica-atomic.js +440 -0
- package/dist/exchanges/pacifica-decimal.d.ts +10 -0
- package/dist/exchanges/pacifica-decimal.js +51 -0
- package/dist/exchanges/pacifica-presigned.d.ts +53 -0
- package/dist/exchanges/pacifica-presigned.js +141 -0
- package/dist/exchanges/pacifica-print.d.ts +200 -0
- package/dist/exchanges/pacifica-print.js +417 -0
- package/dist/exchanges/pacifica-spot.d.ts +8 -2
- package/dist/exchanges/pacifica-spot.js +26 -18
- package/dist/exchanges/pacifica-typed-data.d.ts +1 -1
- package/dist/exchanges/pacifica-typed-data.js +1 -1
- package/dist/exchanges/pacifica-vaults.d.ts +130 -0
- package/dist/exchanges/pacifica-vaults.js +277 -0
- package/dist/exchanges/pacifica.d.ts +108 -10
- package/dist/exchanges/pacifica.js +428 -171
- package/dist/exchanges/precision.d.ts +3 -1
- package/dist/exchanges/precision.js +9 -2
- package/dist/exchanges/public-balances.d.ts +25 -0
- package/dist/exchanges/public-balances.js +158 -0
- package/dist/exchanges/public-positions.d.ts +43 -0
- package/dist/exchanges/public-positions.js +154 -0
- package/dist/exchanges/qfex/adapter.d.ts +69 -13
- package/dist/exchanges/qfex/adapter.js +102 -17
- package/dist/exchanges/qfex/agent.d.ts +1 -1
- package/dist/exchanges/qfex/agent.js +1 -1
- package/dist/exchanges/qfex/client.d.ts +1 -1
- package/dist/exchanges/qfex/client.js +1 -1
- package/dist/exchanges/qfex/errors.d.ts +1 -1
- package/dist/exchanges/qfex/errors.js +2 -2
- package/dist/exchanges/qfex/public.d.ts +65 -12
- package/dist/exchanges/qfex/public.js +131 -25
- package/dist/exchanges/qfex/signing.d.ts +2 -2
- package/dist/exchanges/qfex/signing.js +4 -5
- package/dist/exchanges/qfex/ws-transport.d.ts +3 -3
- package/dist/exchanges/qfex/ws-transport.js +3 -3
- package/dist/exchanges/rate-limiter.d.ts +1 -1
- package/dist/exchanges/rate-limiter.js +5 -2
- package/dist/exchanges/registry.d.ts +1 -1
- package/dist/exchanges/registry.js +1 -1
- package/dist/exchanges/risex/adapter.d.ts +160 -0
- package/dist/exchanges/risex/adapter.js +842 -0
- package/dist/exchanges/risex/agent.d.ts +154 -0
- package/dist/exchanges/risex/agent.js +384 -0
- package/dist/exchanges/risex/client.d.ts +47 -0
- package/dist/exchanges/risex/client.js +174 -0
- package/dist/exchanges/risex/nonce.d.ts +43 -0
- package/dist/exchanges/risex/nonce.js +212 -0
- package/dist/exchanges/risex/public.d.ts +64 -0
- package/dist/exchanges/risex/public.js +150 -0
- package/dist/exchanges/risex/session.d.ts +71 -0
- package/dist/exchanges/risex/session.js +171 -0
- package/dist/exchanges/risex/typed-data.d.ts +173 -0
- package/dist/exchanges/risex/typed-data.js +240 -0
- package/dist/exchanges/risex/units.d.ts +29 -0
- package/dist/exchanges/risex/units.js +104 -0
- package/dist/exchanges/slippage.d.ts +1 -1
- package/dist/exchanges/slippage.js +1 -1
- package/dist/exchanges/spot-factory.d.ts +3 -3
- package/dist/exchanges/spot-factory.js +8 -8
- package/dist/exchanges/spot-interface.d.ts +5 -5
- package/dist/exchanges/spot-interface.js +2 -2
- package/dist/exchanges/spot-result.d.ts +3 -3
- package/dist/exchanges/spot-result.js +3 -3
- package/dist/exchanges/trading-v2.d.ts +3 -3
- package/dist/exchanges/trading-v2.js +9 -6
- package/dist/exchanges/txflow/adapter.d.ts +61 -0
- package/dist/exchanges/txflow/adapter.js +150 -0
- package/dist/exchanges/txflow/client.d.ts +47 -0
- package/dist/exchanges/txflow/client.js +155 -0
- package/dist/exchanges/txflow/public.d.ts +87 -0
- package/dist/exchanges/txflow/public.js +355 -0
- package/dist/exchanges/unknown-symbol.d.ts +34 -0
- package/dist/exchanges/unknown-symbol.js +56 -0
- package/dist/exchanges/variational/adapter.d.ts +67 -0
- package/dist/exchanges/variational/adapter.js +137 -0
- package/dist/exchanges/variational/client.d.ts +21 -0
- package/dist/exchanges/variational/client.js +66 -0
- package/dist/exchanges/variational/public.d.ts +126 -0
- package/dist/exchanges/variational/public.js +430 -0
- package/dist/exchanges/venue-types.d.ts +52 -10
- package/dist/exchanges/venue-types.js +82 -11
- package/dist/exchanges/venue.d.ts +150 -11
- package/dist/exchanges/venue.js +126 -4
- package/dist/exchanges/venues/arcus.d.ts +1 -2
- package/dist/exchanges/venues/arcus.js +5 -4
- package/dist/exchanges/venues/aster.d.ts +2 -2
- package/dist/exchanges/venues/aster.js +6 -4
- package/dist/exchanges/venues/create-helpers.d.ts +1 -1
- package/dist/exchanges/venues/create-helpers.js +3 -3
- package/dist/exchanges/venues/extended.d.ts +21 -0
- package/dist/exchanges/venues/extended.js +96 -0
- package/dist/exchanges/venues/grvt.d.ts +30 -0
- package/dist/exchanges/venues/grvt.js +98 -0
- package/dist/exchanges/venues/hyperliquid.d.ts +2 -2
- package/dist/exchanges/venues/hyperliquid.js +19 -8
- package/dist/exchanges/venues/index.d.ts +7 -2
- package/dist/exchanges/venues/index.js +8 -2
- package/dist/exchanges/venues/lighter-family.d.ts +7 -9
- package/dist/exchanges/venues/lighter-family.js +9 -11
- package/dist/exchanges/venues/lighter-rh.d.ts +2 -2
- package/dist/exchanges/venues/lighter-rh.js +20 -8
- package/dist/exchanges/venues/lighter.d.ts +1 -1
- package/dist/exchanges/venues/lighter.js +18 -6
- package/dist/exchanges/venues/ondo.d.ts +1 -1
- package/dist/exchanges/venues/ondo.js +5 -3
- package/dist/exchanges/venues/pacifica.d.ts +2 -2
- package/dist/exchanges/venues/pacifica.js +15 -4
- package/dist/exchanges/venues/qfex.d.ts +1 -1
- package/dist/exchanges/venues/qfex.js +4 -2
- package/dist/exchanges/venues/risex-release.d.ts +14 -0
- package/dist/exchanges/venues/risex-release.js +14 -0
- package/dist/exchanges/venues/risex.d.ts +31 -0
- package/dist/exchanges/venues/risex.js +131 -0
- package/dist/exchanges/venues/txflow.d.ts +18 -0
- package/dist/exchanges/venues/txflow.js +77 -0
- package/dist/exchanges/venues/variational.d.ts +21 -0
- package/dist/exchanges/venues/variational.js +85 -0
- package/dist/execution-log.d.ts +1 -1
- package/dist/funding/legacy-public.d.ts +6 -4
- package/dist/funding/legacy-public.js +42 -41
- package/dist/funding/normalize.d.ts +1 -1
- package/dist/funding/normalize.js +1 -1
- package/dist/funding/rates.d.ts +95 -6
- package/dist/funding/rates.js +99 -19
- package/dist/index.js +7 -6
- package/dist/jobs.d.ts +1 -0
- package/dist/jobs.js +25 -1
- package/dist/landing.d.ts +2 -0
- package/dist/landing.js +1 -1
- package/dist/liquidity.d.ts +3 -1
- package/dist/liquidity.js +8 -4
- package/dist/mcp-pacifica-earn.d.ts +9 -0
- package/dist/mcp-pacifica-earn.js +64 -0
- package/dist/mcp-server.js +211 -68
- package/dist/pacifica/client.d.ts +69 -5
- package/dist/pacifica/client.js +181 -8
- package/dist/pacifica/rate-limit.d.ts +144 -0
- package/dist/pacifica/rate-limit.js +267 -0
- package/dist/pacifica/types/order.d.ts +2 -1
- package/dist/plan-executor.js +7 -2
- package/dist/positions-by-address.d.ts +34 -0
- package/dist/positions-by-address.js +46 -0
- package/dist/rebalance.js +1 -1
- package/dist/risk.d.ts +2 -1
- package/dist/risk.js +2 -4
- package/dist/settings.d.ts +32 -3
- package/dist/signer/ows-evm.d.ts +1 -1
- package/dist/signer/ows-evm.js +1 -1
- package/dist/smart-order.d.ts +1 -1
- package/dist/smart-order.js +1 -1
- package/dist/strategies/funding-arb.d.ts +1 -1
- package/dist/strategies/funding-arb.js +36 -63
- package/dist/trade-validator.js +2 -2
- package/dist/utils.d.ts +22 -3
- package/dist/utils.js +11 -3
- package/dist/venue-health.d.ts +40 -0
- package/dist/venue-health.js +75 -0
- package/dist/withdraw-gate.d.ts +1 -1
- package/dist/withdraw-gate.js +1 -1
- package/dist/ws/arcus-market.d.ts +9 -0
- package/dist/ws/arcus-market.js +9 -0
- package/dist/ws/aster-market.d.ts +33 -0
- package/dist/ws/aster-market.js +30 -0
- package/dist/ws/index.d.ts +980 -0
- package/dist/ws/index.js +4460 -0
- package/dist/ws/lighter-market.d.ts +14 -0
- package/dist/ws/lighter-market.js +13 -0
- package/dist/ws/node.d.ts +996 -0
- package/dist/ws/node.js +4554 -0
- package/dist/ws/pacifica-instrument.d.ts +8 -0
- package/dist/ws/pacifica-instrument.js +8 -0
- package/dist/ws/unclassified.d.ts +16 -0
- package/dist/ws/unclassified.js +43 -0
- package/dist/ws-cli/credentials.d.ts +62 -0
- package/dist/ws-cli/credentials.js +126 -0
- package/package.json +71 -10
- package/skills/perp-cli/SKILL.md +153 -36
- package/skills/perp-cli/package.json +15 -2
- package/skills/perp-cli/references/agent-operations.md +22 -12
- package/skills/perp-cli/references/commands.md +143 -17
- package/skills/perp-cli/references/strategies.md +38 -3
- package/skills/perp-cli/references/ws-library.md +523 -0
- package/skills/perp-cli/scripts/arb-monitor.sh +13 -10
- package/skills/perp-cli/scripts/funding-analysis.sh +57 -29
- package/skills/perp-cli/scripts/preflight.sh +27 -19
- package/skills/perp-cli/scripts/spot-perp-scan.sh +58 -38
- package/skills/perp-cli/scripts/validate-arb.sh +56 -39
- package/dist/cli-spec.d.ts +0 -46
- package/dist/cli-spec.js +0 -81
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Arcus Spot Router HTTP client + wire types
|
|
2
|
+
* Arcus Spot Router HTTP client + wire types.
|
|
3
3
|
*
|
|
4
4
|
* Ported from @arcus-xyz/arcus-spot-sdk@1.0.2 (src/client.ts, src/types.ts,
|
|
5
5
|
* src/chains.ts) — Copyright Arcus, licensed under the Apache License 2.0
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Arcus Spot Router HTTP client + wire types
|
|
2
|
+
* Arcus Spot Router HTTP client + wire types.
|
|
3
3
|
*
|
|
4
4
|
* Ported from @arcus-xyz/arcus-spot-sdk@1.0.2 (src/client.ts, src/types.ts,
|
|
5
5
|
* src/chains.ts) — Copyright Arcus, licensed under the Apache License 2.0
|
|
@@ -167,7 +167,7 @@ export class ArcusSpotRouter {
|
|
|
167
167
|
sellAmount: p.sellAmount.toString(),
|
|
168
168
|
taker: p.taker,
|
|
169
169
|
slippageBps: String(p.slippageBps),
|
|
170
|
-
allowWrapped: "false", //
|
|
170
|
+
allowWrapped: "false", // never accept a wrapped placeholder
|
|
171
171
|
});
|
|
172
172
|
}
|
|
173
173
|
/** Single attempt — never retried (a resend could double-execute). Throws RouterHttpError / PerpError. */
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Arcus spot = Stock Token swaps through the Arcus Spot Router
|
|
3
|
-
* §12.4 #5 #7). Not an exchange account: balances are the master wallet's
|
|
2
|
+
* Arcus spot = Stock Token swaps through the Arcus Spot Router. Not an exchange account: balances are the master wallet's
|
|
4
3
|
* ERC-20 balances on Robinhood Chain, and every trade is an exact-input swap
|
|
5
4
|
* settled on-chain (Permit2 `PermitWitnessTransferFrom` + `TakerIntent`).
|
|
6
5
|
*
|
|
@@ -79,7 +78,7 @@ export declare class ArcusSpotAdapter implements SpotAdapter, SpotPricesCapable
|
|
|
79
78
|
* all-in buy price at that notional. The signed intent must then carry
|
|
80
79
|
* minBuyAmount ≥ size × (1 − slippageBps), else nothing is signed.
|
|
81
80
|
* Both sides also require minBuyAmount ≥ quote.buyAmount × (1 − slippageBps).
|
|
82
|
-
* slippageBps = the caller's resolveSlippage() value
|
|
81
|
+
* slippageBps = the caller's resolveSlippage() value; the router
|
|
83
82
|
* takes an integer bound.
|
|
84
83
|
*/
|
|
85
84
|
spotMarketOrder(symbol: string, side: "buy" | "sell", size: string, opts: {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Arcus spot = Stock Token swaps through the Arcus Spot Router
|
|
3
|
-
* §12.4 #5 #7). Not an exchange account: balances are the master wallet's
|
|
2
|
+
* Arcus spot = Stock Token swaps through the Arcus Spot Router. Not an exchange account: balances are the master wallet's
|
|
4
3
|
* ERC-20 balances on Robinhood Chain, and every trade is an exact-input swap
|
|
5
4
|
* settled on-chain (Permit2 `PermitWitnessTransferFrom` + `TakerIntent`).
|
|
6
5
|
*
|
|
@@ -335,7 +334,7 @@ export class ArcusSpotAdapter {
|
|
|
335
334
|
* all-in buy price at that notional. The signed intent must then carry
|
|
336
335
|
* minBuyAmount ≥ size × (1 − slippageBps), else nothing is signed.
|
|
337
336
|
* Both sides also require minBuyAmount ≥ quote.buyAmount × (1 − slippageBps).
|
|
338
|
-
* slippageBps = the caller's resolveSlippage() value
|
|
337
|
+
* slippageBps = the caller's resolveSlippage() value; the router
|
|
339
338
|
* takes an integer bound.
|
|
340
339
|
*/
|
|
341
340
|
async spotMarketOrder(symbol, side, size, opts) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Aster Spot Adapter
|
|
2
|
+
* Aster Spot Adapter.
|
|
3
3
|
*
|
|
4
4
|
* Host `sapi.asterdex.com` (testnet `sapi.asterdex-testnet.com`), paths
|
|
5
5
|
* `/api/v3/*`. Signing is the perp EIP-712 Domain B scheme, reused through
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* Venue rules enforced locally (official spot V3 docs):
|
|
12
12
|
* - TIF GTC | IOC | GTX (post-only). FOK is rejected by the venue (-1115).
|
|
13
13
|
* - LIMIT price must be on PRICE_FILTER.tickSize (never rounded).
|
|
14
|
-
* - Market orders are IOC LIMIT at a protection price
|
|
14
|
+
* - Market orders are IOC LIMIT at a protection price: bookTicker
|
|
15
15
|
* mid ± slippage, aligned toward crossing on tickSize, inside PRICE_FILTER
|
|
16
16
|
* min/max and PERCENT_PRICE (venue native MARKET is never sent).
|
|
17
17
|
* - quantity on LOT_SIZE step, min, max (MARKET_LOT_SIZE only for native MARKET).
|
|
@@ -95,7 +95,7 @@ export declare class AsterSpotAdapter implements SpotAdapter, SpotTransferCapabl
|
|
|
95
95
|
/** Effective minimum notional, or null when no filter applies. */
|
|
96
96
|
private _minNotional;
|
|
97
97
|
private _checkNotional;
|
|
98
|
-
/**
|
|
98
|
+
/** gate only when the active signer is an agent lacking canSpotTrade. */
|
|
99
99
|
private _requireSpotPermission;
|
|
100
100
|
private _signed;
|
|
101
101
|
private _publicGet;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Aster Spot Adapter
|
|
2
|
+
* Aster Spot Adapter.
|
|
3
3
|
*
|
|
4
4
|
* Host `sapi.asterdex.com` (testnet `sapi.asterdex-testnet.com`), paths
|
|
5
5
|
* `/api/v3/*`. Signing is the perp EIP-712 Domain B scheme, reused through
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* Venue rules enforced locally (official spot V3 docs):
|
|
12
12
|
* - TIF GTC | IOC | GTX (post-only). FOK is rejected by the venue (-1115).
|
|
13
13
|
* - LIMIT price must be on PRICE_FILTER.tickSize (never rounded).
|
|
14
|
-
* - Market orders are IOC LIMIT at a protection price
|
|
14
|
+
* - Market orders are IOC LIMIT at a protection price: bookTicker
|
|
15
15
|
* mid ± slippage, aligned toward crossing on tickSize, inside PRICE_FILTER
|
|
16
16
|
* min/max and PERCENT_PRICE (venue native MARKET is never sent).
|
|
17
17
|
* - quantity on LOT_SIZE step, min, max (MARKET_LOT_SIZE only for native MARKET).
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
import { unsupported } from "./trading-v2.js";
|
|
25
25
|
import { asterIocOutcome } from "./aster.js";
|
|
26
26
|
import { PerpError, isTransportFailure, orderNotSent, orderOutcomeUnknown, sendFailure, unknownActionRemediation } from "../errors.js";
|
|
27
|
-
import { alignProtectionPrice, exactUnits, floorSize, requireOnTick, requirePositive, slippagePrice, subDecimal } from "./precision.js";
|
|
27
|
+
import { addDecimal, alignProtectionPrice, exactUnits, floorSize, requireOnTick, requirePositive, slippagePrice, subDecimal } from "./precision.js";
|
|
28
28
|
/** Default quote for a bare base symbol (= venue spot quoteAssets[0]). */
|
|
29
29
|
const DEFAULT_QUOTE = "USDT";
|
|
30
30
|
const SPOT_REMEDIATION = "perp wallet agent rotate aster --can-spot";
|
|
@@ -41,9 +41,6 @@ function cmp(a, b) {
|
|
|
41
41
|
return -1;
|
|
42
42
|
return d === "0" ? 0 : 1;
|
|
43
43
|
}
|
|
44
|
-
function addDecimal(a, b) {
|
|
45
|
-
return subDecimal(a, b.startsWith("-") ? b.slice(1) : `-${b}`);
|
|
46
|
-
}
|
|
47
44
|
function isZero(v) {
|
|
48
45
|
return cmp(v, "0") === 0;
|
|
49
46
|
}
|
|
@@ -150,7 +147,7 @@ export class AsterSpotAdapter {
|
|
|
150
147
|
}
|
|
151
148
|
// ── Trading ──
|
|
152
149
|
async spotMarketOrder(symbol, side, size, opts) {
|
|
153
|
-
//
|
|
150
|
+
// IOC LIMIT at the protection price, never native MARKET (no price cap).
|
|
154
151
|
// Pre-send (market, size, price, min notional, permission): a failure is a definite "not placed".
|
|
155
152
|
let m;
|
|
156
153
|
let qty;
|
|
@@ -246,7 +243,7 @@ export class AsterSpotAdapter {
|
|
|
246
243
|
}
|
|
247
244
|
async spotLimitOrder(symbol, side, price, size, opts) {
|
|
248
245
|
const m = this._resolveTrading(symbol);
|
|
249
|
-
// Aster is a legacy family: limit orders keep the GTC default
|
|
246
|
+
// Aster is a legacy family: limit orders keep the GTC default.
|
|
250
247
|
const tif = this._mapTif(opts?.tif === undefined ? "GTC" : opts.tif);
|
|
251
248
|
const px = requireOnTick(price, m.tickSize);
|
|
252
249
|
const qty = this._sizeFor(m, size, false);
|
|
@@ -517,7 +514,7 @@ export class AsterSpotAdapter {
|
|
|
517
514
|
});
|
|
518
515
|
}
|
|
519
516
|
}
|
|
520
|
-
/**
|
|
517
|
+
/** gate only when the active signer is an agent lacking canSpotTrade. */
|
|
521
518
|
_requireSpotPermission() {
|
|
522
519
|
const meta = this._perp.activeAgentMeta();
|
|
523
520
|
if (meta !== null && meta.permissions?.canSpotTrade !== true) {
|
|
@@ -95,7 +95,7 @@ export interface DelAgentParams {
|
|
|
95
95
|
/**
|
|
96
96
|
* Build the EIP-712 typed-data payload for `DELETE /fapi/v3/agent`.
|
|
97
97
|
*
|
|
98
|
-
* OPEN ITEM (
|
|
98
|
+
* OPEN ITEM (Aster DelAgent struct — mainnet verification): the
|
|
99
99
|
* public Aster V3 docs (asterdex/api-docs, futures api v3 + testnet, checked 2026-10-02)
|
|
100
100
|
* document no agent-delete endpoint or DelAgent struct, and HypurrQuant_FE has no
|
|
101
101
|
* revoke method. This field set mirrors the ApproveAgent terminal fields (AgentAddress,
|
|
@@ -99,7 +99,7 @@ export function buildApproveAgentTypedData(params) {
|
|
|
99
99
|
/**
|
|
100
100
|
* Build the EIP-712 typed-data payload for `DELETE /fapi/v3/agent`.
|
|
101
101
|
*
|
|
102
|
-
* OPEN ITEM (
|
|
102
|
+
* OPEN ITEM (Aster DelAgent struct — mainnet verification): the
|
|
103
103
|
* public Aster V3 docs (asterdex/api-docs, futures api v3 + testnet, checked 2026-10-02)
|
|
104
104
|
* document no agent-delete endpoint or DelAgent struct, and HypurrQuant_FE has no
|
|
105
105
|
* revoke method. This field set mirrors the ApproveAgent terminal fields (AgentAddress,
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
* Docs: https://docs.asterdex.com/product/aster-perpetuals/api/api-documentation
|
|
19
19
|
* Base: https://fapi.asterdex.com
|
|
20
20
|
*/
|
|
21
|
-
import type { ExchangeAdapter, ExchangeMarketInfo, ExchangePosition, ExchangeOrder, ExchangeBalance, ExchangeTrade, ExchangeFundingPayment, ExchangeKline } from "./interface.js";
|
|
21
|
+
import type { ExchangeAdapter, ExchangeMarketInfo, ExchangePosition, ExchangeOrder, ExchangeBalance, ExchangeTrade, ExchangePublicTrade, ExchangeFundingPayment, ExchangeKline, FundingHistoryRow } from "./interface.js";
|
|
22
22
|
import type { ResolvedSlippage } from "./slippage.js";
|
|
23
23
|
import type { EvmSigner } from "../signer/interface.js";
|
|
24
24
|
import type { AgentMeta } from "../settings.js";
|
|
@@ -68,6 +68,11 @@ type ResolvedSigner = {
|
|
|
68
68
|
* that the read refuses (EXCHANGE_ERROR) rather than returning a partial history.
|
|
69
69
|
*/
|
|
70
70
|
export declare const ASTER_INCOME_MAX_PAGES = 60;
|
|
71
|
+
/**
|
|
72
|
+
* Kline intervals verified live 2026-10-19 (/fapi/v3/klines BTCUSDT: each answers bars of that
|
|
73
|
+
* length; "7m" / "2d" → -1120 "Invalid interval."). Anything else is refused before a request.
|
|
74
|
+
*/
|
|
75
|
+
export declare const ASTER_KLINE_INTERVALS: ReadonlySet<string>;
|
|
71
76
|
export declare class AsterAdapter implements ExchangeAdapter {
|
|
72
77
|
readonly name = "aster";
|
|
73
78
|
readonly chain = "bnb";
|
|
@@ -89,6 +94,8 @@ export declare class AsterAdapter implements ExchangeAdapter {
|
|
|
89
94
|
/** API symbol → price filters; null = listed but PRICE_FILTER / PERCENT_PRICE unreadable. */
|
|
90
95
|
private _priceFilters;
|
|
91
96
|
private _priceFiltersLoadedAt;
|
|
97
|
+
/** The in-flight exchangeInfo load shared by concurrent first uses (_ensureDirectory). */
|
|
98
|
+
private _directoryLoad;
|
|
92
99
|
private _accountCache;
|
|
93
100
|
private _positionsCache;
|
|
94
101
|
private _ordersCache;
|
|
@@ -135,7 +142,12 @@ export declare class AsterAdapter implements ExchangeAdapter {
|
|
|
135
142
|
* agent. Throws exactly like signed calls when no signer is usable.
|
|
136
143
|
*/
|
|
137
144
|
activeAgentMeta(): AgentMeta | null;
|
|
138
|
-
/**
|
|
145
|
+
/**
|
|
146
|
+
* CLI symbol → Aster API symbol through the LOADED market directory (exchangeInfo): the exact
|
|
147
|
+
* venue symbol first (BTCUSDT, BTCUSD1, BTCU — a non-USDT market's CLI symbol is its venue
|
|
148
|
+
* symbol, asterCliSymbol), then the USDT market of a base (ETH → ETHUSDT, USD1 → USD1USDT),
|
|
149
|
+
* else SYMBOL_NOT_FOUND — never a guessed suffix. Callers load the directory first (_apiSymbol).
|
|
150
|
+
*/
|
|
139
151
|
private _toApi;
|
|
140
152
|
/** Aster API symbol → CLI symbol (ETHUSDT → ETH) */
|
|
141
153
|
private _fromApi;
|
|
@@ -159,9 +171,21 @@ export declare class AsterAdapter implements ExchangeAdapter {
|
|
|
159
171
|
/** Parse PRICE_FILTER + PERCENT_PRICE for every exchangeInfo symbol into the cache. */
|
|
160
172
|
private _ingestPriceFilters;
|
|
161
173
|
/** PRICE_FILTER / PERCENT_PRICE of an API symbol (exchangeInfo, cached CACHE_TTL). */
|
|
174
|
+
/** exchangeInfo symbols (the market directory) loaded / refreshed per CACHE_TTL. */
|
|
175
|
+
/**
|
|
176
|
+
* exchangeInfo symbols (the market directory), refreshed per CACHE_TTL. Concurrent first uses
|
|
177
|
+
* share ONE in-flight request; a failed load is not cached (the next call retries).
|
|
178
|
+
*/
|
|
179
|
+
private _ensureDirectory;
|
|
180
|
+
/**
|
|
181
|
+
* CLI symbol → Aster API symbol, resolved through the market directory (_toApi), loaded on first
|
|
182
|
+
* use and cached CACHE_TTL — so the answer never depends on what was read before (a cold
|
|
183
|
+
* adapter resolves BTCU, USD1 → USD1USDT, an unknown symbol is SYMBOL_NOT_FOUND).
|
|
184
|
+
*/
|
|
185
|
+
private _apiSymbol;
|
|
162
186
|
private _symbolPriceFilters;
|
|
163
187
|
/**
|
|
164
|
-
* Declared protection-price reference
|
|
188
|
+
* Declared protection-price reference: the venue mark price from
|
|
165
189
|
* GET /fapi/v3/premiumIndex — the same price PERCENT_PRICE is evaluated against.
|
|
166
190
|
* No runtime substitute (no mid / last fallback): unavailable → PRICE_STALE.
|
|
167
191
|
*/
|
|
@@ -190,12 +214,8 @@ export declare class AsterAdapter implements ExchangeAdapter {
|
|
|
190
214
|
bids: [string, string][];
|
|
191
215
|
asks: [string, string][];
|
|
192
216
|
}>;
|
|
193
|
-
getRecentTrades(symbol: string, limit?: number): Promise<
|
|
194
|
-
getFundingHistory(symbol: string, limit?: number): Promise<
|
|
195
|
-
time: number;
|
|
196
|
-
rate: string;
|
|
197
|
-
price: string | null;
|
|
198
|
-
}[]>;
|
|
217
|
+
getRecentTrades(symbol: string, limit?: number): Promise<ExchangePublicTrade[]>;
|
|
218
|
+
getFundingHistory(symbol: string, limit?: number): Promise<FundingHistoryRow[]>;
|
|
199
219
|
/**
|
|
200
220
|
* Candles over [startTime, endTime]. GET /fapi/v3/klines returns at most 1500 bars per request
|
|
201
221
|
* (1501 → -1130), so the range is read in pages that start after the last bar returned — a long
|
|
@@ -272,7 +292,7 @@ export declare class AsterAdapter implements ExchangeAdapter {
|
|
|
272
292
|
/**
|
|
273
293
|
* Native modify (PUT /fapi/v3/order, V3 futures docs "Modify Order"): LIMIT orders
|
|
274
294
|
* only; TIF (incl. GTX) and reduceOnly stay on the order. `size` is the NEW UNFILLED
|
|
275
|
-
* quantity
|
|
295
|
+
* quantity; the venue's `quantity` is the order total, so
|
|
276
296
|
* quantity = size + executedQty (read just before). A fill landing between the read
|
|
277
297
|
* and the PUT can only shrink the remainder, never over-size it. A venue rejection
|
|
278
298
|
* leaves the original order untouched (docs).
|