@clonegod/ttd-base-common 1.0.0 → 1.0.2

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
+ ];
@@ -16,3 +16,4 @@ export declare const EVENT_SIGNATURES: {
16
16
  BURN: string;
17
17
  };
18
18
  export declare const UniswapV3PoolABI: string[];
19
+ export declare const UniswapV3RouterABI: string[];
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UniswapV3PoolABI = exports.EVENT_SIGNATURES = exports.EVENT_NAMES = exports.WETH_ADDRESS = exports.BASE_CHAIN_ID = void 0;
3
+ exports.UniswapV3RouterABI = exports.UniswapV3PoolABI = exports.EVENT_SIGNATURES = exports.EVENT_NAMES = exports.WETH_ADDRESS = exports.BASE_CHAIN_ID = void 0;
4
4
  exports.BASE_CHAIN_ID = 8453;
5
5
  exports.WETH_ADDRESS = '0x4200000000000000000000000000000000000006';
6
6
  exports.EVENT_NAMES = {
@@ -32,3 +32,11 @@ exports.UniswapV3PoolABI = [
32
32
  "event Mint(address sender, address indexed owner, int24 indexed tickLower, int24 indexed tickUpper, uint128 amount, uint256 amount0, uint256 amount1)",
33
33
  "event Burn(address indexed owner, int24 indexed tickLower, int24 indexed tickUpper, uint128 amount, uint256 amount0, uint256 amount1)"
34
34
  ];
35
+ exports.UniswapV3RouterABI = [
36
+ 'function exactInputSingle(tuple(address tokenIn, address tokenOut, uint24 fee, address recipient, uint256 amountIn, uint256 amountOutMinimum, uint160 sqrtPriceLimitX96)) external payable returns (uint256 amountOut)',
37
+ 'function exactInput(tuple(bytes path, address recipient, uint256 deadline, uint256 amountIn, uint256 amountOutMinimum)) external payable returns (uint256 amountOut)',
38
+ 'function exactOutputSingle(tuple(address tokenIn, address tokenOut, uint24 fee, address recipient, uint256 deadline, uint256 amountOut, uint256 amountInMaximum, uint160 sqrtPriceLimitX96)) external payable returns (uint256 amountIn)',
39
+ 'function exactOutput(tuple(bytes path, address recipient, uint256 deadline, uint256 amountOut, uint256 amountInMaximum)) external payable returns (uint256 amountIn)',
40
+ 'function factory() external view returns (address)',
41
+ 'function WETH9() external view returns (address)'
42
+ ];
@@ -0,0 +1,5 @@
1
+ export declare class AlchemyBase {
2
+ private endpoint;
3
+ constructor();
4
+ sendTransaction(signedTx: string): Promise<string>;
5
+ }
@@ -0,0 +1,48 @@
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.AlchemyBase = void 0;
16
+ const dist_1 = require("@clonegod/ttd-core/dist");
17
+ const axios_1 = __importDefault(require("axios"));
18
+ class AlchemyBase {
19
+ constructor() {
20
+ this.endpoint = process.env.BASE_ALCHEMY_RPC_ENDPOINT || '';
21
+ }
22
+ sendTransaction(signedTx) {
23
+ return __awaiter(this, void 0, void 0, function* () {
24
+ try {
25
+ const response = yield axios_1.default.post(this.endpoint, {
26
+ jsonrpc: '2.0',
27
+ method: 'eth_sendRawTransaction',
28
+ params: [signedTx],
29
+ id: 1
30
+ }, {
31
+ headers: {
32
+ 'Content-Type': 'application/json'
33
+ },
34
+ timeout: 3000
35
+ });
36
+ if (response.data.error) {
37
+ throw new Error(`Alchemy RPC error: ${response.data.error.message}`);
38
+ }
39
+ return response.data.result;
40
+ }
41
+ catch (error) {
42
+ (0, dist_1.log_info)(`Alchemy transaction sending failed`, { error: error.message });
43
+ throw error;
44
+ }
45
+ });
46
+ }
47
+ }
48
+ exports.AlchemyBase = AlchemyBase;
@@ -1,6 +1,5 @@
1
- export declare class BscRpc {
2
- private url;
3
- private headers;
1
+ export declare class BaseRpc {
2
+ private endpoint;
4
3
  constructor(rpc_endpoint: string);
5
4
  eth_sendRawTransaction(signedTx: string): Promise<string>;
6
5
  }
@@ -0,0 +1,48 @@
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.BaseRpc = void 0;
16
+ const dist_1 = require("@clonegod/ttd-core/dist");
17
+ const axios_1 = __importDefault(require("axios"));
18
+ class BaseRpc {
19
+ constructor(rpc_endpoint) {
20
+ this.endpoint = rpc_endpoint || process.env.BASE_OFFICIAL_RPC_ENDPOINT || 'https://mainnet.base.org';
21
+ }
22
+ eth_sendRawTransaction(signedTx) {
23
+ return __awaiter(this, void 0, void 0, function* () {
24
+ try {
25
+ const response = yield axios_1.default.post(this.endpoint, {
26
+ jsonrpc: "2.0",
27
+ method: "eth_sendRawTransaction",
28
+ params: [signedTx],
29
+ id: 1
30
+ }, {
31
+ headers: {
32
+ "Content-Type": "application/json"
33
+ },
34
+ timeout: 3000
35
+ });
36
+ if (response.data.error) {
37
+ throw new Error(`Base Mainnet RPC error: ${response.data.error.message}`);
38
+ }
39
+ return response.data.result;
40
+ }
41
+ catch (error) {
42
+ (0, dist_1.log_info)(`Base Mainnet transaction sending failed`, { error: error.message });
43
+ throw error;
44
+ }
45
+ });
46
+ }
47
+ }
48
+ exports.BaseRpc = BaseRpc;
@@ -0,0 +1,7 @@
1
+ export declare class BloxrouteBase {
2
+ private endpoint;
3
+ private authToken;
4
+ constructor();
5
+ sendPrivateTransaction(signedTx: string): Promise<string>;
6
+ sendBundle(transactions: string[], targetBlockNumber?: number): Promise<string>;
7
+ }
@@ -12,18 +12,18 @@ 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.BlockRazorTrade = void 0;
15
+ exports.BloxrouteBase = void 0;
16
16
  const dist_1 = require("@clonegod/ttd-core/dist");
17
17
  const axios_1 = __importDefault(require("axios"));
18
- class BlockRazorTrade {
18
+ class BloxrouteBase {
19
19
  constructor() {
20
- this.rpcUrl = process.env.BLOCKRAZOR_RPC_URL || 'https://rpc.blockrazor.builders';
21
- this.authToken = process.env.BLOCKRAZOR_AUTH_TOKEN || '';
20
+ this.endpoint = process.env.BASE_BLOXROUTE_RPC_ENDPOINT || '';
21
+ this.authToken = process.env.BASE_BLOXROUTE_AUTH_TOKEN || '';
22
22
  }
23
23
  sendPrivateTransaction(signedTx) {
24
24
  return __awaiter(this, void 0, void 0, function* () {
25
25
  try {
26
- const response = yield axios_1.default.post(this.rpcUrl, {
26
+ const response = yield axios_1.default.post(this.endpoint, {
27
27
  jsonrpc: "2.0",
28
28
  id: "1",
29
29
  method: "eth_sendPrivateTransaction",
@@ -32,48 +32,52 @@ class BlockRazorTrade {
32
32
  headers: {
33
33
  'Content-Type': 'application/json',
34
34
  'Authorization': this.authToken
35
- }
35
+ },
36
+ timeout: 3000
36
37
  });
37
38
  if (response.data.error) {
38
- throw new Error(`交易发送失败: ${response.data.error.code} - ${response.data.error.message}`);
39
+ throw new Error(`BloXroute Base Error: ${response.data.error.code} - ${response.data.error.message}`);
39
40
  }
40
41
  return response.data.result;
41
42
  }
42
43
  catch (error) {
43
- (0, dist_1.log_error)('blockrazor sendPrivateTransaction failed!!!', error);
44
+ (0, dist_1.log_error)('BloXroute Base sendPrivateTransaction failed!!!', error);
44
45
  throw error;
45
46
  }
46
47
  });
47
48
  }
48
- sendBundle(transactions, maxBlockNumber, revertingTxHashes) {
49
+ sendBundle(transactions, targetBlockNumber) {
49
50
  return __awaiter(this, void 0, void 0, function* () {
50
51
  try {
51
- const currentTimestamp = Math.floor(Date.now() / 1000);
52
- const response = yield axios_1.default.post(this.rpcUrl, {
52
+ const currentBlock = targetBlockNumber || Math.floor(Date.now() / 1000);
53
+ const targetBlock = currentBlock + 1;
54
+ const response = yield axios_1.default.post(this.endpoint, {
53
55
  jsonrpc: "2.0",
54
56
  id: "1",
55
57
  method: "eth_sendBundle",
56
58
  params: [{
57
59
  txs: transactions,
58
- minTimestamp: currentTimestamp + 1,
59
- maxTimestamp: currentTimestamp + 30,
60
+ blockNumber: `0x${targetBlock.toString(16)}`,
61
+ minTimestamp: Math.floor(Date.now() / 1000),
62
+ maxTimestamp: Math.floor(Date.now() / 1000) + 30
60
63
  }]
61
64
  }, {
62
65
  headers: {
63
66
  'Content-Type': 'application/json',
64
- 'Authorization': this.authToken,
65
- }
67
+ 'Authorization': this.authToken
68
+ },
69
+ timeout: 3000
66
70
  });
67
71
  if (response.data.error) {
68
- throw new Error(`Bundle 发送失败: ${response.data.error.message}`);
72
+ throw new Error(`BloXroute Base Bundle Error: ${response.data.error.code} - ${response.data.error.message}`);
69
73
  }
70
- return response.data.result;
74
+ return response.data.result.bundleHash;
71
75
  }
72
76
  catch (error) {
73
- (0, dist_1.log_error)('blockrazor sendBundle failed!!!', error);
77
+ (0, dist_1.log_error)('BloXroute Base sendBundle failed!!!', error);
74
78
  throw error;
75
79
  }
76
80
  });
77
81
  }
78
82
  }
79
- exports.BlockRazorTrade = BlockRazorTrade;
83
+ exports.BloxrouteBase = BloxrouteBase;
@@ -0,0 +1,5 @@
1
+ export declare class DrpcBase {
2
+ private endpoint;
3
+ constructor();
4
+ sendTransaction(signedTx: string): Promise<string>;
5
+ }
@@ -0,0 +1,48 @@
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.DrpcBase = void 0;
16
+ const dist_1 = require("@clonegod/ttd-core/dist");
17
+ const axios_1 = __importDefault(require("axios"));
18
+ class DrpcBase {
19
+ constructor() {
20
+ this.endpoint = process.env.BASE_DRPC_RPC_ENDPOINT || '';
21
+ }
22
+ sendTransaction(signedTx) {
23
+ return __awaiter(this, void 0, void 0, function* () {
24
+ try {
25
+ const response = yield axios_1.default.post(this.endpoint, {
26
+ jsonrpc: '2.0',
27
+ method: 'eth_sendRawTransaction',
28
+ params: [signedTx],
29
+ id: 1
30
+ }, {
31
+ headers: {
32
+ 'Content-Type': 'application/json'
33
+ },
34
+ timeout: 3000
35
+ });
36
+ if (response.data.error) {
37
+ throw new Error(`DRPC RPC error: ${response.data.error.message}`);
38
+ }
39
+ return response.data.result;
40
+ }
41
+ catch (error) {
42
+ (0, dist_1.log_info)(`DRPC transaction sending failed`, { error: error.message });
43
+ throw error;
44
+ }
45
+ });
46
+ }
47
+ }
48
+ exports.DrpcBase = DrpcBase;
@@ -1,5 +1,3 @@
1
1
  export * from './send_tx';
2
- export declare enum BSC_EOA_ADDRESS {
3
- BLOCKRAZOR = "0x1266C6bE60392A8Ff346E8d5ECCd3E69dD9c5F20",
4
- _48CLUB = "0x4848489f0b2BEdd788c696e2D79b6b69D7484848"
2
+ export declare enum BASE_EOA_ADDRESS {
5
3
  }
@@ -14,10 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.BSC_EOA_ADDRESS = void 0;
17
+ exports.BASE_EOA_ADDRESS = void 0;
18
18
  __exportStar(require("./send_tx"), exports);
19
- var BSC_EOA_ADDRESS;
20
- (function (BSC_EOA_ADDRESS) {
21
- BSC_EOA_ADDRESS["BLOCKRAZOR"] = "0x1266C6bE60392A8Ff346E8d5ECCd3E69dD9c5F20";
22
- BSC_EOA_ADDRESS["_48CLUB"] = "0x4848489f0b2BEdd788c696e2D79b6b69D7484848";
23
- })(BSC_EOA_ADDRESS || (exports.BSC_EOA_ADDRESS = BSC_EOA_ADDRESS = {}));
19
+ var BASE_EOA_ADDRESS;
20
+ (function (BASE_EOA_ADDRESS) {
21
+ })(BASE_EOA_ADDRESS || (exports.BASE_EOA_ADDRESS = BASE_EOA_ADDRESS = {}));
@@ -0,0 +1,5 @@
1
+ export declare class InfuraBase {
2
+ private endpoint;
3
+ constructor();
4
+ sendTransaction(signedTx: string): Promise<string>;
5
+ }
@@ -0,0 +1,48 @@
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.InfuraBase = void 0;
16
+ const dist_1 = require("@clonegod/ttd-core/dist");
17
+ const axios_1 = __importDefault(require("axios"));
18
+ class InfuraBase {
19
+ constructor() {
20
+ this.endpoint = process.env.BASE_INFURA_RPC_ENDPOINT || '';
21
+ }
22
+ sendTransaction(signedTx) {
23
+ return __awaiter(this, void 0, void 0, function* () {
24
+ try {
25
+ const response = yield axios_1.default.post(this.endpoint, {
26
+ jsonrpc: '2.0',
27
+ method: 'eth_sendRawTransaction',
28
+ params: [signedTx],
29
+ id: 1
30
+ }, {
31
+ headers: {
32
+ 'Content-Type': 'application/json'
33
+ },
34
+ timeout: 3000
35
+ });
36
+ if (response.data.error) {
37
+ throw new Error(`Infura RPC error: ${response.data.error.message}`);
38
+ }
39
+ return response.data.result;
40
+ }
41
+ catch (error) {
42
+ (0, dist_1.log_info)(`Infura transaction sending failed`, { error: error.message });
43
+ throw error;
44
+ }
45
+ });
46
+ }
47
+ }
48
+ exports.InfuraBase = InfuraBase;
@@ -0,0 +1,5 @@
1
+ export declare class QuickNodeBase {
2
+ private endpoint;
3
+ constructor();
4
+ sendTransaction(signedTx: string): Promise<string>;
5
+ }
@@ -0,0 +1,48 @@
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.QuickNodeBase = void 0;
16
+ const dist_1 = require("@clonegod/ttd-core/dist");
17
+ const axios_1 = __importDefault(require("axios"));
18
+ class QuickNodeBase {
19
+ constructor() {
20
+ this.endpoint = process.env.BASE_QUICKNODE_RPC_ENDPOINT || '';
21
+ }
22
+ sendTransaction(signedTx) {
23
+ return __awaiter(this, void 0, void 0, function* () {
24
+ try {
25
+ const response = yield axios_1.default.post(this.endpoint, {
26
+ jsonrpc: "2.0",
27
+ id: "1",
28
+ method: "eth_sendRawTransaction",
29
+ params: [signedTx]
30
+ }, {
31
+ headers: {
32
+ 'Content-Type': 'application/json'
33
+ },
34
+ timeout: 3000
35
+ });
36
+ if (response.data.error) {
37
+ throw new Error(`QuickNode Base Error: ${response.data.error.code} - ${response.data.error.message}`);
38
+ }
39
+ return response.data.result;
40
+ }
41
+ catch (error) {
42
+ (0, dist_1.log_error)('QuickNode Base sendTransaction failed!!!', error);
43
+ throw error;
44
+ }
45
+ });
46
+ }
47
+ }
48
+ exports.QuickNodeBase = QuickNodeBase;
@@ -1,8 +1,11 @@
1
1
  import { AppConfig } from "@clonegod/ttd-core/dist";
2
- export declare class TransactionSender {
2
+ export declare class BaseTransactionSender {
3
3
  private rpc;
4
- private blockRazor;
5
- private _48Club;
4
+ private quicknode;
5
+ private bloxroute;
6
+ private alchemy;
7
+ private infura;
8
+ private drpc;
6
9
  constructor(appConfig: AppConfig);
7
10
  sendTransaction(signedMainTx: string, eoa_tip_transaction: (eoa_address: string) => Promise<string>, order_trace_id: string): Promise<string[]>;
8
11
  }
@@ -9,56 +9,66 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.TransactionSender = void 0;
12
+ exports.BaseTransactionSender = void 0;
13
13
  const dist_1 = require("@clonegod/ttd-core/dist");
14
- const blockrazor_1 = require("./blockrazor");
15
- const bsc_rpc_1 = require("./bsc_rpc");
16
- const _48club_1 = require("./48club");
17
- const _1 = require(".");
18
- class TransactionSender {
14
+ const base_rpc_1 = require("./base_rpc");
15
+ const quicknode_base_1 = require("./quicknode_base");
16
+ const bloxroute_base_1 = require("./bloxroute_base");
17
+ const alchemy_base_1 = require("./alchemy_base");
18
+ const infura_base_1 = require("./infura_base");
19
+ const drpc_base_1 = require("./drpc_base");
20
+ class BaseTransactionSender {
19
21
  constructor(appConfig) {
20
- this.rpc = new bsc_rpc_1.BscRpc(appConfig.env_args.rpc_endpoint);
21
- this.blockRazor = new blockrazor_1.BlockRazorTrade();
22
- this._48Club = new _48club_1._48ClubTrade();
22
+ this.rpc = new base_rpc_1.BaseRpc(appConfig.env_args.rpc_endpoint);
23
+ this.quicknode = new quicknode_base_1.QuickNodeBase();
24
+ this.bloxroute = new bloxroute_base_1.BloxrouteBase();
25
+ this.alchemy = new alchemy_base_1.AlchemyBase();
26
+ this.infura = new infura_base_1.InfuraBase();
27
+ this.drpc = new drpc_base_1.DrpcBase();
23
28
  }
24
29
  sendTransaction(signedMainTx, eoa_tip_transaction, order_trace_id) {
25
30
  return __awaiter(this, void 0, void 0, function* () {
26
31
  const rpcProviders = [
27
32
  {
28
- name: 'Default (QuickNode / Merkle)',
29
- enable: process.env.SEND_TX_DEFAULT_RPC_PRIVATE === 'true',
33
+ name: 'Base Official RPC',
34
+ enable: process.env.SEND_TX_BASE_OFFICIAL_RPC === 'true',
30
35
  send: () => __awaiter(this, void 0, void 0, function* () {
31
36
  return yield this.rpc.eth_sendRawTransaction(signedMainTx);
32
37
  })
33
38
  },
34
39
  {
35
- name: 'BlockRazor - Private Transaction',
36
- enable: process.env.SEND_TX_BLOCKRAZOR_PRIVATE === 'true',
40
+ name: 'Base QuickNode RPC',
41
+ enable: process.env.SEND_TX_BASE_QUICKNODE_RPC === 'true',
37
42
  send: () => __awaiter(this, void 0, void 0, function* () {
38
- return yield this.blockRazor.sendPrivateTransaction(signedMainTx);
43
+ return yield this.quicknode.sendTransaction(signedMainTx);
39
44
  })
40
45
  },
41
46
  {
42
- name: 'BlockRazor - sendBundle',
43
- enable: process.env.SEND_TX_BLOCKRAZOR_BUNDLE === 'true',
47
+ name: 'Base DRPC RPC',
48
+ enable: process.env.SEND_TX_BASE_DRPC_RPC === 'true',
44
49
  send: () => __awaiter(this, void 0, void 0, function* () {
45
- let bundle = [signedMainTx, yield eoa_tip_transaction(_1.BSC_EOA_ADDRESS.BLOCKRAZOR)];
46
- return yield this.blockRazor.sendBundle(bundle);
50
+ return yield this.drpc.sendTransaction(signedMainTx);
47
51
  })
48
52
  },
49
53
  {
50
- name: '48Club - Private Transaction',
51
- enable: process.env.SEND_TX_48CLUB_PRIVATE === 'true',
54
+ name: 'Base Alchemy RPC',
55
+ enable: process.env.SEND_TX_BASE_ALCHEMY_RPC === 'true',
52
56
  send: () => __awaiter(this, void 0, void 0, function* () {
53
- return yield this._48Club.sendPrivateTransaction(signedMainTx);
57
+ return yield this.alchemy.sendTransaction(signedMainTx);
54
58
  })
55
59
  },
56
60
  {
57
- name: '48Club - sendBundle',
58
- enable: process.env.SEND_TX_48CLUB_BUNDLE === 'true',
61
+ name: 'Base Infura RPC',
62
+ enable: process.env.SEND_TX_BASE_INFURA_RPC === 'true',
59
63
  send: () => __awaiter(this, void 0, void 0, function* () {
60
- let bundle = [signedMainTx, yield eoa_tip_transaction(_1.BSC_EOA_ADDRESS._48CLUB)];
61
- return yield this._48Club.sendBundle({ txs: bundle });
64
+ return yield this.infura.sendTransaction(signedMainTx);
65
+ })
66
+ },
67
+ {
68
+ name: 'BloXroute - Private Transaction',
69
+ enable: process.env.SEND_TX_BLOXROUTE_PRIVATE === 'true',
70
+ send: () => __awaiter(this, void 0, void 0, function* () {
71
+ return yield this.bloxroute.sendPrivateTransaction(signedMainTx);
62
72
  })
63
73
  }
64
74
  ];
@@ -68,24 +78,32 @@ class TransactionSender {
68
78
  try {
69
79
  const txHash = yield provider.send();
70
80
  results.push(txHash);
71
- (0, dist_1.log_info)(`Transaction sent successfully`, { provider: provider.name, order_trace_id, txHash });
81
+ (0, dist_1.log_info)(`Base transaction sent successfully`, {
82
+ provider: provider.name,
83
+ order_trace_id,
84
+ txHash
85
+ });
72
86
  }
73
87
  catch (error) {
74
88
  errors.push(`${provider.name}: ${error.message}`);
75
- (0, dist_1.log_info)(`Transaction sending failed`, { provider: provider.name, order_trace_id, error: error.message });
89
+ (0, dist_1.log_info)(`Base transaction sending failed`, {
90
+ provider: provider.name,
91
+ order_trace_id,
92
+ error: error.message
93
+ });
76
94
  }
77
95
  })));
78
96
  if (errors.some(error => error.includes('nonce'))) {
79
- throw new Error(`!!!!!! Some RPC providers returned nonce error: ${JSON.stringify(errors)}`);
97
+ throw new Error(`!!!!!! Some Base RPC providers returned nonce error: ${JSON.stringify(errors)}`);
80
98
  }
81
- if (errors.some(error => error.includes('bundle already exist') || error.includes('already known'))) {
99
+ if (errors.some(error => error.includes('already known') || error.includes('already exist'))) {
82
100
  return results;
83
101
  }
84
102
  if (results.length === 0 || errors.length > 0) {
85
- throw new Error(`!!!!!! Some RPC providers failed to send transactions: ${JSON.stringify(errors)}`);
103
+ throw new Error(`!!!!!! Some Base RPC providers failed to send transactions: ${JSON.stringify(errors)}`);
86
104
  }
87
105
  return results;
88
106
  });
89
107
  }
90
108
  }
91
- exports.TransactionSender = TransactionSender;
109
+ exports.BaseTransactionSender = BaseTransactionSender;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clonegod/ttd-base-common",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
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,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;