@hypurrquant/defi-cli 1.0.11 → 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.
@@ -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,6 +7454,13 @@ 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).
@@ -7570,8 +7581,7 @@ var Executor = class _Executor {
7570
7581
  try {
7571
7582
  const block = await client.getBlock({ blockTag: "latest" });
7572
7583
  if (block.baseFeePerGas !== null && block.baseFeePerGas !== void 0) {
7573
- const maxFee = block.baseFeePerGas * 125n / 100n + priorityFee;
7574
- return [maxFee, priorityFee];
7584
+ return [_Executor.computeMaxFee(block.baseFeePerGas, priorityFee), priorityFee];
7575
7585
  }
7576
7586
  } catch {
7577
7587
  }