@rhinestone/service-sdk 0.2.6 → 0.2.8
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.map +1 -1
- package/dist/chains.js +39 -14
- package/package.json +1 -1
package/dist/chains.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chains.d.ts","sourceRoot":"","sources":["../src/chains.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"chains.d.ts","sourceRoot":"","sources":["../src/chains.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAY1D,KAAK,mBAAmB,GAAG,IAAI,CAC7B,YAAY,EACZ,oBAAoB,GAAG,eAAe,CACvC,CAAA;AAyGD,wBAAsB,eAAe,CACnC,MAAM,EAAE,mBAAmB,EAC3B,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,gBAAgB,CAAC,CAU3B"}
|
package/dist/chains.js
CHANGED
|
@@ -3,12 +3,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.estimateGasFees = estimateGasFees;
|
|
4
4
|
const chains_1 = require("viem/chains");
|
|
5
5
|
// Chains that price fees from a windowed eth_feeHistory instead of viem's
|
|
6
|
-
// default estimator
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
|
|
6
|
+
// default estimator. Two membership rationales:
|
|
7
|
+
// - volatile-base L1s (mainnet, sepolia): windowing the next-block base fee
|
|
8
|
+
// and pooling tips across the window smooths the single-block noise that
|
|
9
|
+
// made the latest-block-only read jumpy;
|
|
10
|
+
// - broken-tip-oracle chains (Plasma): eth_maxPriorityFeePerGas over-prices
|
|
11
|
+
// the tip by orders of magnitude vs the chain's real rewards, and this path
|
|
12
|
+
// never consults the oracle — see FEE_CONFIG_OVERRIDES for the specifics.
|
|
13
|
+
// Other chains stay on viem's default (some with a tip-floor overlay, see
|
|
14
|
+
// TIP_FLOOR_WEI): their base fee is stable or sequencer-pinned, so windowing
|
|
15
|
+
// adds nothing.
|
|
16
|
+
const HISTORICAL_FEE_CHAINS = new Set([
|
|
17
|
+
chains_1.sepolia.id,
|
|
18
|
+
chains_1.mainnet.id,
|
|
19
|
+
chains_1.plasma.id,
|
|
20
|
+
]);
|
|
12
21
|
const DEFAULT_FEE_CONFIG = {
|
|
13
22
|
historyBlocks: 20, // Geth FullNodeGPO window
|
|
14
23
|
baseFeeMultiplier: 2n, // ~6 blocks / ~70s headroom (cap only — free)
|
|
@@ -30,24 +39,37 @@ const FEE_CONFIG_OVERRIDES = {
|
|
|
30
39
|
congestedTipPercentile: 90,
|
|
31
40
|
tipFloorWei: 0n,
|
|
32
41
|
},
|
|
42
|
+
// Plasma is here for its broken tip oracle, not a volatile base: base fee ~0
|
|
43
|
+
// and rewards flat at the chain-min (probed 2026-07-06, matching the RHI-4468
|
|
44
|
+
// audit). Floor at the chain-min instead of the 0.1 gwei default — that
|
|
45
|
+
// default is a 20x overpay at this chain's fee scale — so a quiet/empty
|
|
46
|
+
// reward window can't stall a tx while flat markets are never overpaid.
|
|
47
|
+
// Percentiles stay on defaults: the reward distribution is flat in calm
|
|
48
|
+
// markets, so they only bite during real congestion, where the p50→p75
|
|
49
|
+
// escalation is the wanted behavior.
|
|
50
|
+
[chains_1.plasma.id]: {
|
|
51
|
+
tipFloorWei: 5000000n, // 0.005 gwei chain-min priority fee
|
|
52
|
+
},
|
|
33
53
|
};
|
|
34
54
|
// Chains where viem's default base-fee estimate is fine but its tip oracle
|
|
35
55
|
// (eth_maxPriorityFeePerGas) under-prices the priority fee versus the real
|
|
36
56
|
// on-chain inclusion floor — the oracle reports the chain-min or zero while txs
|
|
37
57
|
// actually clear at a much higher tip. We keep viem's base estimate and lift
|
|
38
|
-
// only the tip to this absolute floor. Values measured live per chain
|
|
39
|
-
// RHI-4468 audit.
|
|
58
|
+
// only the tip to this absolute floor. Values measured live per chain (the
|
|
59
|
+
// RHI-4468 audit and subsequent fill-tracker probes; each entry dated).
|
|
40
60
|
const TIP_FLOOR_WEI = {
|
|
61
|
+
[chains_1.base.id]: 3000000n, // 0.003 gwei — oracle ~0.001 (network ~p25); real fills ~0.003-0.0036 (probed 2026-07-08)
|
|
41
62
|
[chains_1.polygon.id]: 45000000000n, // 45 gwei — Bor min 30 gwei x1.5; real p50 tip ~200 gwei
|
|
42
63
|
[chains_1.gnosis.id]: 1000000000n, // 1.0 gwei — viem oracle ~21 wei; real p90 inclusion ~1.0 gwei (re-probed 2026-06-25)
|
|
43
64
|
[chains_1.hyperEvm.id]: 150000000n, // 0.15 gwei — oracle returns 0; realized p50 tip ~0.15 gwei
|
|
44
65
|
[chains_1.monad.id]: 22000000000n, // 22 gwei — oracle 2 gwei; competitive tip p50/mode ~22 gwei
|
|
45
66
|
};
|
|
46
|
-
//
|
|
47
|
-
//
|
|
48
|
-
//
|
|
49
|
-
//
|
|
50
|
-
|
|
67
|
+
// Chains whose real tip drifts above the static floor in busy markets — also
|
|
68
|
+
// window the feeHistory tip and take the max with the floor. Polygon: real tip
|
|
69
|
+
// runs ~6.7x its oracle. Base: realized tip drifts above the floor while the
|
|
70
|
+
// oracle stays pinned — see TIP_FLOOR_WEI for the measured values. Both have
|
|
71
|
+
// stable base fees, so the base stays on viem's default.
|
|
72
|
+
const WINDOWED_TIP_CHAINS = new Set([chains_1.polygon.id, chains_1.base.id]);
|
|
51
73
|
const WINDOWED_TIP_HISTORY_BLOCKS = 20;
|
|
52
74
|
const WINDOWED_TIP_PERCENTILE = 50; // p50 per block, nearest-rank across the window
|
|
53
75
|
async function estimateGasFees(client, chainId) {
|
|
@@ -71,7 +93,10 @@ async function estimateViemFeesWithTipFloor(client, chainId, tipFloorWei) {
|
|
|
71
93
|
const oracleTip = fees.maxPriorityFeePerGas;
|
|
72
94
|
let tip = oracleTip;
|
|
73
95
|
if (WINDOWED_TIP_CHAINS.has(chainId)) {
|
|
74
|
-
|
|
96
|
+
// Best-effort: the windowed overlay refines the tip but must never turn a
|
|
97
|
+
// feeHistory outage into a quote outage — on failure, fall back to
|
|
98
|
+
// max(oracle, floor), which is exactly the pre-overlay pricing.
|
|
99
|
+
const windowedTip = await windowedFeeHistoryTip(client).catch(() => 0n);
|
|
75
100
|
if (windowedTip > tip)
|
|
76
101
|
tip = windowedTip;
|
|
77
102
|
}
|