@orbs-network/spot 2.11.2 β†’ 2.12.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.
Files changed (3) hide show
  1. package/README.md +22 -262
  2. package/config.json +43 -4
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,276 +1,36 @@
1
- # Spot β€” Limit, TWAP, Stop-Loss, Take-Profit Non-Custodial Decentralized DeFi Protocol
1
+ # Spot
2
2
 
3
- **Agent-ready decentralized DeFi protocol for non-custodial advanced order types on EVM chains.**
3
+ Non-custodial market, limit, TWAP, stop-loss, take-profit, and delayed-start orders on EVM chains.
4
4
 
5
- Spot provides non-custodial market, limit, TWAP, stop-loss, take-profit, and delayed-start orders on EVM chains, backed by immutable onchain contracts.
5
+ ## πŸ’± Order Types
6
6
 
7
- **πŸ”’ Security Audit Reports:** [Initial AstraSec audit](./Audit-AstraSec.pdf) and [updated AstraSec audit](./Audit2-AstraSec.pdf)
7
+ 1. **Market**: Swap at the current price within your slippage limit.
8
+ 2. **Limit**: Swap only when your minimum output can be met.
9
+ 3. **TWAP**: Split a total amount into equal chunks at regular intervals.
10
+ 4. **Stop-loss**: Trigger a swap when the price falls below your threshold.
11
+ 5. **Take-profit**: Trigger a swap when the price rises above your threshold.
12
+ 6. **Delayed start**: Schedule when your order becomes eligible.
8
13
 
9
- ## Why Spot
14
+ ## βš™οΈ How It Works
10
15
 
11
- 1. βœ… **Non-custodial**: RePermit binds spend authorization to exact order hashes instead of handing custody to the protocol.
12
- 2. πŸ”’ **Oracle-protected**: Trigger checks, slippage caps, freshness windows, and deadlines constrain execution.
13
- 3. πŸ›‘οΈ **Battle-tested**: Contracts are audited and covered by an extensive Foundry test suite.
14
- 4. πŸ—οΈ **Production-ready**: Spot is built for multi-chain deployment with repo-shipped config, ABIs, skill files, and a hosted MCP endpoint.
16
+ Choose your tokens, total amount, price conditions, and expiration. For recurring orders, set the chunk size and interval. Sign the order; executors fill it when its conditions are met.
15
17
 
16
- ## Supported Order Types
18
+ Your funds remain in your wallet until execution. Price checks, slippage limits, and expiration constrain each fill.
17
19
 
18
- 1. Market swaps
19
- 2. Limit orders
20
- 3. TWAP orders
21
- 4. Stop-loss orders
22
- 5. Take-profit orders
23
- 6. Delayed-start orders
24
- 7. Chunked recurring execution
20
+ ## 🌐 Supported Chains
25
21
 
