@cryptorubic/web3 0.8.17-alpha.solana.19 → 0.8.17-alpha.solana.20

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cryptorubic/web3",
3
- "version": "0.8.17-alpha.solana.19",
3
+ "version": "0.8.17-alpha.solana.20",
4
4
  "dependencies": {
5
5
  "@ethersproject/bignumber": "^5.8.0",
6
6
  "@mysten/sui": "^1.24.0",
@@ -79,7 +79,6 @@ class SolanaGasService {
79
79
  const lastSlot = await this.connection.getSlot();
80
80
  // last slots array [1000, 1001, 1002 ...]
81
81
  const last10Slots = Array.from({ length: 10 }, (_, idx) => lastSlot - idx).reverse();
82
- // @CHECK microlamports or lamports
83
82
  const getPriorityFeesFromBlock = async (slotNum) => {
84
83
  const block = await this.connection.getBlock(slotNum, { maxSupportedTransactionVersion: 0, commitment: 'confirmed' });
85
84
  if (!block)
@@ -88,7 +87,10 @@ class SolanaGasService {
88
87
  };
89
88
  const resp = await Promise.all(last10Slots.map((slotNum) => getPriorityFeesFromBlock(slotNum)));
90
89
  const flattenPriorityFees = resp.flat();
91
- const avgPriorityFee = flattenPriorityFees.reduce((acc, fee) => (acc.gt(fee) ? acc : new bignumber_js_1.default(fee)), new bignumber_js_1.default(0));
90
+ const avgProrityFee = flattenPriorityFees
91
+ .reduce((acc, fee) => acc.plus(fee), new bignumber_js_1.default(0))
92
+ .div(flattenPriorityFees.length)
93
+ .dp(0, bignumber_js_1.default.ROUND_CEIL);
92
94
  // const resp = await this.connection.getRecentPrioritizationFees();
93
95
  // const avgPriorityFee = resp
94
96
  // .reduce((acc, tx) => {
@@ -97,8 +99,8 @@ class SolanaGasService {
97
99
  // }, new BigNumber(0))
98
100
  // .div(resp.length)
99
101
  // .dp(0, BigNumber.ROUND_CEIL);
100
- this.logger?.customLog('SOLANA_WEB3 PRIORITY_FEE SUCCESS', { priorityFeeEstimate: avgPriorityFee.toNumber() });
101
- return avgPriorityFee;
102
+ this.logger?.customLog('SOLANA_WEB3 PRIORITY_FEE SUCCESS', { priorityFeeEstimate: avgProrityFee.toNumber(), flattenPriorityFees });
103
+ return avgProrityFee;
102
104
  }
103
105
  }
104
106
  exports.SolanaGasService = SolanaGasService;