@typus/typus-sdk 0.4.6 → 0.4.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. package/package.json +3 -3
  2. package/lib/constants.d.ts +0 -30
  3. package/lib/constants.js +0 -38
  4. package/lib/scripts/getSubVault.d.ts +0 -0
  5. package/lib/scripts/getSubVault.js +0 -6
  6. package/lib/scripts/sui.d.ts +0 -1
  7. package/lib/scripts/sui.js +0 -187
  8. package/lib/test/eventListener.d.ts +0 -5
  9. package/lib/test/eventListener.js +0 -277
  10. package/lib/test/getBidData.d.ts +0 -1
  11. package/lib/test/getBidData.js +0 -53
  12. package/lib/test/getMakersShares.d.ts +0 -1
  13. package/lib/test/getMakersShares.js +0 -52
  14. package/lib/test/getUsersShares.d.ts +0 -1
  15. package/lib/test/getUsersShares.js +0 -52
  16. package/lib/test/getVaultData.d.ts +0 -1
  17. package/lib/test/getVaultData.js +0 -53
  18. package/lib/test/testClaim.d.ts +0 -1
  19. package/lib/test/testClaim.js +0 -81
  20. package/lib/test/testCrypto.d.ts +0 -1
  21. package/lib/test/testCrypto.js +0 -54
  22. package/lib/test/testDeposit.d.ts +0 -1
  23. package/lib/test/testDeposit.js +0 -73
  24. package/lib/test/testDepositV2.d.ts +0 -0
  25. package/lib/test/testDepositV2.js +0 -62
  26. package/lib/test/testMint.d.ts +0 -1
  27. package/lib/test/testMint.js +0 -136
  28. package/lib/test/testNewAuction.d.ts +0 -1
  29. package/lib/test/testNewAuction.js +0 -93
  30. package/lib/test/testNewVault.d.ts +0 -1
  31. package/lib/test/testNewVault.js +0 -152
  32. package/lib/test/testOracle.d.ts +0 -1
  33. package/lib/test/testOracle.js +0 -93
  34. package/lib/test/testSettle.d.ts +0 -1
  35. package/lib/test/testSettle.js +0 -589
  36. package/lib/test/testSubscribeEvent.d.ts +0 -1
  37. package/lib/test/testSubscribeEvent.js +0 -97
  38. package/lib/test/testUnsubscribe.d.ts +0 -1
  39. package/lib/test/testUnsubscribe.js +0 -87
  40. package/lib/test/testWithdraw.d.ts +0 -1
  41. package/lib/test/testWithdraw.js +0 -70
  42. package/lib/utils/auction/getBid.d.ts +0 -2
  43. package/lib/utils/auction/getBid.js +0 -79
  44. package/lib/utils/auction/sealedAuction.d.ts +0 -33
  45. package/lib/utils/auction/sealedAuction.js +0 -64
  46. package/lib/utils/authorized/getAuthorizedAddAuthorizedUserTx.d.ts +0 -1
  47. package/lib/utils/authorized/getAuthorizedAddAuthorizedUserTx.js +0 -60
  48. package/lib/utils/authorized/getAuthorizedAddCoveredCallVaultAuthorizedUserTx.d.ts +0 -1
  49. package/lib/utils/authorized/getAuthorizedAddCoveredCallVaultAuthorizedUserTx.js +0 -60
  50. package/lib/utils/authorized/getAuthorizedDeliveryTx.d.ts +0 -1
  51. package/lib/utils/authorized/getAuthorizedDeliveryTx.js +0 -60
  52. package/lib/utils/authorized/getAuthorizedEvolutionTx.d.ts +0 -1
  53. package/lib/utils/authorized/getAuthorizedEvolutionTx.js +0 -63
  54. package/lib/utils/authorized/getAuthorizedLastEvolutionTx.d.ts +0 -1
  55. package/lib/utils/authorized/getAuthorizedLastEvolutionTx.js +0 -62
  56. package/lib/utils/authorized/getAuthorizedNewAuctionTx.d.ts +0 -1
  57. package/lib/utils/authorized/getAuthorizedNewAuctionTx.js +0 -61
  58. package/lib/utils/authorized/getAuthorizedNewCoveredCallVaultTx.d.ts +0 -1
  59. package/lib/utils/authorized/getAuthorizedNewCoveredCallVaultTx.js +0 -77
  60. package/lib/utils/authorized/getAuthorizedRemoveAuthorizedUserTx.d.ts +0 -1
  61. package/lib/utils/authorized/getAuthorizedRemoveAuthorizedUserTx.js +0 -60
  62. package/lib/utils/authorized/getAuthorizedRemoveCoveredCallVaultAuthorizedUserTx.d.ts +0 -1
  63. package/lib/utils/authorized/getAuthorizedRemoveCoveredCallVaultAuthorizedUserTx.js +0 -60
  64. package/lib/utils/authorized/getAuthorizedSettleTx.d.ts +0 -1
  65. package/lib/utils/authorized/getAuthorizedSettleTx.js +0 -61
  66. package/lib/utils/authorized/getAuthorizedUpdateNextVaultConfigTx.d.ts +0 -1
  67. package/lib/utils/authorized/getAuthorizedUpdateNextVaultConfigTx.js +0 -65
  68. package/lib/utils/coveredCall/createPriceOracle.d.ts +0 -1
  69. package/lib/utils/coveredCall/createPriceOracle.js +0 -92
  70. package/lib/utils/coveredCall/createTimeOracle.d.ts +0 -1
  71. package/lib/utils/coveredCall/createTimeOracle.js +0 -91
  72. package/lib/utils/coveredCall/getAddCoveredCallVaultAuthorizedUserTx.d.ts +0 -1
  73. package/lib/utils/coveredCall/getAddCoveredCallVaultAuthorizedUserTx.js +0 -61
  74. package/lib/utils/coveredCall/getClaimAllTx.d.ts +0 -1
  75. package/lib/utils/coveredCall/getClaimAllTx.js +0 -59
  76. package/lib/utils/coveredCall/getClaimTx.d.ts +0 -1
  77. package/lib/utils/coveredCall/getClaimTx.js +0 -59
  78. package/lib/utils/coveredCall/getDeliveryTx.d.ts +0 -1
  79. package/lib/utils/coveredCall/getDeliveryTx.js +0 -61
  80. package/lib/utils/coveredCall/getDepositTx.d.ts +0 -1
  81. package/lib/utils/coveredCall/getDepositTx.js +0 -65
  82. package/lib/utils/coveredCall/getEvolutionTx.d.ts +0 -1
  83. package/lib/utils/coveredCall/getEvolutionTx.js +0 -64
  84. package/lib/utils/coveredCall/getLastEvolutionTx.d.ts +0 -1
  85. package/lib/utils/coveredCall/getLastEvolutionTx.js +0 -63
  86. package/lib/utils/coveredCall/getMakerClaimAllTx.d.ts +0 -1
  87. package/lib/utils/coveredCall/getMakerClaimAllTx.js +0 -59
  88. package/lib/utils/coveredCall/getMakerClaimTx.d.ts +0 -1
  89. package/lib/utils/coveredCall/getMakerClaimTx.js +0 -59
  90. package/lib/utils/coveredCall/getNewAuctionTx.d.ts +0 -1
  91. package/lib/utils/coveredCall/getNewAuctionTx.js +0 -66
  92. package/lib/utils/coveredCall/getNewAuctionWithNextCoveredCallVaultTx.d.ts +0 -1
  93. package/lib/utils/coveredCall/getNewAuctionWithNextCoveredCallVaultTx.js +0 -64
  94. package/lib/utils/coveredCall/getNewBidTx.d.ts +0 -1
  95. package/lib/utils/coveredCall/getNewBidTx.js +0 -62
  96. package/lib/utils/coveredCall/getNewCoveredCallVaultTx.d.ts +0 -1
  97. package/lib/utils/coveredCall/getNewCoveredCallVaultTx.js +0 -77
  98. package/lib/utils/coveredCall/getNewManagerTx.d.ts +0 -1
  99. package/lib/utils/coveredCall/getNewManagerTx.js +0 -59
  100. package/lib/utils/coveredCall/getRefundTx.d.ts +0 -1
  101. package/lib/utils/coveredCall/getRefundTx.js +0 -59
  102. package/lib/utils/coveredCall/getRemoveBidTx.d.ts +0 -1
  103. package/lib/utils/coveredCall/getRemoveBidTx.js +0 -60
  104. package/lib/utils/coveredCall/getRemoveCoveredCallVaultAuthorizedUserTx.d.ts +0 -1
  105. package/lib/utils/coveredCall/getRemoveCoveredCallVaultAuthorizedUserTx.js +0 -61
  106. package/lib/utils/coveredCall/getRemoveManagerTx.d.ts +0 -1
  107. package/lib/utils/coveredCall/getRemoveManagerTx.js +0 -58
  108. package/lib/utils/coveredCall/getRollOverTx.d.ts +0 -1
  109. package/lib/utils/coveredCall/getRollOverTx.js +0 -60
  110. package/lib/utils/coveredCall/getSettleTx.d.ts +0 -1
  111. package/lib/utils/coveredCall/getSettleTx.js +0 -62
  112. package/lib/utils/coveredCall/getSettleWithRollOverTx.d.ts +0 -1
  113. package/lib/utils/coveredCall/getSettleWithRollOverTx.js +0 -62
  114. package/lib/utils/coveredCall/getSubscribeTx.d.ts +0 -1
  115. package/lib/utils/coveredCall/getSubscribeTx.js +0 -60
  116. package/lib/utils/coveredCall/getUnsubscribeTx.d.ts +0 -1
  117. package/lib/utils/coveredCall/getUnsubscribeTx.js +0 -63
  118. package/lib/utils/coveredCall/getUpdateNextVaultConfigTx.d.ts +0 -1
  119. package/lib/utils/coveredCall/getUpdateNextVaultConfigTx.js +0 -66
  120. package/lib/utils/coveredCall/getUpdatePayoffConfigTx.d.ts +0 -1
  121. package/lib/utils/coveredCall/getUpdatePayoffConfigTx.js +0 -62
  122. package/lib/utils/coveredCall/getWithdrawTx.d.ts +0 -1
  123. package/lib/utils/coveredCall/getWithdrawTx.js +0 -60
  124. package/lib/utils/fetchData.d.ts +0 -83
  125. package/lib/utils/fetchData.js +0 -206
  126. package/lib/utils/getCreateTokenRegistryTx.d.ts +0 -1
  127. package/lib/utils/getCreateTokenRegistryTx.js +0 -59
  128. package/lib/utils/getMakersShares.d.ts +0 -7
  129. package/lib/utils/getMakersShares.js +0 -148
  130. package/lib/utils/getMintTx.d.ts +0 -1
  131. package/lib/utils/getMintTx.js +0 -62
  132. package/lib/utils/getNewOracleTx.d.ts +0 -1
  133. package/lib/utils/getNewOracleTx.js +0 -59
  134. package/lib/utils/getNewTimeOracleTx.d.ts +0 -1
  135. package/lib/utils/getNewTimeOracleTx.js +0 -56
  136. package/lib/utils/getTypeArgumentFromToken.d.ts +0 -1
  137. package/lib/utils/getTypeArgumentFromToken.js +0 -71
  138. package/lib/utils/getUpdateOracleTx.d.ts +0 -1
  139. package/lib/utils/getUpdateOracleTx.js +0 -64
  140. package/lib/utils/getUpdateTimeOracleTx.d.ts +0 -1
  141. package/lib/utils/getUpdateTimeOracleTx.js +0 -60
  142. package/lib/utils/getUsersShares.d.ts +0 -8
  143. package/lib/utils/getUsersShares.js +0 -147
  144. package/lib/utils/getVaultData.d.ts +0 -3
  145. package/lib/utils/getVaultData.js +0 -262
  146. package/lib/utils/getVaultIndexInRegistry.d.ts +0 -1
  147. package/lib/utils/getVaultIndexInRegistry.js +0 -61
  148. package/lib/utils/isObjAvailable.d.ts +0 -0
  149. package/lib/utils/isObjAvailable.js +0 -14
  150. package/lib/utils/loadUsersDepositData.d.ts +0 -8
  151. package/lib/utils/loadUsersDepositData.js +0 -157
