@clonegod/ttd-sol-common 1.2.1 → 2.0.0
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 +0 -7
- package/dist/index.js +0 -23
- package/package.json +31 -32
- package/src/index.ts +0 -0
- package/tsconfig.json +22 -0
- package/dist/appconfig/app_config.d.ts +0 -23
- package/dist/appconfig/app_config.js +0 -134
- package/dist/appconfig/env_args.d.ts +0 -27
- package/dist/appconfig/env_args.js +0 -39
- package/dist/appconfig/index.d.ts +0 -2
- package/dist/appconfig/index.js +0 -18
- package/dist/common/constants.d.ts +0 -12
- package/dist/common/constants.js +0 -18
- package/dist/common/context.d.ts +0 -23
- package/dist/common/context.js +0 -51
- package/dist/common/index.d.ts +0 -2
- package/dist/common/index.js +0 -18
- package/dist/helius_geyser_ws/index.d.ts +0 -3
- package/dist/helius_geyser_ws/index.js +0 -19
- package/dist/helius_geyser_ws/subscribe_pool_change_by_geyser.d.ts +0 -3
- package/dist/helius_geyser_ws/subscribe_pool_change_by_geyser.js +0 -102
- package/dist/helius_geyser_ws/subscribe_txid.d.ts +0 -2
- package/dist/helius_geyser_ws/subscribe_txid.js +0 -109
- package/dist/helius_geyser_ws/subscribe_wallet_transaction.d.ts +0 -2
- package/dist/helius_geyser_ws/subscribe_wallet_transaction.js +0 -102
- package/dist/helius_sdk_v1.4.0/Helius.d.ts +0 -31
- package/dist/helius_sdk_v1.4.0/Helius.js +0 -450
- package/dist/helius_sdk_v1.4.0/RpcClient.d.ts +0 -70
- package/dist/helius_sdk_v1.4.0/RpcClient.js +0 -978
- package/dist/helius_sdk_v1.4.0/constants.d.ts +0 -1
- package/dist/helius_sdk_v1.4.0/constants.js +0 -4
- package/dist/helius_sdk_v1.4.0/index.d.ts +0 -5
- package/dist/helius_sdk_v1.4.0/index.js +0 -21
- package/dist/helius_sdk_v1.4.0/types/das-types.d.ts +0 -408
- package/dist/helius_sdk_v1.4.0/types/das-types.js +0 -2
- package/dist/helius_sdk_v1.4.0/types/enums.d.ts +0 -542
- package/dist/helius_sdk_v1.4.0/types/enums.js +0 -606
- package/dist/helius_sdk_v1.4.0/types/index.d.ts +0 -3
- package/dist/helius_sdk_v1.4.0/types/index.js +0 -19
- package/dist/helius_sdk_v1.4.0/types/types.d.ts +0 -305
- package/dist/helius_sdk_v1.4.0/types/types.js +0 -2
- package/dist/helius_sdk_v1.4.0/utils/get-helius-endpoints.d.ts +0 -2
- package/dist/helius_sdk_v1.4.0/utils/get-helius-endpoints.js +0 -19
- package/dist/helius_sdk_v1.4.0/utils/index.d.ts +0 -1
- package/dist/helius_sdk_v1.4.0/utils/index.js +0 -17
- package/dist/helius_sdk_v1.4.0/utils/mintApi.d.ts +0 -2
- package/dist/helius_sdk_v1.4.0/utils/mintApi.js +0 -14
- package/dist/jito/index.d.ts +0 -14
- package/dist/jito/index.js +0 -142
- package/dist/jito/jitodontfront.d.ts +0 -5
- package/dist/jito/jitodontfront.js +0 -41
- package/dist/quote/index.d.ts +0 -3
- package/dist/quote/index.js +0 -19
- package/dist/quote/log_quote_price.d.ts +0 -2
- package/dist/quote/log_quote_price.js +0 -29
- package/dist/quote/publish_quote_price.d.ts +0 -3
- package/dist/quote/publish_quote_price.js +0 -19
- package/dist/quote/to_price_message.d.ts +0 -5
- package/dist/quote/to_price_message.js +0 -103
- package/dist/send_tx/get_jito_tip_floor.d.ts +0 -1
- package/dist/send_tx/get_jito_tip_floor.js +0 -86
- package/dist/send_tx/get_signature.d.ts +0 -2
- package/dist/send_tx/get_signature.js +0 -17
- package/dist/send_tx/helius_client.d.ts +0 -16
- package/dist/send_tx/helius_client.js +0 -119
- package/dist/send_tx/index.d.ts +0 -4
- package/dist/send_tx/index.js +0 -20
- package/dist/send_tx/notify_new_txid.d.ts +0 -1
- package/dist/send_tx/notify_new_txid.js +0 -20
- package/dist/send_tx/sol_gas_cache.d.ts +0 -3
- package/dist/send_tx/sol_gas_cache.js +0 -15
- package/dist/send_tx/strategy_util.d.ts +0 -7
- package/dist/send_tx/strategy_util.js +0 -147
- package/dist/token/get_token_info.d.ts +0 -4
- package/dist/token/get_token_info.js +0 -136
- package/dist/token/get_token_price.d.ts +0 -6
- package/dist/token/get_token_price.js +0 -186
- package/dist/token/index.d.ts +0 -4
- package/dist/token/index.js +0 -20
- package/dist/token/types.d.ts +0 -17
- package/dist/token/types.js +0 -2
- package/dist/token/util.d.ts +0 -3
- package/dist/token/util.js +0 -33
- package/dist/trade/abstract_trade.d.ts +0 -5
- package/dist/trade/abstract_trade.js +0 -6
- package/dist/trade/handle_order_message.d.ts +0 -4
- package/dist/trade/handle_order_message.js +0 -118
- package/dist/trade/index.d.ts +0 -4
- package/dist/trade/index.js +0 -20
- package/dist/trade/tx_result_check.d.ts +0 -29
- package/dist/trade/tx_result_check.js +0 -232
- package/dist/trade/tx_result_parse.d.ts +0 -13
- package/dist/trade/tx_result_parse.js +0 -150
- package/grpc/transaction/LThcUp2D5p4JgRMnWEUVVSdNEHiq5YfN5HXPGRYeWBfypMT3aTa1CaC9XdPT69CyMdoJ32XAkjXAa2TmBYBeZAy.json +0 -1
- package/types/index.d.ts +0 -71
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.get_quote_token_decimals = void 0;
|
|
16
|
-
exports.to_price_message = to_price_message;
|
|
17
|
-
exports.normalize_pair_name = normalize_pair_name;
|
|
18
|
-
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
19
|
-
const uuid_1 = require("uuid");
|
|
20
|
-
const dist_1 = require("@clonegod/ttd-core/dist");
|
|
21
|
-
const get_quote_token_decimals = (pool_info) => {
|
|
22
|
-
let decimals = 9;
|
|
23
|
-
let { tokenA, tokenB, quote_token } = pool_info;
|
|
24
|
-
if (tokenA.symbol === quote_token) {
|
|
25
|
-
decimals = tokenA.decimals;
|
|
26
|
-
}
|
|
27
|
-
if (tokenB.symbol === quote_token) {
|
|
28
|
-
decimals = tokenB.decimals;
|
|
29
|
-
}
|
|
30
|
-
return decimals;
|
|
31
|
-
};
|
|
32
|
-
exports.get_quote_token_decimals = get_quote_token_decimals;
|
|
33
|
-
function to_price_message(appConfig, quote_amount_usd, tx_price, quote_ask_price, quote_bid_price, pool_info, time, slot) {
|
|
34
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
-
let { pool_address, tokenA, tokenB } = pool_info;
|
|
36
|
-
let { dex_id, pool_name, fee_rate, is_reverse_token } = yield appConfig.arb_cache.get_one_pool_info(pool_address);
|
|
37
|
-
let _dex_id = dex_id;
|
|
38
|
-
let price_id = (0, uuid_1.v4)().replace(/-/gi, '');
|
|
39
|
-
let chain_id = appConfig.env_args.chain_id;
|
|
40
|
-
let unique_orderbook_id = (0, dist_1.format_unique_orderbook_id)(chain_id, _dex_id, pool_address, fee_rate);
|
|
41
|
-
time.price_time = new Date().getTime();
|
|
42
|
-
let fee_rate_bps = fee_rate / 100100;
|
|
43
|
-
let ask_price = getAskPrice(new decimal_js_1.default(quote_ask_price), fee_rate_bps * 0);
|
|
44
|
-
let bid_price = getBidPrice(new decimal_js_1.default(quote_bid_price), fee_rate_bps * 0);
|
|
45
|
-
let price_message = {
|
|
46
|
-
chain_id,
|
|
47
|
-
dex_id,
|
|
48
|
-
price_id,
|
|
49
|
-
pool_id: pool_address,
|
|
50
|
-
pool_name,
|
|
51
|
-
fee_rate,
|
|
52
|
-
pair: pool_name,
|
|
53
|
-
unique_orderbook_id,
|
|
54
|
-
is_reverse_token,
|
|
55
|
-
tokenA: {
|
|
56
|
-
symbol: tokenA.symbol,
|
|
57
|
-
address: tokenA.address,
|
|
58
|
-
address_hex: tokenA.address_hex,
|
|
59
|
-
decimals: tokenA.decimals,
|
|
60
|
-
name: tokenA.name,
|
|
61
|
-
enable: true,
|
|
62
|
-
},
|
|
63
|
-
tokenB: {
|
|
64
|
-
symbol: tokenB.symbol,
|
|
65
|
-
address: tokenB.address,
|
|
66
|
-
address_hex: tokenB.address_hex,
|
|
67
|
-
decimals: tokenB.decimals,
|
|
68
|
-
name: tokenB.name,
|
|
69
|
-
enable: true,
|
|
70
|
-
},
|
|
71
|
-
tx_price: tx_price === null || tx_price === void 0 ? void 0 : tx_price.toFixed(12),
|
|
72
|
-
quote_amount_usd,
|
|
73
|
-
ask: {
|
|
74
|
-
price: ask_price,
|
|
75
|
-
quantity: quote_amount_usd
|
|
76
|
-
},
|
|
77
|
-
bid: {
|
|
78
|
-
price: bid_price,
|
|
79
|
-
quantity: quote_amount_usd
|
|
80
|
-
},
|
|
81
|
-
time,
|
|
82
|
-
slot
|
|
83
|
-
};
|
|
84
|
-
normalize_pair_name(price_message);
|
|
85
|
-
return price_message;
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
const getAskPrice = (price, feeRate) => {
|
|
89
|
-
return price.mul(1 + feeRate).toFixed(12);
|
|
90
|
-
};
|
|
91
|
-
const getBidPrice = (price, feeRate) => {
|
|
92
|
-
return price.mul(1 - feeRate).toFixed(12);
|
|
93
|
-
};
|
|
94
|
-
function normalize_pair_name(priceMessage) {
|
|
95
|
-
let { pool_name, is_reverse_token } = priceMessage;
|
|
96
|
-
if (is_reverse_token) {
|
|
97
|
-
pool_name = pool_name.split('/')[1] + '/' + pool_name.split('/')[0];
|
|
98
|
-
}
|
|
99
|
-
const dex_pair_names = pool_name.split('/');
|
|
100
|
-
let cex_base_token = (0, dist_1.format_symbol_name)(dex_pair_names[0]);
|
|
101
|
-
let cex_qutoe_token = (0, dist_1.format_symbol_name)(dex_pair_names[1]);
|
|
102
|
-
priceMessage.pair = cex_base_token.toUpperCase() + '/' + cex_qutoe_token.toUpperCase();
|
|
103
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function get_latest_jito_tip(speed: string, fee_max_cap: number, tip_up_ratio?: number): Promise<number>;
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.get_latest_jito_tip = get_latest_jito_tip;
|
|
13
|
-
const dist_1 = require("@clonegod/ttd-core/dist");
|
|
14
|
-
const web3_js_1 = require("@solana/web3.js");
|
|
15
|
-
const jito_tip_stats_url = process.env.JITO_TIP_FEE_STATS_URL || 'https://bundles.jito.wtf/api/v1/bundles/tip_floor';
|
|
16
|
-
const JITO_TIP_DEFAULT = 0.00018;
|
|
17
|
-
const JITO_TIP_MIN = 0.00008;
|
|
18
|
-
const JITO_TIP_MAX = 0.001;
|
|
19
|
-
function get_jito_tip_floor_from_cache() {
|
|
20
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
-
let tip_floor = null;
|
|
22
|
-
try {
|
|
23
|
-
let appConfig = global.appConfig;
|
|
24
|
-
let { key, value } = yield appConfig.arb_cache.loading_cache.get(dist_1.CHAIN_ID.SOLANA, 'jito', 'tip', true);
|
|
25
|
-
if (value) {
|
|
26
|
-
tip_floor = JSON.parse(value);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
catch (err) {
|
|
30
|
-
(0, dist_1.log_error)('get_jito_tip_floor_from_cache error!', err);
|
|
31
|
-
}
|
|
32
|
-
if (tip_floor && tip_floor["landed_tips_75th_percentile"] > 0) {
|
|
33
|
-
return tip_floor;
|
|
34
|
-
}
|
|
35
|
-
return null;
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
function get_jito_tip_floor() {
|
|
39
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
-
try {
|
|
41
|
-
let res = yield (yield fetch(jito_tip_stats_url)).json();
|
|
42
|
-
(0, dist_1.log_debug)(`get_jito_tip_floor, res=`, res);
|
|
43
|
-
return res[0];
|
|
44
|
-
}
|
|
45
|
-
catch (err) {
|
|
46
|
-
(0, dist_1.log_error)('get_jito_tip_floor error!', err);
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
function get_latest_jito_tip(speed_1, fee_max_cap_1) {
|
|
51
|
-
return __awaiter(this, arguments, void 0, function* (speed, fee_max_cap, tip_up_ratio = 1.3) {
|
|
52
|
-
let tip_sol = JITO_TIP_DEFAULT;
|
|
53
|
-
let jito_tip_floor = yield get_jito_tip_floor_from_cache();
|
|
54
|
-
if (!jito_tip_floor) {
|
|
55
|
-
jito_tip_floor = yield get_jito_tip_floor();
|
|
56
|
-
}
|
|
57
|
-
if (jito_tip_floor) {
|
|
58
|
-
if (speed === 'fast') {
|
|
59
|
-
tip_sol = jito_tip_floor['landed_tips_50th_percentile'];
|
|
60
|
-
}
|
|
61
|
-
if (speed === 'turbo') {
|
|
62
|
-
tip_sol = jito_tip_floor['landed_tips_75th_percentile'];
|
|
63
|
-
}
|
|
64
|
-
if (speed === 'ultra') {
|
|
65
|
-
tip_sol = jito_tip_floor['landed_tips_95th_percentile'];
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
if (tip_sol < JITO_TIP_MIN) {
|
|
69
|
-
tip_sol = JITO_TIP_MIN;
|
|
70
|
-
}
|
|
71
|
-
if (tip_sol > JITO_TIP_MAX) {
|
|
72
|
-
tip_sol = JITO_TIP_MAX;
|
|
73
|
-
}
|
|
74
|
-
let tip_lamports = Math.ceil((tip_sol * tip_up_ratio) * web3_js_1.LAMPORTS_PER_SOL);
|
|
75
|
-
if (tip_lamports > fee_max_cap) {
|
|
76
|
-
tip_lamports = fee_max_cap;
|
|
77
|
-
}
|
|
78
|
-
(0, dist_1.log_info)('get_latest_jito_tip', {
|
|
79
|
-
jito_tip_floor,
|
|
80
|
-
tip_sol,
|
|
81
|
-
tip_up_ratio,
|
|
82
|
-
tip_lamports
|
|
83
|
-
});
|
|
84
|
-
return tip_lamports;
|
|
85
|
-
});
|
|
86
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getSignature = getSignature;
|
|
7
|
-
const bs58_1 = __importDefault(require("bs58"));
|
|
8
|
-
const notify_new_txid_1 = require("./notify_new_txid");
|
|
9
|
-
function getSignature(transaction) {
|
|
10
|
-
const signature = 'signature' in transaction ? transaction.signature : transaction.signatures[0];
|
|
11
|
-
if (!signature) {
|
|
12
|
-
throw new Error('Missing transaction signature, the transaction was not signed by the fee payer');
|
|
13
|
-
}
|
|
14
|
-
let txid = bs58_1.default.encode(signature);
|
|
15
|
-
(0, notify_new_txid_1.notify_new_txid)(txid);
|
|
16
|
-
return txid;
|
|
17
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { AddressLookupTableAccount, SendOptions, Signer, TransactionInstruction, VersionedTransaction } from "@solana/web3.js";
|
|
2
|
-
import { SolanaTradeRuntimeType } from '../../types';
|
|
3
|
-
import { Helius } from "../helius_sdk_v1.4.0";
|
|
4
|
-
export declare class HeliusClient {
|
|
5
|
-
signers: Signer[];
|
|
6
|
-
sendOptions: SendOptions;
|
|
7
|
-
cluster: string;
|
|
8
|
-
helius_mainnet: Helius;
|
|
9
|
-
helius_staked: Helius;
|
|
10
|
-
constructor(signers: Signer[]);
|
|
11
|
-
send_transaction(solana_trade_runtime: SolanaTradeRuntimeType, instructions: TransactionInstruction[], addressLookupTableAccounts?: AddressLookupTableAccount[]): Promise<string>;
|
|
12
|
-
send_transaction_jup_ag_with_jito(solana_trade_runtime: SolanaTradeRuntimeType, transaction: VersionedTransaction): Promise<string>;
|
|
13
|
-
private send_smart_transaction;
|
|
14
|
-
private send_transaction_by_jito;
|
|
15
|
-
private send_transaction_mixed;
|
|
16
|
-
}
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.HeliusClient = void 0;
|
|
13
|
-
const dist_1 = require("@clonegod/ttd-core/dist");
|
|
14
|
-
const helius_sdk_v1_4_0_1 = require("../helius_sdk_v1.4.0");
|
|
15
|
-
const strategy_util_1 = require("./strategy_util");
|
|
16
|
-
const sol_gas_cache_1 = require("./sol_gas_cache");
|
|
17
|
-
class HeliusClient {
|
|
18
|
-
constructor(signers) {
|
|
19
|
-
this.cluster = 'mainnet-beta';
|
|
20
|
-
this.signers = signers;
|
|
21
|
-
this.sendOptions = {
|
|
22
|
-
skipPreflight: true,
|
|
23
|
-
maxRetries: 3
|
|
24
|
-
};
|
|
25
|
-
let helius_api_key = process.env.HELIUS_API_KEY || '';
|
|
26
|
-
let helius_mainnet_endpoint = `https://mainnet.helius-rpc.com/?api-key=${helius_api_key}`;
|
|
27
|
-
let helius_staked_endpoint = `https://staked.helius-rpc.com?api-key=${helius_api_key}`;
|
|
28
|
-
this.helius_mainnet = new helius_sdk_v1_4_0_1.Helius('', this.cluster, 'helius-sdk', helius_mainnet_endpoint);
|
|
29
|
-
this.helius_staked = new helius_sdk_v1_4_0_1.Helius('', this.cluster, 'helius-sdk', helius_staked_endpoint);
|
|
30
|
-
}
|
|
31
|
-
send_transaction(solana_trade_runtime_1, instructions_1) {
|
|
32
|
-
return __awaiter(this, arguments, void 0, function* (solana_trade_runtime, instructions, addressLookupTableAccounts = []) {
|
|
33
|
-
let txid = '';
|
|
34
|
-
let { broadcast_type, speed } = solana_trade_runtime.settings.strategy;
|
|
35
|
-
let use_staked_endpint = speed === 'turbo' || speed === 'ultra';
|
|
36
|
-
if (broadcast_type === 'rpc') {
|
|
37
|
-
txid = yield this.send_smart_transaction(solana_trade_runtime, instructions, use_staked_endpint, addressLookupTableAccounts);
|
|
38
|
-
}
|
|
39
|
-
else if (broadcast_type === 'jito') {
|
|
40
|
-
txid = yield this.send_transaction_by_jito(solana_trade_runtime, instructions, addressLookupTableAccounts);
|
|
41
|
-
}
|
|
42
|
-
else if (broadcast_type === 'mixed') {
|
|
43
|
-
txid = yield this.send_transaction_mixed(solana_trade_runtime, instructions, use_staked_endpint, addressLookupTableAccounts);
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
throw new Error(`Not support broadcast_type: ${broadcast_type}`);
|
|
47
|
-
}
|
|
48
|
-
return txid;
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
send_transaction_jup_ag_with_jito(solana_trade_runtime, transaction) {
|
|
52
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
-
(0, dist_1.log_info)(`send_transaction_jup_ag_with_jito, start`);
|
|
54
|
-
let start_time = Date.now();
|
|
55
|
-
let { tip_amount: jito_tip_fee, priority_fee } = solana_trade_runtime;
|
|
56
|
-
let jito_region = (0, strategy_util_1.get_jito_region)();
|
|
57
|
-
let rpc = this.helius_mainnet.rpc;
|
|
58
|
-
let txid = yield rpc.send_jup_ag_tx_by_jito(solana_trade_runtime, transaction, this.signers, jito_tip_fee, jito_region);
|
|
59
|
-
(0, sol_gas_cache_1.set_sol_gas_fee)(txid, { priority_fee, jito_tip_fee });
|
|
60
|
-
(0, dist_1.log_info)(`send_transaction_jup_ag_with_jito, end`, {
|
|
61
|
-
jito_tip_fee,
|
|
62
|
-
jito_region,
|
|
63
|
-
txid,
|
|
64
|
-
take_time: Date.now() - start_time
|
|
65
|
-
});
|
|
66
|
-
return txid;
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
send_smart_transaction(solana_trade_runtime_1, instructions_1, use_staked_endpint_1) {
|
|
70
|
-
return __awaiter(this, arguments, void 0, function* (solana_trade_runtime, instructions, use_staked_endpint, addressLookupTableAccounts = []) {
|
|
71
|
-
(0, dist_1.log_info)(`send_smart_transaction, start`);
|
|
72
|
-
let start_time = Date.now();
|
|
73
|
-
let rpc = this.helius_mainnet.rpc;
|
|
74
|
-
let txid = yield rpc.sendSmartTransaction(solana_trade_runtime, instructions, this.signers, addressLookupTableAccounts, this.sendOptions);
|
|
75
|
-
(0, dist_1.log_info)(`send_smart_transaction, end`, {
|
|
76
|
-
txid,
|
|
77
|
-
use_staked_endpint,
|
|
78
|
-
take_time: Date.now() - start_time
|
|
79
|
-
});
|
|
80
|
-
return txid;
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
send_transaction_by_jito(solana_trade_runtime_1, instructions_1) {
|
|
84
|
-
return __awaiter(this, arguments, void 0, function* (solana_trade_runtime, instructions, addressLookupTableAccounts = []) {
|
|
85
|
-
(0, dist_1.log_info)(`send_transaction_by_jito, start`);
|
|
86
|
-
let start_time = Date.now();
|
|
87
|
-
let { tip_amount: jito_tip_fee, priority_fee } = solana_trade_runtime;
|
|
88
|
-
let jito_region = (0, strategy_util_1.get_jito_region)();
|
|
89
|
-
let rpc = this.helius_mainnet.rpc;
|
|
90
|
-
let txid = yield rpc.sendSmartTransactionWithTip(solana_trade_runtime, instructions, this.signers, addressLookupTableAccounts, jito_tip_fee, jito_region);
|
|
91
|
-
(0, sol_gas_cache_1.set_sol_gas_fee)(txid, { priority_fee, jito_tip_fee });
|
|
92
|
-
(0, dist_1.log_info)(`send_transaction_by_jito, end`, {
|
|
93
|
-
jito_tip_fee,
|
|
94
|
-
jito_region,
|
|
95
|
-
txid,
|
|
96
|
-
take_time: Date.now() - start_time
|
|
97
|
-
});
|
|
98
|
-
return txid;
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
send_transaction_mixed(solana_trade_runtime_1, instructions_1, use_staked_endpint_1) {
|
|
102
|
-
return __awaiter(this, arguments, void 0, function* (solana_trade_runtime, instructions, use_staked_endpint, addressLookupTableAccounts = []) {
|
|
103
|
-
(0, dist_1.log_info)(`send_transaction_mixed, start`);
|
|
104
|
-
let start_time = Date.now();
|
|
105
|
-
let tipAmount = solana_trade_runtime.tip_amount;
|
|
106
|
-
let jito_region = (0, strategy_util_1.get_jito_region)();
|
|
107
|
-
let rpc = use_staked_endpint ? this.helius_staked.rpc : this.helius_mainnet.rpc;
|
|
108
|
-
let txid = yield rpc.sendSmartTransactionWithTipMixed(solana_trade_runtime, instructions, this.signers, addressLookupTableAccounts, tipAmount, jito_region);
|
|
109
|
-
(0, dist_1.log_info)(`send_transaction_mixed, end`, {
|
|
110
|
-
tipAmount,
|
|
111
|
-
jito_region,
|
|
112
|
-
txid,
|
|
113
|
-
take_time: Date.now() - start_time
|
|
114
|
-
});
|
|
115
|
-
return txid;
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
exports.HeliusClient = HeliusClient;
|
package/dist/send_tx/index.d.ts
DELETED
package/dist/send_tx/index.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./get_signature"), exports);
|
|
18
|
-
__exportStar(require("./helius_client"), exports);
|
|
19
|
-
__exportStar(require("./strategy_util"), exports);
|
|
20
|
-
__exportStar(require("./sol_gas_cache"), exports);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const notify_new_txid: (txid: string) => Promise<void>;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.notify_new_txid = void 0;
|
|
13
|
-
const common_1 = require("../common");
|
|
14
|
-
const notify_new_txid = (txid) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
|
-
if (!global.event_emitter) {
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
global.event_emitter.emit(common_1.LOCAL_EVENT_NAME.EVENT_WALLET_TRANSACTION_NEW_TXID, txid);
|
|
19
|
-
});
|
|
20
|
-
exports.notify_new_txid = notify_new_txid;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.get_sol_gas_fee = exports.set_sol_gas_fee = void 0;
|
|
4
|
-
var tx_gas_map = new Map();
|
|
5
|
-
const set_sol_gas_fee = (txid, sol_gas_fee) => {
|
|
6
|
-
tx_gas_map.set(txid, sol_gas_fee);
|
|
7
|
-
};
|
|
8
|
-
exports.set_sol_gas_fee = set_sol_gas_fee;
|
|
9
|
-
const get_sol_gas_fee = (txid) => {
|
|
10
|
-
if (tx_gas_map.has(txid)) {
|
|
11
|
-
return tx_gas_map.get(txid);
|
|
12
|
-
}
|
|
13
|
-
return null;
|
|
14
|
-
};
|
|
15
|
-
exports.get_sol_gas_fee = get_sol_gas_fee;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { StandardPoolInfoType, TradeRuntimeType, TradeStrategyType } from "@clonegod/ttd-core";
|
|
2
|
-
import { JitoRegion } from "../helius_sdk_v1.4.0";
|
|
3
|
-
import { Connection } from "@solana/web3.js";
|
|
4
|
-
import { SolanaTradeRuntimeType } from "../../types";
|
|
5
|
-
export declare function create_solana_trade_runtime(connection: Connection, trade_runtime: TradeRuntimeType, pool_info: StandardPoolInfoType): Promise<SolanaTradeRuntimeType>;
|
|
6
|
-
export declare function calculate_gas_fee(trade_strategy: TradeStrategyType): Promise<number>;
|
|
7
|
-
export declare function get_jito_region(): JitoRegion;
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.create_solana_trade_runtime = create_solana_trade_runtime;
|
|
13
|
-
exports.calculate_gas_fee = calculate_gas_fee;
|
|
14
|
-
exports.get_jito_region = get_jito_region;
|
|
15
|
-
const dist_1 = require("@clonegod/ttd-core/dist");
|
|
16
|
-
const constants_1 = require("../common/constants");
|
|
17
|
-
const get_jito_tip_floor_1 = require("./get_jito_tip_floor");
|
|
18
|
-
const DEFAULT_TIP_RATIO = 0.3;
|
|
19
|
-
function create_solana_trade_runtime(connection, trade_runtime, pool_info) {
|
|
20
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
-
let trade_strategy = trade_runtime.settings.strategy;
|
|
22
|
-
let { total_gas, priority_fee, tip_amount } = yield get_priority_fee_and_tip(trade_strategy);
|
|
23
|
-
let { cu_limit } = pool_info;
|
|
24
|
-
if (isNaN(cu_limit) || cu_limit < 35000) {
|
|
25
|
-
cu_limit = 35000;
|
|
26
|
-
}
|
|
27
|
-
let cu_price = Math.ceil(priority_fee * constants_1.ONE_MILLION / cu_limit);
|
|
28
|
-
let jito_use_separate_tx = process.env.JITO_USE_SEPARATE_TIP_TX === 'true';
|
|
29
|
-
(0, dist_1.log_info)(`trade_strategy & gas`, {
|
|
30
|
-
trade_strategy,
|
|
31
|
-
total_gas,
|
|
32
|
-
priority_fee,
|
|
33
|
-
cu_limit,
|
|
34
|
-
cu_price,
|
|
35
|
-
tip_amount
|
|
36
|
-
});
|
|
37
|
-
let solana_trade_runtime = Object.assign(Object.assign({}, trade_runtime), { connection,
|
|
38
|
-
total_gas,
|
|
39
|
-
priority_fee,
|
|
40
|
-
cu_limit,
|
|
41
|
-
cu_price,
|
|
42
|
-
tip_amount,
|
|
43
|
-
jito_use_separate_tx });
|
|
44
|
-
return solana_trade_runtime;
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
function get_priority_fee_and_tip(trade_strategy) {
|
|
48
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
49
|
-
let priority_fee = 0;
|
|
50
|
-
let tip_amount = 0;
|
|
51
|
-
let tip_ratio = trade_strategy.tip_ratio || DEFAULT_TIP_RATIO;
|
|
52
|
-
let total_gas = yield calculate_gas_fee(trade_strategy);
|
|
53
|
-
if (trade_strategy.broadcast_type === 'rpc') {
|
|
54
|
-
priority_fee = total_gas;
|
|
55
|
-
tip_amount = 0;
|
|
56
|
-
}
|
|
57
|
-
else if (trade_strategy.broadcast_type === 'jito') {
|
|
58
|
-
priority_fee = 0;
|
|
59
|
-
tip_amount = total_gas;
|
|
60
|
-
}
|
|
61
|
-
else if (trade_strategy.broadcast_type === 'mixed') {
|
|
62
|
-
if (tip_ratio < 0 || tip_ratio > 1) {
|
|
63
|
-
tip_ratio = DEFAULT_TIP_RATIO;
|
|
64
|
-
}
|
|
65
|
-
tip_amount = Math.ceil(total_gas * tip_ratio);
|
|
66
|
-
priority_fee = total_gas - tip_amount;
|
|
67
|
-
}
|
|
68
|
-
return {
|
|
69
|
-
total_gas,
|
|
70
|
-
priority_fee,
|
|
71
|
-
tip_amount
|
|
72
|
-
};
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
function calculate_gas_fee(trade_strategy) {
|
|
76
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
77
|
-
let { speed, fee_mode, fee_exact, fee_max_cap, tip_up_ratio, broadcast_type } = trade_strategy;
|
|
78
|
-
if (isNaN(tip_up_ratio) || tip_up_ratio < 1) {
|
|
79
|
-
tip_up_ratio = 1;
|
|
80
|
-
}
|
|
81
|
-
let gas_fee = 1000;
|
|
82
|
-
switch (fee_mode) {
|
|
83
|
-
case "exact":
|
|
84
|
-
gas_fee = get_excat_fee_by_speed(speed, fee_exact);
|
|
85
|
-
break;
|
|
86
|
-
case "max_cap":
|
|
87
|
-
if (broadcast_type === 'jito') {
|
|
88
|
-
gas_fee = yield (0, get_jito_tip_floor_1.get_latest_jito_tip)(speed, fee_max_cap, tip_up_ratio);
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
91
|
-
gas_fee = get_dynamic_fee_by_speed(speed, 50000, fee_max_cap);
|
|
92
|
-
}
|
|
93
|
-
break;
|
|
94
|
-
default:
|
|
95
|
-
throw new Error(`Not support fee_mode: ${fee_mode}`);
|
|
96
|
-
}
|
|
97
|
-
return gas_fee;
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
function get_excat_fee_by_speed(speed, fee_exact) {
|
|
101
|
-
let factor = 1;
|
|
102
|
-
if (speed === 'fast') {
|
|
103
|
-
factor = 1;
|
|
104
|
-
}
|
|
105
|
-
if (speed === 'turbo') {
|
|
106
|
-
factor = 2;
|
|
107
|
-
}
|
|
108
|
-
if (speed === 'ultra') {
|
|
109
|
-
factor = 5;
|
|
110
|
-
}
|
|
111
|
-
return fee_exact * factor;
|
|
112
|
-
}
|
|
113
|
-
function get_dynamic_fee_by_speed(speed, estimate_priority_fee, fee_max_cap) {
|
|
114
|
-
let factor = 1;
|
|
115
|
-
if (speed === 'fast') {
|
|
116
|
-
factor = 1;
|
|
117
|
-
}
|
|
118
|
-
if (speed === 'turbo') {
|
|
119
|
-
factor = 2;
|
|
120
|
-
}
|
|
121
|
-
if (speed === 'ultra') {
|
|
122
|
-
factor = 5;
|
|
123
|
-
}
|
|
124
|
-
return Math.min(estimate_priority_fee * factor, fee_max_cap);
|
|
125
|
-
}
|
|
126
|
-
function get_jito_region() {
|
|
127
|
-
let jito_region;
|
|
128
|
-
let server_info = (0, dist_1.getServerInfo)();
|
|
129
|
-
switch (server_info.region) {
|
|
130
|
-
case 'fra':
|
|
131
|
-
jito_region = 'Frankfurt';
|
|
132
|
-
break;
|
|
133
|
-
case 'virginia':
|
|
134
|
-
jito_region = 'NY';
|
|
135
|
-
break;
|
|
136
|
-
case 'jp':
|
|
137
|
-
jito_region = 'Tokyo';
|
|
138
|
-
break;
|
|
139
|
-
default:
|
|
140
|
-
jito_region = 'Default';
|
|
141
|
-
}
|
|
142
|
-
(0, dist_1.log_debug)(`get_jito_region`, {
|
|
143
|
-
server_info,
|
|
144
|
-
jito_region
|
|
145
|
-
});
|
|
146
|
-
return jito_region;
|
|
147
|
-
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { FormattedTokenInfo } from './types';
|
|
2
|
-
export declare const get_token_basic_info: (symbol: string, mint_address: string) => Promise<FormattedTokenInfo>;
|
|
3
|
-
export declare const get_token_basic_info_from_jupiter: (symbol: string, mint_address: string) => Promise<FormattedTokenInfo>;
|
|
4
|
-
export declare const get_token_basic_info_from_raydium: (symbol: string, mint_address: string) => Promise<FormattedTokenInfo>;
|