@typus/typus-sdk 1.2.11 → 1.2.13

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.
@@ -25,3 +25,19 @@ strategy_pool: string, vault_index: string, signal_index: string, coins: string[
25
25
  */
26
26
  export declare function getCloseStrategyTx(gasBudget: number, packageId: string, typeArguments: string[], // D_TOKEN, B_TOKEN
27
27
  strategy_pool: string, vault_index: string, signal_index: string, strategy_index: string): TransactionBlock;
28
+ /**
29
+ entry fun update_strategy<D_TOKEN, B_TOKEN>(
30
+ strategy_pool: &mut StrategyPoolV2,
31
+ vault_index: u64,
32
+ signal_index: u64,
33
+ strategy_index: u64,
34
+ size: Option<u64>,
35
+ price_percentage: Option<u64>,
36
+ max_times: Option<u64>,
37
+ target_rounds: vector<u64>,
38
+ coins: vector<Coin<B_TOKEN>>,
39
+ ctx: & TxContext
40
+ )
41
+ */
42
+ export declare function getUpdateStrategyTx(gasBudget: number, packageId: string, typeArguments: string[], // D_TOKEN, B_TOKEN
43
+ strategy_pool: string, vault_index: string, signal_index: string, strategy_index: string, coins: string[], amount: string, size: string | null, price_percentage: string | null, max_times: string | null, target_rounds: string[]): TransactionBlock;
@@ -16,7 +16,7 @@ var __read = (this && this.__read) || function (o, n) {
16
16
  return ar;
17
17
  };
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
- exports.getCloseStrategyTx = exports.getNewStrategyTx = void 0;
19
+ exports.getUpdateStrategyTx = exports.getCloseStrategyTx = exports.getNewStrategyTx = void 0;
20
20
  var transactions_1 = require("@mysten/sui.js/transactions");
21
21
  /**
22
22
  entry fun new_strategy<B_TOKEN>(
@@ -100,3 +100,67 @@ strategy_pool, vault_index, signal_index, strategy_index) {
100
100
  return tx;
101
101
  }
102
102
  exports.getCloseStrategyTx = getCloseStrategyTx;
103
+ /**
104
+ entry fun update_strategy<D_TOKEN, B_TOKEN>(
105
+ strategy_pool: &mut StrategyPoolV2,
106
+ vault_index: u64,
107
+ signal_index: u64,
108
+ strategy_index: u64,
109
+ size: Option<u64>,
110
+ price_percentage: Option<u64>,
111
+ max_times: Option<u64>,
112
+ target_rounds: vector<u64>,
113
+ coins: vector<Coin<B_TOKEN>>,
114
+ ctx: & TxContext
115
+ )
116
+ */
117
+ function getUpdateStrategyTx(gasBudget, packageId, typeArguments, // D_TOKEN, B_TOKEN
118
+ strategy_pool, vault_index, signal_index, strategy_index, coins, amount, size, price_percentage, max_times, target_rounds) {
119
+ var tx = new transactions_1.TransactionBlock();
120
+ if (
121
+ // B_TOKEN
122
+ typeArguments[1] == "0x2::sui::SUI" ||
123
+ typeArguments[1] == "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI") {
124
+ var _a = __read(amount ? tx.splitCoins(tx.gas, [tx.pure(amount)]) : [tx.pure([])], 1), input_coin = _a[0];
125
+ tx.moveCall({
126
+ target: "".concat(packageId, "::auto_bid::update_strategy"),
127
+ typeArguments: typeArguments,
128
+ arguments: [
129
+ tx.object(strategy_pool),
130
+ tx.pure(vault_index),
131
+ tx.pure(signal_index),
132
+ tx.pure(strategy_index),
133
+ tx.pure(size ? [size] : []),
134
+ tx.pure(price_percentage ? [price_percentage] : []),
135
+ tx.pure(max_times ? [max_times] : []),
136
+ tx.pure(target_rounds),
137
+ input_coin,
138
+ ],
139
+ });
140
+ }
141
+ else {
142
+ var coin = coins.pop();
143
+ if (coins.length > 0) {
144
+ tx.mergeCoins(tx.object(coin), coins.map(function (coin) { return tx.object(coin); }));
145
+ }
146
+ var _b = __read(tx.splitCoins(tx.object(coin), [tx.pure(amount)]), 1), input_coin = _b[0];
147
+ tx.moveCall({
148
+ target: "".concat(packageId, "::auto_bid::update_strategy"),
149
+ typeArguments: typeArguments,
150
+ arguments: [
151
+ tx.object(strategy_pool),
152
+ tx.pure(vault_index),
153
+ tx.pure(signal_index),
154
+ tx.pure(strategy_index),
155
+ tx.pure(size ? [size] : []),
156
+ tx.pure(price_percentage ? [price_percentage] : []),
157
+ tx.pure(max_times ? [max_times] : []),
158
+ tx.pure(target_rounds),
159
+ tx.makeMoveVec({ objects: [input_coin] }),
160
+ ],
161
+ });
162
+ }
163
+ tx.setGasBudget(gasBudget);
164
+ return tx;
165
+ }
166
+ exports.getUpdateStrategyTx = getUpdateStrategyTx;
@@ -177,12 +177,12 @@ function getVaults(provider, strategyPool) {
177
177
  pool = (_a = (_d.sent()).data) === null || _a === void 0 ? void 0 : _a.content.fields;
178
178
  console.log(pool);
179
179
  vaults = pool.strategies.fields.contents;
180
- console.log(vaults);
181
180
  try {
182
181
  for (vaults_1 = __values(vaults), vaults_1_1 = vaults_1.next(); !vaults_1_1.done; vaults_1_1 = vaults_1.next()) {
183
182
  vault = vaults_1_1.value;
184
183
  signals = vault.fields.value.fields.contents;
185
- console.log(signals);
184
+ console.log("vault: ", vault);
185
+ console.log("signals: ", signals);
186
186
  try {
187
187
  for (signals_1 = (e_2 = void 0, __values(signals)), signals_1_1 = signals_1.next(); !signals_1_1.done; signals_1_1 = signals_1.next()) {
188
188
  signal = signals_1_1.value;
@@ -0,0 +1 @@
1
+ export declare function getDrawResult(network: "mainnet" | "testnet", packageId: string, registry: string, index: string, amount: string, guess_1: string, larger_than_1: boolean, guess_2: string, larger_than_2: boolean, vrf_input_1: number[], vrf_input_2: number[]): Promise<any>;
@@ -0,0 +1,77 @@
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 __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.getDrawResult = void 0;
40
+ var apiUrl = "https://us-central1-aqueous-freedom-378103.cloudfunctions.net/draw-result-1";
41
+ function getDrawResult(network, packageId, registry, index, amount, guess_1, larger_than_1, guess_2, larger_than_2, vrf_input_1, vrf_input_2) {
42
+ return __awaiter(this, void 0, void 0, function () {
43
+ var queryParams, vrf_input_1_string, vrf_input_2_string, apiUrlWithParams, response, data;
44
+ return __generator(this, function (_a) {
45
+ switch (_a.label) {
46
+ case 0:
47
+ queryParams = new URLSearchParams({
48
+ network: network,
49
+ packageId: packageId,
50
+ registry: registry,
51
+ index: index,
52
+ amount: amount,
53
+ guess_1: guess_1,
54
+ larger_than_1: "".concat(larger_than_1),
55
+ guess_2: guess_2,
56
+ larger_than_2: "".concat(larger_than_2),
57
+ });
58
+ vrf_input_1_string = JSON.stringify(vrf_input_1);
59
+ vrf_input_2_string = JSON.stringify(vrf_input_2);
60
+ apiUrlWithParams = "".concat(apiUrl, "?").concat(queryParams.toString(), "&vrf_input_1=").concat(vrf_input_1_string, "&vrf_input_2=").concat(vrf_input_2_string);
61
+ return [4 /*yield*/, fetch(apiUrlWithParams, {
62
+ method: "GET",
63
+ headers: { "Content-Type": "application/json" },
64
+ })];
65
+ case 1:
66
+ response = _a.sent();
67
+ if (!response.ok) return [3 /*break*/, 3];
68
+ return [4 /*yield*/, response.json()];
69
+ case 2:
70
+ data = _a.sent();
71
+ return [2 /*return*/, data];
72
+ case 3: return [2 /*return*/];
73
+ }
74
+ });
75
+ });
76
+ }
77
+ exports.getDrawResult = getDrawResult;
@@ -71,7 +71,7 @@ function assetToDecimal(asset) {
71
71
  case "FUD":
72
72
  return 5;
73
73
  case "MFUD":
74
- return 3;
74
+ return 6;
75
75
  case "INJ":
76
76
  return 8;
77
77
  case "SEI":
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.2.11",
5
+ "version": "1.2.13",
6
6
  "dependencies": {
7
7
  "@mysten/bcs": "^0.7.3",
8
8
  "@mysten/kiosk": "0.7.12",