@rhinestone/service-sdk 0.2.13 → 0.2.14

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/chains.d.ts CHANGED
@@ -13,6 +13,27 @@ export type EstimateGasFeesOptions = {
13
13
  */
14
14
  mode?: 'legacy';
15
15
  };
16
+ /**
17
+ * {@link estimateGasFees}' result: viem's EIP-1559 fee values plus the next
18
+ * block's base fee, when it could be read.
19
+ *
20
+ * `baseFeePerGas` is surfaced because `maxFeePerGas` is a submission CAP
21
+ * (`base * baseFeeMultiplierPct + tip`) — the price we are willing to bid up to,
22
+ * not the price a transaction pays (`base + tip`). Billing the cap is correct
23
+ * where a relayer must stay covered if the base fee climbs before inclusion; it
24
+ * is wrong to REPORT to a consumer that compares it against other relayers.
25
+ * Exposing the base fee lets a caller derive the expected price WITHOUT a second
26
+ * eth_feeHistory round trip — every path here already reads it and used to
27
+ * discard it (RHI-4992).
28
+ *
29
+ * `null` when the base fee was unavailable: a non-1559 chain, `mode: 'legacy'`,
30
+ * or a degraded read (already recorded via `recordDegradedEstimate`). Callers
31
+ * must treat null as "unknown" and fall back — never as zero, which would price
32
+ * a cap at the tip alone.
33
+ */
34
+ export type EstimatedGasFees = FeeValuesEIP1559 & {
35
+ baseFeePerGas: bigint | null;
36
+ };
16
37
  /**
17
38
  * Estimates gas fees for a chain and returns EIP-1559-shaped fee values.
18
39
  *
@@ -28,5 +49,5 @@ export type EstimateGasFeesOptions = {
28
49
  * zero. This changes fee estimation only; it does not select a transaction
29
50
  * type.
30
51
  */
31
- export declare function estimateGasFees(client: FeeEstimationClient, chainId: number, options?: EstimateGasFeesOptions): Promise<FeeValuesEIP1559>;
52
+ export declare function estimateGasFees(client: FeeEstimationClient, chainId: number, options?: EstimateGasFeesOptions): Promise<EstimatedGasFees>;
32
53
  //# sourceMappingURL=chains.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"chains.d.ts","sourceRoot":"","sources":["../src/chains.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,OAAO,CAAC,gBAAgB,CAAC,CAiD3B"}
package/dist/chains.js CHANGED
@@ -311,7 +311,12 @@ async function estimateGasFees(client, chainId, options) {
311
311
  // Equal caps preserve gasPrice as the effective-price ceiling. If a
312
312
  // no-priority local fork reports baseFee == gasPrice, the max-fee cap means
313
313
  // the actual paid tip remains zero despite this priority-fee allowance.
314
- return { maxFeePerGas: gasPrice, maxPriorityFeePerGas: gasPrice };
314
+ // Legacy has no base-fee component to report.
315
+ return {
316
+ maxFeePerGas: gasPrice,
317
+ maxPriorityFeePerGas: gasPrice,
318
+ baseFeePerGas: null,
319
+ };
315
320
  }
316
321
  if (HISTORICAL_FEE_CHAINS.has(chainId)) {
317
322
  const config = { ...DEFAULT_FEE_CONFIG, ...FEE_CONFIG_OVERRIDES[chainId] };
@@ -335,6 +340,7 @@ async function estimateGasFees(client, chainId, options) {
335
340
  return {
336
341
  maxFeePerGas: cappedMaxFeePerGas(client, fees, baseFee, chainId, tip, oracleTip),
337
342
  maxPriorityFeePerGas: tip,
343
+ baseFeePerGas: baseFee,
338
344
  };
339
345
  }
340
346
  // viem's oracle tip, lifted to an absolute floor — and, for windowed-tip chains,
@@ -375,6 +381,7 @@ async function estimateViemFeesWithTipFloor(client, chainId, tipFloorWei) {
375
381
  return {
376
382
  maxFeePerGas: cappedMaxFeePerGas(client, fees, history.baseFee, chainId, tip, oracleTip),
377
383
  maxPriorityFeePerGas: tip,
384
+ baseFeePerGas: history.baseFee,
378
385
  };
379
386
  }
380
387
  /**
@@ -557,10 +564,15 @@ async function estimateFeeHistoryGasFees(client, chainId, config) {
557
564
  return {
558
565
  maxFeePerGas: await viemFallbackCap(client, config, priorityFee),
559
566
  maxPriorityFeePerGas: priorityFee,
567
+ baseFeePerGas: null,
560
568
  };
561
569
  }
562
570
  const maxFeePerGas = (baseFee * config.baseFeeMultiplierPct) / 100n + priorityFee;
563
- return { maxFeePerGas, maxPriorityFeePerGas: priorityFee };
571
+ return {
572
+ maxFeePerGas,
573
+ maxPriorityFeePerGas: priorityFee,
574
+ baseFeePerGas: baseFee,
575
+ };
564
576
  }
565
577
  // Nearest-rank percentile over a bigint sample. Empty sample → 0n.
566
578
  function percentileBigInt(values, percentile) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rhinestone/service-sdk",
3
- "version": "0.2.13",
3
+ "version": "0.2.14",
4
4
  "description": "Shared SDK for Rhinestone services",
5
5
  "author": {
6
6
  "name": "Rhinestone",