@cryptorubic/web3 0.8.17-alpha.solana.13 → 0.8.17-alpha.solana.14

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.13",
3
+ "version": "0.8.17-alpha.solana.14",
4
4
  "dependencies": {
5
5
  "@ethersproject/bignumber": "^5.8.0",
6
6
  "@mysten/sui": "^1.24.0",
@@ -27,7 +27,7 @@ class SolanaGasService {
27
27
  return resp.value.unitsConsumed ? new bignumber_js_1.default(resp.value.unitsConsumed * 1.2) : new bignumber_js_1.default(DEFAULT_CU_LIMIT);
28
28
  }
29
29
  catch (err) {
30
- console.error('Solana_simulateTransaction_Error ==> ', err);
30
+ console.error('[SolanaApiService_getConsumedUnitsLimit] err ==> ', err);
31
31
  return new bignumber_js_1.default(DEFAULT_CU_LIMIT);
32
32
  }
33
33
  }
@@ -47,27 +47,35 @@ class SolanaGasService {
47
47
  return cuPrice;
48
48
  }
49
49
  async calculateCUPriceHelius(txData) {
50
- const tx = (0, utility_funcs_1.convertB64DataToTx)(txData);
51
- const resp = await this.httpClient.post(`${this.HELIUS_API_URL}/?api-key=${this.HELIUS_API_KEY}`, {
52
- jsonrpc: '2.0',
53
- id: '1',
54
- method: 'getPriorityFeeEstimate',
55
- params: [
56
- {
57
- transaction: utils_1.base58.encode(tx.serialize()), // Pass the serialized transaction in Base58
58
- options: { priorityLevel: 'Medium' }
59
- }
60
- ]
61
- });
62
- return new bignumber_js_1.default(resp.result.priorityFeeEstimate);
50
+ try {
51
+ const tx = (0, utility_funcs_1.convertB64DataToTx)(txData);
52
+ const resp = await this.httpClient.post(`${this.HELIUS_API_URL}/?api-key=${this.HELIUS_API_KEY}`, {
53
+ jsonrpc: '2.0',
54
+ id: '1',
55
+ method: 'getPriorityFeeEstimate',
56
+ params: [
57
+ {
58
+ transaction: utils_1.base58.encode(tx.serialize()), // Pass the serialized transaction in Base58
59
+ options: { priorityLevel: 'Medium' }
60
+ }
61
+ ]
62
+ });
63
+ return new bignumber_js_1.default(resp.result.priorityFeeEstimate);
64
+ }
65
+ catch (err) {
66
+ console.error('[SolanaGasService_getConsumedUnitsPrice] err ==> ', err);
67
+ return new bignumber_js_1.default(0);
68
+ }
63
69
  }
64
70
  async calculateCUPriceSolWeb3() {
71
+ const BASE_FEE = 5_000;
65
72
  const resp = await this.connection.getRecentPrioritizationFees();
66
73
  const avgCUPrice = resp
67
74
  .reduce((acc, tx) => acc.plus(tx.prioritizationFee), new bignumber_js_1.default(0))
68
75
  .div(resp.length)
69
76
  .dp(0, bignumber_js_1.default.ROUND_CEIL);
70
- return avgCUPrice;
77
+ const cuPrice = new bignumber_js_1.default(Math.max(BASE_FEE, avgCUPrice.toNumber()));
78
+ return cuPrice;
71
79
  }
72
80
  }
73
81
  exports.SolanaGasService = SolanaGasService;