package/package.json CHANGED
@@ -2,10 +2,10 @@
2
2
  "name": "@typus/typus-sdk",
3
3
  "author": "Typus",
4
4
  "description": "typus sdk",
5
- "version": "0.4.6",
5
+ "version": "0.4.8",
6
6
  "dependencies": {
7
7
  "@mysten/bcs": "^0.5.0",
8
- "@mysten/sui.js": "^0.20.0",
8
+ "@mysten/sui.js": "^0.25.0",
9
9
  "@types/node": "^17.0.0",
10
10
  "bs58": "^4.0.1",
11
11
  "builtin-modules": "^1.1.1",
@@ -80,4 +80,4 @@
80
80
  "url": "https://github.com/Typus-Lab/typus-sdk/issues"
81
81
  },
82
82
  "homepage": "https://github.com/Typus-Lab/typus-sdk#readme"
83
- }
83
+ }
@@ -1,30 +0,0 @@
1
- export declare const TOKEN_PACKAGE = "0xa1d0cdb1b41c786d53a03d30340ab05718010e04";
2
- export declare const TOKEN_REGISTRY_BTC = "0x7325b75b85ee45e78204a9dcf7800a397259eb3d";
3
- export declare const TOKEN_REGISTRY_ETH = "0x475d3b10d29c03d85dfa707b5479955729216d4d";
4
- export declare const TOKEN_REGISTRY_SUI = "0x3b87b3f0403f527d28fd1301074a12446f43817a";
5
- export declare const TOKEN_REGISTRY_APT = "0xf1a947ebc2643942bf3f2ecbd6b583c0f8dc3baf";
6
- export declare const TOKEN_REGISTRY_DOGE = "0x4dbe73f8a744008bc20d12aaa0d4fc8f01692358";
7
- export declare const TOKEN_REGISTRY_USDC = "0x82e0a1473c6c4d4f713a0ac5957e0c7a2278ed1e";
8
- export declare const ORACLE_PACKAGE = "0x0a55a6dfa713f83cb3be5e3ca8a8435ccdbb500d";
9
- export declare const TIME_ORACLE = "0x55031e1edc517a4b16543c1c081ba33a59ffd084";
10
- export declare const COVERED_CALL_PACKAGE = "0x503ac615e4844aa31b5e3ca2feadea0d74e1b8af";
11
- export declare const COVERED_CALL_REGISTRY = "0xdf5e52550dc82396ea48a97dbbec65322779db77";
12
- export declare const COVERED_CALL_MANAGER = "0x9be7316b23f19c89073852ad7b8881f8cc89f727";
13
- export declare const USER_SHARE_TABLE = "0xd41260528fe89a571cbcabeefd9c5bd560f01b07";
14
- export declare const USER_REFUND_TABLE = "0xca101b960ca0f71f5d7c090a912e70a22a7b3587";
15
- export declare const MAKER_SHARE_TABLE = "0xe66a7a0051082bdc728077ac6309a7baee208f57";
16
- export declare const DOV_PACKAGE = "0x49e71a735dc6bdf7327e6c663d04a3e7f68bafd0";
17
- export declare const TEST_MINT_TOKEN = "0x672612858fcb5c6abf944638253142820c251753";
18
- export declare const PRICE_DECIMAL = 8;
19
- export declare const TOKEN_DECIMAL = 9;
20
- export declare const DEFAULT_TYPE_ARGUMENT = "0x2::sui::SUI";
21
- export declare const FAKE_TOKEN_TYPE_ARGUMENT = "0x27b3674c685046f66cad1d5496d2967894fa5329::token::USDC";
22
- export declare const TEST_MNEMONIC = "plug grain matter asthma aware critic can lottery blouse uncover sauce speak";
23
- export declare const TOKEN_NAME: string[];
24
- export declare const TOKEN_NAME_TO_MODULE: {
25
- BTC: string;
26
- ETH: string;
27
- SUI: string;
28
- USDC: string;
29
- };
30
- export declare const TESTNET_RPC_ENDPOINT = "https://fullnode.testnet.sui.io:443";
package/lib/constants.js DELETED
@@ -1,38 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TESTNET_RPC_ENDPOINT = exports.TOKEN_NAME_TO_MODULE = exports.TOKEN_NAME = exports.TEST_MNEMONIC = exports.FAKE_TOKEN_TYPE_ARGUMENT = exports.DEFAULT_TYPE_ARGUMENT = exports.TOKEN_DECIMAL = exports.PRICE_DECIMAL = exports.TEST_MINT_TOKEN = exports.DOV_PACKAGE = exports.MAKER_SHARE_TABLE = exports.USER_REFUND_TABLE = exports.USER_SHARE_TABLE = exports.COVERED_CALL_MANAGER = exports.COVERED_CALL_REGISTRY = exports.COVERED_CALL_PACKAGE = exports.TIME_ORACLE = exports.ORACLE_PACKAGE = exports.TOKEN_REGISTRY_USDC = exports.TOKEN_REGISTRY_DOGE = exports.TOKEN_REGISTRY_APT = exports.TOKEN_REGISTRY_SUI = exports.TOKEN_REGISTRY_ETH = exports.TOKEN_REGISTRY_BTC = exports.TOKEN_PACKAGE = void 0;
4
- //publish from sui-dev-token
5
- exports.TOKEN_PACKAGE = "0xa1d0cdb1b41c786d53a03d30340ab05718010e04";
6
- exports.TOKEN_REGISTRY_BTC = "0x7325b75b85ee45e78204a9dcf7800a397259eb3d";
7
- exports.TOKEN_REGISTRY_ETH = "0x475d3b10d29c03d85dfa707b5479955729216d4d";
8
- exports.TOKEN_REGISTRY_SUI = "0x3b87b3f0403f527d28fd1301074a12446f43817a";
9
- exports.TOKEN_REGISTRY_APT = "0xf1a947ebc2643942bf3f2ecbd6b583c0f8dc3baf";
10
- exports.TOKEN_REGISTRY_DOGE = "0x4dbe73f8a744008bc20d12aaa0d4fc8f01692358";
11
- exports.TOKEN_REGISTRY_USDC = "0x82e0a1473c6c4d4f713a0ac5957e0c7a2278ed1e";
12
- //publish from typus-oracle
13
- exports.ORACLE_PACKAGE = "0x0a55a6dfa713f83cb3be5e3ca8a8435ccdbb500d";
14
- exports.TIME_ORACLE = "0x55031e1edc517a4b16543c1c081ba33a59ffd084";
15
- //publish from typus-dov/cover_call
16
- exports.COVERED_CALL_PACKAGE = "0x503ac615e4844aa31b5e3ca2feadea0d74e1b8af";
17
- exports.COVERED_CALL_REGISTRY = "0xdf5e52550dc82396ea48a97dbbec65322779db77";
18
- exports.COVERED_CALL_MANAGER = "0x9be7316b23f19c89073852ad7b8881f8cc89f727";
19
- exports.USER_SHARE_TABLE = "0xd41260528fe89a571cbcabeefd9c5bd560f01b07";
20
- exports.USER_REFUND_TABLE = "0xca101b960ca0f71f5d7c090a912e70a22a7b3587";
21
- exports.MAKER_SHARE_TABLE = "0xe66a7a0051082bdc728077ac6309a7baee208f57";
22
- //publish from typus-dov/typus-dov
23
- exports.DOV_PACKAGE = "0x49e71a735dc6bdf7327e6c663d04a3e7f68bafd0";
24
- exports.TEST_MINT_TOKEN = "0x672612858fcb5c6abf944638253142820c251753";
25
- exports.PRICE_DECIMAL = 8;
26
- exports.TOKEN_DECIMAL = 9;
27
- exports.DEFAULT_TYPE_ARGUMENT = "0x2::sui::SUI";
28
- exports.FAKE_TOKEN_TYPE_ARGUMENT = "0x27b3674c685046f66cad1d5496d2967894fa5329::token::USDC";
29
- exports.TEST_MNEMONIC = "plug grain matter asthma aware critic can lottery blouse uncover sauce speak";
30
- exports.TOKEN_NAME = ["BTC", "ETH", "SUI", "USDC", "USDT", "SUI"];
31
- exports.TOKEN_NAME_TO_MODULE = {
32
- "BTC": "btc",
33
- "ETH": "eth",
34
- "SUI": "sui",
35
- "USDC": "usdc",
36
- // "USDT": "token_usdt",
37
- };
38
- exports.TESTNET_RPC_ENDPOINT = "https://fullnode.testnet.sui.io:443";
File without changes
@@ -1,6 +0,0 @@
1
- "use strict";
2
- // import { subVaults } from '../utils/getSubVault';
3
- // (async () => {
4
- // let res = await subVaults()//TODO: let registry be input variable
5
- // console.log(res)
6
- // })();
@@ -1 +0,0 @@
1
- export {};
@@ -1,187 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- var sui_js_1 = require("@mysten/sui.js");
7
- var fs_1 = __importDefault(require("fs"));
8
- var constants_1 = require("../constants");
9
- var execSync = require('child_process').execSync;
10
- var provider = new sui_js_1.JsonRpcProvider(constants_1.TESTNET_RPC_ENDPOINT); //for read only operations
11
- var owner = "0xd28103a499003bed0b1b9ee52988ecdd2db82224";
12
- var obj1 = "0x7e9e58daeb94bbd0450bb9ee9f00e219a1f2b734"; //obj owned by owner
13
- var obj2 = "0x74aa838eb6627c8e74b0645484abb463e6fd6669"; //obj owned by owner
14
- var obj1Digest = "tclmc0L6hewmfWxQAxSl9eUe14C82+hzE4OblKgY38U=";
15
- var obj2Digest = "tclmc0L6hewmfWxQAxSl9eUe14C82+hzE4OblKgY38U=";
16
- var receiver = "0x15ca0895f29101085cb26e00ede89420741b3140";
17
- var tx1 = "GRiBgktRqgJ4MSoRhCfSm/+1R/Zh9jy4UncoQeFAu5I=";
18
- // export PRIVATEKEY=~/.sui/sui_config/sui.keystore
19
- var secretKeysPath = process.env.PRIVATEKEY;
20
- var subVault = "0xd3b2d3ee74afe2b5af0f810b3368955f068188e8";
21
- var TEST_MNEMONIC = "tackle wheat jungle viable memory dwarf swift fold purpose cattle impose horn";
22
- var VALID_SECRET_KEY = "Itk7iNFs91kXKdqVqmLrBKJItNIoSyWAOh+ZC2qaSihpxiAxNYwKPjwfresk9CSbKCmwNwvXfPQoeLL4rVa4OQ=="; //'mdqVWeFekT7pqy5T49+tV12jO0m+ESW7ki4zSU9JiCgbL0kJbj5dvQ/PqcDAzZLZqzshVEs01d1KZdmLh4uZIg==';
23
- // let secretKeys = (readJsonFile<any>(secretKeysPath as string))
24
- // let sender = secretKeys[0]
25
- // let keypair = Ed25519Keypair.fromSecretKey(fromB64(sender))// Error: Wrong secretKey size. Expected 64 bytes, got 65.
26
- // let keypair = Ed25519Keypair.fromSecretKey(fromB64(VALID_SECRET_KEY))
27
- var keypair = sui_js_1.Ed25519Keypair.deriveKeypair(TEST_MNEMONIC);
28
- var signer = new sui_js_1.RawSigner(keypair, provider);
29
- function readJsonFile(filePath) {
30
- return JSON.parse(fs_1.default.readFileSync(filePath, "utf-8"));
31
- }
32
- // //Success
33
- // (async () => {
34
- // console.log("test for getObjectsOwnedByAddress()")
35
- // const objects = await provider.getObjectsOwnedByAddress(
36
- // owner
37
- // )
38
- // console.log(objects)
39
- // })();
40
- // //Success
41
- // (async () => {
42
- // console.log("test for getObjectsOwnedByObject()")
43
- // const objects = await provider.getObjectsOwnedByObject(
44
- // obj1
45
- // )
46
- // console.log(objects)
47
- // //filter obj by type
48
- // for (let object of objects) {
49
- // if (object.type.includes("dynamic_field")) console.log("it's dynamic field object")
50
- // }
51
- // })();
52
- // //Success
53
- // (async () => {
54
- // console.log("test for getObject() and getObjectBatch()")
55
- // const txn = await provider.getObject(
56
- // obj1
57
- // );
58
- // console.log(txn)
59
- // // You can also fetch multiple objects in one batch request
60
- // const txns = await provider.getObjectBatch([
61
- // obj1,
62
- // obj2,
63
- // ]);
64
- // console.log(txns)
65
- // })();
66
- // // Fail
67
- // (async () => {
68
- // console.log("test for getTransactionWithEffects() and getTransactionWithEffectsBatch()")
69
- // const txn = await provider.getTransactionWithEffects(
70
- // obj1Digest
71
- // );
72
- // console.log(txn)
73
- // You can also fetch multiple transactions in one batch request
74
- // const txns = await provider.getTransactionWithEffectsBatch([
75
- // obj1Digest,
76
- // obj2Digest,
77
- // ]);
78
- // console.log(txns)
79
- // })();
80
- // //Fail (without correct signer)
81
- // (async () => {
82
- // console.log("test for transferObject()")
83
- // const transferTxn = await signer.transferObject({
84
- // objectId: obj1,
85
- // gasBudget: 1000,
86
- // recipient: receiver,
87
- // });
88
- // console.log('transferTxn', transferTxn);
89
- // })();
90
- // //Fail (without correct signer)
91
- // (async () => {
92
- // console.log("test for executeMoveCall()")
93
- // const moveCallTxn = await signer.executeMoveCall({
94
- // packageObjectId: '0x2',
95
- // module: 'devnet_nft',
96
- // function: 'mint',
97
- // typeArguments: [],
98
- // arguments: [
99
- // 'Example NFT',
100
- // 'An NFT created by the wallet Command Line Tool',
101
- // 'ipfs://bafkreibngqhl3gaa7daob4i2vccziay2jjlp435cf66vhono7nrvww53ty',
102
- // ],
103
- // gasBudget: 10000,
104
- // });
105
- // console.log('moveCallTxn', moveCallTxn);
106
- // })();
107
- // //Fail( Error subscribing to event)
108
- // (async () => {
109
- // console.log("test for subscribeEvent()")
110
- // // calls RPC method 'sui_subscribeEvent' with params:
111
- // // [ { SenderAddress: '0xbff6ccc8707aa517b4f1b95750a2a8c666012df3' } ]
112
- // const subscriptionId = await provider.subscribeEvent(
113
- // { SenderAddress: '0xbff6ccc8707aa517b4f1b95750a2a8c666012df3' },
114
- // (event: SuiEventEnvelope) => {
115
- // console.log(event)
116
- // // handle subscription notification message here. This function is called once per subscription message.
117
- // }
118
- // );
119
- // // later, to unsubscribe
120
- // // calls RPC method 'sui_unsubscribeEvent' with params: [ subscriptionId ]
121
- // const subFoundAndRemoved = await provider.unsubscribeEvent(subscriptionId);
122
- // })();
123
- // //Fail (without correct signer)
124
- //refer: https://docs.sui.io/build/json-rpc
125
- // (async () => {
126
- // console.log("test for publish()")
127
- // const compiledModules = JSON.parse(
128
- // execSync(
129
- // `${cliPath} move build --dump-bytecode-as-base64 --path ${packagePath}`,
130
- // { encoding: 'utf-8' }
131
- // )
132
- // );
133
- // const modulesInBytes = compiledModules.map((m) =>
134
- // Array.from(new Base64DataBuffer(m).getData())
135
- // );
136
- // const publishTxn = await signer.publish({
137
- // compiledModules: modulesInBytes,
138
- // gasBudget: 10000,
139
- // });
140
- // console.log('publishTxn', publishTxn);
141
- // })();
142
- // //Success
143
- // (async () => {
144
- // console.log("test for getTransactions()") // return digest
145
- // let txs = await provider.getTransactionsForObject(
146
- // obj1
147
- // )
148
- // console.log(txs)
149
- // let tx = await provider.getTransactionWithEffects(
150
- // txs[0]
151
- // )
152
- // console.log(tx)
153
- // })();
154
- // //Success
155
- // (async () => {
156
- // console.log("test for getEvents()")//input type: EventQuery
157
- // const senderEvents = await provider.getEvents(
158
- // { "Transaction": tx1 },
159
- // null,
160
- // null,
161
- // );
162
- // for (let e of senderEvents.data) {
163
- // console.log(e.event)
164
- // }
165
- // })();
166
- // let packageId = "0xfbbdd33ab4c02e7a315e2477931bae4cbdf46381";
167
- // let registry = "0x0a9d87a1b6c00415708d2f1c62784b52f797213c";
168
- // let coin = "0x84e5c5702bfbb00a830fb43e720a3a412cc2a8db";
169
- // console.log("test for deposit()")
170
- // await deposit(packageId, registry, coin)
171
- // async function deposit(packageId: string, registry: string, coin: string) {
172
- // let txn = {
173
- // packageObjectId: packageId,
174
- // module: 'shark_fin',
175
- // function: 'deposit',
176
- // typeArguments: ["0x2::sui::SUI"],
177
- // arguments: [
178
- // registry,
179
- // 0,
180
- // true,
181
- // coin
182
- // ],
183
- // gasBudget: 1000,
184
- // }
185
- // const moveCallTxn = await signer.executeMoveCall(txn);
186
- // console.log('moveCallTxn', moveCallTxn);
187
- // }
@@ -1,5 +0,0 @@
1
- import { CoveredCallVault } from "../utils/fetchData";
2
- export declare function getBidEventsCranker(type: string, renewSec: number, vault: CoveredCallVault[]): Promise<void>;
3
- export declare function getNewAuctionEventsCranker(type: string, renewSec: number, vault: CoveredCallVault[]): Promise<void>;
4
- export declare function getEndAuctionEventsCranker(type: string, renewSec: number, vault: CoveredCallVault[]): Promise<void>;
5
- export declare function sendEventToTelegramChannel(text: any): Promise<void>;
@@ -1,277 +0,0 @@
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 __importDefault = (this && this.__importDefault) || function (mod) {
39
- return (mod && mod.__esModule) ? mod : { "default": mod };
40
- };
41
- Object.defineProperty(exports, "__esModule", { value: true });
42
- exports.sendEventToTelegramChannel = exports.getEndAuctionEventsCranker = exports.getNewAuctionEventsCranker = exports.getBidEventsCranker = void 0;
43
- var constants_1 = require("../constants");
44
- var sui_js_1 = require("@mysten/sui.js");
45
- var getVaultData_1 = require("../utils/getVaultData");
46
- var node_cron_1 = __importDefault(require("node-cron"));
47
- var XMLHttpRequest_1 = require("XMLHttpRequest");
48
- var moment_1 = __importDefault(require("moment"));
49
- var provider = new sui_js_1.JsonRpcProvider(constants_1.TESTNET_RPC_ENDPOINT); //for read only operations
50
- var apiToken = "5864284783:AAHwXWgt2YgLENdJ9mVBUDBVLHXrMLNgkic";
51
- /*
52
- 「https://api.telegram.org/botTOKEN/getUpdates」,change TOKEN to token from botFather
53
- */
54
- var chatId = "-1001784476809";
55
- (function () { return __awaiter(void 0, void 0, void 0, function () {
56
- var bidTypes, newAuctionType, endAuctionType, renewSec, vault;
57
- return __generator(this, function (_a) {
58
- switch (_a.label) {
59
- case 0:
60
- bidTypes = [
61
- constants_1.COVERED_CALL_PACKAGE + "::covered_call::NewBid<" + constants_1.TOKEN_PACKAGE + "::eth::ETH>",
62
- constants_1.COVERED_CALL_PACKAGE + "::covered_call::NewBid<" + constants_1.TOKEN_PACKAGE + "::btc::BTC>",
63
- constants_1.COVERED_CALL_PACKAGE + "::covered_call::NewBid<" + constants_1.TOKEN_PACKAGE + "::sui::SUI>",
64
- ];
65
- newAuctionType = constants_1.COVERED_CALL_PACKAGE + "::covered_call::NewAuction";
66
- endAuctionType = constants_1.DOV_PACKAGE + "::dutch::Delivery<" + constants_1.TOKEN_PACKAGE + "::eth::ETH>";
67
- renewSec = 10;
68
- return [4 /*yield*/, (0, getVaultData_1.getVaultDataFromRegistry)(constants_1.COVERED_CALL_REGISTRY)];
69
- case 1:
70
- vault = _a.sent();
71
- bidTypes.map(function (bidType) { return __awaiter(void 0, void 0, void 0, function () {
72
- return __generator(this, function (_a) {
73
- switch (_a.label) {
74
- case 0: return [4 /*yield*/, getBidEventsCranker(bidType, renewSec, vault)]; //new_bid
75
- case 1:
76
- _a.sent(); //new_bid
77
- return [2 /*return*/];
78
- }
79
- });
80
- }); });
81
- return [4 /*yield*/, getNewAuctionEventsCranker(newAuctionType, renewSec, vault)]; //evolution
82
- case 2:
83
- _a.sent(); //evolution
84
- return [4 /*yield*/, getEndAuctionEventsCranker(endAuctionType, renewSec, vault)];
85
- case 3:
86
- _a.sent();
87
- return [2 /*return*/];
88
- }
89
- });
90
- }); })();
91
- function generateBidId(vault) {
92
- return __awaiter(this, void 0, void 0, function () {
93
- var liveVault, res;
94
- return __generator(this, function (_a) {
95
- liveVault = vault === null || vault === void 0 ? void 0 : vault.filter(function (v) {
96
- var start = moment_1.default.unix(Number(v.config.activationTsMs) / 1000);
97
- var settled = v.vault.ableToDeposit === false && v.vault.ableToWithdraw === true;
98
- return start.isBefore((0, moment_1.default)()) && !settled;
99
- });
100
- res = liveVault.map(function (v) {
101
- var time = v.config.expirationTsMs;
102
- var expiration = moment_1.default
103
- .unix(Number(time) / 1000)
104
- .format("DDMMMYY");
105
- var bidId = "".concat(v.asset, "-").concat(expiration, "-").concat(v.config.payoffConfig.strike, "-C");
106
- var obj = {
107
- bidFormat: bidId,
108
- bidTime: Number(time)
109
- };
110
- return obj;
111
- });
112
- return [2 /*return*/, res];
113
- });
114
- });
115
- }
116
- function getBidEventsCranker(type, renewSec, vault) {
117
- return __awaiter(this, void 0, void 0, function () {
118
- var res;
119
- var _this = this;
120
- return __generator(this, function (_a) {
121
- res = [];
122
- node_cron_1.default.schedule('*/' + renewSec.toString() + ' * * * * *', function () { return __awaiter(_this, void 0, void 0, function () {
123
- var events, newRes, newBid, format_1, bidIds_1, telegramText;
124
- var _this = this;
125
- return __generator(this, function (_a) {
126
- switch (_a.label) {
127
- case 0: return [4 /*yield*/, provider.getEvents({ MoveEvent: type }, null, null)];
128
- case 1:
129
- events = _a.sent();
130
- newRes = events.data;
131
- if (!(newRes.length != res.length)) return [3 /*break*/, 3];
132
- console.log("the total bid event number now: " + events.data.length);
133
- console.log("there are " + (newRes.length - res.length).toString() + " new bids");
134
- newBid = newRes.filter(function (_a) {
135
- var id1 = _a.timestamp;
136
- return !res.some(function (_a) {
137
- var id2 = _a.timestamp;
138
- return id2 === id1;
139
- });
140
- });
141
- console.log("new bid amount: " + newBid.length);
142
- format_1 = "";
143
- return [4 /*yield*/, generateBidId(vault)];
144
- case 2:
145
- bidIds_1 = _a.sent();
146
- // [
147
- // 'ETH-18Jan23-1750-C',
148
- // 'BTC-18Jan23-21800-C',
149
- // 'ETH-17Jan23-1750-C',
150
- // 'SUI-18Jan23-9-C'
151
- // ]
152
- console.log(bidIds_1);
153
- newBid.map(function (e) { return __awaiter(_this, void 0, void 0, function () {
154
- var bidId, size;
155
- return __generator(this, function (_a) {
156
- bidId = bidIds_1.find(function (bidId) {
157
- var type = e.event.moveEvent.type;
158
- var asset = bidId.bidFormat.split("-")[0];
159
- return e.event.moveEvent.type.includes(bidId.bidFormat.split("-")[0]);
160
- });
161
- if (bidId) {
162
- size = (Number(e.event.moveEvent.fields.size) / (Math.pow(10, constants_1.TOKEN_DECIMAL))).toString();
163
- format_1 += bidId.bidFormat + " is bid with " + size + " " + bidId.bidFormat.split("-")[0] + "! \n";
164
- }
165
- else {
166
- console.log("can't get bidId in getBidEventsCranker");
167
- }
168
- return [2 /*return*/];
169
- });
170
- }); });
171
- telegramText = format_1;
172
- console.log(telegramText);
173
- // sendEventToTelegramChannel(telegramText)
174
- res = newRes;
175
- _a.label = 3;
176
- case 3: return [2 /*return*/];
177
- }
178
- });
179
- }); });
180
- return [2 /*return*/];
181
- });
182
- });
183
- }
184
- exports.getBidEventsCranker = getBidEventsCranker;
185
- function getNewAuctionEventsCranker(type, renewSec, vault) {
186
- return __awaiter(this, void 0, void 0, function () {
187
- var res;
188
- var _this = this;
189
- return __generator(this, function (_a) {
190
- res = [];
191
- node_cron_1.default.schedule('*/' + renewSec.toString() + ' * * * * *', function () { return __awaiter(_this, void 0, void 0, function () {
192
- var events, newRes, format_2, bidIds, telegramText;
193
- var _this = this;
194
- return __generator(this, function (_a) {
195
- switch (_a.label) {
196
- case 0: return [4 /*yield*/, provider.getEvents({ MoveEvent: type }, null, null)];
197
- case 1:
198
- events = _a.sent();
199
- newRes = events.data;
200
- if (!(newRes.length != res.length)) return [3 /*break*/, 3];
201
- format_2 = "";
202
- return [4 /*yield*/, generateBidId(vault)];
203
- case 2:
204
- bidIds = _a.sent();
205
- bidIds.map(function (bidId) { return __awaiter(_this, void 0, void 0, function () {
206
- return __generator(this, function (_a) {
207
- format_2 += bidId.bidFormat + " auction is live now! \n";
208
- return [2 /*return*/];
209
- });
210
- }); });
211
- telegramText = format_2;
212
- console.log(telegramText);
213
- // sendEventToTelegramChannel(telegramText)
214
- res = newRes;
215
- _a.label = 3;
216
- case 3: return [2 /*return*/];
217
- }
218
- });
219
- }); });
220
- return [2 /*return*/];
221
- });
222
- });
223
- }
224
- exports.getNewAuctionEventsCranker = getNewAuctionEventsCranker;
225
- function getEndAuctionEventsCranker(type, renewSec, vault) {
226
- return __awaiter(this, void 0, void 0, function () {
227
- var res;
228
- var _this = this;
229
- return __generator(this, function (_a) {
230
- res = [];
231
- node_cron_1.default.schedule('*/' + renewSec.toString() + ' * * * * *', function () { return __awaiter(_this, void 0, void 0, function () {
232
- var events, newRes, format_3, bidIds, telegramText;
233
- var _this = this;
234
- return __generator(this, function (_a) {
235
- switch (_a.label) {
236
- case 0: return [4 /*yield*/, provider.getEvents({ MoveEvent: type }, null, null)];
237
- case 1:
238
- events = _a.sent();
239
- newRes = events.data;
240
- if (!(newRes.length != res.length)) return [3 /*break*/, 3];
241
- format_3 = "";
242
- return [4 /*yield*/, generateBidId(vault)];
243
- case 2:
244
- bidIds = _a.sent();
245
- bidIds.map(function (bidId) { return __awaiter(_this, void 0, void 0, function () {
246
- return __generator(this, function (_a) {
247
- format_3 += bidId.bidFormat + " auction is closed! \n";
248
- return [2 /*return*/];
249
- });
250
- }); });
251
- telegramText = format_3;
252
- console.log(telegramText);
253
- // sendEventToTelegramChannel(telegramText)
254
- res = newRes;
255
- _a.label = 3;
256
- case 3: return [2 /*return*/];
257
- }
258
- });
259
- }); });
260
- return [2 /*return*/];
261
- });
262
- });
263
- }
264
- exports.getEndAuctionEventsCranker = getEndAuctionEventsCranker;
265
- function sendEventToTelegramChannel(text) {
266
- return __awaiter(this, void 0, void 0, function () {
267
- var urlString, request;
268
- return __generator(this, function (_a) {
269
- urlString = "https://api.telegram.org/bot".concat(apiToken, "/sendMessage?chat_id=").concat(chatId, "&text=").concat(text);
270
- request = new XMLHttpRequest_1.XMLHttpRequest();
271
- request.open("GET", urlString);
272
- request.send();
273
- return [2 /*return*/];
274
- });
275
- });
276
- }
277
- exports.sendEventToTelegramChannel = sendEventToTelegramChannel;
@@ -1 +0,0 @@
1
- export {};
@@ -1,53 +0,0 @@
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 getBid_1 = require("../utils/auction/getBid");
40
- (function () { return __awaiter(void 0, void 0, void 0, function () {
41
- var vault, bid;
42
- return __generator(this, function (_a) {
43
- switch (_a.label) {
44
- case 0:
45
- vault = "0x1e5807f118c2fc7e0f74eeb439b34f448532a900";
46
- return [4 /*yield*/, (0, getBid_1.getBid)(vault)];
47
- case 1:
48
- bid = _a.sent();
49
- console.log(bid);
50
- return [2 /*return*/];
51
- }
52
- });
53
- }); })();
@@ -1 +0,0 @@
1
- export {};