@typus/typus-sdk 1.0.65 → 1.0.67
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.
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getBuckUsdcPrice(): Promise<any>;
|
|
@@ -0,0 +1,61 @@
|
|
|
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.getBuckUsdcPrice = void 0;
|
|
40
|
+
var apiUrl = "https://us-central1-aqueous-freedom-378103.cloudfunctions.net/buck-price";
|
|
41
|
+
function getBuckUsdcPrice() {
|
|
42
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
43
|
+
var response, data;
|
|
44
|
+
return __generator(this, function (_a) {
|
|
45
|
+
switch (_a.label) {
|
|
46
|
+
case 0: return [4 /*yield*/, fetch(apiUrl, {
|
|
47
|
+
method: "GET",
|
|
48
|
+
})];
|
|
49
|
+
case 1:
|
|
50
|
+
response = _a.sent();
|
|
51
|
+
if (!response.ok) return [3 /*break*/, 3];
|
|
52
|
+
return [4 /*yield*/, response.json()];
|
|
53
|
+
case 2:
|
|
54
|
+
data = _a.sent();
|
|
55
|
+
return [2 /*return*/, data];
|
|
56
|
+
case 3: return [2 /*return*/];
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
exports.getBuckUsdcPrice = getBuckUsdcPrice;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PortfolioVault } from "./portfolio-vault";
|
|
2
|
-
export declare function getDb(
|
|
3
|
-
export declare function getShowMap(
|
|
2
|
+
export declare function getDb(database: string, functionNames: string[], vaultIndex: string | undefined, startTsMs: string, limit: number): Promise<any>;
|
|
3
|
+
export declare function getShowMap(database: string, portfolioVaults: Map<string, PortfolioVault>, vaultIndex?: string | undefined, startTsMs?: string, limit?: number): Promise<Map<string, Map<string, Show>>>;
|
|
4
4
|
interface Show {
|
|
5
5
|
ProjectedAPY: number;
|
|
6
6
|
ActivationDate: Date;
|
|
@@ -12,5 +12,8 @@ interface Show {
|
|
|
12
12
|
PaidToDepositors: number;
|
|
13
13
|
PaidToBidders: number;
|
|
14
14
|
EarnedByDepositors: number;
|
|
15
|
+
NewAuctionTx: string | undefined;
|
|
16
|
+
DeliveryTx: string | undefined;
|
|
17
|
+
SettleTx: string | undefined;
|
|
15
18
|
}
|
|
16
19
|
export {};
|
|
@@ -37,14 +37,20 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.getShowMap = exports.getDb = void 0;
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
var apiUrl = "https://us-central1-aqueous-freedom-378103.cloudfunctions.net/mongodb";
|
|
41
|
+
function getDb(database, functionNames, vaultIndex, startTsMs, limit) {
|
|
42
42
|
return __awaiter(this, void 0, void 0, function () {
|
|
43
43
|
var jsonData, response, data;
|
|
44
44
|
return __generator(this, function (_a) {
|
|
45
45
|
switch (_a.label) {
|
|
46
46
|
case 0:
|
|
47
|
-
jsonData = JSON.stringify({
|
|
47
|
+
jsonData = JSON.stringify({
|
|
48
|
+
database: database,
|
|
49
|
+
functionNames: functionNames,
|
|
50
|
+
vaultIndex: vaultIndex,
|
|
51
|
+
startTsMs: startTsMs,
|
|
52
|
+
limit: limit,
|
|
53
|
+
});
|
|
48
54
|
return [4 /*yield*/, fetch(apiUrl, {
|
|
49
55
|
method: "POST",
|
|
50
56
|
headers: { "Content-Type": "application/json" },
|
|
@@ -63,14 +69,16 @@ function getDb(apiUrl, functionNames, vaultIndex) {
|
|
|
63
69
|
});
|
|
64
70
|
}
|
|
65
71
|
exports.getDb = getDb;
|
|
66
|
-
function getShowMap(
|
|
72
|
+
function getShowMap(database, portfolioVaults, vaultIndex, startTsMs, limit) {
|
|
67
73
|
if (vaultIndex === void 0) { vaultIndex = undefined; }
|
|
74
|
+
if (startTsMs === void 0) { startTsMs = "0"; }
|
|
75
|
+
if (limit === void 0) { limit = 1000; }
|
|
68
76
|
return __awaiter(this, void 0, void 0, function () {
|
|
69
77
|
var events, groupEventMap, showMap;
|
|
70
78
|
var _this = this;
|
|
71
79
|
return __generator(this, function (_a) {
|
|
72
80
|
switch (_a.label) {
|
|
73
|
-
case 0: return [4 /*yield*/, getDb(
|
|
81
|
+
case 0: return [4 /*yield*/, getDb(database, ["NewAuction", "Delivery", "Settle"], vaultIndex, startTsMs, limit)];
|
|
74
82
|
case 1:
|
|
75
83
|
events = _a.sent();
|
|
76
84
|
return [4 /*yield*/, events.reduce(function (promise, event) { return __awaiter(_this, void 0, void 0, function () {
|
|
@@ -170,10 +178,10 @@ function getShowMap(apiUrl, portfolioVaults, vaultIndex) {
|
|
|
170
178
|
}
|
|
171
179
|
exports.getShowMap = getShowMap;
|
|
172
180
|
function groupEventToShow(groupEvent, portfolioVault) {
|
|
173
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
181
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
174
182
|
return __awaiter(this, void 0, void 0, function () {
|
|
175
183
|
var PaidToDepositors, portfolio_payoff, PaidToBidders, exp, result;
|
|
176
|
-
return __generator(this, function (
|
|
184
|
+
return __generator(this, function (_r) {
|
|
177
185
|
PaidToDepositors = Number((_a = groupEvent.deliveryEvent) === null || _a === void 0 ? void 0 : _a.premium_value) / Math.pow(10, Number(portfolioVault.config.bTokenDecimal));
|
|
178
186
|
portfolio_payoff = ((_b = groupEvent.settleEvent) === null || _b === void 0 ? void 0 : _b.portfolio_payoff_is_neg)
|
|
179
187
|
? Number(-((_c = groupEvent.settleEvent) === null || _c === void 0 ? void 0 : _c.portfolio_payoff))
|
|
@@ -192,16 +200,19 @@ function groupEventToShow(groupEvent, portfolioVault) {
|
|
|
192
200
|
}
|
|
193
201
|
result = {
|
|
194
202
|
// newAuctionEvent
|
|
195
|
-
|
|
196
|
-
|
|
203
|
+
NewAuctionTx: (_e = groupEvent.newAuctionEvent) === null || _e === void 0 ? void 0 : _e.tx_digest,
|
|
204
|
+
ActivationDate: new Date(Number((_f = groupEvent.newAuctionEvent) === null || _f === void 0 ? void 0 : _f.timestamp_ms)),
|
|
205
|
+
StrikePrice: (_g = groupEvent.newAuctionEvent) === null || _g === void 0 ? void 0 : _g.vault_config.payoffConfigs.map(function (payoffConfig) { return Number(payoffConfig.strike) / Math.pow(10, 8); }),
|
|
197
206
|
// deliveryEvent
|
|
198
|
-
|
|
199
|
-
|
|
207
|
+
DeliveryTx: (_h = groupEvent.deliveryEvent) === null || _h === void 0 ? void 0 : _h.tx_digest,
|
|
208
|
+
ProjectedAPY: Math.pow((1 + (1.01 * Number((_j = groupEvent.deliveryEvent) === null || _j === void 0 ? void 0 : _j.delivery_price)) / Math.pow(10, Number(portfolioVault.config.bTokenDecimal))), exp) - 1,
|
|
209
|
+
Filled: Number((_k = groupEvent.deliveryEvent) === null || _k === void 0 ? void 0 : _k.delivery_size) / Number((_l = groupEvent.deliveryEvent) === null || _l === void 0 ? void 0 : _l.max_size),
|
|
200
210
|
PaidToDepositors: PaidToDepositors,
|
|
201
211
|
// settleEvent
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
212
|
+
SettleTx: (_m = groupEvent.settleEvent) === null || _m === void 0 ? void 0 : _m.tx_digest,
|
|
213
|
+
SettlementTime: new Date(Number((_o = groupEvent.settleEvent) === null || _o === void 0 ? void 0 : _o.timestamp_ms)),
|
|
214
|
+
SettlePrice: Number((_p = groupEvent.settleEvent) === null || _p === void 0 ? void 0 : _p.oracle_price) / Math.pow(10, 8),
|
|
215
|
+
Return: Number((_q = groupEvent.settleEvent) === null || _q === void 0 ? void 0 : _q.share_price) / Math.pow(10, 8) - 1,
|
|
205
216
|
PaidToBidders: PaidToBidders,
|
|
206
217
|
EarnedByDepositors: PaidToDepositors - PaidToBidders,
|
|
207
218
|
};
|
|
@@ -91,12 +91,34 @@ function getPackageVersion(provider, packageId) {
|
|
|
91
91
|
id: packageId,
|
|
92
92
|
options: {
|
|
93
93
|
showContent: true,
|
|
94
|
+
showBcs: true,
|
|
94
95
|
},
|
|
95
96
|
})];
|
|
96
97
|
case 1:
|
|
97
98
|
packageData = _a.sent();
|
|
98
|
-
version = new RegExp("
|
|
99
|
-
|
|
99
|
+
version = new RegExp("Constants \\[[^=]+=> u64: ([^\\s][^\\s])([^\\s][^\\s])([^\\s][^\\s])([^\\s][^\\s])([^\\s][^\\s])([^\\s][^\\s])([^\\s][^\\s])([^\\s][^\\s])").exec(
|
|
100
|
+
// @ts-ignore
|
|
101
|
+
packageData.data.content.disassembled.typus_dov_single
|
|
102
|
+
// " 25: Ret}Constants [0 => u64: e803000000000000jadsfiklajsl1 => u64: 0200000000000000"
|
|
103
|
+
);
|
|
104
|
+
return [2 /*return*/, (0, tools_1.U64FromBytes)([
|
|
105
|
+
// @ts-ignore
|
|
106
|
+
parseInt(version[8], 16),
|
|
107
|
+
// @ts-ignore
|
|
108
|
+
parseInt(version[7], 16),
|
|
109
|
+
// @ts-ignore
|
|
110
|
+
parseInt(version[6], 16),
|
|
111
|
+
// @ts-ignore
|
|
112
|
+
parseInt(version[5], 16),
|
|
113
|
+
// @ts-ignore
|
|
114
|
+
parseInt(version[4], 16),
|
|
115
|
+
// @ts-ignore
|
|
116
|
+
parseInt(version[3], 16),
|
|
117
|
+
// @ts-ignore
|
|
118
|
+
parseInt(version[2], 16),
|
|
119
|
+
// @ts-ignore
|
|
120
|
+
parseInt(version[1], 16),
|
|
121
|
+
])];
|
|
100
122
|
}
|
|
101
123
|
});
|
|
102
124
|
});
|
package/package.json
CHANGED
|
@@ -2,53 +2,53 @@
|
|
|
2
2
|
"name": "@typus/typus-sdk",
|
|
3
3
|
"author": "Typus",
|
|
4
4
|
"description": "typus sdk",
|
|
5
|
-
"version": "1.0.
|
|
5
|
+
"version": "1.0.67",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@mysten/bcs": "^0.7.
|
|
8
|
-
"@mysten/sui.js": "^0.
|
|
9
|
-
"@types/node": "^
|
|
7
|
+
"@mysten/bcs": "^0.7.3",
|
|
8
|
+
"@mysten/sui.js": "^0.37.1",
|
|
9
|
+
"@types/node": "^20.4.2",
|
|
10
10
|
"bignumber.js": "^9.1.1",
|
|
11
|
-
"bs58": "^
|
|
12
|
-
"builtin-modules": "^
|
|
11
|
+
"bs58": "^5.0.0",
|
|
12
|
+
"builtin-modules": "^3.3.0",
|
|
13
13
|
"chai": "^4.3.7",
|
|
14
14
|
"decimal.js": "^10.3.1",
|
|
15
|
-
"diff": "^
|
|
16
|
-
"dotenv": "^
|
|
15
|
+
"diff": "^5.1.0",
|
|
16
|
+
"dotenv": "^16.3.1",
|
|
17
17
|
"encrypt-with-password": "^1.0.0",
|
|
18
|
-
"escape-string-regexp": "^
|
|
18
|
+
"escape-string-regexp": "^5.0.0",
|
|
19
19
|
"esprima": "^4.0.1",
|
|
20
20
|
"fetch": "^1.1.0",
|
|
21
21
|
"fs.realpath": "^1.0.0",
|
|
22
22
|
"function-bind": "^1.1.1",
|
|
23
|
-
"glob": "^
|
|
23
|
+
"glob": "^10.3.3",
|
|
24
24
|
"has": "^1.0.3",
|
|
25
|
-
"has-flag": "^
|
|
25
|
+
"has-flag": "^5.0.1",
|
|
26
26
|
"inflight": "^1.0.6",
|
|
27
27
|
"inherits": "^2.0.4",
|
|
28
|
-
"is-core-module": "^2.
|
|
28
|
+
"is-core-module": "^2.12.1",
|
|
29
29
|
"js-sha3": "^0.8.0",
|
|
30
|
-
"js-tokens": "^
|
|
31
|
-
"js-yaml": "^
|
|
30
|
+
"js-tokens": "^8.0.1",
|
|
31
|
+
"js-yaml": "^4.1.0",
|
|
32
32
|
"math-erf": "^1.0.0",
|
|
33
|
-
"minimatch": "^
|
|
33
|
+
"minimatch": "^9.0.3",
|
|
34
34
|
"minimist": "^1.2.5",
|
|
35
|
-
"mkdirp": "^0.
|
|
35
|
+
"mkdirp": "^3.0.1",
|
|
36
36
|
"mocha": "^10.1.0",
|
|
37
37
|
"moment": "^2.29.4",
|
|
38
38
|
"node-cron": "^3.0.2",
|
|
39
39
|
"once": "^1.4.0",
|
|
40
|
-
"path-is-absolute": "^
|
|
40
|
+
"path-is-absolute": "^2.0.0",
|
|
41
41
|
"path-parse": "^1.0.7",
|
|
42
42
|
"random-bigint": "^0.0.1",
|
|
43
43
|
"resolve": "^1.20.0",
|
|
44
|
-
"rxjs": "^7.
|
|
45
|
-
"semver": "^5.
|
|
44
|
+
"rxjs": "^7.8.1",
|
|
45
|
+
"semver": "^7.5.4",
|
|
46
46
|
"sprintf-js": "^1.0.3",
|
|
47
|
-
"superstruct": "^0.
|
|
48
|
-
"supports-color": "^
|
|
47
|
+
"superstruct": "^1.0.3",
|
|
48
|
+
"supports-color": "^9.4.0",
|
|
49
49
|
"ts-mocha": "^10.0.0",
|
|
50
|
-
"tslib": "^
|
|
51
|
-
"tsutils": "^
|
|
50
|
+
"tslib": "^2.6.0",
|
|
51
|
+
"tsutils": "^3.21.0",
|
|
52
52
|
"typed-rpc": "^3.0.0",
|
|
53
53
|
"wrappy": "^1.0.2",
|
|
54
54
|
"ws": "^8.11.0",
|
|
@@ -57,12 +57,12 @@
|
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@types/bs58": "^4.0.1",
|
|
59
59
|
"@types/expect": "^24.3.0",
|
|
60
|
-
"@types/mocha": "^
|
|
60
|
+
"@types/mocha": "^10.0.1",
|
|
61
61
|
"@types/rx": "^4.1.2",
|
|
62
|
-
"prettier": "^
|
|
62
|
+
"prettier": "^3.0.0",
|
|
63
63
|
"tslint": "^6.1.3",
|
|
64
64
|
"tslint-config-prettier": "^1.18.0",
|
|
65
|
-
"typescript": "^
|
|
65
|
+
"typescript": "^5.1.6"
|
|
66
66
|
},
|
|
67
67
|
"main": "lib/index.js",
|
|
68
68
|
"files": [
|