@typus/typus-sdk 1.0.5 → 1.0.7
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 +16 -16
- package/lib/constants.d.ts +4 -2
- package/lib/constants.js +13 -7
- package/lib/mnemonic.json +1 -0
- package/lib/scripts/sui.js +4 -4
- package/lib/test/authorized/testAuthorizedNewPortfolioVault.js +8 -2
- package/lib/test/authorized/testAuthorizedUpdateUpcomingVaultConfig.js +8 -2
- package/lib/test/authorized/testAuthorizedUpdateWarmupVaultConfig.js +8 -2
- package/lib/test/getBidData.js +11 -4
- package/lib/test/getVaultData.js +2 -1
- package/lib/test/helper/getAuctionMaxSize.js +16 -20
- package/lib/test/helper/getUserStatus.js +58 -39
- package/lib/test/testMint.js +22 -12
- package/lib/test/testSubscribeEvent.js +6 -21
- package/lib/test/user/testClaim.js +4 -4
- package/lib/test/user/testCompound.js +4 -4
- package/lib/test/user/testDeposit.js +19 -17
- package/lib/test/user/testHarvest.js +4 -4
- package/lib/test/user/testNewBid.js +14 -12
- package/lib/test/user/testUnsubscribe.js +4 -4
- package/lib/test/user/testWithdraw.js +8 -7
- package/lib/utils/auction/getBid.d.ts +3 -3
- package/lib/utils/auction/getBid.js +16 -18
- package/lib/utils/fetchData.d.ts +2 -0
- package/lib/utils/fetchData.js +2 -6
- package/lib/utils/getTypeArgumentFromToken.d.ts +1 -1
- package/lib/utils/getTypeArgumentFromToken.js +1 -1
- package/lib/utils/getVaultData.d.ts +1 -1
- package/lib/utils/getVaultData.js +10 -7
- package/lib/utils/getWhiteListFromRegistry.d.ts +1 -1
- package/lib/utils/getWhiteListFromRegistry.js +5 -7
- package/lib/utils/portfolio/authorized/getAuthorizedAddPortfolioVaultAuthorizedUserTx.d.ts +3 -2
- package/lib/utils/portfolio/authorized/getAuthorizedAddPortfolioVaultAuthorizedUserTx.js +12 -14
- package/lib/utils/portfolio/authorized/getAuthorizedDeliveryTx.d.ts +2 -1
- package/lib/utils/portfolio/authorized/getAuthorizedDeliveryTx.js +15 -13
- package/lib/utils/portfolio/authorized/getAuthorizedNewPortfolioVaultTx.d.ts +2 -1
- package/lib/utils/portfolio/authorized/getAuthorizedNewPortfolioVaultTx.js +34 -32
- package/lib/utils/portfolio/authorized/getAuthorizedRemovePortfolioVaultAuthorizedUserTx.d.ts +3 -2
- package/lib/utils/portfolio/authorized/getAuthorizedRemovePortfolioVaultAuthorizedUserTx.js +12 -14
- package/lib/utils/portfolio/authorized/getAuthorizedUpdateCapacityTx.d.ts +2 -1
- package/lib/utils/portfolio/authorized/getAuthorizedUpdateCapacityTx.js +11 -13
- package/lib/utils/portfolio/authorized/getAuthorizedUpdateUpcomingVaultConfigTx.d.ts +2 -1
- package/lib/utils/portfolio/authorized/getAuthorizedUpdateUpcomingVaultConfigTx.js +21 -19
- package/lib/utils/portfolio/authorized/getAuthorizedUpdateWarmupVaultConfigTx.d.ts +2 -1
- package/lib/utils/portfolio/authorized/getAuthorizedUpdateWarmupVaultConfigTx.js +18 -16
- package/lib/utils/portfolio/helper/getAuctionMaxSize.d.ts +2 -1
- package/lib/utils/portfolio/manager/getAddAuthorizedUserTx.d.ts +2 -1
- package/lib/utils/portfolio/manager/getAddAuthorizedUserTx.js +11 -13
- package/lib/utils/portfolio/manager/getAddPortfolioVaultAuthorizedUserTx.d.ts +3 -2
- package/lib/utils/portfolio/manager/getAddPortfolioVaultAuthorizedUserTx.js +12 -15
- package/lib/utils/portfolio/manager/getCloseAuctionTx.d.ts +2 -1
- package/lib/utils/portfolio/manager/getCloseAuctionTx.js +16 -14
- package/lib/utils/portfolio/manager/getCloseVaultTx.d.ts +2 -1
- package/lib/utils/portfolio/manager/getCloseVaultTx.js +10 -12
- package/lib/utils/portfolio/manager/getDeliveryTx.d.ts +2 -1
- package/lib/utils/portfolio/manager/getDeliveryTx.js +16 -14
- package/lib/utils/portfolio/manager/getEvolutionTx.d.ts +2 -1
- package/lib/utils/portfolio/manager/getEvolutionTx.js +18 -16
- package/lib/utils/portfolio/manager/getNewManagerTx.d.ts +2 -1
- package/lib/utils/portfolio/manager/getNewManagerTx.js +10 -11
- package/lib/utils/portfolio/manager/getNewPortfolioVaultTx.d.ts +2 -1
- package/lib/utils/portfolio/manager/getNewPortfolioVaultTx.js +33 -31
- package/lib/utils/portfolio/manager/getRemoveAuthorizedUserTx.d.ts +2 -1
- package/lib/utils/portfolio/manager/getRemoveAuthorizedUserTx.js +10 -12
- package/lib/utils/portfolio/manager/getRemoveManagerTx.d.ts +2 -1
- package/lib/utils/portfolio/manager/getRemoveManagerTx.js +10 -10
- package/lib/utils/portfolio/manager/getRemovePortfolioVaultAuthorizedUserTx.d.ts +3 -2
- package/lib/utils/portfolio/manager/getRemovePortfolioVaultAuthorizedUserTx.js +12 -15
- package/lib/utils/portfolio/manager/getUpdateCapacityTx.d.ts +2 -1
- package/lib/utils/portfolio/manager/getUpdateCapacityTx.js +11 -14
- package/lib/utils/portfolio/user/getCompoundTx.d.ts +2 -1
- package/lib/utils/portfolio/user/getDepositTx.js +3 -7
- package/lib/utils/portfolio/user/getNewBidTx.js +3 -2
- package/lib/utils/portfolio/user/getUnsubscribeTx.js +3 -2
- package/lib/utils/portfolio/user/getWithdrawTx.d.ts +2 -1
- package/package.json +1 -1
|
@@ -40,38 +40,40 @@ var constants_1 = require("../../constants");
|
|
|
40
40
|
var sui_js_1 = require("@mysten/sui.js");
|
|
41
41
|
var getDepositTx_1 = require("../../utils/portfolio/user/getDepositTx");
|
|
42
42
|
var getVaultData_1 = require("../../utils/getVaultData");
|
|
43
|
-
var
|
|
43
|
+
var connection = new sui_js_1.Connection({ fullnode: "https://rpc-testnet.suiscan.xyz:443" });
|
|
44
|
+
var provider = new sui_js_1.JsonRpcProvider(connection); //for read only operations
|
|
44
45
|
var keypair = sui_js_1.Ed25519Keypair.deriveKeypair(constants_1.TEST_MNEMONIC);
|
|
45
46
|
var signer = new sui_js_1.RawSigner(keypair, provider);
|
|
46
47
|
(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
47
|
-
var depositAmount, index, portfolioVaults, portfolioVault, dToken, typeArguments, vaultIndex, coinObjs, _a, _b, coins, gasBudget,
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
var depositAmount, index, portfolioVaults, portfolioVault, dToken, typeArguments, vaultIndex, coinObjs, _a, _b, coins, gasBudget, transactionBlock, res;
|
|
49
|
+
var _c;
|
|
50
|
+
return __generator(this, function (_d) {
|
|
51
|
+
switch (_d.label) {
|
|
50
52
|
case 0:
|
|
51
53
|
depositAmount = "100000000";
|
|
52
|
-
index = "
|
|
53
|
-
return [4 /*yield*/, (0, getVaultData_1.getVaultDataFromRegistry)(constants_1.REGISTRY, provider)];
|
|
54
|
+
index = "1";
|
|
55
|
+
return [4 /*yield*/, (0, getVaultData_1.getVaultDataFromRegistry)(constants_1.REGISTRY, provider, index)];
|
|
54
56
|
case 1:
|
|
55
|
-
portfolioVaults =
|
|
57
|
+
portfolioVaults = _d.sent();
|
|
56
58
|
portfolioVault = portfolioVaults.find(function (portfolioVault) { return portfolioVault.info.index == index; });
|
|
57
|
-
console.log(portfolioVault);
|
|
58
59
|
dToken = portfolioVault.typeArgs[0];
|
|
59
60
|
typeArguments = portfolioVault.typeArgs;
|
|
60
61
|
vaultIndex = portfolioVault.info.index;
|
|
61
|
-
_b = (_a = provider).
|
|
62
|
+
_b = (_a = provider).getCoins;
|
|
63
|
+
_c = {};
|
|
62
64
|
return [4 /*yield*/, signer.getAddress()];
|
|
63
|
-
case 2: return [4 /*yield*/, _b.apply(_a, [_c.sent(),
|
|
65
|
+
case 2: return [4 /*yield*/, _b.apply(_a, [(_c.owner = _d.sent(), _c.coinType = dToken, _c)])];
|
|
64
66
|
case 3:
|
|
65
|
-
coinObjs =
|
|
66
|
-
coins = coinObjs.map(function (coin) { return coin.
|
|
67
|
+
coinObjs = _d.sent();
|
|
68
|
+
coins = coinObjs.data.map(function (coin) { return coin.coinObjectId; });
|
|
67
69
|
console.log("test for deposit, try to deposit " + coins + " for " + depositAmount + " ...");
|
|
68
|
-
gasBudget =
|
|
69
|
-
return [4 /*yield*/, (0, getDepositTx_1.getDepositTx)(gasBudget, constants_1.PORTFOLIO_PACKAGE, constants_1.REGISTRY, typeArguments, vaultIndex, coins, depositAmount)];
|
|
70
|
+
gasBudget = 100000000;
|
|
71
|
+
return [4 /*yield*/, (0, getDepositTx_1.getDepositTx)(gasBudget, constants_1.PORTFOLIO_PACKAGE, constants_1.MODULE, constants_1.REGISTRY, typeArguments, vaultIndex, coins, depositAmount)];
|
|
70
72
|
case 4:
|
|
71
|
-
|
|
72
|
-
return [4 /*yield*/, signer.
|
|
73
|
+
transactionBlock = _d.sent();
|
|
74
|
+
return [4 /*yield*/, signer.signAndExecuteTransactionBlock({ transactionBlock: transactionBlock })];
|
|
73
75
|
case 5:
|
|
74
|
-
res =
|
|
76
|
+
res = _d.sent();
|
|
75
77
|
console.log(res);
|
|
76
78
|
return [2 /*return*/];
|
|
77
79
|
}
|
|
@@ -44,7 +44,7 @@ var provider = new sui_js_1.JsonRpcProvider(sui_js_1.devnetConnection); //for re
|
|
|
44
44
|
var keypair = sui_js_1.Ed25519Keypair.deriveKeypair(constants_1.TEST_MNEMONIC);
|
|
45
45
|
var signer = new sui_js_1.RawSigner(keypair, provider);
|
|
46
46
|
(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
47
|
-
var index, portfolioVaults, portfolioVault, typeArguments, gasBudget,
|
|
47
|
+
var index, portfolioVaults, portfolioVault, typeArguments, gasBudget, transactionBlock;
|
|
48
48
|
return __generator(this, function (_a) {
|
|
49
49
|
switch (_a.label) {
|
|
50
50
|
case 0:
|
|
@@ -56,10 +56,10 @@ var signer = new sui_js_1.RawSigner(keypair, provider);
|
|
|
56
56
|
typeArguments = portfolioVault.typeArgs;
|
|
57
57
|
console.log(portfolioVault);
|
|
58
58
|
gasBudget = 100000;
|
|
59
|
-
return [4 /*yield*/, (0, getHarvestTx_1.getHarvestTx)(gasBudget, constants_1.PORTFOLIO_PACKAGE, constants_1.REGISTRY, typeArguments, index)];
|
|
59
|
+
return [4 /*yield*/, (0, getHarvestTx_1.getHarvestTx)(gasBudget, constants_1.PORTFOLIO_PACKAGE, constants_1.MODULE, constants_1.REGISTRY, typeArguments, index)];
|
|
60
60
|
case 2:
|
|
61
|
-
|
|
62
|
-
return [4 /*yield*/, signer.
|
|
61
|
+
transactionBlock = _a.sent();
|
|
62
|
+
return [4 /*yield*/, signer.signAndExecuteTransactionBlock({ transactionBlock: transactionBlock })];
|
|
63
63
|
case 3:
|
|
64
64
|
_a.sent();
|
|
65
65
|
return [2 /*return*/];
|
|
@@ -44,32 +44,34 @@ var provider = new sui_js_1.JsonRpcProvider(sui_js_1.devnetConnection); //for re
|
|
|
44
44
|
var keypair = sui_js_1.Ed25519Keypair.deriveKeypair(constants_1.TEST_MNEMONIC);
|
|
45
45
|
var signer = new sui_js_1.RawSigner(keypair, provider);
|
|
46
46
|
(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
47
|
-
var size, index, portfolioVaults, portfolioVault, bToken, typeArguments, coinObjs, _a, _b, coins, gasBudget,
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
var size, index, portfolioVaults, portfolioVault, bToken, typeArguments, coinObjs, _a, _b, coins, gasBudget, transactionBlock, res;
|
|
48
|
+
var _c;
|
|
49
|
+
return __generator(this, function (_d) {
|
|
50
|
+
switch (_d.label) {
|
|
50
51
|
case 0:
|
|
51
52
|
size = "100000000";
|
|
52
53
|
index = "0";
|
|
53
54
|
return [4 /*yield*/, (0, getVaultData_1.getVaultDataFromRegistry)(constants_1.REGISTRY, provider)];
|
|
54
55
|
case 1:
|
|
55
|
-
portfolioVaults =
|
|
56
|
+
portfolioVaults = _d.sent();
|
|
56
57
|
portfolioVault = portfolioVaults.find(function (portfolioVault) { return portfolioVault.info.index == index; });
|
|
57
58
|
console.log(portfolioVault);
|
|
58
59
|
bToken = portfolioVault.typeArgs[1];
|
|
59
60
|
typeArguments = portfolioVault.typeArgs;
|
|
60
|
-
_b = (_a = provider).
|
|
61
|
+
_b = (_a = provider).getCoins;
|
|
62
|
+
_c = {};
|
|
61
63
|
return [4 /*yield*/, signer.getAddress()];
|
|
62
|
-
case 2: return [4 /*yield*/, _b.apply(_a, [_c.sent(),
|
|
64
|
+
case 2: return [4 /*yield*/, _b.apply(_a, [(_c.owner = _d.sent(), _c.coinType = bToken, _c)])];
|
|
63
65
|
case 3:
|
|
64
|
-
coinObjs =
|
|
65
|
-
coins = coinObjs.map(function (coin) { return coin.
|
|
66
|
+
coinObjs = _d.sent();
|
|
67
|
+
coins = coinObjs.data.map(function (coin) { return coin.coinObjectId; });
|
|
66
68
|
gasBudget = 100000;
|
|
67
|
-
return [4 /*yield*/, (0, getNewBidTx_1.getNewBidTx)(gasBudget, constants_1.PORTFOLIO_PACKAGE, constants_1.REGISTRY, typeArguments, index, constants_1.DOGE_ORACLE, constants_1.TIME_ORACLE, coins, size)];
|
|
69
|
+
return [4 /*yield*/, (0, getNewBidTx_1.getNewBidTx)(gasBudget, constants_1.PORTFOLIO_PACKAGE, constants_1.MODULE, constants_1.REGISTRY, typeArguments, index, constants_1.DOGE_ORACLE, constants_1.TIME_ORACLE, coins, size)];
|
|
68
70
|
case 4:
|
|
69
|
-
|
|
70
|
-
return [4 /*yield*/, signer.
|
|
71
|
+
transactionBlock = _d.sent();
|
|
72
|
+
return [4 /*yield*/, signer.signAndExecuteTransactionBlock({ transactionBlock: transactionBlock })];
|
|
71
73
|
case 5:
|
|
72
|
-
res =
|
|
74
|
+
res = _d.sent();
|
|
73
75
|
console.log(res);
|
|
74
76
|
return [2 /*return*/];
|
|
75
77
|
}
|
|
@@ -44,7 +44,7 @@ var provider = new sui_js_1.JsonRpcProvider(sui_js_1.devnetConnection); //for re
|
|
|
44
44
|
var keypair = sui_js_1.Ed25519Keypair.deriveKeypair(constants_1.TEST_MNEMONIC);
|
|
45
45
|
var signer = new sui_js_1.RawSigner(keypair, provider);
|
|
46
46
|
(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
47
|
-
var index, share, portfolioVaults, portfolioVault, typeArguments, gasBudget,
|
|
47
|
+
var index, share, portfolioVaults, portfolioVault, typeArguments, gasBudget, transactionBlock;
|
|
48
48
|
return __generator(this, function (_a) {
|
|
49
49
|
switch (_a.label) {
|
|
50
50
|
case 0:
|
|
@@ -57,10 +57,10 @@ var signer = new sui_js_1.RawSigner(keypair, provider);
|
|
|
57
57
|
typeArguments = portfolioVault.typeArgs;
|
|
58
58
|
console.log(portfolioVault);
|
|
59
59
|
gasBudget = 100000;
|
|
60
|
-
return [4 /*yield*/, (0, getUnsubscribeTx_1.getUnsubscribeTx)(gasBudget, constants_1.PORTFOLIO_PACKAGE, constants_1.REGISTRY, typeArguments, index, [share])];
|
|
60
|
+
return [4 /*yield*/, (0, getUnsubscribeTx_1.getUnsubscribeTx)(gasBudget, constants_1.PORTFOLIO_PACKAGE, constants_1.MODULE, constants_1.REGISTRY, typeArguments, index, [share])];
|
|
61
61
|
case 2:
|
|
62
|
-
|
|
63
|
-
return [4 /*yield*/, signer.
|
|
62
|
+
transactionBlock = _a.sent();
|
|
63
|
+
return [4 /*yield*/, signer.signAndExecuteTransactionBlock({ transactionBlock: transactionBlock })];
|
|
64
64
|
case 3:
|
|
65
65
|
_a.sent();
|
|
66
66
|
return [2 /*return*/];
|
|
@@ -44,23 +44,24 @@ var provider = new sui_js_1.JsonRpcProvider(sui_js_1.devnetConnection); //for re
|
|
|
44
44
|
var keypair = sui_js_1.Ed25519Keypair.deriveKeypair(constants_1.TEST_MNEMONIC);
|
|
45
45
|
var signer = new sui_js_1.RawSigner(keypair, provider);
|
|
46
46
|
(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
47
|
-
var share, portfolioVaults, portfolioVault, typeArguments, vaultIndex, gasBudget,
|
|
47
|
+
var share, index, portfolioVaults, portfolioVault, typeArguments, vaultIndex, gasBudget, transactionBlock, res;
|
|
48
48
|
return __generator(this, function (_a) {
|
|
49
49
|
switch (_a.label) {
|
|
50
50
|
case 0:
|
|
51
|
-
share = "
|
|
51
|
+
share = "50000000";
|
|
52
|
+
index = "1";
|
|
52
53
|
return [4 /*yield*/, (0, getVaultData_1.getVaultDataFromRegistry)(constants_1.REGISTRY, provider)];
|
|
53
54
|
case 1:
|
|
54
55
|
portfolioVaults = _a.sent();
|
|
55
|
-
portfolioVault = portfolioVaults
|
|
56
|
+
portfolioVault = portfolioVaults.find(function (portfolioVault) { return portfolioVault.info.index == index; });
|
|
56
57
|
console.log(portfolioVault);
|
|
57
58
|
typeArguments = portfolioVault.typeArgs;
|
|
58
59
|
vaultIndex = portfolioVault.info.index;
|
|
59
|
-
gasBudget =
|
|
60
|
-
return [4 /*yield*/, (0, getWithdrawTx_1.getWithdrawTx)(gasBudget, constants_1.PORTFOLIO_PACKAGE, constants_1.REGISTRY, typeArguments, vaultIndex, [share])];
|
|
60
|
+
gasBudget = 100000000;
|
|
61
|
+
return [4 /*yield*/, (0, getWithdrawTx_1.getWithdrawTx)(gasBudget, constants_1.PORTFOLIO_PACKAGE, constants_1.MODULE, constants_1.REGISTRY, typeArguments, vaultIndex, [share])];
|
|
61
62
|
case 2:
|
|
62
|
-
|
|
63
|
-
return [4 /*yield*/, signer.
|
|
63
|
+
transactionBlock = _a.sent();
|
|
64
|
+
return [4 /*yield*/, signer.signAndExecuteTransactionBlock({ transactionBlock: transactionBlock })];
|
|
64
65
|
case 3:
|
|
65
66
|
res = _a.sent();
|
|
66
67
|
console.log(res);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { JsonRpcProvider } from
|
|
2
|
-
import { Bid } from "../fetchData";
|
|
3
|
-
export declare function getBid(
|
|
1
|
+
import { JsonRpcProvider } from "@mysten/sui.js";
|
|
2
|
+
import { Bid, PortfolioVault } from "../fetchData";
|
|
3
|
+
export declare function getBid(portfolioVault: PortfolioVault, provider: JsonRpcProvider): Promise<Bid[]>;
|
|
@@ -38,33 +38,31 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.getBid = void 0;
|
|
40
40
|
var constants_1 = require("../../constants");
|
|
41
|
-
function getBid(
|
|
41
|
+
function getBid(portfolioVault, provider) {
|
|
42
42
|
return __awaiter(this, void 0, void 0, function () {
|
|
43
|
-
var
|
|
43
|
+
var obj2, ids, tmp, bids;
|
|
44
44
|
return __generator(this, function (_a) {
|
|
45
45
|
switch (_a.label) {
|
|
46
|
-
case 0: return [4 /*yield*/, provider.
|
|
46
|
+
case 0: return [4 /*yield*/, provider.getDynamicFields({ parentId: portfolioVault.auction.bids })];
|
|
47
47
|
case 1:
|
|
48
|
-
obj = _a.sent();
|
|
49
|
-
if (obj.status != "Exists") {
|
|
50
|
-
console.log("obj not exists");
|
|
51
|
-
return [2 /*return*/, []];
|
|
52
|
-
}
|
|
53
|
-
bidTable = obj.details.data.fields.value.fields.auction.fields.bids.fields.id.id;
|
|
54
|
-
return [4 /*yield*/, provider.getDynamicFields(bidTable)];
|
|
55
|
-
case 2:
|
|
56
48
|
obj2 = (_a.sent()).data;
|
|
57
49
|
ids = obj2.map(function (e) { return e.objectId; });
|
|
58
|
-
return [4 /*yield*/, provider.
|
|
59
|
-
|
|
50
|
+
return [4 /*yield*/, provider.multiGetObjects({
|
|
51
|
+
ids: ids,
|
|
52
|
+
options: { showContent: true },
|
|
53
|
+
})];
|
|
54
|
+
case 2:
|
|
60
55
|
tmp = _a.sent();
|
|
61
56
|
bids = tmp.map(function (e) {
|
|
62
|
-
var
|
|
57
|
+
var _a;
|
|
58
|
+
//@ts-ignore
|
|
59
|
+
var bidData = (_a = e.data) === null || _a === void 0 ? void 0 : _a.content.fields.value.fields;
|
|
60
|
+
// console.log(bidData);
|
|
63
61
|
var res = {
|
|
64
|
-
price:
|
|
65
|
-
size: Number(bidData.size /
|
|
66
|
-
tsMs:
|
|
67
|
-
tokenBalance:
|
|
62
|
+
price: bidData.price,
|
|
63
|
+
size: Number(bidData.size / Math.pow(10, constants_1.TOKEN_DECIMAL)).toString(),
|
|
64
|
+
tsMs: bidData.ts_ms,
|
|
65
|
+
tokenBalance: bidData.balance,
|
|
68
66
|
ownerAddress: bidData.bidder,
|
|
69
67
|
};
|
|
70
68
|
return res;
|
package/lib/utils/fetchData.d.ts
CHANGED
package/lib/utils/fetchData.js
CHANGED
|
@@ -3,13 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.parseSubVault = exports.parsePayoffConfig = exports.parseVaultConfig = void 0;
|
|
4
4
|
var sui_js_1 = require("@mysten/sui.js");
|
|
5
5
|
var provider = new sui_js_1.JsonRpcProvider(sui_js_1.devnetConnection); //for read only operations
|
|
6
|
-
var decode = function (str) {
|
|
7
|
-
return Buffer.from(str, "base64").toString("binary");
|
|
8
|
-
};
|
|
6
|
+
var decode = function (str) { return Buffer.from(str, "base64").toString("binary"); };
|
|
9
7
|
function parseVaultConfig(vaultConfigF) {
|
|
10
|
-
var payoffConfigs = vaultConfigF.payoff_configs.map(function (x) {
|
|
11
|
-
return parsePayoffConfig(x.fields);
|
|
12
|
-
});
|
|
8
|
+
var payoffConfigs = vaultConfigF.payoff_configs.map(function (x) { return parsePayoffConfig(x.fields); });
|
|
13
9
|
return {
|
|
14
10
|
payoffConfigs: payoffConfigs,
|
|
15
11
|
strikeIncrement: vaultConfigF.strike_increment,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { JsonRpcProvider } from "@mysten/sui.js";
|
|
2
|
-
export declare function getTypeArgumentFromToken(token: string, provider: JsonRpcProvider): Promise<
|
|
2
|
+
export declare function getTypeArgumentFromToken(token: string, provider: JsonRpcProvider): Promise<string | undefined>;
|
|
@@ -52,7 +52,7 @@ function getTypeArgumentFromToken(token, provider) {
|
|
|
52
52
|
tokenInfo = _a.sent();
|
|
53
53
|
if (tokenInfo.error !== undefined) {
|
|
54
54
|
console.log("obj not exists, but is:");
|
|
55
|
-
console.log(tokenInfo.error.
|
|
55
|
+
console.log(tokenInfo.error.code);
|
|
56
56
|
return [2 /*return*/];
|
|
57
57
|
}
|
|
58
58
|
1;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { JsonRpcProvider } from "@mysten/sui.js";
|
|
2
2
|
import { PortfolioVault } from "./fetchData";
|
|
3
|
-
export declare function getVaultDataFromRegistry(registry: string, provider: JsonRpcProvider): Promise<PortfolioVault[]>;
|
|
3
|
+
export declare function getVaultDataFromRegistry(registry: string, provider: JsonRpcProvider, index?: string): Promise<PortfolioVault[]>;
|
|
4
4
|
export declare function getNodesKeyFromLinkedList(linkedList: string, provider: JsonRpcProvider): Promise<string[]>;
|
|
@@ -49,7 +49,7 @@ var __values = (this && this.__values) || function(o) {
|
|
|
49
49
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
50
|
exports.getNodesKeyFromLinkedList = exports.getVaultDataFromRegistry = void 0;
|
|
51
51
|
var fetchData_1 = require("./fetchData");
|
|
52
|
-
function getVaultDataFromRegistry(registry, provider) {
|
|
52
|
+
function getVaultDataFromRegistry(registry, provider, index) {
|
|
53
53
|
return __awaiter(this, void 0, void 0, function () {
|
|
54
54
|
var vaults, coveredCallVaults, coveredCallVaultsId, objsInfo, objsInfo_1, objsInfo_1_1, objInfo, vaultId, type, typeArgs, assets, infoFields, deliveryInfo, fields, info, config, configRes, depositVaultField, depositVault, bidVaultField, bidVault, auctionField, auctionRes, auction, priceConfig, priceConfigRes, tvl, authorityId, authority, portfolioVaults, e_1_1;
|
|
55
55
|
var e_1, _a;
|
|
@@ -62,7 +62,11 @@ function getVaultDataFromRegistry(registry, provider) {
|
|
|
62
62
|
})];
|
|
63
63
|
case 1:
|
|
64
64
|
coveredCallVaults = (_b.sent()).data;
|
|
65
|
+
if (index) {
|
|
66
|
+
coveredCallVaults = coveredCallVaults.filter(function (e) { return e.name.value == index; });
|
|
67
|
+
}
|
|
65
68
|
coveredCallVaultsId = coveredCallVaults.map(function (e) { return e.objectId; });
|
|
69
|
+
console.log(coveredCallVaultsId);
|
|
66
70
|
return [4 /*yield*/, provider.multiGetObjects({
|
|
67
71
|
ids: coveredCallVaultsId,
|
|
68
72
|
options: { showContent: true },
|
|
@@ -122,8 +126,7 @@ function getVaultDataFromRegistry(registry, provider) {
|
|
|
122
126
|
bTokenDecimal: config.b_token_decimal,
|
|
123
127
|
oTokenDecimal: config.o_token_decimal,
|
|
124
128
|
lotSize: config.lot_size,
|
|
125
|
-
capacity: (Number(config.capacity) /
|
|
126
|
-
Math.pow(10, config.d_token_decimal)).toString(),
|
|
129
|
+
capacity: (Number(config.capacity) / Math.pow(10, config.d_token_decimal)).toString(),
|
|
127
130
|
leverage: config.leverage,
|
|
128
131
|
hasNext: config.has_next,
|
|
129
132
|
activeVaultConfig: (0, fetchData_1.parseVaultConfig)(config.active_vault_config.fields),
|
|
@@ -163,6 +166,8 @@ function getVaultDataFromRegistry(registry, provider) {
|
|
|
163
166
|
endTsMs: auction.end_ts_ms,
|
|
164
167
|
priceConfig: priceConfigRes,
|
|
165
168
|
index: auction.index,
|
|
169
|
+
bids: auction.bids.fields.id.id,
|
|
170
|
+
ownerships: auction.ownerships.fields.id.id,
|
|
166
171
|
totalBidSize: auction.total_bid_size,
|
|
167
172
|
ableToRemoveBid: auction.able_to_remove_bid,
|
|
168
173
|
};
|
|
@@ -170,12 +175,10 @@ function getVaultDataFromRegistry(registry, provider) {
|
|
|
170
175
|
else {
|
|
171
176
|
auctionRes = {};
|
|
172
177
|
}
|
|
173
|
-
tvl = Number(depositVault.activeSubVault.balance) +
|
|
174
|
-
Number(depositVault.warmupSubVault.balance);
|
|
178
|
+
tvl = Number(depositVault.activeSubVault.balance) + Number(depositVault.warmupSubVault.balance);
|
|
175
179
|
authorityId =
|
|
176
180
|
// @ts-ignore
|
|
177
|
-
objInfo.data.content.fields.value.fields.authority.fields.whitelist.fields
|
|
178
|
-
.id.id;
|
|
181
|
+
objInfo.data.content.fields.value.fields.authority.fields.whitelist.fields.id.id;
|
|
179
182
|
return [4 /*yield*/, getNodesKeyFromLinkedList(authorityId, provider)];
|
|
180
183
|
case 5:
|
|
181
184
|
authority = _b.sent();
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { JsonRpcProvider } from "@mysten/sui.js";
|
|
2
|
-
export declare function getWhiteListFromRegistry(registry: string, provider: JsonRpcProvider): Promise<
|
|
2
|
+
export declare function getWhiteListFromRegistry(registry: string, provider: JsonRpcProvider): Promise<string[]>;
|
|
@@ -40,15 +40,13 @@ exports.getWhiteListFromRegistry = void 0;
|
|
|
40
40
|
function getWhiteListFromRegistry(registry, provider) {
|
|
41
41
|
var _a;
|
|
42
42
|
return __awaiter(this, void 0, void 0, function () {
|
|
43
|
-
var
|
|
43
|
+
var registryInfo, whiteListsTable, whiteListsNodes, whiteListsTablesId, whiteListsTableAddress;
|
|
44
44
|
return __generator(this, function (_b) {
|
|
45
45
|
switch (_b.label) {
|
|
46
|
-
case 0:
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
options: { showContent: true },
|
|
51
|
-
})];
|
|
46
|
+
case 0: return [4 /*yield*/, provider.getObject({
|
|
47
|
+
id: registry,
|
|
48
|
+
options: { showContent: true },
|
|
49
|
+
})];
|
|
52
50
|
case 1:
|
|
53
51
|
registryInfo = _b.sent();
|
|
54
52
|
whiteListsTable =
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
+
import { TransactionBlock } from "@mysten/sui.js";
|
|
1
2
|
/**
|
|
2
3
|
* @param typeArguments [D_TOKEN, B_TOKEN, O_TOKEN]
|
|
3
|
-
*/
|
|
4
|
-
export declare function getAuthorizedAddPortfolioVaultAuthorizedUserTx(gasBudget: number, packageId: string, registry: string, typeArguments: string[], index: string,
|
|
4
|
+
*/
|
|
5
|
+
export declare function getAuthorizedAddPortfolioVaultAuthorizedUserTx(gasBudget: number, packageId: string, registry: string, typeArguments: string[], index: string, users: string[]): Promise<TransactionBlock>;
|
|
@@ -37,25 +37,23 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.getAuthorizedAddPortfolioVaultAuthorizedUserTx = void 0;
|
|
40
|
+
var sui_js_1 = require("@mysten/sui.js");
|
|
40
41
|
/**
|
|
41
42
|
* @param typeArguments [D_TOKEN, B_TOKEN, O_TOKEN]
|
|
42
|
-
*/
|
|
43
|
-
function getAuthorizedAddPortfolioVaultAuthorizedUserTx(gasBudget, packageId, registry, typeArguments, index,
|
|
43
|
+
*/
|
|
44
|
+
function getAuthorizedAddPortfolioVaultAuthorizedUserTx(gasBudget, packageId, registry, typeArguments, index, users) {
|
|
44
45
|
return __awaiter(this, void 0, void 0, function () {
|
|
45
|
-
var tx;
|
|
46
|
+
var tx, target, txArguments;
|
|
46
47
|
return __generator(this, function (_a) {
|
|
47
|
-
tx =
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
tx = new sui_js_1.TransactionBlock();
|
|
49
|
+
target = "".concat(packageId, "::").concat(module, "::authorized_add_portfolio_vault_authorized_user");
|
|
50
|
+
txArguments = [tx.pure(registry), tx.pure(index), tx.pure(users)];
|
|
51
|
+
tx.moveCall({
|
|
52
|
+
target: target,
|
|
51
53
|
typeArguments: typeArguments,
|
|
52
|
-
arguments:
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
addresses,
|
|
56
|
-
],
|
|
57
|
-
gasBudget: gasBudget,
|
|
58
|
-
};
|
|
54
|
+
arguments: txArguments,
|
|
55
|
+
});
|
|
56
|
+
tx.setGasBudget(gasBudget);
|
|
59
57
|
return [2 /*return*/, tx];
|
|
60
58
|
});
|
|
61
59
|
});
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { TransactionBlock } from "@mysten/sui.js";
|
|
2
|
+
export declare function getAuthorizedDeliveryTx(gasBudget: number, packageId: string, registry: string, typeArguments: string[], index: string, priceOracle: string, timeOracle: string): Promise<TransactionBlock>;
|
|
@@ -37,23 +37,25 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.getAuthorizedDeliveryTx = void 0;
|
|
40
|
+
var sui_js_1 = require("@mysten/sui.js");
|
|
40
41
|
function getAuthorizedDeliveryTx(gasBudget, packageId, registry, typeArguments, index, priceOracle, timeOracle) {
|
|
41
42
|
return __awaiter(this, void 0, void 0, function () {
|
|
42
|
-
var tx;
|
|
43
|
+
var tx, target, txArguments;
|
|
43
44
|
return __generator(this, function (_a) {
|
|
44
|
-
tx =
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
tx = new sui_js_1.TransactionBlock();
|
|
46
|
+
target = "".concat(packageId, "::").concat(module, "::authorized_delivery");
|
|
47
|
+
txArguments = [
|
|
48
|
+
tx.pure(registry),
|
|
49
|
+
tx.pure(index),
|
|
50
|
+
tx.pure(priceOracle),
|
|
51
|
+
tx.pure(timeOracle),
|
|
52
|
+
];
|
|
53
|
+
tx.moveCall({
|
|
54
|
+
target: target,
|
|
48
55
|
typeArguments: typeArguments,
|
|
49
|
-
arguments:
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
priceOracle,
|
|
53
|
-
timeOracle,
|
|
54
|
-
],
|
|
55
|
-
gasBudget: gasBudget,
|
|
56
|
-
};
|
|
56
|
+
arguments: txArguments,
|
|
57
|
+
});
|
|
58
|
+
tx.setGasBudget(gasBudget);
|
|
57
59
|
return [2 /*return*/, tx];
|
|
58
60
|
});
|
|
59
61
|
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { TransactionBlock } from "@mysten/sui.js";
|
|
1
2
|
/**
|
|
2
3
|
* registry: & mut Registry,
|
|
3
4
|
time_oracle: & Time,
|
|
@@ -35,4 +36,4 @@ strikePct: string[], // vector<u64>
|
|
|
35
36
|
weight: string[], // vector<u64>
|
|
36
37
|
isBuyer: boolean[], // vector<bool>
|
|
37
38
|
strikeIncrement: string, // u64
|
|
38
|
-
lotSize: string, decaySpeed: string, initialPrice: string, finalPrice: string, auctionDurationInMs: string, whitelist: string[], leverage: string, hasNext: boolean): Promise<
|
|
39
|
+
lotSize: string, decaySpeed: string, initialPrice: string, finalPrice: string, auctionDurationInMs: string, whitelist: string[], leverage: string, hasNext: boolean): Promise<TransactionBlock>;
|
|
@@ -37,6 +37,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.getAuthorizedNewPortfolioVaultTx = void 0;
|
|
40
|
+
var sui_js_1 = require("@mysten/sui.js");
|
|
40
41
|
/**
|
|
41
42
|
* registry: & mut Registry,
|
|
42
43
|
time_oracle: & Time,
|
|
@@ -74,41 +75,42 @@ strikePct, // vector<u64>
|
|
|
74
75
|
weight, // vector<u64>
|
|
75
76
|
isBuyer, // vector<bool>
|
|
76
77
|
strikeIncrement, // u64
|
|
77
|
-
lotSize, decaySpeed, initialPrice, finalPrice, auctionDurationInMs, whitelist, leverage, hasNext
|
|
78
|
+
lotSize, decaySpeed, initialPrice, finalPrice, auctionDurationInMs, whitelist, leverage, hasNext // bool
|
|
79
|
+
) {
|
|
78
80
|
return __awaiter(this, void 0, void 0, function () {
|
|
79
|
-
var tx;
|
|
81
|
+
var tx, target, txArguments;
|
|
80
82
|
return __generator(this, function (_a) {
|
|
81
|
-
tx =
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
tx = new sui_js_1.TransactionBlock();
|
|
84
|
+
target = "".concat(packageId, "::").concat(module, "::authorized_new_portfolio_vault");
|
|
85
|
+
txArguments = [
|
|
86
|
+
tx.pure(registry),
|
|
87
|
+
tx.pure(timeOracle),
|
|
88
|
+
tx.pure(optionType),
|
|
89
|
+
tx.pure(period),
|
|
90
|
+
tx.pure(activationTsMs),
|
|
91
|
+
tx.pure(expirationTsMs),
|
|
92
|
+
tx.pure(dTokenDecimal),
|
|
93
|
+
tx.pure(bTokenDecimal),
|
|
94
|
+
tx.pure(oTokenDecimal),
|
|
95
|
+
tx.pure(capacity),
|
|
96
|
+
tx.pure(strikePct),
|
|
97
|
+
tx.pure(weight),
|
|
98
|
+
tx.pure(isBuyer),
|
|
99
|
+
tx.pure(strikeIncrement),
|
|
100
|
+
tx.pure(lotSize),
|
|
101
|
+
tx.pure(decaySpeed),
|
|
102
|
+
tx.pure(initialPrice),
|
|
103
|
+
tx.pure(finalPrice),
|
|
104
|
+
tx.pure(auctionDurationInMs),
|
|
105
|
+
tx.pure(leverage),
|
|
106
|
+
tx.pure(whitelist),
|
|
107
|
+
];
|
|
108
|
+
tx.moveCall({
|
|
109
|
+
target: target,
|
|
85
110
|
typeArguments: typeArguments,
|
|
86
|
-
arguments:
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
optionType,
|
|
90
|
-
period,
|
|
91
|
-
activationTsMs,
|
|
92
|
-
expirationTsMs,
|
|
93
|
-
dTokenDecimal,
|
|
94
|
-
bTokenDecimal,
|
|
95
|
-
oTokenDecimal,
|
|
96
|
-
capacity,
|
|
97
|
-
strikePct,
|
|
98
|
-
weight,
|
|
99
|
-
isBuyer,
|
|
100
|
-
strikeIncrement,
|
|
101
|
-
lotSize,
|
|
102
|
-
decaySpeed,
|
|
103
|
-
initialPrice,
|
|
104
|
-
finalPrice,
|
|
105
|
-
auctionDurationInMs,
|
|
106
|
-
leverage,
|
|
107
|
-
hasNext,
|
|
108
|
-
whitelist,
|
|
109
|
-
],
|
|
110
|
-
gasBudget: gasBudget,
|
|
111
|
-
};
|
|
111
|
+
arguments: txArguments,
|
|
112
|
+
});
|
|
113
|
+
tx.setGasBudget(gasBudget);
|
|
112
114
|
return [2 /*return*/, tx];
|
|
113
115
|
});
|
|
114
116
|
});
|
package/lib/utils/portfolio/authorized/getAuthorizedRemovePortfolioVaultAuthorizedUserTx.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
+
import { TransactionBlock } from "@mysten/sui.js";
|
|
1
2
|
/**
|
|
2
3
|
* @param typeArguments [D_TOKEN, B_TOKEN, O_TOKEN]
|
|
3
|
-
*/
|
|
4
|
-
export declare function getAuthorizedRemovePortfolioVaultAuthorizedUserTx(gasBudget: number, packageId: string, registry: string, typeArguments: string[], index: string,
|
|
4
|
+
*/
|
|
5
|
+
export declare function getAuthorizedRemovePortfolioVaultAuthorizedUserTx(gasBudget: number, packageId: string, registry: string, typeArguments: string[], index: string, users: string[]): Promise<TransactionBlock>;
|
|
@@ -37,25 +37,23 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.getAuthorizedRemovePortfolioVaultAuthorizedUserTx = void 0;
|
|
40
|
+
var sui_js_1 = require("@mysten/sui.js");
|
|
40
41
|
/**
|
|
41
42
|
* @param typeArguments [D_TOKEN, B_TOKEN, O_TOKEN]
|
|
42
|
-
*/
|
|
43
|
-
function getAuthorizedRemovePortfolioVaultAuthorizedUserTx(gasBudget, packageId, registry, typeArguments, index,
|
|
43
|
+
*/
|
|
44
|
+
function getAuthorizedRemovePortfolioVaultAuthorizedUserTx(gasBudget, packageId, registry, typeArguments, index, users) {
|
|
44
45
|
return __awaiter(this, void 0, void 0, function () {
|
|
45
|
-
var tx;
|
|
46
|
+
var tx, target, txArguments;
|
|
46
47
|
return __generator(this, function (_a) {
|
|
47
|
-
tx =
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
tx = new sui_js_1.TransactionBlock();
|
|
49
|
+
target = "".concat(packageId, "::").concat(module, "::authorized_remove_portfolio_vault_authorized_user");
|
|
50
|
+
txArguments = [tx.pure(registry), tx.pure(index), tx.pure(users)];
|
|
51
|
+
tx.moveCall({
|
|
52
|
+
target: target,
|
|
51
53
|
typeArguments: typeArguments,
|
|
52
|
-
arguments:
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
addresses,
|
|
56
|
-
],
|
|
57
|
-
gasBudget: gasBudget,
|
|
58
|
-
};
|
|
54
|
+
arguments: txArguments,
|
|
55
|
+
});
|
|
56
|
+
tx.setGasBudget(gasBudget);
|
|
59
57
|
return [2 /*return*/, tx];
|
|
60
58
|
});
|
|
61
59
|
});
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { TransactionBlock } from "@mysten/sui.js";
|
|
2
|
+
export declare function getAuthorizedUpdateCapacityTx(gasBudget: number, packageId: string, typeArguments: string[], registry: string, index: string, capacity: string): Promise<TransactionBlock>;
|