@typus/typus-sdk 0.6.2 → 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.
- package/lib/config.json +20 -0
- package/lib/constants.d.ts +12 -16
- package/lib/constants.js +17 -17
- package/lib/test/authorized/testAuthorizedNewPortfolioVault.js +82 -0
- package/lib/test/{testClaim.js → authorized/testAuthorizedUpdateUpcomingVaultConfig.js} +20 -31
- package/lib/test/authorized/testAuthorizedUpdateWarmupVaultConfig.js +68 -0
- package/lib/test/getBidData.js +1 -1
- package/lib/test/getVaultData.js +2 -2
- package/lib/test/getWhiteListFromRegistry.js +2 -2
- package/lib/test/helper/getAuctionMaxSize.js +76 -0
- package/lib/test/helper/getUserStatus.js +75 -0
- package/lib/test/testCrypto.js +1 -1
- package/lib/test/testMint.js +2 -2
- package/lib/test/testSubscribeEvent.js +1 -1
- package/lib/test/{testWithdraw.js → user/testClaim.js} +15 -18
- package/lib/test/{getMakersShares.js → user/testCompound.js} +21 -7
- package/lib/test/{testUnsubscribe.js → user/testDeposit.js} +29 -38
- package/lib/test/{getUsersShares.js → user/testHarvest.js} +21 -7
- package/lib/test/user/testNewBid.js +77 -0
- package/lib/test/user/testUnsubscribe.d.ts +1 -0
- package/lib/test/user/testUnsubscribe.js +69 -0
- package/lib/test/user/testWithdraw.d.ts +1 -0
- package/lib/test/{testDeposit.js → user/testWithdraw.js} +16 -20
- package/lib/utils/auction/getBid.js +1 -1
- package/lib/utils/fetchData.d.ts +72 -60
- package/lib/utils/fetchData.js +27 -199
- package/lib/utils/getMintTx.js +1 -1
- package/lib/utils/getTypeArgumentFromToken.js +1 -1
- package/lib/utils/getVaultData.d.ts +3 -2
- package/lib/utils/getVaultData.js +139 -159
- package/lib/utils/getWhiteListFromRegistry.js +1 -2
- package/lib/utils/portfolio/authorized/getAuthorizedAddPortfolioVaultAuthorizedUserTx.d.ts +4 -0
- package/lib/utils/portfolio/authorized/getAuthorizedAddPortfolioVaultAuthorizedUserTx.js +63 -0
- package/lib/utils/portfolio/authorized/getAuthorizedDeliveryTx.d.ts +1 -0
- package/lib/utils/{authorized → portfolio/authorized}/getAuthorizedDeliveryTx.js +10 -5
- package/lib/utils/portfolio/authorized/getAuthorizedNewPortfolioVaultTx.d.ts +38 -0
- package/lib/utils/{authorized/getAuthorizedNewCoveredCallVaultTx.js → portfolio/authorized/getAuthorizedNewPortfolioVaultTx.js} +53 -13
- package/lib/utils/portfolio/authorized/getAuthorizedRemovePortfolioVaultAuthorizedUserTx.d.ts +4 -0
- package/lib/utils/portfolio/authorized/getAuthorizedRemovePortfolioVaultAuthorizedUserTx.js +63 -0
- package/lib/utils/portfolio/authorized/getAuthorizedUpdateCapacityTx.d.ts +1 -0
- package/lib/utils/{authorized → portfolio/authorized}/getAuthorizedUpdateCapacityTx.js +9 -5
- package/lib/utils/portfolio/authorized/getAuthorizedUpdateUpcomingVaultConfigTx.d.ts +4 -0
- package/lib/utils/{authorized/getAuthorizedUpdateVaultConfigTx.js → portfolio/authorized/getAuthorizedUpdateUpcomingVaultConfigTx.js} +13 -7
- package/lib/utils/portfolio/authorized/getAuthorizedUpdateWarmupVaultConfigTx.d.ts +1 -0
- package/lib/utils/{authorized/getAuthorizedUpdateNextVaultConfigTx.js → portfolio/authorized/getAuthorizedUpdateWarmupVaultConfigTx.js} +7 -8
- package/lib/utils/portfolio/helper/getAuctionMaxSize.d.ts +8 -0
- package/lib/utils/{coveredCall/getLastEvolutionTx.js → portfolio/helper/getAuctionMaxSize.js} +14 -11
- package/lib/utils/portfolio/helper/getUserStatus.d.ts +29 -0
- package/lib/utils/portfolio/helper/getUserStatus.js +104 -0
- package/lib/utils/portfolio/manager/getAddAuthorizedUserTx.d.ts +8 -0
- package/lib/utils/{getUpdateTimeOracleTx.js → portfolio/manager/getAddAuthorizedUserTx.js} +15 -8
- package/lib/utils/portfolio/manager/getAddPortfolioVaultAuthorizedUserTx.d.ts +10 -0
- package/lib/utils/{coveredCall/getUpdateNextVaultConfigTx.js → portfolio/manager/getAddPortfolioVaultAuthorizedUserTx.js} +17 -13
- package/lib/utils/portfolio/manager/getCloseAuctionTx.d.ts +1 -0
- package/lib/utils/{coveredCall → portfolio/manager}/getCloseAuctionTx.js +6 -5
- package/lib/utils/portfolio/manager/getCloseVaultTx.d.ts +1 -0
- package/lib/utils/{coveredCall → portfolio/manager}/getCloseVaultTx.js +4 -4
- package/lib/utils/portfolio/manager/getDeliveryTx.d.ts +1 -0
- package/lib/utils/{coveredCall → portfolio/manager}/getDeliveryTx.js +5 -4
- package/lib/utils/portfolio/manager/getEvolutionTx.d.ts +15 -0
- package/lib/utils/{coveredCall → portfolio/manager}/getEvolutionTx.js +18 -4
- package/lib/utils/portfolio/manager/getNewManagerTx.d.ts +8 -0
- package/lib/utils/{coveredCall → portfolio/manager}/getNewManagerTx.js +11 -4
- package/lib/utils/portfolio/manager/getNewPortfolioVaultTx.d.ts +38 -0
- package/lib/utils/{coveredCall/getNewCoveredCallVaultTx.js → portfolio/manager/getNewPortfolioVaultTx.js} +52 -13
- package/lib/utils/portfolio/manager/getRemoveAuthorizedUserTx.d.ts +8 -0
- package/lib/utils/{coveredCall/getRemoveCoveredCallVaultAuthorizedUserTx.js → portfolio/manager/getRemoveAuthorizedUserTx.js} +14 -8
- package/lib/utils/{coveredCall → portfolio/manager}/getRemoveManagerTx.d.ts +5 -0
- package/lib/utils/{coveredCall → portfolio/manager}/getRemoveManagerTx.js +7 -2
- package/lib/utils/portfolio/manager/getRemovePortfolioVaultAuthorizedUserTx.d.ts +10 -0
- package/lib/utils/portfolio/manager/getRemovePortfolioVaultAuthorizedUserTx.js +70 -0
- package/lib/utils/portfolio/manager/getUpdateCapacityTx.d.ts +1 -0
- package/lib/utils/{coveredCall → portfolio/manager}/getUpdateCapacityTx.js +4 -4
- package/lib/utils/portfolio/user/getClaimAndHarvestTx.d.ts +9 -0
- package/lib/utils/portfolio/user/getClaimAndHarvestTx.js +67 -0
- package/lib/utils/portfolio/user/getClaimTx.d.ts +9 -0
- package/lib/utils/{coveredCall → portfolio/user}/getClaimTx.js +12 -4
- package/lib/utils/portfolio/user/getCompoundTx.d.ts +9 -0
- package/lib/utils/{coveredCall/getAddCoveredCallVaultAuthorizedUserTx.js → portfolio/user/getCompoundTx.js} +15 -9
- package/lib/utils/portfolio/user/getDepositTx.d.ts +11 -0
- package/lib/utils/{coveredCall → portfolio/user}/getDepositTx.js +15 -9
- package/lib/utils/portfolio/user/getHarvestTx.d.ts +9 -0
- package/lib/utils/{coveredCall/getClaimAllTx.js → portfolio/user/getHarvestTx.js} +15 -7
- package/lib/utils/portfolio/user/getNewBidTx.d.ts +13 -0
- package/lib/utils/{coveredCall → portfolio/user}/getNewBidTx.js +21 -8
- package/lib/utils/portfolio/user/getUnsubscribeTx.d.ts +10 -0
- package/lib/utils/{coveredCall → portfolio/user}/getUnsubscribeTx.js +14 -8
- package/lib/utils/portfolio/user/getWithdrawTx.d.ts +10 -0
- package/lib/utils/{coveredCall → portfolio/user}/getWithdrawTx.js +13 -4
- package/package.json +2 -2
- package/lib/test/eventListener.d.ts +0 -5
- package/lib/test/eventListener.js +0 -395
- package/lib/test/testDepositV2.d.ts +0 -0
- package/lib/test/testDepositV2.js +0 -64
- package/lib/test/testNewAuction.js +0 -94
- package/lib/test/testNewVault.js +0 -153
- package/lib/test/testOracle.js +0 -94
- package/lib/test/testSettle.js +0 -590
- package/lib/utils/authorized/getAuthorizedAddAuthorizedUserTx.d.ts +0 -1
- package/lib/utils/authorized/getAuthorizedAddAuthorizedUserTx.js +0 -56
- package/lib/utils/authorized/getAuthorizedAddCoveredCallVaultAuthorizedUserTx.d.ts +0 -1
- package/lib/utils/authorized/getAuthorizedAddCoveredCallVaultAuthorizedUserTx.js +0 -56
- package/lib/utils/authorized/getAuthorizedDeliveryTx.d.ts +0 -1
- package/lib/utils/authorized/getAuthorizedEvolutionTx.d.ts +0 -1
- package/lib/utils/authorized/getAuthorizedEvolutionTx.js +0 -56
- package/lib/utils/authorized/getAuthorizedLastEvolutionTx.d.ts +0 -1
- package/lib/utils/authorized/getAuthorizedLastEvolutionTx.js +0 -56
- package/lib/utils/authorized/getAuthorizedNewAuctionTx.d.ts +0 -1
- package/lib/utils/authorized/getAuthorizedNewAuctionTx.js +0 -56
- package/lib/utils/authorized/getAuthorizedNewCoveredCallVaultTx.d.ts +0 -1
- package/lib/utils/authorized/getAuthorizedRemoveAuthorizedUserTx.d.ts +0 -1
- package/lib/utils/authorized/getAuthorizedRemoveAuthorizedUserTx.js +0 -56
- package/lib/utils/authorized/getAuthorizedRemoveCoveredCallVaultAuthorizedUserTx.d.ts +0 -1
- package/lib/utils/authorized/getAuthorizedRemoveCoveredCallVaultAuthorizedUserTx.js +0 -56
- package/lib/utils/authorized/getAuthorizedSettleTx.d.ts +0 -1
- package/lib/utils/authorized/getAuthorizedSettleTx.js +0 -56
- package/lib/utils/authorized/getAuthorizedUpdateCapacityTx.d.ts +0 -1
- package/lib/utils/authorized/getAuthorizedUpdateNextVaultConfigTx.d.ts +0 -1
- package/lib/utils/authorized/getAuthorizedUpdateVaultConfigTx.d.ts +0 -1
- package/lib/utils/coveredCall/createPriceOracle.d.ts +0 -1
- package/lib/utils/coveredCall/createPriceOracle.js +0 -93
- package/lib/utils/coveredCall/createTimeOracle.d.ts +0 -1
- package/lib/utils/coveredCall/createTimeOracle.js +0 -92
- package/lib/utils/coveredCall/getAddCoveredCallVaultAuthorizedUserTx.d.ts +0 -1
- package/lib/utils/coveredCall/getClaimAllTx.d.ts +0 -1
- package/lib/utils/coveredCall/getClaimTx.d.ts +0 -1
- package/lib/utils/coveredCall/getCloseAuctionTx.d.ts +0 -1
- package/lib/utils/coveredCall/getCloseVaultTx.d.ts +0 -1
- package/lib/utils/coveredCall/getDeliveryTx.d.ts +0 -1
- package/lib/utils/coveredCall/getDepositTx.d.ts +0 -1
- package/lib/utils/coveredCall/getEvolutionTx.d.ts +0 -1
- package/lib/utils/coveredCall/getLastEvolutionTx.d.ts +0 -1
- package/lib/utils/coveredCall/getMakerClaimAllTx.d.ts +0 -1
- package/lib/utils/coveredCall/getMakerClaimAllTx.js +0 -59
- package/lib/utils/coveredCall/getMakerClaimTx.d.ts +0 -1
- package/lib/utils/coveredCall/getMakerClaimTx.js +0 -59
- package/lib/utils/coveredCall/getNewAuctionTx.d.ts +0 -1
- package/lib/utils/coveredCall/getNewAuctionTx.js +0 -66
- package/lib/utils/coveredCall/getNewAuctionWithNextCoveredCallVaultTx.d.ts +0 -1
- package/lib/utils/coveredCall/getNewAuctionWithNextCoveredCallVaultTx.js +0 -64
- package/lib/utils/coveredCall/getNewBidTx.d.ts +0 -1
- package/lib/utils/coveredCall/getNewCoveredCallVaultTx.d.ts +0 -1
- package/lib/utils/coveredCall/getNewManagerTx.d.ts +0 -1
- package/lib/utils/coveredCall/getRefundTx.d.ts +0 -1
- package/lib/utils/coveredCall/getRefundTx.js +0 -59
- package/lib/utils/coveredCall/getRemoveBidTx.d.ts +0 -1
- package/lib/utils/coveredCall/getRemoveBidTx.js +0 -60
- package/lib/utils/coveredCall/getRemoveCoveredCallVaultAuthorizedUserTx.d.ts +0 -1
- package/lib/utils/coveredCall/getRollOverTx.d.ts +0 -1
- package/lib/utils/coveredCall/getRollOverTx.js +0 -60
- package/lib/utils/coveredCall/getSettleTx.d.ts +0 -1
- package/lib/utils/coveredCall/getSettleTx.js +0 -62
- package/lib/utils/coveredCall/getSettleWithRollOverTx.d.ts +0 -1
- package/lib/utils/coveredCall/getSettleWithRollOverTx.js +0 -62
- package/lib/utils/coveredCall/getSubscribeTx.d.ts +0 -1
- package/lib/utils/coveredCall/getSubscribeTx.js +0 -60
- package/lib/utils/coveredCall/getUnsubscribeTx.d.ts +0 -1
- package/lib/utils/coveredCall/getUpdateCapacityTx.d.ts +0 -1
- package/lib/utils/coveredCall/getUpdateNextVaultConfigTx.d.ts +0 -1
- package/lib/utils/coveredCall/getUpdatePayoffConfigTx.d.ts +0 -1
- package/lib/utils/coveredCall/getUpdatePayoffConfigTx.js +0 -62
- package/lib/utils/coveredCall/getUpdateVaultConfigTx.d.ts +0 -1
- package/lib/utils/coveredCall/getUpdateVaultConfigTx.js +0 -65
- package/lib/utils/coveredCall/getWithdrawTx.d.ts +0 -1
- package/lib/utils/getCreateTokenRegistryTx.d.ts +0 -1
- package/lib/utils/getCreateTokenRegistryTx.js +0 -59
- package/lib/utils/getMakersShares.d.ts +0 -8
- package/lib/utils/getMakersShares.js +0 -145
- package/lib/utils/getNewOracleTx.d.ts +0 -1
- package/lib/utils/getNewOracleTx.js +0 -59
- package/lib/utils/getNewTimeOracleTx.d.ts +0 -1
- package/lib/utils/getNewTimeOracleTx.js +0 -56
- package/lib/utils/getUpdateOracleTx.d.ts +0 -1
- package/lib/utils/getUpdateOracleTx.js +0 -64
- package/lib/utils/getUpdateTimeOracleTx.d.ts +0 -1
- package/lib/utils/getUsersShares.d.ts +0 -9
- package/lib/utils/getUsersShares.js +0 -148
- package/lib/utils/getVaultIndexInRegistry.d.ts +0 -1
- package/lib/utils/getVaultIndexInRegistry.js +0 -61
- package/lib/utils/isObjAvailable.d.ts +0 -0
- package/lib/utils/isObjAvailable.js +0 -14
- package/lib/utils/loadUsersDepositData.d.ts +0 -8
- package/lib/utils/loadUsersDepositData.js +0 -157
- /package/lib/test/{getMakersShares.d.ts → authorized/testAuthorizedNewPortfolioVault.d.ts} +0 -0
- /package/lib/test/{getUsersShares.d.ts → authorized/testAuthorizedUpdateUpcomingVaultConfig.d.ts} +0 -0
- /package/lib/test/{testClaim.d.ts → authorized/testAuthorizedUpdateWarmupVaultConfig.d.ts} +0 -0
- /package/lib/test/{testDeposit.d.ts → helper/getAuctionMaxSize.d.ts} +0 -0
- /package/lib/test/{testNewAuction.d.ts → helper/getUserStatus.d.ts} +0 -0
- /package/lib/test/{testNewVault.d.ts → user/testClaim.d.ts} +0 -0
- /package/lib/test/{testOracle.d.ts → user/testCompound.d.ts} +0 -0
- /package/lib/test/{testSettle.d.ts → user/testDeposit.d.ts} +0 -0
- /package/lib/test/{testUnsubscribe.d.ts → user/testHarvest.d.ts} +0 -0
- /package/lib/test/{testWithdraw.d.ts → user/testNewBid.d.ts} +0 -0
package/lib/test/testSettle.js
DELETED
|
@@ -1,590 +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 __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 getUpdateOracleTx_1 = require("../utils/getUpdateOracleTx");
|
|
67
|
-
var getNewCoveredCallVaultTx_1 = require("../utils/coveredCall/getNewCoveredCallVaultTx");
|
|
68
|
-
var getDepositTx_1 = require("../utils/coveredCall/getDepositTx");
|
|
69
|
-
var createTimeOracle_1 = require("../utils/coveredCall/createTimeOracle");
|
|
70
|
-
var constants_1 = require("../constants");
|
|
71
|
-
var sui_js_1 = require("@mysten/sui.js");
|
|
72
|
-
var getTypeArgumentFromToken_1 = require("../utils/getTypeArgumentFromToken");
|
|
73
|
-
var getUpdateTimeOracleTx_1 = require("../utils/getUpdateTimeOracleTx");
|
|
74
|
-
var getNewAuctionWithNextCoveredCallVaultTx_1 = require("../utils/coveredCall/getNewAuctionWithNextCoveredCallVaultTx");
|
|
75
|
-
var getNewBidTx_1 = require("../utils/coveredCall/getNewBidTx");
|
|
76
|
-
var getDeliveryTx_1 = require("../utils/coveredCall/getDeliveryTx");
|
|
77
|
-
var getUpdatePayoffConfigTx_1 = require("../utils/coveredCall/getUpdatePayoffConfigTx");
|
|
78
|
-
var getSettleTx_1 = require("../utils/coveredCall/getSettleTx");
|
|
79
|
-
var createPriceOracle_1 = require("../utils/coveredCall/createPriceOracle");
|
|
80
|
-
var provider = new sui_js_1.JsonRpcProvider(constants_1.TESTNET_RPC_ENDPOINT); //for read only operations
|
|
81
|
-
var keypair = sui_js_1.Ed25519Keypair.deriveKeypair(constants_1.TEST_MNEMONIC);
|
|
82
|
-
var signer = new sui_js_1.RawSigner(keypair, provider);
|
|
83
|
-
var token = "0x8f306b0fcbcbdee0b3a5e694c06039dfe8ca7f14"; // minted token
|
|
84
|
-
var tokenB = "0xb1bf91e97ea97712903824f2f9f4a29d629e9fab";
|
|
85
|
-
var decimal = 8;
|
|
86
|
-
var strike = 2000;
|
|
87
|
-
var isRolling = true;
|
|
88
|
-
var expirationTsMs1 = 1000000;
|
|
89
|
-
var expirationTsMs2 = 2000000;
|
|
90
|
-
var gasBudget = 100000;
|
|
91
|
-
// let priceOracle = '0x636b4e02991f13720571d0cbbc8b83d80cd14729';
|
|
92
|
-
// let priceOracleManager = '0xd958057a227cdfd2080f4aeda7a16d6fe7135bcc';
|
|
93
|
-
// let timeOracle = '0x2b06a0f8109e394258c288b1d90c8c5a9c3832db';
|
|
94
|
-
// let timeOracleManager = '0xcad2723ff9c95ce423d3614375e2fa73ce9a7c04';
|
|
95
|
-
(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
96
|
-
var typeArgument, _a, priceOracle, priceOracleManager, _b, timeOracle, timeOracleManager, price, ts, tokenDecimal, shareDecimal, period, activationTsMs, expirationTsMs, capacity, strikeOtmPct, strikeIncrement, decaySpeed, initialPrice, finalPrice, auctionDurationInMs, prevBalance, vaultIndex, depositAmount, startAuctionTsMs, endAuctionTsMs, currentTime, bidSize, sellSize, premiumRoi, exposureRatio;
|
|
97
|
-
return __generator(this, function (_c) {
|
|
98
|
-
switch (_c.label) {
|
|
99
|
-
case 0: return [4 /*yield*/, (0, getTypeArgumentFromToken_1.getTypeArgumentFromToken)(token, provider)
|
|
100
|
-
//create price oracle and time oracle
|
|
101
|
-
];
|
|
102
|
-
case 1:
|
|
103
|
-
typeArgument = _c.sent();
|
|
104
|
-
return [4 /*yield*/, (0, createPriceOracle_1.createPriceOracle)(typeArgument)];
|
|
105
|
-
case 2:
|
|
106
|
-
_a = __read.apply(void 0, [_c.sent(), 2]), priceOracle = _a[0], priceOracleManager = _a[1];
|
|
107
|
-
return [4 /*yield*/, (0, createTimeOracle_1.createTimeOracle)()
|
|
108
|
-
// update price oracle and time oracle
|
|
109
|
-
];
|
|
110
|
-
case 3:
|
|
111
|
-
_b = __read.apply(void 0, [_c.sent()
|
|
112
|
-
// update price oracle and time oracle
|
|
113
|
-
, 2]), timeOracle = _b[0], timeOracleManager = _b[1];
|
|
114
|
-
price = 10000000000;
|
|
115
|
-
ts = 0 //ms
|
|
116
|
-
;
|
|
117
|
-
return [4 /*yield*/, updatePriceOracle(priceOracle, priceOracleManager, typeArgument, price, ts)
|
|
118
|
-
// await updateTimeOracle(timeOracle, timeOracleManager, ts)
|
|
119
|
-
//create new vault
|
|
120
|
-
];
|
|
121
|
-
case 4:
|
|
122
|
-
_c.sent();
|
|
123
|
-
tokenDecimal = 9;
|
|
124
|
-
shareDecimal = 4;
|
|
125
|
-
period = 1;
|
|
126
|
-
activationTsMs = 1671782400000;
|
|
127
|
-
expirationTsMs = 1671782400000 + 604800000;
|
|
128
|
-
capacity = 1000000000;
|
|
129
|
-
strikeOtmPct = 500;
|
|
130
|
-
strikeIncrement = 10000;
|
|
131
|
-
decaySpeed = 1;
|
|
132
|
-
initialPrice = 5000;
|
|
133
|
-
finalPrice = 1000;
|
|
134
|
-
auctionDurationInMs = 3600000;
|
|
135
|
-
prevBalance = 0;
|
|
136
|
-
return [4 /*yield*/, createNewVault(constants_1.COVERED_CALL_PACKAGE, constants_1.COVERED_CALL_REGISTRY, typeArgument, constants_1.COVERED_CALL_MANAGER, timeOracle, period, activationTsMs, expirationTsMs, tokenDecimal, shareDecimal, capacity, strikeOtmPct, strikeIncrement, decaySpeed, initialPrice, finalPrice, auctionDurationInMs, prevBalance)];
|
|
137
|
-
case 5:
|
|
138
|
-
_c.sent();
|
|
139
|
-
return [4 /*yield*/, getNewestVaultIndex(constants_1.COVERED_CALL_REGISTRY)];
|
|
140
|
-
case 6:
|
|
141
|
-
vaultIndex = _c.sent();
|
|
142
|
-
depositAmount = 50000000000;
|
|
143
|
-
return [4 /*yield*/, depositToVault(typeArgument, vaultIndex, depositAmount)
|
|
144
|
-
//================================start auction================================
|
|
145
|
-
//update price oracle and time oracle
|
|
146
|
-
];
|
|
147
|
-
case 7:
|
|
148
|
-
_c.sent();
|
|
149
|
-
startAuctionTsMs = expirationTsMs1 - 1000;
|
|
150
|
-
return [4 /*yield*/, updatePriceOracle(priceOracle, priceOracleManager, typeArgument, price, startAuctionTsMs)];
|
|
151
|
-
case 8:
|
|
152
|
-
_c.sent();
|
|
153
|
-
return [4 /*yield*/, updateTimeOracle(timeOracle, timeOracleManager, startAuctionTsMs)
|
|
154
|
-
//new_auction_with_next_covered_call_vault
|
|
155
|
-
];
|
|
156
|
-
case 9:
|
|
157
|
-
_c.sent();
|
|
158
|
-
endAuctionTsMs = startAuctionTsMs + 500;
|
|
159
|
-
decaySpeed = 2;
|
|
160
|
-
initialPrice = 500000000;
|
|
161
|
-
finalPrice = 100000000;
|
|
162
|
-
activationTsMs = 1672992000000;
|
|
163
|
-
expirationTsMs = 1672992000000 + 604800000;
|
|
164
|
-
return [4 /*yield*/, createNewAuctionWithNextCoveredCallVault(typeArgument, vaultIndex, priceOracle, timeOracle, activationTsMs, expirationTsMs)];
|
|
165
|
-
case 10:
|
|
166
|
-
_c.sent();
|
|
167
|
-
currentTime = startAuctionTsMs + 300;
|
|
168
|
-
return [4 /*yield*/, updateTimeOracle(timeOracle, timeOracleManager, currentTime)
|
|
169
|
-
//new bid
|
|
170
|
-
];
|
|
171
|
-
case 11:
|
|
172
|
-
_c.sent();
|
|
173
|
-
bidSize = 50000000000;
|
|
174
|
-
return [4 /*yield*/, newBid(typeArgument, vaultIndex, bidSize, tokenB, timeOracle)
|
|
175
|
-
// //check some data
|
|
176
|
-
// //TODO
|
|
177
|
-
//update time oracle
|
|
178
|
-
];
|
|
179
|
-
case 12:
|
|
180
|
-
_c.sent();
|
|
181
|
-
// //check some data
|
|
182
|
-
// //TODO
|
|
183
|
-
//update time oracle
|
|
184
|
-
return [4 /*yield*/, updateTimeOracle(timeOracle, timeOracleManager, endAuctionTsMs + 1)
|
|
185
|
-
//delivery
|
|
186
|
-
];
|
|
187
|
-
case 13:
|
|
188
|
-
// //check some data
|
|
189
|
-
// //TODO
|
|
190
|
-
//update time oracle
|
|
191
|
-
_c.sent();
|
|
192
|
-
sellSize = 50000000000;
|
|
193
|
-
return [4 /*yield*/, delivery(typeArgument, vaultIndex, sellSize, timeOracle)
|
|
194
|
-
// //================================end auction================================
|
|
195
|
-
//update price oracle and time oracle
|
|
196
|
-
];
|
|
197
|
-
case 14:
|
|
198
|
-
_c.sent();
|
|
199
|
-
// //================================end auction================================
|
|
200
|
-
//update price oracle and time oracle
|
|
201
|
-
return [4 /*yield*/, updatePriceOracle(priceOracle, priceOracleManager, typeArgument, price, endAuctionTsMs)];
|
|
202
|
-
case 15:
|
|
203
|
-
// //================================end auction================================
|
|
204
|
-
//update price oracle and time oracle
|
|
205
|
-
_c.sent();
|
|
206
|
-
return [4 /*yield*/, updateTimeOracle(timeOracle, timeOracleManager, endAuctionTsMs)
|
|
207
|
-
//update payoff config
|
|
208
|
-
];
|
|
209
|
-
case 16:
|
|
210
|
-
_c.sent();
|
|
211
|
-
premiumRoi = 100000;
|
|
212
|
-
exposureRatio = bidSize * (Math.pow(10, decimal)) / depositAmount;
|
|
213
|
-
return [4 /*yield*/, updatePayoffConfig(typeArgument, vaultIndex, price, premiumRoi, exposureRatio)
|
|
214
|
-
//update price oracle and time oracle
|
|
215
|
-
];
|
|
216
|
-
case 17:
|
|
217
|
-
_c.sent();
|
|
218
|
-
//update price oracle and time oracle
|
|
219
|
-
price = 9800000000;
|
|
220
|
-
return [4 /*yield*/, updatePriceOracle(priceOracle, priceOracleManager, typeArgument, price, expirationTsMs1)];
|
|
221
|
-
case 18:
|
|
222
|
-
_c.sent();
|
|
223
|
-
return [4 /*yield*/, updateTimeOracle(timeOracle, timeOracleManager, expirationTsMs1)
|
|
224
|
-
//settle
|
|
225
|
-
];
|
|
226
|
-
case 19:
|
|
227
|
-
_c.sent();
|
|
228
|
-
//settle
|
|
229
|
-
return [4 /*yield*/, settle(typeArgument, vaultIndex, priceOracle, timeOracle)];
|
|
230
|
-
case 20:
|
|
231
|
-
//settle
|
|
232
|
-
_c.sent();
|
|
233
|
-
return [2 /*return*/];
|
|
234
|
-
}
|
|
235
|
-
});
|
|
236
|
-
}); })();
|
|
237
|
-
function updatePriceOracle(priceOracle, priceOracleManager, typeArgument, price, ts) {
|
|
238
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
239
|
-
var _this = this;
|
|
240
|
-
return __generator(this, function (_a) {
|
|
241
|
-
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
242
|
-
var updateOracleTx, e_1;
|
|
243
|
-
return __generator(this, function (_a) {
|
|
244
|
-
switch (_a.label) {
|
|
245
|
-
case 0:
|
|
246
|
-
_a.trys.push([0, 3, , 4]);
|
|
247
|
-
return [4 /*yield*/, (0, getUpdateOracleTx_1.getUpdateOracleTx)(gasBudget, constants_1.ORACLE_PACKAGE, typeArgument, priceOracle, priceOracleManager, price, ts)];
|
|
248
|
-
case 1:
|
|
249
|
-
updateOracleTx = _a.sent();
|
|
250
|
-
return [4 /*yield*/, signer.executeMoveCall(updateOracleTx)];
|
|
251
|
-
case 2:
|
|
252
|
-
_a.sent();
|
|
253
|
-
console.log("update price oracle successfully");
|
|
254
|
-
resolve(null);
|
|
255
|
-
return [3 /*break*/, 4];
|
|
256
|
-
case 3:
|
|
257
|
-
e_1 = _a.sent();
|
|
258
|
-
console.error("err in updatePriceOracle");
|
|
259
|
-
reject();
|
|
260
|
-
return [3 /*break*/, 4];
|
|
261
|
-
case 4: return [2 /*return*/];
|
|
262
|
-
}
|
|
263
|
-
});
|
|
264
|
-
}); }).catch(function (error) {
|
|
265
|
-
console.error(error);
|
|
266
|
-
})];
|
|
267
|
-
});
|
|
268
|
-
});
|
|
269
|
-
}
|
|
270
|
-
function updateTimeOracle(timeOracle, managerCap, ts) {
|
|
271
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
272
|
-
var _this = this;
|
|
273
|
-
return __generator(this, function (_a) {
|
|
274
|
-
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
275
|
-
var updateTimeOracleTx, e_2;
|
|
276
|
-
return __generator(this, function (_a) {
|
|
277
|
-
switch (_a.label) {
|
|
278
|
-
case 0:
|
|
279
|
-
_a.trys.push([0, 3, , 4]);
|
|
280
|
-
return [4 /*yield*/, (0, getUpdateTimeOracleTx_1.getUpdateTimeOracleTx)(gasBudget, constants_1.ORACLE_PACKAGE, timeOracle, managerCap, ts)];
|
|
281
|
-
case 1:
|
|
282
|
-
updateTimeOracleTx = _a.sent();
|
|
283
|
-
return [4 /*yield*/, signer.executeMoveCall(updateTimeOracleTx)];
|
|
284
|
-
case 2:
|
|
285
|
-
_a.sent();
|
|
286
|
-
console.log("update time oracle successfully");
|
|
287
|
-
resolve(null);
|
|
288
|
-
return [3 /*break*/, 4];
|
|
289
|
-
case 3:
|
|
290
|
-
e_2 = _a.sent();
|
|
291
|
-
console.error("err in updateTimeOracle");
|
|
292
|
-
reject();
|
|
293
|
-
return [3 /*break*/, 4];
|
|
294
|
-
case 4: return [2 /*return*/];
|
|
295
|
-
}
|
|
296
|
-
});
|
|
297
|
-
}); }).catch(function (error) {
|
|
298
|
-
console.error(error);
|
|
299
|
-
})];
|
|
300
|
-
});
|
|
301
|
-
});
|
|
302
|
-
}
|
|
303
|
-
function createNewVault(packageId, registry, typeArgument, managerCap, timeOracle, period, activationTsMs, expirationTsMs, tokenDecimal, shareDecimal, capacity, strikeOtmPct, strikeIncrement, decaySpeed, initialPrice, finalPrice, auctionDurationInMs, leverage) {
|
|
304
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
305
|
-
var _this = this;
|
|
306
|
-
return __generator(this, function (_a) {
|
|
307
|
-
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
308
|
-
var newCoveredCallVaultTx, moveCallTxn, e_3;
|
|
309
|
-
return __generator(this, function (_a) {
|
|
310
|
-
switch (_a.label) {
|
|
311
|
-
case 0:
|
|
312
|
-
_a.trys.push([0, 4, , 5]);
|
|
313
|
-
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.toString(), activationTsMs.toString(), expirationTsMs.toString(), tokenDecimal.toString(), shareDecimal.toString(), capacity.toString(), strikeOtmPct.toString(), strikeIncrement.toString(), decaySpeed.toString(), initialPrice.toString(), finalPrice.toString(), auctionDurationInMs.toString(), [], leverage.toString())];
|
|
314
|
-
case 1:
|
|
315
|
-
newCoveredCallVaultTx = _a.sent();
|
|
316
|
-
return [4 /*yield*/, signer.executeMoveCall(newCoveredCallVaultTx)];
|
|
317
|
-
case 2:
|
|
318
|
-
moveCallTxn = _a.sent();
|
|
319
|
-
return [4 /*yield*/, checkData(moveCallTxn)];
|
|
320
|
-
case 3:
|
|
321
|
-
_a.sent();
|
|
322
|
-
console.log("create new vault successfully");
|
|
323
|
-
resolve(null);
|
|
324
|
-
return [3 /*break*/, 5];
|
|
325
|
-
case 4:
|
|
326
|
-
e_3 = _a.sent();
|
|
327
|
-
console.error("err in createNewVault");
|
|
328
|
-
reject();
|
|
329
|
-
return [3 /*break*/, 5];
|
|
330
|
-
case 5: return [2 /*return*/];
|
|
331
|
-
}
|
|
332
|
-
});
|
|
333
|
-
}); }).catch(function (error) {
|
|
334
|
-
console.error(error);
|
|
335
|
-
})];
|
|
336
|
-
});
|
|
337
|
-
});
|
|
338
|
-
}
|
|
339
|
-
function checkData(moveCallTxn) {
|
|
340
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
341
|
-
var txn, _a, _b, obj, e_4;
|
|
342
|
-
var e_5, _c;
|
|
343
|
-
return __generator(this, function (_d) {
|
|
344
|
-
switch (_d.label) {
|
|
345
|
-
case 0:
|
|
346
|
-
_d.trys.push([0, 2, , 3]);
|
|
347
|
-
return [4 /*yield*/, provider.getTransactionWithEffects(
|
|
348
|
-
//@ts-ignore
|
|
349
|
-
moveCallTxn.EffectsCert.certificate.transactionDigest)];
|
|
350
|
-
case 1:
|
|
351
|
-
txn = _d.sent();
|
|
352
|
-
try {
|
|
353
|
-
for (_a = __values(txn.effects.created), _b = _a.next(); !_b.done; _b = _a.next()) {
|
|
354
|
-
obj = _b.value;
|
|
355
|
-
//@ts-ignore
|
|
356
|
-
if (obj.owner.ObjectOwner == constants_1.COVERED_CALL_REGISTRY)
|
|
357
|
-
console.log("new covered call vault: " + obj.reference.objectId);
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
361
|
-
finally {
|
|
362
|
-
try {
|
|
363
|
-
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
364
|
-
}
|
|
365
|
-
finally { if (e_5) throw e_5.error; }
|
|
366
|
-
}
|
|
367
|
-
return [3 /*break*/, 3];
|
|
368
|
-
case 2:
|
|
369
|
-
e_4 = _d.sent();
|
|
370
|
-
console.error(e_4);
|
|
371
|
-
return [3 /*break*/, 3];
|
|
372
|
-
case 3: return [2 /*return*/];
|
|
373
|
-
}
|
|
374
|
-
});
|
|
375
|
-
});
|
|
376
|
-
}
|
|
377
|
-
function getNewestVaultIndex(registry) {
|
|
378
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
379
|
-
var tmp, numOfVault;
|
|
380
|
-
return __generator(this, function (_a) {
|
|
381
|
-
switch (_a.label) {
|
|
382
|
-
case 0: return [4 /*yield*/, provider.getObject(registry)];
|
|
383
|
-
case 1:
|
|
384
|
-
tmp = _a.sent();
|
|
385
|
-
if (tmp.status != "Exists") {
|
|
386
|
-
console.log("obj not exists");
|
|
387
|
-
return [2 /*return*/, -1];
|
|
388
|
-
}
|
|
389
|
-
numOfVault = tmp.details.data.fields.num_of_vault;
|
|
390
|
-
return [2 /*return*/, numOfVault - 1];
|
|
391
|
-
}
|
|
392
|
-
});
|
|
393
|
-
});
|
|
394
|
-
}
|
|
395
|
-
function depositToVault(typeArgument, vaultIndex, depositAmount) {
|
|
396
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
397
|
-
var _this = this;
|
|
398
|
-
return __generator(this, function (_a) {
|
|
399
|
-
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
400
|
-
var depositTx, e_6;
|
|
401
|
-
return __generator(this, function (_a) {
|
|
402
|
-
switch (_a.label) {
|
|
403
|
-
case 0:
|
|
404
|
-
_a.trys.push([0, 3, , 4]);
|
|
405
|
-
return [4 /*yield*/, (0, getDepositTx_1.getDepositTx)(gasBudget, constants_1.COVERED_CALL_PACKAGE, constants_1.COVERED_CALL_REGISTRY, typeArgument, vaultIndex.toString(), token, depositAmount.toString())];
|
|
406
|
-
case 1:
|
|
407
|
-
depositTx = _a.sent();
|
|
408
|
-
return [4 /*yield*/, signer.executeMoveCall(depositTx)];
|
|
409
|
-
case 2:
|
|
410
|
-
_a.sent();
|
|
411
|
-
console.log("deposit to vault successfully");
|
|
412
|
-
resolve(null);
|
|
413
|
-
return [3 /*break*/, 4];
|
|
414
|
-
case 3:
|
|
415
|
-
e_6 = _a.sent();
|
|
416
|
-
console.log(e_6);
|
|
417
|
-
console.error("err in depositToVault");
|
|
418
|
-
return [3 /*break*/, 4];
|
|
419
|
-
case 4: return [2 /*return*/];
|
|
420
|
-
}
|
|
421
|
-
});
|
|
422
|
-
}); }).catch(function (error) {
|
|
423
|
-
console.error(error);
|
|
424
|
-
})];
|
|
425
|
-
});
|
|
426
|
-
});
|
|
427
|
-
}
|
|
428
|
-
function createNewAuctionWithNextCoveredCallVault(typeArgument, vaultIndex, priceOracle, timeOracle, activationTsMs, expirationTsMs) {
|
|
429
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
430
|
-
var _this = this;
|
|
431
|
-
return __generator(this, function (_a) {
|
|
432
|
-
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
433
|
-
var txn, e_7;
|
|
434
|
-
return __generator(this, function (_a) {
|
|
435
|
-
switch (_a.label) {
|
|
436
|
-
case 0:
|
|
437
|
-
_a.trys.push([0, 3, , 4]);
|
|
438
|
-
return [4 /*yield*/, (0, getNewAuctionWithNextCoveredCallVaultTx_1.getNewAuctionWithNextCoveredCallVaultTx)(gasBudget, constants_1.COVERED_CALL_PACKAGE, constants_1.COVERED_CALL_MANAGER, constants_1.COVERED_CALL_REGISTRY, typeArgument, vaultIndex, priceOracle, timeOracle, activationTsMs, expirationTsMs)];
|
|
439
|
-
case 1:
|
|
440
|
-
txn = _a.sent();
|
|
441
|
-
return [4 /*yield*/, signer.executeMoveCall(txn)];
|
|
442
|
-
case 2:
|
|
443
|
-
_a.sent();
|
|
444
|
-
console.log("create new auction with next covered call successfully");
|
|
445
|
-
resolve(null);
|
|
446
|
-
return [3 /*break*/, 4];
|
|
447
|
-
case 3:
|
|
448
|
-
e_7 = _a.sent();
|
|
449
|
-
console.error("err in createNewAuctionWithNextCoveredCallVault");
|
|
450
|
-
return [3 /*break*/, 4];
|
|
451
|
-
case 4: return [2 /*return*/];
|
|
452
|
-
}
|
|
453
|
-
});
|
|
454
|
-
}); }).catch(function (error) {
|
|
455
|
-
console.error(error);
|
|
456
|
-
})];
|
|
457
|
-
});
|
|
458
|
-
});
|
|
459
|
-
}
|
|
460
|
-
function newBid(typeArgument, vaultIndex, size, token, timeOracle) {
|
|
461
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
462
|
-
var _this = this;
|
|
463
|
-
return __generator(this, function (_a) {
|
|
464
|
-
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
465
|
-
var newBidTx, e_8;
|
|
466
|
-
return __generator(this, function (_a) {
|
|
467
|
-
switch (_a.label) {
|
|
468
|
-
case 0:
|
|
469
|
-
_a.trys.push([0, 3, , 4]);
|
|
470
|
-
return [4 /*yield*/, (0, getNewBidTx_1.getNewBidTx)(gasBudget, constants_1.COVERED_CALL_PACKAGE, constants_1.COVERED_CALL_REGISTRY, typeArgument, vaultIndex.toString(), size.toString(), token, timeOracle)];
|
|
471
|
-
case 1:
|
|
472
|
-
newBidTx = _a.sent();
|
|
473
|
-
return [4 /*yield*/, signer.executeMoveCall(newBidTx)];
|
|
474
|
-
case 2:
|
|
475
|
-
_a.sent();
|
|
476
|
-
console.log("new bid successfully ");
|
|
477
|
-
resolve(null);
|
|
478
|
-
return [3 /*break*/, 4];
|
|
479
|
-
case 3:
|
|
480
|
-
e_8 = _a.sent();
|
|
481
|
-
console.error(e_8);
|
|
482
|
-
return [3 /*break*/, 4];
|
|
483
|
-
case 4: return [2 /*return*/];
|
|
484
|
-
}
|
|
485
|
-
});
|
|
486
|
-
}); }).catch(function (error) {
|
|
487
|
-
console.error(error);
|
|
488
|
-
})];
|
|
489
|
-
});
|
|
490
|
-
});
|
|
491
|
-
}
|
|
492
|
-
function delivery(typeArgument, vaultIndex, sellSize, timeOracle) {
|
|
493
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
494
|
-
var _this = this;
|
|
495
|
-
return __generator(this, function (_a) {
|
|
496
|
-
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
497
|
-
var deliveryTx, e_9;
|
|
498
|
-
return __generator(this, function (_a) {
|
|
499
|
-
switch (_a.label) {
|
|
500
|
-
case 0:
|
|
501
|
-
_a.trys.push([0, 3, , 4]);
|
|
502
|
-
return [4 /*yield*/, (0, getDeliveryTx_1.getDeliveryTx)(gasBudget, constants_1.COVERED_CALL_PACKAGE, constants_1.COVERED_CALL_MANAGER, constants_1.COVERED_CALL_REGISTRY, typeArgument, vaultIndex.toString(), timeOracle)];
|
|
503
|
-
case 1:
|
|
504
|
-
deliveryTx = _a.sent();
|
|
505
|
-
return [4 /*yield*/, signer.executeMoveCall(deliveryTx)];
|
|
506
|
-
case 2:
|
|
507
|
-
_a.sent();
|
|
508
|
-
console.log("delivery successfully");
|
|
509
|
-
resolve(null);
|
|
510
|
-
return [3 /*break*/, 4];
|
|
511
|
-
case 3:
|
|
512
|
-
e_9 = _a.sent();
|
|
513
|
-
console.error("err in delivery");
|
|
514
|
-
reject();
|
|
515
|
-
return [3 /*break*/, 4];
|
|
516
|
-
case 4: return [2 /*return*/];
|
|
517
|
-
}
|
|
518
|
-
});
|
|
519
|
-
}); }).catch(function (error) {
|
|
520
|
-
console.error(error);
|
|
521
|
-
})];
|
|
522
|
-
});
|
|
523
|
-
});
|
|
524
|
-
}
|
|
525
|
-
function updatePayoffConfig(typeArgument, vaultIndex, price, premiumRoi, exposureRatio) {
|
|
526
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
527
|
-
var _this = this;
|
|
528
|
-
return __generator(this, function (_a) {
|
|
529
|
-
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
530
|
-
var updatePayoffConfigTx, e_10;
|
|
531
|
-
return __generator(this, function (_a) {
|
|
532
|
-
switch (_a.label) {
|
|
533
|
-
case 0:
|
|
534
|
-
_a.trys.push([0, 3, , 4]);
|
|
535
|
-
return [4 /*yield*/, (0, getUpdatePayoffConfigTx_1.getUpdatePayoffConfigTx)(gasBudget, constants_1.COVERED_CALL_PACKAGE, constants_1.COVERED_CALL_REGISTRY, typeArgument, constants_1.COVERED_CALL_MANAGER, vaultIndex.toString(), premiumRoi.toString(), exposureRatio.toString())];
|
|
536
|
-
case 1:
|
|
537
|
-
updatePayoffConfigTx = _a.sent();
|
|
538
|
-
return [4 /*yield*/, signer.executeMoveCall(updatePayoffConfigTx)];
|
|
539
|
-
case 2:
|
|
540
|
-
_a.sent();
|
|
541
|
-
console.log("update payoff config successfully");
|
|
542
|
-
resolve(null);
|
|
543
|
-
return [3 /*break*/, 4];
|
|
544
|
-
case 3:
|
|
545
|
-
e_10 = _a.sent();
|
|
546
|
-
console.error(e_10);
|
|
547
|
-
reject();
|
|
548
|
-
return [3 /*break*/, 4];
|
|
549
|
-
case 4: return [2 /*return*/];
|
|
550
|
-
}
|
|
551
|
-
});
|
|
552
|
-
}); }).catch(function (error) {
|
|
553
|
-
console.error(error);
|
|
554
|
-
})];
|
|
555
|
-
});
|
|
556
|
-
});
|
|
557
|
-
}
|
|
558
|
-
function settle(typeArgument, vaultIndex, priceOracle, timeOracle) {
|
|
559
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
560
|
-
var _this = this;
|
|
561
|
-
return __generator(this, function (_a) {
|
|
562
|
-
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
563
|
-
var settleTx, e_11;
|
|
564
|
-
return __generator(this, function (_a) {
|
|
565
|
-
switch (_a.label) {
|
|
566
|
-
case 0:
|
|
567
|
-
_a.trys.push([0, 3, , 4]);
|
|
568
|
-
return [4 /*yield*/, (0, getSettleTx_1.getSettleTx)(gasBudget, constants_1.COVERED_CALL_PACKAGE, constants_1.COVERED_CALL_REGISTRY, typeArgument, constants_1.COVERED_CALL_MANAGER, vaultIndex.toString(), priceOracle, timeOracle)];
|
|
569
|
-
case 1:
|
|
570
|
-
settleTx = _a.sent();
|
|
571
|
-
return [4 /*yield*/, signer.executeMoveCall(settleTx)];
|
|
572
|
-
case 2:
|
|
573
|
-
_a.sent();
|
|
574
|
-
console.log("settle successfully");
|
|
575
|
-
resolve(null);
|
|
576
|
-
return [3 /*break*/, 4];
|
|
577
|
-
case 3:
|
|
578
|
-
e_11 = _a.sent();
|
|
579
|
-
console.error(e_11);
|
|
580
|
-
reject();
|
|
581
|
-
return [3 /*break*/, 4];
|
|
582
|
-
case 4: return [2 /*return*/];
|
|
583
|
-
}
|
|
584
|
-
});
|
|
585
|
-
}); }).catch(function (error) {
|
|
586
|
-
console.error(error);
|
|
587
|
-
})];
|
|
588
|
-
});
|
|
589
|
-
});
|
|
590
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function getAuthorizedAddAuthorizedUserTx(gasBudget: number, packageId: string, registry: string, managerCap: string, address: string): Promise<any>;
|
|
@@ -1,56 +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
|
-
exports.getAuthorizedAddAuthorizedUserTx = void 0;
|
|
40
|
-
function getAuthorizedAddAuthorizedUserTx(gasBudget, packageId, registry, managerCap, address) {
|
|
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: 'add_authorized_user',
|
|
48
|
-
typeArguments: [],
|
|
49
|
-
arguments: [managerCap, registry, address],
|
|
50
|
-
gasBudget: gasBudget,
|
|
51
|
-
};
|
|
52
|
-
return [2 /*return*/, tx];
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
exports.getAuthorizedAddAuthorizedUserTx = getAuthorizedAddAuthorizedUserTx;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function getAuthorizedAddCoveredCallVaultAuthorizedUserTx(gasBudget: number, packageId: string, registry: string, typeArgument: string, index: string, address: string): Promise<any>;
|