@hypurrquant/defi-cli 1.0.10 → 1.0.12
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/dist/index.js +335 -70
- package/dist/index.js.map +1 -1
- package/dist/main.js +335 -70
- package/dist/main.js.map +1 -1
- package/dist/mcp-server.js +31 -6
- package/dist/mcp-server.js.map +1 -1
- package/package.json +1 -1
- package/skills/defi-cli/SKILL.md +37 -1
- package/skills/defi-cli/package.json +1 -1
- package/skills/defi-cli/references/commands.md +39 -6
- package/skills/defi-cli/scripts/bridge-quote.sh +34 -0
- package/skills/defi-cli/scripts/lending-supply-flow.sh +28 -0
- package/skills/defi-cli/scripts/lp-claim-all.sh +25 -0
- package/skills/defi-cli/scripts/lp-emission-discover.sh +20 -0
- package/skills/defi-cli/scripts/portfolio-snapshot.sh +0 -0
- package/skills/defi-cli/scripts/preflight.sh +0 -0
- package/skills/defi-cli/scripts/swap-quote.sh +37 -0
- package/skills/defi-cli/scripts/wallet-status.sh +30 -0
- package/skills/defi-cli/scripts/yield-scan.sh +0 -0
- package/skills/defi-cli/scripts/exploit-scan.sh +0 -10
package/package.json
CHANGED
package/skills/defi-cli/SKILL.md
CHANGED
|
@@ -5,7 +5,7 @@ allowed-tools: "Bash(defi:*), Bash(npx defi-cli:*), Bash(npx -y defi-cli:*)"
|
|
|
5
5
|
license: MIT
|
|
6
6
|
metadata:
|
|
7
7
|
author: hypurrquant
|
|
8
|
-
version: "1.0.
|
|
8
|
+
version: "1.0.11"
|
|
9
9
|
---
|
|
10
10
|
|
|
11
11
|
# defi-cli Agent Guide
|
|
@@ -59,6 +59,29 @@ export DEFI_PRIVATE_KEY=0xYourPrivateKey # only needed for broadcasting
|
|
|
59
59
|
|
|
60
60
|
🟢 = mainnet broadcast verified | 🟡 = configs verified, awaiting funded broadcast
|
|
61
61
|
|
|
62
|
+
## References
|
|
63
|
+
|
|
64
|
+
- **`references/protocols.md`** — full protocol slug catalog per chain (39 protocols across 5 chains)
|
|
65
|
+
- **`references/commands.md`** — every CLI command with flags, dry-run shape, and JSON envelope notes
|
|
66
|
+
|
|
67
|
+
## Scripts (`scripts/`)
|
|
68
|
+
|
|
69
|
+
Copy-paste runnable usage recipes. Each script honours `DEFI_CMD` (override the binary name, e.g. `DEFI_CMD="npx -y -p @hypurrquant/defi-cli@latest defi"`) and emits JSON on stdout, status on stderr.
|
|
70
|
+
|
|
71
|
+
| Script | What it does | Invocation |
|
|
72
|
+
|---|---|---|
|
|
73
|
+
| `preflight.sh` | Verify install + wallet env | `bash preflight.sh` |
|
|
74
|
+
| `yield-scan.sh` | Best supply APY across all chains | `ASSET=USDC bash yield-scan.sh` |
|
|
75
|
+
| `lp-emission-discover.sh` | Active emission pools sorted by APR | `bash lp-emission-discover.sh mantle merchantmoe-mantle` |
|
|
76
|
+
| `swap-quote.sh` | Compare every supported aggregator (dry-run) | `CHAIN=base FROM=WETH TO=USDC AMOUNT=10000000000000000 bash swap-quote.sh` |
|
|
77
|
+
| `bridge-quote.sh` | Compare LI.FI / deBridge / CCTP (dry-run) | `FROM_CHAIN=base TO_CHAIN=arbitrum TOKEN=USDC AMOUNT=100000000 bash bridge-quote.sh` |
|
|
78
|
+
| `lending-supply-flow.sh` | yield → rates → position → dry-run supply | `CHAIN=hyperevm PROTOCOL=hyperlend ASSET=USDC AMOUNT=1000000 bash lending-supply-flow.sh` |
|
|
79
|
+
| `lp-claim-all.sh` | List all LP positions + claim CLI hints | `WALLET=0xABC… bash lp-claim-all.sh mantle` |
|
|
80
|
+
| `portfolio-snapshot.sh` | Snapshot + PnL for a wallet | `WALLET=0xABC… bash portfolio-snapshot.sh hyperevm` |
|
|
81
|
+
| `wallet-status.sh` | Resolved wallet + native balance per chain | `bash wallet-status.sh` |
|
|
82
|
+
|
|
83
|
+
All `*-quote.sh` and `lending-supply-flow.sh` scripts are **dry-run only** — they never touch `--broadcast`. Add `--broadcast` to the printed CLI yourself after user confirmation.
|
|
84
|
+
|
|
62
85
|
## Protocol Slugs by Chain
|
|
63
86
|
|
|
64
87
|
For full protocol list see `references/protocols.md`. High-level summary:
|
|
@@ -166,6 +189,19 @@ Bridge **source** must be a supported chain (hyperevm/mantle/base/bnb/monad). Br
|
|
|
166
189
|
| `No fees to compound` | V3 position has no accumulated fees yet — wait for swaps to cross range |
|
|
167
190
|
| `No pools found` | protocol may be inactive on this chain or discover branch missing config |
|
|
168
191
|
| `DEFI_WALLET_ADDRESS not set` | set env var or pass `--address` |
|
|
192
|
+
| `tokenId X has zero liquidity` | NFT position already removed; verify with `lp positions` |
|
|
193
|
+
| `failed_probes[]` in yield output | RPC transport failure (not "asset unsupported"); set `<CHAIN>_RPC_URL` and retry |
|
|
194
|
+
| `WARNING: no wallet configured` on stderr | dry-run preview using placeholder `0x000…001`; do **NOT** pass `--broadcast` until wallet is set |
|
|
195
|
+
|
|
196
|
+
## Recent Behaviour Notes (v1.0.5 → v1.0.11 + post-release fixes)
|
|
197
|
+
|
|
198
|
+
- **`lp remove` (V3 / Slipstream / Hybra / Algebra)** — pass only `--token-id`; `--token-a/--token-b/--liquidity` are optional. Liquidity is read from `NPM.positions(tokenId)` automatically.
|
|
199
|
+
- **`schema <action>`** accepts hyphenated names (`schema lending-supply` ≡ `schema lending.supply`).
|
|
200
|
+
- **`yield optimize` / `yield compare`** distinguishes "no opportunities" from "RPC failed" — failure surfaces a `failed_probes[]` envelope with per-protocol reason and a hint to set `<CHAIN>_RPC_URL`.
|
|
201
|
+
- **`portfolio show` / `snapshot`** prices each asset via its own oracle (ERC20s no longer mispriced at the native rate) and includes the native gas-token balance in `total_value_usd`.
|
|
202
|
+
- **`wallet address`** with no wallet returns `{ "address": null, "source": "none" }` (machine-parseable; the legacy `"(not set)"` sentinel is gone).
|
|
203
|
+
- **`bridge --provider cctp`** below the protocol min-fee returns a structured error envelope with `minimum_amount_wei` / `minimum_amount_usdc` (no broadcast attempt).
|
|
204
|
+
- **`setup`** masks API keys when displaying RPC URLs and suppresses key-echo when prompting for a private key; only `http://`/`https://` URLs are accepted.
|
|
169
205
|
|
|
170
206
|
## Examples
|
|
171
207
|
|
|
@@ -11,6 +11,8 @@ All amounts are in **wei** unless noted. USDC/USDT/USDT0 use 6 decimals; native
|
|
|
11
11
|
defi --json status # current chain protocols
|
|
12
12
|
defi --json --chain mantle status # Mantle protocols + addresses
|
|
13
13
|
defi --json schema # full CLI schema as JSON
|
|
14
|
+
defi --json schema lending.supply # one action's params + cli example
|
|
15
|
+
defi --json schema lending-supply # hyphenated form also works (post-v1.0.11)
|
|
14
16
|
```
|
|
15
17
|
|
|
16
18
|
## Yield (read-only, safe)
|
|
@@ -21,6 +23,11 @@ defi --json --chain mantle yield compare --asset USDT
|
|
|
21
23
|
defi --json yield optimize --asset USDC --amount 100000000 # diversification plan
|
|
22
24
|
```
|
|
23
25
|
|
|
26
|
+
**Failure shape (post-v1.0.11)**: when every RPC probe fails, the command no longer pretends "no opportunities found" — it returns:
|
|
27
|
+
```json
|
|
28
|
+
{ "error": "...", "failed_probes": [{ "protocol": "aave-v3-mantle", "type": "lending", "reason": "..." }], "hint": "Set MANTLE_RPC_URL=..." }
|
|
29
|
+
```
|
|
30
|
+
|
|
24
31
|
## Price (read-only, safe)
|
|
25
32
|
|
|
26
33
|
```bash
|
|
@@ -125,19 +132,21 @@ Collects accrued fees and re-adds them as liquidity in one tx. V3 fee-only proto
|
|
|
125
132
|
### Remove Liquidity
|
|
126
133
|
|
|
127
134
|
```bash
|
|
128
|
-
# V3 / Slipstream (NFT-based)
|
|
129
|
-
|
|
130
|
-
|
|
135
|
+
# V3 / Slipstream / Algebra / Hybra (NFT-based) — only --token-id required
|
|
136
|
+
# Liquidity is read live from NPM.positions(tokenId); --liquidity overrides if passed
|
|
137
|
+
defi --json --chain <chain> lp remove --protocol <slug> --token-id <id> [--gauge <addr>]
|
|
131
138
|
|
|
132
139
|
# Solidly V2 (LP-token-based)
|
|
133
140
|
defi --json --chain <chain> lp remove --protocol <slug> \
|
|
134
141
|
--token-a <token> --token-b <token> --liquidity <wei> --gauge <addr>
|
|
135
142
|
|
|
136
|
-
# Liquidity Book (Merchant Moe / TraderJoe)
|
|
143
|
+
# Liquidity Book (Merchant Moe / TraderJoe) — pair flags + bins required
|
|
137
144
|
defi --json --chain <chain> lp remove --protocol <slug> \
|
|
138
145
|
--token-a <token> --token-b <token> --pool <addr> --bins <bin1>,<bin2>,...
|
|
139
146
|
```
|
|
140
147
|
|
|
148
|
+
If a V3/CL `--token-id` resolves to zero on-chain liquidity, the command surfaces `tokenId X has zero liquidity (already removed?)` instead of producing a no-op `decreaseLiquidity(0) + collect`.
|
|
149
|
+
|
|
141
150
|
### LP Positions
|
|
142
151
|
|
|
143
152
|
```bash
|
|
@@ -180,6 +189,8 @@ defi --json --chain <chain> portfolio snapshot [--address <addr>]
|
|
|
180
189
|
defi --json --chain <chain> portfolio pnl [--address <addr>]
|
|
181
190
|
```
|
|
182
191
|
|
|
192
|
+
**Pricing (post-v1.0.11)**: each ERC20 is priced via its own oracle (no longer the native asset's price). Native gas-token balance is fetched via `eth_getBalance` and included as `native_balance` / `native_value_usd` in the total. Tokens whose oracle returns 0 are omitted from the total instead of being mispriced. `snapshot` matches `show` to the cent.
|
|
193
|
+
|
|
183
194
|
## Token
|
|
184
195
|
|
|
185
196
|
```bash
|
|
@@ -195,10 +206,27 @@ defi --json --chain <chain> token transfer --token <token> --to <addr> --amount
|
|
|
195
206
|
## Wallet
|
|
196
207
|
|
|
197
208
|
```bash
|
|
198
|
-
defi --json wallet address
|
|
199
|
-
defi --json --chain <chain> wallet balance [--address <addr>]
|
|
209
|
+
defi --json wallet address # { "address": "0x…", "source": "ows|private_key|env|none" }
|
|
210
|
+
defi --json --chain <chain> wallet balance [--address <addr>] # native balance via eth_getBalance
|
|
200
211
|
```
|
|
201
212
|
|
|
213
|
+
`wallet address` returns `{ "address": null, "source": "none" }` when no wallet is configured (the legacy `"(not set)"` string sentinel is gone). Resolution precedence: `--address` flag → OWS vault (`DEFI_WALLET_ADDRESS=ows:<name>`) → `DEFI_PRIVATE_KEY` derived → plain `DEFI_WALLET_ADDRESS`.
|
|
214
|
+
|
|
215
|
+
### Wallet placeholder warning
|
|
216
|
+
|
|
217
|
+
For dry-run paths (`swap`, `bridge`, `lending supply`, etc.), if no wallet is configured the CLI emits a one-shot stderr warning and substitutes the placeholder `0x000…001` so calldata can still be previewed. **Never pass `--broadcast` when the placeholder is in use** — the warning will tell you so explicitly.
|
|
218
|
+
|
|
219
|
+
## Setup (interactive wizard)
|
|
220
|
+
|
|
221
|
+
```bash
|
|
222
|
+
defi setup # prompts for chain RPCs + wallet
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
Stored in `~/.defi/config.toml`. The wizard:
|
|
226
|
+
- Suppresses keypress echo when prompting for a private key.
|
|
227
|
+
- Accepts only `http://` and `https://` RPC URLs (rejects `ws://`, `wss://`, plain hosts).
|
|
228
|
+
- Masks the URL path when displaying current configuration (`https://eth.example.com/***`) so embedded API keys do not leak in transcripts.
|
|
229
|
+
|
|
202
230
|
## Bridge (cross-chain)
|
|
203
231
|
|
|
204
232
|
Source chain (`--chain`) must be a supported chain: `hyperevm`, `mantle`, `base`, `bnb`, `monad`. Destination (`--to-chain`) can be any chain LI.FI/deBridge route to, plus all CCTP V2 chains.
|
|
@@ -213,3 +241,8 @@ defi --json --chain base bridge --token USDC --amount 100000000 --to-chain arbit
|
|
|
213
241
|
# Circle CCTP V2 destinations: ethereum, avalanche, optimism, arbitrum, base, polygon
|
|
214
242
|
defi --json --chain base bridge --token USDC --amount 100000000 --to-chain arbitrum --provider cctp
|
|
215
243
|
```
|
|
244
|
+
|
|
245
|
+
**CCTP min-fee guard (post-v1.0.7)**: when the burn amount cannot cover the protocol fee, the command short-circuits with a structured envelope (no broadcast attempt):
|
|
246
|
+
```json
|
|
247
|
+
{ "error": "amount_below_min_fee", "minimum_amount_wei": "...", "minimum_amount_usdc": "..." }
|
|
248
|
+
```
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# bridge-quote.sh — dry-run a cross-chain bridge across LI.FI / deBridge / CCTP
|
|
3
|
+
# Source must be one of: hyperevm, mantle, base, bnb, monad
|
|
4
|
+
# Usage: FROM_CHAIN=base TO_CHAIN=arbitrum TOKEN=USDC AMOUNT=100000000 bash bridge-quote.sh
|
|
5
|
+
set -euo pipefail
|
|
6
|
+
|
|
7
|
+
DEFI="${DEFI_CMD:-defi}"
|
|
8
|
+
FROM_CHAIN="${FROM_CHAIN:-base}"
|
|
9
|
+
TO_CHAIN="${TO_CHAIN:-arbitrum}"
|
|
10
|
+
TOKEN="${TOKEN:-USDC}"
|
|
11
|
+
AMOUNT="${AMOUNT:-100000000}"
|
|
12
|
+
|
|
13
|
+
# CCTP V2 only routes USDC and only between these chains
|
|
14
|
+
CCTP_CHAINS="ethereum avalanche optimism arbitrum base polygon"
|
|
15
|
+
PROVIDERS=(lifi debridge)
|
|
16
|
+
if [[ "$TOKEN" == "USDC" ]] && [[ " $CCTP_CHAINS " == *" $TO_CHAIN "* ]] && [[ " $CCTP_CHAINS " == *" $FROM_CHAIN "* ]]; then
|
|
17
|
+
PROVIDERS+=(cctp)
|
|
18
|
+
fi
|
|
19
|
+
|
|
20
|
+
echo "[bridge-quote] $AMOUNT $TOKEN: $FROM_CHAIN -> $TO_CHAIN" >&2
|
|
21
|
+
echo "[bridge-quote] providers: ${PROVIDERS[*]}" >&2
|
|
22
|
+
|
|
23
|
+
OUT="["
|
|
24
|
+
SEP=""
|
|
25
|
+
for P in "${PROVIDERS[@]}"; do
|
|
26
|
+
echo "[bridge-quote] probing $P..." >&2
|
|
27
|
+
RES=$("$DEFI" --json --chain "$FROM_CHAIN" bridge \
|
|
28
|
+
--token "$TOKEN" --amount "$AMOUNT" --to-chain "$TO_CHAIN" --provider "$P" 2>/dev/null \
|
|
29
|
+
|| echo "{\"provider\":\"$P\",\"error\":\"probe_failed\"}")
|
|
30
|
+
OUT="${OUT}${SEP}{\"provider\":\"$P\",\"result\":${RES}}"
|
|
31
|
+
SEP=","
|
|
32
|
+
done
|
|
33
|
+
OUT="${OUT}]"
|
|
34
|
+
echo "$OUT"
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# lending-supply-flow.sh — full lending-supply preview without broadcasting
|
|
3
|
+
# Walks: yield scan -> rates on chosen protocol -> existing position -> dry-run supply tx
|
|
4
|
+
# Usage: CHAIN=hyperevm PROTOCOL=hyperlend ASSET=USDC AMOUNT=1000000 bash lending-supply-flow.sh
|
|
5
|
+
set -euo pipefail
|
|
6
|
+
|
|
7
|
+
DEFI="${DEFI_CMD:-defi}"
|
|
8
|
+
CHAIN="${CHAIN:-hyperevm}"
|
|
9
|
+
PROTOCOL="${PROTOCOL:-hyperlend}"
|
|
10
|
+
ASSET="${ASSET:-USDC}"
|
|
11
|
+
AMOUNT="${AMOUNT:-1000000}"
|
|
12
|
+
|
|
13
|
+
echo "[1/4 lending-supply-flow] best $ASSET supply rates across all chains" >&2
|
|
14
|
+
"$DEFI" --json yield scan --asset "$ASSET" --fields chain,protocol,supply_apy 2>/dev/null || true
|
|
15
|
+
|
|
16
|
+
echo "[2/4 lending-supply-flow] rates for $PROTOCOL/$ASSET on $CHAIN" >&2
|
|
17
|
+
"$DEFI" --json --chain "$CHAIN" lending rates --protocol "$PROTOCOL" --asset "$ASSET"
|
|
18
|
+
|
|
19
|
+
echo "[3/4 lending-supply-flow] existing position on $PROTOCOL" >&2
|
|
20
|
+
"$DEFI" --json --chain "$CHAIN" lending position --protocol "$PROTOCOL" 2>/dev/null \
|
|
21
|
+
|| echo '{"position":null,"note":"no wallet configured or no position yet"}'
|
|
22
|
+
|
|
23
|
+
echo "[4/4 lending-supply-flow] DRY-RUN supply tx ($AMOUNT $ASSET) — review before --broadcast" >&2
|
|
24
|
+
"$DEFI" --json --chain "$CHAIN" lending supply \
|
|
25
|
+
--protocol "$PROTOCOL" --asset "$ASSET" --amount "$AMOUNT"
|
|
26
|
+
|
|
27
|
+
echo "" >&2
|
|
28
|
+
echo "[lending-supply-flow] To execute: re-run step 4 with --broadcast" >&2
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# lp-claim-all.sh — list every LP position on a chain that has pending rewards,
|
|
3
|
+
# then print the claim CLI command for each (DRY-RUN guidance only — does not broadcast).
|
|
4
|
+
# Usage: WALLET=0xABC... bash lp-claim-all.sh <chain>
|
|
5
|
+
set -euo pipefail
|
|
6
|
+
|
|
7
|
+
DEFI="${DEFI_CMD:-defi}"
|
|
8
|
+
CHAIN="${1:-mantle}"
|
|
9
|
+
WALLET="${DEFI_WALLET_ADDRESS:-${WALLET:-}}"
|
|
10
|
+
|
|
11
|
+
if [[ -z "$WALLET" ]]; then
|
|
12
|
+
echo '{"error":"Set DEFI_WALLET_ADDRESS or WALLET env var to scan positions"}' >&2
|
|
13
|
+
exit 1
|
|
14
|
+
fi
|
|
15
|
+
|
|
16
|
+
echo "[lp-claim-all] $CHAIN: scanning all LP positions for $WALLET" >&2
|
|
17
|
+
"$DEFI" --json --chain "$CHAIN" lp positions --address "$WALLET"
|
|
18
|
+
|
|
19
|
+
echo "" >&2
|
|
20
|
+
echo "[lp-claim-all] To claim a specific position, use one of:" >&2
|
|
21
|
+
echo " V3 fees: defi --json --chain $CHAIN lp claim --protocol <slug> --token-id <id> --broadcast" >&2
|
|
22
|
+
echo " Solidly gauge: defi --json --chain $CHAIN lp claim --protocol <slug> --gauge <addr> --broadcast" >&2
|
|
23
|
+
echo " Slipstream NFT: defi --json --chain $CHAIN lp claim --protocol <slug> --gauge <addr> --token-id <id> --broadcast" >&2
|
|
24
|
+
echo " Merchant Moe: defi --json --chain $CHAIN lp claim --protocol merchantmoe-mantle --pool <addr> --broadcast" >&2
|
|
25
|
+
echo " KittenSwap: defi --json --chain $CHAIN lp claim --protocol kittenswap --pool <addr> --token-id <id> --broadcast" >&2
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# lp-emission-discover.sh — list active-emission LP pools on a chain, sorted by APR
|
|
3
|
+
# Usage: bash lp-emission-discover.sh <chain> [protocol]
|
|
4
|
+
# Examples:
|
|
5
|
+
# bash lp-emission-discover.sh mantle merchantmoe-mantle
|
|
6
|
+
# bash lp-emission-discover.sh base aerodrome-cl
|
|
7
|
+
# bash lp-emission-discover.sh hyperevm kittenswap
|
|
8
|
+
set -euo pipefail
|
|
9
|
+
|
|
10
|
+
DEFI="${DEFI_CMD:-defi}"
|
|
11
|
+
CHAIN="${1:-mantle}"
|
|
12
|
+
PROTOCOL="${2:-}"
|
|
13
|
+
|
|
14
|
+
if [[ -n "$PROTOCOL" ]]; then
|
|
15
|
+
echo "[lp-emission-discover] $CHAIN/$PROTOCOL — emission-only, APR-sorted desc" >&2
|
|
16
|
+
"$DEFI" --json --chain "$CHAIN" lp discover --protocol "$PROTOCOL" --emission-only
|
|
17
|
+
else
|
|
18
|
+
echo "[lp-emission-discover] $CHAIN (all protocols) — emission-only, APR-sorted desc" >&2
|
|
19
|
+
"$DEFI" --json --chain "$CHAIN" lp discover --emission-only
|
|
20
|
+
fi
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# swap-quote.sh — dry-run a swap across every aggregator that supports the chain
|
|
3
|
+
# Picks the best amount_out and prints a side-by-side comparison.
|
|
4
|
+
# Usage: CHAIN=base FROM=WETH TO=USDC AMOUNT=1000000000000000000 bash swap-quote.sh
|
|
5
|
+
set -euo pipefail
|
|
6
|
+
|
|
7
|
+
DEFI="${DEFI_CMD:-defi}"
|
|
8
|
+
CHAIN="${CHAIN:-hyperevm}"
|
|
9
|
+
FROM="${FROM:-WHYPE}"
|
|
10
|
+
TO="${TO:-USDC}"
|
|
11
|
+
AMOUNT="${AMOUNT:-1000000000000000000}"
|
|
12
|
+
SLIPPAGE="${SLIPPAGE:-50}"
|
|
13
|
+
|
|
14
|
+
case "$CHAIN" in
|
|
15
|
+
hyperevm) PROVIDERS=(kyber openocean liquid lifi relay) ;;
|
|
16
|
+
mantle) PROVIDERS=(openocean lifi relay) ;;
|
|
17
|
+
base) PROVIDERS=(kyber openocean lifi relay) ;;
|
|
18
|
+
bnb) PROVIDERS=(kyber openocean lifi relay) ;;
|
|
19
|
+
monad) PROVIDERS=(lifi relay) ;;
|
|
20
|
+
*) echo "{\"error\":\"unknown chain: $CHAIN (expected hyperevm|mantle|base|bnb|monad)\"}" >&2; exit 1 ;;
|
|
21
|
+
esac
|
|
22
|
+
|
|
23
|
+
echo "[swap-quote] $CHAIN: $AMOUNT $FROM -> $TO @ ${SLIPPAGE}bps slippage" >&2
|
|
24
|
+
echo "[swap-quote] providers: ${PROVIDERS[*]}" >&2
|
|
25
|
+
|
|
26
|
+
OUT="["
|
|
27
|
+
SEP=""
|
|
28
|
+
for P in "${PROVIDERS[@]}"; do
|
|
29
|
+
echo "[swap-quote] probing $P..." >&2
|
|
30
|
+
RES=$("$DEFI" --json --chain "$CHAIN" swap --provider "$P" \
|
|
31
|
+
--from "$FROM" --to "$TO" --amount "$AMOUNT" --slippage "$SLIPPAGE" 2>/dev/null \
|
|
32
|
+
|| echo "{\"provider\":\"$P\",\"error\":\"probe_failed\"}")
|
|
33
|
+
OUT="${OUT}${SEP}{\"provider\":\"$P\",\"result\":${RES}}"
|
|
34
|
+
SEP=","
|
|
35
|
+
done
|
|
36
|
+
OUT="${OUT}]"
|
|
37
|
+
echo "$OUT"
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# wallet-status.sh — print configured wallet + native balance on every supported chain
|
|
3
|
+
# Usage: bash wallet-status.sh
|
|
4
|
+
set -euo pipefail
|
|
5
|
+
|
|
6
|
+
DEFI="${DEFI_CMD:-defi}"
|
|
7
|
+
CHAINS=(hyperevm mantle base bnb monad)
|
|
8
|
+
|
|
9
|
+
echo "[wallet-status] resolving configured wallet..." >&2
|
|
10
|
+
ADDR_JSON=$("$DEFI" --json wallet address)
|
|
11
|
+
echo "$ADDR_JSON"
|
|
12
|
+
|
|
13
|
+
# Extract null check without jq dependency: address field is "null" when unset.
|
|
14
|
+
if echo "$ADDR_JSON" | grep -q '"address":null'; then
|
|
15
|
+
echo "[wallet-status] no wallet configured — skipping per-chain balances" >&2
|
|
16
|
+
echo "[wallet-status] To configure: export DEFI_WALLET_ADDRESS=0x... or run 'defi setup'" >&2
|
|
17
|
+
exit 0
|
|
18
|
+
fi
|
|
19
|
+
|
|
20
|
+
OUT="["
|
|
21
|
+
SEP=""
|
|
22
|
+
for C in "${CHAINS[@]}"; do
|
|
23
|
+
echo "[wallet-status] probing native balance on $C..." >&2
|
|
24
|
+
RES=$("$DEFI" --json --chain "$C" wallet balance 2>/dev/null \
|
|
25
|
+
|| echo "{\"chain\":\"$C\",\"error\":\"rpc_unreachable\"}")
|
|
26
|
+
OUT="${OUT}${SEP}${RES}"
|
|
27
|
+
SEP=","
|
|
28
|
+
done
|
|
29
|
+
OUT="${OUT}]"
|
|
30
|
+
echo "$OUT"
|
|
File without changes
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# exploit-scan.sh — run a one-shot exploit detection scan across all chains
|
|
3
|
-
# Usage: bash exploit-scan.sh [chain]
|
|
4
|
-
set -euo pipefail
|
|
5
|
-
|
|
6
|
-
DEFI="${DEFI_CMD:-defi}"
|
|
7
|
-
CHAIN="${1:-hyperevm}"
|
|
8
|
-
|
|
9
|
-
echo "[exploit-scan] Scanning $CHAIN for oracle divergence, stablecoin depeg, exchange rate anomalies..." >&2
|
|
10
|
-
"$DEFI" --json --chain "$CHAIN" scan --once --patterns oracle,stable,exchange_rate
|