@typus/typus-sdk 0.1.0 → 0.1.2

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.
Files changed (52) hide show
  1. package/README.md +37 -1
  2. package/lib/constants.d.ts +10 -0
  3. package/lib/constants.js +13 -0
  4. package/lib/scripts/coveredCall/getCoveredCallDepositTx.d.ts +1 -0
  5. package/lib/scripts/coveredCall/getCoveredCallDepositTx.js +58 -0
  6. package/lib/scripts/coveredCall/getCoveredCallUnsubscribeTx.d.ts +1 -0
  7. package/lib/scripts/coveredCall/getCoveredCallUnsubscribeTx.js +55 -0
  8. package/lib/scripts/coveredCall/getNewCoveredCallVaultTx.d.ts +1 -0
  9. package/lib/scripts/coveredCall/getNewCoveredCallVaultTx.js +57 -0
  10. package/lib/scripts/getCreateTokenRegistryTx.d.ts +1 -0
  11. package/lib/scripts/getCreateTokenRegistryTx.js +54 -0
  12. package/lib/scripts/getDepositTx.d.ts +1 -0
  13. package/lib/scripts/getDepositTx.js +59 -0
  14. package/lib/scripts/getMintTx.d.ts +1 -0
  15. package/lib/scripts/getMintTx.js +55 -0
  16. package/lib/scripts/getNewOracleTx.d.ts +1 -0
  17. package/lib/scripts/getNewOracleTx.js +55 -0
  18. package/lib/scripts/getNewSharkFinVaultTx.d.ts +1 -0
  19. package/lib/scripts/getNewSharkFinVaultTx.js +59 -0
  20. package/lib/scripts/getSubVault.js +1 -1
  21. package/lib/scripts/getUpdateOracleTx.d.ts +1 -0
  22. package/lib/scripts/getUpdateOracleTx.js +60 -0
  23. package/lib/test/testDeposit.d.ts +1 -0
  24. package/lib/test/testDeposit.js +102 -0
  25. package/lib/test/testDepositV2.d.ts +1 -0
  26. package/lib/test/testDepositV2.js +169 -0
  27. package/lib/test/testMint.d.ts +1 -0
  28. package/lib/test/testMint.js +90 -0
  29. package/lib/test/testOracle.d.ts +1 -0
  30. package/lib/test/testOracle.js +84 -0
  31. package/lib/utils/coveredCall/getCoveredCallDepositTx.d.ts +1 -0
  32. package/lib/utils/coveredCall/getCoveredCallDepositTx.js +65 -0
  33. package/lib/utils/coveredCall/getCoveredCallUnsubscribeTx.d.ts +1 -0
  34. package/lib/utils/coveredCall/getCoveredCallUnsubscribeTx.js +62 -0
  35. package/lib/utils/coveredCall/getNewCoveredCallVaultTx.d.ts +1 -0
  36. package/lib/utils/coveredCall/getNewCoveredCallVaultTx.js +65 -0
  37. package/lib/utils/getCreateTokenRegistryTx.d.ts +1 -0
  38. package/lib/utils/getCreateTokenRegistryTx.js +59 -0
  39. package/lib/utils/getDepositTx.d.ts +1 -0
  40. package/lib/utils/getDepositTx.js +66 -0
  41. package/lib/utils/getMintTx.d.ts +1 -0
  42. package/lib/utils/getMintTx.js +62 -0
  43. package/lib/utils/getNewOracleTx.d.ts +1 -0
  44. package/lib/utils/getNewOracleTx.js +59 -0
  45. package/lib/utils/getNewSharkFinVaultTx.d.ts +1 -0
  46. package/lib/utils/getNewSharkFinVaultTx.js +67 -0
  47. package/lib/utils/getSubVault.d.ts +3 -0
  48. package/lib/utils/{utilsTs/getSubVault.js → getSubVault.js} +13 -15
  49. package/lib/utils/getUpdateOracleTx.d.ts +1 -0
  50. package/lib/utils/getUpdateOracleTx.js +64 -0
  51. package/package.json +6 -5
  52. package/lib/utils/utilsTs/getSubVault.d.ts +0 -3
