@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/dist/mcp-server.js
CHANGED
|
@@ -2080,12 +2080,16 @@ var init_dist2 = __esm({
|
|
|
2080
2080
|
functionName: "add_liquidity",
|
|
2081
2081
|
args: [[params.amount_a, params.amount_b], 0n]
|
|
2082
2082
|
});
|
|
2083
|
+
const approvals = [];
|
|
2084
|
+
if (params.amount_a > 0n) approvals.push({ token: params.token_a, spender: this.router, amount: params.amount_a });
|
|
2085
|
+
if (params.amount_b > 0n) approvals.push({ token: params.token_b, spender: this.router, amount: params.amount_b });
|
|
2083
2086
|
return {
|
|
2084
2087
|
description: `[${this.protocolName}] Curve add liquidity`,
|
|
2085
2088
|
to: this.router,
|
|
2086
2089
|
data,
|
|
2087
2090
|
value: 0n,
|
|
2088
|
-
gas_estimate: 4e5
|
|
2091
|
+
gas_estimate: 4e5,
|
|
2092
|
+
approvals
|
|
2089
2093
|
};
|
|
2090
2094
|
}
|
|
2091
2095
|
async buildRemoveLiquidity(params) {
|
|
@@ -7450,11 +7454,29 @@ var Executor = class _Executor {
|
|
|
7450
7454
|
static applyGasBuffer(gas) {
|
|
7451
7455
|
return gas * GAS_BUFFER_BPS / 10000n;
|
|
7452
7456
|
}
|
|
7457
|
+
/**
|
|
7458
|
+
* EIP-1559 max-fee formula: `baseFee * 1.25 + priorityFee`.
|
|
7459
|
+
* Extracted as a static so the math is unit-testable without mocking viem.
|
|
7460
|
+
*/
|
|
7461
|
+
static computeMaxFee(baseFeePerGas, priorityFee) {
|
|
7462
|
+
return baseFeePerGas * 125n / 100n + priorityFee;
|
|
7463
|
+
}
|
|
7453
7464
|
/**
|
|
7454
7465
|
* Check allowance for a single token/spender pair and send an approve tx if needed.
|
|
7455
7466
|
* Only called in broadcast mode (not dry-run).
|
|
7456
7467
|
*/
|
|
7468
|
+
/**
|
|
7469
|
+
* Recognize the standard native-token sentinels:
|
|
7470
|
+
* - 0x0000…0000 — defi-cli's internal marker for native gas tokens
|
|
7471
|
+
* - 0xeeee…eeee — 1inch / KyberSwap / OpenOcean canonical sentinel
|
|
7472
|
+
* Any address normalised to lowercase matches case-insensitively.
|
|
7473
|
+
*/
|
|
7474
|
+
static isNativeSentinel(token) {
|
|
7475
|
+
const t = token.toLowerCase();
|
|
7476
|
+
return t === "0x0000000000000000000000000000000000000000" || t === "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
|
|
7477
|
+
}
|
|
7457
7478
|
async checkAndApprove(token, spender, amount, owner, publicClient, walletClient) {
|
|
7479
|
+
if (_Executor.isNativeSentinel(token)) return;
|
|
7458
7480
|
const allowance = await publicClient.readContract({
|
|
7459
7481
|
address: token,
|
|
7460
7482
|
abi: ERC20_ABI4,
|
|
@@ -7535,9 +7557,12 @@ var Executor = class _Executor {
|
|
|
7535
7557
|
/**
|
|
7536
7558
|
* Fetch EIP-1559 fee params. Returns [maxFeePerGas, maxPriorityFeePerGas].
|
|
7537
7559
|
*
|
|
7538
|
-
* Strategy: read the latest block's `baseFeePerGas` and
|
|
7539
|
-
*
|
|
7540
|
-
*
|
|
7560
|
+
* Strategy: read the latest block's `baseFeePerGas` and apply the conservative
|
|
7561
|
+
* formula `maxFee = baseFee * 1.25 + priorityFee` (one block of head-room — the
|
|
7562
|
+
* 12.5% per-block max bump). The canonical 2× wastes budget on chains where
|
|
7563
|
+
* baseFee is already elevated (e.g., Mantle ~50 gwei → 100 gwei doubled the
|
|
7564
|
+
* MNT requirement and broke multi-step flows). Falls back to
|
|
7565
|
+
* `getGasPrice() + priorityFee` only when
|
|
7541
7566
|
* the chain doesn't expose `baseFeePerGas` (pre-1559).
|
|
7542
7567
|
*
|
|
7543
7568
|
* Why not gasPrice * 2: `getGasPrice()` returns `baseFee + priorityFee`, so
|
|
@@ -7556,8 +7581,7 @@ var Executor = class _Executor {
|
|
|
7556
7581
|
try {
|
|
7557
7582
|
const block = await client.getBlock({ blockTag: "latest" });
|
|
7558
7583
|
if (block.baseFeePerGas !== null && block.baseFeePerGas !== void 0) {
|
|
7559
|
-
|
|
7560
|
-
return [maxFee, priorityFee];
|
|
7584
|
+
return [_Executor.computeMaxFee(block.baseFeePerGas, priorityFee), priorityFee];
|
|
7561
7585
|
}
|
|
7562
7586
|
} catch {
|
|
7563
7587
|
}
|
|
@@ -7600,6 +7624,7 @@ var Executor = class _Executor {
|
|
|
7600
7624
|
if (tx.approvals && tx.approvals.length > 0) {
|
|
7601
7625
|
const pendingApprovals = [];
|
|
7602
7626
|
for (const approval of tx.approvals) {
|
|
7627
|
+
if (_Executor.isNativeSentinel(approval.token)) continue;
|
|
7603
7628
|
try {
|
|
7604
7629
|
const allowance = await client.readContract({
|
|
7605
7630
|
address: approval.token,
|