@typus/typus-sdk 1.8.41 → 1.8.43-upgrade
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/dist/src/auto-bid/view-function.d.ts +0 -2
- package/dist/src/auto-bid/view-function.js +7 -76
- package/dist/src/constants/constant.d.ts +0 -3
- package/dist/src/constants/constant.js +1 -8
- package/dist/src/constants/token.d.ts +1 -1
- package/dist/src/constants/token.js +12 -0
- package/dist/src/dice/fetch.d.ts +0 -4
- package/dist/src/dice/fetch.js +59 -116
- package/dist/src/typus/airdrop/view-function.js +5 -8
- package/dist/src/typus/leaderboard/view-function.js +5 -8
- package/dist/src/typus/tails-staking/view-function.js +10 -14
- package/dist/src/typus/user/view-function.js +5 -6
- package/dist/src/typus-dov-single-v2/function/bidding.d.ts +4 -3
- package/dist/src/typus-dov-single-v2/function/bidding.js +10 -11
- package/dist/src/typus-dov-single-v2/function/token.js +1 -1
- package/dist/src/typus-dov-single-v2/history/index.d.ts +0 -1
- package/dist/src/typus-dov-single-v2/history/index.js +0 -1
- package/dist/src/typus-dov-single-v2/history/user-history.d.ts +2 -3
- package/dist/src/typus-dov-single-v2/history/user-history.js +122 -184
- package/dist/src/typus-dov-single-v2/otc-entry.js +5 -6
- package/dist/src/typus-dov-single-v2/user-entry.d.ts +1 -1
- package/dist/src/typus-dov-single-v2/view-function.js +29 -27
- package/dist/src/typus-hedge/view-function.js +10 -10
- package/dist/src/typus-launch/airdrop/view-function.js +3 -5
- package/dist/src/typus-launch/auction/view-function.js +17 -16
- package/dist/src/typus-launch/funding-vault/view-function.js +20 -18
- package/dist/src/typus-launch/improvement-proposal/view-function.js +17 -18
- package/dist/src/typus-launch/ve-typus/view-function.js +15 -15
- package/dist/src/typus-safu/view-function.js +13 -13
- package/dist/src/utils/api/price.js +1 -1
- package/dist/src/utils/graphQl.d.ts +24 -0
- package/dist/src/utils/graphQl.js +129 -0
- package/dist/src/utils/index.d.ts +1 -0
- package/dist/src/utils/index.js +1 -0
- package/dist/src/utils/oracle.js +13 -14
- package/dist/src/utils/pyth/constant.js +4 -0
- package/dist/src/utils/sponsoredTx.d.ts +2 -2
- package/dist/src/utils/typusConfig.d.ts +4 -0
- package/dist/src/utils/typusConfig.js +33 -31
- package/package.json +9 -10
- package/dist/src/dice/view-function.d.ts +0 -1
- package/dist/src/dice/view-function.js +0 -20
- package/dist/src/typus-dov-single-v2/history/vault-history.d.ts +0 -123
- package/dist/src/typus-dov-single-v2/history/vault-history.js +0 -307
- package/dist/src/typus-nft/fetch.d.ts +0 -70
- package/dist/src/typus-nft/fetch.js +0 -631
- package/dist/src/typus-nft/index.d.ts +0 -2
- package/dist/src/typus-nft/index.js +0 -18
- package/dist/src/typus-nft/user-entry.d.ts +0 -57
- package/dist/src/typus-nft/user-entry.js +0 -161
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import { SuiEvent } from "@mysten/sui/client";
|
|
2
|
-
import { OracleInfo, VaultConfig } from "../../../src/typus-dov-single-v2";
|
|
3
|
-
import { TypusConfig } from "../../../src/utils";
|
|
4
|
-
export declare function getVaultHistoryEvents(config: TypusConfig, startTimeMs: number): Promise<SuiEvent[]>;
|
|
5
|
-
export declare function parseGroupEvents(datas: SuiEvent[]): Promise<Map<string, Map<string, GroupEvent>>>;
|
|
6
|
-
export declare function parseVaultHistory(inputMap: Map<string, Map<string, GroupEvent>>): Promise<Map<string, Map<string, VaultHistory | undefined>>>;
|
|
7
|
-
export declare function convertGroupEventToVaultHistory(groupEvent: GroupEvent): Promise<VaultHistory | undefined>;
|
|
8
|
-
export interface VaultHistory {
|
|
9
|
-
vaultIndex: string;
|
|
10
|
-
round: string;
|
|
11
|
-
ActivationDate: Date;
|
|
12
|
-
SettlementTime: Date;
|
|
13
|
-
StrikePrice: number[] | undefined;
|
|
14
|
-
SettlePrice: number;
|
|
15
|
-
ActualReturn: number;
|
|
16
|
-
TotalAuctioned: number;
|
|
17
|
-
Filled: number;
|
|
18
|
-
DeliverySize: number;
|
|
19
|
-
DeliveryPrice: number;
|
|
20
|
-
DepositorsRewards: number;
|
|
21
|
-
BiddersPayoff: number;
|
|
22
|
-
DepositorPnl: number;
|
|
23
|
-
ActivateTx: string | undefined;
|
|
24
|
-
NewAuctionTx: string | undefined;
|
|
25
|
-
DeliveryTx: string | undefined;
|
|
26
|
-
RecoupTx: string | undefined;
|
|
27
|
-
SettleTx: string | undefined;
|
|
28
|
-
}
|
|
29
|
-
interface GroupEvent {
|
|
30
|
-
activateEvent: ActivateEvent | undefined;
|
|
31
|
-
newAuctionEvent: NewAuctionEvent | undefined;
|
|
32
|
-
deliveryEvent: DeliveryEvent | undefined;
|
|
33
|
-
recoupEvent: RecoupEvent | undefined;
|
|
34
|
-
settleEvent: SettleEvent | undefined;
|
|
35
|
-
}
|
|
36
|
-
interface ActivateEvent {
|
|
37
|
-
signer: string;
|
|
38
|
-
index: string;
|
|
39
|
-
round: string;
|
|
40
|
-
deposit_amount: string;
|
|
41
|
-
d_token_decimal: string;
|
|
42
|
-
contract_size: string;
|
|
43
|
-
o_token_decimal: string;
|
|
44
|
-
oracle_info: OracleInfo;
|
|
45
|
-
u64_padding: string[];
|
|
46
|
-
timestampMs: string | null | undefined;
|
|
47
|
-
txDigest: string;
|
|
48
|
-
}
|
|
49
|
-
interface NewAuctionEvent {
|
|
50
|
-
signer: string;
|
|
51
|
-
index: string;
|
|
52
|
-
round: string;
|
|
53
|
-
start_ts_ms: string;
|
|
54
|
-
end_ts_ms: string;
|
|
55
|
-
size: string;
|
|
56
|
-
vault_config: VaultConfig;
|
|
57
|
-
oracle_info: OracleInfo;
|
|
58
|
-
u64_padding: string[];
|
|
59
|
-
timestampMs: string | null | undefined;
|
|
60
|
-
txDigest: string;
|
|
61
|
-
}
|
|
62
|
-
interface DeliveryEvent {
|
|
63
|
-
signer: string;
|
|
64
|
-
index: string;
|
|
65
|
-
round: string;
|
|
66
|
-
early: boolean;
|
|
67
|
-
delivery_price: string;
|
|
68
|
-
delivery_size: string;
|
|
69
|
-
o_token_decimal: string;
|
|
70
|
-
o_token: {
|
|
71
|
-
name: string;
|
|
72
|
-
};
|
|
73
|
-
bidder_bid_value: string;
|
|
74
|
-
bidder_fee: string;
|
|
75
|
-
incentive_bid_value: string;
|
|
76
|
-
incentive_fee: string;
|
|
77
|
-
b_token_decimal: string;
|
|
78
|
-
b_token: {
|
|
79
|
-
name: string;
|
|
80
|
-
};
|
|
81
|
-
depositor_incentive_value: string;
|
|
82
|
-
u64_padding: string[];
|
|
83
|
-
timestampMs: string | null | undefined;
|
|
84
|
-
txDigest: string;
|
|
85
|
-
}
|
|
86
|
-
interface RecoupEvent {
|
|
87
|
-
signer: string;
|
|
88
|
-
index: string;
|
|
89
|
-
round: string;
|
|
90
|
-
active_amount: string;
|
|
91
|
-
deactivating_amount: string;
|
|
92
|
-
d_token_decimal: string;
|
|
93
|
-
u64_padding: string[];
|
|
94
|
-
timestampMs: string | null | undefined;
|
|
95
|
-
txDigest: string;
|
|
96
|
-
}
|
|
97
|
-
interface SettleEvent {
|
|
98
|
-
signer: string;
|
|
99
|
-
index: string;
|
|
100
|
-
round: string;
|
|
101
|
-
oracle_price: string;
|
|
102
|
-
oracle_price_decimal: string;
|
|
103
|
-
settle_balance: string;
|
|
104
|
-
settled_balance: string;
|
|
105
|
-
d_token_decimal: string;
|
|
106
|
-
d_token: {
|
|
107
|
-
name: string;
|
|
108
|
-
};
|
|
109
|
-
share_price: string;
|
|
110
|
-
u64_padding: string[];
|
|
111
|
-
timestampMs: string | null | undefined;
|
|
112
|
-
txDigest: string;
|
|
113
|
-
}
|
|
114
|
-
export declare function parseBidEvents(datas: SuiEvent[], end_ts_ms: any): Promise<Map<string, NewBidEvent[]>>;
|
|
115
|
-
interface NewBidEvent {
|
|
116
|
-
signer: string;
|
|
117
|
-
index: string;
|
|
118
|
-
size: string;
|
|
119
|
-
ts_ms: string;
|
|
120
|
-
timestampMs: string | null | undefined;
|
|
121
|
-
txDigest: string;
|
|
122
|
-
}
|
|
123
|
-
export {};
|
|
@@ -1,307 +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 = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
-
return g.next = verb(0), g["throw"] = verb(1), g["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.getVaultHistoryEvents = getVaultHistoryEvents;
|
|
40
|
-
exports.parseGroupEvents = parseGroupEvents;
|
|
41
|
-
exports.parseVaultHistory = parseVaultHistory;
|
|
42
|
-
exports.convertGroupEventToVaultHistory = convertGroupEventToVaultHistory;
|
|
43
|
-
exports.parseBidEvents = parseBidEvents;
|
|
44
|
-
var client_1 = require("@mysten/sui/client");
|
|
45
|
-
var constants_1 = require("../../../src/constants");
|
|
46
|
-
function getVaultHistoryEvents(config, startTimeMs) {
|
|
47
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
48
|
-
var provider, senderFilter, result, datas, hasNextPage, cursor, result;
|
|
49
|
-
return __generator(this, function (_a) {
|
|
50
|
-
switch (_a.label) {
|
|
51
|
-
case 0:
|
|
52
|
-
provider = new client_1.SuiClient({ url: config.rpcEndpoint });
|
|
53
|
-
senderFilter = {
|
|
54
|
-
MoveEventModule: {
|
|
55
|
-
package: config.packageOrigin.dovSingle,
|
|
56
|
-
module: "typus_dov_single",
|
|
57
|
-
},
|
|
58
|
-
};
|
|
59
|
-
return [4 /*yield*/, provider.queryEvents({ query: senderFilter, order: "descending" })];
|
|
60
|
-
case 1:
|
|
61
|
-
result = _a.sent();
|
|
62
|
-
datas = result.data;
|
|
63
|
-
hasNextPage = result.hasNextPage;
|
|
64
|
-
cursor = result.nextCursor;
|
|
65
|
-
_a.label = 2;
|
|
66
|
-
case 2:
|
|
67
|
-
if (!hasNextPage) return [3 /*break*/, 4];
|
|
68
|
-
return [4 /*yield*/, provider.queryEvents({ query: senderFilter, order: "descending", cursor: cursor })];
|
|
69
|
-
case 3:
|
|
70
|
-
result = _a.sent();
|
|
71
|
-
// console.log(result);
|
|
72
|
-
datas = datas.concat(result.data);
|
|
73
|
-
if (result.hasNextPage && Number(result.data.at(-1).timestampMs) < startTimeMs) {
|
|
74
|
-
return [3 /*break*/, 4];
|
|
75
|
-
}
|
|
76
|
-
hasNextPage = result.hasNextPage;
|
|
77
|
-
cursor = result.nextCursor;
|
|
78
|
-
return [3 /*break*/, 2];
|
|
79
|
-
case 4: return [2 /*return*/, datas];
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
function parseGroupEvents(datas) {
|
|
85
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
86
|
-
var results;
|
|
87
|
-
var _this = this;
|
|
88
|
-
return __generator(this, function (_a) {
|
|
89
|
-
switch (_a.label) {
|
|
90
|
-
case 0: return [4 /*yield*/, datas.reduce(function (promise, event) { return __awaiter(_this, void 0, void 0, function () {
|
|
91
|
-
var map, functionType, action, parsedJson, index, round, round_event, round_events, round_events, round_events;
|
|
92
|
-
return __generator(this, function (_a) {
|
|
93
|
-
switch (_a.label) {
|
|
94
|
-
case 0: return [4 /*yield*/, promise];
|
|
95
|
-
case 1:
|
|
96
|
-
map = _a.sent();
|
|
97
|
-
functionType = new RegExp("^([^::]+)::([^::]+)::([^<]+)").exec(event.type);
|
|
98
|
-
action = functionType[3];
|
|
99
|
-
// console.log(action);
|
|
100
|
-
if (!["ActivateEvent", "NewAuctionEvent", "DeliveryEvent", "RecoupEvent", "SettleEvent"].includes(action)) {
|
|
101
|
-
return [2 /*return*/, map];
|
|
102
|
-
}
|
|
103
|
-
parsedJson = event.parsedJson;
|
|
104
|
-
// console.log(parsedJson);
|
|
105
|
-
parsedJson.timestampMs = event.timestampMs;
|
|
106
|
-
parsedJson.txDigest = event.id.txDigest;
|
|
107
|
-
index = parsedJson.index.toString();
|
|
108
|
-
round = parsedJson.round.toString();
|
|
109
|
-
round_event = {
|
|
110
|
-
activateEvent: undefined,
|
|
111
|
-
newAuctionEvent: undefined,
|
|
112
|
-
deliveryEvent: undefined,
|
|
113
|
-
recoupEvent: undefined,
|
|
114
|
-
settleEvent: undefined,
|
|
115
|
-
};
|
|
116
|
-
if (map.has(index)) {
|
|
117
|
-
round_events = map.get(index);
|
|
118
|
-
if (round_events.has(round)) {
|
|
119
|
-
round_event = round_events.get(round);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
switch (action) {
|
|
123
|
-
case "ActivateEvent":
|
|
124
|
-
round_event.activateEvent = parsedJson;
|
|
125
|
-
break;
|
|
126
|
-
case "NewAuctionEvent":
|
|
127
|
-
round_event.newAuctionEvent = parsedJson;
|
|
128
|
-
round_event.newAuctionEvent.vault_config = {
|
|
129
|
-
payoffConfigs: parsedJson.vault_config.payoff_configs.map(function (x) {
|
|
130
|
-
return ({
|
|
131
|
-
weight: x.weight,
|
|
132
|
-
isBuyer: x.is_buyer,
|
|
133
|
-
strike: x.strike,
|
|
134
|
-
strikeBp: x.strike_bp,
|
|
135
|
-
u64Padding: x.u64_padding,
|
|
136
|
-
});
|
|
137
|
-
}),
|
|
138
|
-
strikeIncrement: parsedJson.vault_config.strike_increment,
|
|
139
|
-
decaySpeed: parsedJson.vault_config.decay_speed,
|
|
140
|
-
initialPrice: parsedJson.vault_config.initial_price,
|
|
141
|
-
finalPrice: parsedJson.vault_config.final_price,
|
|
142
|
-
auctionDurationInMs: parsedJson.vault_config.auction_duration_in_ms,
|
|
143
|
-
u64Padding: parsedJson.vault_config.u64_padding,
|
|
144
|
-
};
|
|
145
|
-
break;
|
|
146
|
-
case "DeliveryEvent":
|
|
147
|
-
round_event.deliveryEvent = parsedJson;
|
|
148
|
-
// console.log(parsedJson);
|
|
149
|
-
break;
|
|
150
|
-
case "RecoupEvent":
|
|
151
|
-
round_event.recoupEvent = parsedJson;
|
|
152
|
-
break;
|
|
153
|
-
case "SettleEvent":
|
|
154
|
-
round_event.settleEvent = parsedJson;
|
|
155
|
-
break;
|
|
156
|
-
}
|
|
157
|
-
// console.log(round_event);
|
|
158
|
-
if (map.has(index)) {
|
|
159
|
-
round_events = map.get(index);
|
|
160
|
-
round_events.set(round, round_event);
|
|
161
|
-
map.set(index, round_events);
|
|
162
|
-
}
|
|
163
|
-
else {
|
|
164
|
-
round_events = new Map();
|
|
165
|
-
round_events.set(round, round_event);
|
|
166
|
-
map.set(index, round_events);
|
|
167
|
-
}
|
|
168
|
-
return [2 /*return*/, map];
|
|
169
|
-
}
|
|
170
|
-
});
|
|
171
|
-
}); }, Promise.resolve(new Map()))];
|
|
172
|
-
case 1:
|
|
173
|
-
results = _a.sent();
|
|
174
|
-
// console.log(results);
|
|
175
|
-
return [2 /*return*/, results];
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
function parseVaultHistory(inputMap) {
|
|
181
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
182
|
-
var result;
|
|
183
|
-
var _this = this;
|
|
184
|
-
return __generator(this, function (_a) {
|
|
185
|
-
result = new Map();
|
|
186
|
-
inputMap.forEach(function (innerMap, outerKey) {
|
|
187
|
-
var newInnerMap = new Map();
|
|
188
|
-
innerMap.forEach(function (groupEvent, innerKey) { return __awaiter(_this, void 0, void 0, function () {
|
|
189
|
-
var vaultHistory;
|
|
190
|
-
return __generator(this, function (_a) {
|
|
191
|
-
switch (_a.label) {
|
|
192
|
-
case 0: return [4 /*yield*/, convertGroupEventToVaultHistory(groupEvent)];
|
|
193
|
-
case 1:
|
|
194
|
-
vaultHistory = _a.sent();
|
|
195
|
-
newInnerMap.set(innerKey, vaultHistory);
|
|
196
|
-
return [2 /*return*/];
|
|
197
|
-
}
|
|
198
|
-
});
|
|
199
|
-
}); });
|
|
200
|
-
result.set(outerKey, newInnerMap);
|
|
201
|
-
});
|
|
202
|
-
return [2 /*return*/, result];
|
|
203
|
-
});
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
function convertGroupEventToVaultHistory(groupEvent) {
|
|
207
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
208
|
-
var ActivationMs, SettlementTsMs, b_token, o_token, bidder_bid_value, bidder_fee, delivery_price, delivery_size, incentive_bid_value, incentive_fee, DepositorsRewards, BiddersPayoff, result;
|
|
209
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
210
|
-
return __generator(this, function (_t) {
|
|
211
|
-
ActivationMs = Number((_a = groupEvent.activateEvent) === null || _a === void 0 ? void 0 : _a.timestampMs);
|
|
212
|
-
SettlementTsMs = Number((_b = groupEvent.settleEvent) === null || _b === void 0 ? void 0 : _b.timestampMs);
|
|
213
|
-
if (groupEvent.deliveryEvent) {
|
|
214
|
-
b_token = (0, constants_1.typeArgToAsset)(groupEvent.deliveryEvent.b_token.name);
|
|
215
|
-
o_token = (0, constants_1.typeArgToAsset)(groupEvent.deliveryEvent.o_token.name);
|
|
216
|
-
bidder_bid_value = Number(groupEvent.deliveryEvent.bidder_bid_value) / Math.pow(10, (0, constants_1.assetToDecimal)(b_token));
|
|
217
|
-
bidder_fee = Number(groupEvent.deliveryEvent.bidder_fee) / Math.pow(10, (0, constants_1.assetToDecimal)(b_token));
|
|
218
|
-
delivery_price = Number(groupEvent.deliveryEvent.delivery_price) / Math.pow(10, (0, constants_1.assetToDecimal)(b_token));
|
|
219
|
-
delivery_size = Number(groupEvent.deliveryEvent.delivery_size) / Math.pow(10, (0, constants_1.assetToDecimal)(o_token));
|
|
220
|
-
incentive_bid_value = Number(groupEvent.deliveryEvent.incentive_bid_value) / Math.pow(10, (0, constants_1.assetToDecimal)(b_token));
|
|
221
|
-
incentive_fee = Number(groupEvent.deliveryEvent.incentive_fee) / Math.pow(10, (0, constants_1.assetToDecimal)(b_token));
|
|
222
|
-
DepositorsRewards = bidder_bid_value + bidder_fee + incentive_bid_value + incentive_fee;
|
|
223
|
-
BiddersPayoff = (Number((_c = groupEvent.settleEvent) === null || _c === void 0 ? void 0 : _c.settle_balance) - Number((_d = groupEvent.settleEvent) === null || _d === void 0 ? void 0 : _d.settled_balance)) /
|
|
224
|
-
Math.pow(10, Number((_e = groupEvent.settleEvent) === null || _e === void 0 ? void 0 : _e.d_token_decimal));
|
|
225
|
-
result = {
|
|
226
|
-
vaultIndex: (_f = groupEvent.activateEvent) === null || _f === void 0 ? void 0 : _f.index,
|
|
227
|
-
round: (_g = groupEvent.activateEvent) === null || _g === void 0 ? void 0 : _g.round,
|
|
228
|
-
// activateEvent
|
|
229
|
-
ActivateTx: (_h = groupEvent.activateEvent) === null || _h === void 0 ? void 0 : _h.txDigest,
|
|
230
|
-
ActivationDate: new Date(ActivationMs - (ActivationMs % 3600000)),
|
|
231
|
-
TotalAuctioned: Number((_j = groupEvent.activateEvent) === null || _j === void 0 ? void 0 : _j.contract_size) / Math.pow(10, Number((_k = groupEvent.activateEvent) === null || _k === void 0 ? void 0 : _k.o_token_decimal)),
|
|
232
|
-
// newAuctionEvent
|
|
233
|
-
NewAuctionTx: (_l = groupEvent.newAuctionEvent) === null || _l === void 0 ? void 0 : _l.txDigest,
|
|
234
|
-
StrikePrice: (_m = groupEvent.newAuctionEvent) === null || _m === void 0 ? void 0 : _m.vault_config.payoffConfigs.map(function (payoffConfig) { return Number(payoffConfig.strike) / Math.pow(10, 8); }),
|
|
235
|
-
// deliveryEvent
|
|
236
|
-
DeliveryTx: groupEvent.deliveryEvent.txDigest,
|
|
237
|
-
DeliverySize: delivery_size,
|
|
238
|
-
DeliveryPrice: delivery_price,
|
|
239
|
-
Filled: delivery_size == 0 ? 0 : Number(groupEvent.deliveryEvent.delivery_size) / Number((_o = groupEvent.newAuctionEvent) === null || _o === void 0 ? void 0 : _o.size),
|
|
240
|
-
DepositorsRewards: DepositorsRewards,
|
|
241
|
-
// recoupEvent
|
|
242
|
-
RecoupTx: (_p = groupEvent.recoupEvent) === null || _p === void 0 ? void 0 : _p.txDigest,
|
|
243
|
-
// settleEvent
|
|
244
|
-
SettleTx: (_q = groupEvent.settleEvent) === null || _q === void 0 ? void 0 : _q.txDigest,
|
|
245
|
-
SettlementTime: new Date(SettlementTsMs - (SettlementTsMs % 3600000)),
|
|
246
|
-
SettlePrice: Number((_r = groupEvent.settleEvent) === null || _r === void 0 ? void 0 : _r.oracle_price) / Math.pow(10, 8),
|
|
247
|
-
ActualReturn: Number((_s = groupEvent.settleEvent) === null || _s === void 0 ? void 0 : _s.share_price) / Math.pow(10, 8) - 1,
|
|
248
|
-
BiddersPayoff: BiddersPayoff,
|
|
249
|
-
DepositorPnl: DepositorsRewards - BiddersPayoff,
|
|
250
|
-
};
|
|
251
|
-
return [2 /*return*/, result];
|
|
252
|
-
}
|
|
253
|
-
return [2 /*return*/];
|
|
254
|
-
});
|
|
255
|
-
});
|
|
256
|
-
}
|
|
257
|
-
function parseBidEvents(datas, end_ts_ms) {
|
|
258
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
259
|
-
var results;
|
|
260
|
-
var _this = this;
|
|
261
|
-
return __generator(this, function (_a) {
|
|
262
|
-
switch (_a.label) {
|
|
263
|
-
case 0: return [4 /*yield*/, datas.reduce(function (promise, event) { return __awaiter(_this, void 0, void 0, function () {
|
|
264
|
-
var map, functionType, action, parsedJson, index, bid_event, o_token, size, bid_events;
|
|
265
|
-
return __generator(this, function (_a) {
|
|
266
|
-
switch (_a.label) {
|
|
267
|
-
case 0: return [4 /*yield*/, promise];
|
|
268
|
-
case 1:
|
|
269
|
-
map = _a.sent();
|
|
270
|
-
functionType = new RegExp("^([^::]+)::([^::]+)::([^<]+)").exec(event.type);
|
|
271
|
-
action = functionType[3];
|
|
272
|
-
// console.log(action);
|
|
273
|
-
if (action != "NewBidEvent") {
|
|
274
|
-
return [2 /*return*/, map];
|
|
275
|
-
}
|
|
276
|
-
parsedJson = event.parsedJson;
|
|
277
|
-
// console.log(parsedJson);
|
|
278
|
-
parsedJson.timestampMs = event.timestampMs;
|
|
279
|
-
parsedJson.txDigest = event.id.txDigest;
|
|
280
|
-
index = parsedJson.index.toString();
|
|
281
|
-
bid_event = parsedJson;
|
|
282
|
-
o_token = (0, constants_1.typeArgToAsset)("0x" + parsedJson.o_token.name);
|
|
283
|
-
size = Number(parsedJson.size) / Math.pow(10, (0, constants_1.assetToDecimal)(o_token));
|
|
284
|
-
bid_event.size = size.toString();
|
|
285
|
-
if (Number(bid_event.ts_ms) > end_ts_ms) {
|
|
286
|
-
return [2 /*return*/, map];
|
|
287
|
-
}
|
|
288
|
-
if (map.has(index)) {
|
|
289
|
-
bid_events = map.get(index);
|
|
290
|
-
bid_events.push(bid_event);
|
|
291
|
-
}
|
|
292
|
-
else {
|
|
293
|
-
bid_events = [bid_event];
|
|
294
|
-
}
|
|
295
|
-
map.set(index, bid_events);
|
|
296
|
-
return [2 /*return*/, map];
|
|
297
|
-
}
|
|
298
|
-
});
|
|
299
|
-
}); }, Promise.resolve(new Map()))];
|
|
300
|
-
case 1:
|
|
301
|
-
results = _a.sent();
|
|
302
|
-
// console.log(results);
|
|
303
|
-
return [2 /*return*/, results];
|
|
304
|
-
}
|
|
305
|
-
});
|
|
306
|
-
});
|
|
307
|
-
}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { SuiClient, SuiObjectResponse } from "@mysten/sui/client";
|
|
2
|
-
import { KioskClient, KioskListing } from "@mysten/kiosk";
|
|
3
|
-
export declare function getPool(provider: SuiClient, pool: string): Promise<PoolData>;
|
|
4
|
-
export interface PoolData {
|
|
5
|
-
pool_id: string;
|
|
6
|
-
is_live: boolean;
|
|
7
|
-
start_ms: string;
|
|
8
|
-
num: number;
|
|
9
|
-
remaining: number;
|
|
10
|
-
table: string;
|
|
11
|
-
}
|
|
12
|
-
export declare const necklaces: string[];
|
|
13
|
-
export declare function getPoolMap(provider: SuiClient, nftConfig: any): Promise<Map<string, PoolData>>;
|
|
14
|
-
export declare function getWhitelistMap(nftConfig: any, wlTokens: any): Promise<Map<string, string[]>>;
|
|
15
|
-
export interface TailsId {
|
|
16
|
-
nftId: string;
|
|
17
|
-
kiosk: string;
|
|
18
|
-
kioskCap: string;
|
|
19
|
-
tails: Tails | undefined;
|
|
20
|
-
isPersonal: boolean;
|
|
21
|
-
listing?: KioskListing;
|
|
22
|
-
}
|
|
23
|
-
export interface kioskOwnerCap {
|
|
24
|
-
kioskId: string;
|
|
25
|
-
objectId: string;
|
|
26
|
-
isPersonal: boolean;
|
|
27
|
-
}
|
|
28
|
-
export declare function getkioskOwnerCaps(datas: SuiObjectResponse[]): kioskOwnerCap[];
|
|
29
|
-
export declare function getTailsIds(kioskClient: KioskClient, NFT_PACKAGE_ORIGIN: string, kioskOwnerCaps: kioskOwnerCap[]): Promise<TailsId[]>;
|
|
30
|
-
export interface TailsWithType extends Tails {
|
|
31
|
-
type: string | null | undefined;
|
|
32
|
-
}
|
|
33
|
-
export declare function getTails(provider: SuiClient, tailsIds: string[]): Promise<TailsWithType[]>;
|
|
34
|
-
export declare function getTailsDynamicField(provider: SuiClient, tailsIds: string[]): Promise<[Tails[], Map<string, string>]>;
|
|
35
|
-
export declare function getTailsKiosk(provider: SuiClient, tailsToDynamicField: Map<string, string>): Promise<Map<string, string>>;
|
|
36
|
-
export declare function getKioskOwner(provider: SuiClient, DynamicFieldToKiosk: Map<string, string>): Promise<Map<string, string>>;
|
|
37
|
-
export declare function fieldsToTails(fields: any): Tails;
|
|
38
|
-
export interface Tails {
|
|
39
|
-
id: string;
|
|
40
|
-
name: string;
|
|
41
|
-
number: string;
|
|
42
|
-
url: string;
|
|
43
|
-
level: string;
|
|
44
|
-
exp: string;
|
|
45
|
-
first_bid: string;
|
|
46
|
-
first_deposit: string;
|
|
47
|
-
first_deposit_nft: string;
|
|
48
|
-
attributes: Map<string, string>;
|
|
49
|
-
u64_padding: Map<string, string>;
|
|
50
|
-
}
|
|
51
|
-
export declare function getLevelExp(level: number): number | undefined;
|
|
52
|
-
export declare const LevelExpVec: number[];
|
|
53
|
-
export declare function getTableTails(provider: SuiClient, parentId: string): Promise<TailsWithType[]>;
|
|
54
|
-
export declare function getDiscountPool(provider: SuiClient, pool: string): Promise<DiscountPoolData>;
|
|
55
|
-
export interface DiscountPoolData {
|
|
56
|
-
id: string;
|
|
57
|
-
num: string;
|
|
58
|
-
total: string;
|
|
59
|
-
price: string;
|
|
60
|
-
start_ms: string;
|
|
61
|
-
end_ms: string;
|
|
62
|
-
authority: string;
|
|
63
|
-
public_key: number[];
|
|
64
|
-
discount_pcts: string[];
|
|
65
|
-
is_live: boolean;
|
|
66
|
-
balance: string;
|
|
67
|
-
inventory: number;
|
|
68
|
-
}
|
|
69
|
-
export declare function getMintHistory(provider: SuiClient, NFT_PACKAGE: string, vrf_input: any): Promise<import("@mysten/sui/client").PaginatedEvents | undefined>;
|
|
70
|
-
export declare function calculateLevelReward(totalRewards: number, levelShares: number[], numOfHolders: number[]): number[];
|