@typus/typus-sdk 1.0.28 → 1.0.29
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/package.json +1 -1
- package/lib/constants.d.ts +0 -22
- package/lib/constants.js +0 -28
- package/lib/utils/auction/sealedAuction.d.ts +0 -33
- package/lib/utils/auction/sealedAuction.js +0 -64
- package/lib/utils/leader-board.d.ts +0 -7
- package/lib/utils/leader-board.js +0 -197
- package/lib/utils/mint.d.ts +0 -2
- package/lib/utils/mint.js +0 -58
- package/lib/utils/tools.d.ts +0 -1
- package/lib/utils/tools.js +0 -12
- package/lib/utils/typus-dov-double/authorized-entry.d.ts +0 -102
- package/lib/utils/typus-dov-double/authorized-entry.js +0 -295
- package/lib/utils/typus-dov-double/manager-entry.d.ts +0 -219
- package/lib/utils/typus-dov-double/manager-entry.js +0 -584
- package/lib/utils/typus-dov-double/portfolio-vault.d.ts +0 -68
- package/lib/utils/typus-dov-double/portfolio-vault.js +0 -296
- package/lib/utils/typus-dov-double/user-entry.d.ts +0 -93
- package/lib/utils/typus-dov-double/user-entry.js +0 -280
- package/lib/utils/typus-dov-double/view-function.d.ts +0 -11
- package/lib/utils/typus-dov-double/view-function.js +0 -213
- package/lib/utils/typus-dov-single/portfolio-vault.d.ts +0 -61
- package/lib/utils/typus-dov-single/portfolio-vault.js +0 -241
- package/lib/utils/typus-dov-single/user-entry.d.ts +0 -81
- package/lib/utils/typus-dov-single/user-entry.js +0 -247
- package/lib/utils/typus-dov-single/view-function.d.ts +0 -10
- package/lib/utils/typus-dov-single/view-function.js +0 -196
- package/lib/utils/typus-framework/dutch.d.ts +0 -25
- package/lib/utils/typus-framework/dutch.js +0 -84
- package/lib/utils/typus-framework/vault.d.ts +0 -32
- package/lib/utils/typus-framework/vault.js +0 -32
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { JsonRpcProvider } from "@mysten/sui.js";
|
|
2
|
-
import { DepositVaultUserShare, BidVaultUserShare } from "../typus-framework/vault";
|
|
3
|
-
export interface UserShare {
|
|
4
|
-
index: string;
|
|
5
|
-
tokenDepositVaultUserShare: DepositVaultUserShare;
|
|
6
|
-
usdDepositVaultUserShare: DepositVaultUserShare;
|
|
7
|
-
bidVaultUserShare: BidVaultUserShare;
|
|
8
|
-
}
|
|
9
|
-
export declare function getUserShares(provider: JsonRpcProvider, packageId: string, registry: string, indexes: string[], user: string): Promise<Map<string, UserShare>>;
|
|
10
|
-
export declare function getAuctionMaxSize(provider: JsonRpcProvider, packageId: string, typeArguments: string[], registry: string, index: string): Promise<BigInt>;
|
|
11
|
-
export declare function getMaxLossPerUnit(provider: JsonRpcProvider, packageId: string, typeArguments: string[], registry: string, index: string): Promise<BigInt>;
|
|
@@ -1,213 +0,0 @@
|
|
|
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
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
39
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
40
|
-
if (!m) return o;
|
|
41
|
-
var i = m.call(o), r, ar = [], e;
|
|
42
|
-
try {
|
|
43
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
44
|
-
}
|
|
45
|
-
catch (error) { e = { error: error }; }
|
|
46
|
-
finally {
|
|
47
|
-
try {
|
|
48
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
49
|
-
}
|
|
50
|
-
finally { if (e) throw e.error; }
|
|
51
|
-
}
|
|
52
|
-
return ar;
|
|
53
|
-
};
|
|
54
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
55
|
-
exports.getMaxLossPerUnit = exports.getAuctionMaxSize = exports.getUserShares = void 0;
|
|
56
|
-
var sui_js_1 = require("@mysten/sui.js");
|
|
57
|
-
var tools_1 = require("../tools");
|
|
58
|
-
var constants_1 = require("../../constants");
|
|
59
|
-
function getUserShares(provider, packageId, registry, indexes, user) {
|
|
60
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
61
|
-
var transactionBlock, target, transactionBlockArguments, bytes, result, user_share_bytes, index, tag, position, share;
|
|
62
|
-
return __generator(this, function (_a) {
|
|
63
|
-
switch (_a.label) {
|
|
64
|
-
case 0:
|
|
65
|
-
transactionBlock = new sui_js_1.TransactionBlock();
|
|
66
|
-
target = "".concat(packageId, "::typus_dov_double::get_user_shares");
|
|
67
|
-
transactionBlockArguments = [transactionBlock.pure(registry), transactionBlock.pure(indexes), transactionBlock.pure(user)];
|
|
68
|
-
transactionBlock.moveCall({
|
|
69
|
-
target: target,
|
|
70
|
-
arguments: transactionBlockArguments,
|
|
71
|
-
});
|
|
72
|
-
return [4 /*yield*/, provider.devInspectTransactionBlock({ transactionBlock: transactionBlock, sender: user })];
|
|
73
|
-
case 1:
|
|
74
|
-
bytes = (_a.sent()).results[0].returnValues[0][0];
|
|
75
|
-
result = Array.from(new Map()).reduce(function (map, _a) {
|
|
76
|
-
var _b = __read(_a, 2), key = _b[0], value = _b[1];
|
|
77
|
-
map[key] = value;
|
|
78
|
-
return map;
|
|
79
|
-
}, {});
|
|
80
|
-
while (bytes.length > 50) {
|
|
81
|
-
user_share_bytes = bytes.splice(bytes.length - 50, 50);
|
|
82
|
-
index = (0, tools_1.U64FromBytes)(user_share_bytes.splice(0, 8).reverse()).toString();
|
|
83
|
-
tag = (0, tools_1.U64FromBytes)(user_share_bytes.splice(0, 1).reverse()).toString();
|
|
84
|
-
user_share_bytes.splice(0, 32);
|
|
85
|
-
position = (0, tools_1.U64FromBytes)(user_share_bytes.splice(0, 1).reverse()).toString();
|
|
86
|
-
share = (0, tools_1.U64FromBytes)(user_share_bytes.splice(0, 8).reverse());
|
|
87
|
-
if (result[index] == undefined) {
|
|
88
|
-
result[index] = {
|
|
89
|
-
index: index,
|
|
90
|
-
tokenDepositVaultUserShare: {
|
|
91
|
-
activeSubVaultUserShare: BigInt(0),
|
|
92
|
-
deactivatingSubVaultUserShare: BigInt(0),
|
|
93
|
-
inactiveSubVaultUserShare: BigInt(0),
|
|
94
|
-
warmupSubVaultUserShare: BigInt(0),
|
|
95
|
-
},
|
|
96
|
-
usdDepositVaultUserShare: {
|
|
97
|
-
activeSubVaultUserShare: BigInt(0),
|
|
98
|
-
deactivatingSubVaultUserShare: BigInt(0),
|
|
99
|
-
inactiveSubVaultUserShare: BigInt(0),
|
|
100
|
-
warmupSubVaultUserShare: BigInt(0),
|
|
101
|
-
},
|
|
102
|
-
bidVaultUserShare: {
|
|
103
|
-
bidderSubVaultUserShare: BigInt(0),
|
|
104
|
-
premiumSubVaultUserShare: BigInt(0),
|
|
105
|
-
performanceFeeSubVaultUserShare: BigInt(0),
|
|
106
|
-
},
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
result[index].index = index;
|
|
110
|
-
switch (tag) {
|
|
111
|
-
case "0": {
|
|
112
|
-
if (position == "0") {
|
|
113
|
-
result[index].tokenDepositVaultUserShare.activeSubVaultUserShare = share;
|
|
114
|
-
}
|
|
115
|
-
else {
|
|
116
|
-
result[index].usdDepositVaultUserShare.activeSubVaultUserShare = share;
|
|
117
|
-
}
|
|
118
|
-
break;
|
|
119
|
-
}
|
|
120
|
-
case "1": {
|
|
121
|
-
if (position == "0") {
|
|
122
|
-
result[index].tokenDepositVaultUserShare.deactivatingSubVaultUserShare = share;
|
|
123
|
-
}
|
|
124
|
-
else {
|
|
125
|
-
result[index].usdDepositVaultUserShare.deactivatingSubVaultUserShare = share;
|
|
126
|
-
}
|
|
127
|
-
break;
|
|
128
|
-
}
|
|
129
|
-
case "2": {
|
|
130
|
-
if (position == "0") {
|
|
131
|
-
result[index].tokenDepositVaultUserShare.inactiveSubVaultUserShare = share;
|
|
132
|
-
}
|
|
133
|
-
else {
|
|
134
|
-
result[index].usdDepositVaultUserShare.inactiveSubVaultUserShare = share;
|
|
135
|
-
}
|
|
136
|
-
break;
|
|
137
|
-
}
|
|
138
|
-
case "3": {
|
|
139
|
-
if (position == "0") {
|
|
140
|
-
result[index].tokenDepositVaultUserShare.warmupSubVaultUserShare = share;
|
|
141
|
-
}
|
|
142
|
-
else {
|
|
143
|
-
result[index].usdDepositVaultUserShare.warmupSubVaultUserShare = share;
|
|
144
|
-
}
|
|
145
|
-
break;
|
|
146
|
-
}
|
|
147
|
-
case "4": {
|
|
148
|
-
result[index].bidVaultUserShare.bidderSubVaultUserShare = share;
|
|
149
|
-
break;
|
|
150
|
-
}
|
|
151
|
-
case "5": {
|
|
152
|
-
result[index].bidVaultUserShare.premiumSubVaultUserShare = share;
|
|
153
|
-
break;
|
|
154
|
-
}
|
|
155
|
-
case "6": {
|
|
156
|
-
result[index].bidVaultUserShare.performanceFeeSubVaultUserShare = share;
|
|
157
|
-
break;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
// @ts-ignore
|
|
162
|
-
return [2 /*return*/, result];
|
|
163
|
-
}
|
|
164
|
-
});
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
exports.getUserShares = getUserShares;
|
|
168
|
-
function getAuctionMaxSize(provider, packageId, typeArguments, registry, index) {
|
|
169
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
170
|
-
var transactionBlock, target, transactionBlockArguments, bytes;
|
|
171
|
-
return __generator(this, function (_a) {
|
|
172
|
-
switch (_a.label) {
|
|
173
|
-
case 0:
|
|
174
|
-
transactionBlock = new sui_js_1.TransactionBlock();
|
|
175
|
-
target = "".concat(packageId, "::typus_dov_double::get_auction_max_size");
|
|
176
|
-
transactionBlockArguments = [transactionBlock.pure(registry), transactionBlock.pure(index)];
|
|
177
|
-
transactionBlock.moveCall({
|
|
178
|
-
target: target,
|
|
179
|
-
typeArguments: typeArguments,
|
|
180
|
-
arguments: transactionBlockArguments,
|
|
181
|
-
});
|
|
182
|
-
return [4 /*yield*/, provider.devInspectTransactionBlock({ transactionBlock: transactionBlock, sender: constants_1.SENDER })];
|
|
183
|
-
case 1:
|
|
184
|
-
bytes = (_a.sent()).results[0].returnValues[0][0];
|
|
185
|
-
return [2 /*return*/, (0, tools_1.U64FromBytes)(bytes.reverse())];
|
|
186
|
-
}
|
|
187
|
-
});
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
exports.getAuctionMaxSize = getAuctionMaxSize;
|
|
191
|
-
function getMaxLossPerUnit(provider, packageId, typeArguments, registry, index) {
|
|
192
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
193
|
-
var transactionBlock, target, transactionBlockArguments, bytes;
|
|
194
|
-
return __generator(this, function (_a) {
|
|
195
|
-
switch (_a.label) {
|
|
196
|
-
case 0:
|
|
197
|
-
transactionBlock = new sui_js_1.TransactionBlock();
|
|
198
|
-
target = "".concat(packageId, "::typus_dov_double::get_max_loss_per_unit");
|
|
199
|
-
transactionBlockArguments = [transactionBlock.pure(registry), transactionBlock.pure(index)];
|
|
200
|
-
transactionBlock.moveCall({
|
|
201
|
-
target: target,
|
|
202
|
-
typeArguments: typeArguments,
|
|
203
|
-
arguments: transactionBlockArguments,
|
|
204
|
-
});
|
|
205
|
-
return [4 /*yield*/, provider.devInspectTransactionBlock({ transactionBlock: transactionBlock, sender: constants_1.SENDER })];
|
|
206
|
-
case 1:
|
|
207
|
-
bytes = (_a.sent()).results[0].returnValues[0][0];
|
|
208
|
-
return [2 /*return*/, (0, tools_1.U64FromBytes)(bytes.reverse())];
|
|
209
|
-
}
|
|
210
|
-
});
|
|
211
|
-
});
|
|
212
|
-
}
|
|
213
|
-
exports.getMaxLossPerUnit = getMaxLossPerUnit;
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { JsonRpcProvider } from "@mysten/sui.js";
|
|
2
|
-
import { DepositVault, BidVault } from "../typus-framework/vault";
|
|
3
|
-
import { Auction } from "../typus-framework/dutch";
|
|
4
|
-
export interface PortfolioVault {
|
|
5
|
-
vaultId: string;
|
|
6
|
-
typeArgs: string[];
|
|
7
|
-
assets: string[];
|
|
8
|
-
info: Info;
|
|
9
|
-
config: Config;
|
|
10
|
-
depositVault: DepositVault;
|
|
11
|
-
bidVault: BidVault;
|
|
12
|
-
auction: Auction;
|
|
13
|
-
authority: string;
|
|
14
|
-
tokenTvl: bigint;
|
|
15
|
-
usdTvl: bigint;
|
|
16
|
-
}
|
|
17
|
-
export interface Info {
|
|
18
|
-
index: string;
|
|
19
|
-
creator: string;
|
|
20
|
-
createTsMs: string;
|
|
21
|
-
round: string;
|
|
22
|
-
deliveryInfo?: DeliveryInfo;
|
|
23
|
-
}
|
|
24
|
-
export interface DeliveryInfo {
|
|
25
|
-
round: string;
|
|
26
|
-
price: string;
|
|
27
|
-
size: string;
|
|
28
|
-
premium: string;
|
|
29
|
-
tsMs: string;
|
|
30
|
-
}
|
|
31
|
-
export interface Config {
|
|
32
|
-
optionType: string;
|
|
33
|
-
period: number;
|
|
34
|
-
activationTsMs: string;
|
|
35
|
-
expirationTsMs: string;
|
|
36
|
-
dTokenDecimal: string;
|
|
37
|
-
bTokenDecimal: string;
|
|
38
|
-
oTokenDecimal: string;
|
|
39
|
-
lotSize: string;
|
|
40
|
-
capacity: string;
|
|
41
|
-
leverage: string;
|
|
42
|
-
hasNext: boolean;
|
|
43
|
-
activeVaultConfig: VaultConfig;
|
|
44
|
-
warmupVaultConfig: VaultConfig;
|
|
45
|
-
upcomingVaultConfig: VaultConfig;
|
|
46
|
-
}
|
|
47
|
-
export interface VaultConfig {
|
|
48
|
-
payoffConfigs: PayoffConfig[];
|
|
49
|
-
strikeIncrement: string;
|
|
50
|
-
decaySpeed: string;
|
|
51
|
-
initialPrice: string;
|
|
52
|
-
finalPrice: string;
|
|
53
|
-
auctionDurationInMs: string;
|
|
54
|
-
}
|
|
55
|
-
export interface PayoffConfig {
|
|
56
|
-
strikePct: string;
|
|
57
|
-
weight: string;
|
|
58
|
-
isBuyer: boolean;
|
|
59
|
-
strike?: string;
|
|
60
|
-
}
|
|
61
|
-
export declare function getPortfolioVaults(provider: JsonRpcProvider, registry: string, deposit_vault_registry: string, bid_vault_registry: string, index?: string): Promise<Map<string, PortfolioVault>>;
|
|
@@ -1,241 +0,0 @@
|
|
|
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.getPortfolioVaults = void 0;
|
|
40
|
-
var vault_1 = require("../typus-framework/vault");
|
|
41
|
-
var dutch_1 = require("../typus-framework/dutch");
|
|
42
|
-
function getPortfolioVaults(provider, registry, deposit_vault_registry, bid_vault_registry, index) {
|
|
43
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
44
|
-
var portfolioVaultIds, portfolioVaults, depositVaultIds, bidVaultIds;
|
|
45
|
-
return __generator(this, function (_a) {
|
|
46
|
-
switch (_a.label) {
|
|
47
|
-
case 0: return [4 /*yield*/, provider.getDynamicFields({ parentId: registry })];
|
|
48
|
-
case 1:
|
|
49
|
-
portfolioVaultIds = (_a.sent()).data
|
|
50
|
-
.filter(function (x) { return (index ? x.name.value == index : true); })
|
|
51
|
-
.map(function (x) { return x.objectId; });
|
|
52
|
-
return [4 /*yield*/, provider.multiGetObjects({
|
|
53
|
-
ids: portfolioVaultIds,
|
|
54
|
-
options: { showContent: true },
|
|
55
|
-
})];
|
|
56
|
-
case 2:
|
|
57
|
-
portfolioVaults = (_a.sent())
|
|
58
|
-
.filter(function (portfolioVault) { return portfolioVault.error == undefined; })
|
|
59
|
-
.reduce(function (map, portfolioVault) {
|
|
60
|
-
// console.log(JSON.stringify(portfolioVault, null, 4));
|
|
61
|
-
// @ts-ignore
|
|
62
|
-
var vaultId = portfolioVault.data.content.fields.id.id;
|
|
63
|
-
// @ts-ignore
|
|
64
|
-
var typeArgs = new RegExp(".*<(.*), (.*), (.*)>").exec(portfolioVault.data.content.type).slice(1, 4);
|
|
65
|
-
var assets = typeArgs.map(function (x) { return x.split("::")[2]; });
|
|
66
|
-
var deliveryInfo =
|
|
67
|
-
// @ts-ignore
|
|
68
|
-
portfolioVault.data.content.fields.info.fields.delivery_info
|
|
69
|
-
? {
|
|
70
|
-
// @ts-ignore
|
|
71
|
-
round: portfolioVault.data.content.fields.info.fields.delivery_info.fields.round,
|
|
72
|
-
// @ts-ignore
|
|
73
|
-
price: portfolioVault.data.content.fields.info.fields.delivery_info.fields.price,
|
|
74
|
-
// @ts-ignore
|
|
75
|
-
size: portfolioVault.data.content.fields.info.fields.delivery_info.fields.size,
|
|
76
|
-
// @ts-ignore
|
|
77
|
-
premium: portfolioVault.data.content.fields.info.fields.delivery_info.fields.premium,
|
|
78
|
-
// @ts-ignore
|
|
79
|
-
tsMs: portfolioVault.data.content.fields.info.fields.delivery_info.fields.ts_ms,
|
|
80
|
-
}
|
|
81
|
-
: undefined;
|
|
82
|
-
var info = {
|
|
83
|
-
// @ts-ignore
|
|
84
|
-
index: portfolioVault.data.content.fields.info.fields.index,
|
|
85
|
-
// @ts-ignore
|
|
86
|
-
creator: portfolioVault.data.content.fields.info.fields.creator,
|
|
87
|
-
// @ts-ignore
|
|
88
|
-
createTsMs: portfolioVault.data.content.fields.info.fields.create_ts_ms,
|
|
89
|
-
// @ts-ignore
|
|
90
|
-
round: portfolioVault.data.content.fields.info.fields.round,
|
|
91
|
-
deliveryInfo: deliveryInfo,
|
|
92
|
-
};
|
|
93
|
-
var config = {
|
|
94
|
-
// @ts-ignore
|
|
95
|
-
optionType: portfolioVault.data.content.fields.config.fields.option_type,
|
|
96
|
-
// @ts-ignore
|
|
97
|
-
period: portfolioVault.data.content.fields.config.fields.period,
|
|
98
|
-
// @ts-ignore
|
|
99
|
-
activationTsMs: portfolioVault.data.content.fields.config.fields.activation_ts_ms,
|
|
100
|
-
// @ts-ignore
|
|
101
|
-
expirationTsMs: portfolioVault.data.content.fields.config.fields.expiration_ts_ms,
|
|
102
|
-
// @ts-ignore
|
|
103
|
-
dTokenDecimal: portfolioVault.data.content.fields.config.fields.d_token_decimal,
|
|
104
|
-
// @ts-ignore
|
|
105
|
-
bTokenDecimal: portfolioVault.data.content.fields.config.fields.b_token_decimal,
|
|
106
|
-
// @ts-ignore
|
|
107
|
-
oTokenDecimal: portfolioVault.data.content.fields.config.fields.o_token_decimal,
|
|
108
|
-
// @ts-ignore
|
|
109
|
-
lotSize: portfolioVault.data.content.fields.config.fields.lot_size,
|
|
110
|
-
// @ts-ignore
|
|
111
|
-
capacity: portfolioVault.data.content.fields.config.fields.capacity,
|
|
112
|
-
// @ts-ignore
|
|
113
|
-
leverage: portfolioVault.data.content.fields.config.fields.leverage,
|
|
114
|
-
// @ts-ignore
|
|
115
|
-
hasNext: portfolioVault.data.content.fields.config.fields.has_next,
|
|
116
|
-
activeVaultConfig: {
|
|
117
|
-
// @ts-ignore
|
|
118
|
-
payoffConfigs: portfolioVault.data.content.fields.config.fields.active_vault_config.fields.payoff_configs.map(function (x) {
|
|
119
|
-
return ({
|
|
120
|
-
strikePct: x.fields.strike_pct,
|
|
121
|
-
weight: x.fields.weight,
|
|
122
|
-
isBuyer: x.fields.is_buyer,
|
|
123
|
-
strike: x.fields.strike,
|
|
124
|
-
});
|
|
125
|
-
}),
|
|
126
|
-
// @ts-ignore
|
|
127
|
-
strikeIncrement: portfolioVault.data.content.fields.config.fields.active_vault_config.fields.strike_increment,
|
|
128
|
-
// @ts-ignore
|
|
129
|
-
decaySpeed: portfolioVault.data.content.fields.config.fields.active_vault_config.fields.decay_speed,
|
|
130
|
-
// @ts-ignore
|
|
131
|
-
initialPrice: portfolioVault.data.content.fields.config.fields.active_vault_config.fields.initial_price,
|
|
132
|
-
// @ts-ignore
|
|
133
|
-
finalPrice: portfolioVault.data.content.fields.config.fields.active_vault_config.fields.final_price,
|
|
134
|
-
// @ts-ignore
|
|
135
|
-
auctionDurationInMs: portfolioVault.data.content.fields.config.fields.active_vault_config.fields.auction_duration_in_ms,
|
|
136
|
-
},
|
|
137
|
-
warmupVaultConfig: {
|
|
138
|
-
// @ts-ignore
|
|
139
|
-
payoffConfigs: portfolioVault.data.content.fields.config.fields.warmup_vault_config.fields.payoff_configs.map(function (x) {
|
|
140
|
-
return ({
|
|
141
|
-
strikePct: x.fields.strike_pct,
|
|
142
|
-
weight: x.fields.weight,
|
|
143
|
-
isBuyer: x.fields.is_buyer,
|
|
144
|
-
strike: x.fields.strike,
|
|
145
|
-
});
|
|
146
|
-
}),
|
|
147
|
-
// @ts-ignore
|
|
148
|
-
strikeIncrement: portfolioVault.data.content.fields.config.fields.warmup_vault_config.fields.strike_increment,
|
|
149
|
-
// @ts-ignore
|
|
150
|
-
decaySpeed: portfolioVault.data.content.fields.config.fields.warmup_vault_config.fields.decay_speed,
|
|
151
|
-
// @ts-ignore
|
|
152
|
-
initialPrice: portfolioVault.data.content.fields.config.fields.warmup_vault_config.fields.initial_price,
|
|
153
|
-
// @ts-ignore
|
|
154
|
-
finalPrice: portfolioVault.data.content.fields.config.fields.warmup_vault_config.fields.final_price,
|
|
155
|
-
// @ts-ignore
|
|
156
|
-
auctionDurationInMs: portfolioVault.data.content.fields.config.fields.warmup_vault_config.fields.auction_duration_in_ms,
|
|
157
|
-
},
|
|
158
|
-
upcomingVaultConfig: {
|
|
159
|
-
// @ts-ignore
|
|
160
|
-
payoffConfigs: portfolioVault.data.content.fields.config.fields.upcoming_vault_config.fields.payoff_configs.map(function (x) {
|
|
161
|
-
return ({
|
|
162
|
-
strikePct: x.fields.strike_pct,
|
|
163
|
-
weight: x.fields.weight,
|
|
164
|
-
isBuyer: x.fields.is_buyer,
|
|
165
|
-
strike: x.fields.strike,
|
|
166
|
-
});
|
|
167
|
-
}),
|
|
168
|
-
// @ts-ignore
|
|
169
|
-
strikeIncrement: portfolioVault.data.content.fields.config.fields.upcoming_vault_config.fields.strike_increment,
|
|
170
|
-
// @ts-ignore
|
|
171
|
-
decaySpeed: portfolioVault.data.content.fields.config.fields.upcoming_vault_config.fields.decay_speed,
|
|
172
|
-
// @ts-ignore
|
|
173
|
-
initialPrice: portfolioVault.data.content.fields.config.fields.upcoming_vault_config.fields.initial_price,
|
|
174
|
-
// @ts-ignore
|
|
175
|
-
finalPrice: portfolioVault.data.content.fields.config.fields.upcoming_vault_config.fields.final_price,
|
|
176
|
-
auctionDurationInMs:
|
|
177
|
-
// @ts-ignore
|
|
178
|
-
portfolioVault.data.content.fields.config.fields.upcoming_vault_config.fields.auction_duration_in_ms,
|
|
179
|
-
},
|
|
180
|
-
};
|
|
181
|
-
// @ts-ignore
|
|
182
|
-
var auction = portfolioVault.data.content.fields.auction ? (0, dutch_1.parseAuction)(portfolioVault.data.content.fields.auction) : undefined;
|
|
183
|
-
// @ts-ignore
|
|
184
|
-
var authority = portfolioVault.data.content.fields.authority.fields.whitelist.fields.id.id;
|
|
185
|
-
map[info.index] = {
|
|
186
|
-
vaultId: vaultId,
|
|
187
|
-
typeArgs: typeArgs,
|
|
188
|
-
assets: assets,
|
|
189
|
-
info: info,
|
|
190
|
-
config: config,
|
|
191
|
-
depositVault: {},
|
|
192
|
-
bidVault: {},
|
|
193
|
-
auction: auction,
|
|
194
|
-
authority: authority,
|
|
195
|
-
};
|
|
196
|
-
return map;
|
|
197
|
-
}, {});
|
|
198
|
-
return [4 /*yield*/, provider.getDynamicFields({ parentId: deposit_vault_registry })];
|
|
199
|
-
case 3:
|
|
200
|
-
depositVaultIds = (_a.sent()).data
|
|
201
|
-
.filter(function (x) { return (index ? x.name.value == index : true); })
|
|
202
|
-
.map(function (x) { return x.objectId; });
|
|
203
|
-
return [4 /*yield*/, provider.multiGetObjects({
|
|
204
|
-
ids: depositVaultIds,
|
|
205
|
-
options: { showContent: true },
|
|
206
|
-
})];
|
|
207
|
-
case 4:
|
|
208
|
-
(_a.sent())
|
|
209
|
-
.filter(function (depositVault) { return depositVault.error == undefined; })
|
|
210
|
-
.forEach(function (depositVault) {
|
|
211
|
-
// @ts-ignore
|
|
212
|
-
var index = depositVault.data.content.fields.name;
|
|
213
|
-
// @ts-ignore
|
|
214
|
-
var vault = (0, vault_1.parseDepositVault)(depositVault.data.content.fields.value);
|
|
215
|
-
var tvl = BigInt(vault.activeSubVault.balance) + BigInt(vault.warmupSubVault.balance);
|
|
216
|
-
portfolioVaults[index].tokenTvl = tvl;
|
|
217
|
-
portfolioVaults[index].depositVault = vault;
|
|
218
|
-
});
|
|
219
|
-
return [4 /*yield*/, provider.getDynamicFields({ parentId: bid_vault_registry })];
|
|
220
|
-
case 5:
|
|
221
|
-
bidVaultIds = (_a.sent()).data
|
|
222
|
-
.filter(function (x) { return (index ? x.name.value == index : true); })
|
|
223
|
-
.map(function (x) { return x.objectId; });
|
|
224
|
-
return [4 /*yield*/, provider.multiGetObjects({
|
|
225
|
-
ids: bidVaultIds,
|
|
226
|
-
options: { showContent: true },
|
|
227
|
-
})];
|
|
228
|
-
case 6:
|
|
229
|
-
(_a.sent())
|
|
230
|
-
.filter(function (bidVault) { return bidVault.error == undefined; })
|
|
231
|
-
.forEach(function (bidVault) {
|
|
232
|
-
// @ts-ignore
|
|
233
|
-
portfolioVaults[bidVault.data.content.fields.name].bidVault = (0, vault_1.parseBidVault)(bidVault.data.content.fields.value);
|
|
234
|
-
});
|
|
235
|
-
// @ts-ignore
|
|
236
|
-
return [2 /*return*/, portfolioVaults];
|
|
237
|
-
}
|
|
238
|
-
});
|
|
239
|
-
});
|
|
240
|
-
}
|
|
241
|
-
exports.getPortfolioVaults = getPortfolioVaults;
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { TransactionBlock } from "@mysten/sui.js";
|
|
2
|
-
/**
|
|
3
|
-
public(friend) entry fun deposit<D_TOKEN, B_TOKEN, O_TOKEN>(
|
|
4
|
-
registry: &mut Registry,
|
|
5
|
-
index: u64,
|
|
6
|
-
coins: vector<Coin<D_TOKEN>>,
|
|
7
|
-
amount: u64,
|
|
8
|
-
ctx: &mut TxContext
|
|
9
|
-
)
|
|
10
|
-
@param typeArguments [Deposit Vault Token, Bid Vault Token, Oracle Token]
|
|
11
|
-
*/
|
|
12
|
-
export declare function getDepositTx(gasBudget: number, packageId: string, typeArguments: string[], registry: string, index: string, coins: string[], amount: string): Promise<TransactionBlock>;
|
|
13
|
-
/**
|
|
14
|
-
public(friend) entry fun withdraw<TOKEN>(
|
|
15
|
-
registry: &mut Registry,
|
|
16
|
-
index: u64,
|
|
17
|
-
share: Option<u64>,
|
|
18
|
-
ctx: &mut TxContext
|
|
19
|
-
)
|
|
20
|
-
@param typeArguments [Deposit Vault Token]
|
|
21
|
-
*/
|
|
22
|
-
export declare function getWithdrawTx(gasBudget: number, packageId: string, typeArguments: string[], registry: string, index: string, share?: string): Promise<TransactionBlock>;
|
|
23
|
-
/**
|
|
24
|
-
public(friend) entry fun claim<TOKEN>(
|
|
25
|
-
registry: &mut Registry,
|
|
26
|
-
index: u64,
|
|
27
|
-
ctx: &mut TxContext
|
|
28
|
-
)
|
|
29
|
-
@param typeArguments [Deposit Vault Token]
|
|
30
|
-
*/
|
|
31
|
-
export declare function getClaimTx(gasBudget: number, packageId: string, typeArguments: string[], registry: string, index: string): Promise<TransactionBlock>;
|
|
32
|
-
/**
|
|
33
|
-
public(friend) entry fun harvest<TOKEN>(
|
|
34
|
-
registry: &mut Registry,
|
|
35
|
-
index: u64,
|
|
36
|
-
ctx: &mut TxContext
|
|
37
|
-
)
|
|
38
|
-
@param typeArguments [Bid Vault Token]
|
|
39
|
-
*/
|
|
40
|
-
export declare function getHarvestTx(gasBudget: number, packageId: string, typeArguments: string[], registry: string, index: string): Promise<TransactionBlock>;
|
|
41
|
-
/**
|
|
42
|
-
public(friend) entry fun claim_and_harvest<D_TOKEN, B_TOKEN>(
|
|
43
|
-
registry: &mut Registry,
|
|
44
|
-
index: u64,
|
|
45
|
-
ctx: &mut TxContext
|
|
46
|
-
)
|
|
47
|
-
@param typeArguments [Deposit Vault Token, Bid Vault Token]
|
|
48
|
-
*/
|
|
49
|
-
export declare function getClaimAndHarvestTx(gasBudget: number, packageId: string, typeArguments: string[], registry: string, index: string): Promise<TransactionBlock>;
|
|
50
|
-
/**
|
|
51
|
-
public(friend) entry fun compound<TOKEN, O_TOKEN>(
|
|
52
|
-
registry: &mut Registry,
|
|
53
|
-
index: u64,
|
|
54
|
-
ctx: &mut TxContext,
|
|
55
|
-
)
|
|
56
|
-
@param typeArguments [Deposit Vault Token, Oracle Token]
|
|
57
|
-
*/
|
|
58
|
-
export declare function getCompoundTx(gasBudget: number, packageId: string, typeArguments: string[], registry: string, index: string): Promise<TransactionBlock>;
|
|
59
|
-
/**
|
|
60
|
-
public(friend) entry fun unsubscribe<TOKEN>(
|
|
61
|
-
registry: &mut Registry,
|
|
62
|
-
index: u64,
|
|
63
|
-
share: Option<u64>,
|
|
64
|
-
ctx: &mut TxContext
|
|
65
|
-
)
|
|
66
|
-
@param typeArguments [Deposit Vault Token]
|
|
67
|
-
*/
|
|
68
|
-
export declare function getUnsubscribeTx(gasBudget: number, packageId: string, typeArguments: string[], registry: string, index: string, share?: string): Promise<TransactionBlock>;
|
|
69
|
-
/**
|
|
70
|
-
public(friend) entry fun new_bid<D_TOKEN, B_TOKEN, O_TOKEN>(
|
|
71
|
-
registry: &mut Registry,
|
|
72
|
-
index: u64,
|
|
73
|
-
price_oracle: &Oracle<O_TOKEN>,
|
|
74
|
-
clock: &Clock,
|
|
75
|
-
coins: vector<Coin<B_TOKEN>>,
|
|
76
|
-
size: u64,
|
|
77
|
-
ctx: &mut TxContext,
|
|
78
|
-
)
|
|
79
|
-
@param typeArguments [Deposit Vault Token, Bid Vault Token, Oracle Token]
|
|
80
|
-
*/
|
|
81
|
-
export declare function getNewBidTx(gasBudget: number, packageId: string, typeArguments: string[], registry: string, index: string, priceOracle: string, coins: string[], size: string): Promise<TransactionBlock>;
|