@typus/typus-sdk 0.4.7 → 0.4.9
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/constants.d.ts +30 -0
- package/lib/constants.js +38 -0
- package/lib/scripts/getSubVault.d.ts +0 -0
- package/lib/scripts/getSubVault.js +6 -0
- package/lib/scripts/sui.d.ts +1 -0
- package/lib/scripts/sui.js +187 -0
- package/lib/test/eventListener.d.ts +5 -0
- package/lib/test/eventListener.js +294 -0
- package/lib/test/getBidData.d.ts +1 -0
- package/lib/test/getBidData.js +53 -0
- package/lib/test/getMakersShares.d.ts +1 -0
- package/lib/test/getMakersShares.js +52 -0
- package/lib/test/getUsersShares.d.ts +1 -0
- package/lib/test/getUsersShares.js +52 -0
- package/lib/test/getVaultData.d.ts +1 -0
- package/lib/test/getVaultData.js +53 -0
- package/lib/test/testClaim.d.ts +1 -0
- package/lib/test/testClaim.js +81 -0
- package/lib/test/testCrypto.d.ts +1 -0
- package/lib/test/testCrypto.js +54 -0
- package/lib/test/testDeposit.d.ts +1 -0
- package/lib/test/testDeposit.js +73 -0
- package/lib/test/testDepositV2.d.ts +0 -0
- package/lib/test/testDepositV2.js +62 -0
- package/lib/test/testMint.d.ts +1 -0
- package/lib/test/testMint.js +136 -0
- package/lib/test/testNewAuction.d.ts +1 -0
- package/lib/test/testNewAuction.js +93 -0
- package/lib/test/testNewVault.d.ts +1 -0
- package/lib/test/testNewVault.js +152 -0
- package/lib/test/testOracle.d.ts +1 -0
- package/lib/test/testOracle.js +93 -0
- package/lib/test/testSettle.d.ts +1 -0
- package/lib/test/testSettle.js +589 -0
- package/lib/test/testSubscribeEvent.d.ts +1 -0
- package/lib/test/testSubscribeEvent.js +97 -0
- package/lib/test/testUnsubscribe.d.ts +1 -0
- package/lib/test/testUnsubscribe.js +87 -0
- package/lib/test/testWithdraw.d.ts +1 -0
- package/lib/test/testWithdraw.js +70 -0
- package/lib/utils/auction/getBid.d.ts +2 -0
- package/lib/utils/auction/getBid.js +79 -0
- package/lib/utils/auction/sealedAuction.d.ts +33 -0
- package/lib/utils/auction/sealedAuction.js +64 -0
- package/lib/utils/authorized/getAuthorizedAddAuthorizedUserTx.d.ts +1 -0
- package/lib/utils/authorized/getAuthorizedAddAuthorizedUserTx.js +60 -0
- package/lib/utils/authorized/getAuthorizedAddCoveredCallVaultAuthorizedUserTx.d.ts +1 -0
- package/lib/utils/authorized/getAuthorizedAddCoveredCallVaultAuthorizedUserTx.js +60 -0
- package/lib/utils/authorized/getAuthorizedDeliveryTx.d.ts +1 -0
- package/lib/utils/authorized/getAuthorizedDeliveryTx.js +60 -0
- package/lib/utils/authorized/getAuthorizedEvolutionTx.d.ts +1 -0
- package/lib/utils/authorized/getAuthorizedEvolutionTx.js +63 -0
- package/lib/utils/authorized/getAuthorizedLastEvolutionTx.d.ts +1 -0
- package/lib/utils/authorized/getAuthorizedLastEvolutionTx.js +62 -0
- package/lib/utils/authorized/getAuthorizedNewAuctionTx.d.ts +1 -0
- package/lib/utils/authorized/getAuthorizedNewAuctionTx.js +61 -0
- package/lib/utils/authorized/getAuthorizedNewCoveredCallVaultTx.d.ts +1 -0
- package/lib/utils/authorized/getAuthorizedNewCoveredCallVaultTx.js +77 -0
- package/lib/utils/authorized/getAuthorizedRemoveAuthorizedUserTx.d.ts +1 -0
- package/lib/utils/authorized/getAuthorizedRemoveAuthorizedUserTx.js +60 -0
- package/lib/utils/authorized/getAuthorizedRemoveCoveredCallVaultAuthorizedUserTx.d.ts +1 -0
- package/lib/utils/authorized/getAuthorizedRemoveCoveredCallVaultAuthorizedUserTx.js +60 -0
- package/lib/utils/authorized/getAuthorizedSettleTx.d.ts +1 -0
- package/lib/utils/authorized/getAuthorizedSettleTx.js +61 -0
- package/lib/utils/authorized/getAuthorizedUpdateNextVaultConfigTx.d.ts +1 -0
- package/lib/utils/authorized/getAuthorizedUpdateNextVaultConfigTx.js +65 -0
- package/lib/utils/coveredCall/createPriceOracle.d.ts +1 -0
- package/lib/utils/coveredCall/createPriceOracle.js +92 -0
- package/lib/utils/coveredCall/createTimeOracle.d.ts +1 -0
- package/lib/utils/coveredCall/createTimeOracle.js +91 -0
- package/lib/utils/coveredCall/getAddCoveredCallVaultAuthorizedUserTx.d.ts +1 -0
- package/lib/utils/coveredCall/getAddCoveredCallVaultAuthorizedUserTx.js +61 -0
- package/lib/utils/coveredCall/getClaimAllTx.d.ts +1 -0
- package/lib/utils/coveredCall/getClaimAllTx.js +59 -0
- package/lib/utils/coveredCall/getClaimTx.d.ts +1 -0
- package/lib/utils/coveredCall/getClaimTx.js +59 -0
- package/lib/utils/coveredCall/getDeliveryTx.d.ts +1 -0
- package/lib/utils/coveredCall/getDeliveryTx.js +61 -0
- package/lib/utils/coveredCall/getDepositTx.d.ts +1 -0
- package/lib/utils/coveredCall/getDepositTx.js +65 -0
- package/lib/utils/coveredCall/getEvolutionTx.d.ts +1 -0
- package/lib/utils/coveredCall/getEvolutionTx.js +64 -0
- package/lib/utils/coveredCall/getLastEvolutionTx.d.ts +1 -0
- package/lib/utils/coveredCall/getLastEvolutionTx.js +63 -0
- package/lib/utils/coveredCall/getMakerClaimAllTx.d.ts +1 -0
- package/lib/utils/coveredCall/getMakerClaimAllTx.js +59 -0
- package/lib/utils/coveredCall/getMakerClaimTx.d.ts +1 -0
- package/lib/utils/coveredCall/getMakerClaimTx.js +59 -0
- package/lib/utils/coveredCall/getNewAuctionTx.d.ts +1 -0
- package/lib/utils/coveredCall/getNewAuctionTx.js +66 -0
- package/lib/utils/coveredCall/getNewAuctionWithNextCoveredCallVaultTx.d.ts +1 -0
- package/lib/utils/coveredCall/getNewAuctionWithNextCoveredCallVaultTx.js +64 -0
- package/lib/utils/coveredCall/getNewBidTx.d.ts +1 -0
- package/lib/utils/coveredCall/getNewBidTx.js +62 -0
- package/lib/utils/coveredCall/getNewCoveredCallVaultTx.d.ts +1 -0
- package/lib/utils/coveredCall/getNewCoveredCallVaultTx.js +77 -0
- package/lib/utils/coveredCall/getNewManagerTx.d.ts +1 -0
- package/lib/utils/coveredCall/getNewManagerTx.js +59 -0
- package/lib/utils/coveredCall/getRefundTx.d.ts +1 -0
- package/lib/utils/coveredCall/getRefundTx.js +59 -0
- package/lib/utils/coveredCall/getRemoveBidTx.d.ts +1 -0
- package/lib/utils/coveredCall/getRemoveBidTx.js +60 -0
- package/lib/utils/coveredCall/getRemoveCoveredCallVaultAuthorizedUserTx.d.ts +1 -0
- package/lib/utils/coveredCall/getRemoveCoveredCallVaultAuthorizedUserTx.js +61 -0
- package/lib/utils/coveredCall/getRemoveManagerTx.d.ts +1 -0
- package/lib/utils/coveredCall/getRemoveManagerTx.js +58 -0
- package/lib/utils/coveredCall/getRollOverTx.d.ts +1 -0
- package/lib/utils/coveredCall/getRollOverTx.js +60 -0
- package/lib/utils/coveredCall/getSettleTx.d.ts +1 -0
- package/lib/utils/coveredCall/getSettleTx.js +62 -0
- package/lib/utils/coveredCall/getSettleWithRollOverTx.d.ts +1 -0
- package/lib/utils/coveredCall/getSettleWithRollOverTx.js +62 -0
- package/lib/utils/coveredCall/getSubscribeTx.d.ts +1 -0
- package/lib/utils/coveredCall/getSubscribeTx.js +60 -0
- package/lib/utils/coveredCall/getUnsubscribeTx.d.ts +1 -0
- package/lib/utils/coveredCall/getUnsubscribeTx.js +63 -0
- package/lib/utils/coveredCall/getUpdateNextVaultConfigTx.d.ts +1 -0
- package/lib/utils/coveredCall/getUpdateNextVaultConfigTx.js +66 -0
- package/lib/utils/coveredCall/getUpdatePayoffConfigTx.d.ts +1 -0
- package/lib/utils/coveredCall/getUpdatePayoffConfigTx.js +62 -0
- package/lib/utils/coveredCall/getWithdrawTx.d.ts +1 -0
- package/lib/utils/coveredCall/getWithdrawTx.js +60 -0
- package/lib/utils/fetchData.d.ts +83 -0
- package/lib/utils/fetchData.js +206 -0
- package/lib/utils/getCreateTokenRegistryTx.d.ts +1 -0
- package/lib/utils/getCreateTokenRegistryTx.js +59 -0
- package/lib/utils/getMakersShares.d.ts +7 -0
- package/lib/utils/getMakersShares.js +148 -0
- package/lib/utils/getMintTx.d.ts +1 -0
- package/lib/utils/getMintTx.js +62 -0
- package/lib/utils/getNewOracleTx.d.ts +1 -0
- package/lib/utils/getNewOracleTx.js +59 -0
- package/lib/utils/getNewTimeOracleTx.d.ts +1 -0
- package/lib/utils/getNewTimeOracleTx.js +56 -0
- package/lib/utils/getTypeArgumentFromToken.d.ts +1 -0
- package/lib/utils/getTypeArgumentFromToken.js +71 -0
- package/lib/utils/getUpdateOracleTx.d.ts +1 -0
- package/lib/utils/getUpdateOracleTx.js +64 -0
- package/lib/utils/getUpdateTimeOracleTx.d.ts +1 -0
- package/lib/utils/getUpdateTimeOracleTx.js +60 -0
- package/lib/utils/getUsersShares.d.ts +8 -0
- package/lib/utils/getUsersShares.js +147 -0
- package/lib/utils/getVaultData.d.ts +3 -0
- package/lib/utils/getVaultData.js +262 -0
- package/lib/utils/getVaultIndexInRegistry.d.ts +1 -0
- package/lib/utils/getVaultIndexInRegistry.js +61 -0
- package/lib/utils/isObjAvailable.d.ts +0 -0
- package/lib/utils/isObjAvailable.js +14 -0
- package/lib/utils/loadUsersDepositData.d.ts +8 -0
- package/lib/utils/loadUsersDepositData.js +160 -0
- package/package.json +1 -1
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
export interface SubVaults {
|
|
2
|
+
rolling: string;
|
|
3
|
+
maker: string;
|
|
4
|
+
regular: string;
|
|
5
|
+
}
|
|
6
|
+
export interface VaultConfig {
|
|
7
|
+
strikeOtmPct: string;
|
|
8
|
+
strikeIncrement: string;
|
|
9
|
+
decaySpeed: string;
|
|
10
|
+
initialPrice: string;
|
|
11
|
+
finalPrice: string;
|
|
12
|
+
auctionDurationInMs: string;
|
|
13
|
+
}
|
|
14
|
+
export interface Config {
|
|
15
|
+
period: string;
|
|
16
|
+
activationTsMs: string;
|
|
17
|
+
expirationTsMs: string;
|
|
18
|
+
tokenDecimal: string;
|
|
19
|
+
shareDecimal: string;
|
|
20
|
+
capacity: string;
|
|
21
|
+
vaultConfig: VaultConfig;
|
|
22
|
+
nextVaultConfig: VaultConfig;
|
|
23
|
+
payoffConfig: PayoffConfig;
|
|
24
|
+
}
|
|
25
|
+
export interface SubVault {
|
|
26
|
+
balance: string;
|
|
27
|
+
shareSupply: string;
|
|
28
|
+
}
|
|
29
|
+
export interface Vault {
|
|
30
|
+
ableToDeposit: boolean;
|
|
31
|
+
ableToWithdraw: boolean;
|
|
32
|
+
makerSubVault: SubVault;
|
|
33
|
+
regularSubVault: SubVault;
|
|
34
|
+
rollingSubVault: SubVault;
|
|
35
|
+
}
|
|
36
|
+
export interface Bid {
|
|
37
|
+
price: string;
|
|
38
|
+
size: string;
|
|
39
|
+
tsMs: string;
|
|
40
|
+
tokenBalance: string;
|
|
41
|
+
ownerAddress: string;
|
|
42
|
+
}
|
|
43
|
+
export interface PriceConfig {
|
|
44
|
+
decaySpeed: string;
|
|
45
|
+
initialPrice: string;
|
|
46
|
+
finalPrice: string;
|
|
47
|
+
}
|
|
48
|
+
export interface Auction {
|
|
49
|
+
startTsMs: string;
|
|
50
|
+
endTsMs: string;
|
|
51
|
+
priceConfig: PriceConfig;
|
|
52
|
+
index: string;
|
|
53
|
+
}
|
|
54
|
+
export interface DeliveryInfo {
|
|
55
|
+
deliveryPrice: string;
|
|
56
|
+
deliverySize: string;
|
|
57
|
+
}
|
|
58
|
+
export interface CoveredCallVault {
|
|
59
|
+
vaultId: string;
|
|
60
|
+
vaultIdx: string;
|
|
61
|
+
asset: string;
|
|
62
|
+
config: Config;
|
|
63
|
+
vault: Vault;
|
|
64
|
+
auction: Auction;
|
|
65
|
+
prev: string;
|
|
66
|
+
next: string;
|
|
67
|
+
totalBidSize: string;
|
|
68
|
+
deliveryInfo: DeliveryInfo;
|
|
69
|
+
owner: string;
|
|
70
|
+
tvl: string;
|
|
71
|
+
vaultBidPrice: string;
|
|
72
|
+
}
|
|
73
|
+
export interface PayoffConfig {
|
|
74
|
+
exposureRatio: string;
|
|
75
|
+
premiumRoi: string;
|
|
76
|
+
strike: string;
|
|
77
|
+
}
|
|
78
|
+
export declare function getCoveredCallVaultsFromRegistry(registry: string): Promise<any>;
|
|
79
|
+
export declare function getTableFromCoveredCallVault(coveredCallVault: string): Promise<any>;
|
|
80
|
+
export declare function getSubVaultsFromTable(tableUnderCoveredCallVault: string): Promise<SubVaults>;
|
|
81
|
+
export declare function getTableUnderSubVault(subVault: string): Promise<string>;
|
|
82
|
+
export declare function getLinkedListNodesFromTable(table: string): Promise<any[]>;
|
|
83
|
+
export declare function getUserDataFromLinkedListNode(linkedListNode: string): Promise<any>;
|
|
@@ -0,0 +1,206 @@
|
|
|
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 __values = (this && this.__values) || function(o) {
|
|
39
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
40
|
+
if (m) return m.call(o);
|
|
41
|
+
if (o && typeof o.length === "number") return {
|
|
42
|
+
next: function () {
|
|
43
|
+
if (o && i >= o.length) o = void 0;
|
|
44
|
+
return { value: o && o[i++], done: !o };
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
48
|
+
};
|
|
49
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
+
exports.getUserDataFromLinkedListNode = exports.getLinkedListNodesFromTable = exports.getTableUnderSubVault = exports.getSubVaultsFromTable = exports.getTableFromCoveredCallVault = exports.getCoveredCallVaultsFromRegistry = void 0;
|
|
51
|
+
var sui_js_1 = require("@mysten/sui.js");
|
|
52
|
+
var constants_1 = require("../constants");
|
|
53
|
+
var provider = new sui_js_1.JsonRpcProvider(constants_1.TESTNET_RPC_ENDPOINT); //for read only operations
|
|
54
|
+
var decode = function (str) { return Buffer.from(str, 'base64').toString('binary'); };
|
|
55
|
+
//new version: getVaultDataFromRegistry()
|
|
56
|
+
function getCoveredCallVaultsFromRegistry(registry) {
|
|
57
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
58
|
+
var coveredCallVaults;
|
|
59
|
+
return __generator(this, function (_a) {
|
|
60
|
+
switch (_a.label) {
|
|
61
|
+
case 0:
|
|
62
|
+
console.log("registry: " + registry);
|
|
63
|
+
return [4 /*yield*/, provider.getObjectsOwnedByObject(registry)];
|
|
64
|
+
case 1:
|
|
65
|
+
coveredCallVaults = _a.sent();
|
|
66
|
+
console.log("under the registry, there are " + coveredCallVaults.length + " covered call vaults");
|
|
67
|
+
return [2 /*return*/, coveredCallVaults];
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
exports.getCoveredCallVaultsFromRegistry = getCoveredCallVaultsFromRegistry;
|
|
73
|
+
function getTableFromCoveredCallVault(coveredCallVault) {
|
|
74
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
75
|
+
var tmp, tableUnderCoveredCallVault;
|
|
76
|
+
return __generator(this, function (_a) {
|
|
77
|
+
switch (_a.label) {
|
|
78
|
+
case 0:
|
|
79
|
+
console.log("coveredCallVault: " + coveredCallVault);
|
|
80
|
+
return [4 /*yield*/, provider.getObject(coveredCallVault)];
|
|
81
|
+
case 1:
|
|
82
|
+
tmp = _a.sent();
|
|
83
|
+
if (tmp.status != "Exists") {
|
|
84
|
+
console.log("obj not exists");
|
|
85
|
+
return [2 /*return*/];
|
|
86
|
+
}
|
|
87
|
+
tableUnderCoveredCallVault = tmp.details.data.fields.value.fields.vault.fields.sub_vaults.fields.id.id;
|
|
88
|
+
console.log("table : " + tableUnderCoveredCallVault);
|
|
89
|
+
return [2 /*return*/, tableUnderCoveredCallVault];
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
exports.getTableFromCoveredCallVault = getTableFromCoveredCallVault;
|
|
95
|
+
function getSubVaultsFromTable(tableUnderCoveredCallVault) {
|
|
96
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
97
|
+
var subVaults, result, subVaults_1, subVaults_1_1, subVault, txn, name_1, e_1_1;
|
|
98
|
+
var e_1, _a;
|
|
99
|
+
return __generator(this, function (_b) {
|
|
100
|
+
switch (_b.label) {
|
|
101
|
+
case 0: return [4 /*yield*/, provider.getObjectsOwnedByObject(tableUnderCoveredCallVault)];
|
|
102
|
+
case 1:
|
|
103
|
+
subVaults = _b.sent();
|
|
104
|
+
console.log("there are " + subVaults.length + " sub vault under table, representing rolling, regular and maker");
|
|
105
|
+
result = {};
|
|
106
|
+
_b.label = 2;
|
|
107
|
+
case 2:
|
|
108
|
+
_b.trys.push([2, 7, 8, 9]);
|
|
109
|
+
subVaults_1 = __values(subVaults), subVaults_1_1 = subVaults_1.next();
|
|
110
|
+
_b.label = 3;
|
|
111
|
+
case 3:
|
|
112
|
+
if (!!subVaults_1_1.done) return [3 /*break*/, 6];
|
|
113
|
+
subVault = subVaults_1_1.value;
|
|
114
|
+
return [4 /*yield*/, provider.getObject(subVault.objectId)];
|
|
115
|
+
case 4:
|
|
116
|
+
txn = _b.sent();
|
|
117
|
+
if (txn.status != "Exists") {
|
|
118
|
+
console.log("obj not exists");
|
|
119
|
+
return [2 /*return*/, {}];
|
|
120
|
+
}
|
|
121
|
+
name_1 = decode(txn.details.data.fields.name) //rolling / regular / maker
|
|
122
|
+
;
|
|
123
|
+
//@ts-ignore
|
|
124
|
+
result[name_1] = txn.details.data.fields.id.id;
|
|
125
|
+
_b.label = 5;
|
|
126
|
+
case 5:
|
|
127
|
+
subVaults_1_1 = subVaults_1.next();
|
|
128
|
+
return [3 /*break*/, 3];
|
|
129
|
+
case 6: return [3 /*break*/, 9];
|
|
130
|
+
case 7:
|
|
131
|
+
e_1_1 = _b.sent();
|
|
132
|
+
e_1 = { error: e_1_1 };
|
|
133
|
+
return [3 /*break*/, 9];
|
|
134
|
+
case 8:
|
|
135
|
+
try {
|
|
136
|
+
if (subVaults_1_1 && !subVaults_1_1.done && (_a = subVaults_1.return)) _a.call(subVaults_1);
|
|
137
|
+
}
|
|
138
|
+
finally { if (e_1) throw e_1.error; }
|
|
139
|
+
return [7 /*endfinally*/];
|
|
140
|
+
case 9:
|
|
141
|
+
console.log("sub vaults:");
|
|
142
|
+
console.log(result);
|
|
143
|
+
return [2 /*return*/, result];
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
exports.getSubVaultsFromTable = getSubVaultsFromTable;
|
|
149
|
+
function getTableUnderSubVault(subVault) {
|
|
150
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
151
|
+
var tmp, table;
|
|
152
|
+
return __generator(this, function (_a) {
|
|
153
|
+
switch (_a.label) {
|
|
154
|
+
case 0:
|
|
155
|
+
console.log("sub vault: " + subVault);
|
|
156
|
+
return [4 /*yield*/, provider.getObject(subVault)];
|
|
157
|
+
case 1:
|
|
158
|
+
tmp = _a.sent();
|
|
159
|
+
if (tmp.status != "Exists") {
|
|
160
|
+
console.log("obj not exists");
|
|
161
|
+
return [2 /*return*/, ""];
|
|
162
|
+
}
|
|
163
|
+
table = tmp.details.data.fields.value.fields.user_shares.fields.nodes.fields.id.id;
|
|
164
|
+
console.log("table under sub vault: ", table);
|
|
165
|
+
return [2 /*return*/, table];
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
exports.getTableUnderSubVault = getTableUnderSubVault;
|
|
171
|
+
function getLinkedListNodesFromTable(table) {
|
|
172
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
173
|
+
var linkedListNodes;
|
|
174
|
+
return __generator(this, function (_a) {
|
|
175
|
+
switch (_a.label) {
|
|
176
|
+
case 0: return [4 /*yield*/, provider.getObjectsOwnedByObject(table)];
|
|
177
|
+
case 1:
|
|
178
|
+
linkedListNodes = _a.sent();
|
|
179
|
+
console.log("there are " + linkedListNodes.length + " linked list nodes in table");
|
|
180
|
+
return [2 /*return*/, linkedListNodes];
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
exports.getLinkedListNodesFromTable = getLinkedListNodesFromTable;
|
|
186
|
+
function getUserDataFromLinkedListNode(linkedListNode) {
|
|
187
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
188
|
+
var tmp, usersData;
|
|
189
|
+
return __generator(this, function (_a) {
|
|
190
|
+
switch (_a.label) {
|
|
191
|
+
case 0: return [4 /*yield*/, provider.getObject(linkedListNode)];
|
|
192
|
+
case 1:
|
|
193
|
+
tmp = _a.sent();
|
|
194
|
+
if (tmp.status != "Exists") {
|
|
195
|
+
console.log("obj not exists");
|
|
196
|
+
return [2 /*return*/];
|
|
197
|
+
}
|
|
198
|
+
usersData = tmp.details.data.fields;
|
|
199
|
+
console.log("users data from linked list node:");
|
|
200
|
+
console.log(usersData);
|
|
201
|
+
return [2 /*return*/, usersData];
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
exports.getUserDataFromLinkedListNode = getUserDataFromLinkedListNode;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getCreateTokenRegistryTx(packageId: string): Promise<any>;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (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
|
+
exports.getCreateTokenRegistryTx = void 0;
|
|
40
|
+
function getCreateTokenRegistryTx(packageId) {
|
|
41
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
42
|
+
var tx;
|
|
43
|
+
return __generator(this, function (_a) {
|
|
44
|
+
tx = {
|
|
45
|
+
packageObjectId: packageId,
|
|
46
|
+
module: 'token',
|
|
47
|
+
function: 'new',
|
|
48
|
+
typeArguments: [],
|
|
49
|
+
arguments: [],
|
|
50
|
+
gasBudget: 10000,
|
|
51
|
+
};
|
|
52
|
+
return [2 /*return*/, tx];
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
exports.getCreateTokenRegistryTx = getCreateTokenRegistryTx;
|
|
57
|
+
/*
|
|
58
|
+
sui client call --gas-budget 10000 --package $PACKAGE --module "token" --function "new"
|
|
59
|
+
*/
|
|
@@ -0,0 +1,148 @@
|
|
|
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 __values = (this && this.__values) || function(o) {
|
|
39
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
40
|
+
if (m) return m.call(o);
|
|
41
|
+
if (o && typeof o.length === "number") return {
|
|
42
|
+
next: function () {
|
|
43
|
+
if (o && i >= o.length) o = void 0;
|
|
44
|
+
return { value: o && o[i++], done: !o };
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
48
|
+
};
|
|
49
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
+
exports.getMakersShares = void 0;
|
|
51
|
+
var sui_js_1 = require("@mysten/sui.js");
|
|
52
|
+
var constants_1 = require("../constants");
|
|
53
|
+
var provider = new sui_js_1.JsonRpcProvider(constants_1.TESTNET_RPC_ENDPOINT); //for read only operations
|
|
54
|
+
function getSubVaultsData(registry) {
|
|
55
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
56
|
+
var subVaultsData, coveredCallVaults, coveredCallVaultsId, objsInfo, objsInfo_1, objsInfo_1_1, objInfo, vaultId, vault, subVaultData;
|
|
57
|
+
var e_1, _a;
|
|
58
|
+
return __generator(this, function (_b) {
|
|
59
|
+
switch (_b.label) {
|
|
60
|
+
case 0:
|
|
61
|
+
subVaultsData = new Map();
|
|
62
|
+
return [4 /*yield*/, provider.getObjectsOwnedByObject(registry)];
|
|
63
|
+
case 1:
|
|
64
|
+
coveredCallVaults = _b.sent();
|
|
65
|
+
coveredCallVaultsId = coveredCallVaults.map(function (e) { return e.objectId; });
|
|
66
|
+
return [4 /*yield*/, provider.getObjectBatch(coveredCallVaultsId)];
|
|
67
|
+
case 2:
|
|
68
|
+
objsInfo = _b.sent();
|
|
69
|
+
try {
|
|
70
|
+
for (objsInfo_1 = __values(objsInfo), objsInfo_1_1 = objsInfo_1.next(); !objsInfo_1_1.done; objsInfo_1_1 = objsInfo_1.next()) {
|
|
71
|
+
objInfo = objsInfo_1_1.value;
|
|
72
|
+
if (objInfo.status != "Exists") {
|
|
73
|
+
console.log("obj not exist");
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
vaultId = Number(objInfo.details.data.fields.name);
|
|
77
|
+
vault = objInfo.details.data.fields.value.fields.vault.fields;
|
|
78
|
+
subVaultData = {
|
|
79
|
+
makerTotalSupply: Number(vault.maker_sub_vault.fields.balance),
|
|
80
|
+
makerTotalBalance: Number(vault.maker_sub_vault.fields.share_supply),
|
|
81
|
+
};
|
|
82
|
+
subVaultsData.set(vaultId, subVaultData);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
86
|
+
finally {
|
|
87
|
+
try {
|
|
88
|
+
if (objsInfo_1_1 && !objsInfo_1_1.done && (_a = objsInfo_1.return)) _a.call(objsInfo_1);
|
|
89
|
+
}
|
|
90
|
+
finally { if (e_1) throw e_1.error; }
|
|
91
|
+
}
|
|
92
|
+
return [2 /*return*/, subVaultsData];
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
function getMakersShares(makerShareTable, registry) {
|
|
98
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
99
|
+
var subVaultsData, makerShareIds, makerShares;
|
|
100
|
+
return __generator(this, function (_a) {
|
|
101
|
+
switch (_a.label) {
|
|
102
|
+
case 0: return [4 /*yield*/, getSubVaultsData(registry)]; //vault idx to subvault info
|
|
103
|
+
case 1:
|
|
104
|
+
subVaultsData = _a.sent() //vault idx to subvault info
|
|
105
|
+
;
|
|
106
|
+
return [4 /*yield*/, provider.getObjectsOwnedByObject(makerShareTable)];
|
|
107
|
+
case 2:
|
|
108
|
+
makerShareIds = (_a.sent()).map(function (x) { return x.objectId; });
|
|
109
|
+
return [4 /*yield*/, provider.getObjectBatch(makerShareIds)];
|
|
110
|
+
case 3:
|
|
111
|
+
makerShares = (_a.sent()).map(function (x) {
|
|
112
|
+
var _a, _b;
|
|
113
|
+
if (x.status != "Exists") {
|
|
114
|
+
console.log("obj not exist");
|
|
115
|
+
return {};
|
|
116
|
+
}
|
|
117
|
+
//@ts-ignore
|
|
118
|
+
var obj = (x.details.data.fields);
|
|
119
|
+
/*
|
|
120
|
+
{
|
|
121
|
+
id: { id: '0xae32e84281a8e08fade4f72d0c5f861061deb608' },
|
|
122
|
+
name: {
|
|
123
|
+
type: '0xb92f3c4c26151b86977b8811765fe74cb133a35f::covered_call::MakerShareKey',
|
|
124
|
+
fields: { index: '0', maker: '0x4a3b00eac21bfbe062932a5c2b9710245edb2cc2' }
|
|
125
|
+
},
|
|
126
|
+
value: '23000000000'
|
|
127
|
+
}
|
|
128
|
+
*/
|
|
129
|
+
var index = obj.name.fields.index;
|
|
130
|
+
var share = obj.value;
|
|
131
|
+
var maker = obj.name.fields.maker;
|
|
132
|
+
var depositAmount = (Number(share) / ((_a = subVaultsData.get(Number(index))) === null || _a === void 0 ? void 0 : _a.makerTotalSupply) * ((_b = subVaultsData.get(Number(index))) === null || _b === void 0 ? void 0 : _b.makerTotalBalance));
|
|
133
|
+
var res = {
|
|
134
|
+
coveredCallVaultIndex: index,
|
|
135
|
+
//@ts-ignore
|
|
136
|
+
share: share,
|
|
137
|
+
//@ts-ignore
|
|
138
|
+
maker: maker,
|
|
139
|
+
depositAmount: depositAmount.toFixed(0),
|
|
140
|
+
};
|
|
141
|
+
return res;
|
|
142
|
+
});
|
|
143
|
+
return [2 /*return*/, makerShares];
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
exports.getMakersShares = getMakersShares;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getMintTx(packageId: string, registry: string, moduleName: string, amount: number): Promise<any>;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (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
|
+
exports.getMintTx = void 0;
|
|
40
|
+
function getMintTx(packageId, registry, moduleName, amount) {
|
|
41
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
42
|
+
var tx;
|
|
43
|
+
return __generator(this, function (_a) {
|
|
44
|
+
tx = {
|
|
45
|
+
packageObjectId: packageId,
|
|
46
|
+
module: moduleName,
|
|
47
|
+
function: 'mint',
|
|
48
|
+
typeArguments: [],
|
|
49
|
+
arguments: [
|
|
50
|
+
registry,
|
|
51
|
+
amount,
|
|
52
|
+
],
|
|
53
|
+
gasBudget: 10000,
|
|
54
|
+
};
|
|
55
|
+
return [2 /*return*/, tx];
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
exports.getMintTx = getMintTx;
|
|
60
|
+
/*
|
|
61
|
+
sui client call --gas-budget 10000 --package 0xe879e96fb90a8559127091f1176a2d10bb67c6ff --module "token_btc" --function "mint" --args 0x5dce92f67eeda471369b734deac0d540b751cea6 10000
|
|
62
|
+
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getNewOracleTx(packageId: string, typeArgument: string, decimal: number): Promise<any>;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (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
|
+
exports.getNewOracleTx = void 0;
|
|
40
|
+
function getNewOracleTx(packageId, typeArgument, decimal) {
|
|
41
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
42
|
+
var tx;
|
|
43
|
+
return __generator(this, function (_a) {
|
|
44
|
+
tx = {
|
|
45
|
+
packageObjectId: packageId,
|
|
46
|
+
module: 'oracle',
|
|
47
|
+
function: 'new_oracle',
|
|
48
|
+
typeArguments: [typeArgument],
|
|
49
|
+
arguments: [decimal],
|
|
50
|
+
gasBudget: 1000,
|
|
51
|
+
};
|
|
52
|
+
return [2 /*return*/, tx];
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
exports.getNewOracleTx = getNewOracleTx;
|
|
57
|
+
/*
|
|
58
|
+
sui client call --gas-budget 1000 --package $PACKAGE --module "oracle" --function "new_oracle" --type-args 0x2::sui::SUI
|
|
59
|
+
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getNewTimeOracleTx(packageId: string): Promise<any>;
|