@clonegod/ttd-sui-common 1.0.100 → 1.0.103
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/appconfig/SuiQuoteAppConfig.d.ts +10 -0
- package/dist/appconfig/SuiQuoteAppConfig.js +35 -0
- package/dist/appconfig/SuiTradeAppConfig.d.ts +7 -0
- package/dist/appconfig/SuiTradeAppConfig.js +13 -0
- package/dist/appconfig/ensure_core_env.d.ts +1 -0
- package/dist/appconfig/ensure_core_env.js +18 -0
- package/dist/appconfig/index.d.ts +5 -0
- package/dist/appconfig/index.js +21 -0
- package/dist/appconfig/sui_dex_env_args.d.ts +5 -0
- package/dist/appconfig/sui_dex_env_args.js +28 -0
- package/dist/appconfig/sui_env_args.d.ts +4 -0
- package/dist/appconfig/sui_env_args.js +20 -0
- package/dist/grpc/gas-price-cache.js +19 -32
- package/dist/grpc/grpc-connection.d.ts +1 -0
- package/dist/grpc/grpc-connection.js +21 -20
- package/dist/grpc/grpc_provider_registry.d.ts +14 -0
- package/dist/grpc/grpc_provider_registry.js +60 -0
- package/dist/grpc/index.d.ts +3 -0
- package/dist/grpc/index.js +13 -1
- package/dist/grpc/ledger-service.js +107 -128
- package/dist/grpc/proto_value.d.ts +4 -0
- package/dist/grpc/proto_value.js +59 -0
- package/dist/grpc/state-service.d.ts +1 -0
- package/dist/grpc/state-service.js +99 -102
- package/dist/grpc/sui-grpc-client.js +2 -13
- package/dist/grpc/sui_object_reader.d.ts +15 -0
- package/dist/grpc/sui_object_reader.js +60 -0
- package/dist/grpc/transaction-service.js +26 -37
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/quote/abstract_dex_quote.d.ts +60 -0
- package/dist/quote/abstract_dex_quote.js +186 -0
- package/dist/quote/chain_ops.d.ts +17 -0
- package/dist/quote/chain_ops.js +52 -0
- package/dist/quote/index.d.ts +7 -0
- package/dist/quote/index.js +7 -0
- package/dist/quote/pool_event.d.ts +21 -0
- package/dist/quote/pool_event.js +6 -0
- package/dist/quote/pricing/token_price_cache.js +18 -29
- package/dist/quote/quote_amount.d.ts +4 -0
- package/dist/quote/quote_amount.js +24 -0
- package/dist/quote/quote_trace.d.ts +16 -0
- package/dist/quote/quote_trace.js +40 -0
- package/dist/quote/tick/clmm_v3_engine.d.ts +32 -0
- package/dist/quote/tick/clmm_v3_engine.js +48 -0
- package/dist/quote/tick/index.d.ts +4 -0
- package/dist/quote/tick/index.js +20 -0
- package/dist/quote/tick/local_clmm_state.d.ts +17 -0
- package/dist/quote/tick/local_clmm_state.js +22 -0
- package/dist/quote/tick/sui_clmm_tick_cache.d.ts +42 -0
- package/dist/quote/tick/sui_clmm_tick_cache.js +163 -0
- package/dist/quote/tick/sui_tick_data_provider.d.ts +2 -0
- package/dist/quote/tick/sui_tick_data_provider.js +6 -0
- package/dist/quote/verify/index.d.ts +1 -0
- package/dist/quote/verify/index.js +17 -0
- package/dist/quote/verify/quote_price_verify.d.ts +30 -0
- package/dist/quote/verify/quote_price_verify.js +247 -0
- package/dist/redis/redis_client.d.ts +1 -0
- package/dist/redis/redis_client.js +88 -117
- package/dist/rpc/index.js +59 -75
- package/dist/test/test.js +1 -1
- package/dist/test/test_checkpoint.js +4 -13
- package/dist/test/test_grpc.js +32 -41
- package/dist/trade/abstract_sui_dex_trade_plus.d.ts +3 -1
- package/dist/trade/abstract_sui_dex_trade_plus.js +232 -212
- package/dist/trade/check/tx_result_checker.js +65 -75
- package/dist/trade/coin/index.d.ts +1 -0
- package/dist/trade/coin/index.js +17 -0
- package/dist/trade/coin/lua_scripts.d.ts +5 -0
- package/dist/trade/coin/lua_scripts.js +130 -0
- package/dist/trade/coin/types.d.ts +30 -0
- package/dist/trade/coin/types.js +2 -0
- package/dist/trade/coin/wallet_coin_ledger.d.ts +22 -0
- package/dist/trade/coin/wallet_coin_ledger.js +85 -0
- package/dist/trade/executor/central_executor.d.ts +72 -0
- package/dist/trade/executor/central_executor.js +240 -0
- package/dist/trade/executor/coin_cache.d.ts +21 -0
- package/dist/trade/executor/coin_cache.js +143 -0
- package/dist/trade/executor/coin_maintainer.d.ts +32 -0
- package/dist/trade/executor/coin_maintainer.js +123 -0
- package/dist/trade/executor/core_channel.d.ts +38 -0
- package/dist/trade/executor/core_channel.js +131 -0
- package/dist/trade/executor/data_channel.d.ts +27 -0
- package/dist/trade/executor/data_channel.js +2 -0
- package/dist/trade/executor/effects.d.ts +16 -0
- package/dist/trade/executor/effects.js +63 -0
- package/dist/trade/executor/executor_client.d.ts +13 -0
- package/dist/trade/executor/executor_client.js +55 -0
- package/dist/trade/executor/executor_protocol.d.ts +26 -0
- package/dist/trade/executor/executor_protocol.js +32 -0
- package/dist/trade/executor/executor_server.d.ts +8 -0
- package/dist/trade/executor/executor_server.js +33 -0
- package/dist/trade/executor/executor_ws_client.d.ts +13 -0
- package/dist/trade/executor/executor_ws_client.js +58 -0
- package/dist/trade/executor/grpc_channel.d.ts +14 -0
- package/dist/trade/executor/grpc_channel.js +73 -0
- package/dist/trade/executor/index.d.ts +7 -0
- package/dist/trade/executor/index.js +23 -0
- package/dist/trade/executor/json_rpc_channel.d.ts +14 -0
- package/dist/trade/executor/json_rpc_channel.js +77 -0
- package/dist/trade/index.d.ts +4 -0
- package/dist/trade/index.js +4 -0
- package/dist/trade/parse/sui_tx_parser.js +98 -81
- package/dist/trade/send_tx/index.js +34 -47
- package/dist/trade/swap/builders/bluefin.d.ts +9 -0
- package/dist/trade/swap/builders/bluefin.js +60 -0
- package/dist/trade/swap/builders/cetus_magma.d.ts +13 -0
- package/dist/trade/swap/builders/cetus_magma.js +52 -0
- package/dist/trade/swap/builders/momentum.d.ts +9 -0
- package/dist/trade/swap/builders/momentum.js +80 -0
- package/dist/trade/swap/dex_swap_config.d.ts +28 -0
- package/dist/trade/swap/dex_swap_config.js +40 -0
- package/dist/trade/swap/index.d.ts +7 -0
- package/dist/trade/swap/index.js +36 -0
- package/dist/trade/swap/types.d.ts +20 -0
- package/dist/trade/swap/types.js +2 -0
- package/dist/trade/test/test_parse_sui_tx_result.js +33 -44
- package/dist/trade/tx_result_channel.d.ts +7 -0
- package/dist/trade/tx_result_channel.js +7 -0
- package/dist/utils/decode.js +1 -2
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/trade_direction.d.ts +14 -0
- package/dist/utils/trade_direction.js +23 -0
- package/package.json +3 -2
|
@@ -1,13 +1,4 @@
|
|
|
1
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
const dist_1 = require("@clonegod/ttd-core/dist");
|
|
13
4
|
const fs_1 = require("fs");
|
|
@@ -16,7 +7,7 @@ const subscription_service_1 = require("../grpc/subscription-service");
|
|
|
16
7
|
const utils_1 = require("../utils");
|
|
17
8
|
const grpc_endpoint = process.env.SUI_GRPC_ENDPOINT;
|
|
18
9
|
const grpc_token = process.env.SUI_GRPC_TOKEN;
|
|
19
|
-
const test_subscribe_checkpoints = () =>
|
|
10
|
+
const test_subscribe_checkpoints = async () => {
|
|
20
11
|
const connection = grpc_connection_1.GrpcConnection.getInstance(grpc_endpoint, grpc_token);
|
|
21
12
|
const subscriptionService = new subscription_service_1.SubscriptionService(connection);
|
|
22
13
|
const readMask = ['*'];
|
|
@@ -62,8 +53,8 @@ const test_subscribe_checkpoints = () => __awaiter(void 0, void 0, void 0, funct
|
|
|
62
53
|
}, (error) => {
|
|
63
54
|
(0, dist_1.log_info)(`error`, error);
|
|
64
55
|
}, readMask);
|
|
65
|
-
}
|
|
66
|
-
const main = () =>
|
|
56
|
+
};
|
|
57
|
+
const main = async () => {
|
|
67
58
|
test_subscribe_checkpoints();
|
|
68
|
-
}
|
|
59
|
+
};
|
|
69
60
|
main();
|
package/dist/test/test_grpc.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
const dist_1 = require("@clonegod/ttd-core/dist");
|
|
13
4
|
const grpc_connection_1 = require("../grpc/grpc-connection");
|
|
@@ -15,65 +6,65 @@ const ledger_service_1 = require("../grpc/ledger-service");
|
|
|
15
6
|
const state_service_1 = require("../grpc/state-service");
|
|
16
7
|
const grpc_endpoint = process.env.SUI_GRPC_ENDPOINT;
|
|
17
8
|
const grpc_token = process.env.SUI_GRPC_TOKEN;
|
|
18
|
-
const test_get_service_info = () =>
|
|
9
|
+
const test_get_service_info = async () => {
|
|
19
10
|
const connection = grpc_connection_1.GrpcConnection.getInstance(grpc_endpoint, grpc_token);
|
|
20
11
|
const ledgerService = new ledger_service_1.LedgerService(connection);
|
|
21
|
-
const serviceInfo =
|
|
12
|
+
const serviceInfo = await ledgerService.getServiceInfo();
|
|
22
13
|
(0, dist_1.log_info)(`serviceInfo`, serviceInfo);
|
|
23
|
-
}
|
|
24
|
-
const test_get_epoch = () =>
|
|
14
|
+
};
|
|
15
|
+
const test_get_epoch = async () => {
|
|
25
16
|
const connection = grpc_connection_1.GrpcConnection.getInstance(grpc_endpoint, grpc_token);
|
|
26
17
|
const ledgerService = new ledger_service_1.LedgerService(connection);
|
|
27
|
-
const epoch =
|
|
18
|
+
const epoch = await ledgerService.getEpoch();
|
|
28
19
|
(0, dist_1.log_info)(`epoch`, epoch);
|
|
29
|
-
}
|
|
30
|
-
const test_get_checkpoint = () =>
|
|
20
|
+
};
|
|
21
|
+
const test_get_checkpoint = async () => {
|
|
31
22
|
const connection = grpc_connection_1.GrpcConnection.getInstance(grpc_endpoint, grpc_token);
|
|
32
23
|
const ledgerService = new ledger_service_1.LedgerService(connection);
|
|
33
|
-
const checkpoint =
|
|
24
|
+
const checkpoint = await ledgerService.getCheckpoint();
|
|
34
25
|
(0, dist_1.log_info)(`checkpoint`, checkpoint);
|
|
35
|
-
}
|
|
36
|
-
const test_get_object = (object_id) =>
|
|
26
|
+
};
|
|
27
|
+
const test_get_object = async (object_id) => {
|
|
37
28
|
const connection = grpc_connection_1.GrpcConnection.getInstance(grpc_endpoint, grpc_token);
|
|
38
29
|
const ledgerService = new ledger_service_1.LedgerService(connection);
|
|
39
|
-
const object =
|
|
30
|
+
const object = await ledgerService.getObject(object_id);
|
|
40
31
|
(0, dist_1.log_info)(`object`, object);
|
|
41
|
-
}
|
|
42
|
-
const test_get_objects = (object_ids) =>
|
|
32
|
+
};
|
|
33
|
+
const test_get_objects = async (object_ids) => {
|
|
43
34
|
const connection = grpc_connection_1.GrpcConnection.getInstance(grpc_endpoint, grpc_token);
|
|
44
35
|
const ledgerService = new ledger_service_1.LedgerService(connection);
|
|
45
|
-
const objects =
|
|
36
|
+
const objects = await ledgerService.batchGetObjects(object_ids);
|
|
46
37
|
(0, dist_1.log_info)(`objects`, objects);
|
|
47
|
-
}
|
|
48
|
-
const test_get_transaction = (txid) =>
|
|
38
|
+
};
|
|
39
|
+
const test_get_transaction = async (txid) => {
|
|
49
40
|
const connection = grpc_connection_1.GrpcConnection.getInstance(grpc_endpoint, grpc_token);
|
|
50
41
|
const ledgerService = new ledger_service_1.LedgerService(connection);
|
|
51
|
-
const transaction =
|
|
42
|
+
const transaction = await ledgerService.getTransaction(txid);
|
|
52
43
|
(0, dist_1.log_info)(`transaction`, transaction);
|
|
53
|
-
}
|
|
54
|
-
const test_get_balance = (wallet_address, coin_type) =>
|
|
44
|
+
};
|
|
45
|
+
const test_get_balance = async (wallet_address, coin_type) => {
|
|
55
46
|
const connection = grpc_connection_1.GrpcConnection.getInstance(grpc_endpoint, grpc_token);
|
|
56
47
|
const stateService = new state_service_1.StateService(connection);
|
|
57
|
-
const balance =
|
|
48
|
+
const balance = await stateService.getBalance(wallet_address, coin_type);
|
|
58
49
|
(0, dist_1.log_info)(`balance`, balance);
|
|
59
|
-
}
|
|
60
|
-
const test_list_balances = (wallet_address) =>
|
|
50
|
+
};
|
|
51
|
+
const test_list_balances = async (wallet_address) => {
|
|
61
52
|
const connection = grpc_connection_1.GrpcConnection.getInstance(grpc_endpoint, grpc_token);
|
|
62
53
|
const stateService = new state_service_1.StateService(connection);
|
|
63
|
-
const balances =
|
|
54
|
+
const balances = await stateService.listBalances(wallet_address);
|
|
64
55
|
(0, dist_1.log_info)(`balances`, balances);
|
|
65
|
-
}
|
|
66
|
-
const test_get_coin_info = (coin_type) =>
|
|
56
|
+
};
|
|
57
|
+
const test_get_coin_info = async (coin_type) => {
|
|
67
58
|
const connection = grpc_connection_1.GrpcConnection.getInstance(grpc_endpoint, grpc_token);
|
|
68
59
|
const stateService = new state_service_1.StateService(connection);
|
|
69
|
-
const coinInfo =
|
|
60
|
+
const coinInfo = await stateService.getCoinInfo(coin_type);
|
|
70
61
|
(0, dist_1.log_info)(`coinInfo`, coinInfo);
|
|
71
|
-
}
|
|
72
|
-
const test_list_owned_objects = (wallet_address, coin_type) =>
|
|
62
|
+
};
|
|
63
|
+
const test_list_owned_objects = async (wallet_address, coin_type) => {
|
|
73
64
|
const connection = grpc_connection_1.GrpcConnection.getInstance(grpc_endpoint, grpc_token);
|
|
74
65
|
const startTime = Date.now();
|
|
75
66
|
const stateService = new state_service_1.StateService(connection);
|
|
76
|
-
const ownedObjects =
|
|
67
|
+
const ownedObjects = await stateService.listOwnedObjects(wallet_address, coin_type);
|
|
77
68
|
const duration = Date.now() - startTime;
|
|
78
69
|
if (!coin_type) {
|
|
79
70
|
(0, dist_1.log_info)(`list all owned objects, count=${ownedObjects.objects.length}, cost ${duration}ms`);
|
|
@@ -81,8 +72,8 @@ const test_list_owned_objects = (wallet_address, coin_type) => __awaiter(void 0,
|
|
|
81
72
|
else {
|
|
82
73
|
(0, dist_1.log_info)(`list type of ${coin_type}, count=${ownedObjects.objects.length}, cost ${duration}ms`);
|
|
83
74
|
}
|
|
84
|
-
}
|
|
85
|
-
const main = () =>
|
|
75
|
+
};
|
|
76
|
+
const main = async () => {
|
|
86
77
|
const wallet_address = '0x6367c8755b8c39cab7305bfa75cb17d050508d2e55f6862a7682377ad6d46ee7';
|
|
87
78
|
const usdc_coin_type = '0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC';
|
|
88
79
|
const take_coin_type = '0x76a49ebaf991fa2d4cb6a352af14425d453fe2ba6802b5ed2361b227150b6689::take::TAKE';
|
|
@@ -90,5 +81,5 @@ const main = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
90
81
|
test_list_owned_objects(wallet_address, usdc_coin_type);
|
|
91
82
|
test_list_owned_objects(wallet_address);
|
|
92
83
|
test_list_owned_objects(wallet_address, usdc_coin_type);
|
|
93
|
-
}
|
|
84
|
+
};
|
|
94
85
|
main();
|
|
@@ -5,6 +5,7 @@ import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
|
|
|
5
5
|
import { Transaction } from '@mysten/sui/transactions';
|
|
6
6
|
import { PoolObjectInfo, SuiGrpcClient, SuiTxSender } from '../index';
|
|
7
7
|
import { SimpleRedisClient } from '../redis';
|
|
8
|
+
import { ExecutorWsClient } from './executor';
|
|
8
9
|
export declare abstract class AbstractSuiDexTradePlus extends AbastrcatTrade {
|
|
9
10
|
protected appConfig: AppConfig;
|
|
10
11
|
chain_id: CHAIN_ID.SUI;
|
|
@@ -15,6 +16,7 @@ export declare abstract class AbstractSuiDexTradePlus extends AbastrcatTrade {
|
|
|
15
16
|
grpcClient: SuiGrpcClient;
|
|
16
17
|
transactionSender: SuiTxSender;
|
|
17
18
|
protected redisClient: SimpleRedisClient;
|
|
19
|
+
protected executorClient: ExecutorWsClient;
|
|
18
20
|
walletAddresses: string[];
|
|
19
21
|
currentWalletAddress: string;
|
|
20
22
|
protected chainNameLower: string;
|
|
@@ -36,6 +38,6 @@ export declare abstract class AbstractSuiDexTradePlus extends AbastrcatTrade {
|
|
|
36
38
|
protected compareBigIntBalance(a: any, b: any): number;
|
|
37
39
|
protected mergeTokenObjects(tx: Transaction, primaryCoin: any, objectsToMerge: any[], tokenSymbol: string): void;
|
|
38
40
|
protected try_refresh_wallet_objects(wallet: string, txid: string, context: TradeContext, initial_delay_ms?: number, try_times?: number, try_delay_ms?: number): Promise<void>;
|
|
39
|
-
|
|
41
|
+
execute(context: TradeContext, _retryCount?: number): Promise<string>;
|
|
40
42
|
protected abstract initConfigs(): Promise<void>;
|
|
41
43
|
}
|