@sonarwatch/portfolio-plugins 0.11.97 → 0.11.98
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +1091 -1087
- package/README.md +3 -3
- package/package.json +3 -3
- package/src/plugins/aftermath/poolsJob.js +22 -20
- package/src/plugins/aftermath/poolsJob.js.map +1 -1
- package/src/plugins/balancer/helpers/pools.js +21 -21
- package/src/plugins/bucket/collateralFetcher.js +5 -8
- package/src/plugins/bucket/collateralFetcher.js.map +1 -1
- package/src/plugins/cetus/clmmsFetcher.js +5 -5
- package/src/plugins/cetus/clmmsFetcher.js.map +1 -1
- package/src/plugins/cetus/helpers.d.ts +4 -4
- package/src/plugins/cetus/helpers.js +23 -12
- package/src/plugins/cetus/helpers.js.map +1 -1
- package/src/plugins/cetus/poolsJob.js +5 -10
- package/src/plugins/cetus/poolsJob.js.map +1 -1
- package/src/plugins/navi/collateralFetcher.js +8 -7
- package/src/plugins/navi/collateralFetcher.js.map +1 -1
- package/src/plugins/navi/reservesJob.js +5 -4
- package/src/plugins/navi/reservesJob.js.map +1 -1
- package/src/plugins/scallop/helpers.d.ts +0 -49
- package/src/plugins/scallop/helpers.js +1 -39
- package/src/plugins/scallop/helpers.js.map +1 -1
- package/src/plugins/scallop/lendingsFetcher.js +17 -14
- package/src/plugins/scallop/lendingsFetcher.js.map +1 -1
- package/src/plugins/scallop/marketJob.js +16 -16
- package/src/plugins/scallop/marketJob.js.map +1 -1
- package/src/plugins/scallop/obligationsFetcher.js +25 -21
- package/src/plugins/scallop/obligationsFetcher.js.map +1 -1
- package/src/plugins/scallop/poolsJob.js +7 -12
- package/src/plugins/scallop/poolsJob.js.map +1 -1
- package/src/plugins/scallop/spoolsMarketJob.js +8 -15
- package/src/plugins/scallop/spoolsMarketJob.js.map +1 -1
- package/src/plugins/scallop/types/coin.d.ts +1 -1
- package/src/plugins/scallop/types/market.d.ts +3 -4
- package/src/plugins/scallop/types/market.js.map +1 -1
- package/src/plugins/sushiswap/helpers.js +24 -24
- package/src/plugins/tokens/fetchers/sui-nfts.js +47 -107
- package/src/plugins/tokens/fetchers/sui-nfts.js.map +1 -1
- package/src/plugins/tokens/types.d.ts +0 -48
- package/src/plugins/turbos/clmmsPositionsFetcher.js +18 -16
- package/src/plugins/turbos/clmmsPositionsFetcher.js.map +1 -1
- package/src/plugins/turbos/helper.d.ts +3 -3
- package/src/plugins/turbos/helper.js +6 -4
- package/src/plugins/turbos/helper.js.map +1 -1
- package/src/plugins/turbos/poolsJob.js +10 -10
- package/src/plugins/turbos/poolsJob.js.map +1 -1
- package/src/plugins/uniswap-v2/helpers.js +22 -22
- package/src/utils/clients/getClientSui.d.ts +2 -2
- package/src/utils/clients/getClientSui.js +8 -3
- package/src/utils/clients/getClientSui.js.map +1 -1
- package/src/utils/clients/types.d.ts +2 -0
- package/src/utils/sei/constants.js +8 -8
- package/src/utils/sei/getQueryBalanceByOwner.js +4 -4
- package/src/utils/sui/getDynamicFieldObject.d.ts +4 -0
- package/src/utils/sui/{getMultipleObjectsSafe.js → getDynamicFieldObject.js} +9 -13
- package/src/utils/sui/getDynamicFieldObject.js.map +1 -0
- package/src/utils/sui/getDynamicFields.d.ts +3 -0
- package/src/utils/sui/getDynamicFields.js +38 -0
- package/src/utils/sui/getDynamicFields.js.map +1 -0
- package/src/utils/sui/getObject.d.ts +4 -0
- package/src/utils/sui/{getDynamicFieldsSafe.js → getObject.js} +8 -16
- package/src/utils/sui/getObject.js.map +1 -0
- package/src/utils/sui/getObjectDeletedResponse.d.ts +3 -0
- package/src/utils/sui/getObjectDeletedResponse.js +19 -0
- package/src/utils/sui/getObjectDeletedResponse.js.map +1 -0
- package/src/utils/sui/getObjectNotExistsResponse.d.ts +2 -0
- package/src/utils/sui/getObjectNotExistsResponse.js +14 -0
- package/src/utils/sui/getObjectNotExistsResponse.js.map +1 -0
- package/src/utils/sui/getOwnedObjects.d.ts +4 -0
- package/src/utils/sui/getOwnedObjects.js +36 -0
- package/src/utils/sui/getOwnedObjects.js.map +1 -0
- package/src/utils/sui/multiGetObjects.d.ts +4 -0
- package/src/utils/sui/multiGetObjects.js +32 -0
- package/src/utils/sui/multiGetObjects.js.map +1 -0
- package/src/utils/sui/queryEvents.d.ts +4 -0
- package/src/utils/sui/{queryEventSafe.js → queryEvents.js} +16 -12
- package/src/utils/sui/queryEvents.js.map +1 -0
- package/src/utils/sui/structs/kiosk.d.ts +7 -0
- package/src/utils/sui/structs/kiosk.js +3 -0
- package/src/utils/sui/structs/kiosk.js.map +1 -0
- package/src/utils/sui/structs/nft.d.ts +41 -0
- package/src/utils/sui/structs/nft.js +3 -0
- package/src/utils/sui/structs/nft.js.map +1 -0
- package/src/utils/sui/types.d.ts +23 -0
- package/src/utils/sui/types.js +3 -0
- package/src/utils/sui/types.js.map +1 -0
- package/src/utils/sui/getDynamicFieldsSafe.d.ts +0 -13
- package/src/utils/sui/getDynamicFieldsSafe.js.map +0 -1
- package/src/utils/sui/getFormattedCollectionNameAndId.d.ts +0 -4
- package/src/utils/sui/getFormattedCollectionNameAndId.js +0 -19
- package/src/utils/sui/getFormattedCollectionNameAndId.js.map +0 -1
- package/src/utils/sui/getMultipleObjectsSafe.d.ts +0 -67
- package/src/utils/sui/getMultipleObjectsSafe.js.map +0 -1
- package/src/utils/sui/queryEventSafe.d.ts +0 -14
- package/src/utils/sui/queryEventSafe.js.map +0 -1
package/README.md
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
# @sonarwatch/portfolio-plugins
|
2
|
-
|
3
|
-
This library is @sonarwatch/portfolio-plugins
|
1
|
+
# @sonarwatch/portfolio-plugins
|
2
|
+
|
3
|
+
This library is @sonarwatch/portfolio-plugins
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@sonarwatch/portfolio-plugins",
|
3
|
-
"version": "0.11.
|
3
|
+
"version": "0.11.98",
|
4
4
|
"type": "commonjs",
|
5
5
|
"generators": "./generators.json",
|
6
6
|
"dependencies": {
|
@@ -18,7 +18,7 @@
|
|
18
18
|
"@metaplex-foundation/beet-solana": "^0.4.0",
|
19
19
|
"@metaplex-foundation/js": "^0.19.4",
|
20
20
|
"@metaplex-foundation/umi-serializers-encodings": "^0.8.9",
|
21
|
-
"@mysten/sui.js": "^0.
|
21
|
+
"@mysten/sui.js": "^0.50.1",
|
22
22
|
"@onsol/tldparser": "^0.6.1",
|
23
23
|
"@sei-js/core": "^3.0.1",
|
24
24
|
"@sei-js/proto": "^3.0.1",
|
@@ -41,7 +41,7 @@
|
|
41
41
|
"web3-v1": "npm:web3@^1.5.0"
|
42
42
|
},
|
43
43
|
"peerDependencies": {
|
44
|
-
"@sonarwatch/portfolio-core": "0.11.
|
44
|
+
"@sonarwatch/portfolio-core": "0.11.98"
|
45
45
|
},
|
46
46
|
"main": "./src/index.js",
|
47
47
|
"types": "./src/index.d.ts"
|
@@ -12,33 +12,31 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
13
|
};
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
15
|
-
const sui_js_1 = require("@mysten/sui.js");
|
16
15
|
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
17
16
|
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
18
17
|
const clients_1 = require("../../utils/clients");
|
19
18
|
const constants_1 = require("./constants");
|
20
19
|
const computeAndStoreLpPrice_1 = require("../../utils/misc/computeAndStoreLpPrice");
|
21
|
-
const getMultipleObjectsSafe_1 = __importDefault(require("../../utils/sui/getMultipleObjectsSafe"));
|
22
|
-
const getDynamicFieldsSafe_1 = __importDefault(require("../../utils/sui/getDynamicFieldsSafe"));
|
23
20
|
const aptos_1 = require("../../utils/aptos");
|
24
21
|
const getTokensPricesMap_1 = __importDefault(require("../../utils/misc/getTokensPricesMap"));
|
25
22
|
const getLpUnderlyingTokenSource_1 = __importDefault(require("../../utils/misc/getLpUnderlyingTokenSource"));
|
26
23
|
const getLpTokenSourceRaw_1 = __importDefault(require("../../utils/misc/getLpTokenSourceRaw"));
|
24
|
+
const getDynamicFields_1 = require("../../utils/sui/getDynamicFields");
|
25
|
+
const multiGetObjects_1 = require("../../utils/sui/multiGetObjects");
|
27
26
|
const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
|
28
|
-
var _a;
|
27
|
+
var _a, _b, _c, _d, _e;
|
29
28
|
const client = (0, clients_1.getClientSui)();
|
30
29
|
const networkId = portfolio_core_1.NetworkId.sui;
|
31
|
-
const coinsTableFields = yield (0,
|
32
|
-
const poolFactoryIds = coinsTableFields.map(
|
30
|
+
const coinsTableFields = yield (0, getDynamicFields_1.getDynamicFields)(client, constants_1.lpCoinsTable);
|
31
|
+
const poolFactoryIds = coinsTableFields.map((f) => f.objectId);
|
33
32
|
if (!poolFactoryIds.length)
|
34
33
|
return;
|
35
|
-
const pObjects = yield (0,
|
36
|
-
showContent: true,
|
37
|
-
});
|
34
|
+
const pObjects = yield (0, multiGetObjects_1.multiGetObjects)(client, poolFactoryIds);
|
38
35
|
const poolsIds = pObjects
|
39
36
|
.map((poolObject) => {
|
40
|
-
|
41
|
-
|
37
|
+
var _a, _b, _c, _d;
|
38
|
+
if ((_b = (_a = poolObject.data) === null || _a === void 0 ? void 0 : _a.content) === null || _b === void 0 ? void 0 : _b.fields) {
|
39
|
+
const fields = (_d = (_c = poolObject.data) === null || _c === void 0 ? void 0 : _c.content) === null || _d === void 0 ? void 0 : _d.fields;
|
42
40
|
if (fields.value)
|
43
41
|
return fields.value;
|
44
42
|
}
|
@@ -47,17 +45,20 @@ const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
|
|
47
45
|
.flat();
|
48
46
|
if (!poolsIds.length)
|
49
47
|
return;
|
50
|
-
const poolsInfo = yield (0,
|
51
|
-
showContent: true,
|
52
|
-
});
|
48
|
+
const poolsInfo = yield (0, multiGetObjects_1.multiGetObjects)(client, poolsIds);
|
53
49
|
const tokenPriceById = yield (0, getTokensPricesMap_1.default)(poolsInfo
|
54
|
-
.map((pool) =>
|
50
|
+
.map((pool) => {
|
51
|
+
var _a, _b, _c, _d;
|
52
|
+
return ((_b = (_a = pool.data) === null || _a === void 0 ? void 0 : _a.content) === null || _b === void 0 ? void 0 : _b.fields)
|
53
|
+
? ((_d = (_c = pool.data) === null || _c === void 0 ? void 0 : _c.content) === null || _d === void 0 ? void 0 : _d.fields).type_names
|
54
|
+
: [];
|
55
|
+
})
|
55
56
|
.flat()
|
56
57
|
.map((type) => `0x${type}`), networkId, cache);
|
57
58
|
for (const pool of poolsInfo) {
|
58
|
-
if (!pool.data ||
|
59
|
+
if (!((_b = (_a = pool.data) === null || _a === void 0 ? void 0 : _a.content) === null || _b === void 0 ? void 0 : _b.fields))
|
59
60
|
continue;
|
60
|
-
const poolInfo = (0
|
61
|
+
const poolInfo = (_d = (_c = pool.data) === null || _c === void 0 ? void 0 : _c.content) === null || _d === void 0 ? void 0 : _d.fields;
|
61
62
|
if (poolInfo.lp_supply.fields.value === '0')
|
62
63
|
continue;
|
63
64
|
const moveType = (0, aptos_1.parseTypeString)(poolInfo.lp_supply.type);
|
@@ -73,7 +74,7 @@ const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
|
|
73
74
|
const tokensPrices = rawTokensPrices.filter((tokenPrice) => tokenPrice !== undefined);
|
74
75
|
if (tokensPrices.length === 0)
|
75
76
|
continue;
|
76
|
-
const tokenPriceRef = (
|
77
|
+
const tokenPriceRef = (_e = tokensPrices[0]) === null || _e === void 0 ? void 0 : _e.price;
|
77
78
|
if (!tokenPriceRef)
|
78
79
|
continue;
|
79
80
|
const decimals = poolInfo.lp_decimals;
|
@@ -99,7 +100,7 @@ const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
|
|
99
100
|
if (totalLiquidity.isLessThan(computeAndStoreLpPrice_1.minimumLiquidity))
|
100
101
|
continue;
|
101
102
|
const price = totalLiquidity.dividedBy(poolSupply).toNumber();
|
102
|
-
|
103
|
+
const tokenPriceSoure = {
|
103
104
|
id: constants_1.platformId,
|
104
105
|
weight: 1,
|
105
106
|
address,
|
@@ -109,7 +110,8 @@ const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
|
|
109
110
|
price,
|
110
111
|
underlyings,
|
111
112
|
timestamp: Date.now(),
|
112
|
-
}
|
113
|
+
};
|
114
|
+
yield cache.setTokenPriceSource(tokenPriceSoure);
|
113
115
|
}
|
114
116
|
else {
|
115
117
|
const tokenPriceA = tokenPriceById.get(`0x${poolInfo.type_names[0]}`);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"poolsJob.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/aftermath/poolsJob.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,
|
1
|
+
{"version":3,"file":"poolsJob.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/aftermath/poolsJob.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,gEAAqC;AACrC,+DAIoC;AAGpC,iDAAmD;AACnD,2CAAuD;AAEvD,oFAA2E;AAC3E,6CAAoD;AACpD,6FAAoE;AACpE,6GAAqF;AACrF,+FAAuE;AACvE,uEAAoE;AACpE,qEAAkE;AAElE,MAAM,QAAQ,GAAgB,CAAO,KAAY,EAAE,EAAE;;IACnD,MAAM,MAAM,GAAG,IAAA,sBAAY,GAAE,CAAC;IAC9B,MAAM,SAAS,GAAG,0BAAS,CAAC,GAAG,CAAC;IAChC,MAAM,gBAAgB,GAAG,MAAM,IAAA,mCAAgB,EAAC,MAAM,EAAE,wBAAY,CAAC,CAAC;IAEtE,MAAM,cAAc,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;IAC/D,IAAI,CAAC,cAAc,CAAC,MAAM;QAAE,OAAO;IAEnC,MAAM,QAAQ,GAAG,MAAM,IAAA,iCAAe,EAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAC/D,MAAM,QAAQ,GAAG,QAAQ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AAC,WAAW;gBAC9B,SAAS,EAAE,IAAI,sBAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC;aAC1D,EACD;gBACE;oBACE,OAAO,EAAE,WAAW,CAAC,OAAO;oBAC5B,QAAQ,EAAE,WAAW,CAAC,QAAQ;oBAC9B,KAAK,EAAE,WAAW,CAAC,KAAK;oBACxB,gBAAgB,EAAE,iBAAiB;iBACpC;gBACD;oBACE,OAAO,EAAE,WAAW,CAAC,OAAO;oBAC5B,QAAQ,EAAE,WAAW,CAAC,QAAQ;oBAC9B,KAAK,EAAE,WAAW,CAAC,KAAK;oBACxB,gBAAgB,EAAE,iBAAiB;iBACpC;aACF,CACF,CAAC;YAEF,MAAM,KAAK,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC;QAC5C,CAAC;IACH,CAAC;AACH,CAAC,CAAA,CAAC;AAEF,MAAM,GAAG,GAAQ;IACf,EAAE,EAAE,GAAG,sBAAU,QAAQ;IACzB,QAAQ;IACR,KAAK,EAAE,QAAQ;CAChB,CAAC;AACF,kBAAe,GAAG,CAAC"}
|
@@ -36,27 +36,27 @@ exports.getBalancerPoolsV2 = void 0;
|
|
36
36
|
const graphql_request_1 = __importStar(require("graphql-request"));
|
37
37
|
function getBalancerPoolsV2(url) {
|
38
38
|
return __awaiter(this, void 0, void 0, function* () {
|
39
|
-
const query = (0, graphql_request_1.gql) `
|
40
|
-
query pools {
|
41
|
-
pools(
|
42
|
-
first: 1000
|
43
|
-
orderBy: totalLiquidity
|
44
|
-
orderDirection: desc
|
45
|
-
where: { totalLiquidity_gt: "500" }
|
46
|
-
) {
|
47
|
-
id
|
48
|
-
address
|
49
|
-
symbol
|
50
|
-
totalLiquidity
|
51
|
-
totalShares
|
52
|
-
tokens {
|
53
|
-
balance
|
54
|
-
decimals
|
55
|
-
symbol
|
56
|
-
address
|
57
|
-
}
|
58
|
-
}
|
59
|
-
}
|
39
|
+
const query = (0, graphql_request_1.gql) `
|
40
|
+
query pools {
|
41
|
+
pools(
|
42
|
+
first: 1000
|
43
|
+
orderBy: totalLiquidity
|
44
|
+
orderDirection: desc
|
45
|
+
where: { totalLiquidity_gt: "500" }
|
46
|
+
) {
|
47
|
+
id
|
48
|
+
address
|
49
|
+
symbol
|
50
|
+
totalLiquidity
|
51
|
+
totalShares
|
52
|
+
tokens {
|
53
|
+
balance
|
54
|
+
decimals
|
55
|
+
symbol
|
56
|
+
address
|
57
|
+
}
|
58
|
+
}
|
59
|
+
}
|
60
60
|
`;
|
61
61
|
const res = yield (0, graphql_request_1.default)(url, query);
|
62
62
|
const pools = res.pools;
|
@@ -13,12 +13,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
13
13
|
};
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
15
15
|
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
16
|
-
const sui_js_1 = require("@mysten/sui.js");
|
17
16
|
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
18
17
|
const constants_1 = require("./constants");
|
19
18
|
const clients_1 = require("../../utils/clients");
|
20
19
|
const tokenPriceToAssetToken_1 = __importDefault(require("../../utils/misc/tokenPriceToAssetToken"));
|
20
|
+
const getDynamicFieldObject_1 = require("../../utils/sui/getDynamicFieldObject");
|
21
21
|
const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* () {
|
22
|
+
var _a;
|
22
23
|
const client = (0, clients_1.getClientSui)();
|
23
24
|
const buckPrice = yield cache.getTokenPrice(constants_1.buckId, portfolio_core_1.NetworkId.sui);
|
24
25
|
if (!buckPrice)
|
@@ -37,19 +38,15 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
|
|
37
38
|
value: owner,
|
38
39
|
},
|
39
40
|
};
|
40
|
-
const positionData = yield
|
41
|
+
const positionData = yield (0, getDynamicFieldObject_1.getDynamicFieldObject)(client, input);
|
41
42
|
if (!positionData.data)
|
42
43
|
continue;
|
43
44
|
const tokenPrice = yield cache.getTokenPrice(collateral.tokenId, portfolio_core_1.NetworkId.sui);
|
44
45
|
if (!tokenPrice)
|
45
46
|
continue;
|
46
|
-
const
|
47
|
-
if (!
|
48
|
-
!collateralFields.value.fields ||
|
49
|
-
!collateralFields.value.fields.value ||
|
50
|
-
!collateralFields.value.fields.value.fields)
|
47
|
+
const collateralInfo = (_a = positionData.data.content) === null || _a === void 0 ? void 0 : _a.fields.value.fields.value.fields;
|
48
|
+
if (!collateralInfo)
|
51
49
|
continue;
|
52
|
-
const collateralInfo = collateralFields.value.fields.value.fields;
|
53
50
|
const suppliedQuantity = new bignumber_js_1.default(collateralInfo.collateral_amount)
|
54
51
|
.dividedBy(Math.pow(10, tokenPrice.decimals))
|
55
52
|
.toNumber();
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"collateralFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/bucket/collateralFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAOoC;AACpC,
|
1
|
+
{"version":3,"file":"collateralFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/bucket/collateralFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAOoC;AACpC,gEAAqC;AAGrC,2CAA8D;AAC9D,iDAAmD;AAEnD,qGAA6E;AAC7E,iFAA8E;AAE9E,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;;IACtE,MAAM,MAAM,GAAG,IAAA,sBAAY,GAAE,CAAC;IAC9B,MAAM,SAAS,GAAG,MAAM,KAAK,CAAC,aAAa,CAAC,kBAAM,EAAE,0BAAS,CAAC,GAAG,CAAC,CAAC;IACnE,IAAI,CAAC,SAAS;QAAE,OAAO,EAAE,CAAC;IAC1B,MAAM,QAAQ,GAAuB,EAAE,CAAC;IAExC,KAAK,MAAM,UAAU,IAAI,uBAAW,EAAE,CAAC;QACrC,MAAM,cAAc,GAAqB,EAAE,CAAC;QAC5C,MAAM,cA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CAAC,IAAI,CACjB,IAAA,gCAAsB,EACpB,UAAU,CAAC,OAAO,EAClB,gBAAgB,EAChB,0BAAS,CAAC,GAAG,EACb,UAAU,CACX,CACF,CAAC;QAEF,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,aAAa,EAAE,KAAK,EAAE,GACxD,IAAA,wCAAuB,EAAC,cAAc,EAAE,cAAc,EAAE,YAAY,CAAC,CAAC;QAExE,MAAM,OAAO,GAAqB;YAChC,IAAI,EAAE,qCAAoB,CAAC,UAAU;YACrC,SAAS,EAAE,0BAAS,CAAC,GAAG;YACxB,UAAU,EAAV,sBAAU;YACV,KAAK,EAAE,SAAS;YAChB,KAAK;YACL,IAAI,EAAE;gBACJ,cAAc;gBACd,aAAa;gBACb,cAAc;gBACd,cAAc;gBACd,aAAa;gBACb,cAAc;gBACd,eAAe,EAAE,IAAI;gBAErB,WAAW;gBACX,YAAY;gBACZ,KAAK;aACN;SACF,CAAC;QACF,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACzB,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAA,CAAC;AAEF,MAAM,OAAO,GAAY;IACvB,EAAE,EAAE,GAAG,sBAAU,aAAa;IAC9B,SAAS,EAAE,0BAAS,CAAC,GAAG;IACxB,QAAQ;CACT,CAAC;AAEF,kBAAe,OAAO,CAAC"}
|
@@ -19,10 +19,10 @@ const clients_1 = require("../../utils/clients");
|
|
19
19
|
const helpers_1 = require("./helpers");
|
20
20
|
const tokenPriceToAssetToken_1 = __importDefault(require("../../utils/misc/tokenPriceToAssetToken"));
|
21
21
|
const tokenAmountFromLiquidity_1 = require("../../utils/clmm/tokenAmountFromLiquidity");
|
22
|
+
const getOwnedObjects_1 = require("../../utils/sui/getOwnedObjects");
|
22
23
|
const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* () {
|
23
24
|
const client = (0, clients_1.getClientSui)();
|
24
|
-
const ownerRes = yield
|
25
|
-
owner,
|
25
|
+
const ownerRes = yield (0, getOwnedObjects_1.getOwnedObjects)(client, owner, {
|
26
26
|
options: {
|
27
27
|
showType: true,
|
28
28
|
showContent: true,
|
@@ -31,11 +31,11 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
|
|
31
31
|
},
|
32
32
|
filter: { Package: constants_1.clmmPoolPackageId },
|
33
33
|
});
|
34
|
-
if (
|
34
|
+
if (ownerRes.length === 0)
|
35
35
|
return [];
|
36
36
|
const clmmPositions = [];
|
37
|
-
for (let i = 0; i < ownerRes.
|
38
|
-
const clmmPositionRes = ownerRes
|
37
|
+
for (let i = 0; i < ownerRes.length; i++) {
|
38
|
+
const clmmPositionRes = ownerRes[i];
|
39
39
|
if (!clmmPositionRes.data || !clmmPositionRes.data.type)
|
40
40
|
continue;
|
41
41
|
const type = (0, helpers_1.extractStructTagFromType)(clmmPositionRes.data.type);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"clmmsFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/cetus/clmmsFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAIoC;AACpC,gEAAqC;AAGrC,2CAKqB;AACrB,iDAAmD;AACnD,uCAAoE;AAGpE,qGAA6E;AAC7E,wFAAyF;
|
1
|
+
{"version":3,"file":"clmmsFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/cetus/clmmsFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAIoC;AACpC,gEAAqC;AAGrC,2CAKqB;AACrB,iDAAmD;AACnD,uCAAoE;AAGpE,qGAA6E;AAC7E,wFAAyF;AACzF,qEAAkE;AAElE,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;IACtE,MAAM,MAAM,GAAG,IAAA,sBAAY,GAAE,CAAC;IAC9B,MAAM,QAAQ,GAAG,MAAM,IAAA,iCAAe,EAAC,MAAM,EAAE,KAAK,EAAE;QACpD,OAAO,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Pool, Position, SuiAddressType, SuiStructTag } from './types';
|
4
|
+
import { ObjectResponse } from '../../utils/sui/types';
|
5
5
|
export declare function fromX64(num: BigNumber): Decimal;
|
6
6
|
export declare function composeType(address: string, generics: SuiAddressType[]): SuiAddressType;
|
7
7
|
export declare function composeType(address: string, struct: string, generics?: SuiAddressType[]): SuiAddressType;
|
@@ -11,6 +11,6 @@ export declare function isSuiCoin(coinAddress: SuiAddressType): boolean;
|
|
11
11
|
export declare function buildPoolName(coin_type_a: string, coin_type_b: string, tick_spacing: string): string;
|
12
12
|
export declare function normalizeCoinType(coinType: string): string;
|
13
13
|
export declare function asIntN(int: bigint, bits?: number): number;
|
14
|
-
export declare function getPoolFromObject(object:
|
15
|
-
export declare function buildPosition(objects:
|
16
|
-
export declare function buildNFT(objects:
|
14
|
+
export declare function getPoolFromObject(object: ObjectResponse<unknown>): Pool;
|
15
|
+
export declare function buildPosition(objects: ObjectResponse<unknown>): Position;
|
16
|
+
export declare function buildNFT(objects: ObjectResponse<unknown>): NFT;
|
@@ -5,11 +5,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
5
5
|
};
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
7
7
|
exports.buildNFT = exports.buildPosition = exports.getPoolFromObject = exports.asIntN = exports.normalizeCoinType = exports.buildPoolName = exports.isSuiCoin = exports.extractStructTagFromType = exports.composeType = exports.fromX64 = void 0;
|
8
|
-
const sui_js_1 = require("@mysten/sui.js");
|
9
8
|
const decimal_js_1 = __importDefault(require("decimal.js"));
|
10
9
|
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
11
10
|
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
11
|
+
const utils_1 = require("@mysten/sui.js/utils");
|
12
12
|
const types_1 = require("./types");
|
13
|
+
const getObjectDeletedResponse_1 = require("../../utils/sui/getObjectDeletedResponse");
|
14
|
+
const getObjectNotExistsResponse_1 = require("../../utils/sui/getObjectNotExistsResponse");
|
13
15
|
function fromX64(num) {
|
14
16
|
return new decimal_js_1.default(num.toString()).mul(decimal_js_1.default.pow(2, -64));
|
15
17
|
}
|
@@ -43,7 +45,7 @@ function extractStructTagFromType(type) {
|
|
43
45
|
const parts = newType.split('::');
|
44
46
|
const structTag = {
|
45
47
|
full_address: newType,
|
46
|
-
address: parts[2] === 'SUI' ? '0x2' : (0,
|
48
|
+
address: parts[2] === 'SUI' ? '0x2' : (0, utils_1.normalizeSuiObjectId)(parts[0]),
|
47
49
|
module: parts[1],
|
48
50
|
name: parts[2],
|
49
51
|
type_arguments: [],
|
@@ -85,11 +87,16 @@ function asIntN(int, bits = 32) {
|
|
85
87
|
}
|
86
88
|
exports.asIntN = asIntN;
|
87
89
|
function getPoolFromObject(object) {
|
88
|
-
|
90
|
+
var _a, _b;
|
91
|
+
if (!object.data || !((_a = object.data.content) === null || _a === void 0 ? void 0 : _a.fields))
|
92
|
+
throw Error('getPoolFromObject object.data is missing');
|
93
|
+
const type = (_b = object.data) === null || _b === void 0 ? void 0 : _b.type;
|
89
94
|
const formatType = extractStructTagFromType(type);
|
90
|
-
|
95
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
96
|
+
const fields = object.data.content.fields;
|
91
97
|
const rewarders = [];
|
92
|
-
|
98
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
99
|
+
fields.rewarder_manager.fields.rewarders.forEach((item) => {
|
93
100
|
const { emissions_per_second: emissionsPerSecond } = item.fields.emissions_per_second;
|
94
101
|
const emissionSeconds = fromX64(new bignumber_js_1.default(emissionsPerSecond));
|
95
102
|
const emissionsEveryDay = Math.floor(emissionSeconds.toNumber() * 60 * 60 * 24);
|
@@ -103,7 +110,7 @@ function getPoolFromObject(object) {
|
|
103
110
|
});
|
104
111
|
const name = buildPoolName(formatType.type_arguments[0], formatType.type_arguments[1], fields['tick_spacing']);
|
105
112
|
return {
|
106
|
-
poolAddress:
|
113
|
+
poolAddress: object.data.objectId,
|
107
114
|
poolType: type,
|
108
115
|
coinTypeA: formatType.type_arguments[0],
|
109
116
|
coinTypeB: formatType.type_arguments[1],
|
@@ -133,6 +140,7 @@ function getPoolFromObject(object) {
|
|
133
140
|
}
|
134
141
|
exports.getPoolFromObject = getPoolFromObject;
|
135
142
|
function buildPosition(objects) {
|
143
|
+
var _a, _b, _c;
|
136
144
|
let nft = {
|
137
145
|
creator: '',
|
138
146
|
description: '',
|
@@ -142,10 +150,12 @@ function buildPosition(objects) {
|
|
142
150
|
project_url: '',
|
143
151
|
};
|
144
152
|
let position = Object.assign(Object.assign({}, nft), { pos_object_id: '', owner: '', type: '', coin_type_a: '', coin_type_b: '', liquidity: '', tick_lower_index: 0, tick_upper_index: 0, index: 0, pool: '', reward_amount_owed_0: '0', reward_amount_owed_1: '0', reward_amount_owed_2: '0', reward_growth_inside_0: '0', reward_growth_inside_1: '0', reward_growth_inside_2: '0', fee_growth_inside_a: '0', fee_owed_a: '0', fee_growth_inside_b: '0', fee_owed_b: '0', position_status: types_1.ClmmPositionStatus.Exists });
|
145
|
-
|
153
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
154
|
+
let fields = (_b = (_a = objects.data) === null || _a === void 0 ? void 0 : _a.content) === null || _b === void 0 ? void 0 : _b.fields;
|
146
155
|
if (fields) {
|
147
|
-
|
148
|
-
const
|
156
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
157
|
+
const { type } = objects.data;
|
158
|
+
const ownerWarp = (_c = objects.data) === null || _c === void 0 ? void 0 : _c.owner;
|
149
159
|
if ('nft' in fields) {
|
150
160
|
fields = fields['nft'].fields;
|
151
161
|
nft.description = fields['description'];
|
@@ -157,12 +167,12 @@ function buildPosition(objects) {
|
|
157
167
|
}
|
158
168
|
position = Object.assign(Object.assign({}, nft), { pos_object_id: fields['id'].id, owner: ownerWarp.AddressOwner, type, coin_type_a: fields['coin_type_a'].fields.name, coin_type_b: fields['coin_type_b'].fields.name, liquidity: fields['liquidity'], tick_lower_index: asIntN(BigInt(fields['tick_lower_index'].fields.bits)), tick_upper_index: asIntN(BigInt(fields['tick_upper_index'].fields.bits)), index: fields['index'], pool: fields['pool'], reward_amount_owed_0: '0', reward_amount_owed_1: '0', reward_amount_owed_2: '0', reward_growth_inside_0: '0', reward_growth_inside_1: '0', reward_growth_inside_2: '0', fee_growth_inside_a: '0', fee_owed_a: '0', fee_growth_inside_b: '0', fee_owed_b: '0', position_status: types_1.ClmmPositionStatus.Exists });
|
159
169
|
}
|
160
|
-
const deletedResponse = (0,
|
170
|
+
const deletedResponse = (0, getObjectDeletedResponse_1.getObjectDeletedResponse)(objects);
|
161
171
|
if (deletedResponse) {
|
162
172
|
position.pos_object_id = deletedResponse.objectId;
|
163
173
|
position.position_status = types_1.ClmmPositionStatus.Deleted;
|
164
174
|
}
|
165
|
-
const objectNotExistsResponse = (0,
|
175
|
+
const objectNotExistsResponse = (0, getObjectNotExistsResponse_1.getObjectNotExistsResponse)(objects);
|
166
176
|
if (objectNotExistsResponse) {
|
167
177
|
position.pos_object_id = objectNotExistsResponse;
|
168
178
|
position.position_status = types_1.ClmmPositionStatus.NotExists;
|
@@ -171,7 +181,8 @@ function buildPosition(objects) {
|
|
171
181
|
}
|
172
182
|
exports.buildPosition = buildPosition;
|
173
183
|
function buildNFT(objects) {
|
174
|
-
|
184
|
+
var _a, _b;
|
185
|
+
const fields = (_b = (_a = objects.data) === null || _a === void 0 ? void 0 : _a.display) === null || _b === void 0 ? void 0 : _b.data;
|
175
186
|
const nft = {
|
176
187
|
creator: '',
|
177
188
|
description: '',
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/cetus/helpers.ts"],"names":[],"mappings":";AAAA,sCAAsC;;;;;;AAEtC,
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/cetus/helpers.ts"],"names":[],"mappings":";AAAA,sCAAsC;;;;;;AAEtC,4DAAiC;AACjC,gE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AAC,aAAa,GAAG,eAAe,CAAC,QAAQ,CAAC;QAClD,QAAQ,CAAC,eAAe,GAAG,0BAAkB,CAAC,OAAO,CAAC;IACxD,CAAC;IACD,MAAM,uBAAuB,GAAG,IAAA,uDAA0B,EAAC,OAAO,CAAC,CAAC;IACpE,IAAI,uBAAuB,EAAE,CAAC;QAC5B,QAAQ,CAAC,aAAa,GAAG,uBAAuB,CAAC;QACjD,QAAQ,CAAC,eAAe,GAAG,0BAAkB,CAAC,SAAS,CAAC;IAC1D,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC;AA3FD,sCA2FC;AAED,SAAgB,QAAQ,CAAC,OAAgC;;IACvD,MAAM,MAAM,GAAG,MAAA,MAAA,OAAO,CAAC,IAAI,0CAAE,OAAO,0CAAE,IAAI,CAAC;IAC3C,MAAM,GAAG,GAAQ;QACf,OAAO,EAAE,EAAE;QACX,WAAW,EAAE,EAAE;QACf,SAAS,EAAE,EAAE;QACb,IAAI,EAAE,EAAE;QACR,IAAI,EAAE,EAAE;QACR,WAAW,EAAE,EAAE;KAChB,CAAC;IACF,IAAI,MAAM,EAAE,CAAC;QACX,GAAG,CAAC,OAAO,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC;QAChC,GAAG,CAAC,WAAW,GAAG,MAAM,CAAC,aAAa,CAAC,CAAC;QACxC,GAAG,CAAC,SAAS,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC;QACpC,GAAG,CAAC,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;QAC1B,GAAG,CAAC,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;QAC1B,GAAG,CAAC,WAAW,GAAG,MAAM,CAAC,aAAa,CAAC,CAAC;IAC1C,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAnBD,4BAmBC"}
|
@@ -18,23 +18,18 @@ const clients_1 = require("../../utils/clients");
|
|
18
18
|
const constants_1 = require("./constants");
|
19
19
|
const helpers_1 = require("./helpers");
|
20
20
|
const tokenPricesFromSqrt_1 = __importDefault(require("../../utils/clmm/tokenPricesFromSqrt"));
|
21
|
-
const
|
22
|
-
const
|
21
|
+
const multiGetObjects_1 = require("../../utils/sui/multiGetObjects");
|
22
|
+
const queryEvents_1 = require("../../utils/sui/queryEvents");
|
23
23
|
const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
|
24
24
|
var _a;
|
25
25
|
const client = (0, clients_1.getClientSui)();
|
26
|
-
const eventsData = yield (0,
|
26
|
+
const eventsData = yield (0, queryEvents_1.queryEvents)(client, {
|
27
27
|
MoveEventType: constants_1.createPoolEvent,
|
28
28
|
});
|
29
29
|
const poolsAddresses = eventsData
|
30
|
-
.map((eventData) => eventData.parsedJson
|
31
|
-
? eventData.parsedJson.pool_id
|
32
|
-
: [])
|
30
|
+
.map((eventData) => eventData.parsedJson ? eventData.parsedJson.pool_id : [])
|
33
31
|
.flat();
|
34
|
-
const poolsObjects = yield (0,
|
35
|
-
showContent: true,
|
36
|
-
showType: true,
|
37
|
-
});
|
32
|
+
const poolsObjects = yield (0, multiGetObjects_1.multiGetObjects)(client, poolsAddresses);
|
38
33
|
const promises = [];
|
39
34
|
for (const poolObject of poolsObjects) {
|
40
35
|
const poolId = (_a = poolObject.data) === null || _a === void 0 ? void 0 : _a.objectId;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"poolsJob.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/cetus/poolsJob.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAAuD;AACvD,gEAAqC;AAGrC,iDAAmD;AACnD,2CAA2E;AAC3E,uCAA8C;AAC9C,+FAA4E;AAE5E,
|
1
|
+
{"version":3,"file":"poolsJob.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/cetus/poolsJob.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAAuD;AACvD,gEAAqC;AAGrC,iDAAmD;AACnD,2CAA2E;AAC3E,uCAA8C;AA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MAAM,EAAE,2BAAe;YACvB,SAAS,EAAE,0BAAS,CAAC,GAAG;SACzB,CAAC,CACH,CAAC;IACJ,CAAC;IACD,MAAM,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;AACrC,CAAC,CAAA,CAAC;AAEF,MAAM,GAAG,GAAQ;IACf,EAAE,EAAE,GAAG,sBAAU,QAAQ;IACzB,QAAQ;IACR,KAAK,EAAE,QAAQ;CAChB,CAAC;AACF,kBAAe,GAAG,CAAC"}
|
@@ -13,13 +13,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
13
13
|
};
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
15
15
|
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
16
|
-
const sui_js_1 = require("@mysten/sui.js");
|
17
16
|
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
18
17
|
const constants_1 = require("./constants");
|
19
18
|
const clients_1 = require("../../utils/clients");
|
20
19
|
const tokenPriceToAssetToken_1 = __importDefault(require("../../utils/misc/tokenPriceToAssetToken"));
|
20
|
+
const getDynamicFieldObject_1 = require("../../utils/sui/getDynamicFieldObject");
|
21
21
|
const amountFactor = new bignumber_js_1.default(Math.pow(10, 36));
|
22
22
|
const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* () {
|
23
|
+
var _a, _b, _c, _d;
|
23
24
|
const client = (0, clients_1.getClientSui)();
|
24
25
|
const borrowedAssets = [];
|
25
26
|
const borrowedYields = [];
|
@@ -34,11 +35,11 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
|
|
34
35
|
return [];
|
35
36
|
const tokenPrices = yield cache.getTokenPricesAsMap(reservesData.map((r) => r.value.fields.coin_type), portfolio_core_1.NetworkId.sui);
|
36
37
|
for (const rData of reservesData) {
|
37
|
-
const borrowBalancePromise =
|
38
|
+
const borrowBalancePromise = (0, getDynamicFieldObject_1.getDynamicFieldObject)(client, {
|
38
39
|
parentId: rData.value.fields.borrow_balance.fields.user_state.fields.id.id,
|
39
40
|
name: { type: 'address', value: owner },
|
40
41
|
});
|
41
|
-
const supplyBalancePromise =
|
42
|
+
const supplyBalancePromise = (0, getDynamicFieldObject_1.getDynamicFieldObject)(client, {
|
42
43
|
parentId: rData.value.fields.supply_balance.fields.user_state.fields.id.id,
|
43
44
|
name: { type: 'address', value: owner },
|
44
45
|
});
|
@@ -47,8 +48,8 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
|
|
47
48
|
supplyBalancePromise,
|
48
49
|
]);
|
49
50
|
const tokenPrice = tokenPrices.get((0, portfolio_core_1.formatTokenAddress)(rData.value.fields.coin_type, portfolio_core_1.NetworkId.sui));
|
50
|
-
if (!borrowBalance.error && borrowBalance.data) {
|
51
|
-
const borrowInfo = (
|
51
|
+
if (!borrowBalance.error && ((_a = borrowBalance.data) === null || _a === void 0 ? void 0 : _a.content)) {
|
52
|
+
const borrowInfo = (_b = borrowBalance.data.content) === null || _b === void 0 ? void 0 : _b.fields;
|
52
53
|
if (borrowInfo.value) {
|
53
54
|
borrowedAssets.push((0, tokenPriceToAssetToken_1.default)(rData.value.fields.coin_type, new bignumber_js_1.default(borrowInfo.value)
|
54
55
|
.times(rData.value.fields.current_borrow_index)
|
@@ -65,8 +66,8 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
|
|
65
66
|
]);
|
66
67
|
}
|
67
68
|
}
|
68
|
-
if (!supplyBalance.error && supplyBalance.data) {
|
69
|
-
const supplyInfo =
|
69
|
+
if (!supplyBalance.error && ((_d = (_c = supplyBalance.data) === null || _c === void 0 ? void 0 : _c.content) === null || _d === void 0 ? void 0 : _d.fields)) {
|
70
|
+
const supplyInfo = supplyBalance.data.content.fields;
|
70
71
|
if (supplyInfo.value) {
|
71
72
|
suppliedAssets.push((0, tokenPriceToAssetToken_1.default)(rData.value.fields.coin_type, new bignumber_js_1.default(supplyInfo.value)
|
72
73
|
.times(rData.value.fields.current_supply_index)
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"collateralFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/navi/collateralFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DASoC;AACpC,
|
1
|
+
{"version":3,"file":"collateralFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/navi/collateralFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DASoC;AACpC,gEAAqC;AAGrC,2CAKqB;AACrB,iDAAmD;AACnD,qGAA6E;AAE7E,iFAA8E;AAE9E,MAAM,YAAY,GAAG,IAAI,sBAAS,CAAC,SAAA,EAAE,EAAI,EAAE,CAAA,CAAC,CAAC;AAE7C,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;;IACtE,MAAM,MAAM,GAAG,IAAA,sBAAY,GAAE,CAAC;IAE9B,MAAM,cAAc,GAAqB,EAAE,CAAC;IAC5C,MAAM,cAAc,GAAc,EAAE,CAAC;IACrC,MAAM,cAAc,GAAqB,EAAE,CAAC;IAC5C,MAAM,cAAc,GAAc,EAAE,CAAC;IACrC,MAAM,YAAY,GAAqB,EAAE,CAAC;IAE1C,MAAM,YAAY,GAAG,MAAM,KAAK,CAAC,OAAO,CAAgB,uBAAW,EAAE;QACnE,MAAM,EAAE,0BAAc;QACtB,SAAS,EAAE,0BAAS,CAAC,GAAG;KACzB,CAAC,CAAC;IACH,IAAI,CAAC,YAAY;QAAE,OAAO,EAAE,CAAC;IAE7B,MAAM,WAAW,GAAG,MAAM,KAAK,CAAC,mBAAmB,CACjD,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,EACjD,0BAAS,CAAC,GAAG,CACd,CAAC;IAEF,KAAK,MAAM,KAAK,IAAI,YAAY,EAAE,CAAC;QACjC,MAAM,oBAAoB,GAAG,IAAA,6CAAqB,EAAc,MAA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