@sonarwatch/portfolio-plugins 0.11.120 → 0.11.121
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +1211 -1207
- package/README.md +3 -3
- package/package.json +2 -2
- package/src/plugins/abex/positionsFetcher.js +3 -1
- package/src/plugins/abex/positionsFetcher.js.map +1 -1
- package/src/plugins/balancer/helpers/pools.js +21 -21
- package/src/plugins/suilend/helpers.d.ts +7 -2
- package/src/plugins/suilend/helpers.js +54 -3
- package/src/plugins/suilend/helpers.js.map +1 -1
- package/src/plugins/suilend/marketsJob.js +43 -2
- package/src/plugins/suilend/marketsJob.js.map +1 -1
- package/src/plugins/suilend/obligationsFetcher.js +22 -12
- package/src/plugins/suilend/obligationsFetcher.js.map +1 -1
- package/src/plugins/suilend/types.d.ts +5 -0
- package/src/plugins/sushiswap/helpers.js +24 -24
- package/src/plugins/uniswap-v2/helpers.js +22 -22
- package/src/utils/sei/constants.js +8 -8
- package/src/utils/sei/getQueryBalanceByOwner.js +4 -4
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.121",
|
4
4
|
"type": "commonjs",
|
5
5
|
"generators": "./generators.json",
|
6
6
|
"dependencies": {
|
@@ -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.121"
|
45
45
|
},
|
46
46
|
"main": "./src/index.js",
|
47
47
|
"types": "./src/index.d.ts"
|
@@ -56,7 +56,9 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
|
|
56
56
|
claimmableAmount = claimmableAmount.plus(cClaimmableAmount);
|
57
57
|
}
|
58
58
|
const asset = (0, tokenPriceToAssetToken_1.default)(constants_1.alpType, alpAmount.dividedBy(Math.pow(10, constants_1.alpDecimals)).toNumber(), portfolio_core_1.NetworkId.sui, alpPrice);
|
59
|
-
const rewardAsset = (0, tokenPriceToAssetToken_1.default)(portfolio_core_1.suiNativeAddress, claimmableAmount.dividedBy(Math.pow(10, portfolio_core_1.suiNativeDecimals)).toNumber(), portfolio_core_1.NetworkId.sui, suiPrice
|
59
|
+
const rewardAsset = (0, tokenPriceToAssetToken_1.default)(portfolio_core_1.suiNativeAddress, claimmableAmount.dividedBy(Math.pow(10, portfolio_core_1.suiNativeDecimals)).toNumber(), portfolio_core_1.NetworkId.sui, suiPrice, undefined, {
|
60
|
+
isClaimable: true,
|
61
|
+
});
|
60
62
|
if (claimmableAmount.isZero() && alpAmount.isZero())
|
61
63
|
return [];
|
62
64
|
const value = (0, portfolio_core_1.getUsdValueSum)([rewardAsset.value, asset.value]);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"positionsFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/abex/positionsFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAMoC;AACpC,gEAAqC;AAErC,2CAKqB;AAErB,iDAAmD;AACnD,qEAAkE;AAElE,qGAA6E;AAE7E,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;;IACtE,MAAM,MAAM,GAAG,IAAA,sBAAY,GAAE,CAAC;IAC9B,MAAM,OAAO,GAAG,MAAM,IAAA,iCAAe,EAAa,MAAM,EAAE,KAAK,EAAE;QAC/D,MAAM,EAAE;YACN,OAAO,EACL,oEAAoE;SACvE;KACF,CAAC,CAAC;IACH,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAA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A,CAAC,CAAC;QACjB,gBAAgB,GAAG,gBAAgB,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;IAC9D,CAAC;IACD,MAAM,KAAK,GAAG,IAAA,gCAAsB,EAClC,mBAAO,EACP,SAAS,CAAC,SAAS,CAAC,SAAA,EAAE,EAAI,uBAAW,CAAA,CAAC,CAAC,QAAQ,EAAE,EACjD,0BAAS,CAAC,GAAG,EACb,QAAQ,CACT,CAAC;IACF,MAAM,WAAW,GAAG,IAAA,gCAAsB,EACxC,iCAAgB,EAChB,gBAAgB,CAAC,SAAS,CAAC,SAAA,EAAE,EAAI,kCAAiB,CAAA,CAAC,CAAC,QAAQ,EAAE,EAC9D,0BAAS,CAAC,GAAG,EACb,QAAQ,
|
1
|
+
{"version":3,"file":"positionsFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/abex/positionsFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAMoC;AACpC,gEAAqC;AAErC,2CAKqB;AAErB,iDAAmD;AACnD,qEAAkE;AAElE,qGAA6E;AAE7E,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;;IACtE,MAAM,MAAM,GAAG,IAAA,sBAAY,GAAE,CAAC;IAC9B,MAAM,OAAO,GAAG,MAAM,IAAA,iCAAe,EAAa,MAAM,EAAE,KAAK,EAAE;QAC/D,MAAM,EAAE;YACN,OAAO,EACL,oEAAoE;SACvE;KACF,CAAC,CAAC;IACH,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAEpC,MAAM,CAAC,QAAQ,EAAE,QAAQ,CAAC,GAAG,MAAM,KAAK,CAAC,cAAc,CACrD,CAAC,mBAAO,EAAE,iCAAgB,CAAC,EAC3B,0BAAS,CAAC,GAAG,CACd,CAAC;IACF,MAAM,wBAAwB,GAAG,MAAM,KAAK,CAAC,OAAO,CAClD,oCAAwB,EACxB;QACE,MAAM,EAAE,sBAAU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G,EACb,QAAQ,CACT,CAAC;IACF,MAAM,WAAW,GAAG,IAAA,gCAAsB,EACxC,iCAAgB,EAChB,gBAAgB,CAAC,SAAS,CAAC,SAAA,EAAE,EAAI,kCAAiB,CAAA,CAAC,CAAC,QAAQ,EAAE,EAC9D,0BAAS,CAAC,GAAG,EACb,QAAQ,EACR,SAAS,EACT;QACE,WAAW,EAAE,IAAI;KAClB,CACF,CAAC;IAEF,IAAI,gBAAgB,CAAC,MAAM,EAAE,IAAI,SAAS,CAAC,MAAM,EAAE;QAAE,OAAO,EAAE,CAAC;IAC/D,MAAM,KAAK,GAAG,IAAA,+BAAc,EAAC,CAAC,WAAW,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;IAC/D,MAAM,OAAO,GAA8B;QACzC,SAAS,EAAE,0BAAS,CAAC,GAAG;QACxB,KAAK,EAAE,QAAQ;QACf,UAAU,EAAV,sBAAU;QACV,IAAI,EAAE,WAAW;QACjB,IAAI,EAAE;YACJ,WAAW,EAAE;gBACX;oBACE,MAAM,EAAE,CAAC,KAAK,CAAC;oBACf,WAAW,EAAE,KAAK,CAAC,KAAK;oBACxB,YAAY,EAAE,CAAC,WAAW,CAAC;oBAC3B,iBAAiB,EAAE,WAAW,CAAC,KAAK;oBACpC,KAAK;oBACL,MAAM,EAAE,EAAE;iBACX;aACF;SACF;QACD,KAAK;KACN,CAAC;IACF,OAAO,CAAC,OAAO,CAAC,CAAC;AACnB,CAAC,CAAA,CAAC;AAEF,MAAM,OAAO,GAAY;IACvB,EAAE,EAAE,GAAG,sBAAU,YAAY;IAC7B,SAAS,EAAE,0BAAS,CAAC,GAAG;IACxB,QAAQ;CACT,CAAC;AAEF,kBAAe,OAAO,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;
|
@@ -1,2 +1,7 @@
|
|
1
|
-
import
|
2
|
-
|
1
|
+
import BigNumber from 'bignumber.js';
|
2
|
+
import { BorrowLendRate } from '@sonarwatch/portfolio-core';
|
3
|
+
import { LendingMarket, PoolReward, Reserve } from './types';
|
4
|
+
export declare function getPoolsRewardsAsMap(lendingMarkets: LendingMarket[] | undefined): Map<string, PoolReward>;
|
5
|
+
export declare function getRatesAsMap(borrowLendRates: BorrowLendRate[] | undefined): Map<string, BorrowLendRate>;
|
6
|
+
export declare function getBorrowApr(utilization: BigNumber, borrowedAmount: BigNumber, availableAmount: BigNumber, reserveFields: Reserve): number;
|
7
|
+
export declare function getDepositApr(utilization: BigNumber, borrowApr: number, reserveFields: Reserve): number;
|
@@ -1,10 +1,14 @@
|
|
1
1
|
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.getPoolsRewardsAsMap = void 0;
|
6
|
+
exports.getDepositApr = exports.getBorrowApr = exports.getRatesAsMap = exports.getPoolsRewardsAsMap = void 0;
|
7
|
+
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
4
8
|
function getPoolsRewardsAsMap(lendingMarkets) {
|
5
|
-
if (!lendingMarkets)
|
6
|
-
return undefined;
|
7
9
|
const rewardMintByPoolId = new Map();
|
10
|
+
if (!lendingMarkets)
|
11
|
+
return rewardMintByPoolId;
|
8
12
|
for (const lendingMarket of lendingMarkets) {
|
9
13
|
const { reserves } = lendingMarket;
|
10
14
|
for (const reserve of reserves) {
|
@@ -16,4 +20,51 @@ function getPoolsRewardsAsMap(lendingMarkets) {
|
|
16
20
|
return rewardMintByPoolId;
|
17
21
|
}
|
18
22
|
exports.getPoolsRewardsAsMap = getPoolsRewardsAsMap;
|
23
|
+
function getRatesAsMap(borrowLendRates) {
|
24
|
+
const ratesByReserveId = new Map();
|
25
|
+
if (!borrowLendRates)
|
26
|
+
return ratesByReserveId;
|
27
|
+
for (const borrowLendRate of borrowLendRates) {
|
28
|
+
const id = borrowLendRate.poolName;
|
29
|
+
ratesByReserveId.set(id, borrowLendRate);
|
30
|
+
}
|
31
|
+
return ratesByReserveId;
|
32
|
+
}
|
33
|
+
exports.getRatesAsMap = getRatesAsMap;
|
34
|
+
function getBorrowApr(utilization, borrowedAmount, availableAmount, reserveFields) {
|
35
|
+
const { interest_rate_aprs: rateAprs, interest_rate_utils: rateUtils } = reserveFields.config.fields.element.fields;
|
36
|
+
if (borrowedAmount.isZero())
|
37
|
+
return (0, bignumber_js_1.default)(rateAprs[0]).dividedBy(100).toNumber();
|
38
|
+
if (availableAmount.isZero())
|
39
|
+
return (0, bignumber_js_1.default)(rateAprs[rateAprs.length]).dividedBy(100).toNumber();
|
40
|
+
for (let i = 0; i < rateUtils.length; i++) {
|
41
|
+
const currentUtil = rateUtils[i] / 100;
|
42
|
+
const nextUtil = rateUtils[i + 1] / 100;
|
43
|
+
const currentApr = new bignumber_js_1.default(rateAprs[i]).dividedBy(Math.pow(10, 4));
|
44
|
+
const nextApr = new bignumber_js_1.default(rateAprs[i + 1]).dividedBy(Math.pow(10, 4));
|
45
|
+
if (utilization.isEqualTo(currentUtil)) {
|
46
|
+
return currentApr.toNumber();
|
47
|
+
}
|
48
|
+
if (utilization.isLessThan(nextUtil)) {
|
49
|
+
const utilizationDelta = utilization.minus(currentUtil);
|
50
|
+
const utilStepsDelta = nextUtil - currentUtil;
|
51
|
+
return utilizationDelta
|
52
|
+
.dividedBy(utilStepsDelta)
|
53
|
+
.times(nextApr.minus(currentApr))
|
54
|
+
.plus(currentApr)
|
55
|
+
.toNumber();
|
56
|
+
}
|
57
|
+
}
|
58
|
+
return 0;
|
59
|
+
}
|
60
|
+
exports.getBorrowApr = getBorrowApr;
|
61
|
+
function getDepositApr(utilization, borrowApr, reserveFields) {
|
62
|
+
return (0, bignumber_js_1.default)(borrowApr)
|
63
|
+
.times(1 -
|
64
|
+
Number(reserveFields.config.fields.element.fields.spread_fee_bps) /
|
65
|
+
Math.pow(10, 4))
|
66
|
+
.times(utilization)
|
67
|
+
.toNumber();
|
68
|
+
}
|
69
|
+
exports.getDepositApr = getDepositApr;
|
19
70
|
//# sourceMappingURL=helpers.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/suilend/helpers.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/suilend/helpers.ts"],"names":[],"mappings":";;;;;;AAAA,gEAAqC;AAIrC,SAAgB,oBAAoB,CAClC,cAA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;QAChB,CAAC;IACH,CAAC;IACD,OAAO,CAAC,CAAC;AACX,CAAC;AAlCD,oCAkCC;AAED,SAAgB,aAAa,CAC3B,WAAsB,EACtB,SAAiB,EACjB,aAAsB;IAEtB,OAAO,IAAA,sBAAS,EAAC,SAAS,CAAC;SACxB,KAAK,CACJ,CAAC;QACC,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,cAAc,CAAC;YAC/D,SAAA,EAAE,EAAI,CAAC,CAAA,CACZ;SACA,KAAK,CAAC,WAAW,CAAC;SAClB,QAAQ,EAAE,CAAC;AAChB,CAAC;AAbD,sCAaC"}
|
@@ -8,20 +8,61 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
9
|
});
|
10
10
|
};
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
|
+
};
|
11
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
12
15
|
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
16
|
+
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
13
17
|
const clients_1 = require("../../utils/clients");
|
14
18
|
const multiGetObjects_1 = require("../../utils/sui/multiGetObjects");
|
15
19
|
const constants_1 = require("./constants");
|
20
|
+
const helpers_1 = require("./helpers");
|
21
|
+
const constants_2 = require("../solend/constants");
|
16
22
|
const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
|
23
|
+
var _a, _b;
|
17
24
|
const client = (0, clients_1.getClientSui)();
|
18
25
|
const marketsObjects = yield (0, multiGetObjects_1.multiGetObjects)(client, [
|
19
26
|
constants_1.mainMarket,
|
20
27
|
]);
|
21
|
-
|
28
|
+
const promises = [];
|
29
|
+
const rates = [];
|
30
|
+
const lendingMarkets = [];
|
31
|
+
for (const market of marketsObjects) {
|
32
|
+
if ((_b = (_a = market.data) === null || _a === void 0 ? void 0 : _a.content) === null || _b === void 0 ? void 0 : _b.fields) {
|
33
|
+
lendingMarkets.push(market.data.content.fields);
|
34
|
+
for (const reserve of market.data.content.fields.reserves) {
|
35
|
+
const borrowedAmount = new bignumber_js_1.default(reserve.fields.borrowed_amount.fields.value);
|
36
|
+
const availableAmount = new bignumber_js_1.default(reserve.fields.available_amount).times(Math.pow(10, constants_2.wadsDecimal));
|
37
|
+
const utilization = borrowedAmount.dividedBy(availableAmount.plus(borrowedAmount));
|
38
|
+
const borrowApr = (0, helpers_1.getBorrowApr)(utilization, borrowedAmount, availableAmount, reserve.fields);
|
39
|
+
const depositApr = (0, helpers_1.getDepositApr)(utilization, borrowApr, reserve.fields);
|
40
|
+
const rate = {
|
41
|
+
poolName: reserve.fields.id.id,
|
42
|
+
borrowedAmount: borrowedAmount.toNumber(),
|
43
|
+
depositedAmount: borrowedAmount.plus(availableAmount).toNumber(),
|
44
|
+
platformId: constants_1.platformId,
|
45
|
+
tokenAddress: reserve.fields.coin_type.fields.name,
|
46
|
+
utilizationRatio: utilization.toNumber(),
|
47
|
+
depositYield: { apr: depositApr, apy: (0, portfolio_core_1.aprToApy)(depositApr) },
|
48
|
+
borrowYield: { apr: borrowApr, apy: (0, portfolio_core_1.aprToApy)(borrowApr) },
|
49
|
+
};
|
50
|
+
rates.push(rate);
|
51
|
+
promises.push(cache.setItem(`${reserve.fields.id.id}-${reserve.fields.coin_type.fields.name}`, rate, {
|
52
|
+
prefix: portfolio_core_1.borrowLendRatesPrefix,
|
53
|
+
networkId: portfolio_core_1.NetworkId.solana,
|
54
|
+
}));
|
55
|
+
}
|
56
|
+
}
|
57
|
+
}
|
58
|
+
promises.push(cache.setItem(constants_1.marketsKey, {
|
59
|
+
lendingMarkets,
|
60
|
+
rates,
|
61
|
+
}, {
|
22
62
|
prefix: constants_1.platformId,
|
23
63
|
networkId: portfolio_core_1.NetworkId.sui,
|
24
|
-
});
|
64
|
+
}));
|
65
|
+
yield Promise.allSettled(promises);
|
25
66
|
});
|
26
67
|
const job = {
|
27
68
|
id: `${constants_1.platformId}-markets`,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"marketsJob.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/suilend/marketsJob.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"marketsJob.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/suilend/marketsJob.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAKoC;AACpC,gEAAqC;AAGrC,iDAAmD;AACnD,qEAAkE;AAClE,2CAAiE;AAEjE,uCAAwD;AACxD,mDAAkD;AAElD,MAAM,QAAQ,GAAgB,CAAO,KAAY,EAAE,EAAE;;IACnD,MAAM,MAAM,GAAG,IAAA,sBAAY,GAAE,CAAC;IAC9B,MAAM,cAAc,GAAG,MAAM,IAAA,iCAAe,EAAgB,MAAM,EAAE;QAClE,sBAAU;KACX,CAAC,CAAC;IAEH,MAAM,QAAQ,GAAG,EAAE,CAAC;IACpB,MAAM,KAAK,GAAqB,EAAE,CAAC;IACnC,MAAM,cAAc,GAAoB,EAAE,CAAC;IAE3C,KAAK,MAAM,MAAM,IAAI,cAAc,EAAE,CAAC;QACpC,IAAI,MAAA,MAAA,MAAM,CAAC,IAAI,0CAAE,OAAO,0CAAE,MAAM,EAAE,CAAC;YACjC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YAChD,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;gBAC1D,MAAM,cAAc,GAAG,IAAI,sBAAS,CAClC,OAAO,CAAC,MAAM,CAAC,eAAe,CAAC,MAAM,CAAC,KAAK,CAC5C,CAAC;gBACF,MAAM,eAAe,GAAG,IAAI,sBAAS,CACnC,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAChC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iBAC5B,CACF,CACF,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;IAED,QAAQ,CAAC,IAAI,CACX,KAAK,CAAC,OAAO,CACX,sBAAU,EACV;QACE,cAAc;QACd,KAAK;KACN,EACD;QACE,MAAM,EAAE,sBAAU;QAClB,SAAS,EAAE,0BAAS,CAAC,GAAG;KACzB,CACF,CACF,CAAC;IAEF,MAAM,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;AACrC,CAAC,CAAA,CAAC;AAEF,MAAM,GAAG,GAAQ;IACf,EAAE,EAAE,GAAG,sBAAU,UAAU;IAC3B,QAAQ;IACR,KAAK,EAAE,QAAQ;CAChB,CAAC;AACF,kBAAe,GAAG,CAAC"}
|
@@ -42,18 +42,20 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
|
|
42
42
|
if (obligations.length === 0)
|
43
43
|
return [];
|
44
44
|
const mints = new Set();
|
45
|
-
const
|
45
|
+
const marketsInfo = yield cache.getItem(constants_1.marketsKey, {
|
46
46
|
prefix: constants_1.platformId,
|
47
47
|
networkId: portfolio_core_1.NetworkId.sui,
|
48
48
|
});
|
49
|
+
const lendingMarkets = marketsInfo === null || marketsInfo === void 0 ? void 0 : marketsInfo.lendingMarkets;
|
50
|
+
const rates = marketsInfo === null || marketsInfo === void 0 ? void 0 : marketsInfo.rates;
|
51
|
+
const ratesByReserveId = (0, helpers_1.getRatesAsMap)(rates);
|
49
52
|
const marketsByIndex = new Map();
|
50
|
-
if (
|
51
|
-
|
53
|
+
if (lendingMarkets)
|
54
|
+
marketsInfo.lendingMarkets.forEach((market) => {
|
52
55
|
marketsByIndex.set(market.id.id, market);
|
53
56
|
});
|
54
|
-
const poolRewardById = (0, helpers_1.getPoolsRewardsAsMap)(
|
55
|
-
|
56
|
-
poolRewardById.forEach((pool) => mints.add(pool.coin_type.fields.name));
|
57
|
+
const poolRewardById = (0, helpers_1.getPoolsRewardsAsMap)(lendingMarkets);
|
58
|
+
poolRewardById.forEach((pool) => mints.add(pool.coin_type.fields.name));
|
57
59
|
const borrowedAssets = [];
|
58
60
|
const borrowedYields = [];
|
59
61
|
const suppliedAssets = [];
|
@@ -92,6 +94,10 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
|
|
92
94
|
const tokenPrice = tokenPriceById.get((0, portfolio_core_1.formatTokenAddress)(fields.coin_type.fields.name, portfolio_core_1.NetworkId.sui));
|
93
95
|
if (!tokenPrice)
|
94
96
|
continue;
|
97
|
+
const reserveRates = ratesByReserveId.get(reserve.fields.id.id);
|
98
|
+
if (reserveRates) {
|
99
|
+
suppliedYields.push([reserveRates.depositYield]);
|
100
|
+
}
|
95
101
|
const amount = new bignumber_js_1.default(fields.deposited_ctoken_amount)
|
96
102
|
.multipliedBy(cRatio)
|
97
103
|
.dividedBy(Math.pow(10, tokenPrice.decimals));
|
@@ -103,20 +109,24 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
|
|
103
109
|
}
|
104
110
|
// Borrows
|
105
111
|
for (const borrow of borrows) {
|
106
|
-
const { fields } = borrow;
|
107
|
-
const reserve = reserves.at(Number(
|
112
|
+
const { fields: userBorrowFields } = borrow;
|
113
|
+
const reserve = reserves.at(Number(userBorrowFields.reserve_array_index));
|
108
114
|
if (!reserve)
|
109
115
|
continue;
|
110
|
-
const tokenPrice = tokenPriceById.get((0, portfolio_core_1.formatTokenAddress)(
|
116
|
+
const tokenPrice = tokenPriceById.get((0, portfolio_core_1.formatTokenAddress)(userBorrowFields.coin_type.fields.name, portfolio_core_1.NetworkId.sui));
|
111
117
|
if (!tokenPrice)
|
112
118
|
continue;
|
113
|
-
const cumulativeRateRatio = new bignumber_js_1.default(reserve.fields.cumulative_borrow_rate.fields.value).dividedBy(
|
114
|
-
const amount = new bignumber_js_1.default(
|
119
|
+
const cumulativeRateRatio = new bignumber_js_1.default(reserve.fields.cumulative_borrow_rate.fields.value).dividedBy(userBorrowFields.cumulative_borrow_rate.fields.value);
|
120
|
+
const amount = new bignumber_js_1.default(userBorrowFields.borrowed_amount.fields.value)
|
115
121
|
.times(cumulativeRateRatio)
|
116
122
|
.dividedBy(Math.pow(10, (constants_2.wadsDecimal + tokenPrice.decimals)));
|
117
123
|
if (amount.isZero())
|
118
124
|
continue;
|
119
|
-
const
|
125
|
+
const reserveRates = ratesByReserveId.get(reserve.fields.id.id);
|
126
|
+
if (reserveRates) {
|
127
|
+
borrowedYields.push([reserveRates.borrowYield]);
|
128
|
+
}
|
129
|
+
const price = new bignumber_js_1.default(userBorrowFields.market_value.fields.value)
|
120
130
|
.dividedBy(Math.pow(10, constants_2.wadsDecimal))
|
121
131
|
.dividedBy(amount);
|
122
132
|
borrowedAssets.push((0, tokenPriceToAssetToken_1.default)(tokenPrice.address, amount.toNumber(), portfolio_core_1.NetworkId.sui, tokenPrice, price.toNumber()));
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"obligationsFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/suilend/obligationsFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAQoC;AACpC,gEAAqC;AAGrC,2CAKqB;AACrB,iDAAmD;AACnD,qEAAkE;
|
1
|
+
{"version":3,"file":"obligationsFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/suilend/obligationsFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAQoC;AACpC,gEAAqC;AAGrC,2CAKqB;AACrB,iDAAmD;AACnD,qEAAkE;AAOlE,qEAAkE;AAClE,qGAA6E;AAC7E,uCAAgE;AAChE,mDAAkD;AAElD,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;;IACtE,MAAM,MAAM,GAAG,IAAA,sBAAY,GAAE,CAAC;IAE9B,MAAM,oBAAoB,GAAG,MAAM,IAAA,iCAAe,EAChD,MAAM,EACN,KAAK,EACL;QACE,MAAM,EAAE,EAAE,OAAO,EAAE,qBAAS,EA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,qCAAoB,CAAC,UAAU;QACrC,SAAS,EAAE,0BAAS,CAAC,GAAG;QACxB,UAAU,EAAV,sBAAU;QACV,KAAK,EAAE,SAAS;QAChB,KAAK;QACL,IAAI,EAAE;YACJ,cAAc;YACd,aAAa;YACb,cAAc;YACd,cAAc;YACd,aAAa;YACb,cAAc;YACd,eAAe,EAAE,IAAI;YACrB,WAAW;YACX,YAAY;YACZ,WAAW;YACX,KAAK;SACN;KACF,CAAC;IACF,OAAO,CAAC,OAAO,CAAC,CAAC;AACnB,CAAC,CAAA,CAAC;AAEF,MAAM,OAAO,GAAY;IACvB,EAAE,EAAE,GAAG,sBAAU,cAAc;IAC/B,SAAS,EAAE,0BAAS,CAAC,GAAG;IACxB,QAAQ;CACT,CAAC;AAEF,kBAAe,OAAO,CAAC"}
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import { BorrowLendRate } from '@sonarwatch/portfolio-core';
|
1
2
|
import { ParsedData } from '../../utils/sui/types';
|
2
3
|
export type ObligationCapFields = {
|
3
4
|
id: ID;
|
@@ -47,6 +48,10 @@ export type Reward = {
|
|
47
48
|
earned_rewards: ParsedData<Value>;
|
48
49
|
pool_reward_id: string;
|
49
50
|
};
|
51
|
+
export type MarketsInfo = {
|
52
|
+
lendingMarkets: LendingMarket[];
|
53
|
+
rates: BorrowLendRate[];
|
54
|
+
};
|
50
55
|
export type LendingMarket = {
|
51
56
|
id: ID;
|
52
57
|
version: string;
|
@@ -54,30 +54,30 @@ function sushiV3PairToUniV2(pair) {
|
|
54
54
|
}
|
55
55
|
function getV3PairsAddresses(url, length = 300) {
|
56
56
|
return __awaiter(this, void 0, void 0, function* () {
|
57
|
-
const query = (0, graphql_request_1.gql) `
|
58
|
-
{
|
59
|
-
pools(
|
60
|
-
orderBy: totalValueLockedUSD
|
61
|
-
first: ${length}
|
62
|
-
orderDirection: desc
|
63
|
-
where: { volumeUSD_not: "0", liquidity_not: "0" }
|
64
|
-
) {
|
65
|
-
id
|
66
|
-
token0Price
|
67
|
-
token1Price
|
68
|
-
liquidity
|
69
|
-
token0 {
|
70
|
-
id
|
71
|
-
totalSupply
|
72
|
-
decimals
|
73
|
-
}
|
74
|
-
token1 {
|
75
|
-
id
|
76
|
-
totalSupply
|
77
|
-
decimals
|
78
|
-
}
|
79
|
-
}
|
80
|
-
}
|
57
|
+
const query = (0, graphql_request_1.gql) `
|
58
|
+
{
|
59
|
+
pools(
|
60
|
+
orderBy: totalValueLockedUSD
|
61
|
+
first: ${length}
|
62
|
+
orderDirection: desc
|
63
|
+
where: { volumeUSD_not: "0", liquidity_not: "0" }
|
64
|
+
) {
|
65
|
+
id
|
66
|
+
token0Price
|
67
|
+
token1Price
|
68
|
+
liquidity
|
69
|
+
token0 {
|
70
|
+
id
|
71
|
+
totalSupply
|
72
|
+
decimals
|
73
|
+
}
|
74
|
+
token1 {
|
75
|
+
id
|
76
|
+
totalSupply
|
77
|
+
decimals
|
78
|
+
}
|
79
|
+
}
|
80
|
+
}
|
81
81
|
`;
|
82
82
|
const res = yield (0, graphql_request_1.default)(url, query);
|
83
83
|
const pools = res.pools;
|
@@ -40,28 +40,28 @@ function getPairKey(version) {
|
|
40
40
|
exports.getPairKey = getPairKey;
|
41
41
|
function getPairsV2FromTheGraph(url, length = 300) {
|
42
42
|
return __awaiter(this, void 0, void 0, function* () {
|
43
|
-
const query = (0, graphql_request_1.gql) `
|
44
|
-
{
|
45
|
-
pairs(
|
46
|
-
orderBy: reserveUSD
|
47
|
-
first: ${length}
|
48
|
-
orderDirection: desc
|
49
|
-
where: { trackedReserveETH_not: "0" }
|
50
|
-
) {
|
51
|
-
id
|
52
|
-
reserve0
|
53
|
-
reserve1
|
54
|
-
totalSupply
|
55
|
-
token0 {
|
56
|
-
id
|
57
|
-
decimals
|
58
|
-
}
|
59
|
-
token1 {
|
60
|
-
id
|
61
|
-
decimals
|
62
|
-
}
|
63
|
-
}
|
64
|
-
}
|
43
|
+
const query = (0, graphql_request_1.gql) `
|
44
|
+
{
|
45
|
+
pairs(
|
46
|
+
orderBy: reserveUSD
|
47
|
+
first: ${length}
|
48
|
+
orderDirection: desc
|
49
|
+
where: { trackedReserveETH_not: "0" }
|
50
|
+
) {
|
51
|
+
id
|
52
|
+
reserve0
|
53
|
+
reserve1
|
54
|
+
totalSupply
|
55
|
+
token0 {
|
56
|
+
id
|
57
|
+
decimals
|
58
|
+
}
|
59
|
+
token1 {
|
60
|
+
id
|
61
|
+
decimals
|
62
|
+
}
|
63
|
+
}
|
64
|
+
}
|
65
65
|
`;
|
66
66
|
const res = yield (0, graphql_request_1.default)(url, query);
|
67
67
|
const pairs = res.pairs;
|
@@ -1,16 +1,16 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.poolQueryMsg = exports.minterQueryMsg = exports.tokenInfoQueryMsg = exports.infoQueryMsg = void 0;
|
4
|
-
exports.infoQueryMsg = JSON.parse(`{
|
5
|
-
"info": {}
|
4
|
+
exports.infoQueryMsg = JSON.parse(`{
|
5
|
+
"info": {}
|
6
6
|
}`);
|
7
|
-
exports.tokenInfoQueryMsg = JSON.parse(`{
|
8
|
-
"token_info": {}
|
7
|
+
exports.tokenInfoQueryMsg = JSON.parse(`{
|
8
|
+
"token_info": {}
|
9
9
|
}`);
|
10
|
-
exports.minterQueryMsg = JSON.parse(`{
|
11
|
-
"minter": {}
|
10
|
+
exports.minterQueryMsg = JSON.parse(`{
|
11
|
+
"minter": {}
|
12
12
|
}`);
|
13
|
-
exports.poolQueryMsg = JSON.parse(`{
|
14
|
-
"pool": {}
|
13
|
+
exports.poolQueryMsg = JSON.parse(`{
|
14
|
+
"pool": {}
|
15
15
|
}`);
|
16
16
|
//# sourceMappingURL=constants.js.map
|
@@ -1,10 +1,10 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
function getQueryBalanceByOwner(owner) {
|
4
|
-
return JSON.parse(`{
|
5
|
-
"balance": {
|
6
|
-
"address": "${owner}"
|
7
|
-
}
|
4
|
+
return JSON.parse(`{
|
5
|
+
"balance": {
|
6
|
+
"address": "${owner}"
|
7
|
+
}
|
8
8
|
}`);
|
9
9
|
}
|
10
10
|
exports.default = getQueryBalanceByOwner;
|