@typus/typus-sdk 1.2.82 → 1.2.84
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
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"TYPUS": "0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a"
|
|
16
16
|
},
|
|
17
17
|
"PACKAGE": {
|
|
18
|
-
"DOV_SINGLE": "
|
|
18
|
+
"DOV_SINGLE": "0x8b65b817e7d819ab810bf50eaaa521ceea39d85cd46ab58180cfe287ce6f8ef0",
|
|
19
19
|
"FRAMEWORK": "0x946d188d91cabd4fe15ef763e463a6738db1965814d3fd790085b4720cf90e28",
|
|
20
20
|
"MFUD": "0xd8f04cd2a16c19c17428c3b4c22b01dd06740423b93fb7ee88fbe2676a82849d",
|
|
21
21
|
"NFT": "0xba06aae31d9b7c9f651e783272c7e4f776fb5ae17e89d525b75a17b099f58202",
|
|
@@ -66,12 +66,12 @@
|
|
|
66
66
|
"LOCKED_VAULT": "0xe79b7ba69b750d30ac7ae171483a4064d0bb34090493fef3c844a11b05818d79"
|
|
67
67
|
},
|
|
68
68
|
"PACKAGE": {
|
|
69
|
-
"DOV_SINGLE": "
|
|
69
|
+
"DOV_SINGLE": "0xa4fe84c953785d9dcb388a860d30e3a1e46eeb9647f80c40359c192424f19938",
|
|
70
70
|
"FRAMEWORK": "0xa304e225551b619b07c06d8965462b268138b2c5774fd22ad8853ef91fbb9771",
|
|
71
71
|
"MFUD": "0x7755ff79f0f27256c73e6c197e25b407ef6d4b9bd6e1af8cdd50fef28f84712c",
|
|
72
72
|
"NFT": "0x0f5162014f18686640b8d0adefd60c3fe5b377413ec4f1e77001c67d96f8501a",
|
|
73
73
|
"ORACLE": "0x71fbc7acaf513561dabdeb846e7dd5288108e56edb0b6de8d4999c4dfce21f66",
|
|
74
|
-
"TYPUS": "
|
|
74
|
+
"TYPUS": "0x01840fac0c84618087065346acdbac28bdec4326c416fcd2dc6d2f1b7d86fe62"
|
|
75
75
|
},
|
|
76
76
|
"REGISTRY": {
|
|
77
77
|
"AIRDROP": "0xfb2fbf261f6050d100bcd026ffa0076e088506b1bec26313947239303e2a0224",
|
|
@@ -56,7 +56,7 @@ function getActivateLeaderboardTx(gasBudget, packageId, version, typusLeaderboar
|
|
|
56
56
|
tx.moveCall({
|
|
57
57
|
target: "".concat(packageId, "::leaderboard::activate_leaderboard"),
|
|
58
58
|
typeArguments: [],
|
|
59
|
-
arguments: [tx.object(version), tx.object(typusLeaderboardRegistry), tx.
|
|
59
|
+
arguments: [tx.object(version), tx.object(typusLeaderboardRegistry), tx.pure(key), tx.pure(start_ts_ms), tx.pure(end_ts_ms)],
|
|
60
60
|
});
|
|
61
61
|
tx.setGasBudget(gasBudget);
|
|
62
62
|
return [2 /*return*/, tx];
|
|
@@ -81,7 +81,7 @@ function getDeactivateLeaderboardTx(gasBudget, packageId, version, typusLeaderbo
|
|
|
81
81
|
tx.moveCall({
|
|
82
82
|
target: "".concat(packageId, "::leaderboard::deactivate_leaderboard"),
|
|
83
83
|
typeArguments: [],
|
|
84
|
-
arguments: [tx.object(version), tx.object(typusLeaderboardRegistry), tx.
|
|
84
|
+
arguments: [tx.object(version), tx.object(typusLeaderboardRegistry), tx.pure(key), tx.pure(id)],
|
|
85
85
|
});
|
|
86
86
|
tx.setGasBudget(gasBudget);
|
|
87
87
|
return [2 /*return*/, tx];
|
|
@@ -1,6 +1,58 @@
|
|
|
1
1
|
import BigNumber from "bignumber.js";
|
|
2
|
+
import { PublicKey } from "@solana/web3.js";
|
|
3
|
+
import { PriceData } from "@pythnetwork/client";
|
|
2
4
|
import { SuiClient } from "@mysten/sui.js/dist/cjs/client";
|
|
3
5
|
import { Auction, BidShare, Vault } from "../view-function";
|
|
6
|
+
export declare const ASSET_INFO: {
|
|
7
|
+
BTC: {
|
|
8
|
+
product: PublicKey;
|
|
9
|
+
price: PublicKey;
|
|
10
|
+
};
|
|
11
|
+
ETH: {
|
|
12
|
+
product: PublicKey;
|
|
13
|
+
price: PublicKey;
|
|
14
|
+
};
|
|
15
|
+
SUI: {
|
|
16
|
+
product: PublicKey;
|
|
17
|
+
price: PublicKey;
|
|
18
|
+
};
|
|
19
|
+
CETUS: {
|
|
20
|
+
product: PublicKey;
|
|
21
|
+
price: PublicKey;
|
|
22
|
+
};
|
|
23
|
+
SEI: {
|
|
24
|
+
product: PublicKey;
|
|
25
|
+
price: PublicKey;
|
|
26
|
+
};
|
|
27
|
+
USDC: {
|
|
28
|
+
product: PublicKey;
|
|
29
|
+
price: PublicKey;
|
|
30
|
+
};
|
|
31
|
+
USDT: {
|
|
32
|
+
product: PublicKey;
|
|
33
|
+
price: PublicKey;
|
|
34
|
+
};
|
|
35
|
+
TURBOS: {
|
|
36
|
+
product: PublicKey;
|
|
37
|
+
price: PublicKey;
|
|
38
|
+
};
|
|
39
|
+
APT: {
|
|
40
|
+
product: PublicKey;
|
|
41
|
+
price: PublicKey;
|
|
42
|
+
};
|
|
43
|
+
SOL: {
|
|
44
|
+
product: PublicKey;
|
|
45
|
+
price: PublicKey;
|
|
46
|
+
};
|
|
47
|
+
INJ: {
|
|
48
|
+
product: PublicKey;
|
|
49
|
+
price: PublicKey;
|
|
50
|
+
};
|
|
51
|
+
JUP: {
|
|
52
|
+
product: PublicKey;
|
|
53
|
+
price: PublicKey;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
4
56
|
export declare const tokenOrder: {
|
|
5
57
|
[key: string]: number;
|
|
6
58
|
};
|
|
@@ -43,7 +95,20 @@ export interface OrderBy {
|
|
|
43
95
|
optionTypeOrder: number;
|
|
44
96
|
periodOrder: number;
|
|
45
97
|
}
|
|
98
|
+
export interface CoinInfo {
|
|
99
|
+
price: string;
|
|
100
|
+
decimal: string;
|
|
101
|
+
quote: string;
|
|
102
|
+
}
|
|
46
103
|
export declare const IncentiveRateBp = 4;
|
|
104
|
+
export declare const parsePythOracleData: (data: PriceData[], decimals: {
|
|
105
|
+
[key: string]: string;
|
|
106
|
+
}) => {
|
|
107
|
+
[key: string]: CoinInfo;
|
|
108
|
+
};
|
|
109
|
+
export declare const fetchPrices: (provider: SuiClient, network: string) => Promise<{
|
|
110
|
+
[key: string]: CoinInfo;
|
|
111
|
+
}>;
|
|
47
112
|
export declare const calcIncentiveRate: (incentiveBp: any) => number;
|
|
48
113
|
export declare const calcDeliveryPrice: (bidShare: BidShare, vaultInfo: Vault) => BigNumber;
|
|
49
114
|
export declare const calcBreakEvenPrice: (optionType: string, period: string, strikes: string[], bToken: string, price: string, incentive: number) => number;
|
|
@@ -73,6 +138,6 @@ export declare const getUserBidReceipts: (provider: SuiClient, network: string,
|
|
|
73
138
|
* @param prices - tokens prices (usd pair on Pyth)
|
|
74
139
|
* @return User Bids.
|
|
75
140
|
*/
|
|
76
|
-
export declare const fetchUserBids: (provider: SuiClient, network: string, packageAddress: string, framworkAddress: string, originFramworkAddress: string, registryAddress: string, strategyPoolAddress: string, userAddress: string, prices
|
|
77
|
-
[key: string]:
|
|
78
|
-
}) => Promise<any>;
|
|
141
|
+
export declare const fetchUserBids: (provider: SuiClient, network: string, packageAddress: string, framworkAddress: string, originFramworkAddress: string, registryAddress: string, strategyPoolAddress: string, userAddress: string, prices?: {
|
|
142
|
+
[key: string]: CoinInfo;
|
|
143
|
+
} | undefined) => Promise<any>;
|
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
2
13
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
14
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
15
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -75,17 +86,72 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
75
86
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
76
87
|
};
|
|
77
88
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
78
|
-
exports.fetchUserBids = exports.getUserBidReceipts = exports.parseBid = exports.parseBidReceipt = exports.parseStrikes = exports.calcEstPnl = exports.calcBreakEvenPrice = exports.calcDeliveryPrice = exports.calcIncentiveRate = exports.IncentiveRateBp = exports.periodOrder = exports.optionTypeOrder = exports.tokenOrder = void 0;
|
|
89
|
+
exports.fetchUserBids = exports.getUserBidReceipts = exports.parseBid = exports.parseBidReceipt = exports.parseStrikes = exports.calcEstPnl = exports.calcBreakEvenPrice = exports.calcDeliveryPrice = exports.calcIncentiveRate = exports.fetchPrices = exports.parsePythOracleData = exports.IncentiveRateBp = exports.periodOrder = exports.optionTypeOrder = exports.tokenOrder = exports.ASSET_INFO = void 0;
|
|
79
90
|
var bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
91
|
+
var web3_js_1 = require("@solana/web3.js");
|
|
92
|
+
var client_1 = require("@pythnetwork/client");
|
|
80
93
|
var lodash_1 = require("lodash");
|
|
81
94
|
var moment_1 = __importDefault(require("moment"));
|
|
82
95
|
var view_function_1 = require("../view-function");
|
|
83
96
|
var vault_1 = require("./vault");
|
|
84
97
|
var token_1 = require("./token");
|
|
85
98
|
var tools_1 = require("../../tools");
|
|
99
|
+
var config_json_1 = __importDefault(require("../../../config.json"));
|
|
86
100
|
var view_function_2 = require("../../auto-bid/view-function");
|
|
87
101
|
var token_2 = require("../../token");
|
|
102
|
+
var token_3 = require("./token");
|
|
103
|
+
var price_1 = require("../../price");
|
|
88
104
|
var PriceDecimal = (0, bignumber_js_1.default)(10).pow(8);
|
|
105
|
+
exports.ASSET_INFO = {
|
|
106
|
+
BTC: {
|
|
107
|
+
product: new web3_js_1.PublicKey("4aDoSXJ5o3AuvL7QFeR6h44jALQfTmUUCTVGDD6aoJTM"),
|
|
108
|
+
price: new web3_js_1.PublicKey("GVXRSBjFk6e6J3NbVPXohDJetcTjaeeuykUpbQF8UoMU"),
|
|
109
|
+
},
|
|
110
|
+
ETH: {
|
|
111
|
+
product: new web3_js_1.PublicKey("EMkxjGC1CQ7JLiutDbfYb7UKb3zm9SJcUmr1YicBsdpZ"),
|
|
112
|
+
price: new web3_js_1.PublicKey("JBu1AL4obBcCMqKBBxhpWCNUt136ijcuMZLFvTP7iWdB"),
|
|
113
|
+
},
|
|
114
|
+
SUI: {
|
|
115
|
+
product: new web3_js_1.PublicKey("2F8rfBf4z4SzNpeQstFTpLXTQQ7RNKsLFqPdbpybooCc"),
|
|
116
|
+
price: new web3_js_1.PublicKey("3Qub3HaAJaa2xNY7SUqPKd3vVwTqDfDDkEUMPjXD2c1q"),
|
|
117
|
+
},
|
|
118
|
+
CETUS: {
|
|
119
|
+
product: new web3_js_1.PublicKey("JDHPsM1zxsZ6TfDwpCVzo41DAZdRi6ZmhkzWU1iXvSQ"),
|
|
120
|
+
price: new web3_js_1.PublicKey("GTeC2JfBFrHuYkBivDQcNdLY74X5FRDLEJntnxPKRQbY"),
|
|
121
|
+
},
|
|
122
|
+
SEI: {
|
|
123
|
+
product: new web3_js_1.PublicKey("24bB1mRGsrrDVawJTCVYXrxbEz6ozztukPUKvcZCDcPz"),
|
|
124
|
+
price: new web3_js_1.PublicKey("6cUuAyAX3eXoiWkjFF77RQBEUF15AAMQ7d1hm4EPd3tv"),
|
|
125
|
+
},
|
|
126
|
+
USDC: {
|
|
127
|
+
product: new web3_js_1.PublicKey("8GWTTbNiXdmyZREXbjsZBmCRuzdPrW55dnZGDkTRjWvb"),
|
|
128
|
+
price: new web3_js_1.PublicKey("Gnt27xtC473ZT2Mw5u8wZ68Z3gULkSTb5DuxJy7eJotD"),
|
|
129
|
+
},
|
|
130
|
+
USDT: {
|
|
131
|
+
product: new web3_js_1.PublicKey("Av6XyAMJnyi68FdsKSPYgzfXGjYrrt6jcAMwtvzLCqaM"),
|
|
132
|
+
price: new web3_js_1.PublicKey("3vxLXJqLqF3JG5TCbYycbKWRBbCJQLxQmBGCkyqEEefL"),
|
|
133
|
+
},
|
|
134
|
+
TURBOS: {
|
|
135
|
+
product: new web3_js_1.PublicKey("8DZUgXNQo5Um1pqo4gzv9oWPUZpyKV9nXm51gysZFMef"),
|
|
136
|
+
price: new web3_js_1.PublicKey("HoxttzPFzcPvpZhUY8LCLkFNn9keDnBrctno4wXEhpFk"),
|
|
137
|
+
},
|
|
138
|
+
APT: {
|
|
139
|
+
product: new web3_js_1.PublicKey("6bQMDtuAmRgjvymdWk9w4tTc9YyuXcjMxF8MyPHXejsx"),
|
|
140
|
+
price: new web3_js_1.PublicKey("FNNvb1AFDnDVPkocEri8mWbJ1952HQZtFLuwPiUjSJQ"),
|
|
141
|
+
},
|
|
142
|
+
SOL: {
|
|
143
|
+
product: new web3_js_1.PublicKey("ALP8SdU9oARYVLgLR7LrqMNCYBnhtnQz1cj6bwgwQmgj"),
|
|
144
|
+
price: new web3_js_1.PublicKey("H6ARHf6YXhGYeQfUzQNGk6rDNnLBQKrenN712K4AQJEG"),
|
|
145
|
+
},
|
|
146
|
+
INJ: {
|
|
147
|
+
product: new web3_js_1.PublicKey("5Q5kyCVzssrGMd2BniSdVeRwjNWrGGrFhMrgGt4zURyA"),
|
|
148
|
+
price: new web3_js_1.PublicKey("9EdtbaivHQYA4Nh3XzGR6DwRaoorqXYnmpfsnFhvwuVj"),
|
|
149
|
+
},
|
|
150
|
+
JUP: {
|
|
151
|
+
product: new web3_js_1.PublicKey("AykbyeHZbUbEtEAPVpBLoPAMHBrUrDMtXJkPWZw4TRDX"),
|
|
152
|
+
price: new web3_js_1.PublicKey("g6eRCbboSwK4tSWngn773RCMexr1APQr4uA9bGZBYfo"),
|
|
153
|
+
},
|
|
154
|
+
};
|
|
89
155
|
exports.tokenOrder = {
|
|
90
156
|
// Basically it's a to z but put SUI at first
|
|
91
157
|
SUI: 0,
|
|
@@ -125,6 +191,116 @@ exports.periodOrder = {
|
|
|
125
191
|
3: 0,
|
|
126
192
|
};
|
|
127
193
|
exports.IncentiveRateBp = 4;
|
|
194
|
+
var DefaultOracleDecimal = {
|
|
195
|
+
ETH: "8",
|
|
196
|
+
SUI: "8",
|
|
197
|
+
AFSUI: "8",
|
|
198
|
+
BTC: "8",
|
|
199
|
+
DOGE: "8",
|
|
200
|
+
APT: "8",
|
|
201
|
+
SOL: "8",
|
|
202
|
+
USDC: "8",
|
|
203
|
+
USDT: "8",
|
|
204
|
+
CETUS: "8",
|
|
205
|
+
TURBOS: "8",
|
|
206
|
+
NAVX: "8",
|
|
207
|
+
JUP: "8",
|
|
208
|
+
BUCK: "8",
|
|
209
|
+
USDY: "8",
|
|
210
|
+
SEI: "8",
|
|
211
|
+
FUD: "8",
|
|
212
|
+
MFUD: "8",
|
|
213
|
+
INJ: "8",
|
|
214
|
+
SCA: "8",
|
|
215
|
+
};
|
|
216
|
+
var parsePythOracleData = function (data, decimals) {
|
|
217
|
+
var prices = {};
|
|
218
|
+
Object.entries(exports.ASSET_INFO).forEach(function (p) {
|
|
219
|
+
var _a, _b;
|
|
220
|
+
var asset = p[0].toUpperCase();
|
|
221
|
+
var coinData = data.find(function (s) {
|
|
222
|
+
return s.productAccountKey.equals(p[1].product);
|
|
223
|
+
});
|
|
224
|
+
var decimal = decimals[asset];
|
|
225
|
+
if (decimal && coinData) {
|
|
226
|
+
prices[asset.toLowerCase()] = {
|
|
227
|
+
price: (0, bignumber_js_1.default)((_a = coinData.price) !== null && _a !== void 0 ? _a : 0)
|
|
228
|
+
.multipliedBy((0, bignumber_js_1.default)(10).pow(decimal))
|
|
229
|
+
.toString(),
|
|
230
|
+
decimal: decimal,
|
|
231
|
+
quote: "usd",
|
|
232
|
+
};
|
|
233
|
+
if (token_3.WrappedToken[asset]) {
|
|
234
|
+
prices[token_3.WrappedToken[asset].toLowerCase()] = {
|
|
235
|
+
price: (0, bignumber_js_1.default)((_b = coinData.price) !== null && _b !== void 0 ? _b : 0)
|
|
236
|
+
.multipliedBy((0, bignumber_js_1.default)(10).pow(decimal))
|
|
237
|
+
.toString(),
|
|
238
|
+
decimal: decimal,
|
|
239
|
+
quote: "usd",
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
return prices;
|
|
245
|
+
};
|
|
246
|
+
exports.parsePythOracleData = parsePythOracleData;
|
|
247
|
+
var fetchPrices = function (provider, network) { return __awaiter(void 0, void 0, void 0, function () {
|
|
248
|
+
var coinObjects, oracleDecimal, PYTHNET_CLUSTER_NAME, connection, pythPublicKey, pythClient, priceData, prices, suiusd, suifud, fudusd, suiafsui, afsuiusd, suinavx, navxusd, suibuck, buckusd, usdyusdc, usdyusdcWithDecimal, scasui, scausd;
|
|
249
|
+
var _a, _b;
|
|
250
|
+
return __generator(this, function (_c) {
|
|
251
|
+
switch (_c.label) {
|
|
252
|
+
case 0: return [4 /*yield*/, provider.multiGetObjects({
|
|
253
|
+
ids: Object.values(config_json_1.default[network.toUpperCase()].ORACLE),
|
|
254
|
+
options: { showContent: true },
|
|
255
|
+
})];
|
|
256
|
+
case 1:
|
|
257
|
+
coinObjects = _c.sent();
|
|
258
|
+
oracleDecimal = __assign({}, DefaultOracleDecimal);
|
|
259
|
+
coinObjects.forEach(function (c) {
|
|
260
|
+
var _a, _b;
|
|
261
|
+
// @ts-ignore
|
|
262
|
+
oracleDecimal[(_a = c.data) === null || _a === void 0 ? void 0 : _a.content.fields.base_token] =
|
|
263
|
+
// @ts-ignore
|
|
264
|
+
(_b = c.data) === null || _b === void 0 ? void 0 : _b.content.fields.decimal;
|
|
265
|
+
});
|
|
266
|
+
PYTHNET_CLUSTER_NAME = "pythnet";
|
|
267
|
+
connection = new web3_js_1.Connection((0, client_1.getPythClusterApiUrl)(PYTHNET_CLUSTER_NAME));
|
|
268
|
+
pythPublicKey = (0, client_1.getPythProgramKeyForCluster)(PYTHNET_CLUSTER_NAME);
|
|
269
|
+
pythClient = new client_1.PythHttpClient(connection, pythPublicKey);
|
|
270
|
+
return [4 /*yield*/, pythClient.getAssetPricesFromAccounts(Object.values(exports.ASSET_INFO).map(function (a) { return a.price; }))];
|
|
271
|
+
case 2:
|
|
272
|
+
priceData = _c.sent();
|
|
273
|
+
prices = (0, exports.parsePythOracleData)(priceData, oracleDecimal);
|
|
274
|
+
suiusd = (0, bignumber_js_1.default)((_b = (_a = prices["sui"]) === null || _a === void 0 ? void 0 : _a.price) !== null && _b !== void 0 ? _b : 0);
|
|
275
|
+
return [4 /*yield*/, (0, price_1.getLatestPrice)("SUIFUD")];
|
|
276
|
+
case 3:
|
|
277
|
+
suifud = _c.sent();
|
|
278
|
+
fudusd = suifud == "0" ? (0, bignumber_js_1.default)(0) : suiusd.div(suifud);
|
|
279
|
+
return [4 /*yield*/, (0, price_1.getLatestPrice)("SUIAFSUI")];
|
|
280
|
+
case 4:
|
|
281
|
+
suiafsui = _c.sent();
|
|
282
|
+
afsuiusd = suiafsui == "0" ? (0, bignumber_js_1.default)(0) : suiusd.div(suiafsui);
|
|
283
|
+
return [4 /*yield*/, (0, price_1.getLatestPrice)("SUINAVX")];
|
|
284
|
+
case 5:
|
|
285
|
+
suinavx = _c.sent();
|
|
286
|
+
navxusd = suiusd.div(suinavx);
|
|
287
|
+
return [4 /*yield*/, (0, price_1.getLatestPrice)("SUIBUCK")];
|
|
288
|
+
case 6:
|
|
289
|
+
suibuck = _c.sent();
|
|
290
|
+
buckusd = (0, bignumber_js_1.default)(suibuck).lte(0) ? "0" : suiusd.div(suibuck);
|
|
291
|
+
return [4 /*yield*/, (0, price_1.getLatestPrice)("USDYUSDC")];
|
|
292
|
+
case 7:
|
|
293
|
+
usdyusdc = _c.sent();
|
|
294
|
+
usdyusdcWithDecimal = (0, bignumber_js_1.default)(usdyusdc).multipliedBy((0, bignumber_js_1.default)(10).pow(8));
|
|
295
|
+
return [4 /*yield*/, (0, price_1.getLatestPrice)("SCASUI")];
|
|
296
|
+
case 8:
|
|
297
|
+
scasui = _c.sent();
|
|
298
|
+
scausd = suiusd.eq(0) ? (0, bignumber_js_1.default)(0) : (0, bignumber_js_1.default)(scasui).multipliedBy(suiusd);
|
|
299
|
+
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)];
|
|
300
|
+
}
|
|
301
|
+
});
|
|
302
|
+
}); };
|
|
303
|
+
exports.fetchPrices = fetchPrices;
|
|
128
304
|
var calcIncentiveRate = function (incentiveBp) {
|
|
129
305
|
var incentiveRateBp = (0, bignumber_js_1.default)(incentiveBp).div((0, bignumber_js_1.default)(10).pow(exports.IncentiveRateBp));
|
|
130
306
|
var incentiveRate = 1;
|
|
@@ -501,9 +677,15 @@ var fetchUserBids = function (provider, network, packageAddress, framworkAddress
|
|
|
501
677
|
return [4 /*yield*/, (0, view_function_1.getAuctions)(provider, packageAddress, registryAddress, [])];
|
|
502
678
|
case 4:
|
|
503
679
|
auctions = _f.sent();
|
|
680
|
+
if (!(typeof prices === "undefined")) return [3 /*break*/, 6];
|
|
681
|
+
return [4 /*yield*/, (0, exports.fetchPrices)(provider, "testnet")];
|
|
682
|
+
case 5:
|
|
683
|
+
prices = _f.sent();
|
|
684
|
+
_f.label = 6;
|
|
685
|
+
case 6:
|
|
504
686
|
_a = (0, exports.parseBidReceipt)(Object.values(vaultsInfo), userReceipts), sortedBidReceipts = _a.sortedBidReceipts, bidVaultsInfo = _a.bidVaultsInfo;
|
|
505
687
|
return [4 /*yield*/, (0, view_function_1.getMyBids)(provider, framworkAddress, packageAddress, registryAddress, sortedBidReceipts)];
|
|
506
|
-
case
|
|
688
|
+
case 7:
|
|
507
689
|
bidShares = _f.sent();
|
|
508
690
|
bidsFromBidShares = [];
|
|
509
691
|
_loop_1 = function (bidVaultInfo) {
|
|
@@ -511,7 +693,10 @@ var fetchUserBids = function (provider, network, packageAddress, framworkAddress
|
|
|
511
693
|
var auction = auctions ? auctions[bidVaultInfo.vaultInfo.info.index] : null;
|
|
512
694
|
var _g = __read((0, vault_1.parseAssets)(bidVaultInfo.vaultInfo.info), 3), dToken = _g[0], bToken = _g[1], oToken = _g[2];
|
|
513
695
|
if (bidShare) {
|
|
514
|
-
var
|
|
696
|
+
var price = (0, bignumber_js_1.default)(prices[oToken.toLowerCase()].price)
|
|
697
|
+
.div((0, bignumber_js_1.default)(10).pow(prices[oToken.toLowerCase()].decimal))
|
|
698
|
+
.toString();
|
|
699
|
+
var data = (0, exports.parseBid)(bidVaultInfo, bidShare, auction, price, false);
|
|
515
700
|
var checkExistVault = bidsFromBidShares.find(function (p) { return p.vaultIndex === bidVaultInfo.vaultInfo.info.index && p.receiptsVid.includes(bidVaultInfo.receipt.vid); });
|
|
516
701
|
if (checkExistVault) {
|
|
517
702
|
// Merge the bid receipts into the same vault
|
|
@@ -602,7 +787,10 @@ var fetchUserBids = function (provider, network, packageAddress, framworkAddress
|
|
|
602
787
|
var auction = auctions ? auctions[autoBidVaultInfo.vaultInfo.info.index] : null;
|
|
603
788
|
var _h = __read((0, vault_1.parseAssets)(autoBidVaultInfo.vaultInfo.info), 3), dToken = _h[0], bToken = _h[1], oToken = _h[2];
|
|
604
789
|
if (bidShare) {
|
|
605
|
-
var
|
|
790
|
+
var price = (0, bignumber_js_1.default)(prices[oToken.toLowerCase()].price)
|
|
791
|
+
.div((0, bignumber_js_1.default)(10).pow(prices[oToken.toLowerCase()].decimal))
|
|
792
|
+
.toString();
|
|
793
|
+
var data = (0, exports.parseBid)(autoBidVaultInfo, bidShare, auction, price, false);
|
|
606
794
|
var checkExistVault = bidsFromStrategies.find(function (p) { return p.vaultIndex === autoBidVaultInfo.vaultInfo.info.index && p.receiptsVid.includes(autoBidVaultInfo.receipt.vid); });
|
|
607
795
|
if (checkExistVault) {
|
|
608
796
|
// Merge the bid receipts into the same vault
|
package/package.json
CHANGED
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
"name": "@typus/typus-sdk",
|
|
3
3
|
"author": "Typus",
|
|
4
4
|
"description": "typus sdk",
|
|
5
|
-
"version": "1.2.
|
|
5
|
+
"version": "1.2.84",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@mysten/bcs": "^0.11.1",
|
|
8
8
|
"@mysten/kiosk": "0.7.12",
|
|
9
9
|
"@mysten/sui.js": "0.48.0",
|
|
10
|
+
"@pythnetwork/client": "^2.21.0",
|
|
11
|
+
"@solana/web3.js": "^1.91.8",
|
|
10
12
|
"@types/node": "^20.5.7",
|
|
11
13
|
"aftermath-ts-sdk": "^1.1.14",
|
|
12
14
|
"bignumber.js": "^9.1.1",
|