File tree 1 file changed +15
-3
lines changed
packages/financial-templates-lib/src/helpers 1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -92,16 +92,28 @@ class GasEstimator {
92
92
try {
93
93
const response = await fetch ( url ) ;
94
94
const json = await response . json ( ) ;
95
+ // Depending on the network ID, the structure back from the API might change. If ethereum then expected structure is:
96
+ // {
97
+ // safeLow: 1, // slow maxPriorityFeePerGas
98
+ // standard: 1.5, // standard maxPriorityFeePerGas
99
+ // fast: 4, // fast maxPriorityFeePerGas
100
+ // fastest: 6.2, // fastest maxPriorityFeePerGas
101
+ // currentBaseFee: 33.1, // previous blocks base fee
102
+ // recommendedBaseFee: 67.1 // maxFeePerGas
103
+ // }
104
+ // In this case, we want to use recommendedBaseFee & send legacy transactions. If Polygon then the expected structure is:
95
105
// Primary URL expected response structure:
96
106
// {
97
107
// "safeLow": "25.0",
98
108
// "standard": "30.0",
99
109
// "fast": "35.0",
100
110
// "fastest": "39.6"
101
111
// }
102
- if ( json . fastest ) {
103
- let price = json . recommendedBaseFee ;
104
- return price ;
112
+ // In this case, we want to use fastest and send legacy transactions.
113
+ if ( json . recommendedBaseFee ) {
114
+ return json . recommendedBaseFee ;
115
+ } else if ( json . fastest ) {
116
+ return json . fastest ;
105
117
} else {
106
118
throw new Error ( `Main gas station API @ ${ url } : bad json response` ) ;
107
119
}
You can’t perform that action at this time.
0 commit comments