@clonegod/ttd-base-common 1.0.1 → 1.0.3

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.
@@ -1 +1,29 @@
1
1
  export declare const ERC20_ABI: string[];
2
+ export declare const UNISWAP_PAIR_FULL_ABI: ({
3
+ anonymous: boolean;
4
+ inputs: {
5
+ indexed: boolean;
6
+ internalType: string;
7
+ name: string;
8
+ type: string;
9
+ }[];
10
+ name: string;
11
+ type: string;
12
+ constant?: undefined;
13
+ outputs?: undefined;
14
+ payable?: undefined;
15
+ stateMutability?: undefined;
16
+ } | {
17
+ constant: boolean;
18
+ inputs: any[];
19
+ name: string;
20
+ outputs: {
21
+ internalType: string;
22
+ name: string;
23
+ type: string;
24
+ }[];
25
+ payable: boolean;
26
+ stateMutability: string;
27
+ type: string;
28
+ anonymous?: undefined;
29
+ })[];
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ERC20_ABI = void 0;
3
+ exports.UNISWAP_PAIR_FULL_ABI = exports.ERC20_ABI = void 0;
4
4
  exports.ERC20_ABI = [
5
5
  'function decimals() view returns (uint8)',
6
6
  'function symbol() view returns (string)',
@@ -12,3 +12,45 @@ exports.ERC20_ABI = [
12
12
  'function approve(address spender, uint256 amount) returns (bool)',
13
13
  'function transferFrom(address sender, address recipient, uint256 amount) returns (bool)'
14
14
  ];
15
+ exports.UNISWAP_PAIR_FULL_ABI = [
16
+ {
17
+ "anonymous": false,
18
+ "inputs": [
19
+ { "indexed": false, "internalType": "uint112", "name": "reserve0", "type": "uint112" },
20
+ { "indexed": false, "internalType": "uint112", "name": "reserve1", "type": "uint112" }
21
+ ],
22
+ "name": "Sync",
23
+ "type": "event"
24
+ },
25
+ {
26
+ "constant": true,
27
+ "inputs": [],
28
+ "name": "token0",
29
+ "outputs": [{ "internalType": "address", "name": "", "type": "address" }],
30
+ "payable": false,
31
+ "stateMutability": "view",
32
+ "type": "function"
33
+ },
34
+ {
35
+ "constant": true,
36
+ "inputs": [],
37
+ "name": "token1",
38
+ "outputs": [{ "internalType": "address", "name": "", "type": "address" }],
39
+ "payable": false,
40
+ "stateMutability": "view",
41
+ "type": "function"
42
+ },
43
+ {
44
+ "constant": true,
45
+ "inputs": [],
46
+ "name": "getReserves",
47
+ "outputs": [
48
+ { "internalType": "uint112", "name": "_reserve0", "type": "uint112" },
49
+ { "internalType": "uint112", "name": "_reserve1", "type": "uint112" },
50
+ { "internalType": "uint32", "name": "_blockTimestampLast", "type": "uint32" }
51
+ ],
52
+ "payable": false,
53
+ "stateMutability": "view",
54
+ "type": "function"
55
+ }
56
+ ];
@@ -7,5 +7,7 @@ export declare class BaseEnvArgs extends EnvArgs {
7
7
  tx_status_check_interval_mills: number;
8
8
  tx_cancel_timeout_ms: number;
9
9
  tx_cancel_gas_boost_factor: number;
10
+ evm_max_gas_price_gwei: string;
11
+ evm_max_priority_fee_per_gas_gwei: string;
10
12
  constructor();
11
13
  }
@@ -10,6 +10,8 @@ class BaseEnvArgs extends dist_1.EnvArgs {
10
10
  this.gas_price_gwei = new decimal_js_1.Decimal(process.env.GAS_PRICE_GWEI || '1').toNumber();
11
11
  this.gas_limit = parseInt(process.env.GAS_LIMIT || '300000');
12
12
  this.tip_amount_gwei = parseInt(process.env.EOA_TIP_AMOUNT_GWEI || '10000');
13
+ this.evm_max_gas_price_gwei = process.env.EVM_MAX_GAS_PRICE_GWEI || '0.01';
14
+ this.evm_max_priority_fee_per_gas_gwei = process.env.EVM_MAX_PRIORITY_FEE_PER_GAS_GWEI || '0.005';
13
15
  this.tx_status_check_interval_mills = parseInt(process.env.TX_STATUS_CHECK_INTERVAL_MILLS || '3000');
14
16
  this.tx_cancel_timeout_ms = parseInt(process.env.TX_CANCEL_TIMEOUT_MS || '15000');
15
17
  this.tx_cancel_gas_boost_factor = new decimal_js_1.Decimal(process.env.TX_CANCEL_GAS_PRICE_BOOST_FACTOR || '1.5').toNumber();
@@ -31,7 +31,7 @@ class BaseTransactionSender {
31
31
  const rpcProviders = [
32
32
  {
33
33
  name: 'Base Official RPC',
34
- enable: process.env.SEND_TX_BASE_OFFICIAL_RPC === 'true' || true,
34
+ enable: process.env.SEND_TX_BASE_OFFICIAL_RPC === 'true',
35
35
  send: () => __awaiter(this, void 0, void 0, function* () {
36
36
  return yield this.rpc.eth_sendRawTransaction(signedMainTx);
37
37
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clonegod/ttd-base-common",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Base common library",
5
5
  "license": "UNLICENSED",
6
6
  "main": "dist/index.js",
@@ -1,11 +0,0 @@
1
- import { EnvArgs } from "@clonegod/ttd-core/dist";
2
- export declare class BscEnvArgs extends EnvArgs {
3
- large_trade_threshold_usd: number;
4
- gas_price_gwei: number;
5
- gas_limit: number;
6
- tip_amount_gwei: number;
7
- tx_status_check_interval_mills: number;
8
- tx_cancel_timeout_ms: number;
9
- tx_cancel_gas_boost_factor: number;
10
- constructor();
11
- }
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BscEnvArgs = void 0;
4
- const dist_1 = require("@clonegod/ttd-core/dist");
5
- const decimal_js_1 = require("decimal.js");
6
- class BscEnvArgs extends dist_1.EnvArgs {
7
- constructor() {
8
- super();
9
- this.large_trade_threshold_usd = parseInt(process.env.LARGE_TRADE_THRESHOLD_USD || '500');
10
- this.gas_price_gwei = new decimal_js_1.Decimal(process.env.GAS_PRICE_GWEI || '1').toNumber();
11
- this.gas_limit = parseInt(process.env.GAS_LIMIT || '300000');
12
- this.tip_amount_gwei = parseInt(process.env.EOA_TIP_AMOUNT_GWEI || '10000');
13
- this.tx_status_check_interval_mills = parseInt(process.env.TX_STATUS_CHECK_INTERVAL_MILLS || '3000');
14
- this.tx_cancel_timeout_ms = parseInt(process.env.TX_CANCEL_TIMEOUT_MS || '15000');
15
- this.tx_cancel_gas_boost_factor = new decimal_js_1.Decimal(process.env.TX_CANCEL_GAS_PRICE_BOOST_FACTOR || '1.5').toNumber();
16
- this.print();
17
- }
18
- }
19
- exports.BscEnvArgs = BscEnvArgs;
@@ -1,18 +0,0 @@
1
- export declare const _48CLUB_BUILDER_CONTROL_EOA = "0x4848489f0b2BEdd788c696e2D79b6b69D7484848";
2
- export interface BundleParams {
3
- txs: string[];
4
- maxBlockNumber?: number;
5
- maxTimestamp?: number;
6
- revertingTxHashes?: string[];
7
- noMerge?: boolean;
8
- backrunTarget?: string;
9
- }
10
- export declare class _48ClubTrade {
11
- private rpcUrl;
12
- private soulPointSignature?;
13
- private provider;
14
- constructor(soulPointSignature?: string);
15
- sendPrivateTransaction(signedTx: string): Promise<string>;
16
- _sendPrivateTransactionWith48SP(signedTx: string): Promise<string>;
17
- sendBundle(params: BundleParams): Promise<string>;
18
- }
@@ -1,97 +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._48ClubTrade = exports._48CLUB_BUILDER_CONTROL_EOA = void 0;
16
- const axios_1 = __importDefault(require("axios"));
17
- const ethers_1 = require("ethers");
18
- exports._48CLUB_BUILDER_CONTROL_EOA = '0x4848489f0b2BEdd788c696e2D79b6b69D7484848';
19
- class _48ClubTrade {
20
- constructor(soulPointSignature) {
21
- this.rpcUrl = process.env._48CLUB_RPC_URL || 'https://puissant-builder.48.club/';
22
- this.soulPointSignature = soulPointSignature;
23
- this.provider = new ethers_1.ethers.providers.JsonRpcProvider(this.rpcUrl);
24
- }
25
- sendPrivateTransaction(signedTx) {
26
- return __awaiter(this, void 0, void 0, function* () {
27
- try {
28
- const response = yield axios_1.default.post(this.rpcUrl, {
29
- jsonrpc: "2.0",
30
- id: "1",
31
- method: "eth_sendRawTransaction",
32
- params: [signedTx]
33
- });
34
- if (response.data.error) {
35
- throw new Error(`RPC Error: ${response.data.error.message}`);
36
- }
37
- return response.data.result;
38
- }
39
- catch (error) {
40
- if (error instanceof Error) {
41
- throw new Error(`48club sendPrivateTransaction failed!!! ${error.message}`);
42
- }
43
- throw new Error('48club sendPrivateTransaction failed!!! Unknown error');
44
- }
45
- });
46
- }
47
- _sendPrivateTransactionWith48SP(signedTx) {
48
- return __awaiter(this, void 0, void 0, function* () {
49
- try {
50
- if (!this.soulPointSignature) {
51
- throw new Error('48 SoulPoint signature is required');
52
- }
53
- const response = yield axios_1.default.post(this.rpcUrl, {
54
- jsonrpc: "2.0",
55
- id: "1",
56
- method: "eth_sendPrivateTransactionWith48SP",
57
- params: [signedTx, this.soulPointSignature]
58
- });
59
- if (response.data.error) {
60
- throw new Error(`RPC Error: ${response.data.error.message}`);
61
- }
62
- return response.data.result;
63
- }
64
- catch (error) {
65
- if (error instanceof Error) {
66
- throw new Error(`48club sendPrivateTransactionWith48SP failed!!! ${error.message}`);
67
- }
68
- throw new Error('48club sendPrivateTransactionWith48SP failed!!! Unknown error');
69
- }
70
- });
71
- }
72
- sendBundle(params) {
73
- return __awaiter(this, void 0, void 0, function* () {
74
- try {
75
- const currentTimestamp = Math.floor(Date.now() / 1000);
76
- const requestParams = Object.assign({ txs: params.txs, maxBlockNumber: params.maxBlockNumber, maxTimestamp: params.maxTimestamp || currentTimestamp + 30, revertingTxHashes: params.revertingTxHashes, noMerge: params.noMerge, backrunTarget: params.backrunTarget }, (this.soulPointSignature ? { '48spSign': this.soulPointSignature } : {}));
77
- const response = yield axios_1.default.post(this.rpcUrl, {
78
- jsonrpc: "2.0",
79
- id: "1",
80
- method: "eth_sendBundle",
81
- params: [requestParams]
82
- });
83
- if (response.data.error) {
84
- throw new Error(`RPC Error: ${response.data.error.message}`);
85
- }
86
- return response.data.result;
87
- }
88
- catch (error) {
89
- if (error instanceof Error) {
90
- throw new Error(`48club sendBundle failed!!! ${error.message}`);
91
- }
92
- throw new Error('48club sendBundle failed!!! Unknown error');
93
- }
94
- });
95
- }
96
- }
97
- exports._48ClubTrade = _48ClubTrade;
@@ -1,7 +0,0 @@
1
- export declare class BlockRazorTrade {
2
- private rpcUrl;
3
- private authToken;
4
- constructor();
5
- sendPrivateTransaction(signedTx: string): Promise<string>;
6
- sendBundle(transactions: string[], maxBlockNumber?: number, revertingTxHashes?: string[]): Promise<string>;
7
- }
@@ -1,79 +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.BlockRazorTrade = void 0;
16
- const dist_1 = require("@clonegod/ttd-core/dist");
17
- const axios_1 = __importDefault(require("axios"));
18
- class BlockRazorTrade {
19
- constructor() {
20
- this.rpcUrl = process.env.BLOCKRAZOR_RPC_URL || 'https://rpc.blockrazor.builders';
21
- this.authToken = process.env.BLOCKRAZOR_AUTH_TOKEN || '';
22
- }
23
- sendPrivateTransaction(signedTx) {
24
- return __awaiter(this, void 0, void 0, function* () {
25
- try {
26
- const response = yield axios_1.default.post(this.rpcUrl, {
27
- jsonrpc: "2.0",
28
- id: "1",
29
- method: "eth_sendPrivateTransaction",
30
- params: [signedTx]
31
- }, {
32
- headers: {
33
- 'Content-Type': 'application/json',
34
- 'Authorization': this.authToken
35
- }
36
- });
37
- if (response.data.error) {
38
- throw new Error(`交易发送失败: ${response.data.error.code} - ${response.data.error.message}`);
39
- }
40
- return response.data.result;
41
- }
42
- catch (error) {
43
- (0, dist_1.log_error)('blockrazor sendPrivateTransaction failed!!!', error);
44
- throw error;
45
- }
46
- });
47
- }
48
- sendBundle(transactions, maxBlockNumber, revertingTxHashes) {
49
- return __awaiter(this, void 0, void 0, function* () {
50
- try {
51
- const currentTimestamp = Math.floor(Date.now() / 1000);
52
- const response = yield axios_1.default.post(this.rpcUrl, {
53
- jsonrpc: "2.0",
54
- id: "1",
55
- method: "eth_sendBundle",
56
- params: [{
57
- txs: transactions,
58
- minTimestamp: currentTimestamp + 1,
59
- maxTimestamp: currentTimestamp + 30,
60
- }]
61
- }, {
62
- headers: {
63
- 'Content-Type': 'application/json',
64
- 'Authorization': this.authToken,
65
- }
66
- });
67
- if (response.data.error) {
68
- throw new Error(`Bundle 发送失败: ${response.data.error.message}`);
69
- }
70
- return response.data.result;
71
- }
72
- catch (error) {
73
- (0, dist_1.log_error)('blockrazor sendBundle failed!!!', error);
74
- throw error;
75
- }
76
- });
77
- }
78
- }
79
- exports.BlockRazorTrade = BlockRazorTrade;
@@ -1,6 +0,0 @@
1
- export declare class BscRpc {
2
- private url;
3
- private headers;
4
- constructor(rpc_endpoint: string);
5
- eth_sendRawTransaction(signedTx: string): Promise<string>;
6
- }
@@ -1,43 +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.BscRpc = void 0;
13
- class BscRpc {
14
- constructor(rpc_endpoint) {
15
- this.url = rpc_endpoint || process.env.BSC_RPC_ENDPOINT || '';
16
- this.headers = new Headers();
17
- this.headers.append("Content-Type", "application/json");
18
- }
19
- eth_sendRawTransaction(signedTx) {
20
- return __awaiter(this, void 0, void 0, function* () {
21
- console.log(`Sending transaction to ${this.url}`);
22
- const raw = JSON.stringify({
23
- jsonrpc: "2.0",
24
- method: "eth_sendRawTransaction",
25
- params: [signedTx],
26
- id: 1
27
- });
28
- const requestOptions = {
29
- method: 'POST',
30
- headers: this.headers,
31
- body: raw,
32
- redirect: 'follow'
33
- };
34
- const response = yield fetch(this.url, requestOptions);
35
- const result = yield response.json();
36
- if (result.error) {
37
- throw new Error(result.error.message);
38
- }
39
- return result.result;
40
- });
41
- }
42
- }
43
- exports.BscRpc = BscRpc;