@defisaver/positions-sdk 2.1.153-dev → 2.1.154-shifter-v2-dev
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/cjs/aaveV2/index.js +2 -0
- package/cjs/claiming/index.d.ts +1 -2
- package/cjs/claiming/index.js +1 -3
- package/cjs/fluid/index.d.ts +5 -0
- package/cjs/fluid/index.js +36 -1
- package/cjs/helpers/aaveHelpers/index.js +3 -0
- package/cjs/helpers/aaveV4Helpers/index.js +1 -0
- package/cjs/helpers/compoundHelpers/index.js +2 -0
- package/cjs/helpers/curveUsdHelpers/index.js +2 -0
- package/cjs/helpers/fluidHelpers/index.js +1 -0
- package/cjs/helpers/liquityV2Helpers/index.js +1 -0
- package/cjs/helpers/llamaLendHelpers/index.js +2 -0
- package/cjs/helpers/makerHelpers/index.d.ts +1 -1
- package/cjs/helpers/makerHelpers/index.js +2 -2
- package/cjs/helpers/morphoBlueHelpers/index.js +2 -0
- package/cjs/helpers/morphoMidnightHelpers/index.js +2 -0
- package/cjs/helpers/sparkHelpers/index.js +1 -0
- package/cjs/liquity/index.js +8 -1
- package/cjs/maker/index.d.ts +7 -2
- package/cjs/maker/index.js +32 -12
- package/cjs/markets/index.d.ts +1 -0
- package/cjs/markets/index.js +3 -1
- package/cjs/markets/maker/index.d.ts +1 -0
- package/cjs/markets/maker/index.js +13 -0
- package/cjs/markets/spark/marketAssets.js +1 -1
- package/cjs/portfolio/index.d.ts +5 -1
- package/cjs/portfolio/index.js +287 -13
- package/cjs/types/aave.d.ts +2 -0
- package/cjs/types/aaveV4.d.ts +1 -0
- package/cjs/types/claiming.d.ts +1 -9
- package/cjs/types/claiming.js +0 -2
- package/cjs/types/compound.d.ts +2 -0
- package/cjs/types/fluid.d.ts +1 -0
- package/cjs/types/liquity.d.ts +1 -0
- package/cjs/types/liquityV2.d.ts +2 -0
- package/cjs/types/maker.d.ts +1 -0
- package/cjs/types/morphoBlue.d.ts +2 -0
- package/cjs/types/morphoMidnight.d.ts +1 -0
- package/cjs/types/portfolio.d.ts +26 -10
- package/cjs/types/spark.d.ts +2 -0
- package/esm/aaveV2/index.js +2 -0
- package/esm/claiming/index.d.ts +1 -2
- package/esm/claiming/index.js +1 -2
- package/esm/fluid/index.d.ts +5 -0
- package/esm/fluid/index.js +33 -0
- package/esm/helpers/aaveHelpers/index.js +3 -0
- package/esm/helpers/aaveV4Helpers/index.js +1 -0
- package/esm/helpers/compoundHelpers/index.js +2 -0
- package/esm/helpers/curveUsdHelpers/index.js +2 -0
- package/esm/helpers/fluidHelpers/index.js +1 -0
- package/esm/helpers/liquityV2Helpers/index.js +1 -0
- package/esm/helpers/llamaLendHelpers/index.js +2 -0
- package/esm/helpers/makerHelpers/index.d.ts +1 -1
- package/esm/helpers/makerHelpers/index.js +2 -2
- package/esm/helpers/morphoBlueHelpers/index.js +2 -0
- package/esm/helpers/morphoMidnightHelpers/index.js +2 -0
- package/esm/helpers/sparkHelpers/index.js +1 -0
- package/esm/liquity/index.js +8 -1
- package/esm/maker/index.d.ts +7 -2
- package/esm/maker/index.js +31 -13
- package/esm/markets/index.d.ts +1 -0
- package/esm/markets/index.js +1 -0
- package/esm/markets/maker/index.d.ts +1 -0
- package/esm/markets/maker/index.js +10 -0
- package/esm/markets/spark/marketAssets.js +1 -1
- package/esm/portfolio/index.d.ts +5 -1
- package/esm/portfolio/index.js +289 -16
- package/esm/types/aave.d.ts +2 -0
- package/esm/types/aaveV4.d.ts +1 -0
- package/esm/types/claiming.d.ts +1 -9
- package/esm/types/claiming.js +0 -2
- package/esm/types/compound.d.ts +2 -0
- package/esm/types/fluid.d.ts +1 -0
- package/esm/types/liquity.d.ts +1 -0
- package/esm/types/liquityV2.d.ts +2 -0
- package/esm/types/maker.d.ts +1 -0
- package/esm/types/morphoBlue.d.ts +2 -0
- package/esm/types/morphoMidnight.d.ts +1 -0
- package/esm/types/portfolio.d.ts +26 -10
- package/esm/types/spark.d.ts +2 -0
- package/package.json +1 -1
- package/src/aaveV2/index.ts +2 -0
- package/src/claiming/index.ts +0 -2
- package/src/fluid/index.ts +40 -0
- package/src/helpers/aaveHelpers/index.ts +3 -0
- package/src/helpers/aaveV4Helpers/index.ts +1 -0
- package/src/helpers/compoundHelpers/index.ts +2 -0
- package/src/helpers/curveUsdHelpers/index.ts +2 -0
- package/src/helpers/fluidHelpers/index.ts +1 -0
- package/src/helpers/liquityV2Helpers/index.ts +1 -0
- package/src/helpers/llamaLendHelpers/index.ts +2 -0
- package/src/helpers/makerHelpers/index.ts +2 -1
- package/src/helpers/morphoBlueHelpers/index.ts +2 -0
- package/src/helpers/morphoMidnightHelpers/index.ts +2 -0
- package/src/helpers/sparkHelpers/index.ts +1 -0
- package/src/liquity/index.ts +8 -1
- package/src/maker/index.ts +62 -29
- package/src/markets/index.ts +2 -1
- package/src/markets/maker/index.ts +10 -0
- package/src/markets/spark/marketAssets.ts +1 -1
- package/src/portfolio/index.ts +270 -14
- package/src/types/aave.ts +3 -0
- package/src/types/aaveV4.ts +1 -0
- package/src/types/claiming.ts +0 -10
- package/src/types/compound.ts +2 -0
- package/src/types/fluid.ts +1 -0
- package/src/types/liquity.ts +2 -0
- package/src/types/liquityV2.ts +2 -0
- package/src/types/maker.ts +2 -0
- package/src/types/morphoBlue.ts +2 -0
- package/src/types/morphoMidnight.ts +1 -0
- package/src/types/portfolio.ts +31 -12
- package/src/types/spark.ts +2 -0
- package/cjs/claiming/compV3.d.ts +0 -15
- package/cjs/claiming/compV3.js +0 -50
- package/esm/claiming/compV3.d.ts +0 -15
- package/esm/claiming/compV3.js +0 -46
- package/src/claiming/compV3.ts +0 -37
package/esm/portfolio/index.js
CHANGED
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import Dec from 'decimal.js';
|
|
11
11
|
import { NetworkNumber } from '../types/common';
|
|
12
|
-
import { AaveMarkets, AaveV4Spokes, CompoundMarkets, CrvUsdMarkets, LiquityV2Markets, LlamaLendMarkets, MorphoBlueMarkets, MorphoMidnightMarkets, SparkMarkets, } from '../markets';
|
|
12
|
+
import { AaveMarkets, AaveV4Spokes, CompoundMarkets, CrvUsdMarkets, LiquityV2Markets, LlamaLendMarkets, MakerActiveIlks, MorphoBlueMarkets, MorphoMidnightMarkets, SparkMarkets, } from '../markets';
|
|
13
13
|
import { _getMorphoBlueAccountData, _getMorphoBluePortfolioMarketData, getMorphoEarn } from '../morphoBlue';
|
|
14
14
|
import { _getMorphoMidnightAccountData, _getMorphoMidnightMarketData } from '../morphoMidnight';
|
|
15
15
|
import { AaveVersions, CompoundVersions, } from '../types';
|
|
@@ -19,16 +19,15 @@ import { _getCurveUsdGlobalData, _getCurveUsdUserData } from '../curveUsd';
|
|
|
19
19
|
import { _getLlamaLendGlobalData, _getLlamaLendUserData } from '../llamaLend';
|
|
20
20
|
import { _getAaveV3AccountData, _getAaveV3MarketData, getStakeAaveData } from '../aaveV3';
|
|
21
21
|
import { ZERO_ADDRESS } from '../constants';
|
|
22
|
-
import { _getMakerCdpData, _getUserCdps } from '../maker';
|
|
22
|
+
import { _getMakerCdpData, _getMakerIlksData, _getUserCdps } from '../maker';
|
|
23
23
|
import { _getAaveV2AccountData, _getAaveV2MarketsData } from '../aaveV2';
|
|
24
24
|
import { _getCompoundV2AccountData, _getCompoundV2MarketsData } from '../compoundV2';
|
|
25
25
|
import { getViemProvider } from '../services/viem';
|
|
26
26
|
import { _getLiquityTroveInfo, getLiquityStakingData } from '../liquity';
|
|
27
27
|
import { _getLiquityV2MarketData, getLiquitySAndYBold, getLiquityV2Staking } from '../liquityV2';
|
|
28
|
-
import { _getAllUserEarnPositionsWithFTokens, _getUserPositionsPortfolio } from '../fluid';
|
|
28
|
+
import { _getAllFluidMarketDataPortfolio, _getAllUserEarnPositionsWithFTokens, _getUserPositionsPortfolio } from '../fluid';
|
|
29
29
|
import { getUmbrellaData } from '../umbrella';
|
|
30
30
|
import { getMerklUnclaimedRewards, getUnclaimedRewardsForAllMarkets } from '../claiming/aaveV3';
|
|
31
|
-
import { getCompoundV3Rewards } from '../claiming/compV3';
|
|
32
31
|
import { fetchSparkAirdropRewards, fetchSparkRewards } from '../claiming/spark';
|
|
33
32
|
import { getKingRewards } from '../claiming/king';
|
|
34
33
|
import { fetchEthenaAirdropRewards } from '../claiming/ethena';
|
|
@@ -121,7 +120,6 @@ export function getPortfolioData(provider_1, network_1, defaultProvider_1, addre
|
|
|
121
120
|
rewardsData[address.toLowerCase()] = {
|
|
122
121
|
merkl: {},
|
|
123
122
|
aaveV3: {},
|
|
124
|
-
compV3: {},
|
|
125
123
|
spark: {},
|
|
126
124
|
spk: {},
|
|
127
125
|
king: {},
|
|
@@ -331,17 +329,6 @@ export function getPortfolioData(provider_1, network_1, defaultProvider_1, addre
|
|
|
331
329
|
rewardsData[address.toLowerCase()].spark[market.value] = { error: `Error fetching Spark rewards data for address ${address}`, data: null };
|
|
332
330
|
}
|
|
333
331
|
}))).flat(),
|
|
334
|
-
// CompV3 rewards
|
|
335
|
-
...compoundV3Markets.map(market => addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
|
|
336
|
-
try {
|
|
337
|
-
const compV3Rewards = yield getCompoundV3Rewards(client, network, address, market.baseMarketAddress);
|
|
338
|
-
rewardsData[address.toLowerCase()].compV3[market.value] = { error: '', data: compV3Rewards };
|
|
339
|
-
}
|
|
340
|
-
catch (error) {
|
|
341
|
-
console.error(`Error fetching Compound V3 rewards data for address ${address}:`, error);
|
|
342
|
-
rewardsData[address.toLowerCase()].compV3[market.value] = { error: `Error fetching Compound V3 rewards data for address ${address}`, data: null };
|
|
343
|
-
}
|
|
344
|
-
}))).flat(),
|
|
345
332
|
...addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
|
|
346
333
|
try {
|
|
347
334
|
const merklData = yield getMerklUnclaimedRewards(address, network);
|
|
@@ -603,4 +590,290 @@ export function getPortfolioData(provider_1, network_1, defaultProvider_1, addre
|
|
|
603
590
|
};
|
|
604
591
|
});
|
|
605
592
|
}
|
|
593
|
+
export function getShifterPortfolioData(provider_1, network_1, defaultProvider_1, addresses_1) {
|
|
594
|
+
return __awaiter(this, arguments, void 0, function* (provider, network, defaultProvider, addresses, isSim = false) {
|
|
595
|
+
const isMainnet = network === NetworkNumber.Eth;
|
|
596
|
+
const isFluidSupported = [NetworkNumber.Eth, NetworkNumber.Arb, NetworkNumber.Base, NetworkNumber.Plasma].includes(network);
|
|
597
|
+
const morphoMarkets = Object.values(MorphoBlueMarkets(network)).filter((market) => market.chainIds.includes(network));
|
|
598
|
+
const morphoMidnightMarkets = Object.values(MorphoMidnightMarkets(network)).filter((market) => market.chainIds.includes(network));
|
|
599
|
+
const compoundV3Markets = Object.values(CompoundMarkets(network)).filter((market) => market.chainIds.includes(network) && market.value !== CompoundVersions.CompoundV2);
|
|
600
|
+
const sparkMarkets = Object.values(SparkMarkets(network)).filter((market) => market.chainIds.includes(network));
|
|
601
|
+
const aaveV3Markets = [AaveVersions.AaveV3, AaveVersions.AaveV3Lido, AaveVersions.AaveV3Etherfi].map((version) => AaveMarkets(network)[version]).filter((market) => market.chainIds.includes(network));
|
|
602
|
+
const aaveV2Markets = [AaveVersions.AaveV2].map((version) => AaveMarkets(network)[version]).filter((market) => market.chainIds.includes(network));
|
|
603
|
+
const compoundV2Markets = [CompoundVersions.CompoundV2].map((version) => CompoundMarkets(network)[version]).filter((market) => market.chainIds.includes(network));
|
|
604
|
+
const crvUsdMarkets = Object.values(CrvUsdMarkets(network)).filter((market) => market.chainIds.includes(network));
|
|
605
|
+
const llamaLendMarkets = [NetworkNumber.Eth, NetworkNumber.Arb].includes(network) ? Object.values(LlamaLendMarkets(network)).filter((market) => market.chainIds.includes(network)) : [];
|
|
606
|
+
const liquityV2Markets = [NetworkNumber.Eth].includes(network) ? Object.values(LiquityV2Markets(network)) : [];
|
|
607
|
+
const aaveV4Spokes = Object.values(AaveV4Spokes(network)).filter((market) => market.chainIds.includes(network));
|
|
608
|
+
const args = [network, { batch: { multicall: { batchSize: isSim ? 2000 : 2500000 } } }];
|
|
609
|
+
const client = getViemProvider(provider, ...args);
|
|
610
|
+
const defaultClient = getViemProvider(defaultProvider, ...args);
|
|
611
|
+
const markets = {
|
|
612
|
+
morphoMarketsData: {},
|
|
613
|
+
morphoMidnightMarketsData: {},
|
|
614
|
+
compoundV3MarketsData: {},
|
|
615
|
+
sparkMarketsData: {},
|
|
616
|
+
aaveV3MarketsData: {},
|
|
617
|
+
aaveV2MarketsData: {},
|
|
618
|
+
compoundV2MarketsData: {},
|
|
619
|
+
crvUsdMarketsData: {},
|
|
620
|
+
llamaLendMarketsData: {},
|
|
621
|
+
liquityV2MarketsData: {},
|
|
622
|
+
aaveV4SpokesData: {},
|
|
623
|
+
fluidMarketsData: {},
|
|
624
|
+
makerMarketsData: {},
|
|
625
|
+
};
|
|
626
|
+
const makerCdps = {};
|
|
627
|
+
const positions = {};
|
|
628
|
+
for (const address of addresses) {
|
|
629
|
+
positions[address.toLowerCase()] = {
|
|
630
|
+
aaveV3: {},
|
|
631
|
+
aaveV4: {},
|
|
632
|
+
morphoBlue: {},
|
|
633
|
+
morphoMidnight: {},
|
|
634
|
+
compoundV3: {},
|
|
635
|
+
spark: {},
|
|
636
|
+
maker: {},
|
|
637
|
+
aaveV2: {},
|
|
638
|
+
compoundV2: {},
|
|
639
|
+
liquity: {},
|
|
640
|
+
crvUsd: {},
|
|
641
|
+
llamaLend: {},
|
|
642
|
+
fluid: {
|
|
643
|
+
error: '',
|
|
644
|
+
data: {},
|
|
645
|
+
},
|
|
646
|
+
};
|
|
647
|
+
}
|
|
648
|
+
yield Promise.allSettled([
|
|
649
|
+
// === MARKET DATA (needs to be fetched first) ===
|
|
650
|
+
...morphoMarkets.map((market) => __awaiter(this, void 0, void 0, function* () {
|
|
651
|
+
markets.morphoMarketsData[market.value] = yield _getMorphoBluePortfolioMarketData(client, network, market);
|
|
652
|
+
})),
|
|
653
|
+
...morphoMidnightMarkets.map((market) => __awaiter(this, void 0, void 0, function* () {
|
|
654
|
+
markets.morphoMidnightMarketsData[market.value] = yield _getMorphoMidnightMarketData(client, network, market);
|
|
655
|
+
})),
|
|
656
|
+
...compoundV3Markets.map((market) => __awaiter(this, void 0, void 0, function* () {
|
|
657
|
+
markets.compoundV3MarketsData[market.value] = yield _getCompoundV3MarketsData(client, network, market, defaultClient);
|
|
658
|
+
})),
|
|
659
|
+
...sparkMarkets.map((market) => __awaiter(this, void 0, void 0, function* () {
|
|
660
|
+
markets.sparkMarketsData[market.value] = yield _getSparkMarketsData(client, network, market);
|
|
661
|
+
})),
|
|
662
|
+
...aaveV3Markets.map((market) => __awaiter(this, void 0, void 0, function* () {
|
|
663
|
+
markets.aaveV3MarketsData[market.value] = yield _getAaveV3MarketData(client, network, market);
|
|
664
|
+
})),
|
|
665
|
+
...aaveV4Spokes.map((spoke) => __awaiter(this, void 0, void 0, function* () {
|
|
666
|
+
markets.aaveV4SpokesData[spoke.value] = yield _getAaveV4SpokeData(client, network, spoke);
|
|
667
|
+
})),
|
|
668
|
+
...aaveV2Markets.map((market) => __awaiter(this, void 0, void 0, function* () {
|
|
669
|
+
markets.aaveV2MarketsData[market.value] = yield _getAaveV2MarketsData(client, network, market);
|
|
670
|
+
})),
|
|
671
|
+
...compoundV2Markets.map((market) => __awaiter(this, void 0, void 0, function* () {
|
|
672
|
+
markets.compoundV2MarketsData[market.value] = yield _getCompoundV2MarketsData(client, network);
|
|
673
|
+
})),
|
|
674
|
+
...crvUsdMarkets.map((market) => __awaiter(this, void 0, void 0, function* () {
|
|
675
|
+
markets.crvUsdMarketsData[market.value] = yield _getCurveUsdGlobalData(client, network, market);
|
|
676
|
+
})),
|
|
677
|
+
...llamaLendMarkets.map((market) => __awaiter(this, void 0, void 0, function* () {
|
|
678
|
+
markets.llamaLendMarketsData[market.value] = yield _getLlamaLendGlobalData(client, network, market);
|
|
679
|
+
})),
|
|
680
|
+
...liquityV2Markets.map((market) => __awaiter(this, void 0, void 0, function* () {
|
|
681
|
+
markets.liquityV2MarketsData[market.value] = yield _getLiquityV2MarketData(client, network, market);
|
|
682
|
+
})),
|
|
683
|
+
(() => __awaiter(this, void 0, void 0, function* () {
|
|
684
|
+
if (!isFluidSupported)
|
|
685
|
+
return;
|
|
686
|
+
try {
|
|
687
|
+
markets.fluidMarketsData = yield _getAllFluidMarketDataPortfolio(client, network);
|
|
688
|
+
}
|
|
689
|
+
catch (error) {
|
|
690
|
+
console.error('Error fetching Fluid markets data:', error);
|
|
691
|
+
}
|
|
692
|
+
}))(),
|
|
693
|
+
(() => __awaiter(this, void 0, void 0, function* () {
|
|
694
|
+
if (!isMainnet)
|
|
695
|
+
return; // Maker CDPs are only available on mainnet
|
|
696
|
+
try {
|
|
697
|
+
markets.makerMarketsData = yield _getMakerIlksData(client, network, MakerActiveIlks);
|
|
698
|
+
}
|
|
699
|
+
catch (error) {
|
|
700
|
+
console.error('Error fetching Maker ilks data:', error);
|
|
701
|
+
}
|
|
702
|
+
}))(),
|
|
703
|
+
// === INDEPENDENT USER DATA (doesn't depend on market data) ===
|
|
704
|
+
...addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
|
|
705
|
+
if (!isMainnet)
|
|
706
|
+
return; // Maker CDPs are only available on mainnet
|
|
707
|
+
const makerCdp = yield _getUserCdps(client, network, address);
|
|
708
|
+
makerCdps[address.toLowerCase()] = makerCdp;
|
|
709
|
+
})),
|
|
710
|
+
...addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
|
|
711
|
+
try {
|
|
712
|
+
if (!isFluidSupported)
|
|
713
|
+
return; // Fluid is not available on Optimism
|
|
714
|
+
const userPositions = (yield _getUserPositionsPortfolio(client, network, address));
|
|
715
|
+
for (const position of userPositions) {
|
|
716
|
+
if (position.userData && new Dec(position.userData.suppliedUsd).gt(0)) {
|
|
717
|
+
positions[address.toLowerCase()].fluid.data[position.userData.nftId] = position.userData;
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
catch (error) {
|
|
722
|
+
console.error(`Error fetching Fluid positions for address ${address}:`, error);
|
|
723
|
+
positions[address.toLowerCase()].fluid = {
|
|
724
|
+
error: `Error fetching Fluid positions for address ${address}`,
|
|
725
|
+
data: {},
|
|
726
|
+
};
|
|
727
|
+
}
|
|
728
|
+
})),
|
|
729
|
+
]);
|
|
730
|
+
yield Promise.all([
|
|
731
|
+
...aaveV3Markets.map((market) => addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
|
|
732
|
+
try {
|
|
733
|
+
const accData = yield _getAaveV3AccountData(client, network, address, Object.assign({ selectedMarket: market }, markets.aaveV3MarketsData[market.value]));
|
|
734
|
+
if (new Dec(accData.suppliedUsd).gt(0))
|
|
735
|
+
positions[address.toLowerCase()].aaveV3[market.value] = { error: '', data: accData };
|
|
736
|
+
}
|
|
737
|
+
catch (error) {
|
|
738
|
+
console.error(`Error fetching AaveV3 account data for address ${address} on market ${market.value}:`, error);
|
|
739
|
+
positions[address.toLowerCase()].aaveV3[market.value] = { error: `Error fetching AaveV3 account data for address ${address} on market ${market.value}`, data: null };
|
|
740
|
+
}
|
|
741
|
+
}))).flat(),
|
|
742
|
+
...aaveV4Spokes.map((spoke) => addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
|
|
743
|
+
try {
|
|
744
|
+
const accData = yield _getAaveV4AccountData(client, network, markets.aaveV4SpokesData[spoke.value], address);
|
|
745
|
+
if (new Dec(accData.suppliedUsd).gt(0))
|
|
746
|
+
positions[address.toLowerCase()].aaveV4[spoke.value] = { error: '', data: accData };
|
|
747
|
+
}
|
|
748
|
+
catch (error) {
|
|
749
|
+
console.error(`Error fetching AaveV4 account data for address ${address} on spoke ${spoke.value}:`, error);
|
|
750
|
+
positions[address.toLowerCase()].aaveV4[spoke.value] = { error: `Error fetching AaveV4 account data for address ${address} on spoke ${spoke.value}`, data: null };
|
|
751
|
+
}
|
|
752
|
+
}))).flat(),
|
|
753
|
+
...morphoMarkets.map((market) => addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
|
|
754
|
+
try {
|
|
755
|
+
const accData = yield _getMorphoBlueAccountData(client, network, address, market, markets.morphoMarketsData[market.value]);
|
|
756
|
+
if (new Dec(accData.suppliedUsd).gt(0))
|
|
757
|
+
positions[address.toLowerCase()].morphoBlue[market.value] = { error: '', data: accData };
|
|
758
|
+
}
|
|
759
|
+
catch (error) {
|
|
760
|
+
console.error(`Error fetching MorphoBlue account data for address ${address} on market ${market.value}:`, error);
|
|
761
|
+
positions[address.toLowerCase()].morphoBlue[market.value] = { error: `Error fetching MorphoBlue account data for address ${address} on market ${market.value}`, data: null };
|
|
762
|
+
}
|
|
763
|
+
}))).flat(),
|
|
764
|
+
...morphoMidnightMarkets.map((market) => addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
|
|
765
|
+
try {
|
|
766
|
+
const accData = yield _getMorphoMidnightAccountData(client, network, address, market, markets.morphoMidnightMarketsData[market.value]);
|
|
767
|
+
if (new Dec(accData.suppliedUsd).gt(0))
|
|
768
|
+
positions[address.toLowerCase()].morphoMidnight[market.value] = { error: '', data: accData };
|
|
769
|
+
}
|
|
770
|
+
catch (error) {
|
|
771
|
+
console.error(`Error fetching MorphoMidnight account data for address ${address} on market ${market.value}:`, error);
|
|
772
|
+
positions[address.toLowerCase()].morphoMidnight[market.value] = { error: `Error fetching MorphoMidnight account data for address ${address} on market ${market.value}`, data: null };
|
|
773
|
+
}
|
|
774
|
+
}))).flat(),
|
|
775
|
+
...compoundV3Markets.map((market) => addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
|
|
776
|
+
try {
|
|
777
|
+
const accData = yield _getCompoundV3AccountData(client, network, address, ZERO_ADDRESS, { selectedMarket: market, assetsData: markets.compoundV3MarketsData[market.value].assetsData });
|
|
778
|
+
if (new Dec(accData.suppliedUsd).gt(0))
|
|
779
|
+
positions[address.toLowerCase()].compoundV3[market.value] = { error: '', data: accData };
|
|
780
|
+
}
|
|
781
|
+
catch (error) {
|
|
782
|
+
console.error(`Error fetching CompoundV3 account data for address ${address} on market ${market.value}:`, error);
|
|
783
|
+
positions[address.toLowerCase()].compoundV3[market.value] = { error: `Error fetching CompoundV3 account data for address ${address} on market ${market.value}`, data: null };
|
|
784
|
+
}
|
|
785
|
+
}))).flat(),
|
|
786
|
+
...sparkMarkets.map((market) => addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
|
|
787
|
+
try {
|
|
788
|
+
const accData = yield _getSparkAccountData(client, network, address, { selectedMarket: market, assetsData: markets.sparkMarketsData[market.value].assetsData, eModeCategoriesData: markets.sparkMarketsData[market.value].eModeCategoriesData });
|
|
789
|
+
if (new Dec(accData.suppliedUsd).gt(0))
|
|
790
|
+
positions[address.toLowerCase()].spark[market.value] = { error: '', data: accData };
|
|
791
|
+
}
|
|
792
|
+
catch (error) {
|
|
793
|
+
console.error(`Error fetching Spark account data for address ${address} on market ${market.value}:`, error);
|
|
794
|
+
positions[address.toLowerCase()].spark[market.value] = { error: `Error fetching Spark account data for address ${address} on market ${market.value}`, data: null };
|
|
795
|
+
}
|
|
796
|
+
}))).flat(),
|
|
797
|
+
...addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
|
|
798
|
+
var _a;
|
|
799
|
+
return (_a = makerCdps[address.toLowerCase()]) === null || _a === void 0 ? void 0 : _a.map((cdpInfo) => __awaiter(this, void 0, void 0, function* () {
|
|
800
|
+
try {
|
|
801
|
+
// reuse ilk data fetched for the markets payload; ilks outside the active set are fetched on demand
|
|
802
|
+
const cdpData = yield _getMakerCdpData(client, network, cdpInfo, markets.makerMarketsData[cdpInfo.ilkLabel]);
|
|
803
|
+
if (cdpData) {
|
|
804
|
+
positions[address.toLowerCase()].maker[cdpInfo.id] = { error: '', data: cdpData };
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
catch (error) {
|
|
808
|
+
console.error(`Error fetching Maker CDP data for address ${address} with ID ${cdpInfo.id}:`, error);
|
|
809
|
+
positions[address.toLowerCase()].maker[cdpInfo.id] = { error: `Error fetching Maker CDP data for address ${address} with ID ${cdpInfo.id}`, data: null };
|
|
810
|
+
}
|
|
811
|
+
}));
|
|
812
|
+
})).flat(),
|
|
813
|
+
...aaveV2Markets.map((market) => addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
|
|
814
|
+
try {
|
|
815
|
+
const accData = yield _getAaveV2AccountData(client, network, address, markets.aaveV2MarketsData[market.value].assetsData, market);
|
|
816
|
+
if (new Dec(accData.suppliedUsd).gt(0))
|
|
817
|
+
positions[address.toLowerCase()].aaveV2[market.value] = { error: '', data: accData };
|
|
818
|
+
}
|
|
819
|
+
catch (error) {
|
|
820
|
+
console.error(`Error fetching AaveV2 account data for address ${address}:`, error);
|
|
821
|
+
positions[address.toLowerCase()].aaveV2[market.value] = { error: `Error fetching AaveV2 account data for address ${address}`, data: null };
|
|
822
|
+
}
|
|
823
|
+
}))).flat(),
|
|
824
|
+
...compoundV2Markets.map((market) => addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
|
|
825
|
+
try {
|
|
826
|
+
const accData = yield _getCompoundV2AccountData(client, network, address, markets.compoundV2MarketsData[market.value].assetsData);
|
|
827
|
+
if (new Dec(accData.suppliedUsd).gt(0))
|
|
828
|
+
positions[address.toLowerCase()].compoundV2[market.value] = { error: '', data: accData };
|
|
829
|
+
}
|
|
830
|
+
catch (error) {
|
|
831
|
+
console.error(`Error fetching CompoundV2 account data for address ${address}:`, error);
|
|
832
|
+
positions[address.toLowerCase()].compoundV2[market.value] = { error: `Error fetching CompoundV2 account data for address ${address}`, data: null };
|
|
833
|
+
}
|
|
834
|
+
}))).flat(),
|
|
835
|
+
...addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
|
|
836
|
+
try {
|
|
837
|
+
if (!isMainnet)
|
|
838
|
+
return; // Liquity trove info is only available on mainnet
|
|
839
|
+
const troveInfo = yield _getLiquityTroveInfo(client, network, address);
|
|
840
|
+
if (new Dec(troveInfo.collateral).gt(0))
|
|
841
|
+
positions[address.toLowerCase()].liquity = { error: '', data: troveInfo };
|
|
842
|
+
}
|
|
843
|
+
catch (error) {
|
|
844
|
+
console.error(`Error fetching Liquity trove info for address ${address}:`, error);
|
|
845
|
+
positions[address.toLowerCase()].liquity = { error: `Error fetching Liquity trove info for address ${address}`, data: null };
|
|
846
|
+
}
|
|
847
|
+
})),
|
|
848
|
+
...crvUsdMarkets.map((market) => addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
|
|
849
|
+
try {
|
|
850
|
+
const accData = yield _getCurveUsdUserData(client, network, address, market, markets.crvUsdMarketsData[market.value].activeBand);
|
|
851
|
+
if (new Dec(accData.suppliedUsd).gt(0) || new Dec(accData.borrowedUsd).gt(0)) {
|
|
852
|
+
positions[address.toLowerCase()].crvUsd[market.value] = { error: '', data: Object.assign(Object.assign({}, accData), { borrowRate: markets.crvUsdMarketsData[market.value].borrowRate }) };
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
catch (error) {
|
|
856
|
+
console.error(`Error fetching Curve USD account data for address ${address} on market ${market.value}:`, error);
|
|
857
|
+
positions[address.toLowerCase()].crvUsd[market.value] = { error: `Error fetching Curve USD account data for address ${address} on market ${market.value}`, data: null };
|
|
858
|
+
}
|
|
859
|
+
}))).flat(),
|
|
860
|
+
...llamaLendMarkets.map((market) => addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
|
|
861
|
+
try {
|
|
862
|
+
const accData = yield _getLlamaLendUserData(client, network, address, market, markets.llamaLendMarketsData[market.value]);
|
|
863
|
+
if (new Dec(accData.suppliedUsd).gt(0) || new Dec(accData.borrowedUsd).gt(0)) {
|
|
864
|
+
positions[address.toLowerCase()].llamaLend[market.value] = { error: '', data: Object.assign(Object.assign({}, accData), { borrowRate: markets.llamaLendMarketsData[market.value].borrowRate }) };
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
catch (error) {
|
|
868
|
+
console.error(`Error fetching LlamaLend account data for address ${address} on market ${market.value}:`, error);
|
|
869
|
+
positions[address.toLowerCase()].llamaLend[market.value] = { error: `Error fetching LlamaLend account data for address ${address} on market ${market.value}`, data: null };
|
|
870
|
+
}
|
|
871
|
+
}))).flat(),
|
|
872
|
+
]);
|
|
873
|
+
return {
|
|
874
|
+
positions,
|
|
875
|
+
markets,
|
|
876
|
+
};
|
|
877
|
+
});
|
|
878
|
+
}
|
|
606
879
|
export * from './discovery';
|
package/esm/types/aave.d.ts
CHANGED
|
@@ -126,6 +126,7 @@ export interface AavePositionData extends MMPositionData {
|
|
|
126
126
|
minRatio: string;
|
|
127
127
|
collRatio: string;
|
|
128
128
|
safetyRatioWithLtvZeroFallback?: string;
|
|
129
|
+
safetyRatio?: string;
|
|
129
130
|
suppliedUsd: string;
|
|
130
131
|
borrowedUsd: string;
|
|
131
132
|
borrowLimitUsd: string;
|
|
@@ -159,6 +160,7 @@ export interface AaveV3AggregatedPositionData {
|
|
|
159
160
|
collRatio: string;
|
|
160
161
|
borrowLimitWithLtvZeroFallbackUsd: string;
|
|
161
162
|
safetyRatioWithLtvZeroFallback: string;
|
|
163
|
+
safetyRatio: string;
|
|
162
164
|
netApy: string;
|
|
163
165
|
incentiveUsd: string;
|
|
164
166
|
totalInterestUsd: string;
|
package/esm/types/aaveV4.d.ts
CHANGED
package/esm/types/claiming.d.ts
CHANGED
|
@@ -6,8 +6,6 @@ export declare enum ClaimType {
|
|
|
6
6
|
AAVE_MERIT_REWARDS = "AAVE_MERIT_REWARDS",
|
|
7
7
|
/** Rewards distributed through Merkl across supported protocols */
|
|
8
8
|
MERKL_REWARDS = "MERKL_REWARDS",
|
|
9
|
-
/** Rewards from Compound V3 (only in COMP) */
|
|
10
|
-
COMPOUND_V3_COMP = "COMPOUND_V3_COMP",
|
|
11
9
|
/** Rewards from Spark (wstETH only for now) */
|
|
12
10
|
SPARK_REWARDS = "SPARK_REWARDS",
|
|
13
11
|
/** Rewards from King (prev LTR^2 - received for weETH holding) */
|
|
@@ -68,12 +66,6 @@ export type KingRewardsClaimableToken = _ClaimableTokenPartial & {
|
|
|
68
66
|
merkleProofs: string[];
|
|
69
67
|
};
|
|
70
68
|
};
|
|
71
|
-
export type CompoundV3CompClaimableToken = _ClaimableTokenPartial & {
|
|
72
|
-
claimType: ClaimType.COMPOUND_V3_COMP;
|
|
73
|
-
additionalClaimFields: {
|
|
74
|
-
marketAddress: EthAddress;
|
|
75
|
-
};
|
|
76
|
-
};
|
|
77
69
|
export declare enum SparkAirdropType {
|
|
78
70
|
SPARK_IGNITION = "spark-ignition",
|
|
79
71
|
PRE_FARMING_AND_SOCIAL = "pre-farming-and-social"
|
|
@@ -102,5 +94,5 @@ export type UniswapAirdropClaimableToken = _ClaimableTokenPartial & {
|
|
|
102
94
|
proof: string[];
|
|
103
95
|
};
|
|
104
96
|
};
|
|
105
|
-
export type ClaimableToken = AaveRewardsClaimableToken | AaveMeritRewardsClaimableToken | MerklRewardsClaimableToken |
|
|
97
|
+
export type ClaimableToken = AaveRewardsClaimableToken | AaveMeritRewardsClaimableToken | MerklRewardsClaimableToken | SparkRewardsClaimableToken | KingRewardsClaimableToken | SparkAirdropClaimableToken | SparkWstEthRewardsClaimableToken | EthenaAirdropClaimableToken;
|
|
106
98
|
export {};
|
package/esm/types/claiming.js
CHANGED
|
@@ -6,8 +6,6 @@ export var ClaimType;
|
|
|
6
6
|
ClaimType["AAVE_MERIT_REWARDS"] = "AAVE_MERIT_REWARDS";
|
|
7
7
|
/** Rewards distributed through Merkl across supported protocols */
|
|
8
8
|
ClaimType["MERKL_REWARDS"] = "MERKL_REWARDS";
|
|
9
|
-
/** Rewards from Compound V3 (only in COMP) */
|
|
10
|
-
ClaimType["COMPOUND_V3_COMP"] = "COMPOUND_V3_COMP";
|
|
11
9
|
/** Rewards from Spark (wstETH only for now) */
|
|
12
10
|
ClaimType["SPARK_REWARDS"] = "SPARK_REWARDS";
|
|
13
11
|
/** Rewards from King (prev LTR^2 - received for weETH holding) */
|
package/esm/types/compound.d.ts
CHANGED
|
@@ -96,6 +96,7 @@ export interface CompoundAggregatedPositionData {
|
|
|
96
96
|
leftToBorrowUsd: string;
|
|
97
97
|
ratio: string;
|
|
98
98
|
collRatio: string;
|
|
99
|
+
safetyRatio: string;
|
|
99
100
|
netApy: string;
|
|
100
101
|
incentiveUsd: string;
|
|
101
102
|
totalInterestUsd: string;
|
|
@@ -115,6 +116,7 @@ export interface CompoundAggregatedPositionData {
|
|
|
115
116
|
export interface CompoundPositionData extends MMPositionData {
|
|
116
117
|
ratio: string;
|
|
117
118
|
minRatio: string;
|
|
119
|
+
safetyRatio?: string;
|
|
118
120
|
suppliedUsd: string;
|
|
119
121
|
borrowedUsd: string;
|
|
120
122
|
borrowLimitUsd: string;
|
package/esm/types/fluid.d.ts
CHANGED
package/esm/types/liquity.d.ts
CHANGED
package/esm/types/liquityV2.d.ts
CHANGED
|
@@ -94,6 +94,7 @@ export interface LiquityV2AggregatedTroveData {
|
|
|
94
94
|
liquidationPrice: string;
|
|
95
95
|
ratio: string;
|
|
96
96
|
collRatio: string;
|
|
97
|
+
safetyRatio: string;
|
|
97
98
|
exposure: string;
|
|
98
99
|
}
|
|
99
100
|
export interface LiquityV2TroveData {
|
|
@@ -101,6 +102,7 @@ export interface LiquityV2TroveData {
|
|
|
101
102
|
troveId: string;
|
|
102
103
|
ratio: string;
|
|
103
104
|
collRatio: string;
|
|
105
|
+
safetyRatio?: string;
|
|
104
106
|
liqRatio: string;
|
|
105
107
|
borrowLimitRatio: string;
|
|
106
108
|
interestRate: string;
|
package/esm/types/maker.d.ts
CHANGED
|
@@ -185,6 +185,7 @@ export interface MorphoBlueAggregatedPositionData {
|
|
|
185
185
|
totalInterestUsd: string;
|
|
186
186
|
ltv: string;
|
|
187
187
|
ratio: string;
|
|
188
|
+
safetyRatio: string;
|
|
188
189
|
leveragedType: LeverageType;
|
|
189
190
|
leveragedAsset?: string;
|
|
190
191
|
currentVolatilePairRatio?: string;
|
|
@@ -207,6 +208,7 @@ export interface MorphoBluePositionData {
|
|
|
207
208
|
totalInterestUsd: string;
|
|
208
209
|
ltv: string;
|
|
209
210
|
ratio: string;
|
|
211
|
+
safetyRatio?: string;
|
|
210
212
|
leveragedType: LeverageType;
|
|
211
213
|
leveragedAsset?: string;
|
|
212
214
|
currentVolatilePairRatio?: string;
|
package/esm/types/portfolio.d.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import { AaveV2PositionData, AaveV3PositionData, AaveVersions } from './aave';
|
|
2
|
-
import { AaveV4AccountData, AaveV4SpokesType } from './aaveV4';
|
|
1
|
+
import { AaveV2MarketData, AaveV2PositionData, AaveV3MarketData, AaveV3PositionData, AaveVersions } from './aave';
|
|
2
|
+
import { AaveV4AccountData, AaveV4SpokeData, AaveV4SpokesType } from './aaveV4';
|
|
3
3
|
import { EthAddress } from './common';
|
|
4
|
-
import { CompoundV2PositionData, CompoundV3PositionData, CompoundVersions } from './compound';
|
|
5
|
-
import { CrvUSDUserData, CrvUSDVersions } from './curveUsd';
|
|
6
|
-
import { FluidVaultData } from './fluid';
|
|
4
|
+
import { CompoundV2MarketsData, CompoundV2PositionData, CompoundV3MarketsData, CompoundV3PositionData, CompoundVersions } from './compound';
|
|
5
|
+
import { CrvUSDGlobalMarketData, CrvUSDUserData, CrvUSDVersions } from './curveUsd';
|
|
6
|
+
import { FluidMarketData, FluidVaultData } from './fluid';
|
|
7
7
|
import { LiquityTroveInfo } from './liquity';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
8
|
+
import { LiquityV2MarketData } from './liquityV2';
|
|
9
|
+
import { LlamaLendGlobalMarketData, LlamaLendUserData, LlamaLendVersionsType } from './llamaLend';
|
|
10
|
+
import { CdpData, IlkInfo } from './maker';
|
|
11
|
+
import { MorphoBlueMarketInfo, MorphoBluePositionData, MorphoBlueVersions } from './morphoBlue';
|
|
12
|
+
import { MorphoMidnightMarketInfo, MorphoMidnightPositionData, MorphoMidnightVersions } from './morphoMidnight';
|
|
13
|
+
import { SparkMarketsData, SparkPositionData, SparkVersions } from './spark';
|
|
13
14
|
export interface PortfolioProtocolData<T> {
|
|
14
15
|
error: string;
|
|
15
16
|
data: T | null;
|
|
@@ -59,3 +60,18 @@ export interface PortfolioPositionsDataForAddress {
|
|
|
59
60
|
export interface PortfolioPositionsData {
|
|
60
61
|
[key: EthAddress]: PortfolioPositionsDataForAddress;
|
|
61
62
|
}
|
|
63
|
+
export interface PortfolioMarketsData {
|
|
64
|
+
morphoMarketsData: Record<string, MorphoBlueMarketInfo>;
|
|
65
|
+
morphoMidnightMarketsData: Record<string, MorphoMidnightMarketInfo>;
|
|
66
|
+
compoundV3MarketsData: Record<string, CompoundV3MarketsData>;
|
|
67
|
+
sparkMarketsData: Record<string, SparkMarketsData>;
|
|
68
|
+
aaveV3MarketsData: Record<string, AaveV3MarketData>;
|
|
69
|
+
aaveV2MarketsData: Record<string, AaveV2MarketData>;
|
|
70
|
+
compoundV2MarketsData: Record<string, CompoundV2MarketsData>;
|
|
71
|
+
crvUsdMarketsData: Record<string, CrvUSDGlobalMarketData>;
|
|
72
|
+
llamaLendMarketsData: Record<string, LlamaLendGlobalMarketData>;
|
|
73
|
+
liquityV2MarketsData: Record<string, LiquityV2MarketData>;
|
|
74
|
+
aaveV4SpokesData: Record<string, AaveV4SpokeData>;
|
|
75
|
+
fluidMarketsData: Record<string, FluidMarketData>;
|
|
76
|
+
makerMarketsData: Record<string, IlkInfo>;
|
|
77
|
+
}
|
package/esm/types/spark.d.ts
CHANGED
|
@@ -85,6 +85,7 @@ export interface SparkAggregatedPositionData {
|
|
|
85
85
|
leftToBorrowUsd: string;
|
|
86
86
|
ratio: string;
|
|
87
87
|
collRatio: string;
|
|
88
|
+
safetyRatio: string;
|
|
88
89
|
netApy: string;
|
|
89
90
|
incentiveUsd: string;
|
|
90
91
|
totalInterestUsd: string;
|
|
@@ -104,6 +105,7 @@ export interface SparkPositionData extends MMPositionData {
|
|
|
104
105
|
ratio: string;
|
|
105
106
|
minRatio: string;
|
|
106
107
|
collRatio: string;
|
|
108
|
+
safetyRatio?: string;
|
|
107
109
|
suppliedUsd: string;
|
|
108
110
|
borrowedUsd: string;
|
|
109
111
|
borrowLimitUsd: string;
|
package/package.json
CHANGED
package/src/aaveV2/index.ts
CHANGED
|
@@ -210,6 +210,8 @@ export const _getAaveV2AccountData = async (provider: Client, network: NetworkNu
|
|
|
210
210
|
payload.collRatio = payload.borrowedUsd && payload.borrowedUsd !== '0'
|
|
211
211
|
? new Dec(payload.suppliedCollateralUsd).div(payload.borrowedUsd).mul(100).toString()
|
|
212
212
|
: '0';
|
|
213
|
+
// Aave v2 has no LTV-0 fallback (AaveV3View only), so its safety ratio is the plain ratio.
|
|
214
|
+
payload.safetyRatio = payload.ratio;
|
|
213
215
|
|
|
214
216
|
// Calculate borrow limits per asset
|
|
215
217
|
Object.values(payload.usedAssets).forEach((item) => {
|
package/src/claiming/index.ts
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import * as aaveV3Claim from './aaveV3';
|
|
2
|
-
import * as compV3Claim from './compV3';
|
|
3
2
|
import * as kingV3Claim from './king';
|
|
4
3
|
import * as sparkClaim from './spark';
|
|
5
4
|
import * as uniswapClaim from './uniswap';
|
|
6
5
|
|
|
7
6
|
export {
|
|
8
7
|
aaveV3Claim,
|
|
9
|
-
compV3Claim,
|
|
10
8
|
kingV3Claim,
|
|
11
9
|
sparkClaim,
|
|
12
10
|
uniswapClaim,
|
package/src/fluid/index.ts
CHANGED
|
@@ -1830,3 +1830,43 @@ export const _getUserPositionsPortfolio = async (provider: PublicClient, network
|
|
|
1830
1830
|
userData: userData[i],
|
|
1831
1831
|
})).filter(md => md.marketData !== undefined);
|
|
1832
1832
|
};
|
|
1833
|
+
|
|
1834
|
+
|
|
1835
|
+
export const _getAllFluidMarketDataPortfolio = async (provider: PublicClient, network: NetworkNumber): Promise<Record<string, FluidMarketData>> => {
|
|
1836
|
+
const versions = getFluidVersionsDataForNetwork(network);
|
|
1837
|
+
if (versions.length === 0) return {};
|
|
1838
|
+
|
|
1839
|
+
const view = FluidViewContractViem(provider, network);
|
|
1840
|
+
const vaultsData = await Promise.all(versions.map((version) => view.read.getVaultData([version.marketAddress])));
|
|
1841
|
+
|
|
1842
|
+
const tokens = Array.from(new Set(vaultsData.map((vaultData) => {
|
|
1843
|
+
const vaultTokens = [getAssetInfoByAddress(vaultData.supplyToken0, network).symbol, getAssetInfoByAddress(vaultData.borrowToken0, network).symbol];
|
|
1844
|
+
if (vaultData.supplyToken1 && !compareAddresses(ZERO_ADDRESS, vaultData.supplyToken1)) vaultTokens.push(getAssetInfoByAddress(vaultData.supplyToken1, network).symbol);
|
|
1845
|
+
if (vaultData.borrowToken1 && !compareAddresses(ZERO_ADDRESS, vaultData.borrowToken1)) vaultTokens.push(getAssetInfoByAddress(vaultData.borrowToken1, network).symbol);
|
|
1846
|
+
return vaultTokens;
|
|
1847
|
+
}).flat()));
|
|
1848
|
+
|
|
1849
|
+
// ETH and WBTC needed for other tokens prices
|
|
1850
|
+
if (!tokens.includes('ETH')) tokens.push('ETH');
|
|
1851
|
+
if (!tokens.includes('WBTC')) tokens.push('WBTC');
|
|
1852
|
+
|
|
1853
|
+
const [tokenPrices, merklCampaigns] = await Promise.all([
|
|
1854
|
+
getTokensPricesForPortfolio(tokens, provider, network),
|
|
1855
|
+
getFluidMerklCampaigns(network),
|
|
1856
|
+
]);
|
|
1857
|
+
|
|
1858
|
+
const parsedMarketsData = await Promise.all(vaultsData.map(async (vaultData) => parseMarketData(provider, vaultData, network, tokenPrices)));
|
|
1859
|
+
|
|
1860
|
+
const marketsData: Record<string, FluidMarketData> = {};
|
|
1861
|
+
parsedMarketsData.forEach((marketData, i) => {
|
|
1862
|
+
if (!marketData) return;
|
|
1863
|
+
marketsData[versions[i].value] = attachFluidMerklIncentives(marketData, merklCampaigns);
|
|
1864
|
+
});
|
|
1865
|
+
|
|
1866
|
+
return marketsData;
|
|
1867
|
+
};
|
|
1868
|
+
|
|
1869
|
+
export const getAllFluidMarketDataPortfolio = async (
|
|
1870
|
+
provider: EthereumProvider,
|
|
1871
|
+
network: NetworkNumber,
|
|
1872
|
+
): Promise<Record<string, FluidMarketData>> => _getAllFluidMarketDataPortfolio(getViemProvider(provider, network, { batch: { multicall: true } }), network);
|
|
@@ -169,6 +169,9 @@ export const aaveAnyGetAggregatedPositionData = ({
|
|
|
169
169
|
},
|
|
170
170
|
);
|
|
171
171
|
payload.safetyRatioWithLtvZeroFallback = +payload.suppliedUsd ? new Dec(payload.borrowLimitWithLtvZeroFallbackUsd).div(payload.borrowedUsd).mul(100).toString() : '0';
|
|
172
|
+
// Normalised safety ratio (100 = liquidation on every protocol): the automation ratio above, falling back
|
|
173
|
+
// to the regular ratio when the fallback carries its '0' placeholder.
|
|
174
|
+
payload.safetyRatio = +payload.safetyRatioWithLtvZeroFallback ? payload.safetyRatioWithLtvZeroFallback : payload.ratio;
|
|
172
175
|
payload.liqRatio = new Dec(payload.borrowLimitUsd).div(payload.liquidationLimitUsd).toString();
|
|
173
176
|
payload.liqPercent = new Dec(payload.borrowLimitUsd).div(payload.liquidationLimitUsd).mul(100).toString();
|
|
174
177
|
const { leveragedType, leveragedAsset } = isLeveragedPos(usedAssets);
|