@typus/typus-sdk 1.7.17 → 1.7.18

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.
@@ -35,7 +35,7 @@ var utils_1 = require("../../src/utils");
35
35
  )
36
36
  */
37
37
  function getNewStrategyTx(config, tx, input) {
38
- var input_coin = (0, utils_1.splitCoin)(tx, input.typeArguments[1], input.coins, input.amount, config.sponsored);
38
+ var input_coin = (0, utils_1.splitCoins)(tx, input.typeArguments[1], input.coins, input.amount, config.sponsored);
39
39
  tx.moveCall({
40
40
  target: "".concat(config.package.dovSingle, "::auto_bid::new_strategy"),
41
41
  typeArguments: input.typeArguments,
@@ -107,7 +107,7 @@ function getWithdrawProfitStrategyTx(config, tx, input) {
107
107
  )
108
108
  */
109
109
  function getUpdateStrategyTx(config, tx, input) {
110
- var input_coin = (0, utils_1.splitCoin)(tx, input.typeArguments[1], input.coins, input.amount, config.sponsored);
110
+ var input_coin = (0, utils_1.splitCoins)(tx, input.typeArguments[1], input.coins, input.amount, config.sponsored);
111
111
  tx.moveCall({
112
112
  target: "".concat(config.package.dovSingle, "::auto_bid::update_strategy"),
113
113
  typeArguments: input.typeArguments,
@@ -83,7 +83,7 @@ function newGameTx(config, tx, input) {
83
83
  default:
84
84
  break;
85
85
  }
86
- coin = (0, utils_1.splitCoin)(tx, input.typeArguments[0], input.coins, input.amount, false);
86
+ coin = (0, utils_1.splitCoins)(tx, input.typeArguments[0], input.coins, input.amount, false);
87
87
  tx.moveCall({
88
88
  target: "".concat(config.package.dice, "::").concat(input.module, "::new_game"),
89
89
  typeArguments: input.typeArguments,
@@ -151,7 +151,7 @@ function newGamePlayGuessTx(config, tx, input) {
151
151
  default:
152
152
  break;
153
153
  }
154
- coin = (0, utils_1.splitCoin)(tx, input.typeArguments[0], input.coins, input.amount, false);
154
+ coin = (0, utils_1.splitCoins)(tx, input.typeArguments[0], input.coins, input.amount, false);
155
155
  tx.moveCall({
156
156
  target: "".concat(config.package.dice, "::").concat(input.module, "::new_game"),
157
157
  typeArguments: input.typeArguments,
@@ -234,7 +234,7 @@ function playTx(config, tx, input) {
234
234
  default:
235
235
  break;
236
236
  }
237
- coin = (0, utils_1.splitCoin)(tx, input.typeArguments[0], input.coins, input.amount, false);
237
+ coin = (0, utils_1.splitCoins)(tx, input.typeArguments[0], input.coins, input.amount, false);
238
238
  tx.moveCall({
239
239
  target: "".concat(config.package.dice, "::").concat(input.module, "::play"),
240
240
  typeArguments: input.typeArguments,
@@ -81,7 +81,7 @@ function getSetAirdropTx(config, tx, input) {
81
81
  return __awaiter(this, void 0, void 0, function () {
82
82
  var coin;
83
83
  return __generator(this, function (_a) {
84
- coin = (0, utils_1.splitCoin)(tx, input.typeArguments[0], input.coins, input.amount);
84
+ coin = (0, utils_1.splitCoins)(tx, input.typeArguments[0], input.coins, input.amount);
85
85
  tx.moveCall({
86
86
  target: "".concat(config.package.typus, "::airdrop::set_airdrop"),
87
87
  typeArguments: input.typeArguments,
@@ -119,7 +119,7 @@ function getUpdateConfigTx(config, tx, requests) {
119
119
  ) {
120
120
  */
121
121
  function depositCollateralNavi(config, tx, input) {
122
- var coin = (0, utils_1.splitCoin)(tx, input.typeArguments[0], input.raiseCoins, input.raiseAmount);
122
+ var coin = (0, utils_1.splitCoins)(tx, input.typeArguments[0], input.raiseCoins, input.raiseAmount);
123
123
  tx.moveCall({
124
124
  target: "".concat(config.package.dovSingle, "::tds_authorized_entry::deposit_collateral_navi"),
125
125
  typeArguments: input.typeArguments,
@@ -108,7 +108,7 @@ function otc(config, tx, input) {
108
108
  return __awaiter(this, void 0, void 0, function () {
109
109
  var coin, balance;
110
110
  return __generator(this, function (_a) {
111
- coin = (0, utils_1.splitCoin)(tx, input.typeArguments[1], input.coins, input.amount, config.sponsored);
111
+ coin = (0, utils_1.splitCoins)(tx, input.typeArguments[1], input.coins, input.amount, config.sponsored);
112
112
  balance = tx.moveCall({
113
113
  target: "0x2::coin::into_balance",
114
114
  typeArguments: [input.typeArguments[1]],
@@ -29,7 +29,7 @@ var utils_1 = require("../../src/utils");
29
29
  ): (TypusDepositReceipt, vector<u64>) {
30
30
  */
31
31
  function getRaiseFundTx(config, tx, input) {
32
- var coin = (0, utils_1.splitCoin)(tx, input.typeArguments[0], input.raiseCoins, input.raiseAmount, config.sponsored);
32
+ var coin = (0, utils_1.splitCoins)(tx, input.typeArguments[0], input.raiseCoins, input.raiseAmount, config.sponsored);
33
33
  var raiseBalance = tx.moveCall({
34
34
  target: "0x2::coin::into_balance",
35
35
  typeArguments: [input.typeArguments[0]],
@@ -160,7 +160,7 @@ function getRefreshDepositSnapshotTx(config, tx, input) {
160
160
  )
161
161
  */
162
162
  function getNewBidTx(config, tx, input) {
163
- var coin = (0, utils_1.splitCoin)(tx, input.typeArguments[1], input.coins, input.premium_required, config.sponsored);
163
+ var coin = (0, utils_1.splitCoins)(tx, input.typeArguments[1], input.coins, input.premium_required, config.sponsored);
164
164
  var result = tx.moveCall({
165
165
  target: "".concat(config.package.dovSingle, "::tds_user_entry::public_bid"),
166
166
  typeArguments: input.typeArguments,
@@ -40,8 +40,8 @@ var utils_2 = require("../../src/utils");
40
40
  ) {
41
41
  */
42
42
  function raiseFund(config, tx, input) {
43
- var mainCoin = (0, utils_2.splitCoin)(tx, input.typeArguments[0], input.raiseMainCoins, input.raiseMainAmount, config.sponsored);
44
- var hedgeCoin = (0, utils_2.splitCoin)(tx, input.typeArguments[1], input.raiseHedgeCoins, input.raiseHedgeAmount, config.sponsored);
43
+ var mainCoin = (0, utils_2.splitCoins)(tx, input.typeArguments[0], input.raiseMainCoins, input.raiseMainAmount, config.sponsored);
44
+ var hedgeCoin = (0, utils_2.splitCoins)(tx, input.typeArguments[1], input.raiseHedgeCoins, input.raiseHedgeAmount, config.sponsored);
45
45
  var mainBalance = tx.moveCall({
46
46
  target: "0x2::coin::into_balance",
47
47
  typeArguments: [input.typeArguments[0]],
@@ -60,7 +60,7 @@ function setAirdrop(config, tx, input) {
60
60
  tx.object(config.version.launch.airdrop),
61
61
  tx.object(config.registry.launch.airdrop),
62
62
  tx.pure.string(input.key),
63
- tx.object((0, utils_1.splitCoin)(tx, input.typeArguments[0], input.coins, input.amount)),
63
+ tx.object((0, utils_1.splitCoins)(tx, input.typeArguments[0], input.coins, input.amount)),
64
64
  tx.pure.vector("address", input.users),
65
65
  tx.pure.vector("u64", input.values),
66
66
  ],
@@ -144,7 +144,7 @@ function withdrawFundFromDeepbookBalanceManager(config, tx, input) {
144
144
  ) {
145
145
  */
146
146
  function depositToDeepbookBalanceManager(config, tx, input) {
147
- var coin = (0, utils_1.splitCoin)(tx, input.typeArguments[0], input.coins, input.amount);
147
+ var coin = (0, utils_1.splitCoins)(tx, input.typeArguments[0], input.coins, input.amount);
148
148
  tx.moveCall({
149
149
  target: "".concat(config.package.launch.fundingVault, "::funding_vault::deposit_to_deepbook_balance_manager"),
150
150
  typeArguments: input.typeArguments,
@@ -189,7 +189,7 @@ function withdrawFromDeepbookBalanceManager(config, tx, input) {
189
189
  ) {
190
190
  */
191
191
  function increaseFund(config, tx, input) {
192
- var coin = (0, utils_1.splitCoin)(tx, input.typeArguments[0], input.coins, input.amount);
192
+ var coin = (0, utils_1.splitCoins)(tx, input.typeArguments[0], input.coins, input.amount);
193
193
  tx.moveCall({
194
194
  target: "".concat(config.package.launch.fundingVault, "::funding_vault::increase_fund"),
195
195
  typeArguments: input.typeArguments,
@@ -15,7 +15,7 @@ var utils_1 = require("../../../src/utils");
15
15
  ) {
16
16
  */
17
17
  function raiseFund(config, tx, input) {
18
- var coin = (0, utils_1.splitCoin)(tx, input.typeArguments[0], input.coins, input.amount);
18
+ var coin = (0, utils_1.splitCoins)(tx, input.typeArguments[0], input.coins, input.amount);
19
19
  tx.moveCall({
20
20
  target: "".concat(config.package.launch.fundingVault, "::funding_vault::raise_fund"),
21
21
  typeArguments: input.typeArguments,
@@ -23,7 +23,7 @@ var utils_1 = require("../../src/utils");
23
23
  ) {
24
24
  */
25
25
  function getRaiseFundTx(config, tx, input) {
26
- var coin = (0, utils_1.splitCoin)(tx, input.typeArguments[0], input.raiseCoins, input.raiseAmount, config.sponsored);
26
+ var coin = (0, utils_1.splitCoins)(tx, input.typeArguments[0], input.raiseCoins, input.raiseAmount, config.sponsored);
27
27
  var raiseBalance = tx.moveCall({
28
28
  target: "0x2::coin::into_balance",
29
29
  typeArguments: [input.typeArguments[0]],
@@ -79,7 +79,7 @@ function getReduceFundTx(config, tx, input) {
79
79
  tx.pure.u64(input.reduceFromWarmup),
80
80
  tx.pure.u64(input.reduceFromActive),
81
81
  tx.pure.u64(input.reduceFromInactive),
82
- tx.object((0, utils_1.splitCoin)(tx, constants_1.tokenType.MAINNET.SUI, [], input.feeAmount, config.sponsored)),
82
+ tx.object((0, utils_1.splitCoins)(tx, constants_1.tokenType.MAINNET.SUI, [], input.feeAmount, config.sponsored)),
83
83
  tx.object(constants_1.CLOCK),
84
84
  ],
85
85
  });
@@ -1,5 +1,5 @@
1
- import { HexString, SuiPriceServiceConnection, SuiPythClient } from "@pythnetwork/pyth-sui-js";
2
- import { Argument, Transaction } from "@mysten/sui/transactions";
1
+ import { SuiPriceServiceConnection, SuiPythClient } from "@pythnetwork/pyth-sui-js";
2
+ import { Transaction } from "@mysten/sui/transactions";
3
3
  import { TOKEN } from "../../../src/constants";
4
4
  import { ObjectId } from "@pythnetwork/pyth-sui-js/lib/client";
5
5
  export declare class PythClient {
@@ -11,12 +11,5 @@ export declare function createPythClient(provider: any, network: "MAINNET" | "TE
11
11
  /**
12
12
  * @returns priceInfoObjectIds
13
13
  */
14
- export declare function updatePyth(pythClient: PythClient, tx: Transaction, tokens: TOKEN[], suiCoin?: Argument): Promise<ObjectId[]>;
14
+ export declare function updatePyth(pythClient: PythClient, tx: Transaction, tokens: TOKEN[]): Promise<ObjectId[]>;
15
15
  export declare function updateOracleWithPythUsd(pythClient: PythClient, tx: Transaction, oraclePackage: string, baseToken: TOKEN): void;
16
- /**
17
- * Adds the necessary commands for updating the pyth price feeds to the transaction block.
18
- * @param tx transaction block to add commands to
19
- * @param updates array of price feed updates received from the price service
20
- * @param feedIds array of feed ids to update (in hex format)
21
- */
22
- export declare function updatePriceFeeds(pythClient: PythClient, tx: Transaction, updates: Buffer[], feedIds: HexString[], suiCoin?: Argument): Promise<ObjectId[]>;
@@ -39,7 +39,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.createPythClient = createPythClient;
40
40
  exports.updatePyth = updatePyth;
41
41
  exports.updateOracleWithPythUsd = updateOracleWithPythUsd;
42
- exports.updatePriceFeeds = updatePriceFeeds;
43
42
  var pyth_sui_js_1 = require("@pythnetwork/pyth-sui-js");
44
43
  var constant_1 = require("./constant");
45
44
  var constants_1 = require("../../../src/constants");
@@ -54,7 +53,7 @@ function createPythClient(provider, network) {
54
53
  /**
55
54
  * @returns priceInfoObjectIds
56
55
  */
57
- function updatePyth(pythClient, tx, tokens, suiCoin) {
56
+ function updatePyth(pythClient, tx, tokens) {
58
57
  return __awaiter(this, void 0, void 0, function () {
59
58
  var _priceIDs, priceFeedUpdateData, priceInfoObjectIds;
60
59
  return __generator(this, function (_a) {
@@ -64,7 +63,7 @@ function updatePyth(pythClient, tx, tokens, suiCoin) {
64
63
  return [4 /*yield*/, pythClient.connection.getPriceFeedsUpdateData(_priceIDs)];
65
64
  case 1:
66
65
  priceFeedUpdateData = _a.sent();
67
- return [4 /*yield*/, updatePriceFeeds(pythClient, tx, priceFeedUpdateData, _priceIDs, suiCoin)];
66
+ return [4 /*yield*/, pythClient.client.updatePriceFeeds(tx, priceFeedUpdateData, _priceIDs)];
68
67
  case 2:
69
68
  priceInfoObjectIds = _a.sent();
70
69
  return [2 /*return*/, priceInfoObjectIds];
@@ -84,33 +83,3 @@ function updateOracleWithPythUsd(pythClient, tx, oraclePackage, baseToken) {
84
83
  ],
85
84
  });
86
85
  }
87
- /**
88
- * Adds the necessary commands for updating the pyth price feeds to the transaction block.
89
- * @param tx transaction block to add commands to
90
- * @param updates array of price feed updates received from the price service
91
- * @param feedIds array of feed ids to update (in hex format)
92
- */
93
- function updatePriceFeeds(pythClient, tx, updates, feedIds, suiCoin) {
94
- return __awaiter(this, void 0, void 0, function () {
95
- var packageId, priceUpdatesHotPotato, baseUpdateFee, coins;
96
- return __generator(this, function (_a) {
97
- switch (_a.label) {
98
- case 0: return [4 /*yield*/, pythClient.client.getPythPackageId()];
99
- case 1:
100
- packageId = _a.sent();
101
- return [4 /*yield*/, pythClient.client.verifyVaasAndGetHotPotato(tx, updates, packageId)];
102
- case 2:
103
- priceUpdatesHotPotato = _a.sent();
104
- return [4 /*yield*/, pythClient.client.getBaseUpdateFee()];
105
- case 3:
106
- baseUpdateFee = _a.sent();
107
- coins = tx.splitCoins(suiCoin !== null && suiCoin !== void 0 ? suiCoin : tx.gas, feedIds.map(function () { return tx.pure.u64(baseUpdateFee); }));
108
- if (suiCoin) {
109
- tx.moveCall({ target: "0x2::coin::destroy_zero", arguments: [suiCoin], typeArguments: [constants_1.tokenType.MAINNET.SUI] });
110
- }
111
- return [4 /*yield*/, pythClient.client.executePriceFeedUpdates(tx, packageId, feedIds, priceUpdatesHotPotato, coins)];
112
- case 4: return [2 /*return*/, _a.sent()];
113
- }
114
- });
115
- });
116
- }
@@ -7,12 +7,9 @@ export declare function AddressFromBytes(x: any): string;
7
7
  export declare const insertAt: (str: string, sub: string, pos: number) => string;
8
8
  export declare const checkNumber: (str: any) => boolean;
9
9
  export declare const countFloating: (value: number | BigNumber) => number;
10
- export declare function splitCoin(tx: Transaction, token: string, coins: string[], amount: string, sponsored?: boolean): {
10
+ export declare function splitCoins(tx: Transaction, token: string, coins: string[], amount: string, sponsored?: boolean): {
11
11
  $kind: "NestedResult";
12
12
  NestedResult: [number, number];
13
13
  };
14
- export declare function splitCoins(tx: Transaction, token: string, coins: string[], amounts: string[], sponsored?: boolean): {
15
- $kind: "NestedResult";
16
- NestedResult: [number, number];
17
- }[];
14
+ export declare function promptYesNo(question: string): Promise<boolean>;
18
15
  export declare function getNumberStringWithDecimal(input: string, decimal: number): string;
@@ -22,11 +22,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
22
22
  exports.countFloating = exports.checkNumber = exports.insertAt = exports.prettify_big_number = exports.sleep = void 0;
23
23
  exports.U64FromBytes = U64FromBytes;
24
24
  exports.AddressFromBytes = AddressFromBytes;
25
- exports.splitCoin = splitCoin;
26
25
  exports.splitCoins = splitCoins;
26
+ exports.promptYesNo = promptYesNo;
27
27
  exports.getNumberStringWithDecimal = getNumberStringWithDecimal;
28
28
  var utils_1 = require("@mysten/sui/utils");
29
29
  var constants_1 = require("../../src/constants");
30
+ // import * as readline from "readline";
30
31
  var bignumber_js_1 = __importDefault(require("bignumber.js"));
31
32
  var sleep = function (ms) { return new Promise(function (resolve) { return setTimeout(resolve, ms); }); };
32
33
  exports.sleep = sleep;
@@ -70,35 +71,48 @@ var countFloating = function (value) {
70
71
  return num.split(".")[1].length;
71
72
  };
72
73
  exports.countFloating = countFloating;
73
- function splitCoin(tx, token, coins, amount, sponsored) {
74
+ function splitCoins(tx, token, coins, amount, sponsored) {
75
+ var _a, _b;
74
76
  if (sponsored === void 0) { sponsored = false; }
75
- var _a = __read(splitCoins(tx, token, coins, [amount], sponsored), 1), coin = _a[0];
76
- return coin;
77
- }
78
- function splitCoins(tx, token, coins, amounts, sponsored) {
79
- if (sponsored === void 0) { sponsored = false; }
80
- var coinArgs;
77
+ var coin;
81
78
  if (coins.length == 0) {
82
79
  // support zero coin input for closing position
83
- coinArgs = tx.moveCall({
80
+ _a = __read(tx.moveCall({
84
81
  target: "0x2::coin::zero",
85
82
  typeArguments: [token],
86
83
  arguments: [],
87
- });
84
+ }), 1), coin = _a[0];
88
85
  }
89
86
  else {
90
- coinArgs =
91
- (0, utils_1.normalizeStructTag)(token) == constants_1.tokenType.MAINNET.SUI && !sponsored
92
- ? tx.splitCoins(tx.gas, amounts.map(function (amount) { return tx.pure.u64(amount); }))
93
- : (function () {
94
- var coin = coins.pop();
95
- if (coins.length > 0) {
96
- tx.mergeCoins(tx.object(coin), coins.map(function (id) { return tx.object(id); }));
97
- }
98
- return tx.splitCoins(tx.object(coin), amounts.map(function (amount) { return tx.pure.u64(amount); }));
99
- })();
87
+ _b = __read((0, utils_1.normalizeStructTag)(token) == constants_1.tokenType.MAINNET.SUI && !sponsored
88
+ ? tx.splitCoins(tx.gas, [tx.pure.u64(amount)])
89
+ : (function () {
90
+ var coin = coins.pop();
91
+ if (coins.length > 0) {
92
+ tx.mergeCoins(tx.object(coin), coins.map(function (id) { return tx.object(id); }));
93
+ }
94
+ return tx.splitCoins(tx.object(coin), [tx.pure.u64(amount)]);
95
+ })(), 1), coin = _b[0];
100
96
  }
101
- return coinArgs;
97
+ return coin;
98
+ }
99
+ function promptYesNo(question) {
100
+ // const rl = readline.createInterface({
101
+ // input: process.stdin,
102
+ // output: process.stdout,
103
+ // });
104
+ // return new Promise((resolve) => {
105
+ // rl.question(`${question} [y/N] `, (answer) => {
106
+ // const normalizedAnswer = answer.toLowerCase();
107
+ // if (normalizedAnswer === "y" || normalizedAnswer === "yes") {
108
+ // resolve(true);
109
+ // } else {
110
+ // resolve(false);
111
+ // }
112
+ // rl.close();
113
+ // });
114
+ // });
115
+ return new Promise(function (resolve) { return resolve(true); });
102
116
  }
103
117
  function getNumberStringWithDecimal(input, decimal) {
104
118
  input = input.padStart(decimal, "0");
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@typus/typus-sdk",
3
3
  "author": "Typus",
4
4
  "description": "typus sdk",
5
- "version": "1.7.17",
5
+ "version": "1.7.18",
6
6
  "resolutions": {
7
7
  "@mysten/sui": "1.30.0"
8
8
  },