@typus/typus-sdk 1.2.68 → 1.2.70
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 +14 -14
- package/lib/utils/airdrop/authority-entry.d.ts +22 -0
- package/lib/utils/airdrop/authority-entry.js +138 -0
- package/lib/utils/airdrop/user-entry.d.ts +10 -0
- package/lib/utils/airdrop/user-entry.js +21 -0
- package/lib/utils/airdrop/view-functions.d.ts +10 -0
- package/lib/utils/airdrop/view-functions.js +72 -0
- package/lib/utils/leaderboard/authority-entry.d.ts +22 -0
- package/lib/utils/leaderboard/authority-entry.js +91 -0
- package/lib/utils/leaderboard/view-function.d.ts +21 -0
- package/lib/utils/leaderboard/view-function.js +92 -0
- package/lib/utils/nft-staking/user-entry.d.ts +2 -2
- package/lib/utils/nft-staking/user-entry.js +25 -8
- package/lib/utils/typus-dov-single-v2/mfud-user-entry.d.ts +4 -0
- package/lib/utils/typus-dov-single-v2/mfud-user-entry.js +5 -1
- package/lib/utils/typus-dov-single-v2/user-entry.d.ts +4 -0
- package/lib/utils/typus-dov-single-v2/user-entry.js +10 -2
- package/lib/utils/user/view-functions.d.ts +9 -0
- package/lib/utils/user/view-functions.js +71 -0
- package/package.json +1 -1
- 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 -303
- 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/db-data.d.ts +0 -19
- package/lib/utils/typus-dov-single/db-data.js +0 -226
- package/lib/utils/typus-dov-single/portfolio-vault.d.ts +0 -63
- package/lib/utils/typus-dov-single/portfolio-vault.js +0 -284
- package/lib/utils/typus-dov-single/registry.d.ts +0 -14
- package/lib/utils/typus-dov-single/registry.js +0 -126
- package/lib/utils/typus-dov-single/user-entry.d.ts +0 -103
- package/lib/utils/typus-dov-single/user-entry.js +0 -388
- package/lib/utils/typus-dov-single/user-history.d.ts +0 -17
- package/lib/utils/typus-dov-single/user-history.js +0 -146
- package/lib/utils/typus-dov-single/view-function.d.ts +0 -50
- package/lib/utils/typus-dov-single/view-function.js +0 -444
|
@@ -1,226 +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.getShowMap = exports.getDb = void 0;
|
|
40
|
-
var apiUrl = "https://us-central1-aqueous-freedom-378103.cloudfunctions.net/mongodb";
|
|
41
|
-
function getDb(database_1, functionNames_1, vaultIndex_1, startTsMs_1, limit_1) {
|
|
42
|
-
return __awaiter(this, arguments, void 0, function (database, functionNames, vaultIndex, startTsMs, limit, endTsMs) {
|
|
43
|
-
var jsonData, response, data;
|
|
44
|
-
if (endTsMs === void 0) { endTsMs = undefined; }
|
|
45
|
-
return __generator(this, function (_a) {
|
|
46
|
-
switch (_a.label) {
|
|
47
|
-
case 0:
|
|
48
|
-
jsonData = JSON.stringify({
|
|
49
|
-
database: database,
|
|
50
|
-
functionNames: functionNames,
|
|
51
|
-
vaultIndex: vaultIndex,
|
|
52
|
-
startTsMs: startTsMs,
|
|
53
|
-
endTsMs: endTsMs,
|
|
54
|
-
limit: limit,
|
|
55
|
-
});
|
|
56
|
-
return [4 /*yield*/, fetch(apiUrl, {
|
|
57
|
-
method: "POST",
|
|
58
|
-
headers: { "Content-Type": "application/json" },
|
|
59
|
-
body: jsonData,
|
|
60
|
-
})];
|
|
61
|
-
case 1:
|
|
62
|
-
response = _a.sent();
|
|
63
|
-
if (!response.ok) return [3 /*break*/, 3];
|
|
64
|
-
return [4 /*yield*/, response.json()];
|
|
65
|
-
case 2:
|
|
66
|
-
data = _a.sent();
|
|
67
|
-
return [2 /*return*/, data];
|
|
68
|
-
case 3: return [2 /*return*/];
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
exports.getDb = getDb;
|
|
74
|
-
function getShowMap(database_1, portfolioVaults_1) {
|
|
75
|
-
return __awaiter(this, arguments, void 0, function (database, portfolioVaults, vaultIndex, startTsMs, limit) {
|
|
76
|
-
var events, groupEventMap, showMap;
|
|
77
|
-
var _this = this;
|
|
78
|
-
if (vaultIndex === void 0) { vaultIndex = undefined; }
|
|
79
|
-
if (startTsMs === void 0) { startTsMs = "0"; }
|
|
80
|
-
if (limit === void 0) { limit = 1000; }
|
|
81
|
-
return __generator(this, function (_a) {
|
|
82
|
-
switch (_a.label) {
|
|
83
|
-
case 0: return [4 /*yield*/, getDb(database, ["NewAuction", "Delivery", "Settle"], vaultIndex, startTsMs, limit)];
|
|
84
|
-
case 1:
|
|
85
|
-
events = _a.sent();
|
|
86
|
-
return [4 /*yield*/, events.reduce(function (promise, event) { return __awaiter(_this, void 0, void 0, function () {
|
|
87
|
-
var map, index, round, round_event, round_events, round_events, round_events;
|
|
88
|
-
return __generator(this, function (_a) {
|
|
89
|
-
switch (_a.label) {
|
|
90
|
-
case 0: return [4 /*yield*/, promise];
|
|
91
|
-
case 1:
|
|
92
|
-
map = _a.sent();
|
|
93
|
-
index = event.index.toString();
|
|
94
|
-
round = event.round.toString();
|
|
95
|
-
round_event = {
|
|
96
|
-
newAuctionEvent: undefined,
|
|
97
|
-
deliveryEvent: undefined,
|
|
98
|
-
settleEvent: undefined,
|
|
99
|
-
};
|
|
100
|
-
if (map.has(index)) {
|
|
101
|
-
round_events = map.get(index);
|
|
102
|
-
if (round_events.has(round)) {
|
|
103
|
-
round_event = round_events.get(round);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
switch (event.function) {
|
|
107
|
-
case "NewAuction":
|
|
108
|
-
round_event.newAuctionEvent = event;
|
|
109
|
-
round_event.newAuctionEvent.vault_config = {
|
|
110
|
-
payoffConfigs: event.vault_config.payoff_configs.map(function (x) {
|
|
111
|
-
return ({
|
|
112
|
-
strikePct: x.strike_pct,
|
|
113
|
-
weight: x.weight,
|
|
114
|
-
isBuyer: x.is_buyer,
|
|
115
|
-
strike: x.strike,
|
|
116
|
-
});
|
|
117
|
-
}),
|
|
118
|
-
strikeIncrement: event.vault_config.strike_increment,
|
|
119
|
-
decaySpeed: event.vault_config.decay_speed,
|
|
120
|
-
initialPrice: event.vault_config.initial_price,
|
|
121
|
-
finalPrice: event.vault_config.final_price,
|
|
122
|
-
auctionDurationInMs: event.vault_config.auction_duration_in_ms,
|
|
123
|
-
};
|
|
124
|
-
break;
|
|
125
|
-
case "Delivery":
|
|
126
|
-
round_event.deliveryEvent = event;
|
|
127
|
-
break;
|
|
128
|
-
case "Settle":
|
|
129
|
-
round_event.settleEvent = event;
|
|
130
|
-
break;
|
|
131
|
-
}
|
|
132
|
-
if (map.get(index)) {
|
|
133
|
-
round_events = map.get(index);
|
|
134
|
-
round_events.set(round, round_event);
|
|
135
|
-
map.set(index, round_events);
|
|
136
|
-
}
|
|
137
|
-
else {
|
|
138
|
-
round_events = new Map();
|
|
139
|
-
round_events.set(round, round_event);
|
|
140
|
-
map.set(index, round_events);
|
|
141
|
-
}
|
|
142
|
-
return [2 /*return*/, map];
|
|
143
|
-
}
|
|
144
|
-
});
|
|
145
|
-
}); }, Promise.resolve(new Map()))];
|
|
146
|
-
case 2:
|
|
147
|
-
groupEventMap = _a.sent();
|
|
148
|
-
showMap = new Map();
|
|
149
|
-
return [4 /*yield*/, groupEventMap.forEach(function (innerMap, outerKey) { return __awaiter(_this, void 0, void 0, function () {
|
|
150
|
-
var newInnerMap_1;
|
|
151
|
-
var _this = this;
|
|
152
|
-
return __generator(this, function (_a) {
|
|
153
|
-
if (portfolioVaults[outerKey]) {
|
|
154
|
-
newInnerMap_1 = new Map();
|
|
155
|
-
innerMap.forEach(function (groupEvent, innerKey) { return __awaiter(_this, void 0, void 0, function () {
|
|
156
|
-
var show;
|
|
157
|
-
return __generator(this, function (_a) {
|
|
158
|
-
switch (_a.label) {
|
|
159
|
-
case 0: return [4 /*yield*/, groupEventToShow(groupEvent, portfolioVaults[outerKey])];
|
|
160
|
-
case 1:
|
|
161
|
-
show = _a.sent();
|
|
162
|
-
// console.log(show);
|
|
163
|
-
newInnerMap_1.set(innerKey, show);
|
|
164
|
-
return [2 /*return*/];
|
|
165
|
-
}
|
|
166
|
-
});
|
|
167
|
-
}); });
|
|
168
|
-
showMap.set(outerKey, newInnerMap_1);
|
|
169
|
-
}
|
|
170
|
-
return [2 /*return*/];
|
|
171
|
-
});
|
|
172
|
-
}); })];
|
|
173
|
-
case 3:
|
|
174
|
-
_a.sent();
|
|
175
|
-
// console.log(showMap);
|
|
176
|
-
return [2 /*return*/, showMap];
|
|
177
|
-
}
|
|
178
|
-
});
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
exports.getShowMap = getShowMap;
|
|
182
|
-
function groupEventToShow(groupEvent, portfolioVault) {
|
|
183
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
184
|
-
var PaidToDepositors, portfolio_payoff, PaidToBidders, exp, ActivationTsMs, SettlementTsMs, result;
|
|
185
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
186
|
-
return __generator(this, function (_r) {
|
|
187
|
-
PaidToDepositors = Number((_a = groupEvent.deliveryEvent) === null || _a === void 0 ? void 0 : _a.premium_value) / Math.pow(10, Number(portfolioVault.config.bTokenDecimal));
|
|
188
|
-
portfolio_payoff = ((_b = groupEvent.settleEvent) === null || _b === void 0 ? void 0 : _b.portfolio_payoff_is_neg)
|
|
189
|
-
? Number(-((_c = groupEvent.settleEvent) === null || _c === void 0 ? void 0 : _c.portfolio_payoff))
|
|
190
|
-
: Number((_d = groupEvent.settleEvent) === null || _d === void 0 ? void 0 : _d.portfolio_payoff);
|
|
191
|
-
PaidToBidders = portfolio_payoff / Math.pow(10, Number(portfolioVault.config.oTokenDecimal));
|
|
192
|
-
switch (portfolioVault.config.period) {
|
|
193
|
-
case 0:
|
|
194
|
-
exp = 365;
|
|
195
|
-
break;
|
|
196
|
-
case 1:
|
|
197
|
-
exp = 52;
|
|
198
|
-
break;
|
|
199
|
-
case 2:
|
|
200
|
-
exp = 12;
|
|
201
|
-
break;
|
|
202
|
-
}
|
|
203
|
-
ActivationTsMs = Number((_e = groupEvent.newAuctionEvent) === null || _e === void 0 ? void 0 : _e.timestamp_ms);
|
|
204
|
-
SettlementTsMs = Number((_f = groupEvent.settleEvent) === null || _f === void 0 ? void 0 : _f.timestamp_ms);
|
|
205
|
-
result = {
|
|
206
|
-
// newAuctionEvent
|
|
207
|
-
NewAuctionTx: (_g = groupEvent.newAuctionEvent) === null || _g === void 0 ? void 0 : _g.tx_digest,
|
|
208
|
-
ActivationDate: new Date(ActivationTsMs - (ActivationTsMs % 3600000)),
|
|
209
|
-
StrikePrice: (_h = groupEvent.newAuctionEvent) === null || _h === void 0 ? void 0 : _h.vault_config.payoffConfigs.map(function (payoffConfig) { return Number(payoffConfig.strike) / Math.pow(10, 8); }),
|
|
210
|
-
// deliveryEvent
|
|
211
|
-
DeliveryTx: (_j = groupEvent.deliveryEvent) === null || _j === void 0 ? void 0 : _j.tx_digest,
|
|
212
|
-
ProjectedAPY: Math.pow((1 + (1.01 * Number((_k = groupEvent.deliveryEvent) === null || _k === void 0 ? void 0 : _k.delivery_price)) / Math.pow(10, Number(portfolioVault.config.bTokenDecimal))), exp) - 1,
|
|
213
|
-
Filled: Number((_l = groupEvent.deliveryEvent) === null || _l === void 0 ? void 0 : _l.delivery_size) / Number((_m = groupEvent.deliveryEvent) === null || _m === void 0 ? void 0 : _m.max_size),
|
|
214
|
-
PaidToDepositors: PaidToDepositors,
|
|
215
|
-
// settleEvent
|
|
216
|
-
SettleTx: (_o = groupEvent.settleEvent) === null || _o === void 0 ? void 0 : _o.tx_digest,
|
|
217
|
-
SettlementTime: new Date(SettlementTsMs - (SettlementTsMs % 3600000)),
|
|
218
|
-
SettlePrice: Number((_p = groupEvent.settleEvent) === null || _p === void 0 ? void 0 : _p.oracle_price) / Math.pow(10, 8),
|
|
219
|
-
Return: Number((_q = groupEvent.settleEvent) === null || _q === void 0 ? void 0 : _q.share_price) / Math.pow(10, 8) - 1,
|
|
220
|
-
PaidToBidders: PaidToBidders,
|
|
221
|
-
EarnedByDepositors: PaidToDepositors - PaidToBidders,
|
|
222
|
-
};
|
|
223
|
-
return [2 /*return*/, result];
|
|
224
|
-
});
|
|
225
|
-
});
|
|
226
|
-
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { SuiClient } from "@mysten/sui.js/client";
|
|
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
|
-
auctionDelayTsMs: string;
|
|
37
|
-
dTokenDecimal: string;
|
|
38
|
-
bTokenDecimal: string;
|
|
39
|
-
oTokenDecimal: string;
|
|
40
|
-
lotSize: string;
|
|
41
|
-
capacity: string;
|
|
42
|
-
leverage: string;
|
|
43
|
-
hasNext: boolean;
|
|
44
|
-
activeVaultConfig: VaultConfig;
|
|
45
|
-
warmupVaultConfig: VaultConfig;
|
|
46
|
-
upcomingVaultConfig: VaultConfig;
|
|
47
|
-
}
|
|
48
|
-
export interface VaultConfig {
|
|
49
|
-
payoffConfigs: PayoffConfig[];
|
|
50
|
-
strikeIncrement: string;
|
|
51
|
-
decaySpeed: string;
|
|
52
|
-
initialPrice: string;
|
|
53
|
-
finalPrice: string;
|
|
54
|
-
auctionDurationInMs: string;
|
|
55
|
-
}
|
|
56
|
-
export interface PayoffConfig {
|
|
57
|
-
strikePct: string;
|
|
58
|
-
weight: string;
|
|
59
|
-
isBuyer: boolean;
|
|
60
|
-
strike?: string;
|
|
61
|
-
}
|
|
62
|
-
export declare function getPortfolioVaults(provider: SuiClient, registry: string, deposit_vault_registry: string, bid_vault_registry: string, index?: string): Promise<Map<string, PortfolioVault>>;
|
|
63
|
-
export declare function getPortfolioVaultAuctionDelayTsMs(provider: SuiClient, portfolio_vault: PortfolioVault): Promise<string>;
|
|
@@ -1,284 +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.getPortfolioVaultAuctionDelayTsMs = exports.getPortfolioVaults = void 0;
|
|
40
|
-
var vault_1 = require("../typus-framework/vault");
|
|
41
|
-
var dutch_1 = require("../typus-framework/dutch");
|
|
42
|
-
var token_1 = require("../token");
|
|
43
|
-
function getPortfolioVaults(provider, registry, deposit_vault_registry, bid_vault_registry, index) {
|
|
44
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
45
|
-
var portfolioVaultIds, portfolioVaults, depositVaultIds, bidVaultIds;
|
|
46
|
-
var _this = this;
|
|
47
|
-
return __generator(this, function (_a) {
|
|
48
|
-
switch (_a.label) {
|
|
49
|
-
case 0:
|
|
50
|
-
console.warn = function () { };
|
|
51
|
-
return [4 /*yield*/, provider.getDynamicFields({ parentId: registry })];
|
|
52
|
-
case 1:
|
|
53
|
-
portfolioVaultIds = (_a.sent()).data
|
|
54
|
-
.filter(function (x) { return (index ? x.name.value == index : true); })
|
|
55
|
-
.map(function (x) { return x.objectId; });
|
|
56
|
-
return [4 /*yield*/, provider.multiGetObjects({
|
|
57
|
-
ids: portfolioVaultIds,
|
|
58
|
-
options: { showContent: true },
|
|
59
|
-
})];
|
|
60
|
-
case 2: return [4 /*yield*/, (_a.sent())
|
|
61
|
-
.filter(function (portfolioVault) { return portfolioVault.error == undefined; })
|
|
62
|
-
// @ts-ignore
|
|
63
|
-
.filter(function (portfolioVault) { return portfolioVault.data.content.type.includes("PortfolioVault"); })
|
|
64
|
-
.reduce(function (promise, portfolioVault) { return __awaiter(_this, void 0, void 0, function () {
|
|
65
|
-
var map, vaultId, auctionDelayTsMs, typeArgs, assets, deliveryInfo, info, config, auction, authority;
|
|
66
|
-
return __generator(this, function (_a) {
|
|
67
|
-
switch (_a.label) {
|
|
68
|
-
case 0: return [4 /*yield*/, promise];
|
|
69
|
-
case 1:
|
|
70
|
-
map = _a.sent();
|
|
71
|
-
vaultId = portfolioVault.data.content.fields.id.id;
|
|
72
|
-
auctionDelayTsMs = "0";
|
|
73
|
-
typeArgs = new RegExp(".*<(.*), (.*), (.*)>").exec(portfolioVault.data.content.type).slice(1, 4);
|
|
74
|
-
assets = (0, token_1.typeArgsToAssets)(typeArgs);
|
|
75
|
-
deliveryInfo =
|
|
76
|
-
// @ts-ignore
|
|
77
|
-
portfolioVault.data.content.fields.info.fields.delivery_info
|
|
78
|
-
? {
|
|
79
|
-
// @ts-ignore
|
|
80
|
-
round: portfolioVault.data.content.fields.info.fields.delivery_info.fields.round,
|
|
81
|
-
// @ts-ignore
|
|
82
|
-
price: portfolioVault.data.content.fields.info.fields.delivery_info.fields.price,
|
|
83
|
-
// @ts-ignore
|
|
84
|
-
size: portfolioVault.data.content.fields.info.fields.delivery_info.fields.size,
|
|
85
|
-
// @ts-ignore
|
|
86
|
-
premium: portfolioVault.data.content.fields.info.fields.delivery_info.fields.premium,
|
|
87
|
-
// @ts-ignore
|
|
88
|
-
tsMs: portfolioVault.data.content.fields.info.fields.delivery_info.fields.ts_ms,
|
|
89
|
-
}
|
|
90
|
-
: undefined;
|
|
91
|
-
info = {
|
|
92
|
-
// @ts-ignore
|
|
93
|
-
index: portfolioVault.data.content.fields.info.fields.index,
|
|
94
|
-
// @ts-ignore
|
|
95
|
-
creator: portfolioVault.data.content.fields.info.fields.creator,
|
|
96
|
-
// @ts-ignore
|
|
97
|
-
createTsMs: portfolioVault.data.content.fields.info.fields.create_ts_ms,
|
|
98
|
-
// @ts-ignore
|
|
99
|
-
round: portfolioVault.data.content.fields.info.fields.round,
|
|
100
|
-
deliveryInfo: deliveryInfo,
|
|
101
|
-
};
|
|
102
|
-
config = {
|
|
103
|
-
// @ts-ignore
|
|
104
|
-
optionType: portfolioVault.data.content.fields.config.fields.option_type,
|
|
105
|
-
// @ts-ignore
|
|
106
|
-
period: portfolioVault.data.content.fields.config.fields.period,
|
|
107
|
-
// @ts-ignore
|
|
108
|
-
activationTsMs: portfolioVault.data.content.fields.config.fields.activation_ts_ms,
|
|
109
|
-
// @ts-ignore
|
|
110
|
-
expirationTsMs: portfolioVault.data.content.fields.config.fields.expiration_ts_ms,
|
|
111
|
-
auctionDelayTsMs: auctionDelayTsMs,
|
|
112
|
-
// @ts-ignore
|
|
113
|
-
dTokenDecimal: portfolioVault.data.content.fields.config.fields.d_token_decimal,
|
|
114
|
-
// @ts-ignore
|
|
115
|
-
bTokenDecimal: portfolioVault.data.content.fields.config.fields.b_token_decimal,
|
|
116
|
-
// @ts-ignore
|
|
117
|
-
oTokenDecimal: portfolioVault.data.content.fields.config.fields.o_token_decimal,
|
|
118
|
-
// @ts-ignore
|
|
119
|
-
lotSize: portfolioVault.data.content.fields.config.fields.lot_size,
|
|
120
|
-
// @ts-ignore
|
|
121
|
-
capacity: portfolioVault.data.content.fields.config.fields.capacity,
|
|
122
|
-
// @ts-ignore
|
|
123
|
-
leverage: portfolioVault.data.content.fields.config.fields.leverage,
|
|
124
|
-
// @ts-ignore
|
|
125
|
-
hasNext: portfolioVault.data.content.fields.config.fields.has_next,
|
|
126
|
-
activeVaultConfig: {
|
|
127
|
-
// @ts-ignore
|
|
128
|
-
payoffConfigs: portfolioVault.data.content.fields.config.fields.active_vault_config.fields.payoff_configs.map(function (x) {
|
|
129
|
-
return ({
|
|
130
|
-
strikePct: x.fields.strike_pct,
|
|
131
|
-
weight: x.fields.weight,
|
|
132
|
-
isBuyer: x.fields.is_buyer,
|
|
133
|
-
strike: x.fields.strike,
|
|
134
|
-
});
|
|
135
|
-
}),
|
|
136
|
-
// @ts-ignore
|
|
137
|
-
strikeIncrement: portfolioVault.data.content.fields.config.fields.active_vault_config.fields.strike_increment,
|
|
138
|
-
// @ts-ignore
|
|
139
|
-
decaySpeed: portfolioVault.data.content.fields.config.fields.active_vault_config.fields.decay_speed,
|
|
140
|
-
// @ts-ignore
|
|
141
|
-
initialPrice: portfolioVault.data.content.fields.config.fields.active_vault_config.fields.initial_price,
|
|
142
|
-
// @ts-ignore
|
|
143
|
-
finalPrice: portfolioVault.data.content.fields.config.fields.active_vault_config.fields.final_price,
|
|
144
|
-
// @ts-ignore
|
|
145
|
-
auctionDurationInMs: portfolioVault.data.content.fields.config.fields.active_vault_config.fields.auction_duration_in_ms,
|
|
146
|
-
},
|
|
147
|
-
warmupVaultConfig: {
|
|
148
|
-
// @ts-ignore
|
|
149
|
-
payoffConfigs: portfolioVault.data.content.fields.config.fields.warmup_vault_config.fields.payoff_configs.map(function (x) {
|
|
150
|
-
return ({
|
|
151
|
-
strikePct: x.fields.strike_pct,
|
|
152
|
-
weight: x.fields.weight,
|
|
153
|
-
isBuyer: x.fields.is_buyer,
|
|
154
|
-
strike: x.fields.strike,
|
|
155
|
-
});
|
|
156
|
-
}),
|
|
157
|
-
// @ts-ignore
|
|
158
|
-
strikeIncrement: portfolioVault.data.content.fields.config.fields.warmup_vault_config.fields.strike_increment,
|
|
159
|
-
// @ts-ignore
|
|
160
|
-
decaySpeed: portfolioVault.data.content.fields.config.fields.warmup_vault_config.fields.decay_speed,
|
|
161
|
-
// @ts-ignore
|
|
162
|
-
initialPrice: portfolioVault.data.content.fields.config.fields.warmup_vault_config.fields.initial_price,
|
|
163
|
-
// @ts-ignore
|
|
164
|
-
finalPrice: portfolioVault.data.content.fields.config.fields.warmup_vault_config.fields.final_price,
|
|
165
|
-
// @ts-ignore
|
|
166
|
-
auctionDurationInMs: portfolioVault.data.content.fields.config.fields.warmup_vault_config.fields.auction_duration_in_ms,
|
|
167
|
-
},
|
|
168
|
-
upcomingVaultConfig: {
|
|
169
|
-
// @ts-ignore
|
|
170
|
-
payoffConfigs: portfolioVault.data.content.fields.config.fields.upcoming_vault_config.fields.payoff_configs.map(function (x) {
|
|
171
|
-
return ({
|
|
172
|
-
strikePct: x.fields.strike_pct,
|
|
173
|
-
weight: x.fields.weight,
|
|
174
|
-
isBuyer: x.fields.is_buyer,
|
|
175
|
-
strike: x.fields.strike,
|
|
176
|
-
});
|
|
177
|
-
}),
|
|
178
|
-
// @ts-ignore
|
|
179
|
-
strikeIncrement: portfolioVault.data.content.fields.config.fields.upcoming_vault_config.fields.strike_increment,
|
|
180
|
-
// @ts-ignore
|
|
181
|
-
decaySpeed: portfolioVault.data.content.fields.config.fields.upcoming_vault_config.fields.decay_speed,
|
|
182
|
-
// @ts-ignore
|
|
183
|
-
initialPrice: portfolioVault.data.content.fields.config.fields.upcoming_vault_config.fields.initial_price,
|
|
184
|
-
// @ts-ignore
|
|
185
|
-
finalPrice: portfolioVault.data.content.fields.config.fields.upcoming_vault_config.fields.final_price,
|
|
186
|
-
auctionDurationInMs:
|
|
187
|
-
// @ts-ignore
|
|
188
|
-
portfolioVault.data.content.fields.config.fields.upcoming_vault_config.fields.auction_duration_in_ms,
|
|
189
|
-
},
|
|
190
|
-
};
|
|
191
|
-
auction = portfolioVault.data.content.fields.auction ? (0, dutch_1.parseAuction)(portfolioVault.data.content.fields.auction) : undefined;
|
|
192
|
-
authority = portfolioVault.data.content.fields.authority.fields.whitelist.fields.id.id;
|
|
193
|
-
map[info.index] = {
|
|
194
|
-
vaultId: vaultId,
|
|
195
|
-
typeArgs: typeArgs,
|
|
196
|
-
assets: assets,
|
|
197
|
-
info: info,
|
|
198
|
-
config: config,
|
|
199
|
-
depositVault: {},
|
|
200
|
-
bidVault: {},
|
|
201
|
-
auction: auction,
|
|
202
|
-
authority: authority,
|
|
203
|
-
};
|
|
204
|
-
return [2 /*return*/, map];
|
|
205
|
-
}
|
|
206
|
-
});
|
|
207
|
-
}); }, Promise.resolve({}))];
|
|
208
|
-
case 3:
|
|
209
|
-
portfolioVaults = _a.sent();
|
|
210
|
-
return [4 /*yield*/, provider.getDynamicFields({ parentId: deposit_vault_registry })];
|
|
211
|
-
case 4:
|
|
212
|
-
depositVaultIds = (_a.sent()).data
|
|
213
|
-
.filter(function (x) { return (index ? x.name.value == index : true); })
|
|
214
|
-
.map(function (x) { return x.objectId; });
|
|
215
|
-
return [4 /*yield*/, provider.multiGetObjects({
|
|
216
|
-
ids: depositVaultIds,
|
|
217
|
-
options: { showContent: true },
|
|
218
|
-
})];
|
|
219
|
-
case 5:
|
|
220
|
-
(_a.sent())
|
|
221
|
-
.filter(function (depositVault) { return depositVault.error == undefined; })
|
|
222
|
-
.forEach(function (depositVault) {
|
|
223
|
-
// @ts-ignore
|
|
224
|
-
var index = depositVault.data.content.fields.name;
|
|
225
|
-
// @ts-ignore
|
|
226
|
-
var vault = (0, vault_1.parseDepositVault)(depositVault.data.content.fields.value);
|
|
227
|
-
var tvl = BigInt(vault.activeSubVault.balance) + BigInt(vault.warmupSubVault.balance);
|
|
228
|
-
portfolioVaults[index].tokenTvl = tvl;
|
|
229
|
-
portfolioVaults[index].depositVault = vault;
|
|
230
|
-
});
|
|
231
|
-
return [4 /*yield*/, provider.getDynamicFields({ parentId: bid_vault_registry })];
|
|
232
|
-
case 6:
|
|
233
|
-
bidVaultIds = (_a.sent()).data
|
|
234
|
-
.filter(function (x) { return (index ? x.name.value == index : true); })
|
|
235
|
-
.map(function (x) { return x.objectId; });
|
|
236
|
-
return [4 /*yield*/, provider.multiGetObjects({
|
|
237
|
-
ids: bidVaultIds,
|
|
238
|
-
options: { showContent: true },
|
|
239
|
-
})];
|
|
240
|
-
case 7:
|
|
241
|
-
(_a.sent())
|
|
242
|
-
.filter(function (bidVault) { return bidVault.error == undefined; })
|
|
243
|
-
.forEach(function (bidVault) {
|
|
244
|
-
// @ts-ignore
|
|
245
|
-
portfolioVaults[bidVault.data.content.fields.name].bidVault = (0, vault_1.parseBidVault)(bidVault.data.content.fields.value);
|
|
246
|
-
});
|
|
247
|
-
// @ts-ignore
|
|
248
|
-
return [2 /*return*/, portfolioVaults];
|
|
249
|
-
}
|
|
250
|
-
});
|
|
251
|
-
});
|
|
252
|
-
}
|
|
253
|
-
exports.getPortfolioVaults = getPortfolioVaults;
|
|
254
|
-
function getPortfolioVaultAuctionDelayTsMs(provider, portfolio_vault) {
|
|
255
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
256
|
-
var auctionDelayTsMs;
|
|
257
|
-
return __generator(this, function (_a) {
|
|
258
|
-
switch (_a.label) {
|
|
259
|
-
case 0:
|
|
260
|
-
auctionDelayTsMs = "0";
|
|
261
|
-
return [4 /*yield*/, provider
|
|
262
|
-
.getDynamicFieldObject({
|
|
263
|
-
parentId: portfolio_vault.vaultId,
|
|
264
|
-
name: {
|
|
265
|
-
type: "vector<u8>",
|
|
266
|
-
value: [
|
|
267
|
-
97, 117, 99, 116, 105, 111, 110, 95, 115, 116, 97, 114, 116, 95, 100, 101, 108, 97, 121, 95, 116, 115, 95, 109, 115,
|
|
268
|
-
],
|
|
269
|
-
},
|
|
270
|
-
})
|
|
271
|
-
.then(function (result) {
|
|
272
|
-
if (result.error == undefined) {
|
|
273
|
-
// @ts-ignore
|
|
274
|
-
auctionDelayTsMs = result.data.content.fields.value;
|
|
275
|
-
}
|
|
276
|
-
})];
|
|
277
|
-
case 1:
|
|
278
|
-
_a.sent();
|
|
279
|
-
return [2 /*return*/, auctionDelayTsMs];
|
|
280
|
-
}
|
|
281
|
-
});
|
|
282
|
-
});
|
|
283
|
-
}
|
|
284
|
-
exports.getPortfolioVaultAuctionDelayTsMs = getPortfolioVaultAuctionDelayTsMs;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { SuiClient } from "@mysten/sui.js/client";
|
|
2
|
-
export interface Registry {
|
|
3
|
-
version: string;
|
|
4
|
-
numOfVault: string;
|
|
5
|
-
depositVaultRegistry: string;
|
|
6
|
-
bidVaultRegistry: string;
|
|
7
|
-
restrictActivationTimePeriod: {
|
|
8
|
-
fromTsMs: string;
|
|
9
|
-
toTsMs: string;
|
|
10
|
-
};
|
|
11
|
-
authority: string[];
|
|
12
|
-
}
|
|
13
|
-
export declare function getRegistry(provider: SuiClient, registry: string): Promise<Registry>;
|
|
14
|
-
export declare function getPackageVersion(provider: SuiClient, packageId: string): Promise<bigint>;
|