@typus/typus-sdk 0.6.3 → 1.0.0

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 (212) hide show
  1. package/lib/config.json +17 -20
  2. package/lib/constants.d.ts +9 -7
  3. package/lib/constants.js +10 -8
  4. package/lib/test/authorized/testAuthorizedNewPortfolioVault.js +82 -0
  5. package/lib/test/{testClaim.js → authorized/testAuthorizedUpdateUpcomingVaultConfig.js} +19 -30
  6. package/lib/test/authorized/testAuthorizedUpdateWarmupVaultConfig.js +68 -0
  7. package/lib/test/getVaultData.js +1 -1
  8. package/lib/test/getWhiteListFromRegistry.js +1 -1
  9. package/lib/test/helper/getAuctionMaxSize.js +76 -0
  10. package/lib/test/helper/getUserStatus.js +75 -0
  11. package/lib/test/{testWithdraw.js → user/testClaim.js} +14 -17
  12. package/lib/test/{getMakersShares.js → user/testCompound.js} +20 -6
  13. package/lib/test/{testUnsubscribe.js → user/testDeposit.js} +28 -37
  14. package/lib/test/{getUsersShares.js → user/testHarvest.js} +20 -6
  15. package/lib/test/user/testNewBid.js +77 -0
  16. package/lib/test/user/testUnsubscribe.d.ts +1 -0
  17. package/lib/test/user/testUnsubscribe.js +69 -0
  18. package/lib/test/user/testWithdraw.d.ts +1 -0
  19. package/lib/test/{testDeposit.js → user/testWithdraw.js} +15 -19
  20. package/lib/utils/fetchData.d.ts +72 -61
  21. package/lib/utils/fetchData.js +26 -197
  22. package/lib/utils/getVaultData.d.ts +2 -2
  23. package/lib/utils/getVaultData.js +123 -161
  24. package/lib/utils/getWhiteListFromRegistry.js +0 -1
  25. package/lib/utils/portfolio/authorized/getAuthorizedAddPortfolioVaultAuthorizedUserTx.d.ts +1 -1
  26. package/lib/utils/portfolio/authorized/getAuthorizedAddPortfolioVaultAuthorizedUserTx.js +2 -2
  27. package/lib/utils/portfolio/authorized/getAuthorizedNewPortfolioVaultTx.d.ts +4 -3
  28. package/lib/utils/portfolio/authorized/getAuthorizedNewPortfolioVaultTx.js +5 -3
  29. package/lib/utils/portfolio/authorized/getAuthorizedRemovePortfolioVaultAuthorizedUserTx.d.ts +1 -1
  30. package/lib/utils/portfolio/authorized/getAuthorizedRemovePortfolioVaultAuthorizedUserTx.js +2 -2
  31. package/lib/utils/portfolio/authorized/getAuthorizedUpdateUpcomingVaultConfigTx.d.ts +4 -0
  32. package/lib/utils/portfolio/authorized/{getAuthorizedUpdateNextVaultConfigTx.js → getAuthorizedUpdateUpcomingVaultConfigTx.js} +5 -5
  33. package/lib/utils/portfolio/authorized/getAuthorizedUpdateWarmupVaultConfigTx.d.ts +1 -0
  34. package/lib/utils/portfolio/{manager/getUpdateVaultConfigTx.js → authorized/getAuthorizedUpdateWarmupVaultConfigTx.js} +4 -5
  35. package/lib/utils/portfolio/helper/getAuctionMaxSize.d.ts +8 -0
  36. package/lib/utils/portfolio/{manager/getLastEvolutionTx.js → helper/getAuctionMaxSize.js} +11 -7
  37. package/lib/utils/portfolio/helper/getUserStatus.d.ts +29 -0
  38. package/lib/utils/portfolio/{authorized/getAuthorizedEvolutionTx.js → helper/getUserStatus.js} +50 -9
  39. package/lib/utils/portfolio/manager/getAddAuthorizedUserTx.d.ts +8 -1
  40. package/lib/utils/portfolio/manager/getAddAuthorizedUserTx.js +9 -2
  41. package/lib/utils/portfolio/manager/getAddPortfolioVaultAuthorizedUserTx.d.ts +6 -0
  42. package/lib/utils/portfolio/manager/getAddPortfolioVaultAuthorizedUserTx.js +6 -0
  43. package/lib/utils/portfolio/manager/getEvolutionTx.d.ts +15 -1
  44. package/lib/utils/portfolio/manager/getEvolutionTx.js +14 -0
  45. package/lib/utils/portfolio/manager/getNewManagerTx.d.ts +8 -1
  46. package/lib/utils/portfolio/manager/getNewManagerTx.js +9 -2
  47. package/lib/utils/portfolio/manager/getNewPortfolioVaultTx.d.ts +5 -5
  48. package/lib/utils/portfolio/manager/getNewPortfolioVaultTx.js +5 -5
  49. package/lib/utils/portfolio/manager/getRemoveAuthorizedUserTx.d.ts +7 -0
  50. package/lib/utils/portfolio/manager/getRemoveAuthorizedUserTx.js +7 -0
  51. package/lib/utils/portfolio/manager/getRemoveManagerTx.d.ts +5 -0
  52. package/lib/utils/portfolio/manager/getRemoveManagerTx.js +5 -0
  53. package/lib/utils/portfolio/manager/getRemovePortfolioVaultAuthorizedUserTx.d.ts +7 -1
  54. package/lib/utils/portfolio/manager/getRemovePortfolioVaultAuthorizedUserTx.js +7 -1
  55. package/lib/utils/portfolio/user/getClaimAndHarvestTx.d.ts +9 -1
  56. package/lib/utils/portfolio/user/getClaimAndHarvestTx.js +11 -3
  57. package/lib/utils/portfolio/user/getClaimTx.d.ts +9 -1
  58. package/lib/utils/portfolio/user/getClaimTx.js +8 -0
  59. package/lib/utils/portfolio/user/getCompoundTx.d.ts +9 -0
  60. package/lib/utils/portfolio/{authorized/getAuthorizedLastEvolutionTx.js → user/getCompoundTx.js} +12 -6
  61. package/lib/utils/portfolio/user/getDepositTx.d.ts +10 -0
  62. package/lib/utils/portfolio/user/getDepositTx.js +10 -0
  63. package/lib/utils/portfolio/user/getHarvestTx.d.ts +9 -1
  64. package/lib/utils/portfolio/user/getHarvestTx.js +8 -0
  65. package/lib/utils/portfolio/user/getNewBidTx.d.ts +13 -1
  66. package/lib/utils/portfolio/user/getNewBidTx.js +12 -0
  67. package/lib/utils/portfolio/user/getUnsubscribeTx.d.ts +10 -1
  68. package/lib/utils/portfolio/user/getUnsubscribeTx.js +9 -0
  69. package/lib/utils/portfolio/user/getWithdrawTx.d.ts +10 -1
  70. package/lib/utils/portfolio/user/getWithdrawTx.js +9 -0
  71. package/package.json +1 -1
  72. package/lib/test/eventListener.d.ts +0 -5
  73. package/lib/test/eventListener.js +0 -397
  74. package/lib/test/testDepositV2.d.ts +0 -0
  75. package/lib/test/testDepositV2.js +0 -64
  76. package/lib/test/testNewAuction.js +0 -94
  77. package/lib/test/testNewVault.js +0 -153
  78. package/lib/test/testOracle.js +0 -94
  79. package/lib/test/testSettle.js +0 -590
  80. package/lib/utils/authorized/getAuthorizedAddAuthorizedUserTx.d.ts +0 -1
  81. package/lib/utils/authorized/getAuthorizedAddAuthorizedUserTx.js +0 -56
  82. package/lib/utils/authorized/getAuthorizedAddCoveredCallVaultAuthorizedUserTx.d.ts +0 -1
  83. package/lib/utils/authorized/getAuthorizedAddCoveredCallVaultAuthorizedUserTx.js +0 -56
  84. package/lib/utils/authorized/getAuthorizedDeliveryTx.d.ts +0 -1
  85. package/lib/utils/authorized/getAuthorizedDeliveryTx.js +0 -56
  86. package/lib/utils/authorized/getAuthorizedEvolutionTx.d.ts +0 -1
  87. package/lib/utils/authorized/getAuthorizedEvolutionTx.js +0 -56
  88. package/lib/utils/authorized/getAuthorizedLastEvolutionTx.d.ts +0 -1
  89. package/lib/utils/authorized/getAuthorizedLastEvolutionTx.js +0 -56
  90. package/lib/utils/authorized/getAuthorizedNewAuctionTx.d.ts +0 -1
  91. package/lib/utils/authorized/getAuthorizedNewAuctionTx.js +0 -56
  92. package/lib/utils/authorized/getAuthorizedNewCoveredCallVaultTx.d.ts +0 -1
  93. package/lib/utils/authorized/getAuthorizedNewCoveredCallVaultTx.js +0 -76
  94. package/lib/utils/authorized/getAuthorizedRemoveAuthorizedUserTx.d.ts +0 -1
  95. package/lib/utils/authorized/getAuthorizedRemoveAuthorizedUserTx.js +0 -56
  96. package/lib/utils/authorized/getAuthorizedRemoveCoveredCallVaultAuthorizedUserTx.d.ts +0 -1
  97. package/lib/utils/authorized/getAuthorizedRemoveCoveredCallVaultAuthorizedUserTx.js +0 -56
  98. package/lib/utils/authorized/getAuthorizedSettleTx.d.ts +0 -1
  99. package/lib/utils/authorized/getAuthorizedSettleTx.js +0 -56
  100. package/lib/utils/authorized/getAuthorizedUpdateCapacityTx.d.ts +0 -1
  101. package/lib/utils/authorized/getAuthorizedUpdateCapacityTx.js +0 -56
  102. package/lib/utils/authorized/getAuthorizedUpdateNextVaultConfigTx.d.ts +0 -1
  103. package/lib/utils/authorized/getAuthorizedUpdateNextVaultConfigTx.js +0 -65
  104. package/lib/utils/authorized/getAuthorizedUpdateVaultConfigTx.d.ts +0 -1
  105. package/lib/utils/authorized/getAuthorizedUpdateVaultConfigTx.js +0 -64
  106. package/lib/utils/coveredCall/createPriceOracle.d.ts +0 -1
  107. package/lib/utils/coveredCall/createPriceOracle.js +0 -93
  108. package/lib/utils/coveredCall/createTimeOracle.d.ts +0 -1
  109. package/lib/utils/coveredCall/createTimeOracle.js +0 -92
  110. package/lib/utils/coveredCall/getAddCoveredCallVaultAuthorizedUserTx.d.ts +0 -1
  111. package/lib/utils/coveredCall/getAddCoveredCallVaultAuthorizedUserTx.js +0 -61
  112. package/lib/utils/coveredCall/getClaimAllTx.d.ts +0 -1
  113. package/lib/utils/coveredCall/getClaimAllTx.js +0 -59
  114. package/lib/utils/coveredCall/getClaimTx.d.ts +0 -1
  115. package/lib/utils/coveredCall/getClaimTx.js +0 -59
  116. package/lib/utils/coveredCall/getCloseAuctionTx.d.ts +0 -1
  117. package/lib/utils/coveredCall/getCloseAuctionTx.js +0 -61
  118. package/lib/utils/coveredCall/getCloseVaultTx.d.ts +0 -1
  119. package/lib/utils/coveredCall/getCloseVaultTx.js +0 -60
  120. package/lib/utils/coveredCall/getDeliveryTx.d.ts +0 -1
  121. package/lib/utils/coveredCall/getDeliveryTx.js +0 -61
  122. package/lib/utils/coveredCall/getDepositTx.d.ts +0 -1
  123. package/lib/utils/coveredCall/getDepositTx.js +0 -65
  124. package/lib/utils/coveredCall/getEvolutionTx.d.ts +0 -1
  125. package/lib/utils/coveredCall/getEvolutionTx.js +0 -64
  126. package/lib/utils/coveredCall/getLastEvolutionTx.d.ts +0 -1
  127. package/lib/utils/coveredCall/getLastEvolutionTx.js +0 -63
  128. package/lib/utils/coveredCall/getMakerClaimAllTx.d.ts +0 -1
  129. package/lib/utils/coveredCall/getMakerClaimAllTx.js +0 -59
  130. package/lib/utils/coveredCall/getMakerClaimTx.d.ts +0 -1
  131. package/lib/utils/coveredCall/getMakerClaimTx.js +0 -59
  132. package/lib/utils/coveredCall/getNewAuctionTx.d.ts +0 -1
  133. package/lib/utils/coveredCall/getNewAuctionTx.js +0 -66
  134. package/lib/utils/coveredCall/getNewAuctionWithNextCoveredCallVaultTx.d.ts +0 -1
  135. package/lib/utils/coveredCall/getNewAuctionWithNextCoveredCallVaultTx.js +0 -64
  136. package/lib/utils/coveredCall/getNewBidTx.d.ts +0 -1
  137. package/lib/utils/coveredCall/getNewBidTx.js +0 -62
  138. package/lib/utils/coveredCall/getNewCoveredCallVaultTx.d.ts +0 -1
  139. package/lib/utils/coveredCall/getNewCoveredCallVaultTx.js +0 -77
  140. package/lib/utils/coveredCall/getNewManagerTx.d.ts +0 -1
  141. package/lib/utils/coveredCall/getNewManagerTx.js +0 -59
  142. package/lib/utils/coveredCall/getRefundTx.d.ts +0 -1
  143. package/lib/utils/coveredCall/getRefundTx.js +0 -59
  144. package/lib/utils/coveredCall/getRemoveBidTx.d.ts +0 -1
  145. package/lib/utils/coveredCall/getRemoveBidTx.js +0 -60
  146. package/lib/utils/coveredCall/getRemoveCoveredCallVaultAuthorizedUserTx.d.ts +0 -1
  147. package/lib/utils/coveredCall/getRemoveCoveredCallVaultAuthorizedUserTx.js +0 -61
  148. package/lib/utils/coveredCall/getRemoveManagerTx.d.ts +0 -1
  149. package/lib/utils/coveredCall/getRemoveManagerTx.js +0 -58
  150. package/lib/utils/coveredCall/getRollOverTx.d.ts +0 -1
  151. package/lib/utils/coveredCall/getRollOverTx.js +0 -60
  152. package/lib/utils/coveredCall/getSettleTx.d.ts +0 -1
  153. package/lib/utils/coveredCall/getSettleTx.js +0 -62
  154. package/lib/utils/coveredCall/getSettleWithRollOverTx.d.ts +0 -1
  155. package/lib/utils/coveredCall/getSettleWithRollOverTx.js +0 -62
  156. package/lib/utils/coveredCall/getSubscribeTx.d.ts +0 -1
  157. package/lib/utils/coveredCall/getSubscribeTx.js +0 -60
  158. package/lib/utils/coveredCall/getUnsubscribeTx.d.ts +0 -1
  159. package/lib/utils/coveredCall/getUnsubscribeTx.js +0 -63
  160. package/lib/utils/coveredCall/getUpdateCapacityTx.d.ts +0 -1
  161. package/lib/utils/coveredCall/getUpdateCapacityTx.js +0 -61
  162. package/lib/utils/coveredCall/getUpdateNextVaultConfigTx.d.ts +0 -1
  163. package/lib/utils/coveredCall/getUpdateNextVaultConfigTx.js +0 -66
  164. package/lib/utils/coveredCall/getUpdatePayoffConfigTx.d.ts +0 -1
  165. package/lib/utils/coveredCall/getUpdatePayoffConfigTx.js +0 -62
  166. package/lib/utils/coveredCall/getUpdateVaultConfigTx.d.ts +0 -1
  167. package/lib/utils/coveredCall/getUpdateVaultConfigTx.js +0 -65
  168. package/lib/utils/coveredCall/getWithdrawTx.d.ts +0 -1
  169. package/lib/utils/coveredCall/getWithdrawTx.js +0 -60
  170. package/lib/utils/fetchPortfolioData.d.ts +0 -93
  171. package/lib/utils/fetchPortfolioData.js +0 -205
  172. package/lib/utils/getCreateTokenRegistryTx.d.ts +0 -1
  173. package/lib/utils/getCreateTokenRegistryTx.js +0 -59
  174. package/lib/utils/getMakersShares.d.ts +0 -8
  175. package/lib/utils/getMakersShares.js +0 -145
  176. package/lib/utils/getNewOracleTx.d.ts +0 -1
  177. package/lib/utils/getNewOracleTx.js +0 -59
  178. package/lib/utils/getNewTimeOracleTx.d.ts +0 -1
  179. package/lib/utils/getNewTimeOracleTx.js +0 -56
  180. package/lib/utils/getUpdateOracleTx.d.ts +0 -1
  181. package/lib/utils/getUpdateOracleTx.js +0 -64
  182. package/lib/utils/getUpdateTimeOracleTx.d.ts +0 -1
  183. package/lib/utils/getUpdateTimeOracleTx.js +0 -60
  184. package/lib/utils/getUsersShares.d.ts +0 -9
  185. package/lib/utils/getUsersShares.js +0 -148
  186. package/lib/utils/getVaultIndexInRegistry.d.ts +0 -1
  187. package/lib/utils/getVaultIndexInRegistry.js +0 -61
  188. package/lib/utils/isObjAvailable.d.ts +0 -0
  189. package/lib/utils/isObjAvailable.js +0 -14
  190. package/lib/utils/loadUsersDepositData.d.ts +0 -8
  191. package/lib/utils/loadUsersDepositData.js +0 -160
  192. package/lib/utils/portfolio/authorized/getAuthorizedEvolutionTx.d.ts +0 -1
  193. package/lib/utils/portfolio/authorized/getAuthorizedLastEvolutionTx.d.ts +0 -1
  194. package/lib/utils/portfolio/authorized/getAuthorizedUpdateNextVaultConfigTx.d.ts +0 -4
  195. package/lib/utils/portfolio/authorized/getAuthorizedUpdateVaultConfigTx.d.ts +0 -1
  196. package/lib/utils/portfolio/authorized/getAuthorizedUpdateVaultConfigTx.js +0 -64
  197. package/lib/utils/portfolio/manager/getLastEvolutionTx.d.ts +0 -1
  198. package/lib/utils/portfolio/manager/getUpdateNextVaultConfigTx.d.ts +0 -4
  199. package/lib/utils/portfolio/manager/getUpdateNextVaultConfigTx.js +0 -71
  200. package/lib/utils/portfolio/manager/getUpdateVaultConfigTx.d.ts +0 -1
  201. package/lib/utils/portfolio/user/getCompoundPremiumTx.d.ts +0 -1
  202. package/lib/utils/portfolio/user/getCompoundPremiumTx.js +0 -60
  203. /package/lib/test/{getMakersShares.d.ts → authorized/testAuthorizedNewPortfolioVault.d.ts} +0 -0
  204. /package/lib/test/{getUsersShares.d.ts → authorized/testAuthorizedUpdateUpcomingVaultConfig.d.ts} +0 -0
  205. /package/lib/test/{testClaim.d.ts → authorized/testAuthorizedUpdateWarmupVaultConfig.d.ts} +0 -0
  206. /package/lib/test/{testDeposit.d.ts → helper/getAuctionMaxSize.d.ts} +0 -0
  207. /package/lib/test/{testNewAuction.d.ts → helper/getUserStatus.d.ts} +0 -0
  208. /package/lib/test/{testNewVault.d.ts → user/testClaim.d.ts} +0 -0
  209. /package/lib/test/{testOracle.d.ts → user/testCompound.d.ts} +0 -0
  210. /package/lib/test/{testSettle.d.ts → user/testDeposit.d.ts} +0 -0
  211. /package/lib/test/{testUnsubscribe.d.ts → user/testHarvest.d.ts} +0 -0
  212. /package/lib/test/{testWithdraw.d.ts → user/testNewBid.d.ts} +0 -0
