@sonarwatch/portfolio-plugins 0.11.175 → 0.11.177
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +1439 -1431
- package/README.md +3 -3
- package/package.json +2 -2
- package/src/plugins/balancer/helpers/pools.js +21 -21
- package/src/plugins/bskt/index.js +1 -5
- package/src/plugins/bskt/index.js.map +1 -1
- package/src/plugins/flexlend/depositsFetcher.js +34 -10
- package/src/plugins/flexlend/depositsFetcher.js.map +1 -1
- package/src/plugins/kamino/poolsJob.js +0 -2
- package/src/plugins/kamino/poolsJob.js.map +1 -1
- package/src/plugins/marginfi/depositsFetcher.js +3 -63
- package/src/plugins/marginfi/depositsFetcher.js.map +1 -1
- package/src/plugins/marginfi/helpers.d.ts +4 -0
- package/src/plugins/marginfi/helpers.js +65 -1
- package/src/plugins/marginfi/helpers.js.map +1 -1
- 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.177",
|
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.174"
|
45
45
|
},
|
46
46
|
"main": "./src/index.js",
|
47
47
|
"types": "./src/index.d.ts"
|
@@ -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,12 +1,8 @@
|
|
1
1
|
"use strict";
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
-
};
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
3
|
exports.fetchers = exports.jobs = exports.platforms = void 0;
|
7
4
|
const constants_1 = require("./constants");
|
8
|
-
const vestingFetcher_1 = __importDefault(require("./vestingFetcher"));
|
9
5
|
exports.platforms = [constants_1.platform];
|
10
6
|
exports.jobs = [];
|
11
|
-
exports.fetchers = [
|
7
|
+
exports.fetchers = [];
|
12
8
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/bskt/index.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/bskt/index.ts"],"names":[],"mappings":";;;AAGA,2CAAuC;AAE1B,QAAA,SAAS,GAAe,CAAC,oBAAQ,CAAC,CAAC;AACnC,QAAA,IAAI,GAAU,EAAE,CAAC;AACjB,QAAA,QAAQ,GAAc,EAAE,CAAC"}
|
@@ -19,7 +19,6 @@ const helpers_1 = require("./helpers");
|
|
19
19
|
const deposits_1 = __importDefault(require("../drift/deposits"));
|
20
20
|
const lendsFetcher_1 = __importDefault(require("../kamino/lendsFetcher"));
|
21
21
|
const collateralFetcher_1 = __importDefault(require("../mango/collateralFetcher"));
|
22
|
-
const index_1 = require("../marginfi/index");
|
23
22
|
const constants_2 = require("../tokens/constants");
|
24
23
|
const getParsedAccountInfo_1 = require("../../utils/solana/getParsedAccountInfo");
|
25
24
|
const clients_1 = require("../../utils/clients");
|
@@ -28,26 +27,31 @@ const structs_1 = require("../solend/structs");
|
|
28
27
|
const constants_3 = require("../solend/constants");
|
29
28
|
const getMultipleAccountsInfoSafe_1 = require("../../utils/solana/getMultipleAccountsInfoSafe");
|
30
29
|
const helpers_2 = require("../solend/helpers");
|
30
|
+
const MarginfiAccount_1 = require("../marginfi/structs/MarginfiAccount");
|
31
|
+
const constants_4 = require("../marginfi/constants");
|
32
|
+
const helpers_3 = require("../marginfi/helpers");
|
31
33
|
const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* () {
|
32
34
|
const client = (0, clients_1.getClientSolana)();
|
33
35
|
const pda = (0, helpers_1.getDerivedAccount)(owner);
|
34
36
|
const userAccount = yield (0, getParsedAccountInfo_1.getParsedAccountInfo)(client, struct_1.userAccountStruct, new web3_js_1.PublicKey(pda));
|
35
37
|
if (!userAccount)
|
36
38
|
return [];
|
39
|
+
const isSolendActivated = userAccount.solend_obligation.toString() !==
|
40
|
+
'11111111111111111111111111111111';
|
41
|
+
const isMarginFiActivated = userAccount.mfi_account.toString() !== '11111111111111111111111111111111';
|
37
42
|
const portfolioElements = [];
|
38
|
-
const [
|
39
|
-
|
43
|
+
const [marginfiAccount, driftElements, kaminoElements, mangoElements, solendObligation,] = yield Promise.all([
|
44
|
+
isMarginFiActivated
|
45
|
+
? (0, getParsedAccountInfo_1.getParsedAccountInfo)(client, MarginfiAccount_1.marginfiAccountStruct, userAccount.mfi_account)
|
46
|
+
: undefined,
|
40
47
|
deposits_1.default.executor(pda, cache),
|
41
48
|
lendsFetcher_1.default.executor(pda, cache),
|
42
49
|
collateralFetcher_1.default.executor(pda, cache),
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
...marginElements,
|
47
|
-
...driftElements,
|
48
|
-
...kaminoElements,
|
49
|
-
...mangoElements,
|
50
|
+
isSolendActivated
|
51
|
+
? (0, getParsedAccountInfo_1.getParsedAccountInfo)(client, structs_1.obligationStruct, userAccount.solend_obligation)
|
52
|
+
: undefined,
|
50
53
|
]);
|
54
|
+
portfolioElements.push(...[...driftElements, ...kaminoElements, ...mangoElements]);
|
51
55
|
if (solendObligation) {
|
52
56
|
const mainMarketInfo = yield cache.getItem(constants_3.mainMarket, {
|
53
57
|
prefix: constants_3.marketsPrefix,
|
@@ -89,6 +93,26 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
|
|
89
93
|
}
|
90
94
|
}
|
91
95
|
}
|
96
|
+
if (marginfiAccount) {
|
97
|
+
const banksInfo = yield cache.getItem(constants_4.banksKey, {
|
98
|
+
prefix: constants_4.marginfiPlatform.id,
|
99
|
+
networkId: portfolio_core_1.NetworkId.solana,
|
100
|
+
});
|
101
|
+
if (banksInfo) {
|
102
|
+
const banksInfoByAddress = new Map();
|
103
|
+
const tokensAddresses = new Set();
|
104
|
+
banksInfo.forEach((bankInfo) => {
|
105
|
+
if (!bankInfo)
|
106
|
+
return;
|
107
|
+
banksInfoByAddress.set(bankInfo.pubkey.toString(), bankInfo);
|
108
|
+
tokensAddresses.add(bankInfo.mint.toString());
|
109
|
+
});
|
110
|
+
const tokenPriceById = yield cache.getTokenPricesAsMap(Array.from(tokensAddresses), portfolio_core_1.NetworkId.solana);
|
111
|
+
const element = (0, helpers_3.getElementFromAccount)(marginfiAccount, banksInfoByAddress, tokenPriceById);
|
112
|
+
if (element)
|
113
|
+
portfolioElements.push(element);
|
114
|
+
}
|
115
|
+
}
|
92
116
|
if (portfolioElements.length === 0)
|
93
117
|
return [];
|
94
118
|
const elements = [];
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"depositsFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/flexlend/depositsFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAAyE;AACzE,6CAAyD;AAGzD,2CAAyC;AACzC,uCAA8C;AAC9C,iEAAqD;AACrD,0EAA8D;AAC9D,mFAA6D;AAC7D,
|
1
|
+
{"version":3,"file":"depositsFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/flexlend/depositsFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAAyE;AACzE,6CAAyD;AAGzD,2CAAyC;AACzC,uCAA8C;AAC9C,iEAAqD;AACrD,0EAA8D;AAC9D,mFAA6D;AAC7D,mDAA2D;AAC3D,kFAA+E;AAC/E,iDAAsD;AACtD,qCAA6C;AAC7C,+CAAqD;AACrD,mDAAgF;AAEhF,gGAA6F;AAC7F,+CAA+D;AAC/D,yEAA4E;AAG5E,qDAAmE;AACnE,iDAA4D;AAE5D,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;IACtE,M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@@ const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
|
|
74
74
|
.flat()
|
75
75
|
: undefined;
|
76
76
|
const { tokenAmountA, tokenAmountB } = (0, vaults_1.getTokenAmountsFromInfos)(strategy, pool, position, binArrays);
|
77
|
-
if (tokenAmountA.isZero() && tokenAmountB.isZero())
|
78
|
-
continue;
|
79
77
|
const tokenAAmount = tokenAmountA
|
80
78
|
.plus(strategy.tokenAAmounts)
|
81
79
|
.div(Math.pow(10, strategy.tokenAMintDecimals.toNumber()));
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"poolsJob.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/kamino/poolsJob.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,+DAIoC;AAGpC,iDAAsD;AACtD,2CAAoD;AACpD,+CAG4B;AAC5B,gGAA6F;AAC7F,6CAM0B;AAE1B,6CAA2D;AAC3D,wDAAkE;AAClE,8CAAmD;AAEnD,MAAM,QAAQ,GAAgB,CAAO,KAAY,EAAE,EAAE;;IACnD,MAAM,MAAM,GAAG,IAAA,yBAAe,GAAE,CAAC;IACjC,MAAM,UAAU,GAAG,MAAM,IAAA,iCAAwB,EAC/C,MAAM,EACN,gCAAuB,EACvB,qBAAS,EACT,IAAA,8BAAoB,EAAC,gCAAuB,CAAC,CAC9C,CAAC;IAEF,MAAM,UAAU,GAAG,UAAU;SAC1B,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,QAAQ,EAAE,EAAE,GAAG,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC,CAAC;SACpE,IAAI,EAAE,CAAC;IAEV,MAAM,WAAW,GAAG,MAAM,KAAK,CAAC,cAAc,CAAC,UAAU,EAAE,0BAAS,CAAC,MAAM,CAAC,CAAC;IAE7E,MAAM,mBAAmB,GAA4B,IAAI,GAAG,EAAE,CAAC;IAC/D,WAAW,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE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,EAAE,EAAE,GAAG,sBAAU,QAAQ;IACzB,QAAQ;IACR,KAAK,EAAE,QAAQ;CAChB,CAAC;AACF,kBAAe,GAAG,CAAC"}
|
@@ -8,9 +8,6 @@ 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
|
-
};
|
14
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
15
12
|
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
16
13
|
const constants_1 = require("./constants");
|
@@ -19,7 +16,6 @@ const helpers_1 = require("./helpers");
|
|
19
16
|
const filters_1 = require("./filters");
|
20
17
|
const solana_1 = require("../../utils/solana");
|
21
18
|
const clients_1 = require("../../utils/clients");
|
22
|
-
const tokenPriceToAssetToken_1 = __importDefault(require("../../utils/misc/tokenPriceToAssetToken"));
|
23
19
|
const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* () {
|
24
20
|
const client = (0, clients_1.getClientSolana)();
|
25
21
|
const accounts = yield (0, solana_1.getParsedProgramAccounts)(client, MarginfiAccount_1.marginfiAccountStruct, constants_1.MarginfiProgram, (0, filters_1.accountsFilter)(owner));
|
@@ -42,65 +38,9 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
|
|
42
38
|
const tokenPriceById = yield cache.getTokenPricesAsMap(Array.from(tokensAddresses), portfolio_core_1.NetworkId.solana);
|
43
39
|
const elements = [];
|
44
40
|
for (const account of accounts) {
|
45
|
-
const
|
46
|
-
if (
|
47
|
-
|
48
|
-
const borrowedAssets = [];
|
49
|
-
const borrowedYields = [];
|
50
|
-
const suppliedAssets = [];
|
51
|
-
const suppliedYields = [];
|
52
|
-
const rewardAssets = [];
|
53
|
-
const suppliedLtvs = [];
|
54
|
-
const borrowedWeights = [];
|
55
|
-
for (let index = 0; index < balances.length; index += 1) {
|
56
|
-
const balance = balances[index];
|
57
|
-
if (balance.bankPk.toString() === '11111111111111111111111111111111')
|
58
|
-
continue;
|
59
|
-
const bankInfo = banksInfoByAddress.get(balance.bankPk.toString());
|
60
|
-
if (!bankInfo)
|
61
|
-
continue;
|
62
|
-
const tokenPrice = tokenPriceById.get(bankInfo.mint.toString());
|
63
|
-
if (!balance.assetShares.value.isZero()) {
|
64
|
-
suppliedLtvs.push(bankInfo.suppliedLtv);
|
65
|
-
const suppliedAmount = (0, helpers_1.wrappedI80F48toBigNumber)(balance.assetShares)
|
66
|
-
.times(bankInfo.dividedAssetShareValue)
|
67
|
-
.toNumber();
|
68
|
-
suppliedAssets.push((0, tokenPriceToAssetToken_1.default)(bankInfo.mint.toString(), suppliedAmount, portfolio_core_1.NetworkId.solana, tokenPrice));
|
69
|
-
suppliedYields.push(bankInfo.suppliedYields);
|
70
|
-
}
|
71
|
-
if (!balance.liabilityShares.value.isZero()) {
|
72
|
-
borrowedWeights.push(bankInfo.borrowedWeight);
|
73
|
-
const borrowedAmount = (0, helpers_1.wrappedI80F48toBigNumber)(balance.liabilityShares)
|
74
|
-
.times(bankInfo.dividedLiabilityShareValue)
|
75
|
-
.toNumber();
|
76
|
-
borrowedAssets.push((0, tokenPriceToAssetToken_1.default)(bankInfo.mint.toString(), borrowedAmount, portfolio_core_1.NetworkId.solana, tokenPrice));
|
77
|
-
borrowedYields.push(bankInfo.borrowedYields);
|
78
|
-
}
|
79
|
-
}
|
80
|
-
if (suppliedAssets.length === 0 && borrowedAssets.length === 0)
|
81
|
-
continue;
|
82
|
-
const { borrowedValue, healthRatio, suppliedValue, value, rewardValue } = (0, portfolio_core_1.getElementLendingValues)(suppliedAssets, borrowedAssets, rewardAssets, suppliedLtvs, borrowedWeights);
|
83
|
-
const element = {
|
84
|
-
type: portfolio_core_1.PortfolioElementType.borrowlend,
|
85
|
-
networkId: portfolio_core_1.NetworkId.solana,
|
86
|
-
platformId: constants_1.platformId,
|
87
|
-
label: 'Lending',
|
88
|
-
value,
|
89
|
-
data: {
|
90
|
-
borrowedAssets,
|
91
|
-
borrowedValue,
|
92
|
-
borrowedYields,
|
93
|
-
suppliedAssets,
|
94
|
-
suppliedValue,
|
95
|
-
suppliedYields,
|
96
|
-
collateralRatio: null,
|
97
|
-
healthRatio,
|
98
|
-
rewardAssets,
|
99
|
-
rewardValue,
|
100
|
-
value,
|
101
|
-
},
|
102
|
-
};
|
103
|
-
elements.push(element);
|
41
|
+
const element = (0, helpers_1.getElementFromAccount)(account, banksInfoByAddress, tokenPriceById);
|
42
|
+
if (element)
|
43
|
+
elements.push(element);
|
104
44
|
}
|
105
45
|
return elements;
|
106
46
|
});
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"depositsFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/marginfi/depositsFetcher.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"depositsFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/marginfi/depositsFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,+DAAyE;AACzE,2CAAoE;AACpE,+DAAkE;AAClE,uCAAkD;AAClD,uCAA2C;AAE3C,+CAA6E;AAC7E,iDAAsD;AAItD,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;IACtE,MAAM,MAAM,GAAG,IAAA,yBAAe,GAAE,CAAC;IACjC,MAAM,QAAQ,GAAG,MAAM,IAAA,iCAAwB,EAC7C,MAAM,EACN,uCAAqB,EACrB,2BAAe,EACf,IAAA,wBAAc,EAAC,KAAK,CAAC,CACtB,CAAC;IACF,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAErC,MAAM,SAAS,GAAG,MAAM,KAAK,CAAC,OAAO,CAA4B,oBAAQ,EAAE;QACzE,MAAM,EAAE,sBAAU;QAClB,SAAS,EAAE,0BAAS,C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
|
4
|
+
import { MarginfiAccount } from './structs/MarginfiAccount';
|
5
|
+
import { BankInfo } from './types';
|
3
6
|
export declare function wrappedI80F48toBigNumber({ value }: {
|
4
7
|
value: BigNumber;
|
5
8
|
}, scaleDecimal?: number): BigNumber;
|
@@ -7,3 +10,4 @@ export declare function computeInterestRates(bank: Bank): {
|
|
7
10
|
lendingApr: number;
|
8
11
|
borrowingApr: number;
|
9
12
|
};
|
13
|
+
export declare function getElementFromAccount(marginfiAccount: MarginfiAccount, banksInfoByAddress: Map<string, BankInfo>, tokenPriceById: Map<string, TokenPrice>): PortfolioElement | null;
|
@@ -3,9 +3,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
exports.computeInterestRates = exports.wrappedI80F48toBigNumber = void 0;
|
6
|
+
exports.getElementFromAccount = exports.computeInterestRates = exports.wrappedI80F48toBigNumber = void 0;
|
7
7
|
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
8
8
|
const decimal_js_1 = __importDefault(require("decimal.js"));
|
9
|
+
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
10
|
+
const tokenPriceToAssetToken_1 = __importDefault(require("../../utils/misc/tokenPriceToAssetToken"));
|
11
|
+
const constants_1 = require("./constants");
|
9
12
|
function wrappedI80F48toBigNumber({ value }, scaleDecimal = 0) {
|
10
13
|
if (!value)
|
11
14
|
return new bignumber_js_1.default(0);
|
@@ -58,4 +61,65 @@ function computeInterestRates(bank) {
|
|
58
61
|
return { lendingApr, borrowingApr };
|
59
62
|
}
|
60
63
|
exports.computeInterestRates = computeInterestRates;
|
64
|
+
function getElementFromAccount(marginfiAccount, banksInfoByAddress, tokenPriceById) {
|
65
|
+
const { balances } = marginfiAccount.lendingAccount;
|
66
|
+
if (!balances || balances.length === 0)
|
67
|
+
return null;
|
68
|
+
const borrowedAssets = [];
|
69
|
+
const borrowedYields = [];
|
70
|
+
const suppliedAssets = [];
|
71
|
+
const suppliedYields = [];
|
72
|
+
const rewardAssets = [];
|
73
|
+
const suppliedLtvs = [];
|
74
|
+
const borrowedWeights = [];
|
75
|
+
for (let index = 0; index < balances.length; index += 1) {
|
76
|
+
const balance = balances[index];
|
77
|
+
if (balance.bankPk.toString() === '11111111111111111111111111111111')
|
78
|
+
continue;
|
79
|
+
const bankInfo = banksInfoByAddress.get(balance.bankPk.toString());
|
80
|
+
if (!bankInfo)
|
81
|
+
continue;
|
82
|
+
const tokenPrice = tokenPriceById.get(bankInfo.mint.toString());
|
83
|
+
if (!balance.assetShares.value.isZero()) {
|
84
|
+
suppliedLtvs.push(bankInfo.suppliedLtv);
|
85
|
+
const suppliedAmount = wrappedI80F48toBigNumber(balance.assetShares)
|
86
|
+
.times(bankInfo.dividedAssetShareValue)
|
87
|
+
.toNumber();
|
88
|
+
suppliedAssets.push((0, tokenPriceToAssetToken_1.default)(bankInfo.mint.toString(), suppliedAmount, portfolio_core_1.NetworkId.solana, tokenPrice));
|
89
|
+
suppliedYields.push(bankInfo.suppliedYields);
|
90
|
+
}
|
91
|
+
if (!balance.liabilityShares.value.isZero()) {
|
92
|
+
borrowedWeights.push(bankInfo.borrowedWeight);
|
93
|
+
const borrowedAmount = wrappedI80F48toBigNumber(balance.liabilityShares)
|
94
|
+
.times(bankInfo.dividedLiabilityShareValue)
|
95
|
+
.toNumber();
|
96
|
+
borrowedAssets.push((0, tokenPriceToAssetToken_1.default)(bankInfo.mint.toString(), borrowedAmount, portfolio_core_1.NetworkId.solana, tokenPrice));
|
97
|
+
borrowedYields.push(bankInfo.borrowedYields);
|
98
|
+
}
|
99
|
+
}
|
100
|
+
if (suppliedAssets.length === 0 && borrowedAssets.length === 0)
|
101
|
+
return null;
|
102
|
+
const { borrowedValue, healthRatio, suppliedValue, value, rewardValue } = (0, portfolio_core_1.getElementLendingValues)(suppliedAssets, borrowedAssets, rewardAssets, suppliedLtvs, borrowedWeights);
|
103
|
+
return {
|
104
|
+
type: portfolio_core_1.PortfolioElementType.borrowlend,
|
105
|
+
networkId: portfolio_core_1.NetworkId.solana,
|
106
|
+
platformId: constants_1.platformId,
|
107
|
+
label: 'Lending',
|
108
|
+
value,
|
109
|
+
data: {
|
110
|
+
borrowedAssets,
|
111
|
+
borrowedValue,
|
112
|
+
borrowedYields,
|
113
|
+
suppliedAssets,
|
114
|
+
suppliedValue,
|
115
|
+
suppliedYields,
|
116
|
+
collateralRatio: null,
|
117
|
+
healthRatio,
|
118
|
+
rewardAssets,
|
119
|
+
rewardValue,
|
120
|
+
value,
|
121
|
+
},
|
122
|
+
};
|
123
|
+
}
|
124
|
+
exports.getElementFromAccount = getElementFromAccount;
|
61
125
|
//# sourceMappingURL=helpers.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/marginfi/helpers.ts"],"names":[],"mappings":";;;;;;AAAA,gEAAqC;AACrC,4DAAiC;
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/marginfi/helpers.ts"],"names":[],"mappings":";;;;;;AAAA,gEAAqC;AACrC,4DAAiC;AACjC,+DAQoC;AAIpC,qGAA6E;AAC7E,2CAAyC;AAEzC,SAAgB,wBAAwB,CACtC,EAAE,KAAK,EAAwB,EAC/B,YAAY,GAAG,CAAC;IAEhB,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,sBAAS,CAAC,CAAC,CAAC,CAAC;IAEpC,MAAM,OAAO,GAAG,IAAI,oBAAO,CACzB,GAAG,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,KAAK,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CACnE,CAAC,SAAS,CAAC,SAAA,EAAE,EAAI,YAAY,CAAA,CAAC,CAAC;IAChC,OAA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,WAAW;YACX,KAAK;SACN;KACF,CAAC;AACJ,CAAC;AA1FD,sDA0FC"}
|
@@ -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;
|