@orbs-network/spot 2.1.3 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -10
- package/SKILL.md +60 -0
- package/index.css +10 -0
- package/index.html +25 -13
- package/{skills/advanced-swap-orders/manifest.json → manifest.json} +11 -10
- package/mcp/stdio.mjs +219 -0
- package/package.json +20 -5
- package/server.json +21 -0
- package/{skills/advanced-swap-orders → skill}/references/01-quickstart.md +4 -4
- package/{skills/advanced-swap-orders → skill}/references/03-sign.md +1 -1
- package/{skills/advanced-swap-orders → skill}/scripts/order.js +7 -6
- package/skills/advanced-swap-orders/SKILL.md +0 -54
- /package/{skills/advanced-swap-orders → skill}/assets/repermit.skeleton.json +0 -0
- /package/{skills/advanced-swap-orders → skill}/assets/token-addressbook.md +0 -0
- /package/{skills/advanced-swap-orders → skill}/assets/web3-sign-and-submit.example.js +0 -0
- /package/{skills/advanced-swap-orders → skill}/references/02-params.md +0 -0
- /package/{skills/advanced-swap-orders → skill}/references/04-patterns.md +0 -0
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
# Spot — Limit, TWAP, Stop-Loss, Take-Profit Non-Custodial DeFi Protocol
|
|
1
|
+
# Spot — Limit, TWAP, Stop-Loss, Take-Profit Non-Custodial Decentralized DeFi Protocol
|
|
2
2
|
|
|
3
|
-
**Agent-
|
|
3
|
+
**Agent-ready decentralized DeFi protocol for non-custodial advanced order types on EVM chains.**
|
|
4
4
|
|
|
5
5
|
**🔒 [Security Audit Report](./Audit-AstraSec.pdf)** - Smart contracts professionally audited by AstraSec
|
|
6
6
|
|
|
@@ -8,23 +8,23 @@
|
|
|
8
8
|
|
|
9
9
|
Start with these files:
|
|
10
10
|
|
|
11
|
-
1. [`
|
|
12
|
-
2. [`
|
|
13
|
-
3. [`
|
|
11
|
+
1. [`SKILL.md`](./SKILL.md) for the execution workflow
|
|
12
|
+
2. [`manifest.json`](./manifest.json) for machine-readable discovery
|
|
13
|
+
3. [`skill/scripts/order.js`](./skill/scripts/order.js) for prepare, submit, and query operations
|
|
14
14
|
|
|
15
|
-
The
|
|
15
|
+
The skill bundle is available through these surfaces:
|
|
16
16
|
|
|
17
|
-
1. Repo-local
|
|
18
|
-
2. Hosted raw files from [`https://orbs-network.github.io/spot/`](https://orbs-network.github.io/spot/), with
|
|
17
|
+
1. Repo-local root `SKILL.md`, `manifest.json`, and the `skill/` support directory
|
|
18
|
+
2. Hosted raw files from [`https://orbs-network.github.io/spot/`](https://orbs-network.github.io/spot/), with root entrypoints plus `skill/` support paths
|
|
19
19
|
3. The npm package `@orbs-network/spot`
|
|
20
|
+
4. MCP clients through the package bin `spot-mcp`, published in `server.json` as `io.github.orbs-network/spot`
|
|
20
21
|
|
|
21
22
|
## Agent Capabilities
|
|
22
23
|
|
|
23
24
|
- 🎯 **Intent Mapping**: Translate user intent into market, limit, TWAP, stop-loss, take-profit, and delayed-start orders
|
|
24
25
|
- ✍️ **Signing Prep**: Produce approval calldata, EIP-712 typed data, and relay-ready payloads
|
|
25
26
|
- 🔎 **Machine Discovery**: Read supported chains, runtime addresses, references, and assets from `manifest.json`
|
|
26
|
-
- 🧰 **Direct Execution Tooling**: Use `scripts/order.js` for prepare, submit, and query flows
|
|
27
|
-
- 📦 **Raw File Access**: Consume the same bundle from repo-local files, the hosted raw-file mirror, or from npm
|
|
27
|
+
- 🧰 **Direct Execution Tooling**: Use `skill/scripts/order.js` for prepare, submit, and query flows
|
|
28
28
|
|
|
29
29
|
## Protocol Guarantees
|
|
30
30
|
|
package/SKILL.md
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: spot-advanced-swap-orders
|
|
3
|
+
description: Use for gasless non-custodial EVM market, limit, TWAP, stop-loss, take-profit, delayed-start orders.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Spot Advanced Swap Orders
|
|
7
|
+
|
|
8
|
+
Use this for gasless market swaps and advanced orders on supported EVM chains.
|
|
9
|
+
Choose this skill when a user wants market, limit, TWAP, stop-loss, take-profit, or delayed-start execution, or needs to prepare, sign, submit, query, or cancel one of those orders.
|
|
10
|
+
Supply chain, token addresses, chunk sizing, timing, and optional price constraints.
|
|
11
|
+
The helper turns that into approval calldata, EIP-712 typed data, relay-ready submit payloads, and query/cancel guidance,
|
|
12
|
+
while decentralized, non-custodial, oracle-protected, immutable, audited, battle-tested contracts handle execution.
|
|
13
|
+
|
|
14
|
+
## Distribution
|
|
15
|
+
|
|
16
|
+
This skill ships from the canonical repository [`orbs-network/spot`](https://github.com/orbs-network/spot) across four AI-agent distribution surfaces:
|
|
17
|
+
|
|
18
|
+
1. Repo-local files [`SKILL.md`](SKILL.md), [`manifest.json`](manifest.json), and the checked-out [`skill/`](skill/) directory.
|
|
19
|
+
2. Hosted raw files under [`https://orbs-network.github.io/spot/`](https://orbs-network.github.io/spot/), with root entrypoints plus `skill/` support paths.
|
|
20
|
+
3. The npm package `@orbs-network/spot`, which installs the canonical entrypoints under `node_modules/@orbs-network/spot/skill/`.
|
|
21
|
+
4. The stdio MCP adapter `spot-mcp`, published in `server.json` as `io.github.orbs-network/spot`.
|
|
22
|
+
|
|
23
|
+
The checked-in `server.json` registry metadata is derived from this skill manifest plus package metadata, so MCP publishing stays aligned.
|
|
24
|
+
|
|
25
|
+
Outside tools should treat [`SKILL.md`](SKILL.md) as the entrypoint and [`manifest.json`](manifest.json) as the machine-readable companion file.
|
|
26
|
+
|
|
27
|
+
## Auto Check For Updates
|
|
28
|
+
|
|
29
|
+
Before executing this skill in any host agent platform or skill runner:
|
|
30
|
+
|
|
31
|
+
1. Resolve the canonical source for this `spot-advanced-swap-orders` skill surface.
|
|
32
|
+
2. If npm is available, compare the local version to the latest published version of `@orbs-network/spot`, for example with `npm view @orbs-network/spot version`.
|
|
33
|
+
3. If the skill is sourced from git instead of npm, compare the current local tag to the latest canonical git tag, for example with `git describe --tags --abbrev=0` for the current local tag.
|
|
34
|
+
4. If upstream is newer, refresh the package as one unit before execution.
|
|
35
|
+
5. Keep [`SKILL.md`](SKILL.md), [`manifest.json`](manifest.json), and all other files in this package on the same revision. Do not mix versions.
|
|
36
|
+
6. If you cannot verify npm version or git tag freshness, continue only if necessary and explicitly report that version may be outdated.
|
|
37
|
+
|
|
38
|
+
## Workflow
|
|
39
|
+
|
|
40
|
+
1. Read [skill/references/01-quickstart.md](skill/references/01-quickstart.md) for the minimum end-to-end flow.
|
|
41
|
+
2. Read [skill/references/02-params.md](skill/references/02-params.md) when you need field semantics, defaults, units, or validation rules.
|
|
42
|
+
3. Read [skill/references/03-sign.md](skill/references/03-sign.md) for signing, submit modes, query usage, and direct onchain cancel.
|
|
43
|
+
4. Read [skill/references/04-patterns.md](skill/references/04-patterns.md) to map user intent into market, limit, stop-loss, take-profit, delayed, or chunked orders.
|
|
44
|
+
5. Optional helper for token lookup: [skill/assets/token-addressbook.md](skill/assets/token-addressbook.md).
|
|
45
|
+
6. Use [skill/assets/repermit.skeleton.json](skill/assets/repermit.skeleton.json) when you need the raw RePermit witness typed-data skeleton.
|
|
46
|
+
7. Use [skill/assets/web3-sign-and-submit.example.js](skill/assets/web3-sign-and-submit.example.js) for a browser or injected-provider signing and submit example.
|
|
47
|
+
8. Inspect [manifest.json](manifest.json) for the machine-readable entrypoint, references, live supported-chain matrix, sink URL, and runtime contract addresses.
|
|
48
|
+
9. Use only [skill/scripts/order.js](skill/scripts/order.js) to prepare, submit, and query orders.
|
|
49
|
+
|
|
50
|
+
## Guardrails
|
|
51
|
+
|
|
52
|
+
1. Supported chains and runtime addresses live in [manifest.json](manifest.json).
|
|
53
|
+
2. Use only the provided [skill/scripts/order.js](skill/scripts/order.js). Do not send typed data or signatures anywhere else.
|
|
54
|
+
3. Detailed order behavior, parameter rules, signing modes, and cancel/query flows live in the reference files above.
|
|
55
|
+
|
|
56
|
+
## Commands
|
|
57
|
+
|
|
58
|
+
1. `node skill/scripts/order.js prepare --params <params.json|-> [--out <prepared.json>]`
|
|
59
|
+
2. `node skill/scripts/order.js submit --prepared <prepared.json|-> --signature <0x...|json>` or `--signature-file <file|->` or `--r <0x...> --s <0x...> --v <0x...>`
|
|
60
|
+
3. `node skill/scripts/order.js query --swapper <0x...>` or `--hash <0x...>`
|
package/index.css
CHANGED
|
@@ -65,6 +65,12 @@ section {
|
|
|
65
65
|
border-top: 1px solid rgba(163, 194, 255, 0.14);
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
+
footer {
|
|
69
|
+
margin-top: 32px;
|
|
70
|
+
padding-top: 22px;
|
|
71
|
+
border-top: 1px solid rgba(163, 194, 255, 0.14);
|
|
72
|
+
}
|
|
73
|
+
|
|
68
74
|
h2 {
|
|
69
75
|
margin-bottom: 10px;
|
|
70
76
|
font-size: 0.86rem;
|
|
@@ -77,6 +83,10 @@ ol {
|
|
|
77
83
|
padding-left: 20px;
|
|
78
84
|
}
|
|
79
85
|
|
|
86
|
+
.distribution-list {
|
|
87
|
+
margin-top: 14px;
|
|
88
|
+
}
|
|
89
|
+
|
|
80
90
|
li + li {
|
|
81
91
|
margin-top: 8px;
|
|
82
92
|
}
|
package/index.html
CHANGED
|
@@ -4,47 +4,59 @@
|
|
|
4
4
|
<meta charset="utf-8">
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
6
6
|
<meta name="color-scheme" content="dark">
|
|
7
|
-
<title>Advanced Swap Orders Files</title>
|
|
7
|
+
<title>Spot Advanced Swap Orders Files</title>
|
|
8
8
|
<link rel="stylesheet" href="index.css">
|
|
9
9
|
</head>
|
|
10
10
|
<body>
|
|
11
11
|
<main>
|
|
12
|
-
<h1>Advanced Swap Orders</h1>
|
|
13
|
-
<p>
|
|
12
|
+
<h1>Spot Advanced Swap Orders</h1>
|
|
13
|
+
<p>Hosted raw files for AI agents.</p>
|
|
14
14
|
|
|
15
15
|
<section>
|
|
16
16
|
<h2>Skill</h2>
|
|
17
17
|
<ol>
|
|
18
|
-
<li><a href="
|
|
19
|
-
<li><a href="
|
|
18
|
+
<li><a href="SKILL.md">SKILL.md</a></li>
|
|
19
|
+
<li><a href="manifest.json">manifest.json</a></li>
|
|
20
20
|
</ol>
|
|
21
21
|
</section>
|
|
22
22
|
|
|
23
23
|
<section>
|
|
24
24
|
<h2>References</h2>
|
|
25
25
|
<ol>
|
|
26
|
-
<li><a href="
|
|
27
|
-
<li><a href="
|
|
28
|
-
<li><a href="
|
|
29
|
-
<li><a href="
|
|
26
|
+
<li><a href="skill/references/01-quickstart.md">01-quickstart.md</a></li>
|
|
27
|
+
<li><a href="skill/references/02-params.md">02-params.md</a></li>
|
|
28
|
+
<li><a href="skill/references/03-sign.md">03-sign.md</a></li>
|
|
29
|
+
<li><a href="skill/references/04-patterns.md">04-patterns.md</a></li>
|
|
30
30
|
</ol>
|
|
31
31
|
</section>
|
|
32
32
|
|
|
33
33
|
<section>
|
|
34
34
|
<h2>Scripts</h2>
|
|
35
35
|
<ol>
|
|
36
|
-
<li><a href="
|
|
36
|
+
<li><a href="skill/scripts/order.js">order.js</a></li>
|
|
37
37
|
</ol>
|
|
38
38
|
</section>
|
|
39
39
|
|
|
40
40
|
<section>
|
|
41
41
|
<h2>Assets</h2>
|
|
42
42
|
<ol>
|
|
43
|
-
<li><a href="
|
|
44
|
-
<li><a href="
|
|
45
|
-
<li><a href="
|
|
43
|
+
<li><a href="skill/assets/token-addressbook.md">token-addressbook.md</a></li>
|
|
44
|
+
<li><a href="skill/assets/repermit.skeleton.json">repermit.skeleton.json</a></li>
|
|
45
|
+
<li><a href="skill/assets/web3-sign-and-submit.example.js">web3-sign-and-submit.example.js</a></li>
|
|
46
46
|
</ol>
|
|
47
47
|
</section>
|
|
48
|
+
|
|
49
|
+
<footer>
|
|
50
|
+
<h2>Distributions</h2>
|
|
51
|
+
<ol class="distribution-list">
|
|
52
|
+
<li><a href="https://github.com/orbs-network/spot/blob/main/SKILL.md">GitHub skill entrypoint: Spot Advanced Swap Orders</a></li>
|
|
53
|
+
<li><a href="SKILL.md">Hosted raw entrypoint: Spot Advanced Swap Orders</a></li>
|
|
54
|
+
<li><a href="https://www.npmjs.com/package/@orbs-network/spot">npm package: @orbs-network/spot</a></li>
|
|
55
|
+
<li><a href="https://www.npmjs.com/package/@orbs-network/spot">npm bin: spot-mcp</a></li>
|
|
56
|
+
<li><a href="server.json">MCP metadata: io.github.orbs-network/spot</a></li>
|
|
57
|
+
</ol>
|
|
58
|
+
</footer>
|
|
59
|
+
|
|
48
60
|
</main>
|
|
49
61
|
</body>
|
|
50
62
|
</html>
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name": "advanced-swap-orders",
|
|
3
|
-
"
|
|
2
|
+
"name": "spot-advanced-swap-orders",
|
|
3
|
+
"title": "Spot Advanced Swap Orders",
|
|
4
|
+
"description": "Create and manage gasless, decentralized, non-custodial, oracle-protected market, limit, TWAP, stop-loss, take-profit, and delayed-start swap orders on supported EVM chains with immutable, audited, battle-tested contracts.",
|
|
4
5
|
"entrypoint": "SKILL.md",
|
|
5
6
|
"references": [
|
|
6
|
-
"references/01-quickstart.md",
|
|
7
|
-
"references/02-params.md",
|
|
8
|
-
"references/03-sign.md",
|
|
9
|
-
"references/04-patterns.md"
|
|
7
|
+
"skill/references/01-quickstart.md",
|
|
8
|
+
"skill/references/02-params.md",
|
|
9
|
+
"skill/references/03-sign.md",
|
|
10
|
+
"skill/references/04-patterns.md"
|
|
10
11
|
],
|
|
11
12
|
"scripts": [
|
|
12
|
-
"scripts/order.js"
|
|
13
|
+
"skill/scripts/order.js"
|
|
13
14
|
],
|
|
14
15
|
"assets": [
|
|
15
|
-
"assets/token-addressbook.md",
|
|
16
|
-
"assets/repermit.skeleton.json",
|
|
17
|
-
"assets/web3-sign-and-submit.example.js"
|
|
16
|
+
"skill/assets/token-addressbook.md",
|
|
17
|
+
"skill/assets/repermit.skeleton.json",
|
|
18
|
+
"skill/assets/web3-sign-and-submit.example.js"
|
|
18
19
|
],
|
|
19
20
|
"runtime": {
|
|
20
21
|
"url": "https://agents-sink.orbs.network",
|
package/mcp/stdio.mjs
ADDED
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { spawn } from "node:child_process";
|
|
4
|
+
import { readFile } from "node:fs/promises";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import { fileURLToPath } from "node:url";
|
|
7
|
+
import { z } from "zod";
|
|
8
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
9
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
10
|
+
|
|
11
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
12
|
+
const rootDir = path.resolve(__dirname, "..");
|
|
13
|
+
const packageJsonPath = path.join(rootDir, "package.json");
|
|
14
|
+
const skillMdPath = path.join(rootDir, "SKILL.md");
|
|
15
|
+
const manifestPath = path.join(rootDir, "manifest.json");
|
|
16
|
+
const cliPath = path.join(rootDir, "skill", "scripts", "order.js");
|
|
17
|
+
|
|
18
|
+
const [pkg, manifest] = await Promise.all([
|
|
19
|
+
readJsonFile(packageJsonPath),
|
|
20
|
+
readJsonFile(manifestPath),
|
|
21
|
+
]);
|
|
22
|
+
|
|
23
|
+
const mcpName = requiredString(pkg.mcpName, "package.json mcpName");
|
|
24
|
+
const version = requiredString(pkg.version, "package.json version");
|
|
25
|
+
const skillName = requiredString(manifest.name, "skill manifest name");
|
|
26
|
+
const skillTitle = requiredString(manifest.title, "skill manifest title");
|
|
27
|
+
|
|
28
|
+
const server = new McpServer({
|
|
29
|
+
name: mcpName,
|
|
30
|
+
version,
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
server.registerResource(
|
|
34
|
+
"spot-skill",
|
|
35
|
+
"spot://skill",
|
|
36
|
+
{
|
|
37
|
+
title: `${skillTitle} skill`,
|
|
38
|
+
description: `Canonical ${skillName} SKILL.md for ${mcpName}`,
|
|
39
|
+
mimeType: "text/markdown",
|
|
40
|
+
},
|
|
41
|
+
async (uri) => ({
|
|
42
|
+
contents: [
|
|
43
|
+
{
|
|
44
|
+
uri: uri.href,
|
|
45
|
+
text: await readFile(skillMdPath, "utf8"),
|
|
46
|
+
mimeType: "text/markdown",
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
}),
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
server.registerResource(
|
|
53
|
+
"spot-manifest",
|
|
54
|
+
"spot://manifest",
|
|
55
|
+
{
|
|
56
|
+
title: `${skillTitle} manifest`,
|
|
57
|
+
description: `Canonical ${skillName} manifest.json for ${mcpName}`,
|
|
58
|
+
mimeType: "application/json",
|
|
59
|
+
},
|
|
60
|
+
async (uri) => ({
|
|
61
|
+
contents: [
|
|
62
|
+
{
|
|
63
|
+
uri: uri.href,
|
|
64
|
+
text: JSON.stringify(manifest, null, 2),
|
|
65
|
+
mimeType: "application/json",
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
}),
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
server.registerTool(
|
|
72
|
+
"prepare_order",
|
|
73
|
+
{
|
|
74
|
+
title: "Prepare order",
|
|
75
|
+
description: "Prepare approval calldata, typed data, submit payload, and query URL.",
|
|
76
|
+
inputSchema: {
|
|
77
|
+
params: z.record(z.string(), z.unknown()),
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
async ({ params }) => runTool(["prepare", "--params", "-"], params),
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
server.registerTool(
|
|
84
|
+
"submit_order",
|
|
85
|
+
{
|
|
86
|
+
title: "Submit order",
|
|
87
|
+
description: "Submit a prepared order with a signature.",
|
|
88
|
+
inputSchema: {
|
|
89
|
+
prepared: z.unknown(),
|
|
90
|
+
signature: z.union([
|
|
91
|
+
z.string(),
|
|
92
|
+
z.object({
|
|
93
|
+
r: z.string(),
|
|
94
|
+
s: z.string(),
|
|
95
|
+
v: z.union([z.string(), z.number()]),
|
|
96
|
+
}),
|
|
97
|
+
]),
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
async ({ prepared, signature }) => {
|
|
101
|
+
const signatureArgs =
|
|
102
|
+
typeof signature === "string"
|
|
103
|
+
? ["--signature", signature]
|
|
104
|
+
: ["--signature", JSON.stringify(signature)];
|
|
105
|
+
|
|
106
|
+
return runTool(["submit", "--prepared", "-", ...signatureArgs], prepared);
|
|
107
|
+
},
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
server.registerTool(
|
|
111
|
+
"query_orders",
|
|
112
|
+
{
|
|
113
|
+
title: "Query orders",
|
|
114
|
+
description: "Query orders by swapper and/or order hash.",
|
|
115
|
+
inputSchema: {
|
|
116
|
+
swapper: z.string().optional(),
|
|
117
|
+
hash: z.string().optional(),
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
async ({ swapper, hash }) => {
|
|
121
|
+
if (!swapper && !hash) {
|
|
122
|
+
return toolError("query_orders requires swapper or hash");
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const args = ["query"];
|
|
126
|
+
if (swapper) {
|
|
127
|
+
args.push("--swapper", swapper);
|
|
128
|
+
}
|
|
129
|
+
if (hash) {
|
|
130
|
+
args.push("--hash", hash);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return runTool(args);
|
|
134
|
+
},
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
await server.connect(new StdioServerTransport());
|
|
138
|
+
|
|
139
|
+
async function readJsonFile(filePath) {
|
|
140
|
+
return JSON.parse(await readFile(filePath, "utf8"));
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function requiredString(value, label) {
|
|
144
|
+
if (typeof value !== "string" || value.trim() === "") {
|
|
145
|
+
throw new Error(`${label} is required`);
|
|
146
|
+
}
|
|
147
|
+
return value;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function runCli(args, stdinJson) {
|
|
151
|
+
return new Promise((resolve, reject) => {
|
|
152
|
+
const child = spawn(process.execPath, [cliPath, ...args], {
|
|
153
|
+
cwd: rootDir,
|
|
154
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
let stdout = "";
|
|
158
|
+
let stderr = "";
|
|
159
|
+
|
|
160
|
+
child.stdout.on("data", (chunk) => {
|
|
161
|
+
stdout += String(chunk);
|
|
162
|
+
});
|
|
163
|
+
child.stderr.on("data", (chunk) => {
|
|
164
|
+
stderr += String(chunk);
|
|
165
|
+
});
|
|
166
|
+
child.on("error", reject);
|
|
167
|
+
|
|
168
|
+
child.on("close", (code) => {
|
|
169
|
+
const out = stdout.trim();
|
|
170
|
+
const err = stderr.trim();
|
|
171
|
+
|
|
172
|
+
if (code !== 0) {
|
|
173
|
+
reject(new Error(err || out || `order.js exited with code ${code}`));
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
try {
|
|
178
|
+
resolve(out ? JSON.parse(out) : {});
|
|
179
|
+
} catch {
|
|
180
|
+
resolve({
|
|
181
|
+
raw: out,
|
|
182
|
+
stderr: err,
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
const payload = stdinJson == null ? "" : `${JSON.stringify(stdinJson)}\n`;
|
|
188
|
+
child.stdin.end(payload);
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
async function runTool(args, stdinJson) {
|
|
193
|
+
try {
|
|
194
|
+
const output = await runCli(args, stdinJson);
|
|
195
|
+
return {
|
|
196
|
+
content: [
|
|
197
|
+
{
|
|
198
|
+
type: "text",
|
|
199
|
+
text: JSON.stringify(output, null, 2),
|
|
200
|
+
},
|
|
201
|
+
],
|
|
202
|
+
structuredContent: output,
|
|
203
|
+
};
|
|
204
|
+
} catch (error) {
|
|
205
|
+
return toolError(String(error?.message ?? error));
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function toolError(message) {
|
|
210
|
+
return {
|
|
211
|
+
isError: true,
|
|
212
|
+
content: [
|
|
213
|
+
{
|
|
214
|
+
type: "text",
|
|
215
|
+
text: message,
|
|
216
|
+
},
|
|
217
|
+
],
|
|
218
|
+
};
|
|
219
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orbs-network/spot",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
|
+
"mcpName": "io.github.orbs-network/spot",
|
|
4
5
|
"description": "**A DeFi protocol for noncustodial advanced order types on EVM chains.**",
|
|
5
6
|
"homepage": "https://github.com/orbs-network/spot#readme",
|
|
6
7
|
"bugs": {
|
|
@@ -12,9 +13,15 @@
|
|
|
12
13
|
},
|
|
13
14
|
"license": "MIT",
|
|
14
15
|
"author": "danielz@orbs.com",
|
|
16
|
+
"engines": {
|
|
17
|
+
"node": ">=18"
|
|
18
|
+
},
|
|
19
|
+
"bin": {
|
|
20
|
+
"spot-mcp": "./mcp/stdio.mjs"
|
|
21
|
+
},
|
|
15
22
|
"scripts": {
|
|
16
23
|
"fmt": "forge fmt",
|
|
17
|
-
"build": "forge build --extra-output-files abi",
|
|
24
|
+
"build": "node ./script/sync-mcp.mjs && forge build --extra-output-files abi",
|
|
18
25
|
"test": "forge test",
|
|
19
26
|
"prepublishOnly": "npm run fmt && npm run build && npm run test"
|
|
20
27
|
},
|
|
@@ -22,10 +29,18 @@
|
|
|
22
29
|
"config.json",
|
|
23
30
|
"index.css",
|
|
24
31
|
"index.html",
|
|
25
|
-
"
|
|
32
|
+
"SKILL.md",
|
|
33
|
+
"manifest.json",
|
|
34
|
+
"skill/",
|
|
26
35
|
"script/input/",
|
|
27
36
|
"out/**/*.json",
|
|
28
|
-
"index.js"
|
|
37
|
+
"index.js",
|
|
38
|
+
"mcp/",
|
|
39
|
+
"server.json"
|
|
29
40
|
],
|
|
30
|
-
"main": "index.js"
|
|
41
|
+
"main": "index.js",
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"@modelcontextprotocol/sdk": "1.27.1",
|
|
44
|
+
"zod": "4.3.6"
|
|
45
|
+
}
|
|
31
46
|
}
|
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": "Create and manage gasless, decentralized, non-custodial, oracle-protected market, limit, TWAP, stop-loss, take-profit, and delayed-start swap orders on supported EVM chains with immutable, audited, battle-tested contracts.",
|
|
6
|
+
"repository": {
|
|
7
|
+
"url": "https://github.com/orbs-network/spot",
|
|
8
|
+
"source": "github"
|
|
9
|
+
},
|
|
10
|
+
"version": "2.2.0",
|
|
11
|
+
"packages": [
|
|
12
|
+
{
|
|
13
|
+
"registryType": "npm",
|
|
14
|
+
"identifier": "@orbs-network/spot",
|
|
15
|
+
"version": "2.2.0",
|
|
16
|
+
"transport": {
|
|
17
|
+
"type": "stdio"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
]
|
|
21
|
+
}
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
1. Required fields: `chainId`, `swapper`, `input.token`, `input.amount`, `output.token`.
|
|
4
4
|
2. Read [02-params.md](02-params.md) for defaults, units, chunking semantics, native asset rules, and validation notes.
|
|
5
5
|
3. Read [04-patterns.md](04-patterns.md) to choose the right market, limit, stop-loss, take-profit, delayed, or chunked shape.
|
|
6
|
-
4. Prepare: `node scripts/order.js prepare --params <params.json|->`
|
|
6
|
+
4. Prepare: `node skill/scripts/order.js prepare --params <params.json|->`
|
|
7
7
|
5. If approval is needed, send `prepared.approval.tx`.
|
|
8
|
-
6.
|
|
8
|
+
6. Prefer infinite approval to `RePermit` to save future approval gas costs; no approval reset is needed.
|
|
9
9
|
7. Sign `prepared.typedData` as the `swapper`.
|
|
10
10
|
8. Read [03-sign.md](03-sign.md) for signature formats, submit modes, query usage, and direct onchain cancel.
|
|
11
|
-
9. Submit: `node scripts/order.js submit --prepared <prepared.json|-> --signature <0x...|json>`
|
|
12
|
-
10. Query: `node scripts/order.js query --swapper <0x...>` or `--hash <0x...>`
|
|
11
|
+
9. Submit: `node skill/scripts/order.js submit --prepared <prepared.json|-> --signature <0x...|json>`
|
|
12
|
+
10. Query: `node skill/scripts/order.js query --swapper <0x...>` or `--hash <0x...>`
|
|
13
13
|
11. When measuring a fill onchain, sum both transfers to the swapper: the main fill and the surplus refund. Measuring only the main fill undercounts actual output by up to the slippage tolerance.
|
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
1. Sign `prepared.typedData` with any EIP-712-capable wallet or library. The signer must equal `swapper`. `eth_signTypedData_v4` is only one example.
|
|
4
4
|
2. Submit with `--prepared <prepared.json|->` and exactly one signature mode: `--signature <0x...|json>`, `--signature-file <sig.txt|sig.json|->`, or `--r <0x...> --s <0x...> --v <0x...>`.
|
|
5
5
|
3. The helper accepts a full 65-byte signature, a JSON string, or JSON/object `r/s/v`.
|
|
6
|
-
4. Query with `node scripts/order.js query --swapper <0x...>` or `--hash <0x...>`.
|
|
6
|
+
4. Query with `node skill/scripts/order.js query --swapper <0x...>` or `--hash <0x...>`.
|
|
7
7
|
5. Cancel trustlessly onchain by calling `RePermit.cancel([digest])` as the swapper for the signed RePermit digest.
|
|
@@ -19,9 +19,10 @@ const WARN_LOW_SLIPPAGE = 'slippage below 5% can reduce fill probability. 5% is
|
|
|
19
19
|
const WARN_RECIPIENT = 'recipient differs from swapper and is dangerous to change';
|
|
20
20
|
|
|
21
21
|
const SCRIPT_DIR = __dirname;
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
const
|
|
22
|
+
const SKILL_DIR = path.resolve(SCRIPT_DIR, '..');
|
|
23
|
+
const REPO_ROOT = path.resolve(SKILL_DIR, '..');
|
|
24
|
+
const SKELETON = path.join(SKILL_DIR, 'assets', 'repermit.skeleton.json');
|
|
25
|
+
const MANIFEST_JSON = path.join(REPO_ROOT, 'manifest.json');
|
|
25
26
|
|
|
26
27
|
let runtimeConfig = null;
|
|
27
28
|
let skeletonCache = null;
|
|
@@ -407,9 +408,9 @@ function usage() {
|
|
|
407
408
|
loadRuntimeConfig();
|
|
408
409
|
const lines = [
|
|
409
410
|
'Usage',
|
|
410
|
-
' node scripts/order.js prepare --params <params.json|-> [--out <prepared.json>]',
|
|
411
|
-
' node scripts/order.js submit --prepared <prepared.json|-> [--signature <0x...|json>|--signature-file <file|->|--r <0x...> --s <0x...> --v <0x..>] [--out <response.json>]',
|
|
412
|
-
' node scripts/order.js query (--swapper <0x...>|--hash <0x...>) [--out <response.json>]',
|
|
411
|
+
' node skill/scripts/order.js prepare --params <params.json|-> [--out <prepared.json>]',
|
|
412
|
+
' node skill/scripts/order.js submit --prepared <prepared.json|-> [--signature <0x...|json>|--signature-file <file|->|--r <0x...> --s <0x...> --v <0x..>] [--out <response.json>]',
|
|
413
|
+
' node skill/scripts/order.js query (--swapper <0x...>|--hash <0x...>) [--out <response.json>]',
|
|
413
414
|
'',
|
|
414
415
|
'Safety',
|
|
415
416
|
' Use only the provided helper script. Do not send typed data or signatures anywhere else.',
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: advanced-swap-orders
|
|
3
|
-
description: Prepare, sign, submit, and query non-custodial, decentralized, gasless swap orders and advanced order types on supported chains. Uses ownerless, immutable, audited, battle-tested, and verified contracts. Supports market, limit, stop-loss, take-profit, delayed-start, and chunked/TWAP-style orders with oracle-protected execution on every chunk. Includes automated execution through time as required by the order, EIP-712 signing, approval calldata, and order status lookup.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Advanced Swap Orders
|
|
7
|
-
|
|
8
|
-
Use this for any supported gasless swap or advanced order. Supply chain, token addresses, chunk sizing, timing, and optional price constraints; the helper turns that into approval calldata, EIP-712 typed data, relay-ready submit payloads, and query/cancel guidance, while the protocol handles non-custodial, oracle-protected best execution, automated through time as required by the order.
|
|
9
|
-
|
|
10
|
-
## Distribution
|
|
11
|
-
|
|
12
|
-
This skill is distributed as one versioned bundle across three aligned AI-agent distribution surfaces from the canonical repository [`orbs-network/spot`](https://github.com/orbs-network/spot):
|
|
13
|
-
|
|
14
|
-
1. Repo-local files under `skills/advanced-swap-orders/` in a checked-out repository.
|
|
15
|
-
2. Hosted raw files under [`https://orbs-network.github.io/spot/`](https://orbs-network.github.io/spot/), with the same relative `skills/advanced-swap-orders/` paths.
|
|
16
|
-
3. The npm package `@orbs-network/spot`, where the same relative tree is installed under `node_modules/@orbs-network/spot/skills/advanced-swap-orders/`.
|
|
17
|
-
|
|
18
|
-
Outside tools should treat [`SKILL.md`](SKILL.md) as the entrypoint and [`manifest.json`](manifest.json) as the machine-readable companion file.
|
|
19
|
-
The repository [`README.md`](https://github.com/orbs-network/spot/blob/main/README.md) mirrors the repo-local entrypoints first for top-level AI-agent discovery.
|
|
20
|
-
|
|
21
|
-
## Auto Check For Updates
|
|
22
|
-
|
|
23
|
-
Before executing this skill in any host agent platform or skill runner:
|
|
24
|
-
|
|
25
|
-
1. Resolve the canonical source for this `advanced-swap-orders/` skill directory.
|
|
26
|
-
2. If npm is available, compare the local version to the latest published version of `@orbs-network/spot`, for example with `npm view @orbs-network/spot version`.
|
|
27
|
-
3. If the skill is sourced from git instead of npm, compare the current local tag to the latest canonical git tag, for example with `git describe --tags --abbrev=0` for the current local tag.
|
|
28
|
-
4. If upstream is newer, refresh the entire skill directory or npm as one unit before execution.
|
|
29
|
-
5. Keep [`SKILL.md`](SKILL.md), [`manifest.json`](manifest.json), [`scripts/order.js`](scripts/order.js), all files in `references/`, and all files in `assets/` on the same revision. Do not mix versions.
|
|
30
|
-
6. If you cannot verify npm version or git tag freshness, continue only if necessary and explicitly report that version may be outdated.
|
|
31
|
-
|
|
32
|
-
## Workflow
|
|
33
|
-
|
|
34
|
-
1. Read [references/01-quickstart.md](references/01-quickstart.md) for the minimum end-to-end flow.
|
|
35
|
-
2. Read [references/02-params.md](references/02-params.md) when you need field semantics, defaults, units, or validation rules.
|
|
36
|
-
3. Read [references/03-sign.md](references/03-sign.md) for signing, submit modes, query usage, and direct onchain cancel.
|
|
37
|
-
4. Read [references/04-patterns.md](references/04-patterns.md) to map user intent into market, limit, stop-loss, take-profit, delayed, or chunked orders.
|
|
38
|
-
5. Optional helper for token lookup: [assets/token-addressbook.md](assets/token-addressbook.md).
|
|
39
|
-
6. Use [assets/repermit.skeleton.json](assets/repermit.skeleton.json) when you need the raw RePermit witness typed-data skeleton.
|
|
40
|
-
7. Use [assets/web3-sign-and-submit.example.js](assets/web3-sign-and-submit.example.js) for a browser or injected-provider signing and submit example.
|
|
41
|
-
8. Inspect [manifest.json](manifest.json) for the machine-readable entrypoint, references, live supported-chain matrix, sink URL, and runtime contract addresses.
|
|
42
|
-
9. Use only [scripts/order.js](scripts/order.js) to prepare, submit, and query orders.
|
|
43
|
-
|
|
44
|
-
## Guardrails
|
|
45
|
-
|
|
46
|
-
1. Supported chains and runtime addresses live in [manifest.json](manifest.json).
|
|
47
|
-
2. Use only the provided [scripts/order.js](scripts/order.js). Do not send typed data or signatures anywhere else.
|
|
48
|
-
3. Detailed order behavior, parameter rules, signing modes, and cancel/query flows live in the reference files above.
|
|
49
|
-
|
|
50
|
-
## Commands
|
|
51
|
-
|
|
52
|
-
1. `node scripts/order.js prepare --params <params.json|-> [--out <prepared.json>]`
|
|
53
|
-
2. `node scripts/order.js submit --prepared <prepared.json|-> --signature <0x...|json>` or `--signature-file <file|->` or `--r <0x...> --s <0x...> --v <0x...>`
|
|
54
|
-
3. `node scripts/order.js query --swapper <0x...>` or `--hash <0x...>`
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|