@sonarwatch/portfolio-plugins 0.14.152 → 0.14.153
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/CHANGELOG.md +2232 -2228
- package/README.md +3 -3
- package/package.json +1 -1
- package/src/plugins/balancer/helpers/pools.js +21 -21
- package/src/plugins/drift/spotMarketsJob.js +0 -1
- package/src/plugins/drift/spotMarketsJob.js.map +1 -1
- package/src/plugins/ensofi/index.js +2 -1
- package/src/plugins/ensofi/index.js.map +1 -1
- package/src/plugins/ensofi/solanaLoansJob.d.ts +3 -0
- package/src/plugins/ensofi/solanaLoansJob.js +63 -0
- package/src/plugins/ensofi/solanaLoansJob.js.map +1 -0
- package/src/plugins/ensofi/structs.js +2 -2
- package/src/plugins/ensofi/structs.js.map +1 -1
- package/src/plugins/kamino/reservesJob.js +35 -0
- package/src/plugins/kamino/reservesJob.js.map +1 -1
- package/src/plugins/loopscale/constants.d.ts +2 -3
- package/src/plugins/loopscale/constants.js +3 -4
- package/src/plugins/loopscale/constants.js.map +1 -1
- package/src/plugins/loopscale/helpers.d.ts +6 -33
- package/src/plugins/loopscale/helpers.js +39 -142
- package/src/plugins/loopscale/helpers.js.map +1 -1
- package/src/plugins/loopscale/index.js +10 -3
- package/src/plugins/loopscale/index.js.map +1 -1
- package/src/plugins/loopscale/lendFetcher.js +57 -0
- package/src/plugins/loopscale/lendFetcher.js.map +1 -0
- package/src/plugins/loopscale/lendVaultsFetcher.d.ts +6 -0
- package/src/plugins/loopscale/lendVaultsFetcher.js +68 -0
- package/src/plugins/loopscale/lendVaultsFetcher.js.map +1 -0
- package/src/plugins/loopscale/loansFetcher.d.ts +3 -0
- package/src/plugins/loopscale/loansFetcher.js +79 -0
- package/src/plugins/loopscale/loansFetcher.js.map +1 -0
- package/src/plugins/loopscale/structs.d.ts +116 -86
- package/src/plugins/loopscale/structs.js +101 -79
- package/src/plugins/loopscale/structs.js.map +1 -1
- package/src/plugins/loopscale/types.d.ts +6 -0
- package/src/plugins/loopscale/types.js +3 -0
- package/src/plugins/loopscale/types.js.map +1 -0
- package/src/plugins/loopscale/vaultsJob.d.ts +3 -0
- package/src/plugins/loopscale/vaultsJob.js +121 -0
- package/src/plugins/loopscale/vaultsJob.js.map +1 -0
- package/src/plugins/lulo/depositsFetcher.js +9 -29
- package/src/plugins/lulo/depositsFetcher.js.map +1 -1
- package/src/plugins/marginfi/banksJob.js +6 -2
- package/src/plugins/marginfi/banksJob.js.map +1 -1
- package/src/plugins/marginfi/constants.d.ts +5 -3
- package/src/plugins/marginfi/constants.js +8 -7
- package/src/plugins/marginfi/constants.js.map +1 -1
- package/src/plugins/marginfi/depositsFetcher.js +50 -27
- package/src/plugins/marginfi/depositsFetcher.js.map +1 -1
- package/src/plugins/marginfi/getMarginFiAccounts.d.ts +6 -0
- package/src/plugins/marginfi/getMarginFiAccounts.js +44 -0
- package/src/plugins/marginfi/getMarginFiAccounts.js.map +1 -0
- package/src/plugins/marginfi/helpers.d.ts +0 -5
- package/src/plugins/marginfi/helpers.js +1 -81
- package/src/plugins/marginfi/helpers.js.map +1 -1
- package/src/plugins/marginfi/structs/MarginfiAccount.d.ts +5 -0
- package/src/plugins/marginfi/structs/MarginfiAccount.js.map +1 -1
- package/src/plugins/suilend/helpers.js +2 -0
- package/src/plugins/suilend/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/misc/getLendingMarketAprs.d.ts +3 -1
- package/src/utils/misc/getLendingMarketAprs.js +24 -1
- package/src/utils/misc/getLendingMarketAprs.js.map +1 -1
- package/src/utils/sei/constants.js +8 -8
- package/src/utils/sei/getQueryBalanceByOwner.js +4 -4
- package/src/plugins/loopscale/filters.d.ts +0 -9
- package/src/plugins/loopscale/filters.js +0 -62
- package/src/plugins/loopscale/filters.js.map +0 -1
- package/src/plugins/loopscale/positionsFetcher.js +0 -119
- package/src/plugins/loopscale/positionsFetcher.js.map +0 -1
- package/src/plugins/marginfi/filters.d.ts +0 -5
- package/src/plugins/marginfi/filters.js +0 -45
- package/src/plugins/marginfi/filters.js.map +0 -1
- /package/src/plugins/loopscale/{positionsFetcher.d.ts → lendFetcher.d.ts} +0 -0
@@ -11,38 +11,61 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
12
12
|
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
13
13
|
const constants_1 = require("./constants");
|
14
|
-
const MarginfiAccount_1 = require("./structs/MarginfiAccount");
|
15
14
|
const helpers_1 = require("./helpers");
|
16
|
-
const
|
17
|
-
const
|
18
|
-
const clients_1 = require("../../utils/clients");
|
15
|
+
const ElementRegistry_1 = require("../../utils/elementbuilder/ElementRegistry");
|
16
|
+
const getMarginFiAccounts_1 = require("./getMarginFiAccounts");
|
19
17
|
const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* () {
|
20
|
-
const
|
21
|
-
|
22
|
-
if (accounts.length === 0)
|
18
|
+
const marginFiAccounts = yield (0, getMarginFiAccounts_1.getMarginFiAccounts)(owner, cache);
|
19
|
+
if (!marginFiAccounts)
|
23
20
|
return [];
|
24
|
-
const
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
const banksInfoByAddress = new Map();
|
31
|
-
const tokensAddresses = new Set();
|
32
|
-
banksInfo.forEach((bankInfo) => {
|
33
|
-
if (!bankInfo)
|
21
|
+
const elementRegistry = new ElementRegistry_1.ElementRegistry(portfolio_core_1.NetworkId.solana, constants_1.platformId);
|
22
|
+
marginFiAccounts.forEach((marginfiAccount) => {
|
23
|
+
if (!marginfiAccount)
|
24
|
+
return;
|
25
|
+
const { balances } = marginfiAccount;
|
26
|
+
if (!balances || balances.length === 0)
|
34
27
|
return;
|
35
|
-
|
36
|
-
|
28
|
+
balances.forEach((balance) => {
|
29
|
+
if (!balance)
|
30
|
+
return;
|
31
|
+
const element = elementRegistry.addElementBorrowlend({
|
32
|
+
label: 'Lending',
|
33
|
+
ref: marginfiAccount.pubkey.toString(),
|
34
|
+
link: 'https://app.marginfi.com/portfolio',
|
35
|
+
});
|
36
|
+
if (!balance.assetShares.value.isZero()) {
|
37
|
+
const suppliedAmount = (0, helpers_1.wrappedI80F48toBigNumber)(balance.assetShares)
|
38
|
+
.times(balance.bank.dividedAssetShareValue)
|
39
|
+
.toNumber();
|
40
|
+
element.addSuppliedAsset({
|
41
|
+
address: balance.bank.mint,
|
42
|
+
amount: suppliedAmount,
|
43
|
+
alreadyShifted: true,
|
44
|
+
sourceRefs: [
|
45
|
+
{ name: 'Lending Market', address: balance.bankPk.toString() },
|
46
|
+
],
|
47
|
+
});
|
48
|
+
element.addSuppliedLtv(balance.bank.suppliedLtv);
|
49
|
+
element.addSuppliedYield(balance.bank.suppliedYields);
|
50
|
+
}
|
51
|
+
if (!balance.liabilityShares.value.isZero()) {
|
52
|
+
const borrowedAmount = (0, helpers_1.wrappedI80F48toBigNumber)(balance.liabilityShares)
|
53
|
+
.times(balance.bank.dividedLiabilityShareValue)
|
54
|
+
.toNumber();
|
55
|
+
element.addBorrowedAsset({
|
56
|
+
address: balance.bank.mint,
|
57
|
+
amount: borrowedAmount,
|
58
|
+
alreadyShifted: true,
|
59
|
+
sourceRefs: [
|
60
|
+
{ name: 'Lending Market', address: balance.bankPk.toString() },
|
61
|
+
],
|
62
|
+
});
|
63
|
+
element.addBorrowedWeight(balance.bank.borrowedWeight);
|
64
|
+
element.addBorrowedYield(balance.bank.borrowedYields);
|
65
|
+
}
|
66
|
+
});
|
37
67
|
});
|
38
|
-
|
39
|
-
const elements = [];
|
40
|
-
for (const account of accounts) {
|
41
|
-
const element = (0, helpers_1.getElementFromAccount)(account, banksInfoByAddress, tokenPriceById);
|
42
|
-
if (element)
|
43
|
-
elements.push(element);
|
44
|
-
}
|
45
|
-
return elements;
|
68
|
+
return elementRegistry.getElements(cache);
|
46
69
|
});
|
47
70
|
const fetcher = {
|
48
71
|
id: `${constants_1.platformId}-deposits`,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"depositsFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/marginfi/depositsFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,+
|
1
|
+
{"version":3,"file":"depositsFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/marginfi/depositsFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,+DAAuD;AACvD,2CAAyC;AACzC,uCAAqD;AAGrD,gFAA6E;AAC7E,+DAA4D;AAE5D,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;IACtE,MAAM,gBAAgB,GAAG,MAAM,IAAA,yCAAmB,EAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IAEjE,IAAI,CAAC,gBAAgB;QAAE,OAAO,EAAE,CAAC;IAEjC,MAAM,eAAe,GAAG,IAAI,iCAAe,CAAC,0BAAS,CAAC,MAAM,EAAE,sBAAU,CAAC,CAAC;IAE1E,gBAAgB,CAAC,OAAO,CAAC,CAAC,eAAe,EAAE,EAAE;QAC3C,IAAI,CAAC,eAAe;YAAE,OAAO;QAC7B,MAAM,EAAE,QAAQ,EAAE,GAAG,eAAe,CAAC;QACrC,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO;QAE/C,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC3B,IAAI,CAAC,OAAO;gBAAE,OAAO;YACrB,MAAM,OAAO,GAAG,eAAe,CAAC,oBAAoB,CAAC;gBACnD,KAAK,EAAE,SAAS;gBAChB,GAAG,EAAE,eAAe,CAAC,MAAM,CAAC,QAAQ,EAAE;gBACtC,IAAI,EAAE,oCAAoC;aAC3C,CAAC,CAAC;YAEH,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,MAAM,EA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AC,IAAI,CAAC,cAAc,CAAC,CAAC;YACxD,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,eAAe,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;AAC5C,CAAC,CAAA,CAAC;AAEF,MAAM,OAAO,GAAY;IACvB,EAAE,EAAE,GAAG,sBAAU,WAAW;IAC5B,SAAS,EAAE,0BAAS,CAAC,MAAM;IAC3B,QAAQ;CACT,CAAC;AAEF,kBAAe,OAAO,CAAC"}
|
@@ -0,0 +1,6 @@
|
|
1
|
+
import { BalanceWithBank, MarginfiAccount } from './structs/MarginfiAccount';
|
2
|
+
import { Cache } from '../../Cache';
|
3
|
+
import { ParsedAccount } from '../../utils/solana';
|
4
|
+
export declare const getMarginFiAccounts: (authority: string, cache: Cache) => Promise<((ParsedAccount<MarginfiAccount> & {
|
5
|
+
balances: (BalanceWithBank | null)[];
|
6
|
+
}) | null)[]>;
|
@@ -0,0 +1,44 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
+
});
|
10
|
+
};
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
+
exports.getMarginFiAccounts = void 0;
|
13
|
+
const clients_1 = require("../../utils/clients");
|
14
|
+
const ParsedGpa_1 = require("../../utils/solana/beets/ParsedGpa");
|
15
|
+
const MarginfiAccount_1 = require("./structs/MarginfiAccount");
|
16
|
+
const constants_1 = require("./constants");
|
17
|
+
const getMarginFiAccounts = (authority, cache) => __awaiter(void 0, void 0, void 0, function* () {
|
18
|
+
const client = (0, clients_1.getClientSolana)();
|
19
|
+
const accounts = yield ParsedGpa_1.ParsedGpa.build(client, MarginfiAccount_1.marginfiAccountStruct, constants_1.marginfiProgramId)
|
20
|
+
.addRawFilter(0, 'CKkRR4La3xu')
|
21
|
+
.addRawFilter(8, constants_1.MarginfiAccountAddress)
|
22
|
+
.addRawFilter(40, authority)
|
23
|
+
.run();
|
24
|
+
if (accounts.length === 0)
|
25
|
+
return [];
|
26
|
+
const banksInfoByAddress = yield constants_1.marginFiBanksMemo.getItem(cache);
|
27
|
+
if (!banksInfoByAddress)
|
28
|
+
throw new Error('MarginFi banks not cached');
|
29
|
+
return accounts.map((marginfiAccount) => {
|
30
|
+
const { balances } = marginfiAccount.lendingAccount;
|
31
|
+
if (!balances || balances.length === 0)
|
32
|
+
return null;
|
33
|
+
return Object.assign(Object.assign({}, marginfiAccount), { balances: balances.map((balance) => {
|
34
|
+
if (balance.bankPk.toString() === '11111111111111111111111111111111')
|
35
|
+
return null;
|
36
|
+
const bank = banksInfoByAddress.get(balance.bankPk.toString());
|
37
|
+
if (!bank)
|
38
|
+
return null;
|
39
|
+
return Object.assign(Object.assign({}, balance), { bank });
|
40
|
+
}) });
|
41
|
+
});
|
42
|
+
});
|
43
|
+
exports.getMarginFiAccounts = getMarginFiAccounts;
|
44
|
+
//# sourceMappingURL=getMarginFiAccounts.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"getMarginFiAccounts.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/marginfi/getMarginFiAccounts.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iDAAsD;AACtD,kEAA+D;AAC/D,+DAImC;AACnC,2CAIqB;AAId,MAAM,mBAAmB,GAAG,CACjC,SAAiB,EACjB,KAAY,EAQZ,EAAE;IACF,MAAM,MAAM,GAAG,IAAA,yBAAe,GAAE,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
import { PortfolioElement, TokenPrice } from '@sonarwatch/portfolio-core';
|
3
2
|
import { Bank } from './structs/Bank';
|
4
|
-
import { MarginfiAccount } from './structs/MarginfiAccount';
|
5
|
-
import { BankInfo } from './types';
|
6
|
-
import { ParsedAccount } from '../../utils/solana';
|
7
3
|
export declare function wrappedI80F48toBigNumber({ value }: {
|
8
4
|
value: BigNumber;
|
9
5
|
}, scaleDecimal?: number): BigNumber;
|
@@ -11,4 +7,3 @@ export declare function computeInterestRates(bank: Bank): {
|
|
11
7
|
lendingApr: number;
|
12
8
|
borrowingApr: number;
|
13
9
|
};
|
14
|
-
export declare function getElementFromAccount(marginfiAccount: ParsedAccount<MarginfiAccount>, banksInfoByAddress: Map<string, BankInfo>, tokenPriceById: Map<string, TokenPrice>): PortfolioElement | null;
|
@@ -3,12 +3,9 @@ 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.
|
6
|
+
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");
|
12
9
|
function wrappedI80F48toBigNumber({ value }, scaleDecimal = 0) {
|
13
10
|
if (!value)
|
14
11
|
return new bignumber_js_1.default(0);
|
@@ -61,81 +58,4 @@ function computeInterestRates(bank) {
|
|
61
58
|
return { lendingApr, borrowingApr };
|
62
59
|
}
|
63
60
|
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
|
-
let name;
|
76
|
-
for (let index = 0; index < balances.length; index += 1) {
|
77
|
-
const balance = balances[index];
|
78
|
-
if (balance.bankPk.toString() === '11111111111111111111111111111111')
|
79
|
-
continue;
|
80
|
-
const bankInfo = banksInfoByAddress.get(balance.bankPk.toString());
|
81
|
-
if (!bankInfo)
|
82
|
-
continue;
|
83
|
-
const tokenPrice = tokenPriceById.get(bankInfo.mint.toString());
|
84
|
-
if (!balance.assetShares.value.isZero()) {
|
85
|
-
suppliedLtvs.push(bankInfo.suppliedLtv);
|
86
|
-
const suppliedAmount = wrappedI80F48toBigNumber(balance.assetShares)
|
87
|
-
.times(bankInfo.dividedAssetShareValue)
|
88
|
-
.toNumber();
|
89
|
-
// If one of the deposited asset is a stake collateral, show it inside the element name
|
90
|
-
if ((tokenPrice === null || tokenPrice === void 0 ? void 0 : tokenPrice.elementName) === 'Stake Collateral')
|
91
|
-
name = 'Stake Collateral';
|
92
|
-
suppliedAssets.push(Object.assign(Object.assign({}, (0, tokenPriceToAssetToken_1.default)(bankInfo.mint.toString(), suppliedAmount, portfolio_core_1.NetworkId.solana, tokenPrice)), { sourceRefs: [
|
93
|
-
{ name: 'Lending Market', address: balance.bankPk.toString() },
|
94
|
-
] }));
|
95
|
-
suppliedYields.push(bankInfo.suppliedYields);
|
96
|
-
}
|
97
|
-
if (!balance.liabilityShares.value.isZero()) {
|
98
|
-
borrowedWeights.push(bankInfo.borrowedWeight);
|
99
|
-
const borrowedAmount = wrappedI80F48toBigNumber(balance.liabilityShares)
|
100
|
-
.times(bankInfo.dividedLiabilityShareValue)
|
101
|
-
.toNumber();
|
102
|
-
borrowedAssets.push(Object.assign(Object.assign({}, (0, tokenPriceToAssetToken_1.default)(bankInfo.mint.toString(), borrowedAmount, portfolio_core_1.NetworkId.solana, tokenPrice)), { sourceRefs: [
|
103
|
-
{ name: 'Lending Market', address: balance.bankPk.toString() },
|
104
|
-
] }));
|
105
|
-
borrowedYields.push(bankInfo.borrowedYields);
|
106
|
-
}
|
107
|
-
}
|
108
|
-
if (suppliedAssets.length === 0 && borrowedAssets.length === 0)
|
109
|
-
return null;
|
110
|
-
const { borrowedValue, healthRatio, suppliedValue, value, rewardValue } = (0, portfolio_core_1.getElementLendingValues)({
|
111
|
-
suppliedAssets,
|
112
|
-
borrowedAssets,
|
113
|
-
rewardAssets,
|
114
|
-
suppliedLtvs,
|
115
|
-
borrowedWeights,
|
116
|
-
});
|
117
|
-
return {
|
118
|
-
type: portfolio_core_1.PortfolioElementType.borrowlend,
|
119
|
-
networkId: portfolio_core_1.NetworkId.solana,
|
120
|
-
platformId: constants_1.platformId,
|
121
|
-
label: 'Lending',
|
122
|
-
value,
|
123
|
-
data: {
|
124
|
-
borrowedAssets,
|
125
|
-
borrowedValue,
|
126
|
-
borrowedYields,
|
127
|
-
suppliedAssets,
|
128
|
-
suppliedValue,
|
129
|
-
suppliedYields,
|
130
|
-
healthRatio,
|
131
|
-
rewardAssets,
|
132
|
-
rewardValue,
|
133
|
-
value,
|
134
|
-
ref: marginfiAccount.pubkey.toString(),
|
135
|
-
link: 'https://app.marginfi.com/portfolio',
|
136
|
-
},
|
137
|
-
name,
|
138
|
-
};
|
139
|
-
}
|
140
|
-
exports.getElementFromAccount = getElementFromAccount;
|
141
61
|
//# 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/margin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C,CAAC;IAErD,MAAM,WAAW,GAAG,gBAAgB,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;IAC5D,MAAM,aAAa,GAAG,gBAAgB;SACnC,KAAK,CAAC,IAAI,sBAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;SACrC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAElB,MAAM,UAAU,GAAG,WAAW,CAAC,QAAQ,EAAE,CAAC;IAC1C,MAAM,YAAY,GAAG,aAAa,CAAC,QAAQ,EAAE,CAAC;IAE9C,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,CAAC;AACtC,CAAC;AA9BD,oDA8BC"}
|
@@ -3,7 +3,9 @@
|
|
3
3
|
/// <reference types="jito-ts/node_modules/@solana/web3.js" />
|
4
4
|
import { BeetStruct, FixableBeetStruct } from '@metaplex-foundation/beet';
|
5
5
|
import { PublicKey } from '@solana/web3.js';
|
6
|
+
import { ParsedAccount } from '../../../utils/solana';
|
6
7
|
import { WrappedI80F48 } from './common';
|
8
|
+
import { BankInfo } from '../types';
|
7
9
|
export type Balance = {
|
8
10
|
active: number;
|
9
11
|
bankPk: PublicKey;
|
@@ -12,6 +14,9 @@ export type Balance = {
|
|
12
14
|
liabilityShares: WrappedI80F48;
|
13
15
|
padding: Buffer[];
|
14
16
|
};
|
17
|
+
export type BalanceWithBank = Balance & {
|
18
|
+
bank: ParsedAccount<BankInfo>;
|
19
|
+
};
|
15
20
|
export declare const balanceStruct: BeetStruct<Balance, Partial<Balance>>;
|
16
21
|
export type LendingAccount = {
|
17
22
|
balances: Balance[];
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"MarginfiAccount.js","sourceRoot":"","sources":["../../../../../../../packages/plugins/src/plugins/marginfi/structs/MarginfiAccount.ts"],"names":[],"mappings":";;;AAAA,oDAKmC;AACnC,kEAA6D;AAE7D,
|
1
|
+
{"version":3,"file":"MarginfiAccount.js","sourceRoot":"","sources":["../../../../../../../packages/plug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RatesAsMap(borrowLendRates) {
|
|
38
38
|
return ratesByReserveId;
|
39
39
|
for (const borrowLendRate of borrowLendRates) {
|
40
40
|
const id = borrowLendRate.poolName;
|
41
|
+
if (!id)
|
42
|
+
continue;
|
41
43
|
ratesByReserveId.set(id, borrowLendRate);
|
42
44
|
}
|
43
45
|
return ratesByReserveId;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/suilend/helpers.ts"],"names":[],"mappings":";;;;;;AAAA,gEAAqC;AAIrC,SAAgB,mBAAmB,CACjC,cAA2C;IAE3C,MAAM,cAAc,GAAmB,IAAI,GAAG,EAAE,CAAC;IACjD,MAAM,sBAAsB,GAA2B,IAAI,GAAG,EAAE,CAAC;IACjE,IAAI,CAAC,cAAc;QAAE,OAAO,CAAC,cAAc,EAAE,sBAAsB,CAAC,CAAC;IAErE,KAAK,MAAM,aAAa,IAAI,cAAc,EAAE,CAAC;QAC3C,MAAM,EAAE,QAAQ,EAAE,GAAG,aAAa,CAAC;QACnC,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;YAC/B,MAAM,oBAAoB,GACxB,OAAO,CAAC,MAAM,CAAC,4BAA4B,CAAC,MAAM,CAAC,YAAY,CAAC;YAClE,KAAK,MAAM,UAAU,IAAI,oBAAoB,EAAE,CAAC;gBAC9C,IAAI,CAAC,UAAU,IAAI,CAAC,UAAU,CAAC,MAAM;oBAAE,SAAS;gBAChD,cAAc,CAAC,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;YACjE,CAAC;YACD,sBAAsB,CAAC,GAAG,CACxB,OAAO,CAAC,MAAM,CAAC,4BAA4B,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,EACxD,oBAAoB,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC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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"}
|
@@ -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,3 +1,4 @@
|
|
1
|
+
import { BorrowLendRate } from '@sonarwatch/portfolio-core';
|
1
2
|
import BigNumber from 'bignumber.js';
|
2
3
|
/**
|
3
4
|
* Get both Lending and Borrowing APRs of a market
|
@@ -10,7 +11,8 @@ import BigNumber from 'bignumber.js';
|
|
10
11
|
*
|
11
12
|
* @returns {Aprs} BorrowApr and DepositApr of the market in raw value (i.e 0.02 = 2%)
|
12
13
|
*/
|
13
|
-
export
|
14
|
+
export declare function getLendingMarketAprs(borrowedAmount: BigNumber, availableAmount: BigNumber, interestRateAprs: number[], interestRateSteps: number[], spreadFeeBps: number): Aprs;
|
15
|
+
export declare function getLendingMarketBLRate(tokenAddress: string, netBorrowedAmount: BigNumber, netAvailableAmount: BigNumber, interestRateAprs: number[], interestRateSteps: number[], spreadFeeBps: number, platformId: string, poolName?: string): BorrowLendRate;
|
14
16
|
type Aprs = {
|
15
17
|
borrowApr: number;
|
16
18
|
depositApr: number;
|
@@ -3,6 +3,8 @@ 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.getLendingMarketBLRate = exports.getLendingMarketAprs = void 0;
|
7
|
+
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
6
8
|
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
7
9
|
/**
|
8
10
|
* Get both Lending and Borrowing APRs of a market
|
@@ -54,5 +56,26 @@ function getLendingMarketAprs(borrowedAmount, availableAmount, interestRateAprs,
|
|
54
56
|
depositApr,
|
55
57
|
};
|
56
58
|
}
|
57
|
-
exports.
|
59
|
+
exports.getLendingMarketAprs = getLendingMarketAprs;
|
60
|
+
function getLendingMarketBLRate(tokenAddress, netBorrowedAmount, netAvailableAmount, interestRateAprs, interestRateSteps, spreadFeeBps, platformId, poolName) {
|
61
|
+
const { borrowApr, depositApr } = getLendingMarketAprs(netBorrowedAmount, netAvailableAmount, interestRateAprs, interestRateSteps, spreadFeeBps);
|
62
|
+
const depositedAmount = netBorrowedAmount.plus(netAvailableAmount).toNumber();
|
63
|
+
return {
|
64
|
+
tokenAddress,
|
65
|
+
depositedAmount,
|
66
|
+
utilizationRatio: netBorrowedAmount.dividedBy(depositedAmount).toNumber(),
|
67
|
+
borrowYield: {
|
68
|
+
apy: (0, portfolio_core_1.aprToApy)(borrowApr),
|
69
|
+
apr: borrowApr,
|
70
|
+
},
|
71
|
+
borrowedAmount: 0,
|
72
|
+
depositYield: {
|
73
|
+
apy: (0, portfolio_core_1.aprToApy)(depositApr),
|
74
|
+
apr: depositApr,
|
75
|
+
},
|
76
|
+
platformId,
|
77
|
+
poolName,
|
78
|
+
};
|
79
|
+
}
|
80
|
+
exports.getLendingMarketBLRate = getLendingMarketBLRate;
|
58
81
|
//# sourceMappingURL=getLendingMarketAprs.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"getLendingMarketAprs.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/misc/getLendingMarketAprs.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"getLendingMarketAprs.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/misc/getLendingMarketAprs.ts"],"names":[],"mappings":";;;;;;AAAA,+DAAsE;AACtE,gEAAqC;AAErC;;;;;;;;;;GAUG;AACH,SAAgB,oBAAoB,CAClC,cAAyB,EACzB,eAA0B,EAC1B,gBAA0B,EAC1B,iBAA2B,EAC3B,YAAoB;IAEpB,IAAI,gBAAgB,CAAC,MAAM,KAAK,iBAAiB,CAAC,MAAM;QACtD,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;IAErE,MAAM,WAAW,GAAG,cAAc,CAAC,SAAS,CAC1C,eAAe,CAAC,IAAI,CAAC,cAAc,CAAC,CACrC,CAAC;IACF,IAAI,SAAS,GAAG,CAAC,CAAC;IAClB,IAAI,cAAc,CAAC,MAAM,EAAE;QACzB,SAAS,GAAG,IAAA,sBAAS,EAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAC;IACvE,IAAI,eAAe,CAAC,MAAM,EAAE;QAC1B,SAAS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AAG,MAAM,CAAC,YAAY,CAAC,GAAG,GAAG,CAAC;SACrC,KAAK,CAAC,WAAW,CAAC;SAClB,QAAQ,EAAE,CAAC;IAEd,OAAO;QACL,SAAS;QACT,UAAU;KACX,CAAC;AACJ,CAAC;AAnDD,oDAmDC;AAED,SAAgB,sBAAsB,CACpC,YAAoB,EACpB,iBAA4B,EAC5B,kBAA6B,EAC7B,gBAA0B,EAC1B,iBAA2B,EAC3B,YAAoB,EACpB,UAAkB,EAClB,QAAiB;IAEjB,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,oBAAoB,CACpD,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,YAAY,CACb,CAAC;IACF,MAAM,eAAe,GAAG,iBAAiB,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC,QAAQ,EAAE,CAAC;IAC9E,OAAO;QACL,YAAY;QACZ,eAAe;QACf,gBAAgB,EAAE,iBAAiB,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC,QAAQ,EAAE;QACzE,WAAW,EAAE;YACX,GAAG,EAAE,IAAA,yBAAQ,EAAC,SAAS,CAAC;YACxB,GAAG,EAAE,SAAS;SACf;QACD,cAAc,EAAE,CAAC;QACjB,YAAY,EAAE;YACZ,GAAG,EAAE,IAAA,yBAAQ,EAAC,UAAU,CAAC;YACzB,GAAG,EAAE,UAAU;SAChB;QACD,UAAU;QACV,QAAQ;KACT,CAAC;AACJ,CAAC;AAlCD,wDAkCC"}
|
@@ -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;
|
@@ -1,9 +0,0 @@
|
|
1
|
-
/// <reference types="@drift-labs/sdk/node_modules/@solana/web3.js" />
|
2
|
-
/// <reference types="jito-ts/node_modules/@solana/web3.js" />
|
3
|
-
import { GetProgramAccountsFilter } from '@solana/web3.js';
|
4
|
-
export declare const roleFilters: (owner: string) => GetProgramAccountsFilter[];
|
5
|
-
export declare const escrowFilters: (organization_identifier: string) => GetProgramAccountsFilter[];
|
6
|
-
export declare const orderFilters: (organization_identifier: string) => GetProgramAccountsFilter[];
|
7
|
-
export declare const loanVaultLentFilters: (borrower: string) => GetProgramAccountsFilter[];
|
8
|
-
export declare const loanVaultBorrowedFilters: (borrower: string) => GetProgramAccountsFilter[];
|
9
|
-
export declare const lockboxFilters: (nft: string) => GetProgramAccountsFilter[];
|