@typus/typus-sdk 1.0.105 → 1.0.107

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/lib/config.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
- "VERSION": "3.0.2",
2
+ "VERSION": "3.0.3",
3
3
  "DB_NAME": "testnet_3_0_0",
4
4
  "RPC_ENDPOINT": "https://api.shinami.com:443/node/v1/sui_testnet_c702de54dad05016124f2cfabc1de7e8",
5
5
  "sponsorApi": "https://northamerica-northeast1-aqueous-freedom-378103.cloudfunctions.net/sponsor-testnet",
6
- "SINGLE_COLLATERAL_PACKAGE": "0x6529d0c44d89345b3b851f72acc16670e8e08ff30a46df145e23ab7526c35e02",
6
+ "SINGLE_COLLATERAL_PACKAGE": "0x14be6404c3222346a001386b0eab940b3429a3c904f6a72dab77044ce67f5f60",
7
7
  "SINGLE_COLLATERAL_PACKAGE_ORIGIN": "0x0334a2ae4b0c5cd007d3bf44925975726b94c1061eb45d660e8b79ec91c0599e",
8
8
  "SINGLE_COLLATERAL_MANAGER_CAP": "0xdc092ced3f08dc31cbbdaa584a937d4e54555cb47a1dca1d756560809d92c0ba",
9
9
  "SINGLE_COLLATERAL_REGISTRY": "0xcb757bd17a8daa75c2b12a5c5f19bd88e7e2e96b8a220bbe4cf0605affea7475",
@@ -22,11 +22,13 @@ 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 getStakeNftFromNoKioskTx(gasBudget: number, PackageId: string, nftPackageId: string, policy: string, registry: string, nft_id: string, singer: string): Promise<TransactionBlock>;
25
26
  /**
26
27
  public fun unstake_nft(
27
28
  registry: &mut Registry,
28
29
  kiosk: &mut Kiosk,
29
30
  kiosk_cap: &KioskOwnerCap,
31
+ coin: Coin<SUI>,
30
32
  ctx: &mut TxContext
31
33
  )
32
34
  */
@@ -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.getStakeNftFromNoKioskTx = 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,23 +128,44 @@ function getStakeNftTx(gasBudget, nftPackageId, registry, kiosk, kiosk_cap, nft_
127
128
  });
128
129
  }
129
130
  exports.getStakeNftTx = getStakeNftTx;
131
+ function getStakeNftFromNoKioskTx(gasBudget, PackageId, nftPackageId, policy, registry, 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, policy, tx.object(nft_id));
138
+ tx.moveCall({
139
+ target: "".concat(PackageId, "::tails_staking::stake_nft"),
140
+ typeArguments: [],
141
+ arguments: [tx.object(registry), kiosk, kiosk_cap, tx.object(nft_id), tx.object(constants_1.CLOCK)],
142
+ });
143
+ tx.transferObjects([kiosk_cap], tx.pure(singer));
144
+ tx.setGasBudget(gasBudget);
145
+ return [2 /*return*/, tx];
146
+ });
147
+ });
148
+ }
149
+ exports.getStakeNftFromNoKioskTx = getStakeNftFromNoKioskTx;
130
150
  /**
131
151
  public fun unstake_nft(
132
152
  registry: &mut Registry,
133
153
  kiosk: &mut Kiosk,
134
154
  kiosk_cap: &KioskOwnerCap,
155
+ coin: Coin<SUI>,
135
156
  ctx: &mut TxContext
136
157
  )
137
158
  */
138
159
  function getUnstakeNftTx(gasBudget, nftPackageId, registry, kiosk, kiosk_cap) {
139
160
  return __awaiter(this, void 0, void 0, function () {
140
- var tx;
141
- return __generator(this, function (_a) {
161
+ var tx, _a, coin;
162
+ return __generator(this, function (_b) {
142
163
  tx = new sui_js_1.TransactionBlock();
164
+ _a = __read(tx.splitCoins(tx.gas, [tx.pure(50000000)]), 1), coin = _a[0];
143
165
  tx.moveCall({
144
166
  target: "".concat(nftPackageId, "::tails_staking::unstake_nft"),
145
167
  typeArguments: [],
146
- arguments: [tx.object(registry), tx.object(kiosk), tx.object(kiosk_cap)],
168
+ arguments: [tx.object(registry), tx.object(kiosk), tx.object(kiosk_cap), coin],
147
169
  });
148
170
  tx.setGasBudget(gasBudget);
149
171
  return [2 /*return*/, tx];
@@ -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.105",
5
+ "version": "1.0.107",
6
6
  "dependencies": {
7
7
  "@mysten/bcs": "^0.7.3",
8
8
  "@mysten/kiosk": "^0.3.3",