@raintree-technology/perps 0.1.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/CHANGELOG.md +33 -0
- package/LICENSE +21 -0
- package/README.md +175 -0
- package/dist/adapters/aevo.d.ts +64 -0
- package/dist/adapters/aevo.js +899 -0
- package/dist/adapters/certification.d.ts +33 -0
- package/dist/adapters/certification.js +99 -0
- package/dist/adapters/decibel/order-manager.d.ts +45 -0
- package/dist/adapters/decibel/order-manager.js +140 -0
- package/dist/adapters/decibel/rest-client.d.ts +176 -0
- package/dist/adapters/decibel/rest-client.js +155 -0
- package/dist/adapters/decibel/ws-feed.d.ts +28 -0
- package/dist/adapters/decibel/ws-feed.js +166 -0
- package/dist/adapters/decibel.d.ts +108 -0
- package/dist/adapters/decibel.js +1377 -0
- package/dist/adapters/hyperliquid.d.ts +63 -0
- package/dist/adapters/hyperliquid.js +797 -0
- package/dist/adapters/index.d.ts +11 -0
- package/dist/adapters/index.js +12 -0
- package/dist/adapters/interface.d.ts +310 -0
- package/dist/adapters/interface.js +15 -0
- package/dist/adapters/orderly.d.ts +70 -0
- package/dist/adapters/orderly.js +936 -0
- package/dist/adapters/paradex.d.ts +69 -0
- package/dist/adapters/paradex.js +862 -0
- package/dist/adapters/utils.d.ts +17 -0
- package/dist/adapters/utils.js +122 -0
- package/dist/cli/command-metadata.d.ts +2 -0
- package/dist/cli/command-metadata.js +44 -0
- package/dist/cli/context.d.ts +14 -0
- package/dist/cli/context.js +59 -0
- package/dist/cli/experience.d.ts +48 -0
- package/dist/cli/experience.js +243 -0
- package/dist/cli/ink/app/AppShell.d.ts +12 -0
- package/dist/cli/ink/app/AppShell.js +32 -0
- package/dist/cli/ink/app/MetricStrip.d.ts +6 -0
- package/dist/cli/ink/app/MetricStrip.js +14 -0
- package/dist/cli/ink/app/Panel.d.ts +9 -0
- package/dist/cli/ink/app/Panel.js +7 -0
- package/dist/cli/ink/app/ascii.d.ts +2 -0
- package/dist/cli/ink/app/ascii.js +46 -0
- package/dist/cli/ink/app/index.d.ts +5 -0
- package/dist/cli/ink/app/index.js +4 -0
- package/dist/cli/ink/app/types.d.ts +15 -0
- package/dist/cli/ink/app/types.js +1 -0
- package/dist/cli/ink/components/PnL.d.ts +12 -0
- package/dist/cli/ink/components/PnL.js +23 -0
- package/dist/cli/ink/components/Spinner.d.ts +13 -0
- package/dist/cli/ink/components/Spinner.js +13 -0
- package/dist/cli/ink/components/Table.d.ts +14 -0
- package/dist/cli/ink/components/Table.js +42 -0
- package/dist/cli/ink/components/WatchHeader.d.ts +10 -0
- package/dist/cli/ink/components/WatchHeader.js +18 -0
- package/dist/cli/ink/components/index.d.ts +4 -0
- package/dist/cli/ink/components/index.js +4 -0
- package/dist/cli/ink/index.d.ts +4 -0
- package/dist/cli/ink/index.js +4 -0
- package/dist/cli/ink/render.d.ts +12 -0
- package/dist/cli/ink/render.js +21 -0
- package/dist/cli/ink/theme.d.ts +29 -0
- package/dist/cli/ink/theme.js +40 -0
- package/dist/cli/network-defaults.d.ts +10 -0
- package/dist/cli/network-defaults.js +35 -0
- package/dist/cli/output.d.ts +11 -0
- package/dist/cli/output.js +115 -0
- package/dist/cli/program.d.ts +18 -0
- package/dist/cli/program.js +164 -0
- package/dist/cli/watch.d.ts +19 -0
- package/dist/cli/watch.js +35 -0
- package/dist/client/index.d.ts +55 -0
- package/dist/client/index.js +157 -0
- package/dist/commands/account/add.d.ts +2 -0
- package/dist/commands/account/add.js +510 -0
- package/dist/commands/account/balances-simple.d.ts +5 -0
- package/dist/commands/account/balances-simple.js +63 -0
- package/dist/commands/account/index.d.ts +2 -0
- package/dist/commands/account/index.js +17 -0
- package/dist/commands/account/ls.d.ts +2 -0
- package/dist/commands/account/ls.js +95 -0
- package/dist/commands/account/positions-simple.d.ts +5 -0
- package/dist/commands/account/positions-simple.js +77 -0
- package/dist/commands/account/remove.d.ts +2 -0
- package/dist/commands/account/remove.js +47 -0
- package/dist/commands/account/set-default.d.ts +2 -0
- package/dist/commands/account/set-default.js +47 -0
- package/dist/commands/agent/index.d.ts +2 -0
- package/dist/commands/agent/index.js +126 -0
- package/dist/commands/arb/alert.d.ts +6 -0
- package/dist/commands/arb/alert.js +88 -0
- package/dist/commands/arb/basis-execute.d.ts +6 -0
- package/dist/commands/arb/basis-execute.js +332 -0
- package/dist/commands/arb/basis.d.ts +6 -0
- package/dist/commands/arb/basis.js +181 -0
- package/dist/commands/arb/compare.d.ts +6 -0
- package/dist/commands/arb/compare.js +216 -0
- package/dist/commands/arb/execute.d.ts +6 -0
- package/dist/commands/arb/execute.js +467 -0
- package/dist/commands/arb/funding.d.ts +6 -0
- package/dist/commands/arb/funding.js +201 -0
- package/dist/commands/arb/history.d.ts +6 -0
- package/dist/commands/arb/history.js +153 -0
- package/dist/commands/arb/index.d.ts +6 -0
- package/dist/commands/arb/index.js +29 -0
- package/dist/commands/arb/positions.d.ts +6 -0
- package/dist/commands/arb/positions.js +158 -0
- package/dist/commands/arb/spread.d.ts +6 -0
- package/dist/commands/arb/spread.js +253 -0
- package/dist/commands/arb/track.d.ts +6 -0
- package/dist/commands/arb/track.js +259 -0
- package/dist/commands/asset/book-simple.d.ts +5 -0
- package/dist/commands/asset/book-simple.js +77 -0
- package/dist/commands/asset/index.d.ts +2 -0
- package/dist/commands/asset/index.js +5 -0
- package/dist/commands/completion.d.ts +2 -0
- package/dist/commands/completion.js +161 -0
- package/dist/commands/config/index.d.ts +5 -0
- package/dist/commands/config/index.js +109 -0
- package/dist/commands/data/index.d.ts +31 -0
- package/dist/commands/data/index.js +1466 -0
- package/dist/commands/doctor.d.ts +2 -0
- package/dist/commands/doctor.js +201 -0
- package/dist/commands/exchange/index.d.ts +2 -0
- package/dist/commands/exchange/index.js +107 -0
- package/dist/commands/index.d.ts +2 -0
- package/dist/commands/index.js +48 -0
- package/dist/commands/markets/index.d.ts +2 -0
- package/dist/commands/markets/index.js +5 -0
- package/dist/commands/markets/ls-simple.d.ts +7 -0
- package/dist/commands/markets/ls-simple.js +277 -0
- package/dist/commands/operator/index.d.ts +2 -0
- package/dist/commands/operator/index.js +146 -0
- package/dist/commands/order/cancel-simple.d.ts +5 -0
- package/dist/commands/order/cancel-simple.js +104 -0
- package/dist/commands/order/index.d.ts +2 -0
- package/dist/commands/order/index.js +13 -0
- package/dist/commands/order/limit-simple.d.ts +5 -0
- package/dist/commands/order/limit-simple.js +195 -0
- package/dist/commands/order/market-simple.d.ts +5 -0
- package/dist/commands/order/market-simple.js +190 -0
- package/dist/commands/order/shared.d.ts +17 -0
- package/dist/commands/order/shared.js +51 -0
- package/dist/commands/order/trigger-simple.d.ts +5 -0
- package/dist/commands/order/trigger-simple.js +246 -0
- package/dist/commands/referral/index.d.ts +2 -0
- package/dist/commands/referral/index.js +7 -0
- package/dist/commands/referral/set.d.ts +2 -0
- package/dist/commands/referral/set.js +26 -0
- package/dist/commands/referral/status.d.ts +2 -0
- package/dist/commands/referral/status.js +31 -0
- package/dist/commands/replay/index.d.ts +2 -0
- package/dist/commands/replay/index.js +152 -0
- package/dist/commands/risk/analytics.d.ts +2 -0
- package/dist/commands/risk/analytics.js +64 -0
- package/dist/commands/risk/audit.d.ts +2 -0
- package/dist/commands/risk/audit.js +52 -0
- package/dist/commands/risk/index.d.ts +2 -0
- package/dist/commands/risk/index.js +9 -0
- package/dist/commands/risk/rules.d.ts +2 -0
- package/dist/commands/risk/rules.js +102 -0
- package/dist/commands/server.d.ts +2 -0
- package/dist/commands/server.js +208 -0
- package/dist/commands/setup/index.d.ts +2 -0
- package/dist/commands/setup/index.js +478 -0
- package/dist/commands/signal/index.d.ts +2 -0
- package/dist/commands/signal/index.js +129 -0
- package/dist/commands/state/index.d.ts +2 -0
- package/dist/commands/state/index.js +5 -0
- package/dist/commands/state/show.d.ts +2 -0
- package/dist/commands/state/show.js +105 -0
- package/dist/commands/strategy/index.d.ts +4 -0
- package/dist/commands/strategy/index.js +73 -0
- package/dist/commands/traces/index.d.ts +2 -0
- package/dist/commands/traces/index.js +76 -0
- package/dist/commands/ui/demo.d.ts +9 -0
- package/dist/commands/ui/demo.js +195 -0
- package/dist/commands/ui/index.d.ts +2 -0
- package/dist/commands/ui/index.js +7 -0
- package/dist/commands/ui/terminal.d.ts +2 -0
- package/dist/commands/ui/terminal.js +255 -0
- package/dist/commands/upgrade.d.ts +2 -0
- package/dist/commands/upgrade.js +98 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +4 -0
- package/dist/lib/agent/audit.d.ts +12 -0
- package/dist/lib/agent/audit.js +13 -0
- package/dist/lib/agent/gateway.d.ts +13 -0
- package/dist/lib/agent/gateway.js +598 -0
- package/dist/lib/agent/metrics.d.ts +33 -0
- package/dist/lib/agent/metrics.js +175 -0
- package/dist/lib/agent/signature.d.ts +8 -0
- package/dist/lib/agent/signature.js +28 -0
- package/dist/lib/agent/tools.d.ts +28 -0
- package/dist/lib/agent/tools.js +453 -0
- package/dist/lib/agent/x402.d.ts +23 -0
- package/dist/lib/agent/x402.js +62 -0
- package/dist/lib/api-wallet.d.ts +69 -0
- package/dist/lib/api-wallet.js +101 -0
- package/dist/lib/balance-watcher.d.ts +25 -0
- package/dist/lib/balance-watcher.js +83 -0
- package/dist/lib/book-watcher.d.ts +25 -0
- package/dist/lib/book-watcher.js +48 -0
- package/dist/lib/config.d.ts +88 -0
- package/dist/lib/config.js +427 -0
- package/dist/lib/constants.d.ts +50 -0
- package/dist/lib/constants.js +84 -0
- package/dist/lib/contracts.d.ts +7 -0
- package/dist/lib/contracts.js +8 -0
- package/dist/lib/credential-vault.d.ts +22 -0
- package/dist/lib/credential-vault.js +109 -0
- package/dist/lib/db/accounts.d.ts +83 -0
- package/dist/lib/db/accounts.js +203 -0
- package/dist/lib/db/funding-history.d.ts +69 -0
- package/dist/lib/db/funding-history.js +183 -0
- package/dist/lib/db/index.d.ts +11 -0
- package/dist/lib/db/index.js +272 -0
- package/dist/lib/events/bus.d.ts +10 -0
- package/dist/lib/events/bus.js +17 -0
- package/dist/lib/events/types.d.ts +51 -0
- package/dist/lib/events/types.js +1 -0
- package/dist/lib/exchange.d.ts +30 -0
- package/dist/lib/exchange.js +84 -0
- package/dist/lib/execution/journal.d.ts +25 -0
- package/dist/lib/execution/journal.js +158 -0
- package/dist/lib/execution/safety.d.ts +34 -0
- package/dist/lib/execution/safety.js +197 -0
- package/dist/lib/exit-codes.d.ts +18 -0
- package/dist/lib/exit-codes.js +60 -0
- package/dist/lib/fetch.d.ts +18 -0
- package/dist/lib/fetch.js +66 -0
- package/dist/lib/fs-security.d.ts +10 -0
- package/dist/lib/fs-security.js +26 -0
- package/dist/lib/funding-tracker.d.ts +40 -0
- package/dist/lib/funding-tracker.js +118 -0
- package/dist/lib/logger.d.ts +27 -0
- package/dist/lib/logger.js +82 -0
- package/dist/lib/network-model.d.ts +13 -0
- package/dist/lib/network-model.js +30 -0
- package/dist/lib/onboarding.d.ts +133 -0
- package/dist/lib/onboarding.js +1459 -0
- package/dist/lib/operator-state.d.ts +25 -0
- package/dist/lib/operator-state.js +82 -0
- package/dist/lib/orders-watcher.d.ts +24 -0
- package/dist/lib/orders-watcher.js +74 -0
- package/dist/lib/paths.d.ts +20 -0
- package/dist/lib/paths.js +23 -0
- package/dist/lib/portfolio-watcher.d.ts +33 -0
- package/dist/lib/portfolio-watcher.js +95 -0
- package/dist/lib/position-watcher.d.ts +16 -0
- package/dist/lib/position-watcher.js +44 -0
- package/dist/lib/price-watcher.d.ts +15 -0
- package/dist/lib/price-watcher.js +84 -0
- package/dist/lib/prompts.d.ts +32 -0
- package/dist/lib/prompts.js +105 -0
- package/dist/lib/rate-limit.d.ts +32 -0
- package/dist/lib/rate-limit.js +88 -0
- package/dist/lib/risk/analytics.d.ts +39 -0
- package/dist/lib/risk/analytics.js +98 -0
- package/dist/lib/risk/drawdown.d.ts +18 -0
- package/dist/lib/risk/drawdown.js +49 -0
- package/dist/lib/risk/evaluation-log.d.ts +29 -0
- package/dist/lib/risk/evaluation-log.js +61 -0
- package/dist/lib/risk/index.d.ts +4 -0
- package/dist/lib/risk/index.js +4 -0
- package/dist/lib/risk/limits.d.ts +23 -0
- package/dist/lib/risk/limits.js +27 -0
- package/dist/lib/risk/manager.d.ts +32 -0
- package/dist/lib/risk/manager.js +85 -0
- package/dist/lib/risk/policy-middleware.d.ts +33 -0
- package/dist/lib/risk/policy-middleware.js +267 -0
- package/dist/lib/risk/position-sizer.d.ts +9 -0
- package/dist/lib/risk/position-sizer.js +14 -0
- package/dist/lib/risk/rules-store.d.ts +16 -0
- package/dist/lib/risk/rules-store.js +47 -0
- package/dist/lib/schema.d.ts +254 -0
- package/dist/lib/schema.js +199 -0
- package/dist/lib/secrets.d.ts +3 -0
- package/dist/lib/secrets.js +62 -0
- package/dist/lib/settings.d.ts +24 -0
- package/dist/lib/settings.js +86 -0
- package/dist/lib/signals.d.ts +73 -0
- package/dist/lib/signals.js +136 -0
- package/dist/lib/stable-stringify.d.ts +6 -0
- package/dist/lib/stable-stringify.js +17 -0
- package/dist/lib/state-context.d.ts +44 -0
- package/dist/lib/state-context.js +133 -0
- package/dist/lib/strategy/basis-trade.d.ts +2 -0
- package/dist/lib/strategy/basis-trade.js +24 -0
- package/dist/lib/strategy/funding-arb.d.ts +2 -0
- package/dist/lib/strategy/funding-arb.js +23 -0
- package/dist/lib/strategy/interface.d.ts +23 -0
- package/dist/lib/strategy/interface.js +1 -0
- package/dist/lib/strategy/registry.d.ts +4 -0
- package/dist/lib/strategy/registry.js +10 -0
- package/dist/lib/telemetry.d.ts +25 -0
- package/dist/lib/telemetry.js +101 -0
- package/dist/lib/trace-queries.d.ts +20 -0
- package/dist/lib/trace-queries.js +133 -0
- package/dist/lib/trace.d.ts +1 -0
- package/dist/lib/trace.js +4 -0
- package/dist/lib/trade-reputation.d.ts +6 -0
- package/dist/lib/trade-reputation.js +99 -0
- package/dist/lib/ui-tokens.d.ts +21 -0
- package/dist/lib/ui-tokens.js +26 -0
- package/dist/lib/validate.d.ts +39 -0
- package/dist/lib/validate.js +108 -0
- package/dist/lib/validation.d.ts +9 -0
- package/dist/lib/validation.js +64 -0
- package/dist/server/cache.d.ts +38 -0
- package/dist/server/cache.js +56 -0
- package/dist/server/index.d.ts +2 -0
- package/dist/server/index.js +89 -0
- package/dist/server/ipc.d.ts +18 -0
- package/dist/server/ipc.js +159 -0
- package/dist/server/subscriptions.d.ts +18 -0
- package/dist/server/subscriptions.js +114 -0
- package/package.json +124 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
### Security
|
|
11
|
+
- Replaced `elliptic` and `keccak256` with `@noble/curves` and `@noble/hashes` in Orderly adapter (CVE-2025-14505, CVE-2026-2739)
|
|
12
|
+
- Removed `@types/elliptic` dev dependency
|
|
13
|
+
- Upgraded `pmxtjs` from 2.10.0 to 2.14.1
|
|
14
|
+
- Added dependency auditing section to SECURITY.md
|
|
15
|
+
|
|
16
|
+
## [0.1.0] - 2026-02-23
|
|
17
|
+
|
|
18
|
+
### Added
|
|
19
|
+
- Initial public release
|
|
20
|
+
- Universal CLI for perpetual DEXes (`perps` command)
|
|
21
|
+
- Background data server (`perps-server` command)
|
|
22
|
+
- Exchange adapters: Hyperliquid, Aevo, Orderly, Paradex, Decibel
|
|
23
|
+
- Arbitrage tools: compare, spread, funding, execute, track
|
|
24
|
+
- Order management: market, limit, trigger, cancel
|
|
25
|
+
- Account management with multi-exchange support
|
|
26
|
+
- Interactive onboarding wizard
|
|
27
|
+
- Ink-based terminal UI
|
|
28
|
+
- Agent gateway with x402 payments and EIP-8004 manifests
|
|
29
|
+
- Risk management: limits, drawdown, position sizing
|
|
30
|
+
- Execution journal and safety checks
|
|
31
|
+
|
|
32
|
+
[Unreleased]: https://github.com/raintree-technology/perps/compare/v0.1.0...HEAD
|
|
33
|
+
[0.1.0]: https://github.com/raintree-technology/perps/releases/tag/v0.1.0
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-2026 Zachary Roth and Raintree Technology
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
# perps
|
|
2
|
+
|
|
3
|
+
Universal CLI for perpetual DEXes — by [Raintree Technology](https://raintree.technology).
|
|
4
|
+
|
|
5
|
+
[](https://github.com/raintree-technology/perps/actions/workflows/ci.yml)
|
|
6
|
+
[](https://www.npmjs.com/package/@raintree-technology/perps)
|
|
7
|
+
[](LICENSE)
|
|
8
|
+
[](https://nodejs.org)
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install -g @raintree-technology/perps
|
|
12
|
+
perps --help
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Supported Exchanges
|
|
16
|
+
|
|
17
|
+
| Exchange | Chain | Status | Onboarding |
|
|
18
|
+
|----------|-------|--------|------------|
|
|
19
|
+
| Hyperliquid | Arbitrum L2 | Full | [Guide](docs/exchanges/hyperliquid.md) |
|
|
20
|
+
| Aevo | Ethereum | Full | [Guide](docs/exchanges/aevo.md) |
|
|
21
|
+
| Decibel | Aptos L1 | Full | [Guide](docs/exchanges/decibel.md) |
|
|
22
|
+
| Orderly | Arbitrum / Optimism / Polygon / Base | Full | [Guide](docs/exchanges/orderly.md) |
|
|
23
|
+
| Paradex | StarkNet L2 | Full | [Guide](docs/exchanges/paradex.md) |
|
|
24
|
+
|
|
25
|
+
Plus **100+ CEXes** via CCXT passthrough and **prediction markets** via PMXT (Polymarket, Kalshi, Limitless).
|
|
26
|
+
|
|
27
|
+
Each onboarding guide covers credentials, fees, rate limits, order types, and testnet setup. See the [full exchange docs index](docs/exchanges/README.md).
|
|
28
|
+
|
|
29
|
+
## Quick Start
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
# Interactive setup (testnet by default)
|
|
33
|
+
perps setup wizard
|
|
34
|
+
|
|
35
|
+
# Market data
|
|
36
|
+
perps markets ls
|
|
37
|
+
perps arb funding BTC
|
|
38
|
+
perps arb compare
|
|
39
|
+
|
|
40
|
+
# Trading
|
|
41
|
+
perps order market buy BTC 0.01 --idempotency-key demo-001
|
|
42
|
+
perps order limit sell ETH 0.25 3200 --idempotency-key demo-002
|
|
43
|
+
|
|
44
|
+
# Cross-exchange funding rate arbitrage
|
|
45
|
+
perps arb execute BTC -s 1000 --dry-run --yes
|
|
46
|
+
|
|
47
|
+
# Agent gateway (HTTP API for bots)
|
|
48
|
+
perps agent serve
|
|
49
|
+
curl http://127.0.0.1:4020/capabilities
|
|
50
|
+
|
|
51
|
+
# Raw data from any CCXT exchange
|
|
52
|
+
perps data ccxt binanceusdm fetchTicker --args '["BTC/USDT:USDT"]' --json
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Security Model
|
|
56
|
+
|
|
57
|
+
Credentials are handled with care:
|
|
58
|
+
|
|
59
|
+
- **Testnet by default** — mainnet requires explicit `--mainnet` flag or `*_NETWORK=mainnet` env var
|
|
60
|
+
- **Encrypted at rest** — `perps setup wizard` stores keys in an AES-256-GCM encrypted local vault (`~/.perp/`)
|
|
61
|
+
- **Owner-only permissions** — all credential files are `chmod 600`, directories `chmod 700`
|
|
62
|
+
- **Env vars supported** — standard `HYPERLIQUID_PRIVATE_KEY`, `AEVO_SIGNING_KEY`, etc. for CI/automation
|
|
63
|
+
- **No telemetry, no phoning home** — your keys and trades stay on your machine
|
|
64
|
+
|
|
65
|
+
## Programmatic API
|
|
66
|
+
|
|
67
|
+
Use `perps` as a library in your own TypeScript/Node.js projects:
|
|
68
|
+
|
|
69
|
+
```typescript
|
|
70
|
+
import { HyperliquidAdapter } from "@raintree-technology/perps/adapters"
|
|
71
|
+
|
|
72
|
+
const hl = new HyperliquidAdapter()
|
|
73
|
+
await hl.connect({ testnet: true })
|
|
74
|
+
|
|
75
|
+
const markets = await hl.getMarkets()
|
|
76
|
+
const ticker = await hl.getTicker("BTC-PERP")
|
|
77
|
+
const funding = await hl.getFundingRate("ETH-PERP")
|
|
78
|
+
|
|
79
|
+
await hl.disconnect()
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
All five adapters implement the same `PerpDEXAdapter` interface — swap `HyperliquidAdapter` for `AevoAdapter`, `ParadexAdapter`, `OrderlyAdapter`, or `DecibelAdapter` and the code works the same.
|
|
83
|
+
|
|
84
|
+
## Authentication
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
# Recommended: interactive wizard
|
|
88
|
+
perps setup wizard
|
|
89
|
+
|
|
90
|
+
# Or set env vars directly
|
|
91
|
+
export HYPERLIQUID_PRIVATE_KEY="0x..."
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
<details>
|
|
95
|
+
<summary>Environment variables by exchange</summary>
|
|
96
|
+
|
|
97
|
+
| Exchange | Reads | Trading |
|
|
98
|
+
|----------|-------|---------|
|
|
99
|
+
| Hyperliquid | `HYPERLIQUID_WALLET_ADDRESS` | `HYPERLIQUID_PRIVATE_KEY` |
|
|
100
|
+
| Aevo | `AEVO_API_KEY` + `AEVO_API_SECRET` | + `AEVO_SIGNING_KEY` |
|
|
101
|
+
| Decibel | `DECIBEL_API_WALLET_ADDRESS` + `DECIBEL_API_BEARER_TOKEN` | + `DECIBEL_API_WALLET_PRIVATE_KEY` |
|
|
102
|
+
| Orderly | `ORDERLY_ACCOUNT_ID` + `ORDERLY_KEY` + `ORDERLY_SECRET` | + `ORDERLY_TRADING_SECRET` |
|
|
103
|
+
| Paradex | `PARADEX_ACCOUNT_ADDRESS` + `PARADEX_PRIVATE_KEY` | same |
|
|
104
|
+
|
|
105
|
+
Network overrides: `HYPERLIQUID_NETWORK`, `AEVO_NETWORK`, `DECIBEL_NETWORK`, `ORDERLY_NETWORK`, `PARADEX_NETWORK` (values: `testnet` or `mainnet`).
|
|
106
|
+
|
|
107
|
+
</details>
|
|
108
|
+
|
|
109
|
+
## Capabilities
|
|
110
|
+
|
|
111
|
+
See **[CAPABILITIES.md](CAPABILITIES.md)** for the full reference — every command, option, exchange feature matrix, adapter interface, and programmatic API.
|
|
112
|
+
|
|
113
|
+
## Command Surface
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
perps markets ls --help # List markets with funding, OI, volume
|
|
117
|
+
perps order --help # Place orders (market, limit, stop, take-profit)
|
|
118
|
+
perps arb --help # Cross-exchange arbitrage
|
|
119
|
+
perps account --help # Portfolio (positions, balances)
|
|
120
|
+
perps agent --help # HTTP agent gateway
|
|
121
|
+
perps risk --help # Risk management (rules, audit, analytics)
|
|
122
|
+
perps operator --help # Kill switch (halt, resume)
|
|
123
|
+
perps strategy --help # Strategy registry
|
|
124
|
+
perps signal --help # Trade signals
|
|
125
|
+
perps replay --help # Execution replay
|
|
126
|
+
perps data --help # Raw exchange data (ccxt, pmxt)
|
|
127
|
+
perps setup --help # Onboarding wizard
|
|
128
|
+
perps config --help # Settings (show, get, set)
|
|
129
|
+
perps doctor # Health check
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Every command supports `--json` for machine-readable output and `--help` for usage details.
|
|
133
|
+
|
|
134
|
+
## Exit Codes
|
|
135
|
+
|
|
136
|
+
| Code | Meaning |
|
|
137
|
+
|------|---------|
|
|
138
|
+
| 0 | Success |
|
|
139
|
+
| 2 | Validation error |
|
|
140
|
+
| 4 | Auth/credential error |
|
|
141
|
+
| 5 | Data unavailable |
|
|
142
|
+
| 6 | No opportunity |
|
|
143
|
+
| 7 | Execution error |
|
|
144
|
+
| 8 | Partial execution |
|
|
145
|
+
| 9 | User cancelled |
|
|
146
|
+
|
|
147
|
+
## Development
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
git clone https://github.com/raintree-technology/perps.git
|
|
151
|
+
cd perps
|
|
152
|
+
corepack enable && pnpm install
|
|
153
|
+
|
|
154
|
+
pnpm dev --help # Run from source
|
|
155
|
+
pnpm test # Run tests (1600+)
|
|
156
|
+
pnpm build # Compile to dist/
|
|
157
|
+
pnpm smoke # Local health checks
|
|
158
|
+
pnpm smoke:network # + live network reachability
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## Contributing
|
|
162
|
+
|
|
163
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines. Please read our [Code of Conduct](CODE_OF_CONDUCT.md). For vulnerability reports, see [SECURITY.md](SECURITY.md).
|
|
164
|
+
|
|
165
|
+
## Author
|
|
166
|
+
|
|
167
|
+
[Raintree Technology](https://raintree.technology) ([@raintree_tech](https://x.com/raintree_tech)) — created by [Zachary Roth](https://zacharyr0th.com) ([@zacharyr0th](https://x.com/zacharyr0th))
|
|
168
|
+
|
|
169
|
+
## License
|
|
170
|
+
|
|
171
|
+
[MIT](LICENSE) | [Changelog](CHANGELOG.md)
|
|
172
|
+
|
|
173
|
+
## Disclaimer
|
|
174
|
+
|
|
175
|
+
This software is provided as-is. Trading perpetual contracts involves substantial risk of loss and is not suitable for every investor. The authors and contributors are not responsible for any financial losses, missed trades, or other damages arising from the use of this software. You are solely responsible for your own trading decisions and for securing your own private keys. Use at your own risk.
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Aevo Adapter
|
|
3
|
+
* Implements PerpDEXAdapter interface for Aevo DEX
|
|
4
|
+
*
|
|
5
|
+
* API Docs: https://docs.aevo.xyz/
|
|
6
|
+
* Base URL: https://api.aevo.xyz
|
|
7
|
+
*/
|
|
8
|
+
import { type PerpDEXAdapter, type ExchangeInfo, type ExchangeConfig, type Market, type Ticker, type OrderBook, type FundingRate, type Position, type Order, type Balance, type Trade, type OrderParams, type CancelOrderParams, type ModifyOrderParams, type FundingPayment, type PublicTrade, type SubscriptionCallbacks, type Unsubscribe, type MarginType, type MMPConfig, type MMPStatus, type TWAPParams, type TWAPStatus } from "./interface.js";
|
|
9
|
+
export declare class AevoAdapter implements PerpDEXAdapter {
|
|
10
|
+
readonly info: ExchangeInfo;
|
|
11
|
+
private baseUrl;
|
|
12
|
+
private config;
|
|
13
|
+
private connected;
|
|
14
|
+
private marketsCache;
|
|
15
|
+
private readonly subscriptionTimers;
|
|
16
|
+
connect(config: ExchangeConfig): Promise<void>;
|
|
17
|
+
disconnect(): Promise<void>;
|
|
18
|
+
isConnected(): boolean;
|
|
19
|
+
private fetch;
|
|
20
|
+
private fetchAuthed;
|
|
21
|
+
private getAuthHeaders;
|
|
22
|
+
private fetchMarkets;
|
|
23
|
+
getMarkets(): Promise<Market[]>;
|
|
24
|
+
getMarket(symbol: string): Promise<Market | null>;
|
|
25
|
+
getTicker(market: string): Promise<Ticker>;
|
|
26
|
+
getTickers(): Promise<Ticker[]>;
|
|
27
|
+
getOrderBook(market: string, depth?: number): Promise<OrderBook>;
|
|
28
|
+
getFundingRate(market: string): Promise<FundingRate>;
|
|
29
|
+
getFundingRates(): Promise<FundingRate[]>;
|
|
30
|
+
getPositions(): Promise<Position[]>;
|
|
31
|
+
getPosition(market: string): Promise<Position | null>;
|
|
32
|
+
getOrders(market?: string): Promise<Order[]>;
|
|
33
|
+
getOrder(orderId: string): Promise<Order | null>;
|
|
34
|
+
getBalances(): Promise<Balance[]>;
|
|
35
|
+
getTrades(market?: string, limit?: number): Promise<Trade[]>;
|
|
36
|
+
placeOrder(params: OrderParams): Promise<Order>;
|
|
37
|
+
cancelOrder(params: CancelOrderParams): Promise<boolean>;
|
|
38
|
+
cancelAllOrders(market?: string): Promise<number>;
|
|
39
|
+
setLeverage(market: string, leverage: number): Promise<void>;
|
|
40
|
+
setMarginType(market: string, type: MarginType): Promise<void>;
|
|
41
|
+
modifyOrder(params: ModifyOrderParams): Promise<Order>;
|
|
42
|
+
batchPlaceOrders(paramsList: OrderParams[]): Promise<Order[]>;
|
|
43
|
+
batchCancelOrders(paramsList: CancelOrderParams[]): Promise<boolean[]>;
|
|
44
|
+
cancelAllAfter(_timeoutMs: number): Promise<void>;
|
|
45
|
+
getOrderHistory(market?: string, limit?: number): Promise<Order[]>;
|
|
46
|
+
getFundingHistory(market?: string, limit?: number): Promise<FundingPayment[]>;
|
|
47
|
+
getPublicTrades(market: string, limit?: number): Promise<PublicTrade[]>;
|
|
48
|
+
setMMP(config: MMPConfig): Promise<void>;
|
|
49
|
+
getMMP(market: string): Promise<MMPStatus>;
|
|
50
|
+
resetMMP(market: string): Promise<void>;
|
|
51
|
+
placeTWAP(_params: TWAPParams): Promise<TWAPStatus>;
|
|
52
|
+
cancelTWAP(_twapId: string): Promise<boolean>;
|
|
53
|
+
getTWAPStatus(_twapId: string): Promise<TWAPStatus | null>;
|
|
54
|
+
updateIsolatedMargin(_market: string, _amount: string): Promise<void>;
|
|
55
|
+
subscribe(callbacks: SubscriptionCallbacks): Unsubscribe;
|
|
56
|
+
subscribeOrderBook(market: string, callback: (book: OrderBook) => void): Unsubscribe;
|
|
57
|
+
subscribeTicker(market: string, callback: (ticker: Ticker) => void): Unsubscribe;
|
|
58
|
+
private normalizeSymbol;
|
|
59
|
+
private ensureAuth;
|
|
60
|
+
private resolveLimitPrice;
|
|
61
|
+
private toOrder;
|
|
62
|
+
private sizeToContracts;
|
|
63
|
+
}
|
|
64
|
+
export default AevoAdapter;
|