@typus/typus-sdk 1.4.41 → 1.4.42
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/token-user-entry.js +5 -5
- package/dist/src/constants/token.d.ts +2 -0
- package/dist/src/constants/token.js +2 -0
- package/dist/src/dice/index.d.ts +0 -1
- package/dist/src/dice/index.js +0 -1
- package/dist/src/dice/view-function.d.ts +1 -21
- package/dist/src/dice/view-function.js +0 -119
- package/dist/src/typus-dov-single-v2/history/user-history.d.ts +3 -6
- package/dist/src/typus-dov-single-v2/history/user-history.js +9 -146
- package/dist/src/typus-dov-single-v2/history/vault-history.d.ts +5 -5
- package/dist/src/typus-dov-single-v2/history/vault-history.js +13 -13
- package/dist/src/typus-dov-single-v2/token-user-entry.js +8 -8
- package/dist/src/typus-perp/index.js +2 -2
- package/dist/src/utils/api/defillama/tvl.js +1 -1
- package/dist/src/utils/api/sentio/events.d.ts +9 -0
- package/dist/src/utils/api/sentio/events.js +190 -0
- package/dist/src/utils/api/sentio/index.d.ts +1 -0
- package/dist/src/utils/api/sentio/index.js +1 -0
- package/dist/src/utils/mint.d.ts +1 -1
- package/dist/src/utils/mint.js +1 -2
- package/dist/src/utils/typusConfig.d.ts +5 -1
- package/dist/src/utils/typusConfig.js +16 -8
- package/package.json +1 -1
|
@@ -31,7 +31,7 @@ function getTokenNewStrategyTx(config, tx, input) {
|
|
|
31
31
|
break;
|
|
32
32
|
}
|
|
33
33
|
var tToken = tx.moveCall({
|
|
34
|
-
target: "".concat(
|
|
34
|
+
target: "".concat(input.typusTokenType.split("::")[0], "::").concat(input.typusTokenType.split("::")[1], "::mint"),
|
|
35
35
|
arguments: [
|
|
36
36
|
tx.object(typusTokenRegistry),
|
|
37
37
|
tx.makeMoveVec({ objects: input.coins.map(function (id) { return tx.object(id); }) }),
|
|
@@ -66,7 +66,7 @@ function getTokenUpdateStrategyTx(config, tx, input) {
|
|
|
66
66
|
break;
|
|
67
67
|
}
|
|
68
68
|
var _a = __read(tx.moveCall({
|
|
69
|
-
target: "".concat(
|
|
69
|
+
target: "".concat(input.typusTokenType.split("::")[0], "::").concat(input.typusTokenType.split("::")[1], "::mint"),
|
|
70
70
|
arguments: [
|
|
71
71
|
tx.object(typusTokenRegistry),
|
|
72
72
|
tx.makeMoveVec({ objects: input.coins.map(function (id) { return tx.object(id); }) }),
|
|
@@ -114,7 +114,7 @@ function getTokenCloseStrategyTx(config, tx, input) {
|
|
|
114
114
|
}), 2), d_token = _a[0], b_token = _a[1];
|
|
115
115
|
if (input.typeArguments[0] == input.typusTokenType) {
|
|
116
116
|
var token = tx.moveCall({
|
|
117
|
-
target: "".concat(
|
|
117
|
+
target: "".concat(input.typusTokenType.split("::")[0], "::").concat(input.typusTokenType.split("::")[1], "::burn"),
|
|
118
118
|
arguments: [tx.object(typusTokenRegistry), d_token],
|
|
119
119
|
});
|
|
120
120
|
tx.transferObjects([tx.object(token)], input.user);
|
|
@@ -124,7 +124,7 @@ function getTokenCloseStrategyTx(config, tx, input) {
|
|
|
124
124
|
}
|
|
125
125
|
if (input.typeArguments[1] == input.typusTokenType) {
|
|
126
126
|
var token = tx.moveCall({
|
|
127
|
-
target: "".concat(
|
|
127
|
+
target: "".concat(input.typusTokenType.split("::")[0], "::").concat(input.typusTokenType.split("::")[1], "::burn"),
|
|
128
128
|
arguments: [tx.object(typusTokenRegistry), b_token],
|
|
129
129
|
});
|
|
130
130
|
tx.transferObjects([tx.object(token)], input.user);
|
|
@@ -157,7 +157,7 @@ function getTokenWithdrawProfitStrategyTx(config, tx, input) {
|
|
|
157
157
|
});
|
|
158
158
|
if (input.typeArguments[0] == input.typusTokenType) {
|
|
159
159
|
var token = tx.moveCall({
|
|
160
|
-
target: "".concat(
|
|
160
|
+
target: "".concat(input.typusTokenType.split("::")[0], "::").concat(input.typusTokenType.split("::")[1], "::burn"),
|
|
161
161
|
arguments: [tx.object(typusTokenRegistry), d_token],
|
|
162
162
|
});
|
|
163
163
|
tx.transferObjects([tx.object(token)], input.user);
|
|
@@ -45,6 +45,8 @@ export declare const tokenType: {
|
|
|
45
45
|
BTC: string;
|
|
46
46
|
ETH: string;
|
|
47
47
|
USDC: string;
|
|
48
|
+
BLUB: string;
|
|
49
|
+
MBLUB: string;
|
|
48
50
|
};
|
|
49
51
|
};
|
|
50
52
|
export type TOKEN = "SUI" | "CETUS" | "BUCK" | "SOL" | "TURBOS" | "APT" | "FUD" | "MFUD" | "USDT" | "AFSUI" | "INJ" | "SEI" | "USDY" | "TEXP" | "SCA" | "BTC" | "ETH" | "USDC";
|
|
@@ -144,6 +144,8 @@ exports.tokenType = {
|
|
|
144
144
|
BTC: "0x949572061c09bbedef3ac4ffc42e58632291616f0605117cec86d840e09bf519::btc::BTC",
|
|
145
145
|
ETH: "0x949572061c09bbedef3ac4ffc42e58632291616f0605117cec86d840e09bf519::eth::ETH",
|
|
146
146
|
USDC: "0x949572061c09bbedef3ac4ffc42e58632291616f0605117cec86d840e09bf519::usdc::USDC",
|
|
147
|
+
BLUB: "0x94b8f6dcceeb2be160f6837089cc7502458f4f070fa0814380737acb0c41fd5b::blub::BLUB",
|
|
148
|
+
MBLUB: "0x4b5d0a097ee8a309a89bb2bc589403a4a9a39de639d576495b697be2a60f69bb::mblub::MBLUB",
|
|
147
149
|
},
|
|
148
150
|
};
|
|
149
151
|
function typeArgToToken(typeArg) {
|
package/dist/src/dice/index.d.ts
CHANGED
package/dist/src/dice/index.js
CHANGED
|
@@ -16,5 +16,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./api"), exports);
|
|
18
18
|
__exportStar(require("./user-entry"), exports);
|
|
19
|
-
__exportStar(require("./view-function"), exports);
|
|
20
19
|
__exportStar(require("./fetch"), exports);
|
|
@@ -1,21 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export interface DrawResult {
|
|
3
|
-
answer_1: string;
|
|
4
|
-
result_1: string;
|
|
5
|
-
answer_2: string;
|
|
6
|
-
result_2: string;
|
|
7
|
-
exp: string;
|
|
8
|
-
}
|
|
9
|
-
export declare function simulateGame(config: TypusConfig, input: {
|
|
10
|
-
network: "mainnet" | "testnet";
|
|
11
|
-
module: "tails_exp" | "combo_dice";
|
|
12
|
-
index: string;
|
|
13
|
-
amount: string;
|
|
14
|
-
guess_1: string;
|
|
15
|
-
larger_than_1: boolean;
|
|
16
|
-
guess_2: string;
|
|
17
|
-
larger_than_2: boolean;
|
|
18
|
-
vrf_input_1: number[];
|
|
19
|
-
vrf_input_2: number[];
|
|
20
|
-
drawKeys: any;
|
|
21
|
-
}): Promise<DrawResult>;
|
|
1
|
+
export {};
|
|
@@ -1,124 +1,5 @@
|
|
|
1
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
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
-
};
|
|
41
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
exports.simulateGame = simulateGame;
|
|
43
|
-
var transactions_1 = require("@mysten/sui.js/transactions");
|
|
44
|
-
var client_1 = require("@mysten/sui.js/client");
|
|
45
|
-
var bcs_1 = require("@mysten/bcs");
|
|
46
|
-
var bls_signatures_1 = __importDefault(require("bls-signatures"));
|
|
47
|
-
var constants_1 = require("../../src/constants");
|
|
48
|
-
function simulateGame(config, input) {
|
|
49
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
50
|
-
var provider, transactionBlock, BLS, PRIVATE_KEY, draw_private_key, bls_signature_1, bls_signature_2, registry, results, bytes, reader, answer_1, result_1, answer_2, result_2, exp, result;
|
|
51
|
-
return __generator(this, function (_a) {
|
|
52
|
-
switch (_a.label) {
|
|
53
|
-
case 0:
|
|
54
|
-
provider = new client_1.SuiClient({ url: config.rpcEndpoint });
|
|
55
|
-
transactionBlock = new transactions_1.TransactionBlock();
|
|
56
|
-
return [4 /*yield*/, (0, bls_signatures_1.default)()];
|
|
57
|
-
case 1:
|
|
58
|
-
BLS = _a.sent();
|
|
59
|
-
PRIVATE_KEY = Uint8Array.from(input.drawKeys[input.network][input.index]);
|
|
60
|
-
draw_private_key = BLS.PrivateKey.from_bytes(PRIVATE_KEY, true);
|
|
61
|
-
bls_signature_1 = BLS.BasicSchemeMPL.sign(draw_private_key, Uint8Array.from(input.vrf_input_1)).serialize();
|
|
62
|
-
bls_signature_2 = BLS.BasicSchemeMPL.sign(draw_private_key, Uint8Array.from(input.vrf_input_2)).serialize();
|
|
63
|
-
registry = "";
|
|
64
|
-
switch (input.module) {
|
|
65
|
-
case "tails_exp":
|
|
66
|
-
registry = config.registry.dice.tailsExp;
|
|
67
|
-
break;
|
|
68
|
-
case "combo_dice":
|
|
69
|
-
registry = config.registry.dice.comboDice;
|
|
70
|
-
break;
|
|
71
|
-
default:
|
|
72
|
-
break;
|
|
73
|
-
}
|
|
74
|
-
transactionBlock.moveCall({
|
|
75
|
-
target: "".concat(config.package.dice, "::").concat(input.module, "::simulate_game"),
|
|
76
|
-
typeArguments: [],
|
|
77
|
-
arguments: [
|
|
78
|
-
transactionBlock.object(registry),
|
|
79
|
-
transactionBlock.pure(input.index),
|
|
80
|
-
transactionBlock.pure(input.amount),
|
|
81
|
-
transactionBlock.pure(input.guess_1),
|
|
82
|
-
transactionBlock.pure(input.larger_than_1),
|
|
83
|
-
transactionBlock.pure(input.guess_2),
|
|
84
|
-
transactionBlock.pure(input.larger_than_2),
|
|
85
|
-
transactionBlock.pure(uint8ArrayToBCSStringArray(Uint8Array.from(input.vrf_input_1))),
|
|
86
|
-
transactionBlock.pure(uint8ArrayToBCSStringArray(Uint8Array.from(input.vrf_input_2))),
|
|
87
|
-
transactionBlock.pure(uint8ArrayToBCSStringArray(bls_signature_1)),
|
|
88
|
-
transactionBlock.pure(uint8ArrayToBCSStringArray(bls_signature_2)),
|
|
89
|
-
],
|
|
90
|
-
});
|
|
91
|
-
return [4 /*yield*/, provider.devInspectTransactionBlock({ transactionBlock: transactionBlock, sender: constants_1.SENDER })];
|
|
92
|
-
case 2:
|
|
93
|
-
results = (_a.sent()).results;
|
|
94
|
-
bytes = results[results.length - 1].returnValues[0][0];
|
|
95
|
-
reader = new bcs_1.BcsReader(new Uint8Array(bytes));
|
|
96
|
-
// vector[
|
|
97
|
-
// answer_1,
|
|
98
|
-
// result_1,
|
|
99
|
-
// answer_2,
|
|
100
|
-
// result_2,
|
|
101
|
-
// exp
|
|
102
|
-
// ]
|
|
103
|
-
// skip vector length byte first
|
|
104
|
-
reader.read8();
|
|
105
|
-
answer_1 = reader.read64();
|
|
106
|
-
result_1 = reader.read64();
|
|
107
|
-
answer_2 = reader.read64();
|
|
108
|
-
result_2 = reader.read64();
|
|
109
|
-
exp = reader.read64();
|
|
110
|
-
result = {
|
|
111
|
-
answer_1: answer_1,
|
|
112
|
-
result_1: result_1,
|
|
113
|
-
answer_2: answer_2,
|
|
114
|
-
result_2: result_2,
|
|
115
|
-
exp: exp,
|
|
116
|
-
};
|
|
117
|
-
return [2 /*return*/, result];
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
3
|
function uint8ArrayToBCSStringArray(uint8Array) {
|
|
123
4
|
var result = [];
|
|
124
5
|
for (var i = 0; i < uint8Array.length; i++) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { EventId, SuiClient, SuiEvent } from "@mysten/sui.js/client";
|
|
2
2
|
import { Vault } from "../../../src/typus-dov-single-v2";
|
|
3
|
+
export { getNewBidFromSentio, getExerciseFromSentio } from "../../../src/utils/api/sentio/events";
|
|
3
4
|
export declare function getUserEvents(provider: SuiClient, sender: string, cursor?: EventId | null): Promise<[SuiEvent[], EventId | null | undefined]>;
|
|
4
5
|
export declare function getAutoBidEvents(provider: SuiClient, originPackage: string, startTimeMs: number): Promise<SuiEvent[]>;
|
|
5
6
|
export interface TxHistory {
|
|
@@ -17,13 +18,9 @@ export interface TxHistory {
|
|
|
17
18
|
export declare function parseTxHistory(datas: Array<any>, originPackage: string, vaults: {
|
|
18
19
|
[key: string]: Vault;
|
|
19
20
|
}): Promise<Array<TxHistory>>;
|
|
20
|
-
export declare function
|
|
21
|
-
export declare function getNewBidFromSentio(vaults: {
|
|
21
|
+
export declare function parseVaultInfo(vaults: {
|
|
22
22
|
[key: string]: Vault;
|
|
23
|
-
},
|
|
24
|
-
export declare function getExerciseFromSentio(vaults: {
|
|
25
|
-
[key: string]: Vault;
|
|
26
|
-
}, userAddress: string, startTimestamp: number): Promise<any>;
|
|
23
|
+
}, Index: string, action: string): (string | undefined)[];
|
|
27
24
|
export declare function getDepositorCashFlows(userHistory: TxHistory[]): Map<string, DepositorCashFlow>;
|
|
28
25
|
export interface DepositorCashFlow {
|
|
29
26
|
D_TOKEN: string | undefined;
|
|
@@ -66,15 +66,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
66
66
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
67
67
|
};
|
|
68
68
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
69
|
+
exports.getExerciseFromSentio = exports.getNewBidFromSentio = void 0;
|
|
69
70
|
exports.getUserEvents = getUserEvents;
|
|
70
71
|
exports.getAutoBidEvents = getAutoBidEvents;
|
|
71
72
|
exports.parseTxHistory = parseTxHistory;
|
|
72
|
-
exports.
|
|
73
|
-
exports.getNewBidFromSentio = getNewBidFromSentio;
|
|
74
|
-
exports.getExerciseFromSentio = getExerciseFromSentio;
|
|
73
|
+
exports.parseVaultInfo = parseVaultInfo;
|
|
75
74
|
exports.getDepositorCashFlows = getDepositorCashFlows;
|
|
76
75
|
var constants_1 = require("../../../src/constants");
|
|
77
76
|
var bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
77
|
+
var events_1 = require("../../../src/utils/api/sentio/events");
|
|
78
|
+
Object.defineProperty(exports, "getNewBidFromSentio", { enumerable: true, get: function () { return events_1.getNewBidFromSentio; } });
|
|
79
|
+
Object.defineProperty(exports, "getExerciseFromSentio", { enumerable: true, get: function () { return events_1.getExerciseFromSentio; } });
|
|
78
80
|
function getUserEvents(provider, sender, cursor) {
|
|
79
81
|
return __awaiter(this, void 0, void 0, function () {
|
|
80
82
|
var senderFilter, hasNextPage, datas, result;
|
|
@@ -180,7 +182,7 @@ function parseTxHistory(datas, originPackage, vaults) {
|
|
|
180
182
|
Tails = undefined;
|
|
181
183
|
Index = event.parsedJson.index || event.parsedJson.vault_index;
|
|
182
184
|
if (Index) {
|
|
183
|
-
_a = __read(parseVaultInfo(vaults, Index, action
|
|
185
|
+
_a = __read(parseVaultInfo(vaults, Index, action), 6), Period = _a[0], Vault = _a[1], RiskLevel = _a[2], d_token = _a[3], b_token = _a[4], o_token = _a[5];
|
|
184
186
|
}
|
|
185
187
|
switch (action) {
|
|
186
188
|
// new version events
|
|
@@ -314,7 +316,7 @@ function parseTxHistory(datas, originPackage, vaults) {
|
|
|
314
316
|
break;
|
|
315
317
|
case "RaiseFundEvent":
|
|
316
318
|
Index = event.parsedJson.log[0];
|
|
317
|
-
_b = __read(parseVaultInfo(vaults, Index, action
|
|
319
|
+
_b = __read(parseVaultInfo(vaults, Index, action), 6), Period = _b[0], Vault = _b[1], RiskLevel = _b[2], d_token = _b[3], b_token = _b[4], o_token = _b[5];
|
|
318
320
|
token = (0, constants_1.typeArgToAsset)("0x" + event.parsedJson.token.name);
|
|
319
321
|
if (event.parsedJson.log[4] > 0) {
|
|
320
322
|
// deposit
|
|
@@ -331,7 +333,7 @@ function parseTxHistory(datas, originPackage, vaults) {
|
|
|
331
333
|
break;
|
|
332
334
|
case "ReduceFundEvent":
|
|
333
335
|
Index = event.parsedJson.log[0];
|
|
334
|
-
_c = __read(parseVaultInfo(vaults, Index, action
|
|
336
|
+
_c = __read(parseVaultInfo(vaults, Index, action), 6), Period = _c[0], Vault = _c[1], RiskLevel = _c[2], d_token = _c[3], b_token = _c[4], o_token = _c[5];
|
|
335
337
|
if (event.parsedJson.log[4] > 0) {
|
|
336
338
|
// withdraw
|
|
337
339
|
Action = "Withdraw";
|
|
@@ -574,146 +576,7 @@ function parseTxHistory(datas, originPackage, vaults) {
|
|
|
574
576
|
});
|
|
575
577
|
});
|
|
576
578
|
}
|
|
577
|
-
function
|
|
578
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
579
|
-
var apiUrl, headers, requestData, jsonData, response, data;
|
|
580
|
-
return __generator(this, function (_a) {
|
|
581
|
-
switch (_a.label) {
|
|
582
|
-
case 0:
|
|
583
|
-
apiUrl = "https://app.sentio.xyz/api/v1/analytics/typus/typus_v2/sql/execute";
|
|
584
|
-
headers = {
|
|
585
|
-
"api-key": "tz3JJ6stG7Fux6ueRSRA5mdpC9U0lozI3",
|
|
586
|
-
"Content-Type": "application/json",
|
|
587
|
-
};
|
|
588
|
-
requestData = {
|
|
589
|
-
sqlQuery: {
|
|
590
|
-
sql: "\n SELECT *\n FROM ".concat(event, "\n WHERE distinct_id = \"").concat(userAddress, "\" && timestamp >= ").concat(startTimestamp, "\n ORDER BY timestamp DESC;\n "),
|
|
591
|
-
size: 1000,
|
|
592
|
-
},
|
|
593
|
-
};
|
|
594
|
-
jsonData = JSON.stringify(requestData);
|
|
595
|
-
return [4 /*yield*/, fetch(apiUrl, {
|
|
596
|
-
method: "POST",
|
|
597
|
-
headers: headers,
|
|
598
|
-
body: jsonData,
|
|
599
|
-
})];
|
|
600
|
-
case 1:
|
|
601
|
-
response = _a.sent();
|
|
602
|
-
return [4 /*yield*/, response.json()];
|
|
603
|
-
case 2:
|
|
604
|
-
data = _a.sent();
|
|
605
|
-
return [2 /*return*/, data.result.rows];
|
|
606
|
-
}
|
|
607
|
-
});
|
|
608
|
-
});
|
|
609
|
-
}
|
|
610
|
-
function getNewBidFromSentio(vaults, userAddress, startTimestamp) {
|
|
611
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
612
|
-
var apiUrl, headers, requestData, jsonData, response, data;
|
|
613
|
-
return __generator(this, function (_a) {
|
|
614
|
-
switch (_a.label) {
|
|
615
|
-
case 0:
|
|
616
|
-
apiUrl = "https://app.sentio.xyz/api/v1/analytics/typus/typus_v2/sql/execute";
|
|
617
|
-
headers = {
|
|
618
|
-
"api-key": "tz3JJ6stG7Fux6ueRSRA5mdpC9U0lozI3",
|
|
619
|
-
"Content-Type": "application/json",
|
|
620
|
-
};
|
|
621
|
-
requestData = {
|
|
622
|
-
sqlQuery: {
|
|
623
|
-
sql: "\n SELECT *\n FROM NewBid N\n LEFT JOIN (\n SELECT number, distinct_id, exp_earn, transaction_hash, log_index\n FROM ExpUp\n ) S ON N.transaction_hash = S.transaction_hash && N.log_index + 1 = S.log_index\n WHERE N.distinct_id = \"".concat(userAddress, "\" && N.timestamp >= ").concat(startTimestamp, "\n ORDER BY N.timestamp DESC;\n "),
|
|
624
|
-
size: 1000,
|
|
625
|
-
},
|
|
626
|
-
};
|
|
627
|
-
jsonData = JSON.stringify(requestData);
|
|
628
|
-
return [4 /*yield*/, fetch(apiUrl, {
|
|
629
|
-
method: "POST",
|
|
630
|
-
headers: headers,
|
|
631
|
-
body: jsonData,
|
|
632
|
-
})];
|
|
633
|
-
case 1:
|
|
634
|
-
response = _a.sent();
|
|
635
|
-
return [4 /*yield*/, response.json()];
|
|
636
|
-
case 2:
|
|
637
|
-
data = _a.sent();
|
|
638
|
-
return [2 /*return*/, data.result.rows.map(function (x) {
|
|
639
|
-
var _a = __read(parseVaultInfo(vaults, x.index, "NewBidEvent"), 6), Period = _a[0], Vault = _a[1], RiskLevel = _a[2], d_token = _a[3], b_token = _a[4], o_token = _a[5];
|
|
640
|
-
if (x.number == "0" && x.exp_earn == "0") {
|
|
641
|
-
x.number = undefined;
|
|
642
|
-
x.exp_earn = undefined;
|
|
643
|
-
}
|
|
644
|
-
var txHistory = {
|
|
645
|
-
Index: x.index,
|
|
646
|
-
Period: Period,
|
|
647
|
-
Vault: Vault,
|
|
648
|
-
RiskLevel: RiskLevel,
|
|
649
|
-
Action: "Auto Bid" + " ".concat(x.size, " ").concat(x.o_token),
|
|
650
|
-
Amount: x.bidder_balance + " ".concat(x.b_token),
|
|
651
|
-
Tails: x.number,
|
|
652
|
-
Exp: x.exp_earn,
|
|
653
|
-
Date: new Date(Number(x.ts_ms)),
|
|
654
|
-
txDigest: x.transaction_hash,
|
|
655
|
-
};
|
|
656
|
-
return txHistory;
|
|
657
|
-
})];
|
|
658
|
-
}
|
|
659
|
-
});
|
|
660
|
-
});
|
|
661
|
-
}
|
|
662
|
-
function getExerciseFromSentio(vaults, userAddress, startTimestamp) {
|
|
663
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
664
|
-
var apiUrl, headers, requestData, jsonData, response, data;
|
|
665
|
-
return __generator(this, function (_a) {
|
|
666
|
-
switch (_a.label) {
|
|
667
|
-
case 0:
|
|
668
|
-
apiUrl = "https://app.sentio.xyz/api/v1/analytics/typus/typus_v2/sql/execute";
|
|
669
|
-
headers = {
|
|
670
|
-
"api-key": "tz3JJ6stG7Fux6ueRSRA5mdpC9U0lozI3",
|
|
671
|
-
"Content-Type": "application/json",
|
|
672
|
-
};
|
|
673
|
-
requestData = {
|
|
674
|
-
sqlQuery: {
|
|
675
|
-
sql: "\n SELECT *\n FROM Exercise N\n WHERE N.distinct_id = \"".concat(userAddress, "\" && N.timestamp >= ").concat(startTimestamp, "\n ORDER BY N.timestamp DESC;\n "),
|
|
676
|
-
size: 1000,
|
|
677
|
-
},
|
|
678
|
-
};
|
|
679
|
-
jsonData = JSON.stringify(requestData);
|
|
680
|
-
return [4 /*yield*/, fetch(apiUrl, {
|
|
681
|
-
method: "POST",
|
|
682
|
-
headers: headers,
|
|
683
|
-
body: jsonData,
|
|
684
|
-
})];
|
|
685
|
-
case 1:
|
|
686
|
-
response = _a.sent();
|
|
687
|
-
return [4 /*yield*/, response.json()];
|
|
688
|
-
case 2:
|
|
689
|
-
data = _a.sent();
|
|
690
|
-
return [2 /*return*/, data.result.rows.map(function (x) {
|
|
691
|
-
var _a = __read(parseVaultInfo(vaults, x.index, "ExerciseEvent"), 6), Period = _a[0], Vault = _a[1], RiskLevel = _a[2], d_token = _a[3], b_token = _a[4], o_token = _a[5];
|
|
692
|
-
// console.log(x);
|
|
693
|
-
var Action = "Auto Exercise";
|
|
694
|
-
if (x.raw_share) {
|
|
695
|
-
var size = Number(x.raw_share) / Math.pow(10, (0, constants_1.assetToDecimal)(o_token));
|
|
696
|
-
Action = "Auto Exercise ".concat(size, " ").concat(o_token);
|
|
697
|
-
}
|
|
698
|
-
var txHistory = {
|
|
699
|
-
Index: x.index,
|
|
700
|
-
Period: Period,
|
|
701
|
-
Vault: Vault,
|
|
702
|
-
RiskLevel: RiskLevel,
|
|
703
|
-
Action: Action,
|
|
704
|
-
Amount: "".concat(x.amount, " ").concat(x.coin_symbol),
|
|
705
|
-
Tails: x.number,
|
|
706
|
-
Exp: x.exp_earn,
|
|
707
|
-
Date: new Date(x.timestamp),
|
|
708
|
-
txDigest: x.transaction_hash,
|
|
709
|
-
};
|
|
710
|
-
return txHistory;
|
|
711
|
-
})];
|
|
712
|
-
}
|
|
713
|
-
});
|
|
714
|
-
});
|
|
715
|
-
}
|
|
716
|
-
function parseVaultInfo(vaults, Index, action, eventLog) {
|
|
579
|
+
function parseVaultInfo(vaults, Index, action) {
|
|
717
580
|
var v = vaults[Index];
|
|
718
581
|
var Period;
|
|
719
582
|
var Vault;
|
|
@@ -10,17 +10,17 @@ export interface VaultHistory {
|
|
|
10
10
|
vaultIndex: string;
|
|
11
11
|
round: string;
|
|
12
12
|
ActivationDate: Date;
|
|
13
|
-
MaxSize: number;
|
|
14
13
|
SettlementTime: Date;
|
|
15
14
|
StrikePrice: number[] | undefined;
|
|
16
15
|
SettlePrice: number;
|
|
17
|
-
|
|
16
|
+
ActualReturn: number;
|
|
17
|
+
TotalAuctioned: number;
|
|
18
18
|
Filled: number;
|
|
19
19
|
DeliverySize: number;
|
|
20
20
|
DeliveryPrice: number;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
DepositorsRewards: number;
|
|
22
|
+
BiddersPayoff: number;
|
|
23
|
+
DepositorPnl: number;
|
|
24
24
|
ActivateTx: string | undefined;
|
|
25
25
|
NewAuctionTx: string | undefined;
|
|
26
26
|
DeliveryTx: string | undefined;
|
|
@@ -259,17 +259,17 @@ function getVaultHistoryFromDB(index, startTs, endTs, rounds) {
|
|
|
259
259
|
vaultIndex: index_1,
|
|
260
260
|
round: round,
|
|
261
261
|
ActivationDate: new Date(Number(data.activation_date)),
|
|
262
|
-
|
|
262
|
+
TotalAuctioned: data.max_size,
|
|
263
263
|
SettlementTime: new Date(Number(data.settle_date)),
|
|
264
264
|
StrikePrice: data.strikes || undefined,
|
|
265
265
|
SettlePrice: data.settle_price,
|
|
266
|
-
|
|
266
|
+
ActualReturn: data.return,
|
|
267
267
|
Filled: Number(data.delivery_size) == 0 ? 0 : Number(data.delivery_size) / Number(data.max_size),
|
|
268
268
|
DeliverySize: data.delivery_size,
|
|
269
269
|
DeliveryPrice: data.delivery_price,
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
270
|
+
DepositorsRewards: data.paid_to_depositors,
|
|
271
|
+
BiddersPayoff: data.paid_to_bidders,
|
|
272
|
+
DepositorPnl: data.paid_to_depositors - data.paid_to_bidders,
|
|
273
273
|
ActivateTx: data.activation_tx,
|
|
274
274
|
NewAuctionTx: data.new_auction_tx,
|
|
275
275
|
DeliveryTx: data.delivery_tx,
|
|
@@ -303,7 +303,7 @@ function getVaultHistoryFromDB(index, startTs, endTs, rounds) {
|
|
|
303
303
|
}
|
|
304
304
|
function convertGroupEventToVaultHistory(groupEvent) {
|
|
305
305
|
return __awaiter(this, void 0, void 0, function () {
|
|
306
|
-
var ActivationMs, SettlementTsMs, b_token, o_token, bidder_bid_value, bidder_fee, delivery_price, delivery_size, incentive_bid_value, incentive_fee,
|
|
306
|
+
var ActivationMs, SettlementTsMs, b_token, o_token, bidder_bid_value, bidder_fee, delivery_price, delivery_size, incentive_bid_value, incentive_fee, DepositorsRewards, BiddersPayoff, result;
|
|
307
307
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
308
308
|
return __generator(this, function (_t) {
|
|
309
309
|
ActivationMs = Number((_a = groupEvent.activateEvent) === null || _a === void 0 ? void 0 : _a.timestampMs);
|
|
@@ -317,8 +317,8 @@ function convertGroupEventToVaultHistory(groupEvent) {
|
|
|
317
317
|
delivery_size = Number(groupEvent.deliveryEvent.delivery_size) / Math.pow(10, (0, constants_1.assetToDecimal)(o_token));
|
|
318
318
|
incentive_bid_value = Number(groupEvent.deliveryEvent.incentive_bid_value) / Math.pow(10, (0, constants_1.assetToDecimal)(b_token));
|
|
319
319
|
incentive_fee = Number(groupEvent.deliveryEvent.incentive_fee) / Math.pow(10, (0, constants_1.assetToDecimal)(b_token));
|
|
320
|
-
|
|
321
|
-
|
|
320
|
+
DepositorsRewards = bidder_bid_value + bidder_fee + incentive_bid_value + incentive_fee;
|
|
321
|
+
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)) /
|
|
322
322
|
Math.pow(10, Number((_e = groupEvent.settleEvent) === null || _e === void 0 ? void 0 : _e.d_token_decimal));
|
|
323
323
|
result = {
|
|
324
324
|
vaultIndex: (_f = groupEvent.activateEvent) === null || _f === void 0 ? void 0 : _f.index,
|
|
@@ -326,7 +326,7 @@ function convertGroupEventToVaultHistory(groupEvent) {
|
|
|
326
326
|
// activateEvent
|
|
327
327
|
ActivateTx: (_h = groupEvent.activateEvent) === null || _h === void 0 ? void 0 : _h.txDigest,
|
|
328
328
|
ActivationDate: new Date(ActivationMs - (ActivationMs % 3600000)),
|
|
329
|
-
|
|
329
|
+
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)),
|
|
330
330
|
// newAuctionEvent
|
|
331
331
|
NewAuctionTx: (_l = groupEvent.newAuctionEvent) === null || _l === void 0 ? void 0 : _l.txDigest,
|
|
332
332
|
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); }),
|
|
@@ -335,16 +335,16 @@ function convertGroupEventToVaultHistory(groupEvent) {
|
|
|
335
335
|
DeliverySize: delivery_size,
|
|
336
336
|
DeliveryPrice: delivery_price,
|
|
337
337
|
Filled: delivery_size == 0 ? 0 : Number(groupEvent.deliveryEvent.delivery_size) / Number((_o = groupEvent.newAuctionEvent) === null || _o === void 0 ? void 0 : _o.size),
|
|
338
|
-
|
|
338
|
+
DepositorsRewards: DepositorsRewards,
|
|
339
339
|
// recoupEvent
|
|
340
340
|
RecoupTx: (_p = groupEvent.recoupEvent) === null || _p === void 0 ? void 0 : _p.txDigest,
|
|
341
341
|
// settleEvent
|
|
342
342
|
SettleTx: (_q = groupEvent.settleEvent) === null || _q === void 0 ? void 0 : _q.txDigest,
|
|
343
343
|
SettlementTime: new Date(SettlementTsMs - (SettlementTsMs % 3600000)),
|
|
344
344
|
SettlePrice: Number((_r = groupEvent.settleEvent) === null || _r === void 0 ? void 0 : _r.oracle_price) / Math.pow(10, 8),
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
345
|
+
ActualReturn: Number((_s = groupEvent.settleEvent) === null || _s === void 0 ? void 0 : _s.share_price) / Math.pow(10, 8) - 1,
|
|
346
|
+
BiddersPayoff: BiddersPayoff,
|
|
347
|
+
DepositorPnl: DepositorsRewards - BiddersPayoff,
|
|
348
348
|
};
|
|
349
349
|
return [2 /*return*/, result];
|
|
350
350
|
}
|
|
@@ -23,7 +23,7 @@ function getTokenRaiseFundTx(config, tx, input) {
|
|
|
23
23
|
typeArguments: [input.typusTokenType],
|
|
24
24
|
arguments: [
|
|
25
25
|
tx.object(tx.moveCall({
|
|
26
|
-
target: "".concat(
|
|
26
|
+
target: "".concat(input.typusTokenType.split("::")[0], "::").concat(input.typusTokenType.split("::")[1], "::mint"),
|
|
27
27
|
arguments: [
|
|
28
28
|
tx.object(typusTokenRegistry),
|
|
29
29
|
tx.makeMoveVec({ objects: input.raiseCoins }),
|
|
@@ -101,7 +101,7 @@ function getTokenReduceFundTx(config, tx, input) {
|
|
|
101
101
|
arguments: [tx.object(result[1])],
|
|
102
102
|
});
|
|
103
103
|
var token = tx.moveCall({
|
|
104
|
-
target: "".concat(
|
|
104
|
+
target: "".concat(input.typusTokenType.split("::")[0], "::").concat(input.typusTokenType.split("::")[1], "::burn"),
|
|
105
105
|
arguments: [tx.object(typusTokenRegistry), tx.object(typusToken)],
|
|
106
106
|
});
|
|
107
107
|
tx.transferObjects([tx.object(token)], input.user);
|
|
@@ -120,7 +120,7 @@ function getTokenReduceFundTx(config, tx, input) {
|
|
|
120
120
|
arguments: [tx.object(result[2])],
|
|
121
121
|
});
|
|
122
122
|
var token = tx.moveCall({
|
|
123
|
-
target: "".concat(
|
|
123
|
+
target: "".concat(input.typusTokenType.split("::")[0], "::").concat(input.typusTokenType.split("::")[1], "::burn"),
|
|
124
124
|
arguments: [tx.object(typusTokenRegistry), tx.object(typusToken)],
|
|
125
125
|
});
|
|
126
126
|
tx.transferObjects([tx.object(token)], input.user);
|
|
@@ -139,7 +139,7 @@ function getTokenReduceFundTx(config, tx, input) {
|
|
|
139
139
|
arguments: [tx.object(result[3])],
|
|
140
140
|
});
|
|
141
141
|
var token = tx.moveCall({
|
|
142
|
-
target: "".concat(
|
|
142
|
+
target: "".concat(input.typusTokenType.split("::")[0], "::").concat(input.typusTokenType.split("::")[1], "::burn"),
|
|
143
143
|
arguments: [tx.object(typusTokenRegistry), tx.object(typusToken)],
|
|
144
144
|
});
|
|
145
145
|
tx.transferObjects([tx.object(token)], input.user);
|
|
@@ -164,7 +164,7 @@ function getTokenNewBidTx(config, tx, input) {
|
|
|
164
164
|
break;
|
|
165
165
|
}
|
|
166
166
|
var mToken = tx.moveCall({
|
|
167
|
-
target: "".concat(
|
|
167
|
+
target: "".concat(input.typusTokenType.split("::")[0], "::").concat(input.typusTokenType.split("::")[1], "::mint"),
|
|
168
168
|
arguments: [
|
|
169
169
|
tx.object(typusTokenRegistry),
|
|
170
170
|
tx.makeMoveVec({ objects: input.coins.map(function (id) { return tx.object(id); }) }),
|
|
@@ -188,7 +188,7 @@ function getTokenNewBidTx(config, tx, input) {
|
|
|
188
188
|
});
|
|
189
189
|
tx.transferObjects([tx.object(result[0])], input.user);
|
|
190
190
|
var fud_coin = tx.moveCall({
|
|
191
|
-
target: "".concat(
|
|
191
|
+
target: "".concat(input.typusTokenType.split("::")[0], "::").concat(input.typusTokenType.split("::")[1], "::burn"),
|
|
192
192
|
arguments: [tx.object(typusTokenRegistry), tx.object(result[1])],
|
|
193
193
|
});
|
|
194
194
|
tx.transferObjects([tx.object(fud_coin)], input.user);
|
|
@@ -222,7 +222,7 @@ function getTokenExerciseTx(config, tx, input) {
|
|
|
222
222
|
arguments: [tx.object(result[0])],
|
|
223
223
|
});
|
|
224
224
|
var token = tx.moveCall({
|
|
225
|
-
target: "".concat(
|
|
225
|
+
target: "".concat(input.typusTokenType.split("::")[0], "::").concat(input.typusTokenType.split("::")[1], "::burn"),
|
|
226
226
|
arguments: [tx.object(typusTokenRegistry), tx.object(mToken)],
|
|
227
227
|
});
|
|
228
228
|
tx.transferObjects([tx.object(token)], input.user);
|
|
@@ -254,7 +254,7 @@ function getTokenRebateTx(config, tx, input) {
|
|
|
254
254
|
arguments: [tx.object(balance)],
|
|
255
255
|
});
|
|
256
256
|
var token = tx.moveCall({
|
|
257
|
-
target: "".concat(
|
|
257
|
+
target: "".concat(input.typusTokenType.split("::")[0], "::").concat(input.typusTokenType.split("::")[1], "::burn"),
|
|
258
258
|
arguments: [tx.object(typusTokenRegistry), tx.object(mToken)],
|
|
259
259
|
});
|
|
260
260
|
tx.transferObjects([tx.object(token)], input.user);
|
|
@@ -65,7 +65,7 @@ exports.NETWORK = process.env.CLUSTER == "mainnet" ? "MAINNET" : "TESTNET";
|
|
|
65
65
|
var PACKAGE_ID = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
66
66
|
return __generator(this, function (_a) {
|
|
67
67
|
switch (_a.label) {
|
|
68
|
-
case 0: return [4 /*yield*/, utils_1.TypusConfig.default(exports.NETWORK)];
|
|
68
|
+
case 0: return [4 /*yield*/, utils_1.TypusConfig.default(exports.NETWORK, null)];
|
|
69
69
|
case 1: return [2 /*return*/, (_a.sent()).packageOrigin.perp];
|
|
70
70
|
}
|
|
71
71
|
});
|
|
@@ -75,7 +75,7 @@ exports.PACKAGE_ID = PACKAGE_ID;
|
|
|
75
75
|
var PUBLISHED_AT = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
76
76
|
return __generator(this, function (_a) {
|
|
77
77
|
switch (_a.label) {
|
|
78
|
-
case 0: return [4 /*yield*/, utils_1.TypusConfig.default(exports.NETWORK)];
|
|
78
|
+
case 0: return [4 /*yield*/, utils_1.TypusConfig.default(exports.NETWORK, null)];
|
|
79
79
|
case 1: return [2 /*return*/, (_a.sent()).package.perp];
|
|
80
80
|
}
|
|
81
81
|
});
|
|
@@ -42,7 +42,7 @@ function getTvl() {
|
|
|
42
42
|
var response, data;
|
|
43
43
|
return __generator(this, function (_a) {
|
|
44
44
|
switch (_a.label) {
|
|
45
|
-
case 0: return [4 /*yield*/, fetch("https://api.llama.fi/tvl/typus-
|
|
45
|
+
case 0: return [4 /*yield*/, fetch("https://api.llama.fi/tvl/typus-dov", {
|
|
46
46
|
method: "GET",
|
|
47
47
|
})];
|
|
48
48
|
case 1:
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { TxHistory, Vault } from "../../../../src/typus-dov-single-v2";
|
|
2
|
+
export declare function getFromSentio(event: string, userAddress: string, startTimestamp: string): Promise<any[]>;
|
|
3
|
+
export declare function getFromSentioWithExpUp(event: string, userAddress: string, startTimestamp: string): Promise<any[]>;
|
|
4
|
+
export declare function getNewBidFromSentio(vaults: {
|
|
5
|
+
[key: string]: Vault;
|
|
6
|
+
}, userAddress: string, startTimestamp: number): Promise<TxHistory[]>;
|
|
7
|
+
export declare function getExerciseFromSentio(vaults: {
|
|
8
|
+
[key: string]: Vault;
|
|
9
|
+
}, userAddress: string, startTimestamp: number): Promise<TxHistory[]>;
|
|
@@ -0,0 +1,190 @@
|
|
|
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
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
39
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
40
|
+
if (!m) return o;
|
|
41
|
+
var i = m.call(o), r, ar = [], e;
|
|
42
|
+
try {
|
|
43
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
44
|
+
}
|
|
45
|
+
catch (error) { e = { error: error }; }
|
|
46
|
+
finally {
|
|
47
|
+
try {
|
|
48
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
49
|
+
}
|
|
50
|
+
finally { if (e) throw e.error; }
|
|
51
|
+
}
|
|
52
|
+
return ar;
|
|
53
|
+
};
|
|
54
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
55
|
+
exports.getFromSentio = getFromSentio;
|
|
56
|
+
exports.getFromSentioWithExpUp = getFromSentioWithExpUp;
|
|
57
|
+
exports.getNewBidFromSentio = getNewBidFromSentio;
|
|
58
|
+
exports.getExerciseFromSentio = getExerciseFromSentio;
|
|
59
|
+
var typus_dov_single_v2_1 = require("../../../../src/typus-dov-single-v2");
|
|
60
|
+
var constants_1 = require("../../../../src/constants");
|
|
61
|
+
var headers = {
|
|
62
|
+
"api-key": "tz3JJ6stG7Fux6ueRSRA5mdpC9U0lozI3",
|
|
63
|
+
"Content-Type": "application/json",
|
|
64
|
+
};
|
|
65
|
+
function getFromSentio(event, userAddress, startTimestamp) {
|
|
66
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
67
|
+
var apiUrl, requestData, jsonData, response, data;
|
|
68
|
+
return __generator(this, function (_a) {
|
|
69
|
+
switch (_a.label) {
|
|
70
|
+
case 0:
|
|
71
|
+
apiUrl = "https://app.sentio.xyz/api/v1/analytics/typus/typus_v2/sql/execute";
|
|
72
|
+
requestData = {
|
|
73
|
+
sqlQuery: {
|
|
74
|
+
sql: "\n SELECT *\n FROM ".concat(event, "\n WHERE distinct_id = \"").concat(userAddress, "\" && timestamp >= ").concat(startTimestamp, "\n ORDER BY timestamp DESC;\n "),
|
|
75
|
+
size: 1000,
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
jsonData = JSON.stringify(requestData);
|
|
79
|
+
return [4 /*yield*/, fetch(apiUrl, {
|
|
80
|
+
method: "POST",
|
|
81
|
+
headers: headers,
|
|
82
|
+
body: jsonData,
|
|
83
|
+
})];
|
|
84
|
+
case 1:
|
|
85
|
+
response = _a.sent();
|
|
86
|
+
return [4 /*yield*/, response.json()];
|
|
87
|
+
case 2:
|
|
88
|
+
data = _a.sent();
|
|
89
|
+
// console.log(data);
|
|
90
|
+
return [2 /*return*/, data.result.rows];
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
function getFromSentioWithExpUp(event, userAddress, startTimestamp) {
|
|
96
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
97
|
+
var apiUrl, requestData, jsonData, response, data;
|
|
98
|
+
return __generator(this, function (_a) {
|
|
99
|
+
switch (_a.label) {
|
|
100
|
+
case 0:
|
|
101
|
+
apiUrl = "https://app.sentio.xyz/api/v1/analytics/typus/typus_v2/sql/execute";
|
|
102
|
+
requestData = {
|
|
103
|
+
sqlQuery: {
|
|
104
|
+
sql: "\n SELECT *\n FROM ".concat(event, " N\n LEFT JOIN (\n SELECT number, distinct_id, exp_earn, transaction_hash, log_index\n FROM ExpUp\n ) S ON N.transaction_hash = S.transaction_hash && N.log_index + 1 = S.log_index\n WHERE N.distinct_id = \"").concat(userAddress, "\" && N.timestamp >= ").concat(startTimestamp, "\n ORDER BY N.timestamp DESC;\n "),
|
|
105
|
+
size: 1000,
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
jsonData = JSON.stringify(requestData);
|
|
109
|
+
return [4 /*yield*/, fetch(apiUrl, {
|
|
110
|
+
method: "POST",
|
|
111
|
+
headers: headers,
|
|
112
|
+
body: jsonData,
|
|
113
|
+
})];
|
|
114
|
+
case 1:
|
|
115
|
+
response = _a.sent();
|
|
116
|
+
return [4 /*yield*/, response.json()];
|
|
117
|
+
case 2:
|
|
118
|
+
data = _a.sent();
|
|
119
|
+
// console.log(data);
|
|
120
|
+
return [2 /*return*/, data.result.rows];
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
function getNewBidFromSentio(vaults, userAddress, startTimestamp) {
|
|
126
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
127
|
+
var datas;
|
|
128
|
+
return __generator(this, function (_a) {
|
|
129
|
+
switch (_a.label) {
|
|
130
|
+
case 0: return [4 /*yield*/, getFromSentio("NewBid", userAddress, startTimestamp.toString())];
|
|
131
|
+
case 1:
|
|
132
|
+
datas = _a.sent();
|
|
133
|
+
return [2 /*return*/, datas.map(function (x) {
|
|
134
|
+
var _a = __read((0, typus_dov_single_v2_1.parseVaultInfo)(vaults, x.index, "NewBidEvent"), 6), Period = _a[0], Vault = _a[1], RiskLevel = _a[2], d_token = _a[3], b_token = _a[4], o_token = _a[5];
|
|
135
|
+
if (x.number == "0" && x.exp_earn == "0") {
|
|
136
|
+
x.number = undefined;
|
|
137
|
+
x.exp_earn = undefined;
|
|
138
|
+
}
|
|
139
|
+
var txHistory = {
|
|
140
|
+
Index: x.index,
|
|
141
|
+
Period: Period,
|
|
142
|
+
Vault: Vault,
|
|
143
|
+
RiskLevel: RiskLevel,
|
|
144
|
+
Action: "Auto Bid" + " ".concat(x.size, " ").concat(x.o_token),
|
|
145
|
+
Amount: x.bidder_balance + " ".concat(x.b_token),
|
|
146
|
+
Tails: x.number,
|
|
147
|
+
Exp: x.exp_earn,
|
|
148
|
+
Date: new Date(Number(x.ts_ms)),
|
|
149
|
+
txDigest: x.transaction_hash,
|
|
150
|
+
};
|
|
151
|
+
return txHistory;
|
|
152
|
+
})];
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
function getExerciseFromSentio(vaults, userAddress, startTimestamp) {
|
|
158
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
159
|
+
var datas;
|
|
160
|
+
return __generator(this, function (_a) {
|
|
161
|
+
switch (_a.label) {
|
|
162
|
+
case 0: return [4 /*yield*/, getFromSentio("Exercise", userAddress, startTimestamp.toString())];
|
|
163
|
+
case 1:
|
|
164
|
+
datas = _a.sent();
|
|
165
|
+
return [2 /*return*/, datas.map(function (x) {
|
|
166
|
+
var _a = __read((0, typus_dov_single_v2_1.parseVaultInfo)(vaults, x.index, "ExerciseEvent"), 6), Period = _a[0], Vault = _a[1], RiskLevel = _a[2], d_token = _a[3], b_token = _a[4], o_token = _a[5];
|
|
167
|
+
// console.log(x);
|
|
168
|
+
var Action = "Auto Exercise";
|
|
169
|
+
if (x.raw_share) {
|
|
170
|
+
var size = Number(x.raw_share) / Math.pow(10, (0, constants_1.assetToDecimal)(o_token));
|
|
171
|
+
Action = "Auto Exercise ".concat(size, " ").concat(o_token);
|
|
172
|
+
}
|
|
173
|
+
var txHistory = {
|
|
174
|
+
Index: x.index,
|
|
175
|
+
Period: Period,
|
|
176
|
+
Vault: Vault,
|
|
177
|
+
RiskLevel: RiskLevel,
|
|
178
|
+
Action: Action,
|
|
179
|
+
Amount: "".concat(x.amount, " ").concat(x.coin_symbol),
|
|
180
|
+
Tails: x.number,
|
|
181
|
+
Exp: x.exp_earn,
|
|
182
|
+
Date: new Date(x.timestamp),
|
|
183
|
+
txDigest: x.transaction_hash,
|
|
184
|
+
};
|
|
185
|
+
return txHistory;
|
|
186
|
+
})];
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
});
|
|
190
|
+
}
|
|
@@ -16,3 +16,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./leader-board"), exports);
|
|
18
18
|
__exportStar(require("./reward-generated"), exports);
|
|
19
|
+
__exportStar(require("./events"), exports);
|
package/dist/src/utils/mint.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { TransactionBlock } from "@mysten/sui.js/transactions";
|
|
2
|
-
export declare function getMintTokenTx(
|
|
2
|
+
export declare function getMintTokenTx(packageId: string, registry: string, moduleName: string, amount: number): Promise<TransactionBlock>;
|
package/dist/src/utils/mint.js
CHANGED
|
@@ -38,7 +38,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.getMintTokenTx = getMintTokenTx;
|
|
40
40
|
var transactions_1 = require("@mysten/sui.js/transactions");
|
|
41
|
-
function getMintTokenTx(
|
|
41
|
+
function getMintTokenTx(packageId, registry, moduleName, amount) {
|
|
42
42
|
return __awaiter(this, void 0, void 0, function () {
|
|
43
43
|
var tx;
|
|
44
44
|
return __generator(this, function (_a) {
|
|
@@ -47,7 +47,6 @@ function getMintTokenTx(gasBudget, packageId, registry, moduleName, amount) {
|
|
|
47
47
|
target: "".concat(packageId, "::").concat(moduleName, "::mint"),
|
|
48
48
|
arguments: [tx.pure(registry), tx.pure(amount)],
|
|
49
49
|
});
|
|
50
|
-
tx.setGasBudget(gasBudget);
|
|
51
50
|
return [2 /*return*/, tx];
|
|
52
51
|
});
|
|
53
52
|
});
|
|
@@ -8,7 +8,7 @@ export declare class TypusConfig {
|
|
|
8
8
|
oracle: Oracle;
|
|
9
9
|
token: Token;
|
|
10
10
|
static parse(json: any): TypusConfig;
|
|
11
|
-
static default(network: "MAINNET" | "TESTNET", branch?: string): Promise<TypusConfig>;
|
|
11
|
+
static default(network: "MAINNET" | "TESTNET", customRpcEndpoint: string | null, branch?: string): Promise<TypusConfig>;
|
|
12
12
|
}
|
|
13
13
|
export interface Package {
|
|
14
14
|
dice: string;
|
|
@@ -50,6 +50,7 @@ export interface Registry {
|
|
|
50
50
|
inj: string;
|
|
51
51
|
mfud: string;
|
|
52
52
|
sei: string;
|
|
53
|
+
mblub: string;
|
|
53
54
|
};
|
|
54
55
|
typus: {
|
|
55
56
|
airdrop: string;
|
|
@@ -109,4 +110,7 @@ export interface Token {
|
|
|
109
110
|
usdt: string;
|
|
110
111
|
usdy: string;
|
|
111
112
|
vsui: string;
|
|
113
|
+
blub: string;
|
|
114
|
+
mblub: string;
|
|
115
|
+
ausd: string;
|
|
112
116
|
}
|
|
@@ -44,9 +44,9 @@ var TypusConfig = /** @class */ (function () {
|
|
|
44
44
|
TypusConfig.parse = function (json) {
|
|
45
45
|
return JSON.parse(JSON.stringify(camelcaseKeysDeep(json)));
|
|
46
46
|
};
|
|
47
|
-
TypusConfig.default = function (network_1) {
|
|
48
|
-
return __awaiter(this, arguments, void 0, function (network, branch) {
|
|
49
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
47
|
+
TypusConfig.default = function (network_1, customRpcEndpoint_1) {
|
|
48
|
+
return __awaiter(this, arguments, void 0, function (network, customRpcEndpoint, branch) {
|
|
49
|
+
var _a, typusConfig, _b, _c, _d, _e, _f, typusConfig, _g, _h, _j, _k, _l;
|
|
50
50
|
if (branch === void 0) { branch = "main"; }
|
|
51
51
|
return __generator(this, function (_m) {
|
|
52
52
|
switch (_m.label) {
|
|
@@ -63,14 +63,24 @@ var TypusConfig = /** @class */ (function () {
|
|
|
63
63
|
_f = camelcaseKeysDeep;
|
|
64
64
|
return [4 /*yield*/, fetch("https://raw.githubusercontent.com/Typus-Lab/typus-config/".concat(branch, "/config-mainnet.json"))];
|
|
65
65
|
case 2: return [4 /*yield*/, (_m.sent()).json()];
|
|
66
|
-
case 3:
|
|
66
|
+
case 3:
|
|
67
|
+
typusConfig = _c.apply(_b, [_e.apply(_d, [_f.apply(void 0, [_m.sent()])])]);
|
|
68
|
+
if (customRpcEndpoint) {
|
|
69
|
+
typusConfig.rpcEndpoint = customRpcEndpoint;
|
|
70
|
+
}
|
|
71
|
+
return [2 /*return*/, typusConfig];
|
|
67
72
|
case 4:
|
|
68
73
|
_h = (_g = JSON).parse;
|
|
69
74
|
_k = (_j = JSON).stringify;
|
|
70
75
|
_l = camelcaseKeysDeep;
|
|
71
76
|
return [4 /*yield*/, fetch("https://raw.githubusercontent.com/Typus-Lab/typus-config/".concat(branch, "/config-testnet.json"))];
|
|
72
77
|
case 5: return [4 /*yield*/, (_m.sent()).json()];
|
|
73
|
-
case 6:
|
|
78
|
+
case 6:
|
|
79
|
+
typusConfig = _h.apply(_g, [_k.apply(_j, [_l.apply(void 0, [_m.sent()])])]);
|
|
80
|
+
if (customRpcEndpoint) {
|
|
81
|
+
typusConfig.rpcEndpoint = customRpcEndpoint;
|
|
82
|
+
}
|
|
83
|
+
return [2 /*return*/, typusConfig];
|
|
74
84
|
case 7: return [2 /*return*/];
|
|
75
85
|
}
|
|
76
86
|
});
|
|
@@ -80,9 +90,7 @@ var TypusConfig = /** @class */ (function () {
|
|
|
80
90
|
}());
|
|
81
91
|
exports.TypusConfig = TypusConfig;
|
|
82
92
|
// (async () => {
|
|
83
|
-
// let config = await TypusConfig.default("MAINNET");
|
|
93
|
+
// let config = await TypusConfig.default("MAINNET", null);
|
|
84
94
|
// console.log(config);
|
|
85
95
|
// console.log(config.rpcEndpoint);
|
|
86
|
-
// console.log(config.registry.dice.comboDice);
|
|
87
|
-
// console.log(config.token.tgld);
|
|
88
96
|
// })();
|