@orbs-network/spot-mcp 2.4.0 โ†’ 2.4.1

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 +252 -0
  2. package/package.json +5 -3
  3. package/server.json +21 -0
package/README.md ADDED
@@ -0,0 +1,252 @@
1
+ <!-- Generated by script/sync.mjs from the repository root README.md. Do not edit directly. -->
2
+
3
+ > Auto-synced workspace README for `@orbs-network/spot-mcp`. Repo-relative links are rewritten to canonical GitHub URLs.
4
+ # Spot โ€” Limit, TWAP, Stop-Loss, Take-Profit Non-Custodial Decentralized DeFi Protocol
5
+
6
+ **Agent-ready decentralized DeFi protocol for non-custodial advanced order types on EVM chains.**
7
+
8
+ Spot provides non-custodial market, limit, TWAP, stop-loss, take-profit, and delayed-start orders on EVM chains, backed by immutable onchain contracts.
9
+
10
+ **๐Ÿ”’ [Security Audit Report](https://github.com/orbs-network/spot/blob/master/Audit-AstraSec.pdf)** by AstraSec
11
+
12
+ ## Why Spot
13
+
14
+ 1. โœ… **Non-custodial**: RePermit binds spend authorization to exact order hashes instead of handing custody to the protocol.
15
+ 2. ๐Ÿ”’ **Oracle-protected**: Trigger checks, slippage caps, freshness windows, and deadlines constrain execution.
16
+ 3. ๐Ÿ›ก๏ธ **Battle-tested**: Contracts are audited and covered by an extensive Foundry test suite.
17
+ 4. ๐Ÿ—๏ธ **Production-ready**: Spot is built for multi-chain deployment with repo-shipped config, ABIs, skill files, and MCP metadata.
18
+
19
+ ## Supported Order Types
20
+
21
+ 1. Market swaps
22
+ 2. Limit orders
23
+ 3. TWAP orders
24
+ 4. Stop-loss orders
25
+ 5. Take-profit orders
26
+ 6. Delayed-start orders
27
+ 7. Chunked recurring execution
28
+
29
+ ## Supported Chains
30
+
31
+ Spot supports multiple EVM chains. See [`config.json`](https://github.com/orbs-network/spot/blob/master/config.json) as the canonical source for supported chains and runtime addresses.
32
+
33
+ ## How It Works
34
+
35
+ Each Spot order combines timing, sizing, trigger, and settlement rules in a single signed payload.
36
+
37
+ 1. `input.amount` is the per-fill chunk size.
38
+ 2. `input.maxAmount` is the total budget across fills.
39
+ 3. `output.limit` is the minimum acceptable output per chunk.
40
+ 4. `output.triggerLower` and `output.triggerUpper` define stop-loss and take-profit style trigger bands.
41
+ 5. `epoch` controls recurrence: `0` for one-shot, `> 0` for recurring fills.
42
+ 6. `start` and `deadline` define the execution window.
43
+
44
+ `output.limit`, `triggerLower`, and `triggerUpper` are encoded as per-chunk output-token amounts in the output token's decimals.
45
+
46
+ A typical order lifecycle is:
47
+
48
+ 1. **Order creation**: The user signs one EIP-712 order with chunk size, total amount, limits, slippage tolerance, epoch interval, and deadline.
49
+ 2. **Price attestation**: The cosigner signs both trigger-time and current market price data.
50
+ 3. **Execution trigger**: A whitelisted executor calls `Executor.execute()` when the order is eligible.
51
+ 4. **Validation**: `OrderReactor` validates signatures, checks `start`, enforces epoch windows, verifies timestamps, and applies slippage protection.
52
+ 5. **Settlement**: The reactor transfers input tokens, the executor runs adapter logic via delegatecall, and the system enforces minimum output.
53
+ 6. **Distribution**: Surplus output is distributed between the swapper and optional referrer according to configured shares.
54
+
55
+ ## Security
56
+
57
+ Spot's contracts were professionally audited. See the **[Security Audit Report](https://github.com/orbs-network/spot/blob/master/Audit-AstraSec.pdf)**.
58
+ Spot is also oracle-protected: execution depends on cosigned trigger and market price data, freshness windows, and slippage checks.
59
+
60
+ ### Access Controls
61
+
62
+ 1. **WM Allowlist**: WM-gated entrypoints restrict privileged admin operations, and order execution honors exclusivity rules.
63
+ 2. **Two-Step Ownership**: `WM` uses OpenZeppelin `Ownable2Step` for secure ownership transfers.
64
+ 3. **Executor Binding**: Orders specify an authorized executor; only that executor can fill the order.
65
+ 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.
66
+
67
+ ### Validation Layers
68
+
69
+ 1. **Order Validation**: `OrderValidationLib.validate()` checks all order fields for validity.
70
+ 2. **Signature Verification**: RePermit validates EIP-712 signatures and witness data binding.
71
+ 3. **Oracle Price Attestation**: The cosigner supplies trigger-time and current market price data used to gate execution.
72
+ 4. **Epoch Enforcement**: `EpochLib.update()` prevents early or duplicate fills within time windows.
73
+ 5. **Slippage Protection**: A maximum 50% slippage cap is enforced in `src/Constants.sol`.
74
+ 6. **Freshness Windows**: Current cosignatures expire after configurable time periods.
75
+ 7. **Trigger Timestamp Rules**: Trigger timestamps must be after `start` and no later than the current timestamp.
76
+
77
+ ### Economic Security
78
+
79
+ 1. **Witness-Bound Spending**: RePermit ties allowances to exact order hashes, preventing signature reuse.
80
+ 2. **Surplus Distribution**: Excess tokens are distributed between the swapper and referrer.
81
+ 3. **Exact Allowances**: `SafeERC20.forceApprove()` avoids allowance accumulation attacks.
82
+
83
+ ### Operational Security
84
+
85
+ 1. **Reentrancy Protection**: `OrderReactor` uses `ReentrancyGuard`; `Executor` and `Refinery` rely on WM gating and internal invariants.
86
+ 2. **Safe Token Handling**: The system supports USDT-like tokens and ETH handling semantics.
87
+ 3. **Delegatecall Isolation**: Adapters run in the controlled executor context with validation around settlement.
88
+ 4. **Emergency Pause**: `OrderReactor` can be paused by WM-allowed addresses.
89
+
90
+ ## Examples
91
+
92
+ Plain-English examples:
93
+
94
+ 1. Sell a fixed amount once, but only if the execution meets a minimum output.
95
+ 2. Split a larger budget into equal chunks and execute one chunk every hour as a TWAP.
96
+ 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.
97
+
98
+ ### Single-Shot Limit Order
99
+
100
+ ```solidity
101
+ Order memory order = Order({
102
+ // ... standard fields
103
+ epoch: 0, // Single execution
104
+ input: Input({
105
+ amount: 1000e6, // Exact amount to spend
106
+ maxAmount: 1000e6 // Same as amount
107
+ }),
108
+ output: Output({
109
+ limit: 950 ether, // Minimum acceptable output
110
+ triggerLower: 0, // No lower trigger gate
111
+ triggerUpper: 0 // No upper trigger gate
112
+ })
113
+ });
114
+ ```
115
+
116
+ ### TWAP Order
117
+
118
+ ```solidity
119
+ Order memory order = Order({
120
+ // ... standard fields
121
+ epoch: 3600, // Execute every hour
122
+ input: Input({
123
+ amount: 100e6, // 100 USDC per chunk
124
+ maxAmount: 1000e6 // 1000 USDC total budget
125
+ }),
126
+ output: Output({
127
+ limit: 95 ether, // Minimum per chunk
128
+ triggerLower: 0,
129
+ triggerUpper: 0
130
+ })
131
+ });
132
+ ```
133
+
134
+ ### Stop-Loss / Take-Profit Order
135
+
136
+ ```solidity
137
+ Order memory order = Order({
138
+ // ... standard fields
139
+ epoch: 0, // Single execution
140
+ start: block.timestamp, // Order becomes active immediately
141
+ output: Output({
142
+ limit: 900 ether, // Minimum per chunk output when executing
143
+ triggerLower: 950 ether, // Stop-loss boundary per chunk
144
+ triggerUpper: 1200 ether // Take-profit boundary per chunk
145
+ })
146
+ });
147
+ ```
148
+
149
+ ## Technical Overview
150
+
151
+ ### Core Components
152
+
153
+ 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.
154
+ 2. โœ๏ธ **RePermit** (`src/RePermit.sol`): Permit2-style EIP-712 signatures with witness data that bind allowances to exact order hashes, preventing signature reuse.
155
+ 3. ๐Ÿงพ **Cosigner** (`src/ops/Cosigner.sol`): Attests to trigger-time and current market prices with token validation.
156
+ 4. ๐Ÿ› ๏ธ **Executor** (`src/Executor.sol`): Whitelisted fillers that run venue logic via delegatecall to adapters, enforce minimum output, and distribute surplus.
157
+ 5. ๐Ÿ” **WM** (`src/ops/WM.sol`): Two-step ownership allowlist manager for executors and admin functions with event emission.
158
+ 6. ๐Ÿญ **Refinery** (`src/ops/Refinery.sol`): Operations utility for batching multicalls and sweeping token balances by basis points.
159
+
160
+ ### Order Structure
161
+
162
+ Based on `src/Structs.sol`, each order contains:
163
+
164
+ ```solidity
165
+ struct Order {
166
+ address reactor; // OrderReactor contract address
167
+ address executor; // Authorized executor for this order
168
+ Exchange exchange; // Adapter, referrer, and data
169
+ address swapper; // Order creator/signer
170
+ uint256 nonce; // Unique identifier
171
+ uint256 start; // Earliest execution timestamp
172
+ uint256 deadline; // Expiration timestamp
173
+ uint256 chainid; // Chain ID for cross-chain validation
174
+ uint32 exclusivity; // BPS-bounded exclusive execution
175
+ uint32 epoch; // Seconds between fills (0 = single-use)
176
+ uint32 slippage; // BPS applied to cosigned price
177
+ uint32 freshness; // Cosignature validity window in seconds
178
+ Input input; // Token to spend
179
+ Output output; // Token to receive
180
+ }
181
+
182
+ struct Input {
183
+ address token; // Input token address
184
+ uint256 amount; // Per-fill chunk amount
185
+ uint256 maxAmount; // Total amount across all fills
186
+ }
187
+
188
+ struct Output {
189
+ address token; // Output token address
190
+ uint256 limit; // Minimum acceptable output, in output-token decimals, per chunk
191
+ uint256 triggerLower; // Lower trigger boundary, in output-token decimals, per chunk
192
+ uint256 triggerUpper; // Upper trigger boundary, in output-token decimals, per chunk
193
+ address recipient; // Where to send output tokens
194
+ }
195
+ ```
196
+
197
+ ### Limits & Constants
198
+
199
+ 1. **Maximum Slippage**: Up to 5,000 BPS, or 50%, inclusive, defined in `src/Constants.sol`.
200
+ 2. **Basis Points**: 10,000 BPS equals 100%.
201
+ 3. **Freshness Requirements**: Must be greater than 0 seconds and less than epoch duration when `epoch != 0`.
202
+ 4. **Epoch Behavior**: `0` means single execution; values above `0` mean recurring execution with that interval.
203
+ 5. **Gas Optimization**: Foundry optimizer runs are set to `1,000,000`.
204
+
205
+ ### Multi-Chain Deployment
206
+
207
+ The protocol is designed for deployment across EVM-compatible chains with deterministic addresses via CREATE2. Configuration is managed through [`config.json`](https://github.com/orbs-network/spot/blob/master/config.json).
208
+
209
+ ## For Integrators
210
+
211
+ This repository ships these integration surfaces:
212
+
213
+ 1. Root package `@orbs-network/spot` for config, build orchestration, contracts, and published metadata inputs.
214
+ 2. Self-contained skill package [`skill/`](https://github.com/orbs-network/spot/tree/master/skill) published as `@orbs-network/spot-skill`.
215
+ 3. MCP package [`mcp/`](https://github.com/orbs-network/spot/tree/master/mcp) published as `@orbs-network/spot-mcp` with server name `io.github.orbs-network/spot`.
216
+ 4. Hosted raw files at [`https://orbs-network.github.io/spot/`](https://orbs-network.github.io/spot/) for direct bundle consumption.
217
+
218
+ ## Development
219
+
220
+ ```bash
221
+ npm install
222
+ npm run build
223
+ npm test
224
+ npm run fmt
225
+ ```
226
+
227
+ Notes:
228
+
229
+ 1. `npm run build` runs `npm run sync` and then `forge build --extra-output-files abi`.
230
+ 2. Sync-generated skill metadata, MCP registry metadata, and derived `mcp/package.json` fields should not be hand-maintained; MCP-owned fields there such as pinned runtime dependencies are maintained in `mcp/package.json`.
231
+ 3. Use `forge test` for the Foundry suite.
232
+
233
+ ## Contributing
234
+
235
+ 1. Make the smallest coherent change.
236
+ 2. Keep `skill/`, MCP metadata, and any affected published surfaces in sync.
237
+ 3. Run `npm run build` after changes.
238
+ 4. Run tests when behavior changes or when explicitly requested.
239
+
240
+ ## Operational Notes
241
+
242
+ 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.
243
+ 2. **Input Tokens**: Orders spend ERC-20 tokens; wrap native ETH before creating orders.
244
+
245
+ ## Support
246
+
247
+ 1. **Issues**: Use GitHub Issues for bug reports and feature requests.
248
+ 2. **Documentation**: The repo includes inline code documentation and the canonical skill references.
249
+
250
+ ## License
251
+
252
+ MIT. See [`LICENSE`](https://github.com/orbs-network/spot/blob/master/LICENSE).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orbs-network/spot-mcp",
3
- "version": "2.4.0",
3
+ "version": "2.4.1",
4
4
  "mcpName": "io.github.orbs-network/spot",
5
5
  "description": "MCP adapter for Spot Advanced Swap Orders.",
6
6
  "homepage": "https://orbs-network.github.io/spot/",
@@ -21,11 +21,13 @@
21
21
  "spot-mcp": "./stdio.mjs"
22
22
  },
23
23
  "files": [
24
- "stdio.mjs"
24
+ "*.json",
25
+ "*.md",
26
+ "*.mjs"
25
27
  ],
26
28
  "dependencies": {
27
29
  "@modelcontextprotocol/sdk": "1.27.1",
28
30
  "zod": "4.3.6",
29
- "@orbs-network/spot-skill": "2.4.0"
31
+ "@orbs-network/spot-skill": "2.4.1"
30
32
  }
31
33
  }
package/server.json ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ "$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
3
+ "name": "io.github.orbs-network/spot",
4
+ "title": "Spot Advanced Swap Orders",
5
+ "description": "Use for gasless non-custodial EVM market, limit, TWAP, stop-loss, take-profit, delayed-start orders.",
6
+ "repository": {
7
+ "url": "https://github.com/orbs-network/spot",
8
+ "source": "github"
9
+ },
10
+ "version": "2.4.1",
11
+ "packages": [
12
+ {
13
+ "registryType": "npm",
14
+ "identifier": "@orbs-network/spot-mcp",
15
+ "version": "2.4.1",
16
+ "transport": {
17
+ "type": "stdio"
18
+ }
19
+ }
20
+ ]
21
+ }