@typus/typus-sdk 1.4.49 → 1.4.50
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.
|
@@ -61,6 +61,18 @@ export declare const ASSET_INFO: {
|
|
|
61
61
|
product: PublicKey;
|
|
62
62
|
price: PublicKey;
|
|
63
63
|
};
|
|
64
|
+
AUSD: {
|
|
65
|
+
product: PublicKey;
|
|
66
|
+
price: PublicKey;
|
|
67
|
+
};
|
|
68
|
+
FUD: {
|
|
69
|
+
product: PublicKey;
|
|
70
|
+
price: PublicKey;
|
|
71
|
+
};
|
|
72
|
+
USDY: {
|
|
73
|
+
product: PublicKey;
|
|
74
|
+
price: PublicKey;
|
|
75
|
+
};
|
|
64
76
|
};
|
|
65
77
|
export declare const tokenOrder: {
|
|
66
78
|
[key: string]: number;
|
|
@@ -157,6 +157,18 @@ exports.ASSET_INFO = {
|
|
|
157
157
|
product: new web3_js_1.PublicKey("9L4zWUnRWEqHT9fvH5WkmQgXf7qrr97SGV4pofTSdK5k"),
|
|
158
158
|
price: new web3_js_1.PublicKey("6vWPEigSDaAi6m6HuX24aK4fJGJxvQZ8TLQKADC65S2S"),
|
|
159
159
|
},
|
|
160
|
+
AUSD: {
|
|
161
|
+
product: new web3_js_1.PublicKey("GHXtvZLRq3WGm7DWUke5UdB8P6Jb4MuSwWjd72gGFPc8"),
|
|
162
|
+
price: new web3_js_1.PublicKey("FeHsLbpPsJ7JTBPGKqhBTzvNuX5bjrm4Q6HdgXWgKW8Z"),
|
|
163
|
+
},
|
|
164
|
+
FUD: {
|
|
165
|
+
product: new web3_js_1.PublicKey("2fcvX3is1N5vy17xeqi2x5t7ShFKPaBx91UTH73DvTH3"),
|
|
166
|
+
price: new web3_js_1.PublicKey("89mKNz2WRvoPXy1mbRdaptLPYHsaYBpqmh5oxk2xD4Da"),
|
|
167
|
+
},
|
|
168
|
+
USDY: {
|
|
169
|
+
product: new web3_js_1.PublicKey("555ugWQAae89KU9t9SBWAZTHZtQNkQ18XumbzgxDXQmZ"),
|
|
170
|
+
price: new web3_js_1.PublicKey("GKMnwKMJS97DZHQS9mBquF15cEbgNKHvoayz8uamBp1T"),
|
|
171
|
+
},
|
|
160
172
|
};
|
|
161
173
|
exports.tokenOrder = {
|
|
162
174
|
// Basically it's a to z but put SUI at first
|
|
@@ -256,58 +268,23 @@ var parsePythOracleData = function (data, decimals) {
|
|
|
256
268
|
};
|
|
257
269
|
exports.parsePythOracleData = parsePythOracleData;
|
|
258
270
|
var fetchPrices = function (provider, config) { return __awaiter(void 0, void 0, void 0, function () {
|
|
259
|
-
var
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
case 0: return [4 /*yield*/, provider.multiGetObjects({
|
|
264
|
-
ids: Object.values(config.oracle),
|
|
265
|
-
options: { showContent: true },
|
|
266
|
-
})];
|
|
267
|
-
case 1:
|
|
268
|
-
coinObjects = _c.sent();
|
|
271
|
+
var oracleDecimal, PYTHNET_CLUSTER_NAME, connection, pythPublicKey, pythClient, priceData, prices, mblub;
|
|
272
|
+
return __generator(this, function (_a) {
|
|
273
|
+
switch (_a.label) {
|
|
274
|
+
case 0:
|
|
269
275
|
oracleDecimal = __assign({}, DefaultOracleDecimal);
|
|
270
|
-
coinObjects.forEach(function (c) {
|
|
271
|
-
var _a, _b;
|
|
272
|
-
// @ts-ignore
|
|
273
|
-
oracleDecimal[(_a = c.data) === null || _a === void 0 ? void 0 : _a.content.fields.base_token] =
|
|
274
|
-
// @ts-ignore
|
|
275
|
-
(_b = c.data) === null || _b === void 0 ? void 0 : _b.content.fields.decimal;
|
|
276
|
-
});
|
|
277
276
|
PYTHNET_CLUSTER_NAME = "pythnet";
|
|
278
277
|
connection = new web3_js_1.Connection((0, client_1.getPythClusterApiUrl)(PYTHNET_CLUSTER_NAME));
|
|
279
278
|
pythPublicKey = (0, client_1.getPythProgramKeyForCluster)(PYTHNET_CLUSTER_NAME);
|
|
280
279
|
pythClient = new client_1.PythHttpClient(connection, pythPublicKey);
|
|
281
280
|
return [4 /*yield*/, pythClient.getAssetPricesFromAccounts(Object.values(exports.ASSET_INFO).map(function (a) { return a.price; }))];
|
|
282
|
-
case
|
|
283
|
-
priceData =
|
|
281
|
+
case 1:
|
|
282
|
+
priceData = _a.sent();
|
|
284
283
|
prices = (0, exports.parsePythOracleData)(priceData, oracleDecimal);
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
fudusd = suifud == "0" ? (0, bignumber_js_1.default)(0) : suiusd.div(suifud);
|
|
290
|
-
return [4 /*yield*/, (0, utils_1.getLatestPrice)("SUIAFSUI")];
|
|
291
|
-
case 4:
|
|
292
|
-
suiafsui = _c.sent();
|
|
293
|
-
afsuiusd = suiafsui == "0" ? (0, bignumber_js_1.default)(0) : suiusd.div(suiafsui);
|
|
294
|
-
return [4 /*yield*/, (0, utils_1.getLatestPrice)("SUINAVX")];
|
|
295
|
-
case 5:
|
|
296
|
-
suinavx = _c.sent();
|
|
297
|
-
navxusd = suiusd.div(suinavx);
|
|
298
|
-
return [4 /*yield*/, (0, utils_1.getLatestPrice)("SUIBUCK")];
|
|
299
|
-
case 6:
|
|
300
|
-
suibuck = _c.sent();
|
|
301
|
-
buckusd = (0, bignumber_js_1.default)(suibuck).lte(0) ? "0" : suiusd.div(suibuck);
|
|
302
|
-
return [4 /*yield*/, (0, utils_1.getLatestPrice)("USDYUSDC")];
|
|
303
|
-
case 7:
|
|
304
|
-
usdyusdc = _c.sent();
|
|
305
|
-
usdyusdcWithDecimal = (0, bignumber_js_1.default)(usdyusdc).multipliedBy((0, bignumber_js_1.default)(10).pow(8));
|
|
306
|
-
return [4 /*yield*/, (0, utils_1.getLatestPrice)("SCASUI")];
|
|
307
|
-
case 8:
|
|
308
|
-
scasui = _c.sent();
|
|
309
|
-
scausd = suiusd.eq(0) ? (0, bignumber_js_1.default)(0) : (0, bignumber_js_1.default)(scasui).multipliedBy(suiusd);
|
|
310
|
-
return [2 /*return*/, __assign({ fud: { price: fudusd.toString(), decimal: "8", quote: "usd" }, mfud: { price: fudusd.multipliedBy(1000000).toString(), decimal: "8", quote: "usd" }, afsui: { price: afsuiusd.toString(), decimal: "8", quote: "usd" }, navx: { price: navxusd.toString(), decimal: "8", quote: "usd" }, buck: { price: buckusd.toString(), decimal: "8", quote: "usd" }, usdy: { price: usdyusdcWithDecimal.toString(), decimal: "8", quote: "usd" }, sca: { price: scausd.toString(), decimal: "8", quote: "usd" } }, prices)];
|
|
284
|
+
return [4 /*yield*/, (0, utils_1.getLatestPrice)("MBLUBUSDC")];
|
|
285
|
+
case 2:
|
|
286
|
+
mblub = _a.sent();
|
|
287
|
+
return [2 /*return*/, __assign({ mblub: { price: mblub.toString(), decimal: "8", quote: "usd" } }, prices)];
|
|
311
288
|
}
|
|
312
289
|
});
|
|
313
290
|
}); };
|
|
@@ -403,3 +403,33 @@ function parseBidEvents(datas, end_ts_ms) {
|
|
|
403
403
|
});
|
|
404
404
|
});
|
|
405
405
|
}
|
|
406
|
+
// SELECT
|
|
407
|
+
// Settle.index as Index,
|
|
408
|
+
// Settle.round as Round,
|
|
409
|
+
// NewAuction.start_ts_ms as ActivationDate,
|
|
410
|
+
// COALESCE(NULLIF(UpdateStrike.strikes, ''), NewAuction.strikes) AS Strikes, -- 如果 UpdateStrike.strikes 是空字符串,就使用 NewAuction.strikes
|
|
411
|
+
// Settle.oracle_price as SettlePrice,
|
|
412
|
+
// -- Settle.share_price as share_price,
|
|
413
|
+
// Delivery.max_size as TotalAuctioned,
|
|
414
|
+
// SafuOtc.delivery_size as OtcSize,
|
|
415
|
+
// Delivery.delivery_size as DeliverySize,
|
|
416
|
+
// ((SafuOtc.delivery_size + Delivery.delivery_size) / TotalAuctioned) as Filled,
|
|
417
|
+
// Delivery.delivery_price as DeliveryPrice,
|
|
418
|
+
// SafuOtc.delivery_price as OtcPrice,
|
|
419
|
+
// Delivery.bidder_bid_value as BidderPremium,
|
|
420
|
+
// Delivery.incentive_bid_value as IncentivePremium,
|
|
421
|
+
// SafuOtc.bidder_bid_value as OtcPremium,
|
|
422
|
+
// (Delivery.bidder_bid_value + Delivery.incentive_bid_value + SafuOtc.bidder_bid_value) AS Premium, -- 三個加在一起的 Premium
|
|
423
|
+
// Delivery.depositor_incentive_value as BpIncentive, -- SUI or SCA
|
|
424
|
+
// Delivery.fixed_incentive_amount as FiexedIncentive, -- SUI
|
|
425
|
+
// (Settle.settle_balance - Settle.settled_balance) as OptionProfit,
|
|
426
|
+
// Settle.d_token as d_token,
|
|
427
|
+
// Delivery.b_token as b_token,
|
|
428
|
+
// Delivery.o_token as o_token
|
|
429
|
+
// FROM Settle
|
|
430
|
+
// JOIN NewAuction ON Settle.index = NewAuction.index AND Settle.round = NewAuction.round
|
|
431
|
+
// LEFT JOIN UpdateStrike ON Settle.index = UpdateStrike.index AND Settle.round = UpdateStrike.round
|
|
432
|
+
// JOIN Delivery ON Settle.index = Delivery.index AND Settle.round = Delivery.round
|
|
433
|
+
// LEFT JOIN SafuOtc ON Settle.index = SafuOtc.index AND Settle.round = SafuOtc.round
|
|
434
|
+
// WHERE Settle.timestamp >= 1725170000
|
|
435
|
+
// ORDER BY Index ASC;
|
|
@@ -18,7 +18,6 @@ export interface Package {
|
|
|
18
18
|
oracle: string;
|
|
19
19
|
perp: string;
|
|
20
20
|
safu: string;
|
|
21
|
-
token: string;
|
|
22
21
|
typus: string;
|
|
23
22
|
}
|
|
24
23
|
export interface Version {
|
|
@@ -86,6 +85,8 @@ export interface Oracle {
|
|
|
86
85
|
export interface Token {
|
|
87
86
|
afsui: string;
|
|
88
87
|
apt: string;
|
|
88
|
+
ausd: string;
|
|
89
|
+
blub: string;
|
|
89
90
|
btc: string;
|
|
90
91
|
buck: string;
|
|
91
92
|
cetus: string;
|
|
@@ -94,6 +95,7 @@ export interface Token {
|
|
|
94
95
|
hasui: string;
|
|
95
96
|
inj: string;
|
|
96
97
|
jup: string;
|
|
98
|
+
mblub: string;
|
|
97
99
|
mfud: string;
|
|
98
100
|
navx: string;
|
|
99
101
|
sca: string;
|
|
@@ -109,7 +111,5 @@ export interface Token {
|
|
|
109
111
|
usdt: string;
|
|
110
112
|
usdy: string;
|
|
111
113
|
vsui: string;
|
|
112
|
-
|
|
113
|
-
mblub: string;
|
|
114
|
-
ausd: string;
|
|
114
|
+
wusdc: string;
|
|
115
115
|
}
|