@cryptorubic/web3 0.8.17-alpha.solana.16 → 0.8.17-alpha.solana.18
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
|
@@ -95,18 +95,26 @@ class SolanaGasService {
|
|
|
95
95
|
return { success: true, cuLimit: new bignumber_js_1.default(simulationResp.value.unitsConsumed), idx };
|
|
96
96
|
};
|
|
97
97
|
const recentFees = await this.connection.getRecentPrioritizationFees();
|
|
98
|
-
const
|
|
99
|
-
const lastBlocksSlots = await this.connection.getBlocks(
|
|
98
|
+
const lastTenTxFees = recentFees.slice(recentFees.length - 10);
|
|
99
|
+
const lastBlocksSlots = await this.connection.getBlocks(lastTenTxFees[0].slot).catch((err) => {
|
|
100
|
+
this.logger?.customLog('SolanaGasService_calculateCUPriceSolWeb3_getBlocks ERROR', err);
|
|
101
|
+
return [];
|
|
102
|
+
});
|
|
100
103
|
const lastBlocksSigs = await Promise.all(lastBlocksSlots.map((slot) => this.connection.getBlockSignatures(slot, 'confirmed')));
|
|
101
104
|
const flattenSigs = lastBlocksSigs.flatMap((b) => b.signatures);
|
|
102
|
-
const lastTxs = await this.connection
|
|
105
|
+
const lastTxs = await this.connection
|
|
106
|
+
.getTransactions(flattenSigs, { commitment: 'confirmed', maxSupportedTransactionVersion: 0 })
|
|
107
|
+
.catch((err) => {
|
|
108
|
+
this.logger?.customLog('SolanaGasService_calculateCUPriceSolWeb3_getTransactions ERROR', err);
|
|
109
|
+
return [];
|
|
110
|
+
});
|
|
103
111
|
const serializedTxs = lastTxs
|
|
104
112
|
.filter(Boolean)
|
|
105
113
|
.map((tx) => web3_js_1.VersionedTransaction.deserialize(Buffer.from(tx.transaction.message.serialize())));
|
|
106
114
|
const lastCuLimits = await Promise.all(serializedTxs.map((tx, idx) => estimateCULimitForTx(tx, idx)));
|
|
107
115
|
const successCuLimits = lastCuLimits.filter((obj) => obj.success);
|
|
108
116
|
const avgCuPrice = successCuLimits.reduce((acc, cuLimitInfo) => {
|
|
109
|
-
const cuPrice = new bignumber_js_1.default(
|
|
117
|
+
const cuPrice = new bignumber_js_1.default(lastTenTxFees[cuLimitInfo.idx].prioritizationFee)
|
|
110
118
|
.multipliedBy(1_000_000)
|
|
111
119
|
.div(cuLimitInfo.cuLimit);
|
|
112
120
|
return cuPrice.gt(acc) ? cuPrice : acc;
|