@typus/typus-sdk 1.0.6 → 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/mnemonic.json +1 -3
- package/lib/test/getBidData.js +11 -4
- package/lib/test/helper/getAuctionMaxSize.js +3 -3
- package/lib/test/helper/getUserStatus.js +2 -2
- package/lib/utils/auction/getBid.d.ts +2 -2
- package/lib/utils/auction/getBid.js +5 -12
- package/lib/utils/fetchData.d.ts +2 -0
- package/lib/utils/getVaultData.js +2 -0
- package/package.json +1 -1
package/lib/mnemonic.json
CHANGED
package/lib/test/getBidData.js
CHANGED
|
@@ -38,15 +38,22 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
var getBid_1 = require("../utils/auction/getBid");
|
|
40
40
|
var sui_js_1 = require("@mysten/sui.js");
|
|
41
|
-
var
|
|
41
|
+
var getVaultData_1 = require("../utils/getVaultData");
|
|
42
|
+
var constants_1 = require("../constants");
|
|
43
|
+
var provider = new sui_js_1.JsonRpcProvider(constants_1.testnetConnection); //for read only operations
|
|
42
44
|
(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
43
|
-
var
|
|
45
|
+
var index, portfolioVaults, portfolioVault, bid;
|
|
44
46
|
return __generator(this, function (_a) {
|
|
45
47
|
switch (_a.label) {
|
|
46
48
|
case 0:
|
|
47
|
-
|
|
48
|
-
return [4 /*yield*/, (0,
|
|
49
|
+
index = "1";
|
|
50
|
+
return [4 /*yield*/, (0, getVaultData_1.getVaultDataFromRegistry)(constants_1.REGISTRY, provider, index)];
|
|
49
51
|
case 1:
|
|
52
|
+
portfolioVaults = _a.sent();
|
|
53
|
+
portfolioVault = portfolioVaults[0];
|
|
54
|
+
console.log(portfolioVault);
|
|
55
|
+
return [4 /*yield*/, (0, getBid_1.getBid)(portfolioVault, provider)];
|
|
56
|
+
case 2:
|
|
50
57
|
bid = _a.sent();
|
|
51
58
|
console.log(bid);
|
|
52
59
|
return [2 /*return*/];
|
|
@@ -48,12 +48,12 @@ var provider = new sui_js_1.JsonRpcProvider(constants_1.testnetConnection); //fo
|
|
|
48
48
|
switch (_a.label) {
|
|
49
49
|
case 0:
|
|
50
50
|
sender = "0xb6c7e3b1c61ee81516a8317f221daa035f1503e0ac3ae7a50b61834bc7a3ead9";
|
|
51
|
-
oracle = constants_1.
|
|
51
|
+
oracle = constants_1.BTC_ORACLE;
|
|
52
52
|
index = "1";
|
|
53
|
-
return [4 /*yield*/, (0, getVaultData_1.getVaultDataFromRegistry)(constants_1.REGISTRY, provider)];
|
|
53
|
+
return [4 /*yield*/, (0, getVaultData_1.getVaultDataFromRegistry)(constants_1.REGISTRY, provider, index)];
|
|
54
54
|
case 1:
|
|
55
55
|
portfolioVaults = _a.sent();
|
|
56
|
-
portfolioVault = portfolioVaults
|
|
56
|
+
portfolioVault = portfolioVaults[0];
|
|
57
57
|
console.log(portfolioVault);
|
|
58
58
|
console.log(portfolioVault.config.activeVaultConfig.payoffConfigs);
|
|
59
59
|
return [4 /*yield*/, (0, getAuctionMaxSize_1.getAuctionMaxSize)(constants_1.PORTFOLIO_PACKAGE, constants_1.MODULE, portfolioVault.typeArgs, constants_1.REGISTRY, portfolioVault.info.index, oracle)];
|
|
@@ -48,10 +48,10 @@ var provider = new sui_js_1.JsonRpcProvider(constants_1.testnetConnection); //fo
|
|
|
48
48
|
case 0:
|
|
49
49
|
sender = "0xb6c7e3b1c61ee81516a8317f221daa035f1503e0ac3ae7a50b61834bc7a3ead9";
|
|
50
50
|
index = "1";
|
|
51
|
-
return [4 /*yield*/, (0, getVaultData_1.getVaultDataFromRegistry)(constants_1.REGISTRY, provider)];
|
|
51
|
+
return [4 /*yield*/, (0, getVaultData_1.getVaultDataFromRegistry)(constants_1.REGISTRY, provider, index)];
|
|
52
52
|
case 1:
|
|
53
53
|
portfolioVaults = _a.sent();
|
|
54
|
-
portfolioVault = portfolioVaults
|
|
54
|
+
portfolioVault = portfolioVaults[0];
|
|
55
55
|
console.log(portfolioVault);
|
|
56
56
|
return [4 /*yield*/, (0, getUserStatus_1.getUserStatus)(constants_1.PORTFOLIO_PACKAGE, constants_1.MODULE, portfolioVault.typeArgs, constants_1.REGISTRY, portfolioVault.info.index, sender)];
|
|
57
57
|
case 2:
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { JsonRpcProvider } from "@mysten/sui.js";
|
|
2
|
-
import { Bid } from "../fetchData";
|
|
3
|
-
export declare function getBid(
|
|
2
|
+
import { Bid, PortfolioVault } from "../fetchData";
|
|
3
|
+
export declare function getBid(portfolioVault: PortfolioVault, provider: JsonRpcProvider): Promise<Bid[]>;
|
|
@@ -38,33 +38,26 @@ 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.error) {
|
|
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({ parentId: bidTable })];
|
|
55
|
-
case 2:
|
|
56
48
|
obj2 = (_a.sent()).data;
|
|
57
49
|
ids = obj2.map(function (e) { return e.objectId; });
|
|
58
50
|
return [4 /*yield*/, provider.multiGetObjects({
|
|
59
51
|
ids: ids,
|
|
60
52
|
options: { showContent: true },
|
|
61
53
|
})];
|
|
62
|
-
case
|
|
54
|
+
case 2:
|
|
63
55
|
tmp = _a.sent();
|
|
64
56
|
bids = tmp.map(function (e) {
|
|
65
57
|
var _a;
|
|
66
58
|
//@ts-ignore
|
|
67
59
|
var bidData = (_a = e.data) === null || _a === void 0 ? void 0 : _a.content.fields.value.fields;
|
|
60
|
+
// console.log(bidData);
|
|
68
61
|
var res = {
|
|
69
62
|
price: bidData.price,
|
|
70
63
|
size: Number(bidData.size / Math.pow(10, constants_1.TOKEN_DECIMAL)).toString(),
|
package/lib/utils/fetchData.d.ts
CHANGED
|
@@ -166,6 +166,8 @@ function getVaultDataFromRegistry(registry, provider, index) {
|
|
|
166
166
|
endTsMs: auction.end_ts_ms,
|
|
167
167
|
priceConfig: priceConfigRes,
|
|
168
168
|
index: auction.index,
|
|
169
|
+
bids: auction.bids.fields.id.id,
|
|
170
|
+
ownerships: auction.ownerships.fields.id.id,
|
|
169
171
|
totalBidSize: auction.total_bid_size,
|
|
170
172
|
ableToRemoveBid: auction.able_to_remove_bid,
|
|
171
173
|
};
|