@morebetterclaw/forge-swap 0.1.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.
- package/.env.example +21 -0
- package/.env.railway +24 -0
- package/.mcpregistry_github_token +1 -0
- package/.mcpregistry_registry_token +1 -0
- package/BUILD_BRIEF_V1.md +216 -0
- package/README.md +189 -0
- package/SKILL.md +93 -0
- package/deploy/README.md +156 -0
- package/package.json +40 -0
- package/public/mcp.json +10 -0
- package/railway.json +13 -0
- package/server.json +21 -0
- package/setup-check.js +80 -0
- package/src/formatter.js +56 -0
- package/src/health.js +27 -0
- package/src/index.js +72 -0
- package/src/mcp.js +200 -0
- package/src/parser.js +90 -0
- package/src/server.js +177 -0
- package/src/swapkit.js +135 -0
- package/src/telegram.js +239 -0
- package/src/test.js +109 -0
- package/src/wallet.js +157 -0
package/.env.example
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# ─── Affiliate Fee (revenue) ──────────────────────────────
|
|
2
|
+
# THORChain RUNE address (starts with thor1...) where 0.5% fees land
|
|
3
|
+
FEE_RECIPIENT_ADDRESS=thor1your_address_here
|
|
4
|
+
# Fee in basis points (50 = 0.5%)
|
|
5
|
+
SWAP_FEE_BPS=50
|
|
6
|
+
|
|
7
|
+
# ─── Wallet (optional — for autonomous EVM execution) ─────
|
|
8
|
+
# Only needed if agent will execute swaps autonomously
|
|
9
|
+
# Leave blank for quote-only mode (safe for most deployments)
|
|
10
|
+
WALLET_PRIVATE_KEY=
|
|
11
|
+
EVM_RPC_URL=https://eth-mainnet.g.alchemy.com/v2/your_key_here
|
|
12
|
+
|
|
13
|
+
# ─── Server ───────────────────────────────────────────────
|
|
14
|
+
PORT=3000
|
|
15
|
+
NODE_ENV=production
|
|
16
|
+
ALLOWED_ORIGINS=*
|
|
17
|
+
LOG_LEVEL=info
|
|
18
|
+
|
|
19
|
+
# ─── Rate Limiting ────────────────────────────────────────
|
|
20
|
+
RATE_LIMIT_WINDOW_MS=60000
|
|
21
|
+
RATE_LIMIT_MAX=100
|
package/.env.railway
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# FORGE — Railway Environment Variables
|
|
2
|
+
# Set these in Railway Dashboard → Variables tab
|
|
3
|
+
# Do NOT commit this file with real values
|
|
4
|
+
|
|
5
|
+
NODE_ENV=production
|
|
6
|
+
PORT=3000
|
|
7
|
+
|
|
8
|
+
# ── THORChain Affiliate Fee (REQUIRED) ────────────────────
|
|
9
|
+
# Your RUNE address — all 0.5% swap fees land here automatically
|
|
10
|
+
FEE_RECIPIENT_ADDRESS=thor1yfrfgjgnzkjqqgv02yxn3j3kv50pe0rnhvs8zw
|
|
11
|
+
SWAP_FEE_BPS=50
|
|
12
|
+
|
|
13
|
+
# ── Rate Limiting ──────────────────────────────────────────
|
|
14
|
+
RATE_LIMIT_WINDOW_MS=60000
|
|
15
|
+
RATE_LIMIT_MAX=100
|
|
16
|
+
|
|
17
|
+
# ── CORS ──────────────────────────────────────────────────
|
|
18
|
+
# Set to your domain when website is live:
|
|
19
|
+
# ALLOWED_ORIGINS=https://morebetterstudios.com,https://www.morebetterstudios.com
|
|
20
|
+
ALLOWED_ORIGINS=*
|
|
21
|
+
|
|
22
|
+
# ── Optional: Autonomous EVM execution (v2 — leave blank for launch) ──
|
|
23
|
+
# WALLET_PRIVATE_KEY=
|
|
24
|
+
# EVM_RPC_URL=
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ghu_AMjMT6Ldr8d2xMEGzuRJmFUkO9NrhT4eoByt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"token":"eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJtY3AtcmVnaXN0cnkiLCJleHAiOjE3NzQxOTQ1ODQsIm5iZiI6MTc3NDE5NDI4NCwiaWF0IjoxNzc0MTk0Mjg0LCJhdXRoX21ldGhvZCI6ImdpdGh1Yi1hdCIsImF1dGhfbWV0aG9kX3N1YiI6Im1vcmViZXR0ZXJjbGF3IiwicGVybWlzc2lvbnMiOlt7ImFjdGlvbiI6InB1Ymxpc2giLCJyZXNvdXJjZSI6ImlvLmdpdGh1Yi5tb3JlYmV0dGVyY2xhdy8qIn1dfQ.USQmdeIYcgMQliAgOtfT1VwLtNMpAV_V0NEWyyhHIKhjQxEqlqOOx7Wx66OKZe0a7_OHt1XXJLg5dtGNheOdAw","expires_at":1774194584}
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
# Crypto Swap Agent — Build Brief v1
|
|
2
|
+
**Issued by:** Daksh (CEO, MoreBetter Studios)
|
|
3
|
+
**Date:** 2026-03-14
|
|
4
|
+
**Priority:** HIGH
|
|
5
|
+
**Estimated scope:** 3–4 hours
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Context
|
|
10
|
+
|
|
11
|
+
The `crypto-swap-agent` project exists and has a working SwapKit REST client (`src/swapkit.js`), wallet signing layer (`src/wallet.js`), command parser (`src/parser.js`), and formatter (`src/formatter.js`). However it is incomplete — it is currently a CLI only, and cannot be deployed as an always-on web service. This brief covers everything needed to make it production-deployable.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## What Exists (do not rewrite these)
|
|
16
|
+
|
|
17
|
+
- `src/swapkit.js` — SwapKit REST API client, affiliate fee injection ✅
|
|
18
|
+
- `src/wallet.js` — EVM signing + BTC deposit instructions ✅
|
|
19
|
+
- `src/parser.js` — natural language command parser ✅
|
|
20
|
+
- `src/formatter.js` — response formatters ✅
|
|
21
|
+
- `src/health.js` — Express router with GET /health (has module system conflict — fix in place)
|
|
22
|
+
- `deploy/README.md` — Railway deployment guide ✅
|
|
23
|
+
- `SKILL.md` — OpenClaw skill wrapper ✅
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## Task List
|
|
28
|
+
|
|
29
|
+
### Task 1 — Fix module system conflict (BLOCKING)
|
|
30
|
+
|
|
31
|
+
`package.json` declares `"type": "module"` (ESM) but `health.js` uses CommonJS `require()`. This will crash on start.
|
|
32
|
+
|
|
33
|
+
**Fix:** Convert `health.js` to ESM:
|
|
34
|
+
```js
|
|
35
|
+
// Replace: const { Router } = require('express');
|
|
36
|
+
import { Router } from 'express';
|
|
37
|
+
// Replace: module.exports = router;
|
|
38
|
+
export default router;
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Also audit `src/wallet.js` — it mixes `import` (ESM) with some patterns that may cause issues; ensure it is pure ESM.
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
### Task 2 — Build the HTTP server (BLOCKING for deployment)
|
|
46
|
+
|
|
47
|
+
Create `src/server.js` — an Express HTTP service that exposes the swap agent as an API. This is the core missing piece.
|
|
48
|
+
|
|
49
|
+
**Required endpoints:**
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
GET /health → { status: "ok", version, timestamp }
|
|
53
|
+
POST /swap/quote → get a swap quote
|
|
54
|
+
POST /swap/execute → build + return swap transaction data
|
|
55
|
+
GET /swap/status → check swap status by txHash
|
|
56
|
+
GET /swap/assets → list supported assets
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
**POST /swap/quote body:**
|
|
60
|
+
```json
|
|
61
|
+
{
|
|
62
|
+
"fromAsset": "ETH.ETH",
|
|
63
|
+
"toAsset": "BTC.BTC",
|
|
64
|
+
"amount": "0.1"
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
**POST /swap/quote response:**
|
|
69
|
+
```json
|
|
70
|
+
{
|
|
71
|
+
"fromAsset": "ETH.ETH",
|
|
72
|
+
"toAsset": "BTC.BTC",
|
|
73
|
+
"amount": "0.1",
|
|
74
|
+
"expectedOutput": "0.00312",
|
|
75
|
+
"expectedOutputMinusFees": "0.00308",
|
|
76
|
+
"affiliateFee": "0.5%",
|
|
77
|
+
"route": ["THORChain"],
|
|
78
|
+
"slippage": "0.5%",
|
|
79
|
+
"expiresAt": "<ISO timestamp>"
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
**POST /swap/execute body:**
|
|
84
|
+
```json
|
|
85
|
+
{
|
|
86
|
+
"fromAsset": "ETH.ETH",
|
|
87
|
+
"toAsset": "BTC.BTC",
|
|
88
|
+
"amount": "0.1",
|
|
89
|
+
"destinationAddress": "bc1q..."
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
**POST /swap/execute response:** return the full `swapData` object from `SwapKitApi.executeSwap()` — includes `memo`, `depositAddress`, `expectedOutput`, `affiliateFee`.
|
|
94
|
+
|
|
95
|
+
**Server requirements:**
|
|
96
|
+
- Use `express` (add to dependencies)
|
|
97
|
+
- Rate limiting: 100 requests per 60s window (use `express-rate-limit`)
|
|
98
|
+
- CORS: allow `process.env.ALLOWED_ORIGINS || '*'`
|
|
99
|
+
- Port: `process.env.PORT || 3000`
|
|
100
|
+
- Error handling middleware: catch errors, return `{ error: message }` with appropriate HTTP status
|
|
101
|
+
- Request logging: log method, path, status, duration (use `console.log` — no extra deps)
|
|
102
|
+
- Graceful shutdown on SIGTERM (for Railway)
|
|
103
|
+
|
|
104
|
+
**Add `express` and `express-rate-limit` to `package.json` dependencies.**
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
### Task 3 — Update `src/index.js` to be the entry point for the HTTP server
|
|
109
|
+
|
|
110
|
+
Currently `index.js` is a CLI. Change it so:
|
|
111
|
+
- When run as `node src/index.js` → starts the HTTP server (calls `server.js`)
|
|
112
|
+
- CLI commands are kept as `node src/index.js <command>` for local testing
|
|
113
|
+
- Add a check: if `process.argv[2]` is a recognised command → run CLI mode; otherwise → start server
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
### Task 4 — Create `.env.example`
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
# ─── SwapKit ──────────────────────────────────────────────
|
|
121
|
+
SWAPKIT_API_KEY=your_swapkit_api_key_here
|
|
122
|
+
|
|
123
|
+
# ─── Affiliate Fee (revenue) ──────────────────────────────
|
|
124
|
+
# THORChain RUNE address (starts with thor1...) where 0.5% fees land
|
|
125
|
+
FEE_RECIPIENT_ADDRESS=thor1your_address_here
|
|
126
|
+
# Fee in basis points (50 = 0.5%)
|
|
127
|
+
SWAP_FEE_BPS=50
|
|
128
|
+
|
|
129
|
+
# ─── Wallet (optional — for autonomous EVM execution) ─────
|
|
130
|
+
# Only needed if agent will execute swaps autonomously
|
|
131
|
+
# Leave blank for quote-only mode (safe for most deployments)
|
|
132
|
+
WALLET_PRIVATE_KEY=
|
|
133
|
+
EVM_RPC_URL=https://eth-mainnet.g.alchemy.com/v2/your_key_here
|
|
134
|
+
|
|
135
|
+
# ─── Server ───────────────────────────────────────────────
|
|
136
|
+
PORT=3000
|
|
137
|
+
NODE_ENV=production
|
|
138
|
+
ALLOWED_ORIGINS=*
|
|
139
|
+
LOG_LEVEL=info
|
|
140
|
+
|
|
141
|
+
# ─── Rate Limiting ────────────────────────────────────────
|
|
142
|
+
RATE_LIMIT_WINDOW_MS=60000
|
|
143
|
+
RATE_LIMIT_MAX=100
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
### Task 5 — Write a `src/test.js` smoke test
|
|
149
|
+
|
|
150
|
+
Simple script that:
|
|
151
|
+
1. Starts the server on port 3001
|
|
152
|
+
2. Makes a `GET /health` request — asserts 200 + `{ status: "ok" }`
|
|
153
|
+
3. Makes a `POST /swap/assets` request — asserts array of assets returned
|
|
154
|
+
4. Makes a `POST /swap/quote` with `{ fromAsset: "ETH.ETH", toAsset: "BTC.BTC", amount: "0.1" }` — asserts response has `expectedOutput`
|
|
155
|
+
5. Stops the server
|
|
156
|
+
6. Prints PASS/FAIL for each check
|
|
157
|
+
|
|
158
|
+
No external test framework — plain Node with `assert`.
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
### Task 6 — Update `README.md` (product-grade)
|
|
163
|
+
|
|
164
|
+
The existing README is in `deploy/README.md` (Railway guide only). Create a top-level `README.md` with:
|
|
165
|
+
|
|
166
|
+
1. **What it does** — 2-paragraph product description; mention THORChain routing, affiliate fee model, agent-to-agent use case
|
|
167
|
+
2. **Quick start** (local):
|
|
168
|
+
```bash
|
|
169
|
+
git clone ...
|
|
170
|
+
cd crypto-swap-agent
|
|
171
|
+
cp .env.example .env
|
|
172
|
+
# Fill in SWAPKIT_API_KEY and FEE_RECIPIENT_ADDRESS
|
|
173
|
+
npm install
|
|
174
|
+
npm start
|
|
175
|
+
# Server at http://localhost:3000
|
|
176
|
+
```
|
|
177
|
+
3. **API reference** — table of endpoints with example request/response
|
|
178
|
+
4. **Environment variables** — table (copy from .env.example)
|
|
179
|
+
5. **Deploy to Railway** — 3-line summary with link to `deploy/README.md`
|
|
180
|
+
6. **Revenue model** — explain the 0.5% affiliate fee mechanism
|
|
181
|
+
7. **Using as an OpenClaw skill** — point to SKILL.md
|
|
182
|
+
8. **Cross-chain products** — placeholder section with links TBD (for future: Vantage HL trading agent link)
|
|
183
|
+
|
|
184
|
+
---
|
|
185
|
+
|
|
186
|
+
## What NOT to do
|
|
187
|
+
|
|
188
|
+
- Do NOT rewrite `swapkit.js`, `wallet.js`, `parser.js`, or `formatter.js`
|
|
189
|
+
- Do NOT add a database or any stateful storage
|
|
190
|
+
- Do NOT add authentication/API keys for callers (v2 scope)
|
|
191
|
+
- Do NOT implement x402 (v2 scope)
|
|
192
|
+
- Do NOT remove the `deploy/README.md` (keep the Railway guide)
|
|
193
|
+
- Do NOT hardcode any MoreBetter agent names in user-facing output
|
|
194
|
+
|
|
195
|
+
---
|
|
196
|
+
|
|
197
|
+
## Output Required
|
|
198
|
+
|
|
199
|
+
When complete, confirm:
|
|
200
|
+
1. `npm start` → server starts, `/health` returns 200
|
|
201
|
+
2. `npm test` → all smoke tests pass (needs real SWAPKIT_API_KEY to test quote)
|
|
202
|
+
3. List all files created or modified with brief description
|
|
203
|
+
|
|
204
|
+
Then update your workspace memory with what was done.
|
|
205
|
+
|
|
206
|
+
---
|
|
207
|
+
|
|
208
|
+
## Keys (to be filled in by Daksh after SreeMaan provides them)
|
|
209
|
+
|
|
210
|
+
```
|
|
211
|
+
SWAPKIT_API_KEY= ← pending SreeMaan
|
|
212
|
+
FEE_RECIPIENT_ADDRESS= ← pending SreeMaan (thor1... address)
|
|
213
|
+
EVM_RPC_URL= ← pending SreeMaan (Alchemy)
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
Product name: **TBD** — SreeMaan choosing. Update `package.json` name and README title when confirmed.
|
package/README.md
ADDED
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
# FORGE — Cross-Chain Swap Agent
|
|
2
|
+
|
|
3
|
+
A production-ready HTTP API for cross-chain token swaps via THORChain. It routes swap quotes and executes transactions through THORNode directly — no centralised exchange, no custodian. Designed for agent-to-agent use: any AI agent or automated system can POST a swap request and receive back the deposit memo and vault address needed to execute on-chain.
|
|
4
|
+
|
|
5
|
+
Every swap routed through this service collects a 0.5% affiliate fee to a configurable THORChain address, making it a self-sustaining revenue-generating infrastructure component. Fees are embedded directly in the THORChain memo and settled natively by the protocol — no invoicing, no off-chain reconciliation.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Quick Start (local)
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
git clone <your-repo-url>
|
|
13
|
+
cd crypto-swap-agent
|
|
14
|
+
cp .env.example .env
|
|
15
|
+
# Fill in FEE_RECIPIENT_ADDRESS (your thor1... address)
|
|
16
|
+
npm install
|
|
17
|
+
npm start
|
|
18
|
+
# Server at http://localhost:3000
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## API Reference
|
|
24
|
+
|
|
25
|
+
### `GET /health`
|
|
26
|
+
|
|
27
|
+
Service health check. Used by Railway and uptime monitors.
|
|
28
|
+
|
|
29
|
+
**Response:**
|
|
30
|
+
```json
|
|
31
|
+
{ "status": "ok", "version": "0.1.0", "timestamp": "2026-03-14T00:00:00.000Z" }
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
### `POST /swap/quote`
|
|
37
|
+
|
|
38
|
+
Get a swap quote with affiliate fee included.
|
|
39
|
+
|
|
40
|
+
**Request body:**
|
|
41
|
+
```json
|
|
42
|
+
{
|
|
43
|
+
"fromAsset": "ETH.ETH",
|
|
44
|
+
"toAsset": "BTC.BTC",
|
|
45
|
+
"amount": "0.1"
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
**Response:**
|
|
50
|
+
```json
|
|
51
|
+
{
|
|
52
|
+
"fromAsset": "ETH.ETH",
|
|
53
|
+
"toAsset": "BTC.BTC",
|
|
54
|
+
"amount": "0.1",
|
|
55
|
+
"expectedOutput": "0.00315",
|
|
56
|
+
"expectedOutputMinusFees": "0.00312",
|
|
57
|
+
"affiliateFee": "0.5%",
|
|
58
|
+
"route": ["THORChain"],
|
|
59
|
+
"slippage": "0.50%",
|
|
60
|
+
"expiresAt": "2026-03-14T00:00:30.000Z"
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
### `POST /swap/execute`
|
|
67
|
+
|
|
68
|
+
Build swap transaction data. Returns the memo and deposit address for on-chain execution.
|
|
69
|
+
|
|
70
|
+
**Request body:**
|
|
71
|
+
```json
|
|
72
|
+
{
|
|
73
|
+
"fromAsset": "ETH.ETH",
|
|
74
|
+
"toAsset": "BTC.BTC",
|
|
75
|
+
"amount": "0.1",
|
|
76
|
+
"destinationAddress": "bc1q..."
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
**Response:**
|
|
81
|
+
```json
|
|
82
|
+
{
|
|
83
|
+
"status": "pending_signature",
|
|
84
|
+
"memo": "=:BTC.BTC:bc1q...:0/3/0:thor1ab12:50",
|
|
85
|
+
"depositAsset": "ETH.ETH",
|
|
86
|
+
"depositAmount": 0.1,
|
|
87
|
+
"depositAddress": "0xTHORVault...",
|
|
88
|
+
"expectedOutput": "0.00312",
|
|
89
|
+
"route": ["THORChain"],
|
|
90
|
+
"affiliateFee": "0.5%",
|
|
91
|
+
"warning": "Wallet signing required — call wallet.sign(swapData) to execute"
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
### `GET /swap/status?txHash=<hash>`
|
|
98
|
+
|
|
99
|
+
Check the status of a submitted swap transaction via Midgard.
|
|
100
|
+
|
|
101
|
+
**Response:** Raw Midgard `v2/actions` response for the tx.
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
### `GET /swap/assets`
|
|
106
|
+
|
|
107
|
+
List all supported assets (THORChain pools via Midgard).
|
|
108
|
+
|
|
109
|
+
**Response:** Array of pool/asset objects.
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## MCP Integration
|
|
114
|
+
|
|
115
|
+
FORGE exposes a [Model Context Protocol](https://modelcontextprotocol.io) server at `/mcp` using Streamable HTTP transport (2026 spec).
|
|
116
|
+
|
|
117
|
+
Any MCP-compatible AI agent (Claude, GPT, Cursor, etc.) can discover and call FORGE natively.
|
|
118
|
+
|
|
119
|
+
**Endpoint:** `POST /mcp`
|
|
120
|
+
**Discovery:** `GET /.well-known/mcp.json`
|
|
121
|
+
|
|
122
|
+
**Available tools:** `forge_quote`, `forge_execute`, `forge_assets`, `forge_status`
|
|
123
|
+
|
|
124
|
+
**Claude Desktop config:**
|
|
125
|
+
```json
|
|
126
|
+
{
|
|
127
|
+
"mcpServers": {
|
|
128
|
+
"forge": {
|
|
129
|
+
"url": "https://forge.morebetterstudios.com/mcp",
|
|
130
|
+
"transport": "streamable-http"
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
**Why MCP:** Enables zero-friction discovery and calling by any frontier AI agent without API key registration or custom integration.
|
|
137
|
+
|
|
138
|
+
## Environment Variables
|
|
139
|
+
|
|
140
|
+
| Variable | Required | Default | Description |
|
|
141
|
+
|---|---|---|---|
|
|
142
|
+
| `FEE_RECIPIENT_ADDRESS` | Yes | — | THORChain `thor1...` address for affiliate fee collection |
|
|
143
|
+
| `SWAP_FEE_BPS` | No | `50` | Fee in basis points (50 = 0.5%) |
|
|
144
|
+
| `WALLET_PRIVATE_KEY` | No | — | EVM private key for autonomous swap execution |
|
|
145
|
+
| `EVM_RPC_URL` | No | — | Alchemy/Infura RPC URL for EVM signing |
|
|
146
|
+
| `PORT` | No | `3000` | HTTP port |
|
|
147
|
+
| `NODE_ENV` | No | `production` | Node environment |
|
|
148
|
+
| `ALLOWED_ORIGINS` | No | `*` | CORS allowed origins |
|
|
149
|
+
| `LOG_LEVEL` | No | `info` | Logging verbosity |
|
|
150
|
+
| `RATE_LIMIT_WINDOW_MS` | No | `60000` | Rate limit window in ms |
|
|
151
|
+
| `RATE_LIMIT_MAX` | No | `100` | Max requests per window |
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
## Deploy to Railway
|
|
156
|
+
|
|
157
|
+
1. Push to GitHub
|
|
158
|
+
2. Connect repo at [railway.app/new](https://railway.app/new)
|
|
159
|
+
3. Set environment variables in Railway Dashboard → Variables
|
|
160
|
+
|
|
161
|
+
Full Railway deployment guide: [deploy/README.md](deploy/README.md)
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
## Revenue Model
|
|
166
|
+
|
|
167
|
+
Every swap routed through this agent includes a 0.5% affiliate fee (configurable via `SWAP_FEE_BPS`). The fee address (`FEE_RECIPIENT_ADDRESS`) must be a valid THORChain `thor1...` address.
|
|
168
|
+
|
|
169
|
+
The fee is embedded in the THORChain memo at the protocol level:
|
|
170
|
+
```
|
|
171
|
+
=:BTC.BTC:bc1q...:0/3/0:thor1xxxx:50
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
THORChain nodes enforce and distribute this fee natively — there is no off-chain settlement or trust assumption. At current volumes, each basis point of fee on a $10k swap = $1 in RUNE credited to your address.
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
## Using as an OpenClaw Skill
|
|
179
|
+
|
|
180
|
+
This service is packaged as an OpenClaw skill. See [SKILL.md](SKILL.md) for the skill definition and invocation instructions.
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
## Cross-Chain Products
|
|
185
|
+
|
|
186
|
+
Additional trading agent integrations coming soon:
|
|
187
|
+
|
|
188
|
+
- **Vantage HL** — Hyperliquid perpetuals trading agent (link TBD)
|
|
189
|
+
- Additional DEX/CEX routing integrations (TBD)
|
package/SKILL.md
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: forge
|
|
3
|
+
description: Cross-chain swap routing via THORChain. Get quotes and build swap transactions across 44+ assets (BTC, ETH, RUNE, AVAX, USDC and more). Non-custodial — returns vault address and memo, user's wallet executes. 0.5% affiliate fee to forgemb on every routed swap.
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
author: MoreBetter Studios
|
|
6
|
+
homepage: https://morebetterstudios.com
|
|
7
|
+
repository: https://github.com/morebetterclaw/forge
|
|
8
|
+
api: https://forge-api-production-50de.up.railway.app
|
|
9
|
+
mcp: https://forge-api-production-50de.up.railway.app/mcp
|
|
10
|
+
tags:
|
|
11
|
+
- crypto
|
|
12
|
+
- defi
|
|
13
|
+
- thorchain
|
|
14
|
+
- swap
|
|
15
|
+
- cross-chain
|
|
16
|
+
- bitcoin
|
|
17
|
+
- ethereum
|
|
18
|
+
- rune
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
# FORGE — Cross-Chain Swap Agent
|
|
22
|
+
|
|
23
|
+
Non-custodial cross-chain swaps powered by THORChain. Routes quotes across 44+ assets via the THORNode API directly. Every swap embeds a 0.5% affiliate fee to `forgemb` — protocol-native, trustless, settled in RUNE.
|
|
24
|
+
|
|
25
|
+
## Live API
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
Base: https://forge-api-production-50de.up.railway.app
|
|
29
|
+
MCP: https://forge-api-production-50de.up.railway.app/mcp
|
|
30
|
+
Discovery: https://forge-api-production-50de.up.railway.app/.well-known/mcp.json
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## MCP Tools (Claude Desktop / Cursor / any MCP client)
|
|
34
|
+
|
|
35
|
+
```json
|
|
36
|
+
{
|
|
37
|
+
"mcpServers": {
|
|
38
|
+
"forge": {
|
|
39
|
+
"url": "https://forge-api-production-50de.up.railway.app/mcp",
|
|
40
|
+
"transport": "streamable-http"
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
**Tools:** `forge_quote` · `forge_execute` · `forge_assets` · `forge_status`
|
|
47
|
+
|
|
48
|
+
## REST API
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
# Get a quote
|
|
52
|
+
curl -X POST https://forge-api-production-50de.up.railway.app/swap/quote \
|
|
53
|
+
-H "Content-Type: application/json" \
|
|
54
|
+
-d '{"fromAsset":"ETH.ETH","toAsset":"BTC.BTC","amount":"0.1"}'
|
|
55
|
+
|
|
56
|
+
# Build swap transaction (returns vault address + memo — no funds sent)
|
|
57
|
+
curl -X POST https://forge-api-production-50de.up.railway.app/swap/execute \
|
|
58
|
+
-H "Content-Type: application/json" \
|
|
59
|
+
-d '{"fromAsset":"ETH.ETH","toAsset":"THOR.RUNE","amount":"0.05","destinationAddress":"thor1..."}'
|
|
60
|
+
|
|
61
|
+
# List supported assets
|
|
62
|
+
curl https://forge-api-production-50de.up.railway.app/swap/assets
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## How It Works
|
|
66
|
+
|
|
67
|
+
1. Call `/swap/execute` with from/to asset and destination address
|
|
68
|
+
2. FORGE returns a **vault deposit address** and **THORChain memo**
|
|
69
|
+
3. User's wallet sends funds to vault address with memo as calldata
|
|
70
|
+
4. THORChain protocol routes the swap — FORGE never holds funds
|
|
71
|
+
5. `forgemb` earns 0.5% affiliate fee embedded in the memo, settled natively
|
|
72
|
+
|
|
73
|
+
## Asset Format
|
|
74
|
+
|
|
75
|
+
Assets use `CHAIN.TICKER` format:
|
|
76
|
+
- `ETH.ETH` — Ethereum native
|
|
77
|
+
- `BTC.BTC` — Bitcoin
|
|
78
|
+
- `THOR.RUNE` — THORChain native
|
|
79
|
+
- `AVAX.AVAX` — Avalanche native
|
|
80
|
+
- `ETH.USDC-0xA0b86...` — ERC-20 tokens include contract address
|
|
81
|
+
|
|
82
|
+
## Environment Variables (self-hosted)
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
FEE_RECIPIENT_ADDRESS=forgemb # THORName or thor1... address for affiliate fees
|
|
86
|
+
SWAP_FEE_BPS=50 # 50 = 0.5%
|
|
87
|
+
PORT=3000
|
|
88
|
+
ALLOWED_ORIGINS=*
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Revenue Model
|
|
92
|
+
|
|
93
|
+
Every swap routed through FORGE earns 0.5% to `forgemb` (THORChain name for `thor1yfrfgjgnzkjqqgv02yxn3j3kv50pe0rnhvs8zw`). Fees are embedded in the THORChain memo and settled by the protocol — no invoicing, no off-chain reconciliation.
|