@defisaver/positions-sdk 2.1.151 → 2.1.152-shifter-v2-dev-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/claiming/compV3.js +0 -1
- package/cjs/config/contracts.d.ts +4 -0
- package/cjs/config/contracts.js +4 -0
- package/cjs/fluid/index.d.ts +2 -0
- package/cjs/fluid/index.js +36 -1
- package/cjs/helpers/morphoMidnightHelpers/tenor.d.ts +6 -2
- package/cjs/helpers/morphoMidnightHelpers/tenor.js +5 -1
- package/cjs/maker/index.d.ts +7 -2
- package/cjs/maker/index.js +27 -10
- package/cjs/markets/index.d.ts +2 -1
- package/cjs/markets/index.js +4 -1
- package/cjs/markets/maker/index.d.ts +1 -0
- package/cjs/markets/maker/index.js +13 -0
- package/cjs/markets/morphoMidnight/index.d.ts +92 -10
- package/cjs/markets/morphoMidnight/index.js +519 -60
- package/cjs/morphoMidnight/index.js +11 -1
- package/cjs/portfolio/index.d.ts +5 -1
- package/cjs/portfolio/index.js +287 -0
- package/cjs/types/morphoMidnight.d.ts +57 -4
- package/cjs/types/morphoMidnight.js +45 -0
- package/cjs/types/portfolio.d.ts +26 -10
- package/esm/claiming/compV3.js +0 -1
- package/esm/config/contracts.d.ts +4 -0
- package/esm/config/contracts.js +4 -0
- package/esm/fluid/index.d.ts +2 -0
- package/esm/fluid/index.js +33 -0
- package/esm/helpers/morphoMidnightHelpers/tenor.d.ts +6 -2
- package/esm/helpers/morphoMidnightHelpers/tenor.js +6 -2
- package/esm/maker/index.d.ts +7 -2
- package/esm/maker/index.js +26 -11
- package/esm/markets/index.d.ts +2 -1
- package/esm/markets/index.js +2 -1
- package/esm/markets/maker/index.d.ts +1 -0
- package/esm/markets/maker/index.js +10 -0
- package/esm/markets/morphoMidnight/index.d.ts +92 -10
- package/esm/markets/morphoMidnight/index.js +473 -59
- package/esm/morphoMidnight/index.js +11 -1
- package/esm/portfolio/index.d.ts +5 -1
- package/esm/portfolio/index.js +289 -3
- package/esm/types/morphoMidnight.d.ts +57 -4
- package/esm/types/morphoMidnight.js +45 -0
- package/esm/types/portfolio.d.ts +26 -10
- package/package.json +1 -1
- package/src/claiming/compV3.ts +0 -1
- package/src/config/contracts.ts +4 -0
- package/src/fluid/index.ts +40 -0
- package/src/helpers/morphoMidnightHelpers/tenor.ts +6 -2
- package/src/maker/index.ts +56 -28
- package/src/markets/index.ts +3 -1
- package/src/markets/maker/index.ts +10 -0
- package/src/markets/morphoMidnight/index.ts +724 -61
- package/src/morphoMidnight/index.ts +8 -1
- package/src/portfolio/index.ts +270 -2
- package/src/types/morphoMidnight.ts +59 -3
- package/src/types/portfolio.ts +31 -12
|
@@ -67,8 +67,13 @@ export function _getMorphoMidnightMarketData(provider, network, selectedMarket)
|
|
|
67
67
|
supplyIncentives: [],
|
|
68
68
|
borrowIncentives: [],
|
|
69
69
|
};
|
|
70
|
+
// `collaterals` is the full on-chain set, so `i` is the index `prices` is keyed by. Hidden entries
|
|
71
|
+
// (curator vaults, the loan token itself) are skipped rather than filtered out beforehand, which would
|
|
72
|
+
// shift every later collateral onto the wrong price.
|
|
70
73
|
const collateralSymbols = [];
|
|
71
74
|
collaterals.forEach((coll, i) => {
|
|
75
|
+
if (coll.hidden)
|
|
76
|
+
return;
|
|
72
77
|
const collInfo = getAssetInfoByAddress(coll.token, network);
|
|
73
78
|
const collSym = wethToEth(collInfo.symbol);
|
|
74
79
|
collateralSymbols.push(collSym);
|
|
@@ -131,8 +136,11 @@ export function _getMorphoMidnightAccountData(provider, network, account, select
|
|
|
131
136
|
suppliedUsd: new Dec(credit).mul(loanTokenData.price).toString(),
|
|
132
137
|
borrowedUsd: new Dec(debt).mul(loanTokenData.price).toString(),
|
|
133
138
|
};
|
|
134
|
-
// positionInfo.collateral is index-aligned with the market's collateral set (0 where
|
|
139
|
+
// positionInfo.collateral is index-aligned with the market's full on-chain collateral set (0 where
|
|
140
|
+
// unused), so hidden entries are skipped in place rather than filtered out first.
|
|
135
141
|
collaterals.forEach((coll, i) => {
|
|
142
|
+
if (coll.hidden)
|
|
143
|
+
return;
|
|
136
144
|
const collInfo = getAssetInfoByAddress(coll.token, network);
|
|
137
145
|
const collSym = wethToEth(collInfo.symbol);
|
|
138
146
|
const rawAmount = positionInfo.collateral[i] ? positionInfo.collateral[i].toString() : '0';
|
|
@@ -212,6 +220,8 @@ export const _getMorphoMidnightAccountBalances = (provider, network, block, addr
|
|
|
212
220
|
};
|
|
213
221
|
const collateral = {};
|
|
214
222
|
collaterals.forEach((coll, i) => {
|
|
223
|
+
if (coll.hidden)
|
|
224
|
+
return;
|
|
215
225
|
const collInfo = getAssetInfoByAddress(coll.token, network);
|
|
216
226
|
const rawAmount = positionInfo.collateral[i] ? positionInfo.collateral[i].toString() : '0';
|
|
217
227
|
collateral[addressMapping ? collInfo.address.toLowerCase() : wethToEth(collInfo.symbol)] = assetAmountInEth(rawAmount, wethToEth(collInfo.symbol));
|
package/esm/portfolio/index.d.ts
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { EthAddress, EthereumProvider, NetworkNumber } from '../types/common';
|
|
2
|
-
import { PortfolioPositionsData } from '../types';
|
|
2
|
+
import { PortfolioMarketsData, PortfolioPositionsData } from '../types';
|
|
3
3
|
export declare function getPortfolioData(provider: EthereumProvider, network: NetworkNumber, defaultProvider: EthereumProvider, addresses: EthAddress[], isSim?: boolean): Promise<{
|
|
4
4
|
positions: PortfolioPositionsData;
|
|
5
5
|
stakingPositions: any;
|
|
6
6
|
rewardsData: any;
|
|
7
7
|
markets: any;
|
|
8
8
|
}>;
|
|
9
|
+
export declare function getShifterPortfolioData(provider: EthereumProvider, network: NetworkNumber, defaultProvider: EthereumProvider, addresses: EthAddress[], isSim?: boolean): Promise<{
|
|
10
|
+
positions: PortfolioPositionsData;
|
|
11
|
+
markets: PortfolioMarketsData;
|
|
12
|
+
}>;
|
|
9
13
|
export * from './discovery';
|
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,13 +19,13 @@ 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
31
|
import { getCompoundV3Rewards } from '../claiming/compV3';
|
|
@@ -603,4 +603,290 @@ export function getPortfolioData(provider_1, network_1, defaultProvider_1, addre
|
|
|
603
603
|
};
|
|
604
604
|
});
|
|
605
605
|
}
|
|
606
|
+
export function getShifterPortfolioData(provider_1, network_1, defaultProvider_1, addresses_1) {
|
|
607
|
+
return __awaiter(this, arguments, void 0, function* (provider, network, defaultProvider, addresses, isSim = false) {
|
|
608
|
+
const isMainnet = network === NetworkNumber.Eth;
|
|
609
|
+
const isFluidSupported = [NetworkNumber.Eth, NetworkNumber.Arb, NetworkNumber.Base, NetworkNumber.Plasma].includes(network);
|
|
610
|
+
const morphoMarkets = Object.values(MorphoBlueMarkets(network)).filter((market) => market.chainIds.includes(network));
|
|
611
|
+
const morphoMidnightMarkets = Object.values(MorphoMidnightMarkets(network)).filter((market) => market.chainIds.includes(network));
|
|
612
|
+
const compoundV3Markets = Object.values(CompoundMarkets(network)).filter((market) => market.chainIds.includes(network) && market.value !== CompoundVersions.CompoundV2);
|
|
613
|
+
const sparkMarkets = Object.values(SparkMarkets(network)).filter((market) => market.chainIds.includes(network));
|
|
614
|
+
const aaveV3Markets = [AaveVersions.AaveV3, AaveVersions.AaveV3Lido, AaveVersions.AaveV3Etherfi].map((version) => AaveMarkets(network)[version]).filter((market) => market.chainIds.includes(network));
|
|
615
|
+
const aaveV2Markets = [AaveVersions.AaveV2].map((version) => AaveMarkets(network)[version]).filter((market) => market.chainIds.includes(network));
|
|
616
|
+
const compoundV2Markets = [CompoundVersions.CompoundV2].map((version) => CompoundMarkets(network)[version]).filter((market) => market.chainIds.includes(network));
|
|
617
|
+
const crvUsdMarkets = Object.values(CrvUsdMarkets(network)).filter((market) => market.chainIds.includes(network));
|
|
618
|
+
const llamaLendMarkets = [NetworkNumber.Eth, NetworkNumber.Arb].includes(network) ? Object.values(LlamaLendMarkets(network)).filter((market) => market.chainIds.includes(network)) : [];
|
|
619
|
+
const liquityV2Markets = [NetworkNumber.Eth].includes(network) ? Object.values(LiquityV2Markets(network)) : [];
|
|
620
|
+
const aaveV4Spokes = Object.values(AaveV4Spokes(network)).filter((market) => market.chainIds.includes(network));
|
|
621
|
+
const args = [network, { batch: { multicall: { batchSize: isSim ? 2000 : 2500000 } } }];
|
|
622
|
+
const client = getViemProvider(provider, ...args);
|
|
623
|
+
const defaultClient = getViemProvider(defaultProvider, ...args);
|
|
624
|
+
const markets = {
|
|
625
|
+
morphoMarketsData: {},
|
|
626
|
+
morphoMidnightMarketsData: {},
|
|
627
|
+
compoundV3MarketsData: {},
|
|
628
|
+
sparkMarketsData: {},
|
|
629
|
+
aaveV3MarketsData: {},
|
|
630
|
+
aaveV2MarketsData: {},
|
|
631
|
+
compoundV2MarketsData: {},
|
|
632
|
+
crvUsdMarketsData: {},
|
|
633
|
+
llamaLendMarketsData: {},
|
|
634
|
+
liquityV2MarketsData: {},
|
|
635
|
+
aaveV4SpokesData: {},
|
|
636
|
+
fluidMarketsData: {},
|
|
637
|
+
makerMarketsData: {},
|
|
638
|
+
};
|
|
639
|
+
const makerCdps = {};
|
|
640
|
+
const positions = {};
|
|
641
|
+
for (const address of addresses) {
|
|
642
|
+
positions[address.toLowerCase()] = {
|
|
643
|
+
aaveV3: {},
|
|
644
|
+
aaveV4: {},
|
|
645
|
+
morphoBlue: {},
|
|
646
|
+
morphoMidnight: {},
|
|
647
|
+
compoundV3: {},
|
|
648
|
+
spark: {},
|
|
649
|
+
maker: {},
|
|
650
|
+
aaveV2: {},
|
|
651
|
+
compoundV2: {},
|
|
652
|
+
liquity: {},
|
|
653
|
+
crvUsd: {},
|
|
654
|
+
llamaLend: {},
|
|
655
|
+
fluid: {
|
|
656
|
+
error: '',
|
|
657
|
+
data: {},
|
|
658
|
+
},
|
|
659
|
+
};
|
|
660
|
+
}
|
|
661
|
+
yield Promise.allSettled([
|
|
662
|
+
// === MARKET DATA (needs to be fetched first) ===
|
|
663
|
+
...morphoMarkets.map((market) => __awaiter(this, void 0, void 0, function* () {
|
|
664
|
+
markets.morphoMarketsData[market.value] = yield _getMorphoBluePortfolioMarketData(client, network, market);
|
|
665
|
+
})),
|
|
666
|
+
...morphoMidnightMarkets.map((market) => __awaiter(this, void 0, void 0, function* () {
|
|
667
|
+
markets.morphoMidnightMarketsData[market.value] = yield _getMorphoMidnightMarketData(client, network, market);
|
|
668
|
+
})),
|
|
669
|
+
...compoundV3Markets.map((market) => __awaiter(this, void 0, void 0, function* () {
|
|
670
|
+
markets.compoundV3MarketsData[market.value] = yield _getCompoundV3MarketsData(client, network, market, defaultClient);
|
|
671
|
+
})),
|
|
672
|
+
...sparkMarkets.map((market) => __awaiter(this, void 0, void 0, function* () {
|
|
673
|
+
markets.sparkMarketsData[market.value] = yield _getSparkMarketsData(client, network, market);
|
|
674
|
+
})),
|
|
675
|
+
...aaveV3Markets.map((market) => __awaiter(this, void 0, void 0, function* () {
|
|
676
|
+
markets.aaveV3MarketsData[market.value] = yield _getAaveV3MarketData(client, network, market);
|
|
677
|
+
})),
|
|
678
|
+
...aaveV4Spokes.map((spoke) => __awaiter(this, void 0, void 0, function* () {
|
|
679
|
+
markets.aaveV4SpokesData[spoke.value] = yield _getAaveV4SpokeData(client, network, spoke);
|
|
680
|
+
})),
|
|
681
|
+
...aaveV2Markets.map((market) => __awaiter(this, void 0, void 0, function* () {
|
|
682
|
+
markets.aaveV2MarketsData[market.value] = yield _getAaveV2MarketsData(client, network, market);
|
|
683
|
+
})),
|
|
684
|
+
...compoundV2Markets.map((market) => __awaiter(this, void 0, void 0, function* () {
|
|
685
|
+
markets.compoundV2MarketsData[market.value] = yield _getCompoundV2MarketsData(client, network);
|
|
686
|
+
})),
|
|
687
|
+
...crvUsdMarkets.map((market) => __awaiter(this, void 0, void 0, function* () {
|
|
688
|
+
markets.crvUsdMarketsData[market.value] = yield _getCurveUsdGlobalData(client, network, market);
|
|
689
|
+
})),
|
|
690
|
+
...llamaLendMarkets.map((market) => __awaiter(this, void 0, void 0, function* () {
|
|
691
|
+
markets.llamaLendMarketsData[market.value] = yield _getLlamaLendGlobalData(client, network, market);
|
|
692
|
+
})),
|
|
693
|
+
...liquityV2Markets.map((market) => __awaiter(this, void 0, void 0, function* () {
|
|
694
|
+
markets.liquityV2MarketsData[market.value] = yield _getLiquityV2MarketData(client, network, market);
|
|
695
|
+
})),
|
|
696
|
+
(() => __awaiter(this, void 0, void 0, function* () {
|
|
697
|
+
if (!isFluidSupported)
|
|
698
|
+
return;
|
|
699
|
+
try {
|
|
700
|
+
markets.fluidMarketsData = yield _getAllFluidMarketDataPortfolio(client, network);
|
|
701
|
+
}
|
|
702
|
+
catch (error) {
|
|
703
|
+
console.error('Error fetching Fluid markets data:', error);
|
|
704
|
+
}
|
|
705
|
+
}))(),
|
|
706
|
+
(() => __awaiter(this, void 0, void 0, function* () {
|
|
707
|
+
if (!isMainnet)
|
|
708
|
+
return; // Maker CDPs are only available on mainnet
|
|
709
|
+
try {
|
|
710
|
+
markets.makerMarketsData = yield _getMakerIlksData(client, network, MakerActiveIlks);
|
|
711
|
+
}
|
|
712
|
+
catch (error) {
|
|
713
|
+
console.error('Error fetching Maker ilks data:', error);
|
|
714
|
+
}
|
|
715
|
+
}))(),
|
|
716
|
+
// === INDEPENDENT USER DATA (doesn't depend on market data) ===
|
|
717
|
+
...addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
|
|
718
|
+
if (!isMainnet)
|
|
719
|
+
return; // Maker CDPs are only available on mainnet
|
|
720
|
+
const makerCdp = yield _getUserCdps(client, network, address);
|
|
721
|
+
makerCdps[address.toLowerCase()] = makerCdp;
|
|
722
|
+
})),
|
|
723
|
+
...addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
|
|
724
|
+
try {
|
|
725
|
+
if (!isFluidSupported)
|
|
726
|
+
return; // Fluid is not available on Optimism
|
|
727
|
+
const userPositions = (yield _getUserPositionsPortfolio(client, network, address));
|
|
728
|
+
for (const position of userPositions) {
|
|
729
|
+
if (position.userData && new Dec(position.userData.suppliedUsd).gt(0)) {
|
|
730
|
+
positions[address.toLowerCase()].fluid.data[position.userData.nftId] = position.userData;
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
catch (error) {
|
|
735
|
+
console.error(`Error fetching Fluid positions for address ${address}:`, error);
|
|
736
|
+
positions[address.toLowerCase()].fluid = {
|
|
737
|
+
error: `Error fetching Fluid positions for address ${address}`,
|
|
738
|
+
data: {},
|
|
739
|
+
};
|
|
740
|
+
}
|
|
741
|
+
})),
|
|
742
|
+
]);
|
|
743
|
+
yield Promise.all([
|
|
744
|
+
...aaveV3Markets.map((market) => addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
|
|
745
|
+
try {
|
|
746
|
+
const accData = yield _getAaveV3AccountData(client, network, address, Object.assign({ selectedMarket: market }, markets.aaveV3MarketsData[market.value]));
|
|
747
|
+
if (new Dec(accData.suppliedUsd).gt(0))
|
|
748
|
+
positions[address.toLowerCase()].aaveV3[market.value] = { error: '', data: accData };
|
|
749
|
+
}
|
|
750
|
+
catch (error) {
|
|
751
|
+
console.error(`Error fetching AaveV3 account data for address ${address} on market ${market.value}:`, error);
|
|
752
|
+
positions[address.toLowerCase()].aaveV3[market.value] = { error: `Error fetching AaveV3 account data for address ${address} on market ${market.value}`, data: null };
|
|
753
|
+
}
|
|
754
|
+
}))).flat(),
|
|
755
|
+
...aaveV4Spokes.map((spoke) => addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
|
|
756
|
+
try {
|
|
757
|
+
const accData = yield _getAaveV4AccountData(client, network, markets.aaveV4SpokesData[spoke.value], address);
|
|
758
|
+
if (new Dec(accData.suppliedUsd).gt(0))
|
|
759
|
+
positions[address.toLowerCase()].aaveV4[spoke.value] = { error: '', data: accData };
|
|
760
|
+
}
|
|
761
|
+
catch (error) {
|
|
762
|
+
console.error(`Error fetching AaveV4 account data for address ${address} on spoke ${spoke.value}:`, error);
|
|
763
|
+
positions[address.toLowerCase()].aaveV4[spoke.value] = { error: `Error fetching AaveV4 account data for address ${address} on spoke ${spoke.value}`, data: null };
|
|
764
|
+
}
|
|
765
|
+
}))).flat(),
|
|
766
|
+
...morphoMarkets.map((market) => addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
|
|
767
|
+
try {
|
|
768
|
+
const accData = yield _getMorphoBlueAccountData(client, network, address, market, markets.morphoMarketsData[market.value]);
|
|
769
|
+
if (new Dec(accData.suppliedUsd).gt(0))
|
|
770
|
+
positions[address.toLowerCase()].morphoBlue[market.value] = { error: '', data: accData };
|
|
771
|
+
}
|
|
772
|
+
catch (error) {
|
|
773
|
+
console.error(`Error fetching MorphoBlue account data for address ${address} on market ${market.value}:`, error);
|
|
774
|
+
positions[address.toLowerCase()].morphoBlue[market.value] = { error: `Error fetching MorphoBlue account data for address ${address} on market ${market.value}`, data: null };
|
|
775
|
+
}
|
|
776
|
+
}))).flat(),
|
|
777
|
+
...morphoMidnightMarkets.map((market) => addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
|
|
778
|
+
try {
|
|
779
|
+
const accData = yield _getMorphoMidnightAccountData(client, network, address, market, markets.morphoMidnightMarketsData[market.value]);
|
|
780
|
+
if (new Dec(accData.suppliedUsd).gt(0))
|
|
781
|
+
positions[address.toLowerCase()].morphoMidnight[market.value] = { error: '', data: accData };
|
|
782
|
+
}
|
|
783
|
+
catch (error) {
|
|
784
|
+
console.error(`Error fetching MorphoMidnight account data for address ${address} on market ${market.value}:`, error);
|
|
785
|
+
positions[address.toLowerCase()].morphoMidnight[market.value] = { error: `Error fetching MorphoMidnight account data for address ${address} on market ${market.value}`, data: null };
|
|
786
|
+
}
|
|
787
|
+
}))).flat(),
|
|
788
|
+
...compoundV3Markets.map((market) => addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
|
|
789
|
+
try {
|
|
790
|
+
const accData = yield _getCompoundV3AccountData(client, network, address, ZERO_ADDRESS, { selectedMarket: market, assetsData: markets.compoundV3MarketsData[market.value].assetsData });
|
|
791
|
+
if (new Dec(accData.suppliedUsd).gt(0))
|
|
792
|
+
positions[address.toLowerCase()].compoundV3[market.value] = { error: '', data: accData };
|
|
793
|
+
}
|
|
794
|
+
catch (error) {
|
|
795
|
+
console.error(`Error fetching CompoundV3 account data for address ${address} on market ${market.value}:`, error);
|
|
796
|
+
positions[address.toLowerCase()].compoundV3[market.value] = { error: `Error fetching CompoundV3 account data for address ${address} on market ${market.value}`, data: null };
|
|
797
|
+
}
|
|
798
|
+
}))).flat(),
|
|
799
|
+
...sparkMarkets.map((market) => addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
|
|
800
|
+
try {
|
|
801
|
+
const accData = yield _getSparkAccountData(client, network, address, { selectedMarket: market, assetsData: markets.sparkMarketsData[market.value].assetsData, eModeCategoriesData: markets.sparkMarketsData[market.value].eModeCategoriesData });
|
|
802
|
+
if (new Dec(accData.suppliedUsd).gt(0))
|
|
803
|
+
positions[address.toLowerCase()].spark[market.value] = { error: '', data: accData };
|
|
804
|
+
}
|
|
805
|
+
catch (error) {
|
|
806
|
+
console.error(`Error fetching Spark account data for address ${address} on market ${market.value}:`, error);
|
|
807
|
+
positions[address.toLowerCase()].spark[market.value] = { error: `Error fetching Spark account data for address ${address} on market ${market.value}`, data: null };
|
|
808
|
+
}
|
|
809
|
+
}))).flat(),
|
|
810
|
+
...addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
|
|
811
|
+
var _a;
|
|
812
|
+
return (_a = makerCdps[address.toLowerCase()]) === null || _a === void 0 ? void 0 : _a.map((cdpInfo) => __awaiter(this, void 0, void 0, function* () {
|
|
813
|
+
try {
|
|
814
|
+
// reuse ilk data fetched for the markets payload; ilks outside the active set are fetched on demand
|
|
815
|
+
const cdpData = yield _getMakerCdpData(client, network, cdpInfo, markets.makerMarketsData[cdpInfo.ilkLabel]);
|
|
816
|
+
if (cdpData) {
|
|
817
|
+
positions[address.toLowerCase()].maker[cdpInfo.id] = { error: '', data: cdpData };
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
catch (error) {
|
|
821
|
+
console.error(`Error fetching Maker CDP data for address ${address} with ID ${cdpInfo.id}:`, error);
|
|
822
|
+
positions[address.toLowerCase()].maker[cdpInfo.id] = { error: `Error fetching Maker CDP data for address ${address} with ID ${cdpInfo.id}`, data: null };
|
|
823
|
+
}
|
|
824
|
+
}));
|
|
825
|
+
})).flat(),
|
|
826
|
+
...aaveV2Markets.map((market) => addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
|
|
827
|
+
try {
|
|
828
|
+
const accData = yield _getAaveV2AccountData(client, network, address, markets.aaveV2MarketsData[market.value].assetsData, market);
|
|
829
|
+
if (new Dec(accData.suppliedUsd).gt(0))
|
|
830
|
+
positions[address.toLowerCase()].aaveV2[market.value] = { error: '', data: accData };
|
|
831
|
+
}
|
|
832
|
+
catch (error) {
|
|
833
|
+
console.error(`Error fetching AaveV2 account data for address ${address}:`, error);
|
|
834
|
+
positions[address.toLowerCase()].aaveV2[market.value] = { error: `Error fetching AaveV2 account data for address ${address}`, data: null };
|
|
835
|
+
}
|
|
836
|
+
}))).flat(),
|
|
837
|
+
...compoundV2Markets.map((market) => addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
|
|
838
|
+
try {
|
|
839
|
+
const accData = yield _getCompoundV2AccountData(client, network, address, markets.compoundV2MarketsData[market.value].assetsData);
|
|
840
|
+
if (new Dec(accData.suppliedUsd).gt(0))
|
|
841
|
+
positions[address.toLowerCase()].compoundV2[market.value] = { error: '', data: accData };
|
|
842
|
+
}
|
|
843
|
+
catch (error) {
|
|
844
|
+
console.error(`Error fetching CompoundV2 account data for address ${address}:`, error);
|
|
845
|
+
positions[address.toLowerCase()].compoundV2[market.value] = { error: `Error fetching CompoundV2 account data for address ${address}`, data: null };
|
|
846
|
+
}
|
|
847
|
+
}))).flat(),
|
|
848
|
+
...addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
|
|
849
|
+
try {
|
|
850
|
+
if (!isMainnet)
|
|
851
|
+
return; // Liquity trove info is only available on mainnet
|
|
852
|
+
const troveInfo = yield _getLiquityTroveInfo(client, network, address);
|
|
853
|
+
if (new Dec(troveInfo.collateral).gt(0))
|
|
854
|
+
positions[address.toLowerCase()].liquity = { error: '', data: troveInfo };
|
|
855
|
+
}
|
|
856
|
+
catch (error) {
|
|
857
|
+
console.error(`Error fetching Liquity trove info for address ${address}:`, error);
|
|
858
|
+
positions[address.toLowerCase()].liquity = { error: `Error fetching Liquity trove info for address ${address}`, data: null };
|
|
859
|
+
}
|
|
860
|
+
})),
|
|
861
|
+
...crvUsdMarkets.map((market) => addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
|
|
862
|
+
try {
|
|
863
|
+
const accData = yield _getCurveUsdUserData(client, network, address, market, markets.crvUsdMarketsData[market.value].activeBand);
|
|
864
|
+
if (new Dec(accData.suppliedUsd).gt(0) || new Dec(accData.borrowedUsd).gt(0)) {
|
|
865
|
+
positions[address.toLowerCase()].crvUsd[market.value] = { error: '', data: Object.assign(Object.assign({}, accData), { borrowRate: markets.crvUsdMarketsData[market.value].borrowRate }) };
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
catch (error) {
|
|
869
|
+
console.error(`Error fetching Curve USD account data for address ${address} on market ${market.value}:`, error);
|
|
870
|
+
positions[address.toLowerCase()].crvUsd[market.value] = { error: `Error fetching Curve USD account data for address ${address} on market ${market.value}`, data: null };
|
|
871
|
+
}
|
|
872
|
+
}))).flat(),
|
|
873
|
+
...llamaLendMarkets.map((market) => addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
|
|
874
|
+
try {
|
|
875
|
+
const accData = yield _getLlamaLendUserData(client, network, address, market, markets.llamaLendMarketsData[market.value]);
|
|
876
|
+
if (new Dec(accData.suppliedUsd).gt(0) || new Dec(accData.borrowedUsd).gt(0)) {
|
|
877
|
+
positions[address.toLowerCase()].llamaLend[market.value] = { error: '', data: Object.assign(Object.assign({}, accData), { borrowRate: markets.llamaLendMarketsData[market.value].borrowRate }) };
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
catch (error) {
|
|
881
|
+
console.error(`Error fetching LlamaLend account data for address ${address} on market ${market.value}:`, error);
|
|
882
|
+
positions[address.toLowerCase()].llamaLend[market.value] = { error: `Error fetching LlamaLend account data for address ${address} on market ${market.value}`, data: null };
|
|
883
|
+
}
|
|
884
|
+
}))).flat(),
|
|
885
|
+
]);
|
|
886
|
+
return {
|
|
887
|
+
positions,
|
|
888
|
+
markets,
|
|
889
|
+
};
|
|
890
|
+
});
|
|
891
|
+
}
|
|
606
892
|
export * from './discovery';
|
|
@@ -31,7 +31,49 @@ export declare enum MorphoMidnightVersions {
|
|
|
31
31
|
MorphoMidnightTenorCbETHWETH_20261030_Base = "morphomidnighttenorcbethweth_20261030_base",
|
|
32
32
|
MorphoMidnightTenorCbETHWETH_20261127_Base = "morphomidnighttenorcbethweth_20261127_base",
|
|
33
33
|
MorphoMidnightTenorCbETHWETH_20261225_Base = "morphomidnighttenorcbethweth_20261225_base",
|
|
34
|
-
MorphoMidnightTenorCbETHWETH_20270129_Base = "morphomidnighttenorcbethweth_20270129_base"
|
|
34
|
+
MorphoMidnightTenorCbETHWETH_20270129_Base = "morphomidnighttenorcbethweth_20270129_base",
|
|
35
|
+
MorphoMidnightWBTCUSDC_860_20260925_Eth = "morphomidnightwbtcusdc_860_20260925_eth",
|
|
36
|
+
MorphoMidnightWBTCUSDC_860_20261030_Eth = "morphomidnightwbtcusdc_860_20261030_eth",
|
|
37
|
+
MorphoMidnightWBTCUSDC_860_20261127_Eth = "morphomidnightwbtcusdc_860_20261127_eth",
|
|
38
|
+
MorphoMidnightWBTCUSDC_860_20261225_Eth = "morphomidnightwbtcusdc_860_20261225_eth",
|
|
39
|
+
MorphoMidnightWBTCUSDC_860_20270129_Eth = "morphomidnightwbtcusdc_860_20270129_eth",
|
|
40
|
+
MorphoMidnightWBTCUSDC_860_20270226_Eth = "morphomidnightwbtcusdc_860_20270226_eth",
|
|
41
|
+
MorphoMidnightWBTCUSDC_860_20270326_Eth = "morphomidnightwbtcusdc_860_20270326_eth",
|
|
42
|
+
MorphoMidnightCbBTCUSDC_860_20260925_Eth = "morphomidnightcbbtcusdc_860_20260925_eth",
|
|
43
|
+
MorphoMidnightCbBTCUSDC_860_20261030_Eth = "morphomidnightcbbtcusdc_860_20261030_eth",
|
|
44
|
+
MorphoMidnightCbBTCUSDC_860_20261127_Eth = "morphomidnightcbbtcusdc_860_20261127_eth",
|
|
45
|
+
MorphoMidnightCbBTCUSDC_860_20261225_Eth = "morphomidnightcbbtcusdc_860_20261225_eth",
|
|
46
|
+
MorphoMidnightCbBTCUSDC_860_20270129_Eth = "morphomidnightcbbtcusdc_860_20270129_eth",
|
|
47
|
+
MorphoMidnightCbBTCUSDC_860_20270226_Eth = "morphomidnightcbbtcusdc_860_20270226_eth",
|
|
48
|
+
MorphoMidnightCbBTCUSDC_860_20270326_Eth = "morphomidnightcbbtcusdc_860_20270326_eth",
|
|
49
|
+
MorphoMidnightTenorReUSDUSDC_20260925_Eth = "morphomidnighttenorreusdusdc_20260925_eth",
|
|
50
|
+
MorphoMidnightTenorReUSDUSDC_20261030_Eth = "morphomidnighttenorreusdusdc_20261030_eth",
|
|
51
|
+
MorphoMidnightTenorReUSDUSDC_20261127_Eth = "morphomidnighttenorreusdusdc_20261127_eth",
|
|
52
|
+
MorphoMidnightTenorReUSDUSDC_20261225_Eth = "morphomidnighttenorreusdusdc_20261225_eth",
|
|
53
|
+
MorphoMidnightTenorSiUSDUSDC_20260925_Eth = "morphomidnighttenorsiusdusdc_20260925_eth",
|
|
54
|
+
MorphoMidnightTenorSiUSDUSDC_20261030_Eth = "morphomidnighttenorsiusdusdc_20261030_eth",
|
|
55
|
+
MorphoMidnightTenorSiUSDUSDC_20261127_Eth = "morphomidnighttenorsiusdusdc_20261127_eth",
|
|
56
|
+
MorphoMidnightTenorSiUSDUSDC_20261225_Eth = "morphomidnighttenorsiusdusdc_20261225_eth",
|
|
57
|
+
MorphoMidnightTenorStrUSDUSDC_20260925_Eth = "morphomidnighttenorstrusdusdc_20260925_eth",
|
|
58
|
+
MorphoMidnightTenorStrUSDUSDC_20261030_Eth = "morphomidnighttenorstrusdusdc_20261030_eth",
|
|
59
|
+
MorphoMidnightTenorStrUSDUSDC_20261127_Eth = "morphomidnighttenorstrusdusdc_20261127_eth",
|
|
60
|
+
MorphoMidnightTenorStrUSDUSDC_20261225_Eth = "morphomidnighttenorstrusdusdc_20261225_eth",
|
|
61
|
+
MorphoMidnightTenorUSD3USDC_20260925_Eth = "morphomidnighttenorusd3usdc_20260925_eth",
|
|
62
|
+
MorphoMidnightTenorUSD3USDC_20261030_Eth = "morphomidnighttenorusd3usdc_20261030_eth",
|
|
63
|
+
MorphoMidnightTenorUSD3USDC_20261127_Eth = "morphomidnighttenorusd3usdc_20261127_eth",
|
|
64
|
+
MorphoMidnightTenorUSD3USDC_20261225_Eth = "morphomidnighttenorusd3usdc_20261225_eth",
|
|
65
|
+
MorphoMidnightTenorWETHUSDC_20260925_Eth = "morphomidnighttenorwethusdc_20260925_eth",
|
|
66
|
+
MorphoMidnightTenorWETHUSDC_20261030_Eth = "morphomidnighttenorwethusdc_20261030_eth",
|
|
67
|
+
MorphoMidnightTenorWETHUSDC_20261127_Eth = "morphomidnighttenorwethusdc_20261127_eth",
|
|
68
|
+
MorphoMidnightTenorWETHUSDC_20261225_Eth = "morphomidnighttenorwethusdc_20261225_eth",
|
|
69
|
+
MorphoMidnightTenorWsrUSDUSDC_20260925_Eth = "morphomidnighttenorwsrusdusdc_20260925_eth",
|
|
70
|
+
MorphoMidnightTenorWsrUSDUSDC_20261030_Eth = "morphomidnighttenorwsrusdusdc_20261030_eth",
|
|
71
|
+
MorphoMidnightTenorWsrUSDUSDC_20261127_Eth = "morphomidnighttenorwsrusdusdc_20261127_eth",
|
|
72
|
+
MorphoMidnightTenorWsrUSDUSDC_20261225_Eth = "morphomidnighttenorwsrusdusdc_20261225_eth",
|
|
73
|
+
MorphoMidnightTenorWstETHWETH_20260925_Eth = "morphomidnighttenorwstethweth_20260925_eth",
|
|
74
|
+
MorphoMidnightTenorWstETHWETH_20261030_Eth = "morphomidnighttenorwstethweth_20261030_eth",
|
|
75
|
+
MorphoMidnightTenorWstETHWETH_20261127_Eth = "morphomidnighttenorwstethweth_20261127_eth",
|
|
76
|
+
MorphoMidnightTenorWstETHWETH_20261225_Eth = "morphomidnighttenorwstethweth_20261225_eth"
|
|
35
77
|
}
|
|
36
78
|
export type MorphoMidnightCurator = 'Morpho' | 'Tenor';
|
|
37
79
|
export interface MorphoMidnightCollateralParams {
|
|
@@ -39,6 +81,13 @@ export interface MorphoMidnightCollateralParams {
|
|
|
39
81
|
lltv: number | string;
|
|
40
82
|
liquidationCursor: number | string;
|
|
41
83
|
oracle: EthAddress;
|
|
84
|
+
/**
|
|
85
|
+
* A collateral the market carries on-chain but the app never surfaces: a curator's own vault share
|
|
86
|
+
* token (Tenor's collateral vaults) or the loan token itself (Morpho's mainnet ladders list USDC at
|
|
87
|
+
* 98% next to the real collateral). It is not an asset the app deals in — nothing renders, prices or
|
|
88
|
+
* supplies it — but it stays in `collaterals` because the market id is the hash of the full set.
|
|
89
|
+
*/
|
|
90
|
+
hidden?: boolean;
|
|
42
91
|
}
|
|
43
92
|
export interface MorphoMidnightMarketData {
|
|
44
93
|
chainIds: NetworkNumber[];
|
|
@@ -48,11 +97,15 @@ export interface MorphoMidnightMarketData {
|
|
|
48
97
|
value: MorphoMidnightVersions;
|
|
49
98
|
midnight: EthAddress;
|
|
50
99
|
loanToken: EthAddress;
|
|
51
|
-
collaterals: MorphoMidnightCollateralParams[];
|
|
52
100
|
/**
|
|
53
|
-
*
|
|
101
|
+
* Every collateral the market carries on-chain, in the chain's own order — which is what the id is
|
|
102
|
+
* hashed from, so neither the set nor the order may be rearranged. Entries the app does not deal in
|
|
103
|
+
* are flagged `hidden` rather than kept in a second list: their on-chain position varies per market
|
|
104
|
+
* (Morpho's mainnet cbBTC ladder lists USDC first, its WBTC ladder second), so a separate list can
|
|
105
|
+
* only be re-joined by guessing, and every positional read — `MarketInfo.prices[i]`,
|
|
106
|
+
* `PositionInfo.collateral[i]`, the collateral index a supply call takes — indexes into *this* array.
|
|
54
107
|
*/
|
|
55
|
-
|
|
108
|
+
collaterals: MorphoMidnightCollateralParams[];
|
|
56
109
|
maturity: number;
|
|
57
110
|
rcfThreshold: number | string;
|
|
58
111
|
enterGate: EthAddress;
|
|
@@ -36,6 +36,51 @@ export var MorphoMidnightVersions;
|
|
|
36
36
|
MorphoMidnightVersions["MorphoMidnightTenorCbETHWETH_20261127_Base"] = "morphomidnighttenorcbethweth_20261127_base";
|
|
37
37
|
MorphoMidnightVersions["MorphoMidnightTenorCbETHWETH_20261225_Base"] = "morphomidnighttenorcbethweth_20261225_base";
|
|
38
38
|
MorphoMidnightVersions["MorphoMidnightTenorCbETHWETH_20270129_Base"] = "morphomidnighttenorcbethweth_20270129_base";
|
|
39
|
+
// ETHEREUM
|
|
40
|
+
// Sourced from the official listing at https://markets.morpho.org/fixed?chains=1
|
|
41
|
+
MorphoMidnightVersions["MorphoMidnightWBTCUSDC_860_20260925_Eth"] = "morphomidnightwbtcusdc_860_20260925_eth";
|
|
42
|
+
MorphoMidnightVersions["MorphoMidnightWBTCUSDC_860_20261030_Eth"] = "morphomidnightwbtcusdc_860_20261030_eth";
|
|
43
|
+
MorphoMidnightVersions["MorphoMidnightWBTCUSDC_860_20261127_Eth"] = "morphomidnightwbtcusdc_860_20261127_eth";
|
|
44
|
+
MorphoMidnightVersions["MorphoMidnightWBTCUSDC_860_20261225_Eth"] = "morphomidnightwbtcusdc_860_20261225_eth";
|
|
45
|
+
MorphoMidnightVersions["MorphoMidnightWBTCUSDC_860_20270129_Eth"] = "morphomidnightwbtcusdc_860_20270129_eth";
|
|
46
|
+
MorphoMidnightVersions["MorphoMidnightWBTCUSDC_860_20270226_Eth"] = "morphomidnightwbtcusdc_860_20270226_eth";
|
|
47
|
+
MorphoMidnightVersions["MorphoMidnightWBTCUSDC_860_20270326_Eth"] = "morphomidnightwbtcusdc_860_20270326_eth";
|
|
48
|
+
MorphoMidnightVersions["MorphoMidnightCbBTCUSDC_860_20260925_Eth"] = "morphomidnightcbbtcusdc_860_20260925_eth";
|
|
49
|
+
MorphoMidnightVersions["MorphoMidnightCbBTCUSDC_860_20261030_Eth"] = "morphomidnightcbbtcusdc_860_20261030_eth";
|
|
50
|
+
MorphoMidnightVersions["MorphoMidnightCbBTCUSDC_860_20261127_Eth"] = "morphomidnightcbbtcusdc_860_20261127_eth";
|
|
51
|
+
MorphoMidnightVersions["MorphoMidnightCbBTCUSDC_860_20261225_Eth"] = "morphomidnightcbbtcusdc_860_20261225_eth";
|
|
52
|
+
MorphoMidnightVersions["MorphoMidnightCbBTCUSDC_860_20270129_Eth"] = "morphomidnightcbbtcusdc_860_20270129_eth";
|
|
53
|
+
MorphoMidnightVersions["MorphoMidnightCbBTCUSDC_860_20270226_Eth"] = "morphomidnightcbbtcusdc_860_20270226_eth";
|
|
54
|
+
MorphoMidnightVersions["MorphoMidnightCbBTCUSDC_860_20270326_Eth"] = "morphomidnightcbbtcusdc_860_20270326_eth";
|
|
55
|
+
// Tenor-hosted Midnight markets (same core, different order book)
|
|
56
|
+
MorphoMidnightVersions["MorphoMidnightTenorReUSDUSDC_20260925_Eth"] = "morphomidnighttenorreusdusdc_20260925_eth";
|
|
57
|
+
MorphoMidnightVersions["MorphoMidnightTenorReUSDUSDC_20261030_Eth"] = "morphomidnighttenorreusdusdc_20261030_eth";
|
|
58
|
+
MorphoMidnightVersions["MorphoMidnightTenorReUSDUSDC_20261127_Eth"] = "morphomidnighttenorreusdusdc_20261127_eth";
|
|
59
|
+
MorphoMidnightVersions["MorphoMidnightTenorReUSDUSDC_20261225_Eth"] = "morphomidnighttenorreusdusdc_20261225_eth";
|
|
60
|
+
MorphoMidnightVersions["MorphoMidnightTenorSiUSDUSDC_20260925_Eth"] = "morphomidnighttenorsiusdusdc_20260925_eth";
|
|
61
|
+
MorphoMidnightVersions["MorphoMidnightTenorSiUSDUSDC_20261030_Eth"] = "morphomidnighttenorsiusdusdc_20261030_eth";
|
|
62
|
+
MorphoMidnightVersions["MorphoMidnightTenorSiUSDUSDC_20261127_Eth"] = "morphomidnighttenorsiusdusdc_20261127_eth";
|
|
63
|
+
MorphoMidnightVersions["MorphoMidnightTenorSiUSDUSDC_20261225_Eth"] = "morphomidnighttenorsiusdusdc_20261225_eth";
|
|
64
|
+
MorphoMidnightVersions["MorphoMidnightTenorStrUSDUSDC_20260925_Eth"] = "morphomidnighttenorstrusdusdc_20260925_eth";
|
|
65
|
+
MorphoMidnightVersions["MorphoMidnightTenorStrUSDUSDC_20261030_Eth"] = "morphomidnighttenorstrusdusdc_20261030_eth";
|
|
66
|
+
MorphoMidnightVersions["MorphoMidnightTenorStrUSDUSDC_20261127_Eth"] = "morphomidnighttenorstrusdusdc_20261127_eth";
|
|
67
|
+
MorphoMidnightVersions["MorphoMidnightTenorStrUSDUSDC_20261225_Eth"] = "morphomidnighttenorstrusdusdc_20261225_eth";
|
|
68
|
+
MorphoMidnightVersions["MorphoMidnightTenorUSD3USDC_20260925_Eth"] = "morphomidnighttenorusd3usdc_20260925_eth";
|
|
69
|
+
MorphoMidnightVersions["MorphoMidnightTenorUSD3USDC_20261030_Eth"] = "morphomidnighttenorusd3usdc_20261030_eth";
|
|
70
|
+
MorphoMidnightVersions["MorphoMidnightTenorUSD3USDC_20261127_Eth"] = "morphomidnighttenorusd3usdc_20261127_eth";
|
|
71
|
+
MorphoMidnightVersions["MorphoMidnightTenorUSD3USDC_20261225_Eth"] = "morphomidnighttenorusd3usdc_20261225_eth";
|
|
72
|
+
MorphoMidnightVersions["MorphoMidnightTenorWETHUSDC_20260925_Eth"] = "morphomidnighttenorwethusdc_20260925_eth";
|
|
73
|
+
MorphoMidnightVersions["MorphoMidnightTenorWETHUSDC_20261030_Eth"] = "morphomidnighttenorwethusdc_20261030_eth";
|
|
74
|
+
MorphoMidnightVersions["MorphoMidnightTenorWETHUSDC_20261127_Eth"] = "morphomidnighttenorwethusdc_20261127_eth";
|
|
75
|
+
MorphoMidnightVersions["MorphoMidnightTenorWETHUSDC_20261225_Eth"] = "morphomidnighttenorwethusdc_20261225_eth";
|
|
76
|
+
MorphoMidnightVersions["MorphoMidnightTenorWsrUSDUSDC_20260925_Eth"] = "morphomidnighttenorwsrusdusdc_20260925_eth";
|
|
77
|
+
MorphoMidnightVersions["MorphoMidnightTenorWsrUSDUSDC_20261030_Eth"] = "morphomidnighttenorwsrusdusdc_20261030_eth";
|
|
78
|
+
MorphoMidnightVersions["MorphoMidnightTenorWsrUSDUSDC_20261127_Eth"] = "morphomidnighttenorwsrusdusdc_20261127_eth";
|
|
79
|
+
MorphoMidnightVersions["MorphoMidnightTenorWsrUSDUSDC_20261225_Eth"] = "morphomidnighttenorwsrusdusdc_20261225_eth";
|
|
80
|
+
MorphoMidnightVersions["MorphoMidnightTenorWstETHWETH_20260925_Eth"] = "morphomidnighttenorwstethweth_20260925_eth";
|
|
81
|
+
MorphoMidnightVersions["MorphoMidnightTenorWstETHWETH_20261030_Eth"] = "morphomidnighttenorwstethweth_20261030_eth";
|
|
82
|
+
MorphoMidnightVersions["MorphoMidnightTenorWstETHWETH_20261127_Eth"] = "morphomidnighttenorwstethweth_20261127_eth";
|
|
83
|
+
MorphoMidnightVersions["MorphoMidnightTenorWstETHWETH_20261225_Eth"] = "morphomidnighttenorwstethweth_20261225_eth";
|
|
39
84
|
})(MorphoMidnightVersions || (MorphoMidnightVersions = {}));
|
|
40
85
|
/**
|
|
41
86
|
* How much weight `borrowRate` / `debtBase` / `debtInterest` carry on a given position. They fall back to
|
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/package.json
CHANGED
package/src/claiming/compV3.ts
CHANGED
|
@@ -9,7 +9,6 @@ import { ClaimType } from '../types/claiming';
|
|
|
9
9
|
// Not decodable by name, since the error lives in CometRewards' ABI and we call through CompV3View.
|
|
10
10
|
const NOT_SUPPORTED_ERROR_SIG = '0x9c58e3b6';
|
|
11
11
|
|
|
12
|
-
// Only an actual on-chain revert counts - viem reports transport failures as ContractFunctionExecutionError too.
|
|
13
12
|
const isMarketWithoutRewardsConfig = (err: unknown) => {
|
|
14
13
|
if (!(err instanceof BaseError)) return false;
|
|
15
14
|
const revert = err.walk((e) => e instanceof ContractFunctionRevertedError);
|
package/src/config/contracts.ts
CHANGED
|
@@ -1128,6 +1128,10 @@ export const MorphoBlueView = {
|
|
|
1128
1128
|
export const MidnightView = {
|
|
1129
1129
|
"abi": [{"inputs":[{"internalType":"bytes32","name":"_id","type":"bytes32"}],"name":"getMarketInfo","outputs":[{"components":[{"internalType":"bytes32","name":"id","type":"bytes32"},{"internalType":"uint128","name":"totalUnits","type":"uint128"},{"internalType":"uint128","name":"lossFactor","type":"uint128"},{"internalType":"uint128","name":"withdrawable","type":"uint128"},{"internalType":"uint128","name":"continuousFeeCredit","type":"uint128"},{"internalType":"uint16[7]","name":"settlementFees","type":"uint16[7]"},{"internalType":"uint32","name":"continuousFee","type":"uint32"},{"internalType":"uint8","name":"tickSpacing","type":"uint8"},{"internalType":"uint256[]","name":"prices","type":"uint256[]"}],"internalType":"struct MidnightView.MarketInfo","name":"info","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_id","type":"bytes32"},{"internalType":"address","name":"_user","type":"address"}],"name":"getPositionInfo","outputs":[{"components":[{"internalType":"uint128","name":"credit","type":"uint128"},{"internalType":"uint128","name":"pendingFee","type":"uint128"},{"internalType":"uint128","name":"debt","type":"uint128"},{"internalType":"uint128","name":"collateralBitmap","type":"uint128"},{"internalType":"uint128[]","name":"collateral","type":"uint128[]"},{"internalType":"uint256","name":"ratio","type":"uint256"}],"internalType":"struct MidnightView.PositionInfo","name":"pos","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_id","type":"bytes32"},{"internalType":"address","name":"_user","type":"address"}],"name":"getRatio","outputs":[{"internalType":"uint256","name":"ratio","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"address","name":"midnight","type":"address"},{"internalType":"address","name":"loanToken","type":"address"},{"components":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"lltv","type":"uint256"},{"internalType":"uint256","name":"liquidationCursor","type":"uint256"},{"internalType":"address","name":"oracle","type":"address"}],"internalType":"struct CollateralParams[]","name":"collateralParams","type":"tuple[]"},{"internalType":"uint256","name":"maturity","type":"uint256"},{"internalType":"uint256","name":"rcfThreshold","type":"uint256"},{"internalType":"address","name":"enterGate","type":"address"},{"internalType":"address","name":"liquidatorGate","type":"address"}],"internalType":"struct Market","name":"_market","type":"tuple"}],"name":"toId","outputs":[{"internalType":"bytes32","name":"id","type":"bytes32"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_id","type":"bytes32"}],"name":"toMarket","outputs":[{"components":[{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"address","name":"midnight","type":"address"},{"internalType":"address","name":"loanToken","type":"address"},{"components":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"lltv","type":"uint256"},{"internalType":"uint256","name":"liquidationCursor","type":"uint256"},{"internalType":"address","name":"oracle","type":"address"}],"internalType":"struct CollateralParams[]","name":"collateralParams","type":"tuple[]"},{"internalType":"uint256","name":"maturity","type":"uint256"},{"internalType":"uint256","name":"rcfThreshold","type":"uint256"},{"internalType":"address","name":"enterGate","type":"address"},{"internalType":"address","name":"liquidatorGate","type":"address"}],"internalType":"struct Market","name":"market","type":"tuple"}],"stateMutability":"view","type":"function"}],
|
|
1130
1130
|
"networks": {
|
|
1131
|
+
"1": {
|
|
1132
|
+
"address": "0xB64FBf011343961D9AC4A04b714414E35ebE6BE0",
|
|
1133
|
+
"createdBlock": 25938908,
|
|
1134
|
+
},
|
|
1131
1135
|
"8453": {
|
|
1132
1136
|
"address": "0x3aa272f329E8B562A3bA56Bb6979a44D23A28839",
|
|
1133
1137
|
"createdBlock": 48932293,
|