@clonegod/ttd-sol-common 1.0.13 → 1.0.15

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/dist/index.d.ts CHANGED
@@ -14,6 +14,7 @@ export declare enum LOCAL_EVENT_NAME {
14
14
  }
15
15
  export declare const subscribe_pool_change_by_geyser: (geyser_ws_url: string, pool_list: StandardPoolInfoType[], eventEmitter: EventEmitter) => Promise<void>;
16
16
  export declare class HeliusClient {
17
+ cluster: string;
17
18
  helius_mainnet: Helius;
18
19
  helius_staked: Helius;
19
20
  helius_qn: Helius;
@@ -22,5 +23,6 @@ export declare class HeliusClient {
22
23
  jito_tip_max: number;
23
24
  constructor(signers: Signer[], jito_tip_max?: number);
24
25
  send_smart_transaction(instructions: TransactionInstruction[], use_staked_endpint?: boolean): Promise<string>;
25
- send_transaction_by_jito(instructions: TransactionInstruction[], tipAmount: number, region: JitoRegion): Promise<TransactionSignature>;
26
+ send_transaction_by_jito(instructions: TransactionInstruction[], tipAmount: number): Promise<TransactionSignature>;
26
27
  }
28
+ export declare const get_jito_region: () => JitoRegion;
package/dist/index.js CHANGED
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.HeliusClient = exports.subscribe_pool_change_by_geyser = exports.LOCAL_EVENT_NAME = exports.COMMITMENT_LEVEL = exports.ONE_SOL_IN_LAMPORTS = void 0;
15
+ exports.get_jito_region = exports.HeliusClient = exports.subscribe_pool_change_by_geyser = exports.LOCAL_EVENT_NAME = exports.COMMITMENT_LEVEL = exports.ONE_SOL_IN_LAMPORTS = void 0;
16
16
  const ws_1 = __importDefault(require("ws"));
17
17
  const dist_1 = require("@clonegod/ttd-common/dist");
18
18
  const helius_sdk_1 = require("helius-sdk");
@@ -105,13 +105,14 @@ const subscribe_pool_change_by_geyser = (geyser_ws_url, pool_list, eventEmitter)
105
105
  exports.subscribe_pool_change_by_geyser = subscribe_pool_change_by_geyser;
106
106
  class HeliusClient {
107
107
  constructor(signers, jito_tip_max = 500000) {
108
+ this.cluster = 'mainnet-beta';
108
109
  let helius_api_key = process.env.HELIUS_API_KEY;
109
110
  let helius_mainnet_endpoint = `https://mainnet.helius-rpc.com/?api-key=${helius_api_key}`;
110
111
  let helius_staked_endpoint = `https://staked.helius-rpc.com?api-key=${helius_api_key}`;
111
112
  let quicknode_endpoint = process.env.QUICKNODE_ENDPOINT;
112
- this.helius_mainnet = new helius_sdk_1.Helius(null, null, null, helius_mainnet_endpoint);
113
- this.helius_staked = new helius_sdk_1.Helius(null, null, null, helius_staked_endpoint);
114
- this.helius_qn = new helius_sdk_1.Helius(null, null, null, quicknode_endpoint);
113
+ this.helius_mainnet = new helius_sdk_1.Helius('', this.cluster, 'helius-sdk', helius_mainnet_endpoint);
114
+ this.helius_staked = new helius_sdk_1.Helius('', this.cluster, 'helius-sdk', helius_staked_endpoint);
115
+ this.helius_qn = new helius_sdk_1.Helius('', this.cluster, 'helius-sdk', quicknode_endpoint);
115
116
  this.signers = signers;
116
117
  this.sendOptions = {
117
118
  skipPreflight: true,
@@ -123,8 +124,8 @@ class HeliusClient {
123
124
  return __awaiter(this, arguments, void 0, function* (instructions, use_staked_endpint = false) {
124
125
  (0, dist_1.log_info)(`send_smart_transaction, start`);
125
126
  let start_time = Date.now();
126
- let helius_rpc = use_staked_endpint ? this.helius_staked.rpc : this.helius_mainnet.rpc;
127
- let txid = yield helius_rpc.sendSmartTransaction(instructions, this.signers, [], this.sendOptions);
127
+ let rpc = use_staked_endpint ? this.helius_staked.rpc : this.helius_mainnet.rpc;
128
+ let txid = yield rpc.sendSmartTransaction(instructions, this.signers, [], this.sendOptions);
128
129
  (0, dist_1.log_info)(`send_smart_transaction, end`, {
129
130
  txid,
130
131
  use_staked_endpint,
@@ -133,14 +134,16 @@ class HeliusClient {
133
134
  return txid;
134
135
  });
135
136
  }
136
- send_transaction_by_jito(instructions, tipAmount, region) {
137
+ send_transaction_by_jito(instructions, tipAmount) {
137
138
  return __awaiter(this, void 0, void 0, function* () {
138
139
  if (tipAmount > this.jito_tip_max) {
139
140
  tipAmount = this.jito_tip_max;
141
+ (0, dist_1.log_warn)(`tipAmount too high!!! reset from ${tipAmount} to ${this.jito_tip_max}`);
140
142
  }
141
143
  (0, dist_1.log_info)(`send_transaction_by_jito, start`);
142
144
  let start_time = Date.now();
143
- let txid = yield this.helius_qn.rpc.sendSmartTransactionWithTip(instructions, this.signers, [], tipAmount, region);
145
+ let rpc = this.helius_qn.rpc;
146
+ let txid = yield rpc.sendSmartTransactionWithTip(instructions, this.signers, [], tipAmount, (0, exports.get_jito_region)());
144
147
  (0, dist_1.log_info)(`send_transaction_by_jito, end`, {
145
148
  txid,
146
149
  take_time: Date.now() - start_time
@@ -150,3 +153,26 @@ class HeliusClient {
150
153
  }
151
154
  }
152
155
  exports.HeliusClient = HeliusClient;
156
+ const get_jito_region = () => {
157
+ let jito_region;
158
+ let server_info = (0, dist_1.getServerInfo)();
159
+ switch (server_info.region) {
160
+ case 'fra':
161
+ jito_region = 'Frankfurt';
162
+ break;
163
+ case 'virginia':
164
+ jito_region = 'NY';
165
+ break;
166
+ case 'jp':
167
+ jito_region = 'Tokyo';
168
+ break;
169
+ default:
170
+ jito_region = 'Default';
171
+ }
172
+ (0, dist_1.log_debug)(`get_jito_region`, {
173
+ server_info,
174
+ jito_region
175
+ });
176
+ return jito_region;
177
+ };
178
+ exports.get_jito_region = get_jito_region;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clonegod/ttd-sol-common",
3
- "version": "1.0.13",
3
+ "version": "1.0.15",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "types/index.d.ts",