@clonegod/ttd-sui-common 1.0.54 → 1.0.56

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.
@@ -42,6 +42,7 @@ class TransactionService {
42
42
  else
43
43
  resolve(response);
44
44
  });
45
+ console.log('executeTransaction, read_mask=', request.read_mask);
45
46
  });
46
47
  });
47
48
  }
@@ -29,7 +29,7 @@ export declare abstract class AbstractSuiDexTradePlus extends AbastrcatTrade {
29
29
  inputToken: any;
30
30
  outputToken: any;
31
31
  };
32
- local_calculate_output_amt(context: TradeContext): Promise<QuoteResultType>;
32
+ local_calculate_output_amt(context: TradeContext): QuoteResultType;
33
33
  protected getWalletAssetsFromRedis(walletAddress: string): Promise<any>;
34
34
  protected getObjectInfo(objectId: string): Promise<PoolObjectInfo | null>;
35
35
  protected compareBigIntBalance(a: any, b: any): number;
@@ -214,38 +214,36 @@ class AbstractSuiDexTradePlus extends dist_1.AbastrcatTrade {
214
214
  return { inputToken, outputToken };
215
215
  }
216
216
  local_calculate_output_amt(context) {
217
- return __awaiter(this, void 0, void 0, function* () {
218
- const { price_msg, order_msg, pool_info, trade_runtime, slippage_bps } = context;
219
- let { ask, bid } = price_msg;
220
- const { aToB, amount: uiAmount, price: cex_order_price } = order_msg;
221
- let { inputToken, outputToken } = (0, dist_1.get_input_out_token)(pool_info, aToB);
222
- let amountIn = new decimal_js_1.default(uiAmount).mul(Math.pow(10, inputToken.decimals));
223
- let slippage = slippage_bps / 10000;
224
- let price;
225
- let amountOut;
226
- let amountOutMin;
227
- if (aToB) {
228
- price = cex_order_price !== null && cex_order_price !== void 0 ? cex_order_price : bid.price;
229
- amountOut = new decimal_js_1.default(uiAmount).mul(price).mul(Math.pow(10, outputToken.decimals));
230
- amountOutMin = amountOut.mul(1 - slippage);
231
- }
232
- else {
233
- price = cex_order_price !== null && cex_order_price !== void 0 ? cex_order_price : ask.price;
234
- amountOut = new decimal_js_1.default(uiAmount).div(price).mul(Math.pow(10, outputToken.decimals));
235
- amountOutMin = amountOut.mul(1 - slippage);
236
- }
237
- let quote_result = {
238
- inputToken,
239
- outputToken,
240
- amountIn: Number(amountIn.toFixed(0)),
241
- amountOut: Number(amountOut.toFixed(0)),
242
- amountOutMin: Number(amountOutMin.toFixed(0)),
243
- slippageBps: slippage_bps,
244
- priceImpact: 0,
245
- price: price.toString()
246
- };
247
- return quote_result;
248
- });
217
+ const { price_msg, order_msg, pool_info, trade_runtime, slippage_bps } = context;
218
+ let { ask, bid } = price_msg;
219
+ const { aToB, amount: uiAmount, price: cex_order_price } = order_msg;
220
+ let { inputToken, outputToken } = (0, dist_1.get_input_out_token)(pool_info, aToB);
221
+ let amountIn = new decimal_js_1.default(uiAmount).mul(Math.pow(10, inputToken.decimals));
222
+ let slippage = slippage_bps / 10000;
223
+ let price;
224
+ let amountOut;
225
+ let amountOutMin;
226
+ if (aToB) {
227
+ price = cex_order_price !== null && cex_order_price !== void 0 ? cex_order_price : bid.price;
228
+ amountOut = new decimal_js_1.default(uiAmount).mul(price).mul(Math.pow(10, outputToken.decimals));
229
+ amountOutMin = amountOut.mul(1 - slippage);
230
+ }
231
+ else {
232
+ price = cex_order_price !== null && cex_order_price !== void 0 ? cex_order_price : ask.price;
233
+ amountOut = new decimal_js_1.default(uiAmount).div(price).mul(Math.pow(10, outputToken.decimals));
234
+ amountOutMin = amountOut.mul(1 - slippage);
235
+ }
236
+ let quote_result = {
237
+ inputToken,
238
+ outputToken,
239
+ amountIn: Number(amountIn.toFixed(0)),
240
+ amountOut: Number(amountOut.toFixed(0)),
241
+ amountOutMin: Number(amountOutMin.toFixed(0)),
242
+ slippageBps: slippage_bps,
243
+ priceImpact: 0,
244
+ price: price.toString()
245
+ };
246
+ return quote_result;
249
247
  }