@@ -0,0 +1,65 @@
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.getNewCoveredCallVaultTx = void 0;
40
+ function getNewCoveredCallVaultTx(packageId, registry, typeArgument, managerCap, expiration, assetName, strike) {
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: 'covered_call',
47
+ function: 'new_covered_call_vault',
48
+ typeArguments: [typeArgument],
49
+ arguments: [
50
+ managerCap,
51
+ registry,
52
+ expiration,
53
+ assetName,
54
+ strike
55
+ ],
56
+ gasBudget: 10000,
57
+ };
58
+ return [2 /*return*/, tx];
59
+ });
60
+ });
61
+ }
62
+ exports.getNewCoveredCallVaultTx = getNewCoveredCallVaultTx;
63
+ /*
64
+ sui client call --package 0x1543511bdce9ea3c401c4939126cea518adee965 --module covered_call --function new_covered_call_vault --type-args 0x2::sui::SUI --args 0x8517b2dbaae56eeb84352e4869b289459c68965b 0xb02452d0bbef3cbdc7840ea5bad27bcdd4031675 123 leoAsset 456 --gas-budget 100000
65
+ */
@@ -0,0 +1 @@
1
+ export declare function getCreateTokenRegistryTx(packageId: string): Promise<any>;
@@ -0,0 +1,59 @@
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.getCreateTokenRegistryTx = void 0;
40
+ function getCreateTokenRegistryTx(packageId) {
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: 'token',
47
+ function: 'new',
48
+ typeArguments: [],
49
+ arguments: [],
50
+ gasBudget: 10000,
51
+ };
52
+ return [2 /*return*/, tx];
53
+ });
54
+ });
55
+ }
56
+ exports.getCreateTokenRegistryTx = getCreateTokenRegistryTx;
57
+ /*
58
+ sui client call --gas-budget 10000 --package $PACKAGE --module "token" --function "new"
59
+ */
@@ -0,0 +1 @@
1
+ export declare function getDepositTx(packageId: string, registry: string, typeArgument: string, vaultIndex: number, isRolling: Boolean, coin: string, amount: number): Promise<any>;
@@ -0,0 +1,66 @@
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.getDepositTx = void 0;
40
+ function getDepositTx(packageId, registry, typeArgument, vaultIndex, isRolling, coin, amount) {
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: 'shark_fin',
47
+ function: 'deposit',
48
+ typeArguments: [typeArgument],
49
+ arguments: [
50
+ registry,
51
+ vaultIndex,
52
+ isRolling,
53
+ coin,
54
+ amount,
55
+ ],
56
+ gasBudget: 1000,
57
+ };
58
+ return [2 /*return*/, tx];
59
+ });
60
+ });
61
+ }
62
+ exports.getDepositTx = getDepositTx;
63
+ /*
64
+ sui client call --gas-budget 1000 --package $PACKAGE --module "shark_fin" --function "deposit"
65
+ --type-args 0x27b3674c685046f66cad1d5496d2967894fa5329::token::USDC --args $VAULT_REGISTRY 1 true $TOKENAID 9999
66
+ */
@@ -0,0 +1 @@
1
+ export declare function getMintTx(packageId: string, registry: string, amount: number): Promise<any>;
@@ -0,0 +1,62 @@
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.getMintTx = void 0;
40
+ function getMintTx(packageId, registry, amount) {
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: 'token',
47
+ function: 'mint',
48
+ typeArguments: [],
49
+ arguments: [
50
+ registry,
51
+ amount,
52
+ ],
53
+ gasBudget: 10000,
54
+ };
55
+ return [2 /*return*/, tx];
56
+ });
57
+ });
58
+ }
59
+ exports.getMintTx = getMintTx;
60
+ /*
61
+ sui client call --gas-budget 10000 --package $PACKAGE --module "token" --function "mint" --args $REGISTRY 10000
62
+ */
@@ -0,0 +1 @@
1
+ export declare function getNewOracleTx(packageId: string, typeArgument: string): Promise<any>;
@@ -0,0 +1,59 @@
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.getNewOracleTx = void 0;
40
+ function getNewOracleTx(packageId, typeArgument) {
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: 'oracle',
47
+ function: 'new_oracle',
48
+ typeArguments: [typeArgument],
49
+ arguments: [],
50
+ gasBudget: 1000,
51
+ };
52
+ return [2 /*return*/, tx];
53
+ });
54
+ });
55
+ }
56
+ exports.getNewOracleTx = getNewOracleTx;
57
+ /*
58
+ sui client call --gas-budget 1000 --package $PACKAGE --module "oracle" --function "new_oracle" --type-args 0x2::sui::SUI
59
+ */
@@ -0,0 +1 @@
1
+ export declare function getNewSharkFinVaultTx(packageId: string, registry: string, typeArgument: string, expiration: number, bullish: Boolean, lowBarrierPrice: number, highBarrierPrice: number): Promise<any>;
@@ -0,0 +1,67 @@
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.getNewSharkFinVaultTx = void 0;
40
+ function getNewSharkFinVaultTx(packageId, registry, typeArgument, expiration, bullish, lowBarrierPrice, highBarrierPrice) {
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: 'shark_fin',
47
+ function: 'new_shark_fin_vault',
48
+ typeArguments: [typeArgument],
49
+ arguments: [
50
+ registry,
51
+ expiration,
52
+ bullish,
53
+ lowBarrierPrice,
54
+ highBarrierPrice,
55
+ ],
56
+ gasBudget: 10000,
57
+ };
58
+ return [2 /*return*/, tx];
59
+ });
60
+ });
61
+ }
62
+ exports.getNewSharkFinVaultTx = getNewSharkFinVaultTx;
63
+ /*
64
+ sui client call --gas-budget 1000 --package $PACKAGE --module "shark_fin" --function "new_shark_fin_vault"
65
+ --type-args 0x27b3674c685046f66cad1d5496d2967894fa5329::token::USDC
66
+ --args $VAULT_REGISTRY 1671344789 true 1 10
67
+ */
@@ -0,0 +1,3 @@
1
+ import { JsonRpcProvider } from '@mysten/sui.js';
2
+ export declare function subVaults(): Promise<any>;
3
+ export declare function subVaultsV2(registry: string, provider: JsonRpcProvider): Promise<any>;
@@ -49,37 +49,32 @@ var __values = (this && this.__values) || function(o) {
49
49
  Object.defineProperty(exports, "__esModule", { value: true });
50
50
  exports.subVaultsV2 = exports.subVaults = void 0;
51
51
  var sui_js_1 = require("@mysten/sui.js");
52
+ var constants_1 = require("../constants");
52
53
  var provider = new sui_js_1.JsonRpcProvider(sui_js_1.Network.DEVNET); //for read only operations
53
54
  function subVaults() {
54
55
  return __awaiter(this, void 0, void 0, function () {
55
- var packageID, registry;
56
56
  return __generator(this, function (_a) {
57
57
  switch (_a.label) {
58
- case 0:
59
- packageID = process.env.PACKAGE;
60
- registry = process.env.VAULT_REGISTRY;
61
- return [4 /*yield*/, subVaultsV2(packageID, registry, provider)];
58
+ case 0: return [4 /*yield*/, subVaultsV2(constants_1.SHARKFIN_REGISTRY, provider)];
62
59
  case 1: return [2 /*return*/, _a.sent()];
63
60
  }
64
61
  });
65
62
  });
66
63
  }
67
64
  exports.subVaults = subVaults;
68
- function subVaultsV2(packageID, registry, provider) {
65
+ function subVaultsV2(registry, provider) {
69
66
  return __awaiter(this, void 0, void 0, function () {
70
- var tmpObj1, vault, tmpObj2, table, tmpObj3, subVaultsId, subVaultsMap, subVaultsId_1, subVaultsId_1_1, e, tmpObj4, e_1_1;
67
+ var tmpObj1, vault, tmpObj2, table, tmpObj3, subVaultsId_2, subVaultsMap, subVaultsId_1, subVaultsId_1_1, e, tmpObj4, e_1_1;
71
68
  var e_1, _a;
72
69
  return __generator(this, function (_b) {
73
70
  switch (_b.label) {
74
71
  case 0:
75
- //packageID and registry
76
- // let packageID = process.env.PACKAGE!
77
- // let registry = process.env.VAULT_REGISTRY!
78
- console.log("packageID: " + packageID);
79
72
  console.log("registry: " + registry);
80
73
  return [4 /*yield*/, provider.getObjectsOwnedByObject(registry)];
81
74
  case 1:
82
75
  tmpObj1 = _b.sent();
76
+ console.log("vault num under registry:" + tmpObj1.length);
77
+ if (!(tmpObj1.length != 0)) return [3 /*break*/, 12];
83
78
  vault = tmpObj1[0].objectId;
84
79
  console.log("vault: " + vault);
85
80
  return [4 /*yield*/, provider.getObject(vault)
@@ -92,18 +87,18 @@ function subVaultsV2(packageID, registry, provider) {
92
87
  return [4 /*yield*/, provider.getObjectsOwnedByObject(table)];
93
88
  case 3:
94
89
  tmpObj3 = _b.sent();
95
- subVaultsId = [];
90
+ subVaultsId_2 = [];
96
91
  tmpObj3.map(function (e) {
97
- subVaultsId.push(e.objectId);
92
+ subVaultsId_2.push(e.objectId);
98
93
  });
99
94
  console.log("subVaults: ");
100
95
  //@ts-ignore
101
- console.log(subVaultsId);
96
+ console.log(subVaultsId_2);
102
97
  subVaultsMap = new Map();
103
98
  _b.label = 4;
104
99
  case 4:
105
100
  _b.trys.push([4, 9, 10, 11]);
106
- subVaultsId_1 = __values(subVaultsId), subVaultsId_1_1 = subVaultsId_1.next();
101
+ subVaultsId_1 = __values(subVaultsId_2), subVaultsId_1_1 = subVaultsId_1.next();
107
102
  _b.label = 5;
108
103
  case 5:
109
104
  if (!!subVaultsId_1_1.done) return [3 /*break*/, 8];
@@ -133,6 +128,9 @@ function subVaultsV2(packageID, registry, provider) {
133
128
  case 11:
134
129
  // console.log(subVaultsMap.get("rolling").value.fields.users_table)
135
130
  return [2 /*return*/, subVaultsMap];
131
+ case 12:
132
+ console.log("no vault under this registry: " + registry);
133
+ return [2 /*return*/, null];
136
134
  }
137
135
  });
138
136
  });
@@ -0,0 +1 @@
1
+ export declare function getUpdateOracleTx(packageId: string, typeArgument: string, oracle: string, managerCap: string, price: number, unix: number): Promise<any>;
@@ -0,0 +1,64 @@
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.getUpdateOracleTx = void 0;
40
+ function getUpdateOracleTx(packageId, typeArgument, oracle, managerCap, price, unix) {
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: 'oracle',
47
+ function: 'update',
48
+ typeArguments: [typeArgument],
49
+ arguments: [
50
+ oracle,
51
+ managerCap,
52
+ price,
53
+ unix
54
+ ],
55
+ gasBudget: 1000,
56
+ };
57
+ return [2 /*return*/, tx];
58
+ });
59
+ });
60
+ }
61
+ exports.getUpdateOracleTx = getUpdateOracleTx;
62
+ /*
63
+ sui client call --gas-budget 1000 --package $PACKAGE --module "oracle" --function "update" --type-args 0x2::sui::SUI --args 0x7158f68a06bc09123fcba1645f4c56ca866a8e90 0xa31180f78ee420b561240214c301df4adf9377ab 1201 1328
64
+ */
package/package.json CHANGED
@@ -2,19 +2,19 @@
2
2
  "name": "@typus/typus-sdk",
3
3
  "author": "Typus",
4
4
  "description": "typus sdk",
5
- "version": "0.1.0",
5
+ "version": "0.1.2",
6
6
  "dependencies": {
7
7
  "@mysten/sui.js": "^0.17.1",
8
- "fetch": "^1.1.0",
9
- "node-fetch": "^3.3.0",
10
8
  "@types/node": "^17.0.0",
11
9
  "bs58": "^4.0.1",
12
10
  "builtin-modules": "^1.1.1",
11
+ "chai": "^4.3.7",
13
12
  "decimal.js": "^10.3.1",
14
13
  "diff": "^4.0.2",
15
14
  "dotenv": "^10.0.0",
16
15
  "escape-string-regexp": "^1.0.5",
17
16
  "esprima": "^4.0.1",
17
+ "fetch": "^1.1.0",
18
18
  "fs.realpath": "^1.0.0",
19
19
  "function-bind": "^1.1.1",
20
20
  "glob": "^7.2.0",
@@ -29,6 +29,7 @@
29
29
  "minimatch": "^3.0.4",
30
30
  "minimist": "^1.2.5",
31
31
  "mkdirp": "^0.5.5",
32
+ "mocha": "^10.1.0",
32
33
  "moment": "^2.29.4",
33
34
  "once": "^1.4.0",
34
35
  "path-is-absolute": "^1.0.1",
@@ -39,6 +40,7 @@
39
40
  "sprintf-js": "^1.0.3",
40
41
  "superstruct": "^0.16.0",
41
42
  "supports-color": "^5.5.0",
43
+ "ts-mocha": "^10.0.0",
42
44
  "tslib": "^1.14.1",
43
45
  "tsutils": "^2.29.0",
44
46
  "wrappy": "^1.0.2"
@@ -49,7 +51,6 @@
49
51
  "@types/mocha": "^9.0.0",
50
52
  "@types/rx": "^4.1.2",
51
53
  "prettier": "^2.5.1",
52
- "ts-mocha": "^8.0.0",
53
54
  "tslint": "^6.1.3",
54
55
  "tslint-config-prettier": "^1.18.0",
55
56
  "typescript": "^4.5.4"
@@ -60,7 +61,7 @@
60
61
  ],
61
62
  "types": "lib/index.d.ts",
62
63
  "scripts": {
63
- "test": "echo \"Error: no test specified\" && exit 1",
64
+ "test": "rm -rf lib && tsc && ts-mocha test/test*.ts",
64
65
  "build": "rm -rf lib && tsc"
65
66
  },
66
67
  "repository": {
@@ -1,3 +0,0 @@
1
- import { JsonRpcProvider } from '@mysten/sui.js';
2
- export declare function subVaults(): Promise<any>;
3
- export declare function subVaultsV2(packageID: string, registry: string, provider: JsonRpcProvider): Promise<any>;