26
- ## Supported Chains
22
+ See [supported chains](./skill/SKILL.md#supported-chains) and [contract addresses](./config.json).
27
23
 
28
- Spot supports explicitly included chains with all six core contracts and at least one deployed shared (`*`) or chain-specific adapter. See [`config.json`](./config.json) for the supported chain configurations and [`skill/SKILL.md`](./skill/SKILL.md#supported-chains) for the matching chain list. Existing deployments do not add a chain to the supported set; Mantle and Manta remain excluded.
24
+ ## πŸš€ Get Started
29
25
 
30
- Run `t` before local order QA. `npm test` includes `npm run test:e2e`, a read-only live dependency check using `chain`, `cast`, `jq`, `curl`, and GNU `parallel`. It fetches the current production [offchain oracle config](https://github.com/orbs-network/offchain-oracle/blob/master/config.json) once per run and reports the union of Spot config, skill chains, and oracle chains in a coverage table. `npm run test:e2e -- 1` scopes the report to Ethereum.
26
+ 1. **AI agents**: Use the [Spot Advanced Swap Orders skill](./skill/SKILL.md), available on [Clawhub](https://clawhub.ai/eranp-orbs/spot-advanced-swap-orders), or connect to the [hosted MCP endpoint](https://agents-sink.orbs.network/mcp).
27
+ 2. **Integrators**: Follow the [API, TypeScript, React, and swap-routing guides](https://spot-integration-docs.vercel.app/).
28
+ 3. **Support**: [Report a bug or request a feature](https://github.com/orbs-network/spot/issues).
31
29
 
32
- The E2E table shows core deployment, deployed/known adapter counts, support status, and oracle health separately. Every explicit Spot chain requires all six core contracts and at least one deployed adapter; named solver counts are informational. Shared integrations whose adapters are undeployed are omitted from that chain's active integrations, while missing chain-specific integrations remain failures. Configured chains missing a skill listing also fail. Unlisted chains remain unsupported even when contracts and adapters are deployed.
30
+ ## πŸ”’ Security
33
31
 
34
- Oracle checks require a deployed USD oracle and aggregator, deployed and registered oracle adapters, the correct binding, and positive USD quotes for native, wrapped native, and configured oracle connectors. Missing config, contracts, quotes, or RPC access fail with visible details for supported chains. Oracle-only chains show deployment discovery and configured oracle coverage. Discovery covers the selected config/skill/oracle chain set, not every EVM network. `SPOT_ORACLE_CONFIG_JSON` can supply an explicit snapshot for diagnostics; normal tests fetch production directly.
32
+ Spot's contracts were audited by AstraSec: [initial audit](./Audit-AstraSec.pdf) and [updated audit](./Audit2-AstraSec.pdf).
35
33
 
36
- Live relay and taker coverage is reviewed manually by the AI during `qa`, following `AGENTS.md`. Normal tests do not query relay/taker health or require their integration coverage. The QA review checks relay health, listeners, registered adapters, active taker polling and loops, and chain/refinery/solver metadata, accounting for deployed versions and SAFO/backup/L3 assignments. Private taker health URLs come from `SPOT_TAKER_HEALTH_URLS`; missing configuration skips that check. Observed health is distinct from successful order execution.
34
+ ## πŸ“„ License
37
35
 
38
- Notion checking is a manual AI review during `qa`, following the repository’s `AGENTS.md`; normal tests do not access Notion or check board readiness. The AI uses `NOTION_API_KEY` from the private environment to review SPOT contracts, oracle, taker, and relay readiness, chain membership, and solver labels. It accounts for runtime versions, taker assignments, user-confirmed readiness, and integrations already marked Dead, then reports only a concise grouped fix list. Board updates require user authorization and are verified afterward.
39
-
40
- Orvex uses Spot's universal integration on Robinhood Chain (`4663`), with execution routing selected at fill time. No other Orvex mainnet deployment is listed in its [official contract directory](https://docs.orvex.fi/developer-resources/contract-addresses).
41
-
42
- Robinhood's solver adapters cover Kyber, OpenOcean, LI.FI (`LiFi`), 0x (`ZeroX`), and OKX. Orders use the universal integration to select a solver adapter at fill time. 0x uses `DefaultDexAdapter` with its [AllowanceHolder](https://github.com/0xProject/0x-settler/blob/master/chain_config.json); OKX uses `ApprovalDexAdapter` with separate [router and approval contracts](https://web3.okx.com/onchainos/dev-docs/trade/dex-smart-contract).
43
-
44
- Deploy the Robinhood solver adapters with the chain-managed signer:
45
-
46
- ```sh
47
- chain robinhood
48
- dev true
49
- ADAPTER_TYPE=default ROUTER=0x0000000000001fF3684f28c67538d4D072C22734 script/deploy --adapter ZeroX --broadcast --sender "$ETH_FROM"
50
- ADAPTER_TYPE=approval ROUTER=0x6e2a35a7ad683cf634d91492d73bb7ff774c6919 SPENDER=0x42170295F1173c9e5874ea9d00c6d137E1a4f53d script/deploy --adapter OKX --broadcast --sender "$ETH_FROM"
51
- npm run build
52
- ```
53
-
54
- Omit `--broadcast` to simulate. Successful broadcasts write the adapter addresses to `config.json`; configured adapters are skipped on subsequent runs.
55
-
56
- ## How It Works
57
-
58
- Each Spot order combines timing, sizing, trigger, and settlement rules in a single signed payload.
59
-
60
- 1. `input.amount` is the per-fill chunk size.
61
- 2. `input.maxAmount` is the total budget across fills.
62
- 3. `output.limit` is the minimum acceptable output per chunk.
63
- 4. `output.triggerLower` and `output.triggerUpper` define stop-loss and take-profit style trigger bands.
64
- 5. `epoch` controls recurrence: `0` for one-shot, `> 0` for recurring fills.
65
- 6. `start` and `deadline` define the execution window.
66
-
67
- `output.limit`, `triggerLower`, and `triggerUpper` are encoded as per-chunk output-token amounts in the output token's decimals.
68
-
69
- A typical order lifecycle is:
70
-
71
- 1. **Order creation**: The user signs one EIP-712 order with chunk size, total amount, limits, slippage tolerance, epoch interval, and deadline.
72
- 2. **Price attestation**: The cosigner signs both trigger-time and current market price data.
73
- 3. **Execution trigger**: A whitelisted executor calls `Executor.execute()` when the order is eligible.
74
- 4. **Validation**: `OrderReactor` validates signatures, checks `start`, enforces epoch windows, verifies timestamps, and applies slippage protection.
75
- 5. **Settlement**: The reactor transfers input tokens, validates the fill result, and enforces minimum output.
76
- 6. **Distribution**: Surplus output is distributed between the swapper and optional referrer according to configured shares.
77
-
78
- ## Security
79
-
80
- Spot's contracts were professionally audited by AstraSec. See the **[initial security audit report](./Audit-AstraSec.pdf)** and **[updated security audit report](./Audit2-AstraSec.pdf)**.
81
- Spot is also oracle-protected: execution depends on cosigned trigger and market price data, freshness windows, and slippage checks.
82
-
83
- ### Access Controls
84
-
85
- 1. **WM Allowlist**: WM-gated entrypoints restrict privileged admin operations, and order execution honors exclusivity rules.
86
- 2. **Two-Step Ownership**: `WM` uses OpenZeppelin `Ownable2Step` for secure ownership transfers.
87
- 3. **Executor Binding**: Orders specify an authorized executor; only that executor can fill the order.
88
- 4. **Non-Exclusive Fillers**: `exclusivity = 0` locks fills to the designated executor, while values above zero allow third-party fillers that satisfy the higher minimum output requirement.
89
-
90
- ### Validation Layers
91
-
92
- 1. **Order Validation**: `OrderValidationLib.validate()` checks all order fields for validity.
93
- 2. **Signature Verification**: RePermit validates EIP-712 signatures and witness data binding.
94
- 3. **Oracle Price Attestation**: The cosigner supplies trigger-time and current market price data used to gate execution.
95
- 4. **Epoch Enforcement**: `EpochLib.update()` prevents early or duplicate fills within time windows.
96
- 5. **Slippage Protection**: A maximum 50% slippage cap is enforced in `src/Constants.sol`.
97
- 6. **Freshness Windows**: Current cosignatures expire after configurable time periods.
98
- 7. **Trigger Timestamp Rules**: Trigger timestamps must be after `start` and no later than the current timestamp.
99
-
100
- ### Economic Security
101
-
102
- 1. **Witness-Bound Spending**: RePermit ties allowances to exact order hashes, preventing signature reuse.
103
- 2. **Surplus Distribution**: Excess tokens are distributed between the swapper and referrer.
104
- 3. **Exact Allowances**: `SafeERC20.forceApprove()` avoids allowance accumulation attacks.
105
-
106
- ### Operational Security
107
-
108
- 1. **Reentrancy Protection**: `OrderReactor` uses `ReentrancyGuard`; `Executor` and `Refinery` rely on WM gating and internal invariants.
109
- 2. **Safe Token Handling**: The system supports USDT-like tokens and ETH handling semantics.
110
- 3. **Emergency Pause**: `OrderReactor` can be paused by WM-allowed addresses.
111
-
112
- ## Examples
113
-
114
- Plain-English examples:
115
-
116
- 1. Sell a fixed amount once, but only if the execution meets a minimum output.
117
- 2. Split a larger budget into equal chunks and execute one chunk every hour as a TWAP.
118
- 3. Move into a safer asset if price falls below a stop-loss threshold, or exit on strength if a take-profit threshold is reached.
119
-
120
- ### Single-Shot Limit Order
121
-
122
- ```solidity
123
- Order memory order = Order({
124
- // ... standard fields
125
- epoch: 0, // Single execution
126
- input: Input({
127
- amount: 1000e6, // Exact amount to spend
128
- maxAmount: 1000e6 // Same as amount
129
- }),
130
- output: Output({
131
- limit: 950 ether, // Minimum acceptable output
132
- triggerLower: 0, // No lower trigger gate
133
- triggerUpper: 0 // No upper trigger gate
134
- })
135
- });
136
- ```
137
-
138
- ### TWAP Order
139
-
140
- ```solidity
141
- Order memory order = Order({
142
- // ... standard fields
143
- epoch: 3600, // Execute every hour
144
- input: Input({
145
- amount: 100e6, // 100 USDC per chunk
146
- maxAmount: 1000e6 // 1000 USDC total budget
147
- }),
148
- output: Output({
149
- limit: 95 ether, // Minimum per chunk
150
- triggerLower: 0,
151
- triggerUpper: 0
152
- })
153
- });
154
- ```
155
-
156
- ### Stop-Loss / Take-Profit Order
157
-
158
- ```solidity
159
- Order memory order = Order({
160
- // ... standard fields
161
- epoch: 0, // Single execution
162
- start: block.timestamp, // Order becomes active immediately
163
- output: Output({
164
- limit: 900 ether, // Minimum per chunk output when executing
165
- triggerLower: 950 ether, // Stop-loss boundary per chunk
166
- triggerUpper: 1200 ether // Take-profit boundary per chunk
167
- })
168
- });
169
- ```
170
-
171
- ## Technical Overview
172
-
173
- ### Core Components
174
-
175
- 1. 🧠 **OrderReactor** (`src/OrderReactor.sol`): Validates orders, checks epoch constraints, computes minimum output from cosigned prices, settles via inlined implementation with reentrancy protection, and supports emergency pause via the WM allowlist.
176
- 2. ✍️ **RePermit** (`src/RePermit.sol`): Permit2-style EIP-712 signatures with witness data that bind allowances to exact order hashes, preventing signature reuse.
177
- 3. 🧾 **Cosigner** (`src/ops/Cosigner.sol`): Attests to trigger-time and current market prices with token validation.
178
- 4. πŸ› οΈ **Executor** (`src/Executor.sol`): Whitelisted fillers that execute eligible orders, enforce minimum output, and distribute surplus.
179
- 5. πŸ” **WM** (`src/ops/WM.sol`): Two-step ownership allowlist manager for executors and admin functions with event emission.
180
- 6. 🏭 **Refinery** (`src/ops/Refinery.sol`): Operations utility for batching multicalls and sweeping token balances by basis points.
181
-
182
- ### Order Structure
183
-
184
- Based on `src/Structs.sol`, each order contains:
185
-
186
- ```solidity
187
- struct Order {
188
- address reactor; // OrderReactor contract address
189
- address executor; // Authorized executor for this order
190
- Exchange exchange; // Exchange parameters, referrer, and data
191
- address swapper; // Order creator/signer
192
- uint256 nonce; // Unique identifier
193
- uint256 start; // Earliest execution timestamp
194
- uint256 deadline; // Expiration timestamp
195
- uint256 chainid; // Chain ID for cross-chain validation
196
- uint32 exclusivity; // BPS-bounded exclusive execution
197
- uint32 epoch; // Seconds between fills (0 = single-use)
198
- uint32 slippage; // BPS applied to cosigned price
199
- uint32 freshness; // Cosignature validity window in seconds
200
- Input input; // Token to spend
201
- Output output; // Token to receive
202
- }
203
-
204
- struct Input {
205
- address token; // Input token address
206
- uint256 amount; // Per-fill chunk amount
207
- uint256 maxAmount; // Total amount across all fills
208
- }
209
-
210
- struct Output {
211
- address token; // Output token address
212
- uint256 limit; // Minimum acceptable output, in output-token decimals, per chunk
213
- uint256 triggerLower; // Lower trigger boundary, in output-token decimals, per chunk
214
- uint256 triggerUpper; // Upper trigger boundary, in output-token decimals, per chunk
215
- address recipient; // Where to send output tokens
216
- }
217
- ```
218
-
219
- ### Limits & Constants
220
-
221
- 1. **Maximum Slippage**: Up to 5,000 BPS, or 50%, inclusive, defined in `src/Constants.sol`.
222
- 2. **Basis Points**: 10,000 BPS equals 100%.
223
- 3. **Freshness Requirements**: Must be greater than 0 seconds and less than epoch duration when `epoch != 0`.
224
- 4. **Epoch Behavior**: `0` means single execution; values above `0` mean recurring execution with that interval.
225
- 5. **Gas Optimization**: Foundry optimizer runs are set to `1,000,000`.
226
-
227
- ### Multi-Chain Deployment
228
-
229
- The protocol is designed for deployment across EVM-compatible chains with deterministic addresses via CREATE2. Configuration is managed through [`config.json`](./config.json).
230
-
231
- ## For Integrators
232
-
233
- This repository ships these integration surfaces:
234
-
235
- 1. Root package `@orbs-network/spot` for config, build orchestration, contracts, and published metadata inputs.
236
- 2. Self-contained skill package [`skill/`](./skill/) published as `@orbs-network/spot-skill`.
237
- 3. Skills-only OpenAI plugin artifact generated with `npm run plugin:build` for marketplace testing and submission.
238
- 4. Hosted MCP endpoint at [`https://agents-sink.orbs.network/mcp`](https://agents-sink.orbs.network/mcp).
239
- 5. Hosted raw files at [`https://orbs-network.github.io/spot/`](https://orbs-network.github.io/spot/) for direct bundle consumption.
240
- 6. Hosted skill distribution on [Clawhub](https://clawhub.ai/eranp-orbs/spot-advanced-swap-orders) for direct skill discovery.
241
-
242
- ## Development
243
-
244
- ```bash
245
- npm install
246
- npm run build
247
- npm test
248
- npm run fmt
249
- ```
250
-
251
- Notes:
252
-
253
- 1. `npm run build` runs `npm run sync` and then `forge build --extra-output-files abi`.
254
- 2. `npm run plugin:build` generates the untracked plugin bundle at `dist/spot/`.
255
- 3. Use `forge test` for the Foundry suite.
256
-
257
- ## Contributing
258
-
259
- 1. Make the smallest coherent change.
260
- 2. Keep `skill/`, hosted MCP references, and any affected published surfaces in sync.
261
- 3. Run `npm run build` after changes.
262
- 4. Run tests when behavior changes or when explicitly requested.
263
-
264
- ## Operational Notes
265
-
266
- 1. **Executor ETH Refunds**: Order execution returns the reactor's ETH balance to the filler. Keep executors funded, and treat unexpected reactor ETH as recoverable by WM-allowed addresses.
267
- 2. **Input Tokens**: Orders spend ERC-20 tokens; wrap native ETH before creating orders.
268
-
269
- ## Support
270
-
271
- 1. **Issues**: Use GitHub Issues for bug reports and feature requests.
272
- 2. **Documentation**: The repo includes inline code documentation and the canonical skill references.
273
-
274
- ## License
275
-
276
- MIT. See [`LICENSE`](./LICENSE).
36
+ [MIT](./LICENSE).
package/config.json CHANGED
@@ -453,10 +453,8 @@
453
453
  },
454
454
  "dex": {
455
455
  "spark": {
456
- "type": "default",
457
- "solver": "SparkDex",
458
- "router": "0x0f3D8a38D4c74afBebc2c42695642f0e3acb15D3",
459
- "adapter": "0x00c7617C471Ef69124464CEc318a3b8CC90aE9A7",
456
+ "type": "universal",
457
+ "adapter": "0x149B199cAdF7A273ed0A4E9Ba50Be0656C3273ab",
460
458
  "fee": "0xaeA8C3e1a129A77686E115b1a46D9aD8405F7D2b"
461
459
  }
462
460
  }
@@ -514,6 +512,11 @@
514
512
  "type": "universal",
515
513
  "adapter": "0xbdf2A1565f0fa68974d703e3F0505e26DBeB604f",
516
514
  "fee": "0xA31F236b8f9cb321258824d33472D7b06d98D648"
515
+ },
516
+ "listed": {
517
+ "type": "universal",
518
+ "adapter": "0x3aBD8B498945794F714da98a39ED3Ce154363147",
519
+ "fee": "0xB1d553E04FB3B3293ea15921DF82869aF49254eD"
517
520
  }
518
521
  }
519
522
  },
@@ -536,5 +539,41 @@
536
539
  "fee": "0x28F6C9dBE21fFc146Af8d5D15c49Cf48F61140Dc"
537
540
  }
538
541
  }
542
+ },
543
+ "9745": {
544
+ "adapter": {
545
+ "Sushi": "0xA985f801ea74321AdcC9Ef88B394858CbA3F71ba",
546
+ "LiFi": "0xB75B57A3e99ADb78A3Be05ba235146F6bea6EA75",
547
+ "Kyber": "0x6bbE14b2205a87FA0EAdE5f0795C7bb16B5347EA",
548
+ "ZeroX": "0x196F49fafBC3A5B6BB3661660892978Ca3679927",
549
+ "OpenOcean": "0x2Be5260d030ff9A6040bA4292326B796ff1a055d",
550
+ "OKX": "0x31461FaE1a11723b1176Adb03A2e74477Df58785"
551
+ },
552
+ "dex": {}
553
+ },
554
+ "5000": {
555
+ "adapter": {
556
+ "Sushi": "0xA985f801ea74321AdcC9Ef88B394858CbA3F71ba",
557
+ "LiFi": "0xe8CD820d5bb34141C4bfd92544Ba9246fc6e8380",
558
+ "ZeroX": "0x9DB46f6359e06b2cBfeFEA61C9171221025f827e",
559
+ "OKX": "0xDD535A91c8166159FA08C4fcd5959c623A472B71"
560
+ },
561
+ "dex": {}
562
+ },
563
+ "57073": {
564
+ "adapter": {
565
+ "LiFi": "0xb9E1a6265dF9a860690A74C1482537061b1E3e28",
566
+ "ZeroX": "0x196F49fafBC3A5B6BB3661660892978Ca3679927",
567
+ "OKX": "0xCdb7F258DE544c4E2a40ed0092A5188B06f09318"
568
+ },
569
+ "dex": {}
570
+ },
571
+ "30": {
572
+ "adapter": {
573
+ "Sushi": "0xA985f801ea74321AdcC9Ef88B394858CbA3F71ba",
574
+ "LiFi": "0xe8CD820d5bb34141C4bfd92544Ba9246fc6e8380",
575
+ "OpenOcean": "0x2Be5260d030ff9A6040bA4292326B796ff1a055d"
576
+ },
577
+ "dex": {}
539
578
  }
540
579
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orbs-network/spot",
3
- "version": "2.11.2",
3
+ "version": "2.12.0",
4
4
  "description": "**A DeFi protocol for noncustodial advanced order types on EVM chains.**",
5
5
  "homepage": "https://orbs-network.github.io/spot/",
6
6
  "bugs": {