@clonegod/ttd-core 2.0.98 → 2.1.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.
|
@@ -59,4 +59,9 @@ export declare class LoadingCache {
|
|
|
59
59
|
[x: string]: string;
|
|
60
60
|
};
|
|
61
61
|
}>;
|
|
62
|
+
push_block_info(chain_id: CHAIN_ID, block_info: string): Promise<boolean>;
|
|
63
|
+
get_block_info(chain_id: CHAIN_ID, offset: number, limit?: number): Promise<{
|
|
64
|
+
key: string;
|
|
65
|
+
blocks: string[];
|
|
66
|
+
}>;
|
|
62
67
|
}
|
|
@@ -229,5 +229,27 @@ class LoadingCache {
|
|
|
229
229
|
return data;
|
|
230
230
|
});
|
|
231
231
|
}
|
|
232
|
+
push_block_info(chain_id, block_info) {
|
|
233
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
234
|
+
const key = this.get_key(chain_id, 'b', 'block');
|
|
235
|
+
yield this.redis_client.lPush(key, block_info);
|
|
236
|
+
this.redis_client.lTrim(key, 0, 149).then(res => {
|
|
237
|
+
(0, index_1.log_info)(`push_block_info, res=${res}`);
|
|
238
|
+
}).catch(err => {
|
|
239
|
+
(0, index_1.log_warn)(`push_block_info, err=${err.message}`);
|
|
240
|
+
});
|
|
241
|
+
return true;
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
get_block_info(chain_id_1, offset_1) {
|
|
245
|
+
return __awaiter(this, arguments, void 0, function* (chain_id, offset, limit = 1) {
|
|
246
|
+
const key = this.get_key(chain_id, 'b', 'block');
|
|
247
|
+
const blocks = yield this.redis_client.lRange(key, offset, offset + limit - 1);
|
|
248
|
+
return {
|
|
249
|
+
key,
|
|
250
|
+
blocks
|
|
251
|
+
};
|
|
252
|
+
});
|
|
253
|
+
}
|
|
232
254
|
}
|
|
233
255
|
exports.LoadingCache = LoadingCache;
|
|
@@ -18,6 +18,7 @@ const axios_1 = __importDefault(require("axios"));
|
|
|
18
18
|
const index_1 = require("../../index");
|
|
19
19
|
const gecko_terminal_1 = require("./gecko_terminal");
|
|
20
20
|
const price_cache_1 = require("./price_cache");
|
|
21
|
+
const defi_llama_1 = require("./defi_llama");
|
|
21
22
|
function get_solana_token_price_info(addresses) {
|
|
22
23
|
return __awaiter(this, void 0, void 0, function* () {
|
|
23
24
|
const result = new Map();
|
|
@@ -34,6 +35,12 @@ function get_solana_token_price_info(addresses) {
|
|
|
34
35
|
batchSize: 10,
|
|
35
36
|
batchDelay: 1000,
|
|
36
37
|
},
|
|
38
|
+
{
|
|
39
|
+
name: 'DefiLlama',
|
|
40
|
+
fetchFn: (address_list) => (0, defi_llama_1.fetchPriceFromDefiLlama)(index_1.CHAIN_ID.SOLANA, address_list),
|
|
41
|
+
batchSize: 10,
|
|
42
|
+
batchDelay: 1000,
|
|
43
|
+
},
|
|
37
44
|
{
|
|
38
45
|
name: 'GeckoTerminal',
|
|
39
46
|
fetchFn: (address_list) => (0, gecko_terminal_1.fetchPriceFromGeckoTerminal)(index_1.CHAIN_ID.SOLANA, address_list),
|
|
@@ -99,19 +106,19 @@ function fetchPriceFromJupiter(addresses) {
|
|
|
99
106
|
const timeout = 10000;
|
|
100
107
|
const maxRetries = 2;
|
|
101
108
|
const retrysleepMs = 500;
|
|
102
|
-
const url = `https://api.jup.ag/price/
|
|
109
|
+
const url = `https://lite-api.jup.ag/price/v3?ids=${addresses.join(',')}`;
|
|
103
110
|
(0, index_1.log_debug)(`[fetchPriceFromJupiter] Requesting Jupiter API for ${addresses.length} tokens`);
|
|
104
111
|
let retryCount = 0;
|
|
105
112
|
while (retryCount <= maxRetries) {
|
|
106
113
|
try {
|
|
107
114
|
const response = yield axios_1.default.get(url, { timeout });
|
|
108
|
-
if (response.data
|
|
115
|
+
if (response.data) {
|
|
109
116
|
for (const address of addresses) {
|
|
110
117
|
const key = address;
|
|
111
|
-
if (response.data
|
|
118
|
+
if (response.data[key] !== undefined) {
|
|
112
119
|
result.set(address, {
|
|
113
120
|
address: address,
|
|
114
|
-
price: response.data
|
|
121
|
+
price: response.data[key]['usdPrice'].toString(),
|
|
115
122
|
symbol: '',
|
|
116
123
|
name: '',
|
|
117
124
|
update_time: currentTime
|
|
@@ -145,6 +152,5 @@ if (require.main === module) {
|
|
|
145
152
|
"JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN",
|
|
146
153
|
"MEW1gQWJ3nEXg2qgERiKu7FAFj79PHvQVREQUzScPP5",
|
|
147
154
|
];
|
|
148
|
-
console.log(yield get_solana_token_price_info(addresses));
|
|
149
155
|
}))();
|
|
150
156
|
}
|
package/package.json
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -168,6 +168,7 @@ export interface TradeStrategyType {
|
|
|
168
168
|
fee_max_cap: number, // 动态GAS的上限
|
|
169
169
|
tip_ratio: number // tip 占总gas的比例(gas=priority_fee + tip_fee)
|
|
170
170
|
tip_up_ratio: number // tip上浮比例
|
|
171
|
+
block_offset?: number // Solana特定:交易在提交之后的指定slot偏移内有效
|
|
171
172
|
// evm chain
|
|
172
173
|
evm_gas_limit: number // 300000
|
|
173
174
|
evm_gas_price_gwei: number // 1.1 Gwei
|
|
@@ -742,6 +743,11 @@ export declare class LoadingCache {
|
|
|
742
743
|
[x: string]: string;
|
|
743
744
|
};
|
|
744
745
|
}>;
|
|
746
|
+
push_block_info(chain_id: CHAIN_ID, block_info: string): Promise<boolean>;
|
|
747
|
+
get_block_info(chain_id: CHAIN_ID, offset: number, limit?: number): Promise<{
|
|
748
|
+
key: string;
|
|
749
|
+
blocks: string[];
|
|
750
|
+
}>;
|
|
745
751
|
}
|
|
746
752
|
|
|
747
753
|
export declare class RedisCommand {
|