@typus/typus-sdk 1.0.106 → 1.0.108

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.
@@ -22,6 +22,7 @@ export declare function getTransferNftsTx(gasBudget: number, nftPackageId: strin
22
22
  )
23
23
  */
24
24
  export declare function getStakeNftTx(gasBudget: number, nftPackageId: string, registry: string, kiosk: string, kiosk_cap: string, nft_id: string): Promise<TransactionBlock>;
25
+ export declare function getCreateKioskAndLockNftTx(gasBudget: number, nftPackageId: string, policy: string, nft_id: string, singer: string): Promise<TransactionBlock>;
25
26
  /**
26
27
  public fun unstake_nft(
27
28
  registry: &mut Registry,
@@ -52,9 +52,10 @@ var __read = (this && this.__read) || function (o, n) {
52
52
  return ar;
53
53
  };
54
54
  Object.defineProperty(exports, "__esModule", { value: true });
55
- exports.getLevelUpTx = exports.getDepositWithNftTx = exports.getNewBidWithNftTx = exports.getDailyAttendTx = exports.getUnstakeNftTx = exports.getStakeNftTx = exports.getTransferNftsTx = exports.getTransferNftTx = void 0;
55
+ exports.getLevelUpTx = exports.getDepositWithNftTx = exports.getNewBidWithNftTx = exports.getDailyAttendTx = exports.getUnstakeNftTx = exports.getCreateKioskAndLockNftTx = exports.getStakeNftTx = exports.getTransferNftsTx = exports.getTransferNftTx = void 0;
56
56
  var sui_js_1 = require("@mysten/sui.js");
57
57
  var constants_1 = require("../../constants");
58
+ var kiosk_1 = require("@mysten/kiosk");
58
59
  /**
59
60
  entry fun transfer_nft(
60
61
  registry: &mut Registry,
@@ -127,6 +128,25 @@ function getStakeNftTx(gasBudget, nftPackageId, registry, kiosk, kiosk_cap, nft_
127
128
  });
128
129
  }
129
130
  exports.getStakeNftTx = getStakeNftTx;
131
+ function getCreateKioskAndLockNftTx(gasBudget, nftPackageId, policy, nft_id, singer) {
132
+ return __awaiter(this, void 0, void 0, function () {
133
+ var tx, _a, kiosk, kiosk_cap;
134
+ return __generator(this, function (_b) {
135
+ tx = new sui_js_1.TransactionBlock();
136
+ _a = __read((0, kiosk_1.createKiosk)(tx), 2), kiosk = _a[0], kiosk_cap = _a[1];
137
+ (0, kiosk_1.lock)(tx, "".concat(nftPackageId, "::typus_nft::Tails"), kiosk, kiosk_cap, tx.object(policy), tx.object(nft_id));
138
+ tx.moveCall({
139
+ target: "0x2::transfer::public_share_object",
140
+ typeArguments: [kiosk_1.KIOSK_TYPE],
141
+ arguments: [kiosk],
142
+ });
143
+ tx.transferObjects([kiosk_cap], tx.pure(singer));
144
+ tx.setGasBudget(gasBudget);
145
+ return [2 /*return*/, tx];
146
+ });
147
+ });
148
+ }
149
+ exports.getCreateKioskAndLockNftTx = getCreateKioskAndLockNftTx;
130
150
  /**
131
151
  public fun unstake_nft(
132
152
  registry: &mut Registry,
@@ -1,5 +1,131 @@
1
1
  import { JsonRpcProvider } from "@mysten/sui.js";
2
2
  export declare const SENDER = "0xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
3
+ export interface Vault {
4
+ id: string;
5
+ info: Info;
6
+ config: Config;
7
+ deposit_vault: DepositVault;
8
+ }
9
+ export interface Info {
10
+ index: string;
11
+ option_type: string;
12
+ period: string;
13
+ activation_ts_ms: string;
14
+ expiration_ts_ms: string;
15
+ deposit_token: string;
16
+ bid_token: string;
17
+ oracle_token: string;
18
+ d_token_decimal: string;
19
+ b_token_decimal: string;
20
+ o_token_decimal: string;
21
+ creator: string;
22
+ create_ts_ms: string;
23
+ round: string;
24
+ status: string;
25
+ oracle_info: OracleInfo;
26
+ delivery_infos: DeliveryInfos;
27
+ settlement_info: SettlementInfo | undefined;
28
+ u64_padding: string[];
29
+ bcs_padding: string[];
30
+ }
31
+ export interface OracleInfo {
32
+ price: string;
33
+ decimal: string;
34
+ }
35
+ export interface DeliveryInfos {
36
+ round: string;
37
+ max_size: string;
38
+ total_delivery_size: string;
39
+ total_bidder_bid_value: string;
40
+ total_bidder_fee: string;
41
+ total_incentive_bid_value: string;
42
+ total_incentive_fee: string;
43
+ delivery_info: DeliveryInfo[];
44
+ }
45
+ export interface DeliveryInfo {
46
+ delivery_price: string;
47
+ delivery_size: string;
48
+ bidder_bid_value: string;
49
+ bidder_fee: string;
50
+ incentive_bid_value: string;
51
+ incentive_fee: string;
52
+ ts_ms: string;
53
+ }
54
+ export interface SettlementInfo {
55
+ round: string;
56
+ oracle_price: string;
57
+ oracle_price_decimal: string;
58
+ settle_balance: string;
59
+ settled_balance: string;
60
+ share_price: string;
61
+ share_price_decimal: string;
62
+ ts_ms: string;
63
+ }
64
+ export interface Config {
65
+ oracle_id: string;
66
+ deposit_lot_size: string;
67
+ bid_lot_size: string;
68
+ min_deposit_size: string;
69
+ min_bid_size: string;
70
+ deposit_fee_bp: string;
71
+ deposit_fee_share_bp: string;
72
+ deposit_shared_fee_pool: string | undefined;
73
+ bid_fee_bp: string;
74
+ deposit_incentive_bp: string;
75
+ bid_incentive_bp: string;
76
+ auction_delay_ts_ms: string;
77
+ auction_duration_ts_ms: string;
78
+ capacity: string;
79
+ leverage: string;
80
+ risk_level: string;
81
+ has_next: boolean;
82
+ active_vault_config: VaultConfig;
83
+ warmup_vault_config: VaultConfig;
84
+ deposit_receipt_display_name: string;
85
+ deposit_receipt_display_description: string;
86
+ deposit_receipt_display_image_url: string;
87
+ bid_receipt_display_name: string;
88
+ bid_receipt_display_description: string;
89
+ bid_receipt_display_image_url: string;
90
+ u64_padding: string[];
91
+ bcs_padding: string[];
92
+ }
93
+ export interface VaultConfig {
94
+ payoff_configs: PayoffConfig[];
95
+ strike_increment: string;
96
+ decay_speed: string;
97
+ initial_price: string;
98
+ final_price: string;
99
+ }
100
+ export interface PayoffConfig {
101
+ strike_bp: string;
102
+ weight: string;
103
+ is_buyer: boolean;
104
+ strike: string | undefined;
105
+ }
106
+ export interface DepositVault {
107
+ id: string;
108
+ deposit_token: string;
109
+ bid_token: string;
110
+ incentive_token: string | undefined;
111
+ index: string;
112
+ fee_bp: string;
113
+ fee_share_bp: string;
114
+ shared_fee_pool: string | undefined;
115
+ active_share_supply: string;
116
+ deactivating_share_supply: string;
117
+ inactive_share_supply: string;
118
+ warmup_share_supply: string;
119
+ premium_share_supply: string;
120
+ incentive_share_supply: string;
121
+ has_next: boolean;
122
+ name: string;
123
+ description: string;
124
+ image_url: string;
125
+ u64_padding: string[];
126
+ bcs_padding: string[];
127
+ }
128
+ export declare function getVaults(provider: JsonRpcProvider, typusFrameworkPackageId: string, packageId: string, registry: string, indexes: string[]): Promise<Map<string, DepositShare>>;
3
129
  export interface DepositShare {
4
130
  index: string;
5
131
  activeSubVaultUserShare: string;
@@ -52,10 +52,228 @@ var __read = (this && this.__read) || function (o, n) {
52
52
  return ar;
53
53
  };
54
54
  Object.defineProperty(exports, "__esModule", { value: true });
55
- exports.getDepositShares = exports.SENDER = void 0;
55
+ exports.getDepositShares = exports.getVaults = exports.SENDER = void 0;
56
56
  var sui_js_1 = require("@mysten/sui.js");
57
57
  var bcs_1 = require("@mysten/bcs");
58
+ var tools_1 = require("../tools");
58
59
  exports.SENDER = "0xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
60
+ function getVaults(provider, typusFrameworkPackageId, packageId, registry, indexes) {
61
+ return __awaiter(this, void 0, void 0, function () {
62
+ var transactionBlock, target, transactionBlockArguments, results, bytes, reader, result;
63
+ return __generator(this, function (_a) {
64
+ switch (_a.label) {
65
+ case 0:
66
+ transactionBlock = new sui_js_1.TransactionBlock();
67
+ target = "".concat(packageId, "::typus_dov_single::get_vault_data_bcs");
68
+ transactionBlockArguments = [transactionBlock.pure(registry), transactionBlock.pure(indexes)];
69
+ transactionBlock.moveCall({
70
+ target: target,
71
+ typeArguments: [],
72
+ arguments: transactionBlockArguments,
73
+ });
74
+ return [4 /*yield*/, provider.devInspectTransactionBlock({ transactionBlock: transactionBlock, sender: exports.SENDER })];
75
+ case 1:
76
+ results = (_a.sent()).results;
77
+ bytes = results[results.length - 1].returnValues[0][0];
78
+ console.log(JSON.stringify(bytes));
79
+ reader = new bcs_1.BcsReader(new Uint8Array(bytes));
80
+ result = Array.from(new Map()).reduce(function (map, _a) {
81
+ var _b = __read(_a, 2), key = _b[0], value = _b[1];
82
+ map[key] = value;
83
+ return map;
84
+ }, {});
85
+ reader.readVec(function (reader) {
86
+ reader.read16();
87
+ var id = (0, tools_1.AddressFromBytes)(reader.readBytes(32));
88
+ var info = {
89
+ index: reader.read64(),
90
+ option_type: reader.read64(),
91
+ period: reader.read8() + "",
92
+ activation_ts_ms: reader.read64(),
93
+ expiration_ts_ms: reader.read64(),
94
+ deposit_token: String.fromCharCode.apply(null, Array.from(reader.readBytes(reader.read8()))),
95
+ bid_token: String.fromCharCode.apply(null, Array.from(reader.readBytes(reader.read8()))),
96
+ oracle_token: String.fromCharCode.apply(null, Array.from(reader.readBytes(reader.read8()))),
97
+ d_token_decimal: reader.read64(),
98
+ b_token_decimal: reader.read64(),
99
+ o_token_decimal: reader.read64(),
100
+ creator: (0, tools_1.AddressFromBytes)(reader.readBytes(32)),
101
+ create_ts_ms: reader.read64(),
102
+ round: reader.read64(),
103
+ status: reader.read64(),
104
+ oracle_info: {
105
+ price: reader.read64(),
106
+ decimal: reader.read64(),
107
+ },
108
+ delivery_infos: {
109
+ round: reader.read64(),
110
+ max_size: reader.read64(),
111
+ total_delivery_size: reader.read64(),
112
+ total_bidder_bid_value: reader.read64(),
113
+ total_bidder_fee: reader.read64(),
114
+ total_incentive_bid_value: reader.read64(),
115
+ total_incentive_fee: reader.read64(),
116
+ delivery_info: reader.readVec(function (reader) {
117
+ return {
118
+ delivery_price: reader.read64(),
119
+ delivery_size: reader.read64(),
120
+ bidder_bid_value: reader.read64(),
121
+ bidder_fee: reader.read64(),
122
+ incentive_bid_value: reader.read64(),
123
+ incentive_fee: reader.read64(),
124
+ ts_ms: reader.read64(),
125
+ };
126
+ }),
127
+ },
128
+ settlement_info: reader
129
+ .readVec(function (reader) {
130
+ return {
131
+ round: reader.read64(),
132
+ oracle_price: reader.read64(),
133
+ oracle_price_decimal: reader.read64(),
134
+ settle_balance: reader.read64(),
135
+ settled_balance: reader.read64(),
136
+ share_price: reader.read64(),
137
+ share_price_decimal: reader.read64(),
138
+ ts_ms: reader.read64(),
139
+ };
140
+ })
141
+ .at(0),
142
+ u64_padding: reader.readVec(function (reader) {
143
+ return reader.read64();
144
+ }),
145
+ bcs_padding: reader.readVec(function (reader) {
146
+ return reader.read8();
147
+ }),
148
+ };
149
+ var config = {
150
+ oracle_id: (0, tools_1.AddressFromBytes)(reader.readBytes(32)),
151
+ deposit_lot_size: reader.read64(),
152
+ bid_lot_size: reader.read64(),
153
+ min_deposit_size: reader.read64(),
154
+ min_bid_size: reader.read64(),
155
+ deposit_fee_bp: reader.read64(),
156
+ deposit_fee_share_bp: reader.read64(),
157
+ deposit_shared_fee_pool: reader
158
+ .readVec(function (reader) {
159
+ return String.fromCharCode.apply(null, Array.from(reader.readBytes(reader.read8())));
160
+ })
161
+ .at(0),
162
+ bid_fee_bp: reader.read64(),
163
+ deposit_incentive_bp: reader.read64(),
164
+ bid_incentive_bp: reader.read64(),
165
+ auction_delay_ts_ms: reader.read64(),
166
+ auction_duration_ts_ms: reader.read64(),
167
+ capacity: reader.read64(),
168
+ leverage: reader.read64(),
169
+ risk_level: reader.read64(),
170
+ has_next: reader.read8() > 0,
171
+ active_vault_config: {
172
+ payoff_configs: reader.readVec(function (reader) {
173
+ return {
174
+ strike_bp: reader.read64(),
175
+ weight: reader.read64(),
176
+ is_buyer: reader.read8() > 0,
177
+ strike: reader
178
+ .readVec(function (reader) {
179
+ return reader.read64();
180
+ })
181
+ .at(0),
182
+ };
183
+ }),
184
+ strike_increment: reader.read64(),
185
+ decay_speed: reader.read64(),
186
+ initial_price: reader.read64(),
187
+ final_price: reader.read64(),
188
+ },
189
+ warmup_vault_config: {
190
+ payoff_configs: reader.readVec(function (reader) {
191
+ return {
192
+ strike_bp: reader.read64(),
193
+ weight: reader.read64(),
194
+ is_buyer: reader.read8() > 0,
195
+ strike: reader
196
+ .readVec(function (reader) {
197
+ return reader.read64();
198
+ })
199
+ .at(0),
200
+ };
201
+ }),
202
+ strike_increment: reader.read64(),
203
+ decay_speed: reader.read64(),
204
+ initial_price: reader.read64(),
205
+ final_price: reader.read64(),
206
+ },
207
+ deposit_receipt_display_name: String.fromCharCode.apply(null, Array.from(reader.readBytes(reader.read8()))),
208
+ deposit_receipt_display_description: String.fromCharCode.apply(null, Array.from(reader.readBytes(reader.read8()))),
209
+ deposit_receipt_display_image_url: String.fromCharCode.apply(null, Array.from(reader.readBytes(reader.read8()))),
210
+ bid_receipt_display_name: String.fromCharCode.apply(null, Array.from(reader.readBytes(reader.read8()))),
211
+ bid_receipt_display_description: String.fromCharCode.apply(null, Array.from(reader.readBytes(reader.read8()))),
212
+ bid_receipt_display_image_url: String.fromCharCode.apply(null, Array.from(reader.readBytes(reader.read8()))),
213
+ u64_padding: reader.readVec(function (reader) {
214
+ return reader.read64();
215
+ }),
216
+ bcs_padding: reader.readVec(function (reader) {
217
+ return reader.read8();
218
+ }),
219
+ };
220
+ // skip authority bytes
221
+ reader.readBytes(32); // id
222
+ reader.read64(); // size
223
+ reader.readVec(function (reader) {
224
+ return reader.readBytes(32);
225
+ }); // head
226
+ reader.readVec(function (reader) {
227
+ return reader.readBytes(32);
228
+ }); // tail
229
+ var deposit_vault = {
230
+ id: (0, tools_1.AddressFromBytes)(reader.readBytes(32)),
231
+ deposit_token: String.fromCharCode.apply(null, Array.from(reader.readBytes(reader.read8()))),
232
+ bid_token: String.fromCharCode.apply(null, Array.from(reader.readBytes(reader.read8()))),
233
+ incentive_token: reader
234
+ .readVec(function (reader) {
235
+ return String.fromCharCode.apply(null, Array.from(reader.readBytes(reader.read8())));
236
+ })
237
+ .at(0),
238
+ index: reader.read64(),
239
+ fee_bp: reader.read64(),
240
+ fee_share_bp: reader.read64(),
241
+ shared_fee_pool: reader
242
+ .readVec(function (reader) {
243
+ return String.fromCharCode.apply(null, Array.from(reader.readBytes(reader.read8())));
244
+ })
245
+ .at(0),
246
+ active_share_supply: reader.read64(),
247
+ deactivating_share_supply: reader.read64(),
248
+ inactive_share_supply: reader.read64(),
249
+ warmup_share_supply: reader.read64(),
250
+ premium_share_supply: reader.read64(),
251
+ incentive_share_supply: reader.read64(),
252
+ has_next: reader.read8() > 0,
253
+ name: String.fromCharCode.apply(null, Array.from(reader.readBytes(reader.read8()))),
254
+ description: String.fromCharCode.apply(null, Array.from(reader.readBytes(reader.read8()))),
255
+ image_url: String.fromCharCode.apply(null, Array.from(reader.readBytes(reader.read8()))),
256
+ u64_padding: reader.readVec(function (reader) {
257
+ return reader.read64();
258
+ }),
259
+ bcs_padding: reader.readVec(function (reader) {
260
+ return reader.read8();
261
+ }),
262
+ };
263
+ result[info.index] = {
264
+ id: id,
265
+ info: info,
266
+ config: config,
267
+ deposit_vault: deposit_vault,
268
+ };
269
+ });
270
+ // @ts-ignore
271
+ return [2 /*return*/, result];
272
+ }
273
+ });
274
+ });
275
+ }
276
+ exports.getVaults = getVaults;
59
277
  function getDepositShares(provider, typusFrameworkPackageId, packageId, registry, receipts) {
60
278
  return __awaiter(this, void 0, void 0, function () {
61
279
  var transactionBlock, target, transactionBlockArguments, results, bytes, reader, result;
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.0.106",
5
+ "version": "1.0.108",
6
6
  "dependencies": {
7
7
  "@mysten/bcs": "^0.7.3",
8
8
  "@mysten/kiosk": "^0.3.3",