@clonegod/ttd-sol-common 1.0.78 → 1.0.79

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.
@@ -418,9 +418,6 @@ class RpcClient {
418
418
  if (solana_trade_runtime.settings.strategy.broadcast_type === 'jito') {
419
419
  priorityFeeEstimate = 1;
420
420
  }
421
- if (solana_trade_runtime.settings.strategy.broadcast_type === 'mixed') {
422
- priorityFeeEstimate = Math.ceil(priorityFeeEstimate * 0.7);
423
- }
424
421
  const computeBudgetIx = web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({
425
422
  microLamports: priorityFeeEstimate,
426
423
  });
@@ -65,7 +65,7 @@ class HeliusClient {
65
65
  return __awaiter(this, void 0, void 0, function* () {
66
66
  (0, dist_1.log_info)(`send_transaction_by_jito, start`);
67
67
  let start_time = Date.now();
68
- let tipAmount = solana_trade_runtime.priority_fee;
68
+ let tipAmount = solana_trade_runtime.tip_amount;
69
69
  let jito_region = (0, strategy_util_1.get_jito_region)();
70
70
  let rpc = this.helius_mainnet.rpc;
71
71
  let txid = yield rpc.sendSmartTransactionWithTip(solana_trade_runtime, instructions, this.signers, [], tipAmount, jito_region);
@@ -82,7 +82,7 @@ class HeliusClient {
82
82
  return __awaiter(this, void 0, void 0, function* () {
83
83
  (0, dist_1.log_info)(`send_transaction_mixed, start`);
84
84
  let start_time = Date.now();
85
- let tipAmount = Math.ceil(solana_trade_runtime.priority_fee * 0.3);
85
+ let tipAmount = solana_trade_runtime.tip_amount;
86
86
  let jito_region = (0, strategy_util_1.get_jito_region)();
87
87
  let rpc = use_staked_endpint ? this.helius_staked.rpc : this.helius_mainnet.rpc;
88
88
  let txid = yield rpc.sendSmartTransactionWithTipMixed(solana_trade_runtime, instructions, this.signers, [], tipAmount, jito_region);
@@ -7,11 +7,11 @@ const dist_1 = require("@clonegod/ttd-common/dist");
7
7
  const constants_1 = require("../common/constants");
8
8
  function create_solana_trade_runtime(connection, trade_runtime, pool_info) {
9
9
  let trade_strategy = trade_runtime.settings.strategy;
10
+ let { total_gas, priority_fee, tip_amount } = get_priority_fee_and_tip(trade_strategy);
10
11
  let { cu_limit, use_jito_plugin } = pool_info;
11
12
  if (isNaN(cu_limit) || cu_limit < 35000) {
12
13
  cu_limit = 35000;
13
14
  }
14
- let priority_fee = calculate_gas_fee(trade_strategy);
15
15
  let cu_price = Math.ceil(priority_fee * constants_1.ONE_MILLION / cu_limit);
16
16
  let jito_plugin_url = '';
17
17
  if (use_jito_plugin) {
@@ -19,20 +19,50 @@ function create_solana_trade_runtime(connection, trade_runtime, pool_info) {
19
19
  }
20
20
  (0, dist_1.log_info)(`trade_strategy & gas`, {
21
21
  trade_strategy,
22
+ total_gas,
22
23
  priority_fee,
23
24
  cu_limit,
24
25
  cu_price,
25
26
  use_jito_plugin,
26
- jito_plugin_url
27
+ jito_plugin_url,
28
+ tip_amount
27
29
  });
28
30
  let solana_trade_runtime = Object.assign(Object.assign({}, trade_runtime), { connection,
31
+ total_gas,
29
32
  priority_fee,
30
33
  cu_limit,
31
34
  cu_price,
32
35
  use_jito_plugin,
33
- jito_plugin_url });
36
+ jito_plugin_url,
37
+ tip_amount });
34
38
  return solana_trade_runtime;
35
39
  }
40
+ function get_priority_fee_and_tip(trade_strategy) {
41
+ let priority_fee = 0;
42
+ let tip_amount = 0;
43
+ let total_gas = calculate_gas_fee(trade_strategy);
44
+ if (trade_strategy.broadcast_type === 'rpc') {
45
+ priority_fee = total_gas;
46
+ tip_amount = 0;
47
+ }
48
+ if (trade_strategy.broadcast_type === 'jito') {
49
+ priority_fee = 0;
50
+ tip_amount = total_gas;
51
+ }
52
+ else if (trade_strategy.broadcast_type === 'mixed') {
53
+ let tip_ratio = trade_strategy.tip_ratio;
54
+ if (Number.isNaN(tip_ratio) || tip_ratio <= 0) {
55
+ tip_ratio = 0.3;
56
+ }
57
+ tip_amount = Math.ceil(total_gas * tip_ratio);
58
+ priority_fee = total_gas - tip_amount;
59
+ }
60
+ return {
61
+ total_gas,
62
+ priority_fee,
63
+ tip_amount
64
+ };
65
+ }
36
66
  function calculate_gas_fee(trade_strategy) {
37
67
  let { speed, fee_mode, fee_exact, fee_max_cap, } = trade_strategy;
38
68
  let gas_fee = 1000;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clonegod/ttd-sol-common",
3
- "version": "1.0.78",
3
+ "version": "1.0.79",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "types/index.d.ts",
@@ -13,7 +13,7 @@
13
13
  "push": "npm run build && npm publish"
14
14
  },
15
15
  "dependencies": {
16
- "@clonegod/ttd-common": "^1.0.158",
16
+ "@clonegod/ttd-common": "^1.0.159",
17
17
  "@irys/sdk": "^0.2.10",
18
18
  "@metaplex-foundation/mpl-token-metadata": "^2.5.2",
19
19
  "@solana/web3.js": "1.91.6",
package/types/index.d.ts CHANGED
@@ -40,6 +40,9 @@ export interface SolanaTradeRuntimeType extends TradeRuntimeType {
40
40
  // common connection
41
41
  connection: Connection
42
42
 
43
+ // total pay gas for one tx
44
+ total_gas: number
45
+
43
46
  // priority fee
44
47
  priority_fee: number
45
48
 
@@ -50,6 +53,8 @@ export interface SolanaTradeRuntimeType extends TradeRuntimeType {
50
53
  cu_limit: number
51
54
 
52
55
  jito_plugin_url: string
56
+
57
+ tip_amount: number
53
58
  }
54
59
 
55
60