@sonarwatch/portfolio-plugins 0.14.5 → 0.14.6
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +4 -0
- package/package.json +1 -1
- package/src/plugins/lulo/depositsFetcher.js +1 -17
- package/src/plugins/lulo/depositsFetcher.js.map +1 -1
- package/src/plugins/save/constants.d.ts +2 -0
- package/src/plugins/save/constants.js +9 -1
- package/src/plugins/save/constants.js.map +1 -1
- package/src/plugins/save/helpers.d.ts +3 -3
- package/src/plugins/save/helpers.js +122 -121
- package/src/plugins/save/helpers.js.map +1 -1
- package/src/plugins/save/index.js +1 -1
- package/src/plugins/save/index.js.map +1 -1
- package/src/plugins/save/obligationsFetcher.js +14 -34
- package/src/plugins/save/obligationsFetcher.js.map +1 -1
- package/src/utils/elementbuilder/ElementRegistry.js.map +1 -1
package/CHANGELOG.md
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
4
4
|
|
5
|
+
## [0.14.6](https://github.com/sonarwatch/portfolio/compare/plugins-0.14.5...plugins-0.14.6) (2024-10-17)
|
6
|
+
|
7
|
+
|
8
|
+
|
5
9
|
## [0.14.5](https://github.com/sonarwatch/portfolio/compare/plugins-0.14.4...plugins-0.14.5) (2024-10-17)
|
6
10
|
|
7
11
|
|
package/package.json
CHANGED
@@ -25,7 +25,6 @@ const clients_1 = require("../../utils/clients");
|
|
25
25
|
const struct_1 = require("./struct");
|
26
26
|
const structs_1 = require("../save/structs");
|
27
27
|
const constants_3 = require("../save/constants");
|
28
|
-
const getMultipleAccountsInfoSafe_1 = require("../../utils/solana/getMultipleAccountsInfoSafe");
|
29
28
|
const helpers_2 = require("../save/helpers");
|
30
29
|
const MarginfiAccount_1 = require("../marginfi/structs/MarginfiAccount");
|
31
30
|
const constants_4 = require("../marginfi/constants");
|
@@ -67,28 +66,13 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
|
|
67
66
|
networkId: portfolio_core_1.NetworkId.solana,
|
68
67
|
});
|
69
68
|
if (reservesInfos.length !== 0) {
|
70
|
-
const mints = [];
|
71
|
-
const pythAddresses = [];
|
72
69
|
const reserveByAddress = new Map();
|
73
70
|
reservesInfos.forEach((reserve) => {
|
74
71
|
if (!reserve)
|
75
72
|
return;
|
76
|
-
pythAddresses.push(new web3_js_1.PublicKey(reserve.reserve.liquidity.pythOracle));
|
77
|
-
mints.push(reserve.reserve.liquidity.mintPubkey);
|
78
73
|
reserveByAddress.set(reserve.pubkey, reserve);
|
79
74
|
});
|
80
|
-
const
|
81
|
-
(0, getMultipleAccountsInfoSafe_1.getMultipleAccountsInfoSafe)(client, pythAddresses),
|
82
|
-
cache.getTokenPricesAsMap(mints, portfolio_core_1.NetworkId.solana),
|
83
|
-
]);
|
84
|
-
const pythAccByAddress = new Map();
|
85
|
-
for (let i = 0; i < pythAddresses.length; i++) {
|
86
|
-
const account = pythAccounts[i];
|
87
|
-
if (account === null)
|
88
|
-
continue;
|
89
|
-
pythAccByAddress.set(pythAddresses[i].toString(), account);
|
90
|
-
}
|
91
|
-
const solendElements = (0, helpers_2.getElementsFromObligations)([saveObligation], reserveByAddress, new Map([[constants_3.mainMarket, mainMarketInfo]]), tokenPriceByAddress, pythAccByAddress);
|
75
|
+
const solendElements = yield (0, helpers_2.getElementsFromObligations)([saveObligation], reserveByAddress, new Map([[constants_3.mainMarket, mainMarketInfo]]), owner, cache);
|
92
76
|
portfolioElements.push(...solendElements);
|
93
77
|
}
|
94
78
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"depositsFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/lulo/depositsFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAAyE;AACzE,
|
1
|
+
{"version":3,"file":"depositsFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/lulo/depositsFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAAyE;AACzE,6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K,MAAM,OAAO,IAAI,iBAAiB,EAAE,CAAC;QACxC,MAAM,UAAU,GAAG,OAAO,CAAC;QAC3B,UAAU,CAAC,IAAI;YACb,UAAU,CAAC,UAAU,KAAK,gCAAoB,CAAC,EAAE;gBAC/C,CAAC,CAAC,gBAAgB;gBAClB,CAAC,CAAC,UAAU,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE;oBAC/C,UAAU,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACrC,UAAU,CAAC,UAAU,GAAG,sBAAU,CAAC;QACnC,QAAQ,CAAC,IAAI,mBACR,UAAU,EACb,CAAC;IACL,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,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"}
|
@@ -1,7 +1,9 @@
|
|
1
1
|
import { PublicKey } from '@solana/web3.js';
|
2
2
|
import { Platform } from '@sonarwatch/portfolio-core';
|
3
3
|
export declare const platformId = "save";
|
4
|
+
export declare const platformDumpyId = "dumpy";
|
4
5
|
export declare const platform: Platform;
|
6
|
+
export declare const platformDumpy: Platform;
|
5
7
|
export declare const marketsPrefix = "save-markets";
|
6
8
|
export declare const marketsKey = "markets";
|
7
9
|
export declare const reservesPrefix = "save-reserves";
|
@@ -1,8 +1,9 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.slndMint = exports.externalRewardStatsEndpoint = exports.rewardProofsEndpoint = exports.mainMarket = exports.wadsDecimal = exports.reserveEndpoint = exports.marketsEndpoint = exports.merkleProgramId = exports.pid = exports.rewardStatsKey = exports.rewardStatsPrefix = exports.reservesPrefix = exports.marketsKey = exports.marketsPrefix = exports.platform = exports.platformId = void 0;
|
3
|
+
exports.slndMint = exports.externalRewardStatsEndpoint = exports.rewardProofsEndpoint = exports.mainMarket = exports.wadsDecimal = exports.reserveEndpoint = exports.marketsEndpoint = exports.merkleProgramId = exports.pid = exports.rewardStatsKey = exports.rewardStatsPrefix = exports.reservesPrefix = exports.marketsKey = exports.marketsPrefix = exports.platformDumpy = exports.platform = exports.platformDumpyId = exports.platformId = void 0;
|
4
4
|
const web3_js_1 = require("@solana/web3.js");
|
5
5
|
exports.platformId = 'save';
|
6
|
+
exports.platformDumpyId = 'dumpy';
|
6
7
|
exports.platform = {
|
7
8
|
id: exports.platformId,
|
8
9
|
name: 'Save',
|
@@ -10,6 +11,13 @@ exports.platform = {
|
|
10
11
|
defiLlamaId: 'save',
|
11
12
|
website: 'https://save.finance/',
|
12
13
|
};
|
14
|
+
exports.platformDumpy = {
|
15
|
+
id: exports.platformDumpyId,
|
16
|
+
name: 'Dumpy',
|
17
|
+
image: 'https://sonar.watch/img/platforms/dumpy.webp',
|
18
|
+
// defiLlamaId: 'dumpy',
|
19
|
+
website: 'https://dumpy.fun/',
|
20
|
+
};
|
13
21
|
exports.marketsPrefix = `${exports.platformId}-markets`;
|
14
22
|
exports.marketsKey = 'markets';
|
15
23
|
exports.reservesPrefix = `${exports.platformId}-reserves`;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/save/constants.ts"],"names":[],"mappings":";;;AAAA,6CAA4C;AAG/B,QAAA,UAAU,GAAG,MAAM,CAAC;AACpB,QAAA,QAAQ,GAAa;IAChC,EAAE,EAAE,kBAAU;IACd,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,6CAA6C;IACpD,WAAW,EAAE,MAAM;IACnB,OAAO,EAAE,uBAAuB;CACjC,CAAC;
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/save/constants.ts"],"names":[],"mappings":";;;AAAA,6CAA4C;AAG/B,QAAA,UAAU,GAAG,MAAM,CAAC;AACpB,QAAA,eAAe,GAAG,OAAO,CAAC;AAE1B,QAAA,QAAQ,GAAa;IAChC,EAAE,EAAE,kBAAU;IACd,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,6CAA6C;IACpD,WAAW,EAAE,MAAM;IACnB,OAAO,EAAE,uBAAuB;CACjC,CAAC;AAEW,QAAA,aAAa,GAAa;IACrC,EAAE,EAAE,uBAAe;IACnB,IAAI,EAAE,OAAO;IACb,KAAK,EAAE,8CAA8C;IACrD,wBAAwB;IACxB,OAAO,EAAE,oBAAoB;CAC9B,CAAC;AAEW,QAAA,aAAa,GAAG,GAAG,kBAAU,UAAU,CAAC;AACxC,QAAA,UAAU,GAAG,SAAS,CAAC;AACvB,QAAA,cAAc,GAAG,GAAG,kBAAU,WAAW,CAAC;AAC1C,QAAA,iBAAiB,GAAG,GAAG,kBAAU,eAAe,CAAC;AACjD,QAAA,cAAc,GAAG,cAAc,CAAC;AAEhC,QAAA,GAAG,GAAG,IAAI,mBAAS,CAAC,6CAA6C,CAAC,CAAC;AACnE,QAAA,eAAe,GAAG,IAAI,mBAAS,CAC1C,6CAA6C,CAC9C,CAAC;AACW,QAAA,eAAe,GAAG,6CAA6C,CAAC;AAChE,QAAA,eAAe,GAAG,4CAA4C,CAAC;AAC/D,QAAA,WAAW,GAAG,EAAE,CAAC;AACjB,QAAA,UAAU,GAAG,8CAA8C,CAAC;AAC5D,QAAA,oBAAoB,GAC/B,qEAAqE,CAAC;AAC3D,QAAA,2BAA2B,GACtC,8EAA8E,CAAC;AAEpE,QAAA,QAAQ,GAAG,6CAA6C,CAAC"}
|
@@ -1,9 +1,9 @@
|
|
1
1
|
/// <reference types="node" />
|
2
|
-
import { PortfolioElement
|
3
|
-
import { AccountInfo } from '@solana/web3.js';
|
2
|
+
import { PortfolioElement } from '@sonarwatch/portfolio-core';
|
4
3
|
import { Obligation } from './structs';
|
5
4
|
import { ParsedAccount } from '../../utils/solana';
|
6
5
|
import { MarketInfo, ReserveInfo } from './types';
|
6
|
+
import { Cache } from '../../Cache';
|
7
7
|
export declare const upperFirst: (string: string) => string;
|
8
8
|
export declare function getObligationSeed(marketAddress: string, accountId: number): string;
|
9
9
|
export declare const parseDataflat: (dataFlat: Buffer, depositsLen: number, borrowsLen: number) => {
|
@@ -12,4 +12,4 @@ export declare const parseDataflat: (dataFlat: Buffer, depositsLen: number, borr
|
|
12
12
|
borrows: import("./structs").ObligationLiquidity[];
|
13
13
|
borrowsMap: Map<string, import("./structs").ObligationLiquidity>;
|
14
14
|
};
|
15
|
-
export declare function getElementsFromObligations(obligations: ParsedAccount<Obligation>[], reserveByAddress: Map<string, ReserveInfo>, marketByAddress: Map<string, MarketInfo>,
|
15
|
+
export declare function getElementsFromObligations(obligations: ParsedAccount<Obligation>[], reserveByAddress: Map<string, ReserveInfo>, marketByAddress: Map<string, MarketInfo>, owner: string, cache: Cache): Promise<PortfolioElement[]>;
|
@@ -1,4 +1,13 @@
|
|
1
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
|
+
};
|
2
11
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
13
|
};
|
@@ -6,10 +15,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
15
|
exports.getElementsFromObligations = exports.parseDataflat = exports.getObligationSeed = exports.upperFirst = void 0;
|
7
16
|
const beet_1 = require("@metaplex-foundation/beet");
|
8
17
|
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
18
|
+
const web3_js_1 = require("@solana/web3.js");
|
9
19
|
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
10
20
|
const structs_1 = require("./structs");
|
11
21
|
const constants_1 = require("./constants");
|
12
|
-
const
|
22
|
+
const ElementRegistry_1 = require("../../utils/elementbuilder/ElementRegistry");
|
13
23
|
const upperFirst = (string) => string ? string.charAt(0).toUpperCase() + string.slice(1) : '';
|
14
24
|
exports.upperFirst = upperFirst;
|
15
25
|
function getObligationSeed(marketAddress, accountId) {
|
@@ -34,132 +44,123 @@ const parseDataflat = (dataFlat, depositsLen, borrowsLen) => {
|
|
34
44
|
};
|
35
45
|
};
|
36
46
|
exports.parseDataflat = parseDataflat;
|
37
|
-
function getElementsFromObligations(obligations, reserveByAddress, marketByAddress,
|
38
|
-
|
39
|
-
|
40
|
-
const
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
continue;
|
46
|
-
const { depositsMap, borrowsMap } = (0, exports.parseDataflat)(obligation.dataFlat, obligation.depositsLen, obligation.borrowsLen);
|
47
|
-
if (depositsMap.size === 0 && borrowsMap.size === 0)
|
48
|
-
continue;
|
49
|
-
const borrowedAssets = [];
|
50
|
-
const borrowedYields = [];
|
51
|
-
const suppliedAssets = [];
|
52
|
-
const suppliedYields = [];
|
53
|
-
const rewardAssets = [];
|
54
|
-
const suppliedLtvs = [];
|
55
|
-
const borrowedWeights = [];
|
56
|
-
for (let j = 0; j < market.reserves.length; j += 1) {
|
57
|
-
const { address: reserveAddress } = market.reserves[j];
|
58
|
-
const reserveInfo = reserveByAddress.get(reserveAddress);
|
59
|
-
if (!reserveInfo)
|
47
|
+
function getElementsFromObligations(obligations, reserveByAddress, marketByAddress, owner, cache) {
|
48
|
+
return __awaiter(this, void 0, void 0, function* () {
|
49
|
+
const obligationAddressesRelatedToSavePlatform = yield getObligationAddressesRelatedToSavePlatform(owner, marketByAddress);
|
50
|
+
const elementRegistrySave = new ElementRegistry_1.ElementRegistry(portfolio_core_1.NetworkId.solana, constants_1.platformId);
|
51
|
+
const elementRegistryDumpy = new ElementRegistry_1.ElementRegistry(portfolio_core_1.NetworkId.solana, constants_1.platformDumpyId);
|
52
|
+
for (let i = 0; i < obligations.length; i += 1) {
|
53
|
+
const obligation = obligations[i];
|
54
|
+
if (!obligation)
|
60
55
|
continue;
|
61
|
-
const
|
62
|
-
|
63
|
-
const lMint = liquidity.mintPubkey;
|
64
|
-
const lTokenPrice = tokenPriceByAddress.get(lMint);
|
65
|
-
let price;
|
66
|
-
if (!lTokenPrice) {
|
56
|
+
const market = marketByAddress.get(obligation.lendingMarket.toString());
|
57
|
+
if (!market)
|
67
58
|
continue;
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
.
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
.
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
59
|
+
const { depositsMap, borrowsMap } = (0, exports.parseDataflat)(obligation.dataFlat, obligation.depositsLen, obligation.borrowsLen);
|
60
|
+
if (depositsMap.size === 0 && borrowsMap.size === 0)
|
61
|
+
continue;
|
62
|
+
const element = (obligationAddressesRelatedToSavePlatform === null || obligationAddressesRelatedToSavePlatform === void 0 ? void 0 : obligationAddressesRelatedToSavePlatform.includes(obligation.pubkey.toString()))
|
63
|
+
? elementRegistrySave.addElementBorrowlend({
|
64
|
+
label: 'Lending',
|
65
|
+
})
|
66
|
+
: elementRegistryDumpy.addElementBorrowlend({
|
67
|
+
label: 'Lending',
|
68
|
+
});
|
69
|
+
for (let j = 0; j < market.reserves.length; j += 1) {
|
70
|
+
const { address: reserveAddress } = market.reserves[j];
|
71
|
+
const reserveInfo = reserveByAddress.get(reserveAddress);
|
72
|
+
if (!reserveInfo)
|
73
|
+
continue;
|
74
|
+
const { reserve } = reserveInfo;
|
75
|
+
const { liquidity, collateral } = reserve;
|
76
|
+
const lMint = liquidity.mintPubkey;
|
77
|
+
const decimals = liquidity.mintDecimals;
|
78
|
+
const reserveBorrowAmount = new bignumber_js_1.default(liquidity.borrowedAmountWads)
|
79
|
+
.dividedBy(Math.pow(10, (constants_1.wadsDecimal + decimals)))
|
80
|
+
.toNumber();
|
81
|
+
const reserveAvailableAmount = new bignumber_js_1.default(liquidity.availableAmount)
|
82
|
+
.dividedBy(Math.pow(10, decimals))
|
83
|
+
.toNumber();
|
84
|
+
const collateralSupply = new bignumber_js_1.default(collateral.mintTotalSupply)
|
85
|
+
.dividedBy(Math.pow(10, decimals))
|
86
|
+
.toNumber();
|
87
|
+
const reserveDepositAmount = reserveBorrowAmount + reserveAvailableAmount;
|
88
|
+
// Deposit
|
89
|
+
const deposit = depositsMap.get(reserveAddress);
|
90
|
+
if (deposit) {
|
91
|
+
if (!deposit.depositedAmount.isZero()) {
|
92
|
+
const suppliedAmount = deposit.depositedAmount
|
93
|
+
.div(Math.pow(10, decimals))
|
94
|
+
.times(reserveDepositAmount / collateralSupply)
|
95
|
+
.toNumber();
|
96
|
+
element.addSuppliedLtv(reserve.config.liquidationThreshold / 100);
|
97
|
+
const apy = +reserveInfo.rates.supplyInterest / 100;
|
98
|
+
const cSuppliedYields = [
|
99
|
+
{
|
100
|
+
apr: (0, portfolio_core_1.apyToApr)(apy),
|
101
|
+
apy,
|
102
|
+
},
|
103
|
+
];
|
104
|
+
element.addSuppliedYield(cSuppliedYields);
|
105
|
+
element.addSuppliedAsset({
|
106
|
+
address: lMint,
|
107
|
+
amount: suppliedAmount,
|
108
|
+
alreadyShifted: true,
|
109
|
+
});
|
110
|
+
}
|
105
111
|
}
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
.
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
.
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
112
|
+
// Borrow
|
113
|
+
const borrow = borrowsMap.get(reserveAddress);
|
114
|
+
if (borrow) {
|
115
|
+
if (!borrow.borrowedAmountWads.isZero()) {
|
116
|
+
const borrowedAmount = borrow.borrowedAmountWads
|
117
|
+
.times(new bignumber_js_1.default(liquidity.cumulativeBorrowRateWads))
|
118
|
+
.div(borrow.cumulativeBorrowRateWads)
|
119
|
+
.dividedBy(new bignumber_js_1.default(Math.pow(10, (constants_1.wadsDecimal + decimals))))
|
120
|
+
.toNumber();
|
121
|
+
element.addBorrowedWeight(new bignumber_js_1.default(reserve.config.addedBorrowWeightBPS)
|
122
|
+
.dividedBy(Math.pow(10, 4))
|
123
|
+
.plus(1)
|
124
|
+
.toNumber());
|
125
|
+
const apy = +reserveInfo.rates.borrowInterest / 100;
|
126
|
+
const cBorrowedYields = [
|
127
|
+
{
|
128
|
+
apr: -(0, portfolio_core_1.apyToApr)(apy),
|
129
|
+
apy: -apy,
|
130
|
+
},
|
131
|
+
];
|
132
|
+
element.addBorrowedYield(cBorrowedYields);
|
133
|
+
element.addSuppliedAsset({
|
134
|
+
address: lMint,
|
135
|
+
amount: borrowedAmount,
|
136
|
+
alreadyShifted: true,
|
137
|
+
});
|
138
|
+
}
|
129
139
|
}
|
130
140
|
}
|
131
141
|
}
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
borrowedAssets,
|
137
|
-
rewardAssets,
|
138
|
-
suppliedLtvs,
|
139
|
-
borrowedWeights,
|
140
|
-
});
|
141
|
-
elements.push({
|
142
|
-
type: portfolio_core_1.PortfolioElementType.borrowlend,
|
143
|
-
networkId: portfolio_core_1.NetworkId.solana,
|
144
|
-
platformId: constants_1.platformId,
|
145
|
-
label: 'Lending',
|
146
|
-
value,
|
147
|
-
name: market.name,
|
148
|
-
data: {
|
149
|
-
borrowedAssets,
|
150
|
-
borrowedValue,
|
151
|
-
borrowedYields,
|
152
|
-
suppliedAssets,
|
153
|
-
suppliedValue,
|
154
|
-
suppliedYields,
|
155
|
-
healthRatio,
|
156
|
-
rewardAssets,
|
157
|
-
rewardValue,
|
158
|
-
value,
|
159
|
-
},
|
160
|
-
});
|
161
|
-
}
|
162
|
-
return elements;
|
142
|
+
const dumpyElements = yield elementRegistryDumpy.getElements(cache);
|
143
|
+
const saveElements = yield elementRegistrySave.getElements(cache);
|
144
|
+
return [...dumpyElements, ...saveElements];
|
145
|
+
});
|
163
146
|
}
|
164
147
|
exports.getElementsFromObligations = getElementsFromObligations;
|
148
|
+
const getObligationAddressesRelatedToSavePlatform = (owner, marketsByAddress) => __awaiter(void 0, void 0, void 0, function* () {
|
149
|
+
const obligationAddressesRelatedToSavePlatform = [];
|
150
|
+
for (const marketInfo of marketsByAddress.values()) {
|
151
|
+
if (!marketInfo)
|
152
|
+
continue;
|
153
|
+
const seeds = [
|
154
|
+
getObligationSeed(marketInfo.address, 0),
|
155
|
+
getObligationSeed(marketInfo.address, 1),
|
156
|
+
getObligationSeed(marketInfo.address, 2),
|
157
|
+
];
|
158
|
+
for (let i = 0; i < seeds.length; i += 1) {
|
159
|
+
const seed = seeds[i];
|
160
|
+
const obligationAddress = yield web3_js_1.PublicKey.createWithSeed(new web3_js_1.PublicKey(owner), seed, constants_1.pid);
|
161
|
+
obligationAddressesRelatedToSavePlatform.push(obligationAddress.toString());
|
162
|
+
}
|
163
|
+
}
|
164
|
+
return obligationAddressesRelatedToSavePlatform;
|
165
|
+
});
|
165
166
|
//# sourceMappingURL=helpers.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/save/helpers.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/save/helpers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,oDAAkE;AAClE,+DAKoC;AACpC,6CAA4C;AAC5C,gEAAqC;AACrC,uCAImB;AAGnB,2CAA4E;AAC5E,gFAA6E;AAGtE,MAAM,UAAU,GAAG,CAAC,MAAc,EAAE,EAAE,CAC3C,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AADpD,QAAA,UAAU,cAC0C;AAEjE,SAAgB,iBAAiB,CAAC,aAAqB,EAAE,SAAiB;IACxE,IAAI,SAAS,KAAK,CAAC;QAAE,OAAO,aAAa,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACvD,2EAA2E;IAC3E,OAAO,aAAa,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,UAAU,SAAS,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AACtE,CAAC;AAJD,8CAIC;AAEM,MAAM,aAAa,GAAG,CAC3B,QAAgB,EAChB,WAAmB,EACnB,UAAkB,EAClB,EAAE;IACF,MAAM,yBAAyB,GAAG,IAAA,4BAAqB,EACrD,oCAA0B,EAC1B,WAAW,CACZ,CAAC;IACF,MAAM,QAAQ,GAAG,yBAAyB,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;IAC7D,MAAM,WAAW,GAAG,IAAI,GAAG,CACzB,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC,CACtD,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AC,GAAG,aAAa,EAAE,GAAG,YAAY,CAAC,CAAC;IAC7C,CAAC;CAAA;AAhID,gEAgIC;AAED,MAAM,2CAA2C,GAAG,CAClD,KAAa,EACb,gBAAyC,EACzC,EAAE;IACF,MAAM,wCAAwC,GAAa,EAAE,CAAC;IAC9D,KAAK,MAAM,UAAU,IAAI,gBAAgB,CAAC,MAAM,EAAE,EAAE,CAAC;QACnD,IAAI,CAAC,UAAU;YAAE,SAAS;QAC1B,MAAM,KAAK,GAAG;YACZ,iBAAiB,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC;YACxC,iBAAiB,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC;YACxC,iBAAiB,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC;SACzC,CAAC;QACF,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;YACzC,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;YACtB,MAAM,iBAAiB,GAAG,MAAM,mBAAS,CAAC,cAAc,CACtD,IAAI,mBAAS,CAAC,KAAK,CAAC,EACpB,IAAI,EACJ,eAAG,CACJ,CAAC;YACF,wCAAwC,CAAC,IAAI,CAC3C,iBAAiB,CAAC,QAAQ,EAAE,CAC7B,CAAC;QACJ,CAAC;IACH,CAAC;IACD,OAAO,wCAAwC,CAAC;AAClD,CAAC,CAAA,CAAC"}
|
@@ -11,7 +11,7 @@ const constants_1 = require("./constants");
|
|
11
11
|
const rewardsFetcher_1 = __importDefault(require("./rewardsFetcher"));
|
12
12
|
const rewardStatsJob_1 = __importDefault(require("./rewardStatsJob"));
|
13
13
|
const token2022wrapperJob_1 = __importDefault(require("./token2022wrapperJob"));
|
14
|
-
exports.platforms = [constants_1.platform];
|
14
|
+
exports.platforms = [constants_1.platform, constants_1.platformDumpy];
|
15
15
|
exports.jobs = [
|
16
16
|
marketsJob_1.default,
|
17
17
|
reservesJob_1.default,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/save/index.ts"],"names":[],"mappings":";;;;;;AAGA,gEAAwC;AACxC,8DAAsC;AACtC,8EAAqD;AACrD,
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/save/index.ts"],"names":[],"mappings":";;;;;;AAGA,gEAAwC;AACxC,8DAAsC;AACtC,8EAAqD;AACrD,2CAAsD;AACtD,sEAA8C;AAC9C,sEAA8C;AAC9C,gFAAwD;AAE3C,QAAA,SAAS,GAAe,CAAC,oBAAQ,EAAE,yBAAa,CAAC,CAAC;AAClD,QAAA,IAAI,GAAU;IACzB,oBAAU;IACV,qBAAW;IACX,wBAAc;IACd,6BAAmB;CACpB,CAAC;AACW,QAAA,QAAQ,GAAc,CAAC,4BAAiB,EAAE,wBAAc,CAAC,CAAC"}
|
@@ -10,16 +10,26 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
10
10
|
};
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
12
12
|
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
13
|
-
const web3_js_1 = require("@solana/web3.js");
|
14
13
|
const constants_1 = require("./constants");
|
15
14
|
const helpers_1 = require("./helpers");
|
16
15
|
const solana_1 = require("../../utils/solana");
|
17
16
|
const clients_1 = require("../../utils/clients");
|
18
17
|
const structs_1 = require("./structs");
|
19
|
-
const getMultipleAccountsInfoSafe_1 = require("../../utils/solana/getMultipleAccountsInfoSafe");
|
20
18
|
const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* () {
|
21
19
|
const client = (0, clients_1.getClientSolana)();
|
22
|
-
const
|
20
|
+
const obligationsRaw = yield (0, solana_1.getParsedProgramAccounts)(client, structs_1.obligationStruct, constants_1.pid, [
|
21
|
+
{
|
22
|
+
dataSize: 1300,
|
23
|
+
},
|
24
|
+
{
|
25
|
+
memcmp: {
|
26
|
+
offset: 42,
|
27
|
+
bytes: owner,
|
28
|
+
},
|
29
|
+
},
|
30
|
+
]);
|
31
|
+
if (!obligationsRaw.length)
|
32
|
+
return [];
|
23
33
|
const markets = yield cache.getItem(constants_1.marketsKey, {
|
24
34
|
prefix: constants_1.platformId,
|
25
35
|
networkId: portfolio_core_1.NetworkId.solana,
|
@@ -31,23 +41,6 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
|
|
31
41
|
if (market)
|
32
42
|
marketsByAddress.set(market.address.toString(), market);
|
33
43
|
});
|
34
|
-
for (const marketInfo of marketsByAddress.values()) {
|
35
|
-
if (!marketInfo)
|
36
|
-
continue;
|
37
|
-
const seeds = [
|
38
|
-
(0, helpers_1.getObligationSeed)(marketInfo.address, 0),
|
39
|
-
(0, helpers_1.getObligationSeed)(marketInfo.address, 1),
|
40
|
-
(0, helpers_1.getObligationSeed)(marketInfo.address, 2),
|
41
|
-
];
|
42
|
-
for (let i = 0; i < seeds.length; i += 1) {
|
43
|
-
const seed = seeds[i];
|
44
|
-
const obligationAddress = yield web3_js_1.PublicKey.createWithSeed(new web3_js_1.PublicKey(owner), seed, constants_1.pid);
|
45
|
-
obligationAddresses.push(obligationAddress);
|
46
|
-
}
|
47
|
-
}
|
48
|
-
const obligationsRaw = yield (0, solana_1.getParsedMultipleAccountsInfo)(client, structs_1.obligationStruct, obligationAddresses);
|
49
|
-
if (obligationsRaw.length === 0)
|
50
|
-
return [];
|
51
44
|
const obligations = [];
|
52
45
|
const reserveAddresses = new Set();
|
53
46
|
obligationsRaw.forEach((obligation) => {
|
@@ -70,25 +63,12 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
|
|
70
63
|
if (!reservesInfos)
|
71
64
|
return [];
|
72
65
|
const reserveByAddress = new Map();
|
73
|
-
const mints = new Set();
|
74
|
-
const pythAddresses = [];
|
75
66
|
reservesInfos.forEach((reserveInfo) => {
|
76
67
|
if (!reserveInfo)
|
77
68
|
return;
|
78
|
-
mints.add(reserveInfo.reserve.liquidity.mintPubkey);
|
79
69
|
reserveByAddress.set(reserveInfo.pubkey, reserveInfo);
|
80
|
-
pythAddresses.push(new web3_js_1.PublicKey(reserveInfo.reserve.liquidity.pythOracle));
|
81
70
|
});
|
82
|
-
|
83
|
-
const pythAccounts = yield (0, getMultipleAccountsInfoSafe_1.getMultipleAccountsInfoSafe)(client, pythAddresses);
|
84
|
-
const pythAccByAddress = new Map();
|
85
|
-
for (let i = 0; i < pythAddresses.length; i++) {
|
86
|
-
const account = pythAccounts[i];
|
87
|
-
if (account === null)
|
88
|
-
continue;
|
89
|
-
pythAccByAddress.set(pythAddresses[i].toString(), account);
|
90
|
-
}
|
91
|
-
return (0, helpers_1.getElementsFromObligations)(obligations, reserveByAddress, marketsByAddress, tokenPriceByAddress, pythAccByAddress);
|
71
|
+
return (0, helpers_1.getElementsFromObligations)(obligations, reserveByAddress, marketsByAddress, owner, cache);
|
92
72
|
});
|
93
73
|
const fetcher = {
|
94
74
|
id: `${constants_1.platformId}-obligations`,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"obligationsFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/save/obligationsFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,+DAAuD;
|
1
|
+
{"version":3,"file":"obligationsFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/save/obligationsFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,+DAAuD;AAGvD,2CAA0E;AAC1E,uCAAuD;AAEvD,+CAA6E;AAC7E,iDAAsD;AACtD,uCAAyD;AAEzD,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;IACtE,MAAM,MAAM,GAAG,IAAA,yBAAe,GAAE,CAAC;IAEjC,MAAM,cAAc,GAAG,MAAM,IAAA,iCAAwB,EACnD,MAAM,EACN,0BAAgB,EAChB,eAA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,EAAE,CAAC;IAExC,MAAM,aAAa,GAAG,MAAM,KAAK,CAAC,QAAQ,CACxC,KAAK,CAAC,IAAI,CAAC,gBAAgB,CAAC,EAC5B;QACE,MAAM,EAAE,0BAAc;QACtB,SAAS,EAAE,0BAAS,CAAC,MAAM;KAC5B,CACF,CAAC;IACF,IAAI,CAAC,aAAa;QAAE,OAAO,EAAE,CAAC;IAE9B,MAAM,gBAAgB,GAA6B,IAAI,GAAG,EAAE,CAAC;IAC7D,aAAa,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,EAAE;QACpC,IAAI,CAAC,WAAW;YAAE,OAAO;QAEzB,gBAAgB,CAAC,GAAG,CAAC,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACxD,CAAC,CAAC,CAAC;IAEH,OAAO,IAAA,oCAA0B,EAC/B,WAAW,EACX,gBAAgB,EAChB,gBAAgB,EAChB,KAAK,EACL,KAAK,CACN,CAAC;AACJ,CAAC,CAAA,CAAC;AAEF,MAAM,OAAO,GAAY;IACvB,EAAE,EAAE,GAAG,sBAAU,cAAc;IAC/B,SAAS,EAAE,0BAAS,CAAC,MAAM;IAC3B,QAAQ;CACT,CAAC;AAEF,kBAAe,OAAO,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ElementRegistry.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/elementbuilder/ElementRegistry.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+
|
1
|
+
{"version":3,"file":"ElementRegistry.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/elementbuilder/ElementRegistry.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+DAIoC;AAIpC,qEAAkE;AAClE,uEAAoE;AACpE,yEAAsE;AACtE,qEAAkE;AAElE,MAAa,eAAe;IAK1B,YAAY,SAAwB,EAAE,UAAkB;QACtD,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,UAAU,GAAG,UA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