@@ -1,64 +0,0 @@
1
- "use strict";
2
- // import { getNewSharkFinVaultTx } from "../utils/getNewSharkFinVaultTx"
3
- // import { getDepositTx } from "../utils/coveredCall/getDepositTx"
4
- // import { SHARKFIN_PACKAGE, SHARKFIN_REGISTRY, TEST_MNEMONIC, TOKEN_REGISTRY } from "../constants"
5
- // import { JsonRpcProvider, Ed25519Keypair, RawSigner, Network } from '@mysten/sui.js';
6
- // import { expect } from 'chai';
7
- // import * as assert from "assert";
8
- // const provider = new JsonRpcProvider(TESTNET_RPC_ENDPOINT);//for read only operations
9
- // const keypair = Ed25519Keypair.deriveKeypair(TEST_MNEMONIC);
10
- // const signer = new RawSigner(keypair, provider);
11
- // /*
12
- // after deposit, token object balance will decrease, and new vault "deposit" in fields will increase
13
- // */
14
- // describe('deposit', async () => {
15
- // //init
16
- // let depositAmount = 123;
17
- // let typeArgument = "0x27b3674c685046f66cad1d5496d2967894fa5329::token::USDC" //0x27b3674c685046f66cad1d5496d2967894fa5329:TOKEN_PACKAGE
18
- // let expiration = 1671344789
19
- // let bullish = true
20
- // let lowBarrierPrice = 1
21
- // let highBarrierPrice = 10
22
- // let isRolling = true;
23
- // let token = "0xdb85a3efc1706010fa9530ef3b8a8a5cf4b290b7"
24
- // console.log("test for deposit, try to deposit " + token + " for " + depositAmount + " ...")
25
- // it('Check registry', async () => {
26
- // try {
27
- // await provider.getObject(SHARKFIN_REGISTRY)
28
- // assert.ok("Get registry successfully");
29
- // } catch (e) {
30
- // assert.fail("Wrong registry")
31
- // }
32
- // })
33
- // it('Create new vault in registry', async () => {
34
- // try {
35
- // let newSharkFinVaultTx: any = await getNewSharkFinVaultTx(
36
- // gasBudget: number, SHARKFIN_PACKAGE, SHARKFIN_REGISTRY, typeArgument, expiration, bullish, lowBarrierPrice, highBarrierPrice);
37
- // let moveCallTxn = await signer.executeMoveCall(newSharkFinVaultTx);
38
- // console.log(moveCallTxn)
39
- // assert.ok("Create new vault in registry successfully");
40
- // } catch (e) {
41
- // assert.fail("Can't create new vault in registry")
42
- // }
43
- // })
44
- // it('Check vault number after create new vault', async () => {
45
- // try {
46
- // let registry = await provider.getObject(SHARKFIN_REGISTRY)
47
- // //@ts-ignore
48
- // let numOfVaultBeforeCreateVault = registry.details.data.fields.num_of_vault
49
- // // console.log("numOfVaultBeforeCreateVault: " + numOfVaultBeforeCreateVault)
50
- // let newSharkFinVaultTx: any = await getNewSharkFinVaultTx(
51
- // gasBudget: number, SHARKFIN_PACKAGE, SHARKFIN_REGISTRY, typeArgument, expiration, bullish, lowBarrierPrice, highBarrierPrice);
52
- // await signer.executeMoveCall(newSharkFinVaultTx);
53
- // registry = await provider.getObject(SHARKFIN_REGISTRY)
54
- // //@ts-ignore
55
- // let numOfVaultAfterCreateVault = registry.details.data.fields.num_of_vault
56
- // // console.log("numOfVaultAfterCreateVault: " + numOfVaultAfterCreateVault)
57
- // assert.ok(numOfVaultAfterCreateVault == numOfVaultBeforeCreateVault + 1, "wrong vault number");
58
- // } catch (e) {
59
- // assert.fail("Error in check vault number after create new vault")
60
- // }
61
- // })
62
- // it('Deposit to new vault', async () => {
63
- // })
64
- // })
@@ -1,94 +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 (g && (g = 0, op[0] && (_ = 0)), _) 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 __read = (this && this.__read) || function (o, n) {
39
- var m = typeof Symbol === "function" && o[Symbol.iterator];
40
- if (!m) return o;
41
- var i = m.call(o), r, ar = [], e;
42
- try {
43
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
44
- }
45
- catch (error) { e = { error: error }; }
46
- finally {
47
- try {
48
- if (r && !r.done && (m = i["return"])) m.call(i);
49
- }
50
- finally { if (e) throw e.error; }
51
- }
52
- return ar;
53
- };
54
- Object.defineProperty(exports, "__esModule", { value: true });
55
- var getNewAuctionTx_1 = require("../utils/coveredCall/getNewAuctionTx");
56
- var constants_1 = require("../constants");
57
- var getTypeArgumentFromToken_1 = require("../utils/getTypeArgumentFromToken");
58
- var sui_js_1 = require("@mysten/sui.js");
59
- var createPriceOracle_1 = require("../utils/coveredCall/createPriceOracle");
60
- var createTimeOracle_1 = require("../utils/coveredCall/createTimeOracle");
61
- var provider = new sui_js_1.JsonRpcProvider(constants_1.TESTNET_RPC_ENDPOINT); //for read only operations
62
- var keypair = sui_js_1.Ed25519Keypair.deriveKeypair(constants_1.TEST_MNEMONIC);
63
- var signer = new sui_js_1.RawSigner(keypair, provider);
64
- (function () { return __awaiter(void 0, void 0, void 0, function () {
65
- var token, typeArgument, vaultIndex, _a, priceOracle, priceOracleManager, _b, timeOracle, timeOracleManager, activationTsMs, expirationTsMs, gasBudget, newAuctionTx, a;
66
- return __generator(this, function (_c) {
67
- switch (_c.label) {
68
- case 0:
69
- token = constants_1.TEST_MINT_TOKEN // minted token
70
- ;
71
- return [4 /*yield*/, (0, getTypeArgumentFromToken_1.getTypeArgumentFromToken)(token, provider)];
72
- case 1:
73
- typeArgument = _c.sent();
74
- vaultIndex = 0;
75
- return [4 /*yield*/, (0, createPriceOracle_1.createPriceOracle)(typeArgument)];
76
- case 2:
77
- _a = __read.apply(void 0, [_c.sent(), 2]), priceOracle = _a[0], priceOracleManager = _a[1];
78
- return [4 /*yield*/, (0, createTimeOracle_1.createTimeOracle)()];
79
- case 3:
80
- _b = __read.apply(void 0, [_c.sent(), 2]), timeOracle = _b[0], timeOracleManager = _b[1];
81
- activationTsMs = 1671992000000;
82
- expirationTsMs = 1;
83
- gasBudget = 100000;
84
- return [4 /*yield*/, (0, getNewAuctionTx_1.getNewAuctionTx)(gasBudget, constants_1.COVERED_CALL_PACKAGE, constants_1.COVERED_CALL_REGISTRY, typeArgument, constants_1.COVERED_CALL_MANAGER, vaultIndex.toString(), priceOracle, timeOracle)];
85
- case 4:
86
- newAuctionTx = _c.sent();
87
- return [4 /*yield*/, signer.executeMoveCall(newAuctionTx)];
88
- case 5:
89
- a = _c.sent();
90
- console.log(a);
91
- return [2 /*return*/];
92
- }
93
- });
94
- }); })();
@@ -1,153 +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 (g && (g = 0, op[0] && (_ = 0)), _) 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 __read = (this && this.__read) || function (o, n) {
39
- var m = typeof Symbol === "function" && o[Symbol.iterator];
40
- if (!m) return o;
41
- var i = m.call(o), r, ar = [], e;
42
- try {
43
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
44
- }
45
- catch (error) { e = { error: error }; }
46
- finally {
47
- try {
48
- if (r && !r.done && (m = i["return"])) m.call(i);
49
- }
50
- finally { if (e) throw e.error; }
51
- }
52
- return ar;
53
- };
54
- var __values = (this && this.__values) || function(o) {
55
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
56
- if (m) return m.call(o);
57
- if (o && typeof o.length === "number") return {
58
- next: function () {
59
- if (o && i >= o.length) o = void 0;
60
- return { value: o && o[i++], done: !o };
61
- }
62
- };
63
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
64
- };
65
- Object.defineProperty(exports, "__esModule", { value: true });
66
- var getNewCoveredCallVaultTx_1 = require("../utils/coveredCall/getNewCoveredCallVaultTx");
67
- var createTimeOracle_1 = require("../utils/coveredCall/createTimeOracle");
68
- var constants_1 = require("../constants");
69
- var sui_js_1 = require("@mysten/sui.js");
70
- var getTypeArgumentFromToken_1 = require("../utils/getTypeArgumentFromToken");
71
- var provider = new sui_js_1.JsonRpcProvider(constants_1.TESTNET_RPC_ENDPOINT); //for read only operations
72
- var keypair = sui_js_1.Ed25519Keypair.deriveKeypair(constants_1.TEST_MNEMONIC);
73
- var signer = new sui_js_1.RawSigner(keypair, provider);
74
- var token = constants_1.TEST_MINT_TOKEN; // minted token
75
- var tokenDecimal = "9";
76
- var shareDecimal = "4";
77
- var period = "1";
78
- var activationTsMs = "1671782400000";
79
- var expirationTsMs = 1671782400000 + 604800000;
80
- var capacity = "1000000000";
81
- var strikeOtmPct = "500";
82
- var strikeIncrement = "10000";
83
- var decaySpeed = "1";
84
- var initialPrice = "5000";
85
- var finalPrice = "1000";
86
- var auctionDurationInMs = "3600000";
87
- var prevBalance = 0;
88
- var leverage = "100";
89
- (function () { return __awaiter(void 0, void 0, void 0, function () {
90
- var typeArgument, _a, timeOracle, _, gasBudget, newCoveredCallVaultTx, moveCallTxn;
91
- return __generator(this, function (_b) {
92
- switch (_b.label) {
93
- case 0: return [4 /*yield*/, (0, getTypeArgumentFromToken_1.getTypeArgumentFromToken)(token, provider)
94
- // let priceOracle: string = await createAndUpdatePriceOracle(typeArgument)
95
- ];
96
- case 1:
97
- typeArgument = _b.sent();
98
- return [4 /*yield*/, (0, createTimeOracle_1.createTimeOracle)()];
99
- case 2:
100
- _a = __read.apply(void 0, [_b.sent(), 2]), timeOracle = _a[0], _ = _a[1];
101
- console.log(typeArgument, timeOracle);
102
- gasBudget = 100000;
103
- return [4 /*yield*/, (0, getNewCoveredCallVaultTx_1.getNewCoveredCallVaultTx)(gasBudget, constants_1.COVERED_CALL_PACKAGE, constants_1.COVERED_CALL_REGISTRY, typeArgument, constants_1.COVERED_CALL_MANAGER, timeOracle, period, activationTsMs, expirationTsMs.toString(), tokenDecimal, shareDecimal, capacity, strikeOtmPct, strikeIncrement, decaySpeed, initialPrice, finalPrice, auctionDurationInMs, [], leverage)];
104
- case 3:
105
- newCoveredCallVaultTx = _b.sent();
106
- return [4 /*yield*/, signer.executeMoveCall(newCoveredCallVaultTx)];
107
- case 4:
108
- moveCallTxn = _b.sent();
109
- return [4 /*yield*/, checkData(moveCallTxn)];
110
- case 5:
111
- _b.sent();
112
- return [2 /*return*/];
113
- }
114
- });
115
- }); })();
116
- function checkData(moveCallTxn) {
117
- return __awaiter(this, void 0, void 0, function () {
118
- var txn, _a, _b, obj, e_1;
119
- var e_2, _c;
120
- return __generator(this, function (_d) {
121
- switch (_d.label) {
122
- case 0:
123
- _d.trys.push([0, 2, , 3]);
124
- return [4 /*yield*/, provider.getTransactionWithEffects(
125
- //@ts-ignore
126
- moveCallTxn.EffectsCert.certificate.transactionDigest)];
127
- case 1:
128
- txn = _d.sent();
129
- try {
130
- for (_a = __values(txn.effects.created), _b = _a.next(); !_b.done; _b = _a.next()) {
131
- obj = _b.value;
132
- //@ts-ignore
133
- if (obj.owner.ObjectOwner == constants_1.COVERED_CALL_REGISTRY)
134
- console.log("new covered call vault: " + obj.reference.objectId);
135
- }
136
- }
137
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
138
- finally {
139
- try {
140
- if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
141
- }
142
- finally { if (e_2) throw e_2.error; }
143
- }
144
- return [3 /*break*/, 3];
145
- case 2:
146
- e_1 = _d.sent();
147
- console.error(e_1);
148
- return [3 /*break*/, 3];
149
- case 3: return [2 /*return*/];
150
- }
151
- });
152
- });
153
- }
@@ -1,94 +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 (g && (g = 0, op[0] && (_ = 0)), _) 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 getUpdateOracleTx_1 = require("../utils/getUpdateOracleTx");
40
- var getNewOracleTx_1 = require("../utils/getNewOracleTx");
41
- var constants_1 = require("../constants");
42
- var sui_js_1 = require("@mysten/sui.js");
43
- var provider = new sui_js_1.JsonRpcProvider(constants_1.TESTNET_RPC_ENDPOINT); //for read only operations
44
- var keypair = sui_js_1.Ed25519Keypair.deriveKeypair(constants_1.TEST_MNEMONIC);
45
- var signer = new sui_js_1.RawSigner(keypair, provider);
46
- (function () { return __awaiter(void 0, void 0, void 0, function () {
47
- var price, unix, decimal, gasBudget, newOracleTx, moveCallTxn, digest, txn, newOracle, managerCap, updateOracleTx, newOracleObj;
48
- return __generator(this, function (_a) {
49
- switch (_a.label) {
50
- case 0:
51
- price = 1234;
52
- unix = 5678;
53
- decimal = 8;
54
- console.log("create new oracle...");
55
- gasBudget = 100000;
56
- return [4 /*yield*/, (0, getNewOracleTx_1.getNewOracleTx)(gasBudget, constants_1.ORACLE_PACKAGE, constants_1.DEFAULT_TYPE_ARGUMENT, decimal)];
57
- case 1:
58
- newOracleTx = _a.sent();
59
- return [4 /*yield*/, signer.executeMoveCall(newOracleTx)];
60
- case 2:
61
- moveCallTxn = _a.sent();
62
- digest = moveCallTxn.EffectsCert.certificate.transactionDigest;
63
- return [4 /*yield*/, provider.getTransactionWithEffects(digest)];
64
- case 3:
65
- txn = _a.sent();
66
- if (txn.effects.created[0].owner["AddressOwner"] == undefined) {
67
- newOracle = txn.effects.created[0].reference.objectId;
68
- managerCap = txn.effects.created[1].reference.objectId;
69
- }
70
- else {
71
- newOracle = txn.effects.created[1].reference.objectId;
72
- managerCap = txn.effects.created[0].reference.objectId;
73
- }
74
- console.log("update oracle...");
75
- return [4 /*yield*/, (0, getUpdateOracleTx_1.getUpdateOracleTx)(gasBudget, constants_1.ORACLE_PACKAGE, constants_1.DEFAULT_TYPE_ARGUMENT, newOracle, managerCap, price, unix)];
76
- case 4:
77
- updateOracleTx = _a.sent();
78
- return [4 /*yield*/, signer.executeMoveCall(updateOracleTx)];
79
- case 5:
80
- moveCallTxn = _a.sent();
81
- return [4 /*yield*/, provider.getObject(newOracle)];
82
- case 6:
83
- newOracleObj = _a.sent();
84
- if (newOracleObj.status != "Exists") {
85
- console.log("obj not exists");
86
- return [2 /*return*/];
87
- }
88
- console.log("updated oracle:");
89
- //@ts-ignore
90
- console.log(newOracleObj.details.data.fields);
91
- return [2 /*return*/];
92
- }
93
- });
94
- }); })();