@typus/typus-sdk 0.1.7 → 0.1.9
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 +8 -5
- package/lib/constants.js +10 -8
- package/lib/scripts/coveredCall/getClaimAllTx.d.ts +1 -0
- package/lib/scripts/coveredCall/getClaimAllTx.js +56 -0
- package/lib/scripts/coveredCall/getClaimTx.d.ts +1 -0
- package/lib/scripts/coveredCall/getClaimTx.js +57 -0
- package/lib/scripts/coveredCall/getNewAuctionWithNextCoveredCallVaultTx.js +2 -4
- package/lib/scripts/coveredCall/getNewCoveredCallVaultTx.js +2 -5
- package/lib/scripts/coveredCall/getNewManagerTx.d.ts +1 -0
- package/lib/scripts/coveredCall/getNewManagerTx.js +55 -0
- package/lib/scripts/coveredCall/getRemoveManagerTx.d.ts +1 -0
- package/lib/scripts/coveredCall/getRemoveManagerTx.js +54 -0
- package/lib/scripts/coveredCall/getRollOverTx.d.ts +1 -0
- package/lib/scripts/coveredCall/getRollOverTx.js +55 -0
- package/lib/scripts/coveredCall/getSettleTx.d.ts +1 -0
- package/lib/scripts/coveredCall/getSettleTx.js +57 -0
- package/lib/scripts/coveredCall/getSettleWithRollOverTx.d.ts +1 -0
- package/lib/scripts/coveredCall/getSettleWithRollOverTx.js +57 -0
- package/lib/scripts/coveredCall/getUpdatePayoffConfigTx.d.ts +1 -0
- package/lib/scripts/coveredCall/getUpdatePayoffConfigTx.js +57 -0
- package/lib/scripts/getMintTx.js +1 -1
- package/lib/scripts/getNewOracleTx.js +1 -1
- package/lib/scripts/getNewTimeOracleTx.d.ts +1 -0
- package/lib/scripts/getNewTimeOracleTx.js +54 -0
- package/lib/scripts/getSubVault.d.ts +0 -1
- package/lib/scripts/getSubVault.js +5 -51
- package/lib/scripts/getUpdateTimeOracleTx.d.ts +1 -0
- package/lib/scripts/getUpdateTimeOracleTx.js +59 -0
- package/lib/test/testDeposit.js +2 -2
- package/lib/test/testMint.js +11 -9
- package/lib/test/testNewVault.js +8 -10
- package/lib/test/testSettle.d.ts +1 -0
- package/lib/test/testSettle.js +437 -0
- package/lib/test/testWithdraw.d.ts +1 -0
- package/lib/test/testWithdraw.js +70 -0
- package/lib/utils/coveredCall/getClaimAllTx.d.ts +1 -0
- package/lib/utils/coveredCall/getClaimAllTx.js +60 -0
- package/lib/utils/coveredCall/getClaimTx.d.ts +1 -0
- package/lib/utils/coveredCall/getClaimTx.js +61 -0
- package/lib/utils/coveredCall/getNewAuctionWithNextCoveredCallVaultTx.d.ts +1 -1
- package/lib/utils/coveredCall/getNewAuctionWithNextCoveredCallVaultTx.js +1 -2
- package/lib/utils/coveredCall/getNewCoveredCallVaultTx.d.ts +1 -1
- package/lib/utils/coveredCall/getNewCoveredCallVaultTx.js +1 -3
- package/lib/utils/coveredCall/getNewManagerTx.d.ts +1 -0
- package/lib/utils/coveredCall/getNewManagerTx.js +59 -0
- package/lib/utils/coveredCall/getRemoveManagerTx.d.ts +1 -0
- package/lib/utils/coveredCall/getRemoveManagerTx.js +58 -0
- package/lib/utils/coveredCall/getRollOverTx.d.ts +1 -0
- package/lib/utils/coveredCall/getRollOverTx.js +60 -0
- package/lib/utils/coveredCall/getSettleTx.d.ts +1 -0
- package/lib/utils/coveredCall/getSettleTx.js +62 -0
- package/lib/utils/coveredCall/getSettleWithRollOverTx.d.ts +1 -0
- package/lib/utils/coveredCall/getSettleWithRollOverTx.js +62 -0
- package/lib/utils/coveredCall/getUpdatePayoffConfigTx.d.ts +1 -0
- package/lib/utils/coveredCall/getUpdatePayoffConfigTx.js +62 -0
- package/lib/utils/getNewTimeOracleTx.d.ts +1 -0
- package/lib/utils/getNewTimeOracleTx.js +56 -0
- package/lib/utils/getSubVault.d.ts +0 -3
- package/lib/utils/getSubVault.js +51 -137
- package/lib/utils/getUpdateTimeOracleTx.d.ts +1 -0
- package/lib/utils/getUpdateTimeOracleTx.js +60 -0
- package/lib/utils/getVaultIndexInRegistry.d.ts +1 -0
- package/lib/utils/getVaultIndexInRegistry.js +56 -0
- package/package.json +1 -1
package/lib/utils/getSubVault.js
CHANGED
|
@@ -1,138 +1,52 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
var provider = new sui_js_1.JsonRpcProvider(sui_js_1.Network.DEVNET); //for read only operations
|
|
54
|
-
function subVaults() {
|
|
55
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
56
|
-
return __generator(this, function (_a) {
|
|
57
|
-
switch (_a.label) {
|
|
58
|
-
case 0: return [4 /*yield*/, subVaultsV2(constants_1.COVERED_CALL_REGISTRY, provider)];
|
|
59
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
exports.subVaults = subVaults;
|
|
65
|
-
function subVaultsV2(registry, provider) {
|
|
66
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
67
|
-
var tmpObj1, vault, tmpObj2, table, tmpObj3, subVaultsId_2, subVaultsMap, subVaultsId_1, subVaultsId_1_1, e, tmpObj4, e_1_1;
|
|
68
|
-
var e_1, _a;
|
|
69
|
-
return __generator(this, function (_b) {
|
|
70
|
-
switch (_b.label) {
|
|
71
|
-
case 0:
|
|
72
|
-
console.log("registry: " + registry);
|
|
73
|
-
return [4 /*yield*/, provider.getObjectsOwnedByObject(registry)];
|
|
74
|
-
case 1:
|
|
75
|
-
tmpObj1 = _b.sent();
|
|
76
|
-
console.log("vault num under registry:" + tmpObj1.length);
|
|
77
|
-
if (!(tmpObj1.length != 0)) return [3 /*break*/, 12];
|
|
78
|
-
vault = tmpObj1[0].objectId;
|
|
79
|
-
console.log("vault: " + vault);
|
|
80
|
-
return [4 /*yield*/, provider.getObject(vault)
|
|
81
|
-
//@ts-ignore
|
|
82
|
-
];
|
|
83
|
-
case 2:
|
|
84
|
-
tmpObj2 = _b.sent();
|
|
85
|
-
table = tmpObj2.details.data.fields.value.fields.sub_vaults.fields.id.id;
|
|
86
|
-
console.log("table: " + table);
|
|
87
|
-
return [4 /*yield*/, provider.getObjectsOwnedByObject(table)];
|
|
88
|
-
case 3:
|
|
89
|
-
tmpObj3 = _b.sent();
|
|
90
|
-
subVaultsId_2 = [];
|
|
91
|
-
tmpObj3.map(function (e) {
|
|
92
|
-
subVaultsId_2.push(e.objectId);
|
|
93
|
-
});
|
|
94
|
-
console.log("subVaults: ");
|
|
95
|
-
//@ts-ignore
|
|
96
|
-
console.log(subVaultsId_2);
|
|
97
|
-
subVaultsMap = new Map();
|
|
98
|
-
_b.label = 4;
|
|
99
|
-
case 4:
|
|
100
|
-
_b.trys.push([4, 9, 10, 11]);
|
|
101
|
-
subVaultsId_1 = __values(subVaultsId_2), subVaultsId_1_1 = subVaultsId_1.next();
|
|
102
|
-
_b.label = 5;
|
|
103
|
-
case 5:
|
|
104
|
-
if (!!subVaultsId_1_1.done) return [3 /*break*/, 8];
|
|
105
|
-
e = subVaultsId_1_1.value;
|
|
106
|
-
return [4 /*yield*/, provider.getObject(e)
|
|
107
|
-
//@ts-ignore
|
|
108
|
-
];
|
|
109
|
-
case 6:
|
|
110
|
-
tmpObj4 = _b.sent();
|
|
111
|
-
//@ts-ignore
|
|
112
|
-
subVaultsMap.set(tmpObj4.details.data.fields.name, tmpObj4.details.data.fields);
|
|
113
|
-
_b.label = 7;
|
|
114
|
-
case 7:
|
|
115
|
-
subVaultsId_1_1 = subVaultsId_1.next();
|
|
116
|
-
return [3 /*break*/, 5];
|
|
117
|
-
case 8: return [3 /*break*/, 11];
|
|
118
|
-
case 9:
|
|
119
|
-
e_1_1 = _b.sent();
|
|
120
|
-
e_1 = { error: e_1_1 };
|
|
121
|
-
return [3 /*break*/, 11];
|
|
122
|
-
case 10:
|
|
123
|
-
try {
|
|
124
|
-
if (subVaultsId_1_1 && !subVaultsId_1_1.done && (_a = subVaultsId_1.return)) _a.call(subVaultsId_1);
|
|
125
|
-
}
|
|
126
|
-
finally { if (e_1) throw e_1.error; }
|
|
127
|
-
return [7 /*endfinally*/];
|
|
128
|
-
case 11:
|
|
129
|
-
// console.log(subVaultsMap.get("rolling").value.fields.users_table)
|
|
130
|
-
return [2 /*return*/, subVaultsMap];
|
|
131
|
-
case 12:
|
|
132
|
-
console.log("no vault under this registry: " + registry);
|
|
133
|
-
return [2 /*return*/, null];
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
exports.subVaultsV2 = subVaultsV2;
|
|
2
|
+
// import { JsonRpcProvider, Network } from '@mysten/sui.js';
|
|
3
|
+
// import { COVERED_CALL_REGISTRY } from "../constants"
|
|
4
|
+
// const provider = new JsonRpcProvider(Network.DEVNET);//for read only operations
|
|
5
|
+
// export async function subVaults(): Promise<any> {
|
|
6
|
+
// // let data = await provider.getObject("0x9f3a10e5e7cc22092825c9a4e8269b37fb935a9d")
|
|
7
|
+
// // let data = await provider.getObjectsOwnedByObject("0x0fda36c64af91d4f9c946f00c6f13194c37493ab")
|
|
8
|
+
// // let data = await provider.getObject("0x933ab335ef83ef247ae43f537f9a76317feb7358")
|
|
9
|
+
// // console.log("data: ", JSON.stringify(data))
|
|
10
|
+
// return await subVaultsV2(COVERED_CALL_REGISTRY, provider)
|
|
11
|
+
// }
|
|
12
|
+
// export async function subVaultsV2(registry: string, provider: JsonRpcProvider): Promise<any> {
|
|
13
|
+
// console.log("registry: " + registry)
|
|
14
|
+
// //vault
|
|
15
|
+
// let tmpObj1 = await provider.getObjectsOwnedByObject(registry)
|
|
16
|
+
// console.log("vault num under registry:" + tmpObj1.length)
|
|
17
|
+
// if (tmpObj1.length != 0) {
|
|
18
|
+
// let vault = tmpObj1[0].objectId
|
|
19
|
+
// // let vault = "0x701c014a20294ee7e170148353a2dfe42fb5fb88"
|
|
20
|
+
// console.log("vault: " + vault)
|
|
21
|
+
// //table
|
|
22
|
+
// let tmpObj2 = await provider.getObject(vault)
|
|
23
|
+
// //@ts-ignore
|
|
24
|
+
// let tableId = tmpObj2.details.data.fields.value.fields.vault.fields.sub_vaults.fields.id.id
|
|
25
|
+
// console.log("table: " + tableId)
|
|
26
|
+
// //sub vault (maker / rolling / no_rolling) id
|
|
27
|
+
// let tmpObj3 = await provider.getObjectsOwnedByObject(tableId)
|
|
28
|
+
// let subVaultsId: string[] = [];
|
|
29
|
+
// tmpObj3.map(e => {
|
|
30
|
+
// // console.log("data: " + JSON.stringify(e))
|
|
31
|
+
// subVaultsId.push(e.objectId as string)
|
|
32
|
+
// }
|
|
33
|
+
// )
|
|
34
|
+
// console.log("subVaults: ")
|
|
35
|
+
// //@ts-ignore
|
|
36
|
+
// console.log(subVaultsId)
|
|
37
|
+
// //sub vault data
|
|
38
|
+
// const subVaultsMap = new Map();
|
|
39
|
+
// //@ts-ignore
|
|
40
|
+
// for (let e of subVaultsId) {
|
|
41
|
+
// let tmpObj4 = await provider.getObject(e)
|
|
42
|
+
// //@ts-ignore
|
|
43
|
+
// subVaultsMap.set(tmpObj4.details.data.fields.name, tmpObj4.details.data.fields)
|
|
44
|
+
// }
|
|
45
|
+
// // console.log(subVaultsMap.get("rolling").value.fields.users_table)
|
|
46
|
+
// return subVaultsMap
|
|
47
|
+
// } else {
|
|
48
|
+
// console.log("no vault under this registry: " + registry);
|
|
49
|
+
// return null;
|
|
50
|
+
// }
|
|
51
|
+
// }
|
|
52
|
+
// subVaults()
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getUpdateTimeOracleTx(packageId: string, oracle: string, managerCap: string, ts: number): Promise<any>;
|
|
@@ -0,0 +1,60 @@
|
|
|
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.getUpdateTimeOracleTx = void 0;
|
|
40
|
+
function getUpdateTimeOracleTx(packageId, oracle, managerCap, ts) {
|
|
41
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
42
|
+
var tx;
|
|
43
|
+
return __generator(this, function (_a) {
|
|
44
|
+
tx = {
|
|
45
|
+
packageObjectId: packageId,
|
|
46
|
+
module: 'unix_time',
|
|
47
|
+
function: 'update',
|
|
48
|
+
typeArguments: [],
|
|
49
|
+
arguments: [
|
|
50
|
+
oracle,
|
|
51
|
+
managerCap,
|
|
52
|
+
ts
|
|
53
|
+
],
|
|
54
|
+
gasBudget: 1000,
|
|
55
|
+
};
|
|
56
|
+
return [2 /*return*/, tx];
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
exports.getUpdateTimeOracleTx = getUpdateTimeOracleTx;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getVaultIndexInregistry(registry: string): Promise<number>;
|
|
@@ -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.getVaultIndexInregistry = 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 getVaultIndexInregistry(registry) {
|
|
43
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
44
|
+
var txn, index;
|
|
45
|
+
return __generator(this, function (_a) {
|
|
46
|
+
switch (_a.label) {
|
|
47
|
+
case 0: return [4 /*yield*/, provider.getObject(registry)];
|
|
48
|
+
case 1:
|
|
49
|
+
txn = _a.sent();
|
|
50
|
+
index = txn.details.data.fields.name;
|
|
51
|
+
return [2 /*return*/, index];
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
exports.getVaultIndexInregistry = getVaultIndexInregistry;
|