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

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