@typus/typus-sdk 0.2.4 → 0.2.6
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/constants.d.ts +10 -9
- package/lib/constants.js +11 -10
- package/lib/scripts/coveredCall/getNewCoveredCallVaultTx.js +3 -2
- package/lib/test/testDeposit.js +2 -4
- package/lib/test/testNewVault.js +4 -3
- package/lib/test/testSettle.js +5 -4
- package/lib/utils/coveredCall/getNewCoveredCallVaultTx.d.ts +1 -1
- package/lib/utils/coveredCall/getNewCoveredCallVaultTx.js +2 -1
- package/lib/utils/fetchData.d.ts +34 -9
- package/lib/utils/getVaultData.d.ts +2 -2
- package/lib/utils/getVaultData.js +69 -20
- package/package.json +1 -1
package/lib/constants.d.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
export declare const TOKEN_PACKAGE = "
|
|
2
|
-
export declare const TOKEN_REGISTRY_BTC = "
|
|
3
|
-
export declare const TOKEN_REGISTRY_ETH = "
|
|
4
|
-
export declare const TOKEN_REGISTRY_SUI = "
|
|
1
|
+
export declare const TOKEN_PACKAGE = "0xed553b5e7e8690216566974f843c59711ae2f0b7";
|
|
2
|
+
export declare const TOKEN_REGISTRY_BTC = "0xf936133c49899c482e818cb7aad7a1a245615703";
|
|
3
|
+
export declare const TOKEN_REGISTRY_ETH = "0x9c041d2f4dc68577b9d828ec23d2f64cc2b0426c";
|
|
4
|
+
export declare const TOKEN_REGISTRY_SUI = "0x0a35b52763fda836155f3fab655f1fb0477fd428";
|
|
5
5
|
export declare const ORACLE_PACKAGE = "0x437d2eb473bd348ad22b37ffb84bd652656026b1";
|
|
6
|
-
export declare const COVERED_CALL_PACKAGE = "
|
|
7
|
-
export declare const COVERED_CALL_REGISTRY = "
|
|
8
|
-
export declare const COVERED_CALL_MANAGER = "
|
|
9
|
-
export declare const USER_SHARE_TABLE = "
|
|
10
|
-
export declare const MAKER_SHARE_TABLE = "
|
|
6
|
+
export declare const COVERED_CALL_PACKAGE = "0x8e1d90b8f79583a3ca67c9e731039b297c59252a";
|
|
7
|
+
export declare const COVERED_CALL_REGISTRY = "0xd39929844191b67993d84b1bf258ec08a0aa06ba";
|
|
8
|
+
export declare const COVERED_CALL_MANAGER = "0xbfbdae13e30a27d9774a4bc441b71f07dea03710";
|
|
9
|
+
export declare const USER_SHARE_TABLE = "0x6d3e5cc791c7d4a7cfb98955f2afa8b55a729fa8";
|
|
10
|
+
export declare const MAKER_SHARE_TABLE = "0xc42377112a39fb6138e89099912d3888df6444ba";
|
|
11
11
|
export declare const DOV_PACKAGE = "0x1ab7f453176dc6d35fe5e8b6b27a53cb73d1061d";
|
|
12
|
+
export declare const TEST_MINT_TOKEN = "0xd3aeb5597cd4ddea33921fe1155387db28502d13";
|
|
12
13
|
export declare const DEFAULT_TYPE_ARGUMENT = "0x2::sui::SUI";
|
|
13
14
|
export declare const FAKE_TOKEN_TYPE_ARGUMENT = "0x27b3674c685046f66cad1d5496d2967894fa5329::token::USDC";
|
|
14
15
|
export declare const TEST_MNEMONIC = "plug grain matter asthma aware critic can lottery blouse uncover sauce speak";
|
package/lib/constants.js
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TOKEN_NAME_TO_MODULE = exports.TOKEN_NAME = exports.TEST_MNEMONIC = exports.FAKE_TOKEN_TYPE_ARGUMENT = exports.DEFAULT_TYPE_ARGUMENT = exports.DOV_PACKAGE = exports.MAKER_SHARE_TABLE = exports.USER_SHARE_TABLE = exports.COVERED_CALL_MANAGER = exports.COVERED_CALL_REGISTRY = exports.COVERED_CALL_PACKAGE = exports.ORACLE_PACKAGE = exports.TOKEN_REGISTRY_SUI = exports.TOKEN_REGISTRY_ETH = exports.TOKEN_REGISTRY_BTC = exports.TOKEN_PACKAGE = void 0;
|
|
3
|
+
exports.TOKEN_NAME_TO_MODULE = exports.TOKEN_NAME = exports.TEST_MNEMONIC = exports.FAKE_TOKEN_TYPE_ARGUMENT = exports.DEFAULT_TYPE_ARGUMENT = exports.TEST_MINT_TOKEN = exports.DOV_PACKAGE = exports.MAKER_SHARE_TABLE = exports.USER_SHARE_TABLE = exports.COVERED_CALL_MANAGER = exports.COVERED_CALL_REGISTRY = exports.COVERED_CALL_PACKAGE = exports.ORACLE_PACKAGE = exports.TOKEN_REGISTRY_SUI = exports.TOKEN_REGISTRY_ETH = exports.TOKEN_REGISTRY_BTC = exports.TOKEN_PACKAGE = void 0;
|
|
4
4
|
//publish from sui-dev-token
|
|
5
|
-
exports.TOKEN_PACKAGE = "
|
|
6
|
-
exports.TOKEN_REGISTRY_BTC = "
|
|
7
|
-
exports.TOKEN_REGISTRY_ETH = "
|
|
8
|
-
exports.TOKEN_REGISTRY_SUI = "
|
|
5
|
+
exports.TOKEN_PACKAGE = "0xed553b5e7e8690216566974f843c59711ae2f0b7";
|
|
6
|
+
exports.TOKEN_REGISTRY_BTC = "0xf936133c49899c482e818cb7aad7a1a245615703"; //fake btc registry
|
|
7
|
+
exports.TOKEN_REGISTRY_ETH = "0x9c041d2f4dc68577b9d828ec23d2f64cc2b0426c"; //fake eth registry
|
|
8
|
+
exports.TOKEN_REGISTRY_SUI = "0x0a35b52763fda836155f3fab655f1fb0477fd428"; //fake usdc registry
|
|
9
9
|
//publish from typus-oracle
|
|
10
10
|
exports.ORACLE_PACKAGE = "0x437d2eb473bd348ad22b37ffb84bd652656026b1";
|
|
11
11
|
//publish from typus-dov/cover_call
|
|
12
|
-
exports.COVERED_CALL_PACKAGE = "
|
|
13
|
-
exports.COVERED_CALL_REGISTRY = "
|
|
14
|
-
exports.COVERED_CALL_MANAGER = "
|
|
15
|
-
exports.USER_SHARE_TABLE = "
|
|
16
|
-
exports.MAKER_SHARE_TABLE = "
|
|
12
|
+
exports.COVERED_CALL_PACKAGE = "0x8e1d90b8f79583a3ca67c9e731039b297c59252a";
|
|
13
|
+
exports.COVERED_CALL_REGISTRY = "0xd39929844191b67993d84b1bf258ec08a0aa06ba";
|
|
14
|
+
exports.COVERED_CALL_MANAGER = "0xbfbdae13e30a27d9774a4bc441b71f07dea03710";
|
|
15
|
+
exports.USER_SHARE_TABLE = "0x6d3e5cc791c7d4a7cfb98955f2afa8b55a729fa8";
|
|
16
|
+
exports.MAKER_SHARE_TABLE = "0xc42377112a39fb6138e89099912d3888df6444ba";
|
|
17
17
|
//publish from typus-dov/typus-dov
|
|
18
18
|
exports.DOV_PACKAGE = "0x1ab7f453176dc6d35fe5e8b6b27a53cb73d1061d";
|
|
19
|
+
exports.TEST_MINT_TOKEN = "0xd3aeb5597cd4ddea33921fe1155387db28502d13";
|
|
19
20
|
exports.DEFAULT_TYPE_ARGUMENT = "0x2::sui::SUI";
|
|
20
21
|
exports.FAKE_TOKEN_TYPE_ARGUMENT = "0x27b3674c685046f66cad1d5496d2967894fa5329::token::USDC";
|
|
21
22
|
exports.TEST_MNEMONIC = "plug grain matter asthma aware critic can lottery blouse uncover sauce speak";
|
|
@@ -39,7 +39,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
39
39
|
var getNewCoveredCallVaultTx_1 = require("../../utils/coveredCall/getNewCoveredCallVaultTx");
|
|
40
40
|
var constants_1 = require("../../constants");
|
|
41
41
|
(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
42
|
-
var tokenDecimal, shareDecimal, timeOracle, period, activationTsMs, expirationTsMs, capacity, strikeOtmPct, decaySpeed, initialPrice, finalPrice, auctionDurationInMs, prevBalance, newCoveredCallVaultTx;
|
|
42
|
+
var tokenDecimal, shareDecimal, timeOracle, period, activationTsMs, expirationTsMs, capacity, strikeOtmPct, strikeIncrement, decaySpeed, initialPrice, finalPrice, auctionDurationInMs, prevBalance, newCoveredCallVaultTx;
|
|
43
43
|
return __generator(this, function (_a) {
|
|
44
44
|
switch (_a.label) {
|
|
45
45
|
case 0:
|
|
@@ -52,12 +52,13 @@ var constants_1 = require("../../constants");
|
|
|
52
52
|
expirationTsMs = 1671782400000 + 604800000;
|
|
53
53
|
capacity = 1000000000;
|
|
54
54
|
strikeOtmPct = 500;
|
|
55
|
+
strikeIncrement = 10000;
|
|
55
56
|
decaySpeed = 1;
|
|
56
57
|
initialPrice = 5000;
|
|
57
58
|
finalPrice = 1000;
|
|
58
59
|
auctionDurationInMs = 3600000;
|
|
59
60
|
prevBalance = 0;
|
|
60
|
-
return [4 /*yield*/, (0, getNewCoveredCallVaultTx_1.getNewCoveredCallVaultTx)(constants_1.COVERED_CALL_PACKAGE, constants_1.COVERED_CALL_REGISTRY, constants_1.DEFAULT_TYPE_ARGUMENT, constants_1.COVERED_CALL_MANAGER, timeOracle, period, activationTsMs, expirationTsMs, tokenDecimal, shareDecimal, capacity, strikeOtmPct, decaySpeed, initialPrice, finalPrice, auctionDurationInMs, prevBalance)];
|
|
61
|
+
return [4 /*yield*/, (0, getNewCoveredCallVaultTx_1.getNewCoveredCallVaultTx)(constants_1.COVERED_CALL_PACKAGE, constants_1.COVERED_CALL_REGISTRY, constants_1.DEFAULT_TYPE_ARGUMENT, constants_1.COVERED_CALL_MANAGER, timeOracle, period, activationTsMs, expirationTsMs, tokenDecimal, shareDecimal, capacity, strikeOtmPct, strikeIncrement, decaySpeed, initialPrice, finalPrice, auctionDurationInMs, prevBalance)];
|
|
61
62
|
case 1:
|
|
62
63
|
newCoveredCallVaultTx = _a.sent();
|
|
63
64
|
console.log(newCoveredCallVaultTx);
|
package/lib/test/testDeposit.js
CHANGED
|
@@ -45,8 +45,7 @@ var keypair = sui_js_1.Ed25519Keypair.deriveKeypair(constants_1.TEST_MNEMONIC);
|
|
|
45
45
|
var signer = new sui_js_1.RawSigner(keypair, provider);
|
|
46
46
|
/*
|
|
47
47
|
after deposit, token object (minted token) balance will decrease,
|
|
48
|
-
and subVault "
|
|
49
|
-
and a new rolling linked list node will be created if not exist, and the value will increase the same value
|
|
48
|
+
and subVault "rolling_sub_vault" will increase
|
|
50
49
|
*/
|
|
51
50
|
(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
52
51
|
var depositAmount, isRolling, token, vaultIndex, typeArgument, depositTx;
|
|
@@ -55,8 +54,7 @@ var signer = new sui_js_1.RawSigner(keypair, provider);
|
|
|
55
54
|
case 0:
|
|
56
55
|
depositAmount = 100000000;
|
|
57
56
|
isRolling = true;
|
|
58
|
-
token =
|
|
59
|
-
;
|
|
57
|
+
token = constants_1.TEST_MINT_TOKEN;
|
|
60
58
|
vaultIndex = 0;
|
|
61
59
|
return [4 /*yield*/, (0, getTypeArgumentFromToken_1.getTypeArgumentFromToken)(token)];
|
|
62
60
|
case 1:
|
package/lib/test/testNewVault.js
CHANGED
|
@@ -71,15 +71,15 @@ var getTypeArgumentFromToken_1 = require("../utils/getTypeArgumentFromToken");
|
|
|
71
71
|
var provider = new sui_js_1.JsonRpcProvider(sui_js_1.Network.DEVNET); //for read only operations
|
|
72
72
|
var keypair = sui_js_1.Ed25519Keypair.deriveKeypair(constants_1.TEST_MNEMONIC);
|
|
73
73
|
var signer = new sui_js_1.RawSigner(keypair, provider);
|
|
74
|
-
var token =
|
|
74
|
+
var token = constants_1.TEST_MINT_TOKEN; // minted token
|
|
75
75
|
var tokenDecimal = 9;
|
|
76
76
|
var shareDecimal = 4;
|
|
77
|
-
var timeOracle = "";
|
|
78
77
|
var period = 1;
|
|
79
78
|
var activationTsMs = 1671782400000;
|
|
80
79
|
var expirationTsMs = 1671782400000 + 604800000;
|
|
81
80
|
var capacity = 1000000000;
|
|
82
81
|
var strikeOtmPct = 500;
|
|
82
|
+
var strikeIncrement = 10000;
|
|
83
83
|
var decaySpeed = 1;
|
|
84
84
|
var initialPrice = 5000;
|
|
85
85
|
var finalPrice = 1000;
|
|
@@ -97,7 +97,8 @@ var prevBalance = 0;
|
|
|
97
97
|
return [4 /*yield*/, (0, createTimeOracle_1.createTimeOracle)()];
|
|
98
98
|
case 2:
|
|
99
99
|
_a = __read.apply(void 0, [_b.sent(), 2]), timeOracle = _a[0], _ = _a[1];
|
|
100
|
-
|
|
100
|
+
console.log(typeArgument, timeOracle);
|
|
101
|
+
return [4 /*yield*/, (0, getNewCoveredCallVaultTx_1.getNewCoveredCallVaultTx)(constants_1.COVERED_CALL_PACKAGE, constants_1.COVERED_CALL_REGISTRY, typeArgument, constants_1.COVERED_CALL_MANAGER, timeOracle, period, activationTsMs, expirationTsMs, tokenDecimal, shareDecimal, capacity, strikeOtmPct, strikeIncrement, decaySpeed, initialPrice, finalPrice, auctionDurationInMs, prevBalance)];
|
|
101
102
|
case 3:
|
|
102
103
|
newCoveredCallVaultTx = _b.sent();
|
|
103
104
|
return [4 /*yield*/, signer.executeMoveCall(newCoveredCallVaultTx)];
|
package/lib/test/testSettle.js
CHANGED
|
@@ -92,7 +92,7 @@ var expirationTsMs2 = 2000000;
|
|
|
92
92
|
// let timeOracle = '0x2b06a0f8109e394258c288b1d90c8c5a9c3832db';
|
|
93
93
|
// let timeOracleManager = '0xcad2723ff9c95ce423d3614375e2fa73ce9a7c04';
|
|
94
94
|
(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
95
|
-
var typeArgument, _a, priceOracle, priceOracleManager, _b, timeOracle, timeOracleManager, price, ts, tokenDecimal, shareDecimal, period, activationTsMs, expirationTsMs, capacity, strikeOtmPct, decaySpeed, initialPrice, finalPrice, auctionDurationInMs, prevBalance, vaultIndex, depositAmount, startAuctionTsMs, endAuctionTsMs, currentTime, bidSize, sellSize, premiumRoi, exposureRatio;
|
|
95
|
+
var typeArgument, _a, priceOracle, priceOracleManager, _b, timeOracle, timeOracleManager, price, ts, tokenDecimal, shareDecimal, period, activationTsMs, expirationTsMs, capacity, strikeOtmPct, strikeIncrement, decaySpeed, initialPrice, finalPrice, auctionDurationInMs, prevBalance, vaultIndex, depositAmount, startAuctionTsMs, endAuctionTsMs, currentTime, bidSize, sellSize, premiumRoi, exposureRatio;
|
|
96
96
|
return __generator(this, function (_c) {
|
|
97
97
|
switch (_c.label) {
|
|
98
98
|
case 0: return [4 /*yield*/, (0, getTypeArgumentFromToken_1.getTypeArgumentFromToken)(token)
|
|
@@ -126,12 +126,13 @@ var expirationTsMs2 = 2000000;
|
|
|
126
126
|
expirationTsMs = 1671782400000 + 604800000;
|
|
127
127
|
capacity = 1000000000;
|
|
128
128
|
strikeOtmPct = 500;
|
|
129
|
+
strikeIncrement = 10000;
|
|
129
130
|
decaySpeed = 1;
|
|
130
131
|
initialPrice = 5000;
|
|
131
132
|
finalPrice = 1000;
|
|
132
133
|
auctionDurationInMs = 3600000;
|
|
133
134
|
prevBalance = 0;
|
|
134
|
-
return [4 /*yield*/, createNewVault(constants_1.COVERED_CALL_PACKAGE, constants_1.COVERED_CALL_REGISTRY, typeArgument, constants_1.COVERED_CALL_MANAGER, timeOracle, period, activationTsMs, expirationTsMs, tokenDecimal, shareDecimal, capacity, strikeOtmPct, decaySpeed, initialPrice, finalPrice, auctionDurationInMs, prevBalance)];
|
|
135
|
+
return [4 /*yield*/, createNewVault(constants_1.COVERED_CALL_PACKAGE, constants_1.COVERED_CALL_REGISTRY, typeArgument, constants_1.COVERED_CALL_MANAGER, timeOracle, period, activationTsMs, expirationTsMs, tokenDecimal, shareDecimal, capacity, strikeOtmPct, strikeIncrement, decaySpeed, initialPrice, finalPrice, auctionDurationInMs, prevBalance)];
|
|
135
136
|
case 5:
|
|
136
137
|
_c.sent();
|
|
137
138
|
return [4 /*yield*/, getNewestVaultIndex(constants_1.COVERED_CALL_REGISTRY)];
|
|
@@ -343,7 +344,7 @@ function updateTimeOracle(timeOracle, managerCap, ts) {
|
|
|
343
344
|
});
|
|
344
345
|
});
|
|
345
346
|
}
|
|
346
|
-
function createNewVault(packageId, registry, typeArgument, managerCap, timeOracle, period, activationTsMs, expirationTsMs, tokenDecimal, shareDecimal, capacity, strikeOtmPct, decaySpeed, initialPrice, finalPrice, auctionDurationInMs, prevBalance) {
|
|
347
|
+
function createNewVault(packageId, registry, typeArgument, managerCap, timeOracle, period, activationTsMs, expirationTsMs, tokenDecimal, shareDecimal, capacity, strikeOtmPct, strikeIncrement, decaySpeed, initialPrice, finalPrice, auctionDurationInMs, prevBalance) {
|
|
347
348
|
return __awaiter(this, void 0, void 0, function () {
|
|
348
349
|
var _this = this;
|
|
349
350
|
return __generator(this, function (_a) {
|
|
@@ -353,7 +354,7 @@ function createNewVault(packageId, registry, typeArgument, managerCap, timeOracl
|
|
|
353
354
|
switch (_a.label) {
|
|
354
355
|
case 0:
|
|
355
356
|
_a.trys.push([0, 4, , 5]);
|
|
356
|
-
return [4 /*yield*/, (0, getNewCoveredCallVaultTx_1.getNewCoveredCallVaultTx)(constants_1.COVERED_CALL_PACKAGE, constants_1.COVERED_CALL_REGISTRY, typeArgument, constants_1.COVERED_CALL_MANAGER, timeOracle, period, activationTsMs, expirationTsMs, tokenDecimal, shareDecimal, capacity, strikeOtmPct, decaySpeed, initialPrice, finalPrice, auctionDurationInMs, prevBalance)];
|
|
357
|
+
return [4 /*yield*/, (0, getNewCoveredCallVaultTx_1.getNewCoveredCallVaultTx)(constants_1.COVERED_CALL_PACKAGE, constants_1.COVERED_CALL_REGISTRY, typeArgument, constants_1.COVERED_CALL_MANAGER, timeOracle, period, activationTsMs, expirationTsMs, tokenDecimal, shareDecimal, capacity, strikeOtmPct, strikeIncrement, decaySpeed, initialPrice, finalPrice, auctionDurationInMs, prevBalance)];
|
|
357
358
|
case 1:
|
|
358
359
|
newCoveredCallVaultTx = _a.sent();
|
|
359
360
|
return [4 /*yield*/, signer.executeMoveCall(newCoveredCallVaultTx)];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function getNewCoveredCallVaultTx(packageId: string, registry: string, typeArgument: string, managerCap: string, timeOracle: string, period: number, activationTsMs: number, expirationTsMs: number, tokenDecimal: number, shareDecimal: number, capacity: number, strikeOtmPct: number, decaySpeed: number, initialPrice: number, finalPrice: number, auctionDurationInMs: number, prevBalance: number): Promise<any>;
|
|
1
|
+
export declare function getNewCoveredCallVaultTx(packageId: string, registry: string, typeArgument: string, managerCap: string, timeOracle: string, period: number, activationTsMs: number, expirationTsMs: number, tokenDecimal: number, shareDecimal: number, capacity: number, strikeOtmPct: number, strikeIncrement: number, decaySpeed: number, initialPrice: number, finalPrice: number, auctionDurationInMs: number, prevBalance: number): Promise<any>;
|
|
@@ -37,7 +37,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.getNewCoveredCallVaultTx = void 0;
|
|
40
|
-
function getNewCoveredCallVaultTx(packageId, registry, typeArgument, managerCap, timeOracle, period, activationTsMs, expirationTsMs, tokenDecimal, shareDecimal, capacity, strikeOtmPct, decaySpeed, initialPrice, finalPrice, auctionDurationInMs, prevBalance) {
|
|
40
|
+
function getNewCoveredCallVaultTx(packageId, registry, typeArgument, managerCap, timeOracle, period, activationTsMs, expirationTsMs, tokenDecimal, shareDecimal, capacity, strikeOtmPct, strikeIncrement, decaySpeed, initialPrice, finalPrice, auctionDurationInMs, prevBalance) {
|
|
41
41
|
return __awaiter(this, void 0, void 0, function () {
|
|
42
42
|
var tx;
|
|
43
43
|
return __generator(this, function (_a) {
|
|
@@ -57,6 +57,7 @@ function getNewCoveredCallVaultTx(packageId, registry, typeArgument, managerCap,
|
|
|
57
57
|
shareDecimal,
|
|
58
58
|
capacity,
|
|
59
59
|
strikeOtmPct,
|
|
60
|
+
strikeIncrement,
|
|
60
61
|
decaySpeed,
|
|
61
62
|
initialPrice,
|
|
62
63
|
finalPrice,
|
package/lib/utils/fetchData.d.ts
CHANGED
|
@@ -3,24 +3,49 @@ export interface SubVaults {
|
|
|
3
3
|
maker: string;
|
|
4
4
|
regular: string;
|
|
5
5
|
}
|
|
6
|
+
export interface VaultConfig {
|
|
7
|
+
strikeOtmPct: number;
|
|
8
|
+
strikeIncrement: number;
|
|
9
|
+
decaySpeed: number;
|
|
10
|
+
initialPrice: number;
|
|
11
|
+
finalPrice: number;
|
|
12
|
+
auctionDurationInMs: number;
|
|
13
|
+
}
|
|
14
|
+
export interface Config {
|
|
15
|
+
period: number;
|
|
16
|
+
activationTsMs: number;
|
|
17
|
+
expirationTsMs: number;
|
|
18
|
+
tokenDecimal: number;
|
|
19
|
+
shareDecimal: number;
|
|
20
|
+
capacity: number;
|
|
21
|
+
vaultConfig: VaultConfig;
|
|
22
|
+
nextVaultConfig: VaultConfig;
|
|
23
|
+
payoffConfig: PayoffConfig;
|
|
24
|
+
}
|
|
25
|
+
export interface SubVault {
|
|
26
|
+
balance: number;
|
|
27
|
+
shareSupply: number;
|
|
28
|
+
}
|
|
6
29
|
export interface Vault {
|
|
30
|
+
ableToDeposit: boolean;
|
|
31
|
+
ableToWithdraw: boolean;
|
|
32
|
+
makerSubVault: SubVault;
|
|
33
|
+
regularSubVault: SubVault;
|
|
34
|
+
rollingSubVault: SubVault;
|
|
35
|
+
}
|
|
36
|
+
export interface CoveredCallVault {
|
|
7
37
|
vaultId: string;
|
|
8
38
|
vaultIdx: number;
|
|
9
39
|
asset: string;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
period: number;
|
|
15
|
-
shareDecimal: number;
|
|
16
|
-
startTsMs: number;
|
|
17
|
-
tokenDecimal: number;
|
|
40
|
+
config: Config;
|
|
41
|
+
vault: Vault;
|
|
42
|
+
prevBalance: number;
|
|
43
|
+
tvl: number;
|
|
18
44
|
}
|
|
19
45
|
export interface PayoffConfig {
|
|
20
46
|
exposureRatio: number;
|
|
21
47
|
premiumRoi: number;
|
|
22
48
|
strike: number;
|
|
23
|
-
strikeOtmPct: number;
|
|
24
49
|
}
|
|
25
50
|
export declare function getCoveredCallVaultsFromRegistry(registry: string): Promise<any>;
|
|
26
51
|
export declare function getTableFromCoveredCallVault(coveredCallVault: string): Promise<any>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function getVaultDataFromRegistry(registry: string): Promise<
|
|
1
|
+
import { CoveredCallVault } from "../utils/fetchData";
|
|
2
|
+
export declare function getVaultDataFromRegistry(registry: string): Promise<CoveredCallVault[]>;
|
|
@@ -72,12 +72,11 @@ function getVaultDataFromRegistry(registry) {
|
|
|
72
72
|
console.log("obj not exist");
|
|
73
73
|
return "continue";
|
|
74
74
|
}
|
|
75
|
-
//vault
|
|
76
75
|
//@ts-ignore
|
|
77
|
-
|
|
78
|
-
//
|
|
76
|
+
// console.log(objInfo.details.data.fields.value.fields.config.fields)
|
|
77
|
+
//vaultId
|
|
79
78
|
//@ts-ignore
|
|
80
|
-
var
|
|
79
|
+
var vaultId = objInfo.details.data.fields.id.id;
|
|
81
80
|
//vaultIdx
|
|
82
81
|
//@ts-ignore
|
|
83
82
|
var vaultIdx = objInfo.details.data.fields.name;
|
|
@@ -89,28 +88,78 @@ function getVaultDataFromRegistry(registry) {
|
|
|
89
88
|
console.log("can't find token");
|
|
90
89
|
asset = "";
|
|
91
90
|
}
|
|
92
|
-
//
|
|
91
|
+
//config
|
|
93
92
|
//@ts-ignore
|
|
94
|
-
var
|
|
95
|
-
//
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
93
|
+
var config = objInfo.details.data.fields.value.fields.config.fields;
|
|
94
|
+
//vault
|
|
95
|
+
//@ts-ignore
|
|
96
|
+
var vault = objInfo.details.data.fields.value.fields.vault.fields;
|
|
97
|
+
//prevBalance
|
|
98
|
+
//@ts-ignore
|
|
99
|
+
var prevBalance = objInfo.details.data.fields.value.fields.prev_balance;
|
|
100
|
+
var vaultConfig = config.vault_config.fields;
|
|
101
|
+
var vaultConfigRes = {
|
|
102
|
+
strikeOtmPct: vaultConfig.strike_otm_pct,
|
|
103
|
+
strikeIncrement: vaultConfig.strike_increment,
|
|
104
|
+
decaySpeed: vaultConfig.decay_speed,
|
|
105
|
+
initialPrice: vaultConfig.initial_price,
|
|
106
|
+
finalPrice: vaultConfig.final_price,
|
|
107
|
+
auctionDurationInMs: vaultConfig.auction_duration_in_ms,
|
|
108
|
+
};
|
|
109
|
+
var nextVaultConfig = config.next_vault_config.fields;
|
|
110
|
+
var nextVaultConfigRes = {
|
|
111
|
+
strikeOtmPct: nextVaultConfig.strike_otm_pct,
|
|
112
|
+
strikeIncrement: nextVaultConfig.strike_increment,
|
|
113
|
+
decaySpeed: nextVaultConfig.decay_speed,
|
|
114
|
+
initialPrice: nextVaultConfig.initial_price,
|
|
115
|
+
finalPrice: nextVaultConfig.final_price,
|
|
116
|
+
auctionDurationInMs: nextVaultConfig.auction_duration_in_ms,
|
|
117
|
+
};
|
|
118
|
+
var payoffConfig = config.payoff_config.fields;
|
|
119
|
+
var payoffConfigRes = {
|
|
120
|
+
exposureRatio: Number(payoffConfig.exposure_ratio),
|
|
121
|
+
premiumRoi: Number(payoffConfig.premium_roi),
|
|
122
|
+
strike: Number(payoffConfig.strike),
|
|
101
123
|
};
|
|
124
|
+
var configRes = {
|
|
125
|
+
period: config.period,
|
|
126
|
+
activationTsMs: config.activation_ts_ms,
|
|
127
|
+
expirationTsMs: config.expiration_ts_ms,
|
|
128
|
+
tokenDecimal: config.token_decimal,
|
|
129
|
+
shareDecimal: config.share_decimal,
|
|
130
|
+
capacity: config.capacity,
|
|
131
|
+
vaultConfig: vaultConfigRes,
|
|
132
|
+
nextVaultConfig: nextVaultConfigRes,
|
|
133
|
+
payoffConfig: payoffConfigRes,
|
|
134
|
+
};
|
|
135
|
+
var maker = {
|
|
136
|
+
balance: Number(vault.maker_sub_vault.fields.balance),
|
|
137
|
+
shareSupply: Number(vault.maker_sub_vault.fields.share_supply),
|
|
138
|
+
};
|
|
139
|
+
var regular = {
|
|
140
|
+
balance: Number(vault.regular_sub_vault.fields.balance),
|
|
141
|
+
shareSupply: Number(vault.regular_sub_vault.fields.share_supply),
|
|
142
|
+
};
|
|
143
|
+
var rolling = {
|
|
144
|
+
balance: Number(vault.rolling_sub_vault.fields.balance),
|
|
145
|
+
shareSupply: Number(vault.rolling_sub_vault.fields.share_supply),
|
|
146
|
+
};
|
|
147
|
+
var vaultRes = {
|
|
148
|
+
ableToDeposit: vault.able_to_deposit,
|
|
149
|
+
ableToWithdraw: vault.able_to_withdraw,
|
|
150
|
+
makerSubVault: maker,
|
|
151
|
+
regularSubVault: regular,
|
|
152
|
+
rollingSubVault: rolling,
|
|
153
|
+
};
|
|
154
|
+
var tvl = Number(vault.regular_sub_vault.fields.balance) + Number(vault.rolling_sub_vault.fields.balance);
|
|
102
155
|
var res = {
|
|
103
156
|
vaultId: vaultId,
|
|
104
157
|
vaultIdx: vaultIdx,
|
|
105
158
|
asset: asset,
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
period: Number(config.period),
|
|
111
|
-
shareDecimal: config.share_decimal,
|
|
112
|
-
startTsMs: config.start_ts_ms,
|
|
113
|
-
tokenDecimal: config.token_decimal,
|
|
159
|
+
config: configRes,
|
|
160
|
+
vault: vaultRes,
|
|
161
|
+
prevBalance: prevBalance,
|
|
162
|
+
tvl: tvl,
|
|
114
163
|
};
|
|
115
164
|
vaults.push(res);
|
|
116
165
|
};
|