@typus/typus-sdk 0.2.6 → 0.2.8
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 +12 -12
- package/lib/constants.js +12 -12
- package/lib/scripts/coveredCall/getNewAuctionTx.js +4 -2
- package/lib/scripts/coveredCall/getNewAuctionWithNextCoveredCallVaultTx.js +3 -2
- package/lib/test/getBidData.d.ts +1 -0
- package/lib/test/getBidData.js +52 -0
- package/lib/test/testNewAuction.d.ts +1 -0
- package/lib/test/testNewAuction.js +93 -0
- package/lib/test/testSettle.js +33 -78
- package/lib/utils/auction/getBid.d.ts +1 -0
- package/lib/utils/auction/getBid.js +56 -0
- package/lib/utils/coveredCall/createPriceOracle.d.ts +1 -0
- package/lib/utils/coveredCall/createPriceOracle.js +92 -0
- package/lib/utils/coveredCall/getNewAuctionTx.d.ts +1 -1
- package/lib/utils/coveredCall/getNewAuctionTx.js +3 -1
- package/lib/utils/coveredCall/getNewAuctionWithNextCoveredCallVaultTx.d.ts +1 -1
- package/lib/utils/coveredCall/getNewAuctionWithNextCoveredCallVaultTx.js +2 -1
- package/lib/utils/fetchData.d.ts +1 -0
- package/lib/utils/getTypeArgumentFromToken.js +2 -1
- package/lib/utils/getVaultData.js +3 -0
- package/package.json +1 -1
package/lib/constants.d.ts
CHANGED
|
@@ -1,15 +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 = "
|
|
5
|
-
export declare const ORACLE_PACKAGE = "
|
|
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 = "
|
|
11
|
-
export declare const DOV_PACKAGE = "
|
|
12
|
-
export declare const TEST_MINT_TOKEN = "
|
|
1
|
+
export declare const TOKEN_PACKAGE = "0x2c9a10117599e2d3232495a525b10f679691c9ae";
|
|
2
|
+
export declare const TOKEN_REGISTRY_BTC = "0xe0dc19dfc9023f2e86462aa37dc8fae290b4e2bb";
|
|
3
|
+
export declare const TOKEN_REGISTRY_ETH = "0x9ad1db50850079e98d5972e3d9a8fdc90b9d1f19";
|
|
4
|
+
export declare const TOKEN_REGISTRY_SUI = "0xc6128d63d24cbdb66e50cef4577e5cf36bb889e1";
|
|
5
|
+
export declare const ORACLE_PACKAGE = "0x0d4b13cc0467c0620ce54abf703faa3b419d967b";
|
|
6
|
+
export declare const COVERED_CALL_PACKAGE = "0x26bde55e579bd0418aaa140cd869153afeb34467";
|
|
7
|
+
export declare const COVERED_CALL_REGISTRY = "0xf1d4a2db033cba8bb3a69cf3de2558d89bed6dd4";
|
|
8
|
+
export declare const COVERED_CALL_MANAGER = "0xef73bf17e55fc9d5e31513df50c7e912bb729fc6";
|
|
9
|
+
export declare const USER_SHARE_TABLE = "0xd1ea22029f899265c9588c0e19d0366e6bb60d44";
|
|
10
|
+
export declare const MAKER_SHARE_TABLE = "0xf4db8e77a8763e1ac2d3038f53456410e2175989";
|
|
11
|
+
export declare const DOV_PACKAGE = "0xaf114c36e5329271f84a0d2cb1310d0efa6c6bb9";
|
|
12
|
+
export declare const TEST_MINT_TOKEN = "0x672612858fcb5c6abf944638253142820c251753";
|
|
13
13
|
export declare const DEFAULT_TYPE_ARGUMENT = "0x2::sui::SUI";
|
|
14
14
|
export declare const FAKE_TOKEN_TYPE_ARGUMENT = "0x27b3674c685046f66cad1d5496d2967894fa5329::token::USDC";
|
|
15
15
|
export declare const TEST_MNEMONIC = "plug grain matter asthma aware critic can lottery blouse uncover sauce speak";
|
package/lib/constants.js
CHANGED
|
@@ -2,21 +2,21 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
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 = "0x2c9a10117599e2d3232495a525b10f679691c9ae";
|
|
6
|
+
exports.TOKEN_REGISTRY_BTC = "0xe0dc19dfc9023f2e86462aa37dc8fae290b4e2bb"; //fake btc registry
|
|
7
|
+
exports.TOKEN_REGISTRY_ETH = "0x9ad1db50850079e98d5972e3d9a8fdc90b9d1f19"; //fake eth registry
|
|
8
|
+
exports.TOKEN_REGISTRY_SUI = "0xc6128d63d24cbdb66e50cef4577e5cf36bb889e1"; //fake usdc registry
|
|
9
9
|
//publish from typus-oracle
|
|
10
|
-
exports.ORACLE_PACKAGE = "
|
|
10
|
+
exports.ORACLE_PACKAGE = "0x0d4b13cc0467c0620ce54abf703faa3b419d967b";
|
|
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 = "0x26bde55e579bd0418aaa140cd869153afeb34467";
|
|
13
|
+
exports.COVERED_CALL_REGISTRY = "0xf1d4a2db033cba8bb3a69cf3de2558d89bed6dd4";
|
|
14
|
+
exports.COVERED_CALL_MANAGER = "0xef73bf17e55fc9d5e31513df50c7e912bb729fc6";
|
|
15
|
+
exports.USER_SHARE_TABLE = "0xd1ea22029f899265c9588c0e19d0366e6bb60d44";
|
|
16
|
+
exports.MAKER_SHARE_TABLE = "0xf4db8e77a8763e1ac2d3038f53456410e2175989";
|
|
17
17
|
//publish from typus-dov/typus-dov
|
|
18
|
-
exports.DOV_PACKAGE = "
|
|
19
|
-
exports.TEST_MINT_TOKEN = "
|
|
18
|
+
exports.DOV_PACKAGE = "0xaf114c36e5329271f84a0d2cb1310d0efa6c6bb9";
|
|
19
|
+
exports.TEST_MINT_TOKEN = "0x672612858fcb5c6abf944638253142820c251753";
|
|
20
20
|
exports.DEFAULT_TYPE_ARGUMENT = "0x2::sui::SUI";
|
|
21
21
|
exports.FAKE_TOKEN_TYPE_ARGUMENT = "0x27b3674c685046f66cad1d5496d2967894fa5329::token::USDC";
|
|
22
22
|
exports.TEST_MNEMONIC = "plug grain matter asthma aware critic can lottery blouse uncover sauce speak";
|
|
@@ -39,14 +39,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
39
39
|
var getNewAuctionTx_1 = require("../../utils/coveredCall/getNewAuctionTx");
|
|
40
40
|
var constants_1 = require("../../constants");
|
|
41
41
|
(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
42
|
-
var typeArgument, vaultIndex, newAuctionTx;
|
|
42
|
+
var typeArgument, vaultIndex, priceOracle, timeOracle, newAuctionTx;
|
|
43
43
|
return __generator(this, function (_a) {
|
|
44
44
|
switch (_a.label) {
|
|
45
45
|
case 0:
|
|
46
46
|
console.log("test for getNewAuctionTx()");
|
|
47
47
|
typeArgument = "0x27b3674c685046f66cad1d5496d2967894fa5329::token::USDC";
|
|
48
48
|
vaultIndex = 1;
|
|
49
|
-
|
|
49
|
+
priceOracle = "";
|
|
50
|
+
timeOracle = "";
|
|
51
|
+
return [4 /*yield*/, (0, getNewAuctionTx_1.getNewAuctionTx)(constants_1.COVERED_CALL_PACKAGE, constants_1.COVERED_CALL_REGISTRY, typeArgument, constants_1.COVERED_CALL_MANAGER, vaultIndex, priceOracle, timeOracle)];
|
|
50
52
|
case 1:
|
|
51
53
|
newAuctionTx = _a.sent();
|
|
52
54
|
console.log(newAuctionTx);
|
|
@@ -39,16 +39,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
39
39
|
var getNewAuctionWithNextCoveredCallVaultTx_1 = require("../../utils/coveredCall/getNewAuctionWithNextCoveredCallVaultTx");
|
|
40
40
|
var constants_1 = require("../../constants");
|
|
41
41
|
(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
42
|
-
var index, timeOracle, activationTsMs, expirationTsMs, newAuctionWithNextCoveredCallVaultTx;
|
|
42
|
+
var index, timeOracle, priceOracle, activationTsMs, expirationTsMs, newAuctionWithNextCoveredCallVaultTx;
|
|
43
43
|
return __generator(this, function (_a) {
|
|
44
44
|
switch (_a.label) {
|
|
45
45
|
case 0:
|
|
46
46
|
console.log("test for getNewAuctionWithNextCoveredCallVaultTx()");
|
|
47
47
|
index = 1;
|
|
48
48
|
timeOracle = "";
|
|
49
|
+
priceOracle = "";
|
|
49
50
|
activationTsMs = 1672992000000;
|
|
50
51
|
expirationTsMs = 1672992000000 + 604800000;
|
|
51
|
-
return [4 /*yield*/, (0, getNewAuctionWithNextCoveredCallVaultTx_1.getNewAuctionWithNextCoveredCallVaultTx)(constants_1.COVERED_CALL_PACKAGE, constants_1.COVERED_CALL_MANAGER, constants_1.COVERED_CALL_REGISTRY, constants_1.DEFAULT_TYPE_ARGUMENT, index, timeOracle, activationTsMs, expirationTsMs)];
|
|
52
|
+
return [4 /*yield*/, (0, getNewAuctionWithNextCoveredCallVaultTx_1.getNewAuctionWithNextCoveredCallVaultTx)(constants_1.COVERED_CALL_PACKAGE, constants_1.COVERED_CALL_MANAGER, constants_1.COVERED_CALL_REGISTRY, constants_1.DEFAULT_TYPE_ARGUMENT, index, priceOracle, timeOracle, activationTsMs, expirationTsMs)];
|
|
52
53
|
case 1:
|
|
53
54
|
newAuctionWithNextCoveredCallVaultTx = _a.sent();
|
|
54
55
|
console.log(newAuctionWithNextCoveredCallVaultTx);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
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 (_) 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
|
+
var constants_1 = require("../constants");
|
|
40
|
+
var getBid_1 = require("../utils/auction/getBid");
|
|
41
|
+
(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
42
|
+
var bid;
|
|
43
|
+
return __generator(this, function (_a) {
|
|
44
|
+
switch (_a.label) {
|
|
45
|
+
case 0: return [4 /*yield*/, (0, getBid_1.getBid)(constants_1.DOV_PACKAGE)];
|
|
46
|
+
case 1:
|
|
47
|
+
bid = _a.sent();
|
|
48
|
+
console.log(bid);
|
|
49
|
+
return [2 /*return*/];
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}); })();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,93 @@
|
|
|
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 (_) 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
|
+
var getNewAuctionTx_1 = require("../utils/coveredCall/getNewAuctionTx");
|
|
56
|
+
var constants_1 = require("../constants");
|
|
57
|
+
var getTypeArgumentFromToken_1 = require("../utils/getTypeArgumentFromToken");
|
|
58
|
+
var sui_js_1 = require("@mysten/sui.js");
|
|
59
|
+
var createPriceOracle_1 = require("../utils/coveredCall/createPriceOracle");
|
|
60
|
+
var createTimeOracle_1 = require("../utils/coveredCall/createTimeOracle");
|
|
61
|
+
var provider = new sui_js_1.JsonRpcProvider(sui_js_1.Network.DEVNET); //for read only operations
|
|
62
|
+
var keypair = sui_js_1.Ed25519Keypair.deriveKeypair(constants_1.TEST_MNEMONIC);
|
|
63
|
+
var signer = new sui_js_1.RawSigner(keypair, provider);
|
|
64
|
+
(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
65
|
+
var token, typeArgument, vaultIndex, _a, priceOracle, priceOracleManager, _b, timeOracle, timeOracleManager, activationTsMs, expirationTsMs, newAuctionTx, a;
|
|
66
|
+
return __generator(this, function (_c) {
|
|
67
|
+
switch (_c.label) {
|
|
68
|
+
case 0:
|
|
69
|
+
token = constants_1.TEST_MINT_TOKEN // minted token
|
|
70
|
+
;
|
|
71
|
+
return [4 /*yield*/, (0, getTypeArgumentFromToken_1.getTypeArgumentFromToken)(token)];
|
|
72
|
+
case 1:
|
|
73
|
+
typeArgument = _c.sent();
|
|
74
|
+
vaultIndex = 0;
|
|
75
|
+
return [4 /*yield*/, (0, createPriceOracle_1.createPriceOracle)(typeArgument)];
|
|
76
|
+
case 2:
|
|
77
|
+
_a = __read.apply(void 0, [_c.sent(), 2]), priceOracle = _a[0], priceOracleManager = _a[1];
|
|
78
|
+
return [4 /*yield*/, (0, createTimeOracle_1.createTimeOracle)()];
|
|
79
|
+
case 3:
|
|
80
|
+
_b = __read.apply(void 0, [_c.sent(), 2]), timeOracle = _b[0], timeOracleManager = _b[1];
|
|
81
|
+
activationTsMs = 1671992000000;
|
|
82
|
+
expirationTsMs = 1;
|
|
83
|
+
return [4 /*yield*/, (0, getNewAuctionTx_1.getNewAuctionTx)(constants_1.COVERED_CALL_PACKAGE, constants_1.COVERED_CALL_REGISTRY, typeArgument, constants_1.COVERED_CALL_MANAGER, vaultIndex, priceOracle, timeOracle)];
|
|
84
|
+
case 4:
|
|
85
|
+
newAuctionTx = _c.sent();
|
|
86
|
+
return [4 /*yield*/, signer.executeMoveCall(newAuctionTx)];
|
|
87
|
+
case 5:
|
|
88
|
+
a = _c.sent();
|
|
89
|
+
console.log(a);
|
|
90
|
+
return [2 /*return*/];
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
}); })();
|
package/lib/test/testSettle.js
CHANGED
|
@@ -63,7 +63,6 @@ var __values = (this && this.__values) || function(o) {
|
|
|
63
63
|
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
64
64
|
};
|
|
65
65
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
66
|
-
var getNewOracleTx_1 = require("../utils/getNewOracleTx");
|
|
67
66
|
var getUpdateOracleTx_1 = require("../utils/getUpdateOracleTx");
|
|
68
67
|
var getNewCoveredCallVaultTx_1 = require("../utils/coveredCall/getNewCoveredCallVaultTx");
|
|
69
68
|
var getDepositTx_1 = require("../utils/coveredCall/getDepositTx");
|
|
@@ -77,6 +76,7 @@ var getNewBidTx_1 = require("../utils/coveredCall/getNewBidTx");
|
|
|
77
76
|
var getDeliveryTx_1 = require("../utils/coveredCall/getDeliveryTx");
|
|
78
77
|
var getUpdatePayoffConfigTx_1 = require("../utils/coveredCall/getUpdatePayoffConfigTx");
|
|
79
78
|
var getSettleTx_1 = require("../utils/coveredCall/getSettleTx");
|
|
79
|
+
var createPriceOracle_1 = require("../utils/coveredCall/createPriceOracle");
|
|
80
80
|
var provider = new sui_js_1.JsonRpcProvider(sui_js_1.Network.DEVNET); //for read only operations
|
|
81
81
|
var keypair = sui_js_1.Ed25519Keypair.deriveKeypair(constants_1.TEST_MNEMONIC);
|
|
82
82
|
var signer = new sui_js_1.RawSigner(keypair, provider);
|
|
@@ -100,7 +100,7 @@ var expirationTsMs2 = 2000000;
|
|
|
100
100
|
];
|
|
101
101
|
case 1:
|
|
102
102
|
typeArgument = _c.sent();
|
|
103
|
-
return [4 /*yield*/, createPriceOracle(typeArgument)];
|
|
103
|
+
return [4 /*yield*/, (0, createPriceOracle_1.createPriceOracle)(typeArgument)];
|
|
104
104
|
case 2:
|
|
105
105
|
_a = __read.apply(void 0, [_c.sent(), 2]), priceOracle = _a[0], priceOracleManager = _a[1];
|
|
106
106
|
return [4 /*yield*/, (0, createTimeOracle_1.createTimeOracle)()
|
|
@@ -160,7 +160,7 @@ var expirationTsMs2 = 2000000;
|
|
|
160
160
|
finalPrice = 100000000;
|
|
161
161
|
activationTsMs = 1672992000000;
|
|
162
162
|
expirationTsMs = 1672992000000 + 604800000;
|
|
163
|
-
return [4 /*yield*/, createNewAuctionWithNextCoveredCallVault(typeArgument, vaultIndex, timeOracle, activationTsMs, expirationTsMs)];
|
|
163
|
+
return [4 /*yield*/, createNewAuctionWithNextCoveredCallVault(typeArgument, vaultIndex, priceOracle, timeOracle, activationTsMs, expirationTsMs)];
|
|
164
164
|
case 10:
|
|
165
165
|
_c.sent();
|
|
166
166
|
currentTime = startAuctionTsMs + 300;
|
|
@@ -233,57 +233,12 @@ var expirationTsMs2 = 2000000;
|
|
|
233
233
|
}
|
|
234
234
|
});
|
|
235
235
|
}); })();
|
|
236
|
-
function createPriceOracle(typeArgument) {
|
|
237
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
238
|
-
var _this = this;
|
|
239
|
-
return __generator(this, function (_a) {
|
|
240
|
-
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
241
|
-
var newOracleTx, moveCallTxn, digest, txn, priceOracle, managerCap, e_1;
|
|
242
|
-
return __generator(this, function (_a) {
|
|
243
|
-
switch (_a.label) {
|
|
244
|
-
case 0:
|
|
245
|
-
_a.trys.push([0, 4, , 5]);
|
|
246
|
-
console.log("create new price oracle...");
|
|
247
|
-
return [4 /*yield*/, (0, getNewOracleTx_1.getNewOracleTx)(constants_1.ORACLE_PACKAGE, typeArgument, decimal)];
|
|
248
|
-
case 1:
|
|
249
|
-
newOracleTx = _a.sent();
|
|
250
|
-
return [4 /*yield*/, signer.executeMoveCall(newOracleTx)];
|
|
251
|
-
case 2:
|
|
252
|
-
moveCallTxn = _a.sent();
|
|
253
|
-
digest = moveCallTxn.EffectsCert.certificate.transactionDigest;
|
|
254
|
-
return [4 /*yield*/, provider.getTransactionWithEffects(digest)];
|
|
255
|
-
case 3:
|
|
256
|
-
txn = _a.sent();
|
|
257
|
-
priceOracle = void 0;
|
|
258
|
-
managerCap = void 0;
|
|
259
|
-
if (txn.effects.created[0].owner["AddressOwner"] == undefined) {
|
|
260
|
-
priceOracle = txn.effects.created[0].reference.objectId;
|
|
261
|
-
managerCap = txn.effects.created[1].reference.objectId;
|
|
262
|
-
}
|
|
263
|
-
else {
|
|
264
|
-
priceOracle = txn.effects.created[1].reference.objectId;
|
|
265
|
-
managerCap = txn.effects.created[0].reference.objectId;
|
|
266
|
-
}
|
|
267
|
-
resolve([priceOracle, managerCap]);
|
|
268
|
-
return [3 /*break*/, 5];
|
|
269
|
-
case 4:
|
|
270
|
-
e_1 = _a.sent();
|
|
271
|
-
console.error("err in createPriceOracle");
|
|
272
|
-
reject(e_1);
|
|
273
|
-
return [3 /*break*/, 5];
|
|
274
|
-
case 5: return [2 /*return*/];
|
|
275
|
-
}
|
|
276
|
-
});
|
|
277
|
-
}); })];
|
|
278
|
-
});
|
|
279
|
-
});
|
|
280
|
-
}
|
|
281
236
|
function updatePriceOracle(priceOracle, priceOracleManager, typeArgument, price, ts) {
|
|
282
237
|
return __awaiter(this, void 0, void 0, function () {
|
|
283
238
|
var _this = this;
|
|
284
239
|
return __generator(this, function (_a) {
|
|
285
240
|
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
286
|
-
var updateOracleTx,
|
|
241
|
+
var updateOracleTx, e_1;
|
|
287
242
|
return __generator(this, function (_a) {
|
|
288
243
|
switch (_a.label) {
|
|
289
244
|
case 0:
|
|
@@ -298,7 +253,7 @@ function updatePriceOracle(priceOracle, priceOracleManager, typeArgument, price,
|
|
|
298
253
|
resolve(null);
|
|
299
254
|
return [3 /*break*/, 4];
|
|
300
255
|
case 3:
|
|
301
|
-
|
|
256
|
+
e_1 = _a.sent();
|
|
302
257
|
console.error("err in updatePriceOracle");
|
|
303
258
|
reject();
|
|
304
259
|
return [3 /*break*/, 4];
|
|
@@ -316,7 +271,7 @@ function updateTimeOracle(timeOracle, managerCap, ts) {
|
|
|
316
271
|
var _this = this;
|
|
317
272
|
return __generator(this, function (_a) {
|
|
318
273
|
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
319
|
-
var updateTimeOracleTx,
|
|
274
|
+
var updateTimeOracleTx, e_2;
|
|
320
275
|
return __generator(this, function (_a) {
|
|
321
276
|
switch (_a.label) {
|
|
322
277
|
case 0:
|
|
@@ -331,7 +286,7 @@ function updateTimeOracle(timeOracle, managerCap, ts) {
|
|
|
331
286
|
resolve(null);
|
|
332
287
|
return [3 /*break*/, 4];
|
|
333
288
|
case 3:
|
|
334
|
-
|
|
289
|
+
e_2 = _a.sent();
|
|
335
290
|
console.error("err in updateTimeOracle");
|
|
336
291
|
reject();
|
|
337
292
|
return [3 /*break*/, 4];
|
|
@@ -349,7 +304,7 @@ function createNewVault(packageId, registry, typeArgument, managerCap, timeOracl
|
|
|
349
304
|
var _this = this;
|
|
350
305
|
return __generator(this, function (_a) {
|
|
351
306
|
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
352
|
-
var newCoveredCallVaultTx, moveCallTxn,
|
|
307
|
+
var newCoveredCallVaultTx, moveCallTxn, e_3;
|
|
353
308
|
return __generator(this, function (_a) {
|
|
354
309
|
switch (_a.label) {
|
|
355
310
|
case 0:
|
|
@@ -367,7 +322,7 @@ function createNewVault(packageId, registry, typeArgument, managerCap, timeOracl
|
|
|
367
322
|
resolve(null);
|
|
368
323
|
return [3 /*break*/, 5];
|
|
369
324
|
case 4:
|
|
370
|
-
|
|
325
|
+
e_3 = _a.sent();
|
|
371
326
|
console.error("err in createNewVault");
|
|
372
327
|
reject();
|
|
373
328
|
return [3 /*break*/, 5];
|
|
@@ -382,8 +337,8 @@ function createNewVault(packageId, registry, typeArgument, managerCap, timeOracl
|
|
|
382
337
|
}
|
|
383
338
|
function checkData(moveCallTxn) {
|
|
384
339
|
return __awaiter(this, void 0, void 0, function () {
|
|
385
|
-
var txn, _a, _b, obj,
|
|
386
|
-
var
|
|
340
|
+
var txn, _a, _b, obj, e_4;
|
|
341
|
+
var e_5, _c;
|
|
387
342
|
return __generator(this, function (_d) {
|
|
388
343
|
switch (_d.label) {
|
|
389
344
|
case 0:
|
|
@@ -401,17 +356,17 @@ function checkData(moveCallTxn) {
|
|
|
401
356
|
console.log("new covered call vault: " + obj.reference.objectId);
|
|
402
357
|
}
|
|
403
358
|
}
|
|
404
|
-
catch (
|
|
359
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
405
360
|
finally {
|
|
406
361
|
try {
|
|
407
362
|
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
408
363
|
}
|
|
409
|
-
finally { if (
|
|
364
|
+
finally { if (e_5) throw e_5.error; }
|
|
410
365
|
}
|
|
411
366
|
return [3 /*break*/, 3];
|
|
412
367
|
case 2:
|
|
413
|
-
|
|
414
|
-
console.error(
|
|
368
|
+
e_4 = _d.sent();
|
|
369
|
+
console.error(e_4);
|
|
415
370
|
return [3 /*break*/, 3];
|
|
416
371
|
case 3: return [2 /*return*/];
|
|
417
372
|
}
|
|
@@ -441,7 +396,7 @@ function depositToVault(typeArgument, vaultIndex, depositAmount) {
|
|
|
441
396
|
var _this = this;
|
|
442
397
|
return __generator(this, function (_a) {
|
|
443
398
|
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
444
|
-
var depositTx,
|
|
399
|
+
var depositTx, e_6;
|
|
445
400
|
return __generator(this, function (_a) {
|
|
446
401
|
switch (_a.label) {
|
|
447
402
|
case 0:
|
|
@@ -456,8 +411,8 @@ function depositToVault(typeArgument, vaultIndex, depositAmount) {
|
|
|
456
411
|
resolve(null);
|
|
457
412
|
return [3 /*break*/, 4];
|
|
458
413
|
case 3:
|
|
459
|
-
|
|
460
|
-
console.log(
|
|
414
|
+
e_6 = _a.sent();
|
|
415
|
+
console.log(e_6);
|
|
461
416
|
console.error("err in depositToVault");
|
|
462
417
|
return [3 /*break*/, 4];
|
|
463
418
|
case 4: return [2 /*return*/];
|
|
@@ -469,17 +424,17 @@ function depositToVault(typeArgument, vaultIndex, depositAmount) {
|
|
|
469
424
|
});
|
|
470
425
|
});
|
|
471
426
|
}
|
|
472
|
-
function createNewAuctionWithNextCoveredCallVault(typeArgument, vaultIndex, timeOracle, activationTsMs, expirationTsMs) {
|
|
427
|
+
function createNewAuctionWithNextCoveredCallVault(typeArgument, vaultIndex, priceOracle, timeOracle, activationTsMs, expirationTsMs) {
|
|
473
428
|
return __awaiter(this, void 0, void 0, function () {
|
|
474
429
|
var _this = this;
|
|
475
430
|
return __generator(this, function (_a) {
|
|
476
431
|
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
477
|
-
var txn,
|
|
432
|
+
var txn, e_7;
|
|
478
433
|
return __generator(this, function (_a) {
|
|
479
434
|
switch (_a.label) {
|
|
480
435
|
case 0:
|
|
481
436
|
_a.trys.push([0, 3, , 4]);
|
|
482
|
-
return [4 /*yield*/, (0, getNewAuctionWithNextCoveredCallVaultTx_1.getNewAuctionWithNextCoveredCallVaultTx)(constants_1.COVERED_CALL_PACKAGE, constants_1.COVERED_CALL_MANAGER, constants_1.COVERED_CALL_REGISTRY, typeArgument, vaultIndex, timeOracle, activationTsMs, expirationTsMs)];
|
|
437
|
+
return [4 /*yield*/, (0, getNewAuctionWithNextCoveredCallVaultTx_1.getNewAuctionWithNextCoveredCallVaultTx)(constants_1.COVERED_CALL_PACKAGE, constants_1.COVERED_CALL_MANAGER, constants_1.COVERED_CALL_REGISTRY, typeArgument, vaultIndex, priceOracle, timeOracle, activationTsMs, expirationTsMs)];
|
|
483
438
|
case 1:
|
|
484
439
|
txn = _a.sent();
|
|
485
440
|
return [4 /*yield*/, signer.executeMoveCall(txn)];
|
|
@@ -489,7 +444,7 @@ function createNewAuctionWithNextCoveredCallVault(typeArgument, vaultIndex, time
|
|
|
489
444
|
resolve(null);
|
|
490
445
|
return [3 /*break*/, 4];
|
|
491
446
|
case 3:
|
|
492
|
-
|
|
447
|
+
e_7 = _a.sent();
|
|
493
448
|
console.error("err in createNewAuctionWithNextCoveredCallVault");
|
|
494
449
|
return [3 /*break*/, 4];
|
|
495
450
|
case 4: return [2 /*return*/];
|
|
@@ -506,7 +461,7 @@ function newBid(typeArgument, vaultIndex, size, token, timeOracle) {
|
|
|
506
461
|
var _this = this;
|
|
507
462
|
return __generator(this, function (_a) {
|
|
508
463
|
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
509
|
-
var newBidTx,
|
|
464
|
+
var newBidTx, e_8;
|
|
510
465
|
return __generator(this, function (_a) {
|
|
511
466
|
switch (_a.label) {
|
|
512
467
|
case 0:
|
|
@@ -521,8 +476,8 @@ function newBid(typeArgument, vaultIndex, size, token, timeOracle) {
|
|
|
521
476
|
resolve(null);
|
|
522
477
|
return [3 /*break*/, 4];
|
|
523
478
|
case 3:
|
|
524
|
-
|
|
525
|
-
console.error(
|
|
479
|
+
e_8 = _a.sent();
|
|
480
|
+
console.error(e_8);
|
|
526
481
|
return [3 /*break*/, 4];
|
|
527
482
|
case 4: return [2 /*return*/];
|
|
528
483
|
}
|
|
@@ -538,7 +493,7 @@ function delivery(typeArgument, vaultIndex, sellSize, timeOracle) {
|
|
|
538
493
|
var _this = this;
|
|
539
494
|
return __generator(this, function (_a) {
|
|
540
495
|
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
541
|
-
var deliveryTx,
|
|
496
|
+
var deliveryTx, e_9;
|
|
542
497
|
return __generator(this, function (_a) {
|
|
543
498
|
switch (_a.label) {
|
|
544
499
|
case 0:
|
|
@@ -553,7 +508,7 @@ function delivery(typeArgument, vaultIndex, sellSize, timeOracle) {
|
|
|
553
508
|
resolve(null);
|
|
554
509
|
return [3 /*break*/, 4];
|
|
555
510
|
case 3:
|
|
556
|
-
|
|
511
|
+
e_9 = _a.sent();
|
|
557
512
|
console.error("err in delivery");
|
|
558
513
|
reject();
|
|
559
514
|
return [3 /*break*/, 4];
|
|
@@ -571,7 +526,7 @@ function updatePayoffConfig(typeArgument, vaultIndex, price, premiumRoi, exposur
|
|
|
571
526
|
var _this = this;
|
|
572
527
|
return __generator(this, function (_a) {
|
|
573
528
|
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
574
|
-
var updatePayoffConfigTx,
|
|
529
|
+
var updatePayoffConfigTx, e_10;
|
|
575
530
|
return __generator(this, function (_a) {
|
|
576
531
|
switch (_a.label) {
|
|
577
532
|
case 0:
|
|
@@ -586,8 +541,8 @@ function updatePayoffConfig(typeArgument, vaultIndex, price, premiumRoi, exposur
|
|
|
586
541
|
resolve(null);
|
|
587
542
|
return [3 /*break*/, 4];
|
|
588
543
|
case 3:
|
|
589
|
-
|
|
590
|
-
console.error(
|
|
544
|
+
e_10 = _a.sent();
|
|
545
|
+
console.error(e_10);
|
|
591
546
|
reject();
|
|
592
547
|
return [3 /*break*/, 4];
|
|
593
548
|
case 4: return [2 /*return*/];
|
|
@@ -604,7 +559,7 @@ function settle(typeArgument, vaultIndex, priceOracle, timeOracle) {
|
|
|
604
559
|
var _this = this;
|
|
605
560
|
return __generator(this, function (_a) {
|
|
606
561
|
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
607
|
-
var settleTx,
|
|
562
|
+
var settleTx, e_11;
|
|
608
563
|
return __generator(this, function (_a) {
|
|
609
564
|
switch (_a.label) {
|
|
610
565
|
case 0:
|
|
@@ -619,8 +574,8 @@ function settle(typeArgument, vaultIndex, priceOracle, timeOracle) {
|
|
|
619
574
|
resolve(null);
|
|
620
575
|
return [3 /*break*/, 4];
|
|
621
576
|
case 3:
|
|
622
|
-
|
|
623
|
-
console.error(
|
|
577
|
+
e_11 = _a.sent();
|
|
578
|
+
console.error(e_11);
|
|
624
579
|
reject();
|
|
625
580
|
return [3 /*break*/, 4];
|
|
626
581
|
case 4: return [2 /*return*/];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getBid(dov: string): Promise<any>;
|
|
@@ -0,0 +1,56 @@
|
|
|
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 (_) 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.getBid = void 0;
|
|
40
|
+
var sui_js_1 = require("@mysten/sui.js");
|
|
41
|
+
var provider = new sui_js_1.JsonRpcProvider(sui_js_1.Network.DEVNET); //for read only operations
|
|
42
|
+
function getBid(dov) {
|
|
43
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
44
|
+
var obj;
|
|
45
|
+
return __generator(this, function (_a) {
|
|
46
|
+
switch (_a.label) {
|
|
47
|
+
case 0: return [4 /*yield*/, provider.getObject(dov)];
|
|
48
|
+
case 1:
|
|
49
|
+
obj = _a.sent();
|
|
50
|
+
console.log(obj);
|
|
51
|
+
return [2 /*return*/];
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
exports.getBid = getBid;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function createPriceOracle(typeArgument: string): Promise<[string, string]>;
|
|
@@ -0,0 +1,92 @@
|
|
|
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 (_) 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.createPriceOracle = void 0;
|
|
40
|
+
var getNewOracleTx_1 = require("../../utils/getNewOracleTx");
|
|
41
|
+
var constants_1 = require("../../constants");
|
|
42
|
+
var sui_js_1 = require("@mysten/sui.js");
|
|
43
|
+
var provider = new sui_js_1.JsonRpcProvider(sui_js_1.Network.DEVNET); //for read only operations
|
|
44
|
+
var keypair = sui_js_1.Ed25519Keypair.deriveKeypair(constants_1.TEST_MNEMONIC);
|
|
45
|
+
var signer = new sui_js_1.RawSigner(keypair, provider);
|
|
46
|
+
var decimal = 8;
|
|
47
|
+
function createPriceOracle(typeArgument) {
|
|
48
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
49
|
+
var _this = this;
|
|
50
|
+
return __generator(this, function (_a) {
|
|
51
|
+
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
52
|
+
var newOracleTx, moveCallTxn, digest, txn, priceOracle, managerCap, e_1;
|
|
53
|
+
return __generator(this, function (_a) {
|
|
54
|
+
switch (_a.label) {
|
|
55
|
+
case 0:
|
|
56
|
+
_a.trys.push([0, 4, , 5]);
|
|
57
|
+
console.log("create new price oracle...");
|
|
58
|
+
return [4 /*yield*/, (0, getNewOracleTx_1.getNewOracleTx)(constants_1.ORACLE_PACKAGE, typeArgument, decimal)];
|
|
59
|
+
case 1:
|
|
60
|
+
newOracleTx = _a.sent();
|
|
61
|
+
return [4 /*yield*/, signer.executeMoveCall(newOracleTx)];
|
|
62
|
+
case 2:
|
|
63
|
+
moveCallTxn = _a.sent();
|
|
64
|
+
digest = moveCallTxn.EffectsCert.certificate.transactionDigest;
|
|
65
|
+
return [4 /*yield*/, provider.getTransactionWithEffects(digest)];
|
|
66
|
+
case 3:
|
|
67
|
+
txn = _a.sent();
|
|
68
|
+
priceOracle = void 0;
|
|
69
|
+
managerCap = void 0;
|
|
70
|
+
if (txn.effects.created[0].owner["AddressOwner"] == undefined) {
|
|
71
|
+
priceOracle = txn.effects.created[0].reference.objectId;
|
|
72
|
+
managerCap = txn.effects.created[1].reference.objectId;
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
priceOracle = txn.effects.created[1].reference.objectId;
|
|
76
|
+
managerCap = txn.effects.created[0].reference.objectId;
|
|
77
|
+
}
|
|
78
|
+
resolve([priceOracle, managerCap]);
|
|
79
|
+
return [3 /*break*/, 5];
|
|
80
|
+
case 4:
|
|
81
|
+
e_1 = _a.sent();
|
|
82
|
+
console.error("err in createPriceOracle");
|
|
83
|
+
reject(e_1);
|
|
84
|
+
return [3 /*break*/, 5];
|
|
85
|
+
case 5: return [2 /*return*/];
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
}); })];
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
exports.createPriceOracle = createPriceOracle;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function getNewAuctionTx(packageId: string, registry: string, typeArgument: string, managerCap: string, index: number): Promise<any>;
|
|
1
|
+
export declare function getNewAuctionTx(packageId: string, registry: string, typeArgument: string, managerCap: string, index: number, priceOracle: string, timeOracle: string): 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.getNewAuctionTx = void 0;
|
|
40
|
-
function getNewAuctionTx(packageId, registry, typeArgument, managerCap, index) {
|
|
40
|
+
function getNewAuctionTx(packageId, registry, typeArgument, managerCap, index, priceOracle, timeOracle) {
|
|
41
41
|
return __awaiter(this, void 0, void 0, function () {
|
|
42
42
|
var tx;
|
|
43
43
|
return __generator(this, function (_a) {
|
|
@@ -50,6 +50,8 @@ function getNewAuctionTx(packageId, registry, typeArgument, managerCap, index) {
|
|
|
50
50
|
managerCap,
|
|
51
51
|
registry,
|
|
52
52
|
index,
|
|
53
|
+
priceOracle,
|
|
54
|
+
timeOracle,
|
|
53
55
|
],
|
|
54
56
|
gasBudget: 1000,
|
|
55
57
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function getNewAuctionWithNextCoveredCallVaultTx(packageId: string, managerCap: string, registry: string, typeArgument: string, index: number, timeOracle: string, activationTsMs: number, expirationTsMs: number): Promise<any>;
|
|
1
|
+
export declare function getNewAuctionWithNextCoveredCallVaultTx(packageId: string, managerCap: string, registry: string, typeArgument: string, index: number, priceOracle: string, timeOracle: string, activationTsMs: number, expirationTsMs: 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.getNewAuctionWithNextCoveredCallVaultTx = void 0;
|
|
40
|
-
function getNewAuctionWithNextCoveredCallVaultTx(packageId, managerCap, registry, typeArgument, index, timeOracle, activationTsMs, expirationTsMs) {
|
|
40
|
+
function getNewAuctionWithNextCoveredCallVaultTx(packageId, managerCap, registry, typeArgument, index, priceOracle, timeOracle, activationTsMs, expirationTsMs) {
|
|
41
41
|
return __awaiter(this, void 0, void 0, function () {
|
|
42
42
|
var tx;
|
|
43
43
|
return __generator(this, function (_a) {
|
|
@@ -50,6 +50,7 @@ function getNewAuctionWithNextCoveredCallVaultTx(packageId, managerCap, registry
|
|
|
50
50
|
managerCap,
|
|
51
51
|
registry,
|
|
52
52
|
index,
|
|
53
|
+
priceOracle,
|
|
53
54
|
timeOracle,
|
|
54
55
|
activationTsMs,
|
|
55
56
|
expirationTsMs,
|
package/lib/utils/fetchData.d.ts
CHANGED
|
@@ -50,7 +50,8 @@ function getTypeArgumentFromToken(token) {
|
|
|
50
50
|
case 1:
|
|
51
51
|
tmp = _a.sent();
|
|
52
52
|
if (tmp.status != "Exists") {
|
|
53
|
-
console.log("obj not exists");
|
|
53
|
+
console.log("obj not exists, but is:");
|
|
54
|
+
console.log(tmp.status);
|
|
54
55
|
return [2 /*return*/];
|
|
55
56
|
}
|
|
56
57
|
typeArgument = tmp.details.data.type;
|
|
@@ -152,6 +152,8 @@ function getVaultDataFromRegistry(registry) {
|
|
|
152
152
|
rollingSubVault: rolling,
|
|
153
153
|
};
|
|
154
154
|
var tvl = Number(vault.regular_sub_vault.fields.balance) + Number(vault.rolling_sub_vault.fields.balance);
|
|
155
|
+
//@ts-ignore
|
|
156
|
+
var next = objInfo.details.data.fields.value.fields.next;
|
|
155
157
|
var res = {
|
|
156
158
|
vaultId: vaultId,
|
|
157
159
|
vaultIdx: vaultIdx,
|
|
@@ -159,6 +161,7 @@ function getVaultDataFromRegistry(registry) {
|
|
|
159
161
|
config: configRes,
|
|
160
162
|
vault: vaultRes,
|
|
161
163
|
prevBalance: prevBalance,
|
|
164
|
+
next: next,
|
|
162
165
|
tvl: tvl,
|
|
163
166
|
};
|
|
164
167
|
vaults.push(res);
|