@goplausible/openclaw-algorand-plugin 1.1.0 → 1.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/openclaw.plugin.json +4 -2
- package/package.json +1 -1
- package/skills/algorand-interaction/SKILL.md +4 -2
- package/skills/algorand-interaction/references/algorand-mcp.md +49 -2
- package/skills/algorand-interaction/references/examples-algorand-mcp.md +49 -0
- package/skills/haystack-router-development/SKILL.md +85 -0
- package/skills/haystack-router-development/references/api-reference.md +381 -0
- package/skills/haystack-router-development/references/configuration.md +184 -0
- package/skills/haystack-router-development/references/fees-and-referrals.md +91 -0
- package/skills/haystack-router-development/references/getting-started.md +93 -0
- package/skills/haystack-router-development/references/migration.md +53 -0
- package/skills/haystack-router-development/references/node-automation.md +113 -0
- package/skills/haystack-router-development/references/quotes.md +155 -0
- package/skills/haystack-router-development/references/react-integration.md +260 -0
- package/skills/haystack-router-development/references/swaps.md +161 -0
- package/skills/haystack-router-interaction/SKILL.md +146 -0
- package/skills/haystack-router-interaction/references/configuration.md +53 -0
- package/skills/haystack-router-interaction/references/getting-started.md +48 -0
- package/skills/haystack-router-interaction/references/node-automation.md +51 -0
- package/skills/haystack-router-interaction/references/quotes.md +80 -0
- package/skills/haystack-router-interaction/references/swaps.md +84 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Node.js Automation (Algorand MCP)
|
|
2
|
+
|
|
3
|
+
Automate swaps using Algorand MCP tools. The `api_haystack_execute_swap` tool handles quoting, signing, and submission in one call.
|
|
4
|
+
|
|
5
|
+
## Single Swap
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
1. wallet_get_info { network: "testnet" }
|
|
9
|
+
→ Get address and confirm ALGO balance is sufficient
|
|
10
|
+
|
|
11
|
+
2. api_haystack_needs_optin { address, assetId: 31566704, network: "testnet" }
|
|
12
|
+
→ Check if output asset needs opt-in
|
|
13
|
+
|
|
14
|
+
3. (If needsOptIn) wallet_optin_asset { assetId: 31566704, network: "testnet" }
|
|
15
|
+
→ Opt into output asset
|
|
16
|
+
|
|
17
|
+
4. api_haystack_get_swap_quote {
|
|
18
|
+
fromASAID: 0, toASAID: 31566704, amount: 1000000,
|
|
19
|
+
address: "<wallet_address>", network: "testnet"
|
|
20
|
+
}
|
|
21
|
+
→ Preview quote → confirm with user
|
|
22
|
+
|
|
23
|
+
5. api_haystack_execute_swap {
|
|
24
|
+
fromASAID: 0, toASAID: 31566704, amount: 1000000,
|
|
25
|
+
slippage: 1, note: "order-123", network: "testnet"
|
|
26
|
+
}
|
|
27
|
+
→ Signs via wallet, submits, waits for confirmation
|
|
28
|
+
→ Returns: confirmedRound, txIds, summary with exact amounts
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Batch Swaps
|
|
32
|
+
|
|
33
|
+
For multiple sequential swaps, repeat steps 4–5 for each pair:
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
Swap pairs example:
|
|
37
|
+
- 0 → 31566704, amount: 1000000 (1 ALGO → USDC)
|
|
38
|
+
- 0 → 312769, amount: 2000000 (2 ALGO → USDt)
|
|
39
|
+
|
|
40
|
+
For each pair:
|
|
41
|
+
→ api_haystack_get_swap_quote { ... } → show user
|
|
42
|
+
→ api_haystack_execute_swap { ... } → execute after confirmation
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Key Rules
|
|
46
|
+
|
|
47
|
+
- **Use `api_haystack_execute_swap`** — it handles signing via the active wallet
|
|
48
|
+
- **Always confirm each swap with the user** before executing
|
|
49
|
+
- **Each execute call gets a fresh quote** — no stale quote issues
|
|
50
|
+
- **Check opt-in** before first swap to a new ASA using `api_haystack_needs_optin`
|
|
51
|
+
- **Default to testnet** unless user explicitly requests mainnet
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# Quotes
|
|
2
|
+
|
|
3
|
+
## Getting a Quote
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
→ api_haystack_get_swap_quote {
|
|
7
|
+
fromASAID: 0, // ALGO
|
|
8
|
+
toASAID: 31566704, // USDC
|
|
9
|
+
amount: 1000000, // 1 ALGO in base units
|
|
10
|
+
type: "fixed-input", // or "fixed-output"
|
|
11
|
+
address: "<wallet_address>", // optional, for opt-in detection
|
|
12
|
+
network: "mainnet"
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
Response includes:
|
|
16
|
+
- expectedOutput: output amount in base units
|
|
17
|
+
- inputAmount: original input amount
|
|
18
|
+
- usdIn / usdOut: USD values
|
|
19
|
+
- userPriceImpact: price impact percentage
|
|
20
|
+
- route: detailed routing path
|
|
21
|
+
- flattenedRoute: protocol split percentages (e.g., "TinymanV2: 60%", "Pact: 40%")
|
|
22
|
+
- requiredAppOptIns: app IDs needing opt-in
|
|
23
|
+
- protocolFees: fee breakdown
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Parameters
|
|
27
|
+
|
|
28
|
+
| Parameter | Type | Required | Description |
|
|
29
|
+
| -------------- | -------- | -------- | ----------------------------------------------- |
|
|
30
|
+
| `fromASAID` | `number` | Yes | Input asset ID (0 = ALGO) |
|
|
31
|
+
| `toASAID` | `number` | Yes | Output asset ID |
|
|
32
|
+
| `amount` | `number` | Yes | Amount in base units |
|
|
33
|
+
| `type` | `string` | No | `"fixed-input"` (default) or `"fixed-output"` |
|
|
34
|
+
| `address` | `string` | No | User address (for opt-in detection) |
|
|
35
|
+
| `maxGroupSize` | `number` | No | Max transactions in group (default: 16) |
|
|
36
|
+
| `maxDepth` | `number` | No | Max routing hops (default: 4) |
|
|
37
|
+
| `network` | `string` | No | `"mainnet"` (default) or `"testnet"` |
|
|
38
|
+
|
|
39
|
+
## Quote Types
|
|
40
|
+
|
|
41
|
+
**Fixed-input** (default): Specify exact input amount, receive variable output.
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
→ api_haystack_get_swap_quote {
|
|
45
|
+
fromASAID: 0, toASAID: 31566704,
|
|
46
|
+
amount: 1000000, // Exact: send 1 ALGO
|
|
47
|
+
type: "fixed-input", network: "mainnet"
|
|
48
|
+
}
|
|
49
|
+
// expectedOutput = USDC to receive
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
**Fixed-output**: Specify desired output, send variable input.
|
|
53
|
+
|
|
54
|
+
```
|
|
55
|
+
→ api_haystack_get_swap_quote {
|
|
56
|
+
fromASAID: 0, toASAID: 31566704,
|
|
57
|
+
amount: 1000000, // Exact: receive 1 USDC
|
|
58
|
+
type: "fixed-output", network: "mainnet"
|
|
59
|
+
}
|
|
60
|
+
// inputAmount = ALGO required to send
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Asset Opt-In Detection
|
|
64
|
+
|
|
65
|
+
Use the dedicated `api_haystack_needs_optin` tool to check:
|
|
66
|
+
|
|
67
|
+
```
|
|
68
|
+
1. api_haystack_needs_optin { address: "<address>", assetId: <toASAID>, network }
|
|
69
|
+
→ Returns { needsOptIn: true/false }
|
|
70
|
+
|
|
71
|
+
2. If needsOptIn is true:
|
|
72
|
+
→ wallet_optin_asset { assetId: <toASAID>, network }
|
|
73
|
+
→ This handles build, sign, and submit in one step
|
|
74
|
+
|
|
75
|
+
3. Then proceed with quote or execute:
|
|
76
|
+
→ api_haystack_get_swap_quote { fromASAID, toASAID, amount, address, network }
|
|
77
|
+
→ api_haystack_execute_swap { fromASAID, toASAID, amount, slippage, network }
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Note: `api_haystack_execute_swap` automatically handles opt-in detection when the RouterClient is configured with `autoOptIn: true` (default for Algorand MCP tools).
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# Swaps
|
|
2
|
+
|
|
3
|
+
The `api_haystack_execute_swap` tool handles the entire swap lifecycle: quoting, signing (via active wallet), submission, and confirmation — all in one call. **No manual signing or transaction assembly needed.**
|
|
4
|
+
|
|
5
|
+
## Quick Swap (Single Tool)
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
→ api_haystack_execute_swap {
|
|
9
|
+
fromASAID: 0, // ALGO
|
|
10
|
+
toASAID: 31566704, // USDC
|
|
11
|
+
amount: 1000000, // 1 ALGO in base units
|
|
12
|
+
slippage: 1, // 1% tolerance
|
|
13
|
+
network: "mainnet"
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
Returns:
|
|
17
|
+
status: "confirmed"
|
|
18
|
+
confirmedRound: "12345678"
|
|
19
|
+
txIds: ["TXID1...", "TXID2...", ...]
|
|
20
|
+
signer: "<wallet_address>"
|
|
21
|
+
nickname: "<account_nickname>"
|
|
22
|
+
quote: { expectedOutput, usdIn, usdOut, userPriceImpact, route }
|
|
23
|
+
summary: { inputAmount, outputAmount, totalFees, transactionCount }
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Complete Workflow (with preview)
|
|
27
|
+
|
|
28
|
+
For best UX, preview the quote before executing:
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
1. Check wallet state
|
|
32
|
+
→ wallet_get_info { network: "mainnet" }
|
|
33
|
+
→ Note the address and ALGO balance
|
|
34
|
+
|
|
35
|
+
2. Check output asset opt-in (skip for ALGO)
|
|
36
|
+
→ api_haystack_needs_optin { address, assetId: 31566704, network: "mainnet" }
|
|
37
|
+
→ If needsOptIn is true:
|
|
38
|
+
→ wallet_optin_asset { assetId: 31566704, network: "mainnet" }
|
|
39
|
+
|
|
40
|
+
3. Preview quote (show user before executing)
|
|
41
|
+
→ api_haystack_get_swap_quote {
|
|
42
|
+
fromASAID: 0, toASAID: 31566704, amount: 1000000,
|
|
43
|
+
address: "<wallet_address>", network: "mainnet"
|
|
44
|
+
}
|
|
45
|
+
→ Present to user: expected output, USD values, route, price impact
|
|
46
|
+
|
|
47
|
+
4. User confirms → Execute (all-in-one)
|
|
48
|
+
→ api_haystack_execute_swap {
|
|
49
|
+
fromASAID: 0, toASAID: 31566704, amount: 1000000,
|
|
50
|
+
slippage: 1, network: "mainnet"
|
|
51
|
+
}
|
|
52
|
+
→ Returns confirmed result with exact summary
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Important Rules
|
|
56
|
+
|
|
57
|
+
- **Always check wallet first** — Use `wallet_get_info` to confirm address, balance, and network
|
|
58
|
+
- **Always confirm with user** — Show quote details and ask for confirmation before executing
|
|
59
|
+
- **Use `api_haystack_execute_swap`** — It handles signing via the active wallet account
|
|
60
|
+
- **Check opt-in for ASAs** — Use `api_haystack_needs_optin` + `wallet_optin_asset` if needed
|
|
61
|
+
- **Default to testnet** — Unless user explicitly requests mainnet
|
|
62
|
+
- **Handle quote staleness** — Quotes are time-sensitive; execute promptly after user confirms
|
|
63
|
+
|
|
64
|
+
## Slippage Guidance
|
|
65
|
+
|
|
66
|
+
| Pair Type | Recommended Slippage |
|
|
67
|
+
| ----------------- | -------------------- |
|
|
68
|
+
| Stable pairs | 0.5–1% |
|
|
69
|
+
| Volatile pairs | 1–3% |
|
|
70
|
+
| Low liquidity | 3–5% |
|
|
71
|
+
|
|
72
|
+
Slippage is verified on the **final output** of the swap, not individual hops.
|
|
73
|
+
|
|
74
|
+
## Error Handling
|
|
75
|
+
|
|
76
|
+
Common errors:
|
|
77
|
+
|
|
78
|
+
- **Slippage exceeded** — price moved beyond tolerance, refetch quote
|
|
79
|
+
- **Insufficient balance** — check with `wallet_get_info`
|
|
80
|
+
- **Asset not opted in** — use `wallet_optin_asset`
|
|
81
|
+
- **Transaction rejected** — user declined or signing failed
|
|
82
|
+
- **Network timeout** — retry after brief delay
|
|
83
|
+
|
|
84
|
+
Quotes are time-sensitive. If a quote is stale (prices moved significantly), refetch before executing.
|