250
248
  getWalletAssetsFromRedis(walletAddress) {
251
249
  return __awaiter(this, void 0, void 0, function* () {
@@ -6,7 +6,7 @@ export declare class SuiTxSender {
6
6
  sui_client: SuiClient;
7
7
  grpcClient: SuiGrpcClient;
8
8
  constructor(appConfig: AppConfig, sui_client: SuiClient, grpcClient: SuiGrpcClient);
9
- send_tx: (signedTxBytes: string, signature: string, txDigest: string, send_grpc?: boolean) => Promise<void>;
9
+ send_tx: (signedTxBytes: string, signature: string, txDigest: string, send_grpc?: boolean, read_mask_fileds?: string[]) => Promise<void>;
10
10
  private sendTxByGrpc;
11
11
  private sendTxByRpc;
12
12
  }
@@ -13,10 +13,10 @@ exports.SuiTxSender = void 0;
13
13
  const dist_1 = require("@clonegod/ttd-core/dist");
14
14
  class SuiTxSender {
15
15
  constructor(appConfig, sui_client, grpcClient) {
16
- this.send_tx = (signedTxBytes_1, signature_1, txDigest_1, ...args_1) => __awaiter(this, [signedTxBytes_1, signature_1, txDigest_1, ...args_1], void 0, function* (signedTxBytes, signature, txDigest, send_grpc = false) {
17
- (0, dist_1.log_info)(`send tx:txid=${txDigest}, send_grpc=${send_grpc}`);
16
+ this.send_tx = (signedTxBytes_1, signature_1, txDigest_1, ...args_1) => __awaiter(this, [signedTxBytes_1, signature_1, txDigest_1, ...args_1], void 0, function* (signedTxBytes, signature, txDigest, send_grpc = false, read_mask_fileds = null) {
17
+ (0, dist_1.log_info)(`send tx, txid=${txDigest}, send_grpc=${send_grpc}`);
18
18
  if (send_grpc) {
19
- yield this.sendTxByGrpc(signedTxBytes, signature, txDigest);
19
+ yield this.sendTxByGrpc(signedTxBytes, signature, txDigest, read_mask_fileds);
20
20
  }
21
21
  else {
22
22
  yield this.sendTxByRpc(signedTxBytes, signature, txDigest);
@@ -26,12 +26,12 @@ class SuiTxSender {
26
26
  this.sui_client = sui_client;
27
27
  this.grpcClient = grpcClient;
28
28
  }
29
- sendTxByGrpc(signedTxBytes, signature, txDigest) {
30
- return __awaiter(this, void 0, void 0, function* () {
29
+ sendTxByGrpc(signedTxBytes_1, signature_1, txDigest_1) {
30
+ return __awaiter(this, arguments, void 0, function* (signedTxBytes, signature, txDigest, read_mask_fileds = null) {
31
31
  const bcsBytes = Buffer.from(signedTxBytes, 'base64');
32
32
  const signatureBytes = Buffer.from(signature, 'base64');
33
33
  try {
34
- let response = yield this.grpcClient.transactionService.executeTransaction(bcsBytes, signatureBytes);
34
+ let response = yield this.grpcClient.transactionService.executeTransaction(bcsBytes, signatureBytes, read_mask_fileds);
35
35
  this.appConfig.emit(`SUI_TX_RESULT_${txDigest}`, response);
36
36
  }
37
37
  catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clonegod/ttd-sui-common",
3
- "version": "1.0.54",
3
+ "version": "1.0.56",
4
4
  "description": "Sui common library",
5
5
  "license": "UNLICENSED",
6
6
  "main": "dist/index.js",