Skip to content

Commit cf47655

Browse files
authored
fix: update gas calculations (#1939)
1 parent 4ebccb8 commit cf47655

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

apps/namadillo/src/atoms/fees/atoms.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ export const gasEstimateFamily = atomFamily(
3737
}
3838

3939
const gasEstimate = await fetchGasEstimate(api, txKinds);
40-
41-
// TODO: we need to improve this estimate API. Currently, gasEstimate.min returns
42-
// the minimum gas limit ever used for a TX, and avg is failing in most of the transactions.
43-
const newMin = gasEstimate.max;
40+
const precision = Math.max(
41+
0,
42+
Math.min(1, gasEstimate.totalEstimates / 1000)
43+
);
4444
return {
45-
min: newMin,
46-
avg: Math.ceil(newMin * 1.25),
47-
max: Math.ceil(newMin * 1.5),
45+
min: gasEstimate.min * 1.1 - precision * 0.1,
46+
avg: gasEstimate.avg * 1.25 - precision * 0.25,
47+
max: gasEstimate.max * 1.5 - precision * 0.5,
4848
totalEstimates: gasEstimate.totalEstimates,
4949
};
5050
},

0 commit comments

Comments
 (0)