@typus/typus-sdk 0.1.3 → 0.1.5
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 +9 -11
- package/lib/constants.js +19 -15
- package/lib/scripts/coveredCall/{getCoveredCallDepositTx.d.ts → getDeliveryTx.d.ts} +0 -0
- package/lib/scripts/coveredCall/{getCoveredCallUnsubscribeTx.js → getDeliveryTx.js} +6 -6
- package/lib/scripts/{getDepositTx.d.ts → coveredCall/getDepositTx.d.ts} +0 -0
- package/lib/scripts/{getDepositTx.js → coveredCall/getDepositTx.js} +7 -8
- package/lib/scripts/coveredCall/{getCoveredCallUnsubscribeTx.d.ts → getNewAuctionTx.d.ts} +0 -0
- package/lib/scripts/{getNewSharkFinVaultTx.js → coveredCall/getNewAuctionTx.js} +13 -11
- package/lib/scripts/{getNewSharkFinVaultTx.d.ts → coveredCall/getNewAuctionWithNextCoveredCallVaultTx.d.ts} +0 -0
- package/lib/scripts/coveredCall/getNewAuctionWithNextCoveredCallVaultTx.js +65 -0
- package/lib/scripts/coveredCall/getNewBidTx.d.ts +1 -0
- package/lib/scripts/coveredCall/getNewBidTx.js +59 -0
- package/lib/scripts/coveredCall/getNewCoveredCallVaultTx.js +4 -2
- package/lib/scripts/coveredCall/getRemoveBidTx.d.ts +1 -0
- package/lib/scripts/coveredCall/getRemoveBidTx.js +56 -0
- package/lib/scripts/coveredCall/getSubscribeTx.d.ts +1 -0
- package/lib/scripts/coveredCall/getSubscribeTx.js +55 -0
- package/lib/scripts/coveredCall/getUnsubscribeTx.d.ts +1 -0
- package/lib/scripts/coveredCall/getUnsubscribeTx.js +55 -0
- package/lib/scripts/coveredCall/getWithdrawTx.d.ts +1 -0
- package/lib/scripts/coveredCall/{getCoveredCallDepositTx.js → getWithdrawTx.js} +6 -7
- package/lib/scripts/getNewOracleTx.js +3 -3
- package/lib/scripts/getUpdateOracleTx.js +1 -1
- package/lib/test/getUserShareFromRegistry.d.ts +1 -0
- package/lib/test/getUserShareFromRegistry.js +172 -0
- package/lib/test/testCrypto.d.ts +1 -0
- package/lib/test/testCrypto.js +54 -0
- package/lib/test/testDeposit.js +16 -43
- package/lib/test/testDepositV2.d.ts +0 -1
- package/lib/test/testDepositV2.js +61 -168
- package/lib/test/testMint.js +70 -30
- package/lib/test/testNewVault.d.ts +1 -0
- package/lib/test/testNewVault.js +171 -0
- package/lib/test/testOracle.js +4 -3
- package/lib/test/testSubscribeEvent.d.ts +1 -0
- package/lib/test/testSubscribeEvent.js +97 -0
- package/lib/test/testUnsubscribe.d.ts +1 -0
- package/lib/test/testUnsubscribe.js +86 -0
- package/lib/utils/auction/sealedAuction.d.ts +33 -0
- package/lib/utils/auction/sealedAuction.js +64 -0
- package/lib/utils/coveredCall/getDeliveryTx.d.ts +1 -0
- package/lib/utils/coveredCall/{getCoveredCallDepositTx.js → getDeliveryTx.js} +5 -10
- package/lib/utils/{getDepositTx.d.ts → coveredCall/getDepositTx.d.ts} +0 -0
- package/lib/utils/{getDepositTx.js → coveredCall/getDepositTx.js} +3 -3
- package/lib/utils/coveredCall/getNewAuctionTx.d.ts +1 -0
- package/lib/utils/{getNewSharkFinVaultTx.js → coveredCall/getNewAuctionTx.js} +15 -13
- package/lib/utils/coveredCall/getNewAuctionWithNextCoveredCallVaultTx.d.ts +1 -0
- package/lib/utils/coveredCall/getNewAuctionWithNextCoveredCallVaultTx.js +69 -0
- package/lib/utils/coveredCall/getNewBidTx.d.ts +1 -0
- package/lib/utils/coveredCall/getNewBidTx.js +62 -0
- package/lib/utils/coveredCall/getNewCoveredCallVaultTx.d.ts +1 -1
- package/lib/utils/coveredCall/getNewCoveredCallVaultTx.js +3 -2
- package/lib/utils/coveredCall/getRemoveBidTx.d.ts +1 -0
- package/lib/utils/coveredCall/getRemoveBidTx.js +60 -0
- package/lib/utils/coveredCall/getSubscribeTx.d.ts +1 -0
- package/lib/utils/coveredCall/getSubscribeTx.js +59 -0
- package/lib/utils/coveredCall/getUnsubscribeTx.d.ts +1 -0
- package/lib/utils/coveredCall/{getCoveredCallUnsubscribeTx.js → getUnsubscribeTx.js} +3 -3
- package/lib/utils/coveredCall/getWithdrawTx.d.ts +1 -0
- package/lib/utils/coveredCall/getWithdrawTx.js +61 -0
- package/lib/utils/fetchData.d.ts +11 -0
- package/lib/utils/fetchData.js +191 -0
- package/lib/utils/getNewOracleTx.d.ts +1 -1
- package/lib/utils/getNewOracleTx.js +2 -2
- package/lib/utils/getSubVault.js +1 -1
- package/lib/utils/getTypeArgumentFromToken.d.ts +1 -0
- package/lib/utils/getTypeArgumentFromToken.js +67 -0
- package/package.json +6 -2
- package/lib/utils/coveredCall/getCoveredCallDepositTx.d.ts +0 -1
- package/lib/utils/coveredCall/getCoveredCallUnsubscribeTx.d.ts +0 -1
- package/lib/utils/getNewSharkFinVaultTx.d.ts +0 -1
|
@@ -0,0 +1,172 @@
|
|
|
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 __values = (this && this.__values) || function(o) {
|
|
39
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
40
|
+
if (m) return m.call(o);
|
|
41
|
+
if (o && typeof o.length === "number") return {
|
|
42
|
+
next: function () {
|
|
43
|
+
if (o && i >= o.length) o = void 0;
|
|
44
|
+
return { value: o && o[i++], done: !o };
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
48
|
+
};
|
|
49
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
+
var constants_1 = require("../constants");
|
|
51
|
+
var fetchData_1 = require("../utils/fetchData");
|
|
52
|
+
/*
|
|
53
|
+
test sub vault:
|
|
54
|
+
0x1395a87663995fe2040fecf1866a01f9a0270fc2
|
|
55
|
+
test table under sub vault:
|
|
56
|
+
0x0fda36c64af91d4f9c946f00c6f13194c37493ab
|
|
57
|
+
test linked list node:
|
|
58
|
+
0x933ab335ef83ef247ae43f537f9a76317feb7358
|
|
59
|
+
*/
|
|
60
|
+
(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
61
|
+
var user, coveredCallVaults, coveredCallVaults_1, coveredCallVaults_1_1, coveredCallVault, tableUnderCoveredCallVault, subVaults, _a, _b, _i, e, tableUnderSubVault, linkedListNodes, linkedListNodes_1, linkedListNodes_1_1, linkedListNode, usersData, usersData_1, usersData_1_1, userData, e_1_1, e_2_1;
|
|
62
|
+
var e_2, _c, e_1, _d, e_3, _e;
|
|
63
|
+
return __generator(this, function (_f) {
|
|
64
|
+
switch (_f.label) {
|
|
65
|
+
case 0:
|
|
66
|
+
user = "0x81c962005db9bd02711b00909cd28a707ec0a248";
|
|
67
|
+
//from registry find covered call vaults
|
|
68
|
+
console.log("registry: " + constants_1.COVERED_CALL_REGISTRY);
|
|
69
|
+
return [4 /*yield*/, (0, fetchData_1.getCoveredCallVaultsFromRegistry)(user)];
|
|
70
|
+
case 1:
|
|
71
|
+
coveredCallVaults = _f.sent();
|
|
72
|
+
_f.label = 2;
|
|
73
|
+
case 2:
|
|
74
|
+
_f.trys.push([2, 20, 21, 22]);
|
|
75
|
+
coveredCallVaults_1 = __values(coveredCallVaults), coveredCallVaults_1_1 = coveredCallVaults_1.next();
|
|
76
|
+
_f.label = 3;
|
|
77
|
+
case 3:
|
|
78
|
+
if (!!coveredCallVaults_1_1.done) return [3 /*break*/, 19];
|
|
79
|
+
coveredCallVault = coveredCallVaults_1_1.value;
|
|
80
|
+
return [4 /*yield*/, (0, fetchData_1.getTableFromCoveredCallVault)(coveredCallVault)
|
|
81
|
+
//from table find sub vault
|
|
82
|
+
];
|
|
83
|
+
case 4:
|
|
84
|
+
tableUnderCoveredCallVault = _f.sent();
|
|
85
|
+
return [4 /*yield*/, (0, fetchData_1.getSubVaultsFromTable)(tableUnderCoveredCallVault)
|
|
86
|
+
//from sub vault find table
|
|
87
|
+
];
|
|
88
|
+
case 5:
|
|
89
|
+
subVaults = _f.sent();
|
|
90
|
+
_a = [];
|
|
91
|
+
for (_b in subVaults)
|
|
92
|
+
_a.push(_b);
|
|
93
|
+
_i = 0;
|
|
94
|
+
_f.label = 6;
|
|
95
|
+
case 6:
|
|
96
|
+
if (!(_i < _a.length)) return [3 /*break*/, 17];
|
|
97
|
+
e = _a[_i];
|
|
98
|
+
return [4 /*yield*/, (0, fetchData_1.getTableUnderSubVault)(subVaults[e])
|
|
99
|
+
//from table find linked list node
|
|
100
|
+
];
|
|
101
|
+
case 7:
|
|
102
|
+
tableUnderSubVault = _f.sent();
|
|
103
|
+
return [4 /*yield*/, (0, fetchData_1.getLinkedListNodesFromTable)(tableUnderSubVault)
|
|
104
|
+
//from linkedListNode find user data
|
|
105
|
+
];
|
|
106
|
+
case 8:
|
|
107
|
+
linkedListNodes = _f.sent();
|
|
108
|
+
_f.label = 9;
|
|
109
|
+
case 9:
|
|
110
|
+
_f.trys.push([9, 14, 15, 16]);
|
|
111
|
+
linkedListNodes_1 = (e_1 = void 0, __values(linkedListNodes)), linkedListNodes_1_1 = linkedListNodes_1.next();
|
|
112
|
+
_f.label = 10;
|
|
113
|
+
case 10:
|
|
114
|
+
if (!!linkedListNodes_1_1.done) return [3 /*break*/, 13];
|
|
115
|
+
linkedListNode = linkedListNodes_1_1.value;
|
|
116
|
+
return [4 /*yield*/, (0, fetchData_1.getUserDataFromLinkedListNode)(linkedListNode)
|
|
117
|
+
//TODO: from user data to match specific user
|
|
118
|
+
];
|
|
119
|
+
case 11:
|
|
120
|
+
usersData = _f.sent();
|
|
121
|
+
try {
|
|
122
|
+
//TODO: from user data to match specific user
|
|
123
|
+
for (usersData_1 = (e_3 = void 0, __values(usersData)), usersData_1_1 = usersData_1.next(); !usersData_1_1.done; usersData_1_1 = usersData_1.next()) {
|
|
124
|
+
userData = usersData_1_1.value;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
128
|
+
finally {
|
|
129
|
+
try {
|
|
130
|
+
if (usersData_1_1 && !usersData_1_1.done && (_e = usersData_1.return)) _e.call(usersData_1);
|
|
131
|
+
}
|
|
132
|
+
finally { if (e_3) throw e_3.error; }
|
|
133
|
+
}
|
|
134
|
+
_f.label = 12;
|
|
135
|
+
case 12:
|
|
136
|
+
linkedListNodes_1_1 = linkedListNodes_1.next();
|
|
137
|
+
return [3 /*break*/, 10];
|
|
138
|
+
case 13: return [3 /*break*/, 16];
|
|
139
|
+
case 14:
|
|
140
|
+
e_1_1 = _f.sent();
|
|
141
|
+
e_1 = { error: e_1_1 };
|
|
142
|
+
return [3 /*break*/, 16];
|
|
143
|
+
case 15:
|
|
144
|
+
try {
|
|
145
|
+
if (linkedListNodes_1_1 && !linkedListNodes_1_1.done && (_d = linkedListNodes_1.return)) _d.call(linkedListNodes_1);
|
|
146
|
+
}
|
|
147
|
+
finally { if (e_1) throw e_1.error; }
|
|
148
|
+
return [7 /*endfinally*/];
|
|
149
|
+
case 16:
|
|
150
|
+
_i++;
|
|
151
|
+
return [3 /*break*/, 6];
|
|
152
|
+
case 17:
|
|
153
|
+
console.log("------------------------------------------------");
|
|
154
|
+
_f.label = 18;
|
|
155
|
+
case 18:
|
|
156
|
+
coveredCallVaults_1_1 = coveredCallVaults_1.next();
|
|
157
|
+
return [3 /*break*/, 3];
|
|
158
|
+
case 19: return [3 /*break*/, 22];
|
|
159
|
+
case 20:
|
|
160
|
+
e_2_1 = _f.sent();
|
|
161
|
+
e_2 = { error: e_2_1 };
|
|
162
|
+
return [3 /*break*/, 22];
|
|
163
|
+
case 21:
|
|
164
|
+
try {
|
|
165
|
+
if (coveredCallVaults_1_1 && !coveredCallVaults_1_1.done && (_c = coveredCallVaults_1.return)) _c.call(coveredCallVaults_1);
|
|
166
|
+
}
|
|
167
|
+
finally { if (e_2) throw e_2.error; }
|
|
168
|
+
return [7 /*endfinally*/];
|
|
169
|
+
case 22: return [2 /*return*/];
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
}); })();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,54 @@
|
|
|
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 sealedAuction_1 = require("../utils/auction/sealedAuction");
|
|
40
|
+
(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
41
|
+
var price, size, secret, encryptedBid, hash, bid;
|
|
42
|
+
return __generator(this, function (_a) {
|
|
43
|
+
price = BigInt(100);
|
|
44
|
+
size = BigInt(2);
|
|
45
|
+
secret = "my secret";
|
|
46
|
+
encryptedBid = (0, sealedAuction_1.encryptBid)(price, size, secret);
|
|
47
|
+
console.log("encryptedBid: ", encryptedBid);
|
|
48
|
+
hash = (0, sealedAuction_1.getBidHash)(price, size, encryptedBid[0]);
|
|
49
|
+
console.log("hash: ", hash);
|
|
50
|
+
bid = (0, sealedAuction_1.decryptBid)(encryptedBid[1], "my secret");
|
|
51
|
+
console.log("bid: ", bid);
|
|
52
|
+
return [2 /*return*/];
|
|
53
|
+
});
|
|
54
|
+
}); })();
|
package/lib/test/testDeposit.js
CHANGED
|
@@ -36,66 +36,39 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
var
|
|
40
|
-
var getDepositTx_1 = require("../utils/getDepositTx");
|
|
39
|
+
var getDepositTx_1 = require("../utils/coveredCall/getDepositTx");
|
|
41
40
|
var constants_1 = require("../constants");
|
|
42
41
|
var sui_js_1 = require("@mysten/sui.js");
|
|
42
|
+
var getTypeArgumentFromToken_1 = require("../utils/getTypeArgumentFromToken");
|
|
43
43
|
var provider = new sui_js_1.JsonRpcProvider(sui_js_1.Network.DEVNET); //for read only operations
|
|
44
44
|
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
|
-
after deposit, token object balance will decrease,
|
|
47
|
+
after deposit, token object (minted token) balance will decrease,
|
|
48
|
+
and subVault "balance" in fields will increase,
|
|
49
|
+
and a new rolling linked list node will be created if not exist, and the value will increase the same value
|
|
48
50
|
*/
|
|
49
51
|
(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
50
|
-
var depositAmount,
|
|
52
|
+
var depositAmount, isRolling, token, vaultIndex, typeArgument, depositTx;
|
|
51
53
|
return __generator(this, function (_a) {
|
|
52
54
|
switch (_a.label) {
|
|
53
55
|
case 0:
|
|
54
56
|
depositAmount = 123;
|
|
55
|
-
typeArgument = "0x27b3674c685046f66cad1d5496d2967894fa5329::token::USDC" //0x27b3674c685046f66cad1d5496d2967894fa5329:TOKEN_PACKAGE
|
|
56
|
-
;
|
|
57
|
-
expiration = 1671344789;
|
|
58
|
-
bullish = true;
|
|
59
|
-
lowBarrierPrice = 1;
|
|
60
|
-
highBarrierPrice = 10;
|
|
61
57
|
isRolling = true;
|
|
62
|
-
token = "
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
];
|
|
58
|
+
token = "0xaa8f8ccf372b461e5b8778b250bf13d9b1013174" // minted token
|
|
59
|
+
;
|
|
60
|
+
vaultIndex = 3;
|
|
61
|
+
return [4 /*yield*/, (0, getTypeArgumentFromToken_1.getTypeArgumentFromToken)(token)];
|
|
67
62
|
case 1:
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
return [4 /*yield*/, (0, getNewSharkFinVaultTx_1.getNewSharkFinVaultTx)(constants_1.SHARKFIN_PACKAGE, constants_1.SHARKFIN_REGISTRY, typeArgument, expiration, bullish, lowBarrierPrice, highBarrierPrice)];
|
|
63
|
+
typeArgument = _a.sent();
|
|
64
|
+
console.log("test for deposit, try to deposit " + token + " for " + depositAmount + " ...");
|
|
65
|
+
return [4 /*yield*/, (0, getDepositTx_1.getDepositTx)(constants_1.COVERED_CALL_PACKAGE, constants_1.COVERED_CALL_REGISTRY, typeArgument, vaultIndex, isRolling, token, depositAmount)];
|
|
72
66
|
case 2:
|
|
73
|
-
newSharkFinVaultTx = _a.sent();
|
|
74
|
-
return [4 /*yield*/, signer.executeMoveCall(newSharkFinVaultTx)];
|
|
75
|
-
case 3:
|
|
76
|
-
moveCallTxn = _a.sent();
|
|
77
|
-
return [4 /*yield*/, provider.getTransactionWithEffects(
|
|
78
|
-
//@ts-ignore
|
|
79
|
-
moveCallTxn.EffectsCert.certificate.transactionDigest)];
|
|
80
|
-
case 4:
|
|
81
|
-
txn = _a.sent();
|
|
82
|
-
newVault = txn.effects.created[0].reference.objectId;
|
|
83
|
-
console.log("create new vault " + newVault + " for token successfully");
|
|
84
|
-
return [4 /*yield*/, provider.getObject(constants_1.SHARKFIN_REGISTRY)
|
|
85
|
-
//@ts-ignore
|
|
86
|
-
];
|
|
87
|
-
case 5:
|
|
88
|
-
registry = _a.sent();
|
|
89
|
-
numOfVaultAfterCreateVault = registry.details.data.fields.num_of_vault;
|
|
90
|
-
console.log("numOfVaultAfterCreateVault: " + numOfVaultAfterCreateVault);
|
|
91
|
-
vaultIndex = numOfVaultAfterCreateVault - 1;
|
|
92
|
-
return [4 /*yield*/, (0, getDepositTx_1.getDepositTx)(constants_1.SHARKFIN_PACKAGE, constants_1.SHARKFIN_REGISTRY, typeArgument, vaultIndex, isRolling, token, depositAmount)];
|
|
93
|
-
case 6:
|
|
94
67
|
depositTx = _a.sent();
|
|
95
68
|
return [4 /*yield*/, signer.executeMoveCall(depositTx)];
|
|
96
|
-
case
|
|
97
|
-
|
|
98
|
-
console.log("deposit to
|
|
69
|
+
case 3:
|
|
70
|
+
_a.sent();
|
|
71
|
+
console.log("deposit to vault successfully");
|
|
99
72
|
return [2 /*return*/];
|
|
100
73
|
}
|
|
101
74
|
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,169 +1,62 @@
|
|
|
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
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
var constants_1 = require("../constants");
|
|
64
|
-
var sui_js_1 = require("@mysten/sui.js");
|
|
65
|
-
var assert = __importStar(require("assert"));
|
|
66
|
-
var provider = new sui_js_1.JsonRpcProvider(sui_js_1.Network.DEVNET); //for read only operations
|
|
67
|
-
var keypair = sui_js_1.Ed25519Keypair.deriveKeypair(constants_1.TEST_MNEMONIC);
|
|
68
|
-
var signer = new sui_js_1.RawSigner(keypair, provider);
|
|
69
|
-
/*
|
|
70
|
-
after deposit, token object balance will decrease, and new vault "deposit" in fields will increase
|
|
71
|
-
*/
|
|
72
|
-
describe('deposit', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
73
|
-
var depositAmount, typeArgument, expiration, bullish, lowBarrierPrice, highBarrierPrice, isRolling, token;
|
|
74
|
-
return __generator(this, function (_a) {
|
|
75
|
-
depositAmount = 123;
|
|
76
|
-
typeArgument = "0x27b3674c685046f66cad1d5496d2967894fa5329::token::USDC" //0x27b3674c685046f66cad1d5496d2967894fa5329:TOKEN_PACKAGE
|
|
77
|
-
;
|
|
78
|
-
expiration = 1671344789;
|
|
79
|
-
bullish = true;
|
|
80
|
-
lowBarrierPrice = 1;
|
|
81
|
-
highBarrierPrice = 10;
|
|
82
|
-
isRolling = true;
|
|
83
|
-
token = "0xdb85a3efc1706010fa9530ef3b8a8a5cf4b290b7";
|
|
84
|
-
console.log("test for deposit, try to deposit " + token + " for " + depositAmount + " ...");
|
|
85
|
-
it('Check registry', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
86
|
-
var e_1;
|
|
87
|
-
return __generator(this, function (_a) {
|
|
88
|
-
switch (_a.label) {
|
|
89
|
-
case 0:
|
|
90
|
-
_a.trys.push([0, 2, , 3]);
|
|
91
|
-
return [4 /*yield*/, provider.getObject(constants_1.SHARKFIN_REGISTRY)];
|
|
92
|
-
case 1:
|
|
93
|
-
_a.sent();
|
|
94
|
-
assert.ok("Get registry successfully");
|
|
95
|
-
return [3 /*break*/, 3];
|
|
96
|
-
case 2:
|
|
97
|
-
e_1 = _a.sent();
|
|
98
|
-
assert.fail("Wrong registry");
|
|
99
|
-
return [3 /*break*/, 3];
|
|
100
|
-
case 3: return [2 /*return*/];
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
}); });
|
|
104
|
-
it('Create new vault in registry', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
105
|
-
var newSharkFinVaultTx, moveCallTxn, e_2;
|
|
106
|
-
return __generator(this, function (_a) {
|
|
107
|
-
switch (_a.label) {
|
|
108
|
-
case 0:
|
|
109
|
-
_a.trys.push([0, 3, , 4]);
|
|
110
|
-
return [4 /*yield*/, (0, getNewSharkFinVaultTx_1.getNewSharkFinVaultTx)(constants_1.SHARKFIN_PACKAGE, constants_1.SHARKFIN_REGISTRY, typeArgument, expiration, bullish, lowBarrierPrice, highBarrierPrice)];
|
|
111
|
-
case 1:
|
|
112
|
-
newSharkFinVaultTx = _a.sent();
|
|
113
|
-
return [4 /*yield*/, signer.executeMoveCall(newSharkFinVaultTx)];
|
|
114
|
-
case 2:
|
|
115
|
-
moveCallTxn = _a.sent();
|
|
116
|
-
console.log(moveCallTxn);
|
|
117
|
-
assert.ok("Create new vault in registry successfully");
|
|
118
|
-
return [3 /*break*/, 4];
|
|
119
|
-
case 3:
|
|
120
|
-
e_2 = _a.sent();
|
|
121
|
-
assert.fail("Can't create new vault in registry");
|
|
122
|
-
return [3 /*break*/, 4];
|
|
123
|
-
case 4: return [2 /*return*/];
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
}); });
|
|
127
|
-
it('Check vault number after create new vault', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
128
|
-
var registry, numOfVaultBeforeCreateVault, newSharkFinVaultTx, numOfVaultAfterCreateVault, e_3;
|
|
129
|
-
return __generator(this, function (_a) {
|
|
130
|
-
switch (_a.label) {
|
|
131
|
-
case 0:
|
|
132
|
-
_a.trys.push([0, 5, , 6]);
|
|
133
|
-
return [4 /*yield*/, provider.getObject(constants_1.SHARKFIN_REGISTRY)
|
|
134
|
-
//@ts-ignore
|
|
135
|
-
];
|
|
136
|
-
case 1:
|
|
137
|
-
registry = _a.sent();
|
|
138
|
-
numOfVaultBeforeCreateVault = registry.details.data.fields.num_of_vault;
|
|
139
|
-
return [4 /*yield*/, (0, getNewSharkFinVaultTx_1.getNewSharkFinVaultTx)(constants_1.SHARKFIN_PACKAGE, constants_1.SHARKFIN_REGISTRY, typeArgument, expiration, bullish, lowBarrierPrice, highBarrierPrice)];
|
|
140
|
-
case 2:
|
|
141
|
-
newSharkFinVaultTx = _a.sent();
|
|
142
|
-
return [4 /*yield*/, signer.executeMoveCall(newSharkFinVaultTx)];
|
|
143
|
-
case 3:
|
|
144
|
-
_a.sent();
|
|
145
|
-
return [4 /*yield*/, provider.getObject(constants_1.SHARKFIN_REGISTRY)
|
|
146
|
-
//@ts-ignore
|
|
147
|
-
];
|
|
148
|
-
case 4:
|
|
149
|
-
registry = _a.sent();
|
|
150
|
-
numOfVaultAfterCreateVault = registry.details.data.fields.num_of_vault;
|
|
151
|
-
// console.log("numOfVaultAfterCreateVault: " + numOfVaultAfterCreateVault)
|
|
152
|
-
assert.ok(numOfVaultAfterCreateVault == numOfVaultBeforeCreateVault + 1, "wrong vault number");
|
|
153
|
-
return [3 /*break*/, 6];
|
|
154
|
-
case 5:
|
|
155
|
-
e_3 = _a.sent();
|
|
156
|
-
assert.fail("Error in check vault number after create new vault");
|
|
157
|
-
return [3 /*break*/, 6];
|
|
158
|
-
case 6: return [2 /*return*/];
|
|
159
|
-
}
|
|
160
|
-
});
|
|
161
|
-
}); });
|
|
162
|
-
it('Deposit to new vault', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
163
|
-
return __generator(this, function (_a) {
|
|
164
|
-
return [2 /*return*/];
|
|
165
|
-
});
|
|
166
|
-
}); });
|
|
167
|
-
return [2 /*return*/];
|
|
168
|
-
});
|
|
169
|
-
}); });
|
|
2
|
+
// import { getNewSharkFinVaultTx } from "../utils/getNewSharkFinVaultTx"
|
|
3
|
+
// import { getDepositTx } from "../utils/coveredCall/getDepositTx"
|
|
4
|
+
// import { SHARKFIN_PACKAGE, SHARKFIN_REGISTRY, TEST_MNEMONIC, TOKEN_REGISTRY } from "../constants"
|
|
5
|
+
// import { JsonRpcProvider, Ed25519Keypair, RawSigner, Network } from '@mysten/sui.js';
|
|
6
|
+
// import { expect } from 'chai';
|
|
7
|
+
// import * as assert from "assert";
|
|
8
|
+
// const provider = new JsonRpcProvider(Network.DEVNET);//for read only operations
|
|
9
|
+
// const keypair = Ed25519Keypair.deriveKeypair(TEST_MNEMONIC);
|
|
10
|
+
// const signer = new RawSigner(keypair, provider);
|
|
11
|
+
// /*
|
|
12
|
+
// after deposit, token object balance will decrease, and new vault "deposit" in fields will increase
|
|
13
|
+
// */
|
|
14
|
+
// describe('deposit', async () => {
|
|
15
|
+
// //init
|
|
16
|
+
// let depositAmount = 123;
|
|
17
|
+
// let typeArgument = "0x27b3674c685046f66cad1d5496d2967894fa5329::token::USDC" //0x27b3674c685046f66cad1d5496d2967894fa5329:TOKEN_PACKAGE
|
|
18
|
+
// let expiration = 1671344789
|
|
19
|
+
// let bullish = true
|
|
20
|
+
// let lowBarrierPrice = 1
|
|
21
|
+
// let highBarrierPrice = 10
|
|
22
|
+
// let isRolling = true;
|
|
23
|
+
// let token = "0xdb85a3efc1706010fa9530ef3b8a8a5cf4b290b7"
|
|
24
|
+
// console.log("test for deposit, try to deposit " + token + " for " + depositAmount + " ...")
|
|
25
|
+
// it('Check registry', async () => {
|
|
26
|
+
// try {
|
|
27
|
+
// await provider.getObject(SHARKFIN_REGISTRY)
|
|
28
|
+
// assert.ok("Get registry successfully");
|
|
29
|
+
// } catch (e) {
|
|
30
|
+
// assert.fail("Wrong registry")
|
|
31
|
+
// }
|
|
32
|
+
// })
|
|
33
|
+
// it('Create new vault in registry', async () => {
|
|
34
|
+
// try {
|
|
35
|
+
// let newSharkFinVaultTx: any = await getNewSharkFinVaultTx(SHARKFIN_PACKAGE, SHARKFIN_REGISTRY, typeArgument, expiration, bullish, lowBarrierPrice, highBarrierPrice);
|
|
36
|
+
// let moveCallTxn = await signer.executeMoveCall(newSharkFinVaultTx);
|
|
37
|
+
// console.log(moveCallTxn)
|
|
38
|
+
// assert.ok("Create new vault in registry successfully");
|
|
39
|
+
// } catch (e) {
|
|
40
|
+
// assert.fail("Can't create new vault in registry")
|
|
41
|
+
// }
|
|
42
|
+
// })
|
|
43
|
+
// it('Check vault number after create new vault', async () => {
|
|
44
|
+
// try {
|
|
45
|
+
// let registry = await provider.getObject(SHARKFIN_REGISTRY)
|
|
46
|
+
// //@ts-ignore
|
|
47
|
+
// let numOfVaultBeforeCreateVault = registry.details.data.fields.num_of_vault
|
|
48
|
+
// // console.log("numOfVaultBeforeCreateVault: " + numOfVaultBeforeCreateVault)
|
|
49
|
+
// let newSharkFinVaultTx: any = await getNewSharkFinVaultTx(SHARKFIN_PACKAGE, SHARKFIN_REGISTRY, typeArgument, expiration, bullish, lowBarrierPrice, highBarrierPrice);
|
|
50
|
+
// await signer.executeMoveCall(newSharkFinVaultTx);
|
|
51
|
+
// registry = await provider.getObject(SHARKFIN_REGISTRY)
|
|
52
|
+
// //@ts-ignore
|
|
53
|
+
// let numOfVaultAfterCreateVault = registry.details.data.fields.num_of_vault
|
|
54
|
+
// // console.log("numOfVaultAfterCreateVault: " + numOfVaultAfterCreateVault)
|
|
55
|
+
// assert.ok(numOfVaultAfterCreateVault == numOfVaultBeforeCreateVault + 1, "wrong vault number");
|
|
56
|
+
// } catch (e) {
|
|
57
|
+
// assert.fail("Error in check vault number after create new vault")
|
|
58
|
+
// }
|
|
59
|
+
// })
|
|
60
|
+
// it('Deposit to new vault', async () => {
|
|
61
|
+
// })
|
|
62
|
+
// })
|