@typus/typus-sdk 0.1.1 → 0.1.3

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 (51) hide show
  1. package/README.md +33 -1
  2. package/lib/constants.d.ts +18 -2
  3. package/lib/constants.js +19 -3
  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.js +4 -2
  15. package/lib/scripts/getNewOracleTx.d.ts +1 -0
  16. package/lib/scripts/getNewOracleTx.js +55 -0
  17. package/lib/scripts/getNewSharkFinVaultTx.d.ts +1 -0
  18. package/lib/scripts/getNewSharkFinVaultTx.js +59 -0
  19. package/lib/scripts/getSubVault.js +3 -2
  20. package/lib/scripts/getUpdateOracleTx.d.ts +1 -0
  21. package/lib/scripts/getUpdateOracleTx.js +60 -0
  22. package/lib/scripts/sui.js +1 -65
  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 -1
  42. package/lib/utils/getMintTx.js +5 -2
  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 +1 -1
  48. package/lib/utils/getSubVault.js +12 -11
  49. package/lib/utils/getUpdateOracleTx.d.ts +1 -0
  50. package/lib/utils/getUpdateOracleTx.js +64 -0
  51. package/package.json +6 -5
@@ -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.getCoveredCallUnsubscribeTx = void 0;
40
+ function getCoveredCallUnsubscribeTx(packageId, registry, typeArgument, index) {
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: 'unsubscribe',
48
+ typeArguments: [typeArgument],
49
+ arguments: [
50
+ registry,
51
+ index,
52
+ ],
53
+ gasBudget: 10000,
54
+ };
55
+ return [2 /*return*/, tx];
56
+ });
57
+ });
58
+ }
59
+ exports.getCoveredCallUnsubscribeTx = getCoveredCallUnsubscribeTx;
60
+ /*
61
+ sui client call --package 0x1543511bdce9ea3c401c4939126cea518adee965 --module covered_call --function unsubscribe --type-args 0x2::sui::SUI --args 0xb02452d0bbef3cbdc7840ea5bad27bcdd4031675 0 --gas-budget 100000
62
+ */
@@ -0,0 +1 @@
1
+ export declare function getNewCoveredCallVaultTx(packageId: string, registry: string, typeArgument: string, managerCap: string, expiration: number, assetName: string, strike: number): Promise<any>;
@@ -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
+ */
@@ -1 +1 @@
1
- export declare function getMintTx(packageId: string, registry: string, amount: number): Promise<any>;
1
+ export declare function getMintTx(packageId: string, registry: string, moduleName: string, amount: number): Promise<any>;
@@ -37,13 +37,13 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.getMintTx = void 0;
40
- function getMintTx(packageId, registry, amount) {
40
+ function getMintTx(packageId, registry, moduleName, amount) {
41
41
  return __awaiter(this, void 0, void 0, function () {
42
42
  var tx;
43
43
  return __generator(this, function (_a) {
44
44
  tx = {
45
45
  packageObjectId: packageId,
46
- module: 'token',
46
+ module: moduleName,
47
47
  function: 'mint',
48
48
  typeArguments: [],
49
49
  arguments: [
@@ -57,3 +57,6 @@ function getMintTx(packageId, registry, amount) {
57
57
  });
58
58
  }
59
59
  exports.getMintTx = getMintTx;
60
+ /*
61
+ sui client call --gas-budget 10000 --package 0xe879e96fb90a8559127091f1176a2d10bb67c6ff --module "token_btc" --function "mint" --args 0x5dce92f67eeda471369b734deac0d540b751cea6 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
+ */
@@ -1,3 +1,3 @@
1
1
  import { JsonRpcProvider } from '@mysten/sui.js';
2
2
  export declare function subVaults(): Promise<any>;
3
- export declare function subVaultsV2(packageId: string, registry: string, provider: JsonRpcProvider): Promise<any>;
3
+ export declare function subVaultsV2(registry: string, provider: JsonRpcProvider): Promise<any>;
@@ -55,28 +55,26 @@ function subVaults() {
55
55
  return __awaiter(this, void 0, void 0, function () {
56
56
  return __generator(this, function (_a) {
57
57
  switch (_a.label) {
58
- case 0: return [4 /*yield*/, subVaultsV2(constants_1.packageId, constants_1.registry, provider)];
58
+ case 0: return [4 /*yield*/, subVaultsV2(constants_1.SHARKFIN_REGISTRY, provider)];
59
59
  case 1: return [2 /*return*/, _a.sent()];
60
60
  }
61
61
  });
62
62
  });
63
63
  }
64
64
  exports.subVaults = subVaults;
65
- function subVaultsV2(packageId, registry, provider) {
65
+ function subVaultsV2(registry, provider) {
66
66
  return __awaiter(this, void 0, void 0, function () {
67
- 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;
68
68
  var e_1, _a;
69
69
  return __generator(this, function (_b) {
70
70
  switch (_b.label) {
71
71
  case 0:
72
- //packageID and registry
73
- // let packageID = process.env.PACKAGE!
74
- // let registry = process.env.VAULT_REGISTRY!
75
- console.log("packageID: " + packageId);
76
72
  console.log("registry: " + registry);
77
73
  return [4 /*yield*/, provider.getObjectsOwnedByObject(registry)];
78
74
  case 1:
79
75
  tmpObj1 = _b.sent();
76
+ console.log("vault num under registry:" + tmpObj1.length);
77
+ if (!(tmpObj1.length != 0)) return [3 /*break*/, 12];
80
78
  vault = tmpObj1[0].objectId;
81
79
  console.log("vault: " + vault);
82
80
  return [4 /*yield*/, provider.getObject(vault)
@@ -89,18 +87,18 @@ function subVaultsV2(packageId, registry, provider) {
89
87
  return [4 /*yield*/, provider.getObjectsOwnedByObject(table)];
90
88
  case 3:
91
89
  tmpObj3 = _b.sent();
92
- subVaultsId = [];
90
+ subVaultsId_2 = [];
93
91
  tmpObj3.map(function (e) {
94
- subVaultsId.push(e.objectId);
92
+ subVaultsId_2.push(e.objectId);
95
93
  });
96
94
  console.log("subVaults: ");
97
95
  //@ts-ignore
98
- console.log(subVaultsId);
96
+ console.log(subVaultsId_2);
99
97
  subVaultsMap = new Map();
100
98
  _b.label = 4;
101
99
  case 4:
102
100
  _b.trys.push([4, 9, 10, 11]);
103
- subVaultsId_1 = __values(subVaultsId), subVaultsId_1_1 = subVaultsId_1.next();
101
+ subVaultsId_1 = __values(subVaultsId_2), subVaultsId_1_1 = subVaultsId_1.next();
104
102
  _b.label = 5;
105
103
  case 5:
106
104
  if (!!subVaultsId_1_1.done) return [3 /*break*/, 8];
@@ -130,6 +128,9 @@ function subVaultsV2(packageId, registry, provider) {
130
128
  case 11:
131
129
  // console.log(subVaultsMap.get("rolling").value.fields.users_table)
132
130
  return [2 /*return*/, subVaultsMap];
131
+ case 12:
132
+ console.log("no vault under this registry: " + registry);
133
+ return [2 /*return*/, null];
133
134
  }
134
135
  });
135
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.1",
5
+ "version": "0.1.3",
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": {