@cryptorubic/web3 0.8.17-alpha.solana.12 → 0.8.17-alpha.solana.13
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/package.json
CHANGED
|
@@ -39,7 +39,11 @@ class SolanaGasService {
|
|
|
39
39
|
if (!this.HELIUS_API_KEY) {
|
|
40
40
|
console.warn('[SolanaApiService_getConsumedUnitsPrice] heliusApiKey is not provided in "createFactory"');
|
|
41
41
|
}
|
|
42
|
-
const
|
|
42
|
+
const resp = await Promise.allSettled([this.calculateCUPriceHelius(txData), this.calculateCUPriceSolWeb3()]);
|
|
43
|
+
const cuPrice = resp
|
|
44
|
+
.filter((r) => r.status === 'fulfilled')
|
|
45
|
+
.map((r) => r.value)
|
|
46
|
+
.reduce((acc, price) => (acc.gt(price) ? acc : price), new bignumber_js_1.default(0));
|
|
43
47
|
return cuPrice;
|
|
44
48
|
}
|
|
45
49
|
async calculateCUPriceHelius(txData) {
|
|
@@ -58,14 +62,12 @@ class SolanaGasService {
|
|
|
58
62
|
return new bignumber_js_1.default(resp.result.priorityFeeEstimate);
|
|
59
63
|
}
|
|
60
64
|
async calculateCUPriceSolWeb3() {
|
|
61
|
-
const BASE_FEE = 5_000;
|
|
62
65
|
const resp = await this.connection.getRecentPrioritizationFees();
|
|
63
66
|
const avgCUPrice = resp
|
|
64
67
|
.reduce((acc, tx) => acc.plus(tx.prioritizationFee), new bignumber_js_1.default(0))
|
|
65
68
|
.div(resp.length)
|
|
66
69
|
.dp(0, bignumber_js_1.default.ROUND_CEIL);
|
|
67
|
-
|
|
68
|
-
return cuPrice;
|
|
70
|
+
return avgCUPrice;
|
|
69
71
|
}
|
|
70
72
|
}
|
|
71
73
|
exports.SolanaGasService = SolanaGasService;
|