@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
|
@@ -78,8 +78,13 @@ function _getMorphoMidnightMarketData(provider, network, selectedMarket) {
|
|
|
78
78
|
supplyIncentives: [],
|
|
79
79
|
borrowIncentives: [],
|
|
80
80
|
};
|
|
81
|
+
// `collaterals` is the full on-chain set, so `i` is the index `prices` is keyed by. Hidden entries
|
|
82
|
+
// (curator vaults, the loan token itself) are skipped rather than filtered out beforehand, which would
|
|
83
|
+
// shift every later collateral onto the wrong price.
|
|
81
84
|
const collateralSymbols = [];
|
|
82
85
|
collaterals.forEach((coll, i) => {
|
|
86
|
+
if (coll.hidden)
|
|
87
|
+
return;
|
|
83
88
|
const collInfo = (0, tokens_1.getAssetInfoByAddress)(coll.token, network);
|
|
84
89
|
const collSym = (0, utils_1.wethToEth)(collInfo.symbol);
|
|
85
90
|
collateralSymbols.push(collSym);
|
|
@@ -142,8 +147,11 @@ function _getMorphoMidnightAccountData(provider, network, account, selectedMarke
|
|
|
142
147
|
suppliedUsd: new decimal_js_1.default(credit).mul(loanTokenData.price).toString(),
|
|
143
148
|
borrowedUsd: new decimal_js_1.default(debt).mul(loanTokenData.price).toString(),
|
|
144
149
|
};
|
|
145
|
-
// positionInfo.collateral is index-aligned with the market's collateral set (0 where
|
|
150
|
+
// positionInfo.collateral is index-aligned with the market's full on-chain collateral set (0 where
|
|
151
|
+
// unused), so hidden entries are skipped in place rather than filtered out first.
|
|
146
152
|
collaterals.forEach((coll, i) => {
|
|
153
|
+
if (coll.hidden)
|
|
154
|
+
return;
|
|
147
155
|
const collInfo = (0, tokens_1.getAssetInfoByAddress)(coll.token, network);
|
|
148
156
|
const collSym = (0, utils_1.wethToEth)(collInfo.symbol);
|
|
149
157
|
const rawAmount = positionInfo.collateral[i] ? positionInfo.collateral[i].toString() : '0';
|
|
@@ -223,6 +231,8 @@ const _getMorphoMidnightAccountBalances = (provider, network, block, addressMapp
|
|
|
223
231
|
};
|
|
224
232
|
const collateral = {};
|
|
225
233
|
collaterals.forEach((coll, i) => {
|
|
234
|
+
if (coll.hidden)
|
|
235
|
+
return;
|
|
226
236
|
const collInfo = (0, tokens_1.getAssetInfoByAddress)(coll.token, network);
|
|
227
237
|
const rawAmount = positionInfo.collateral[i] ? positionInfo.collateral[i].toString() : '0';
|
|
228
238
|
collateral[addressMapping ? collInfo.address.toLowerCase() : (0, utils_1.wethToEth)(collInfo.symbol)] = (0, tokens_1.assetAmountInEth)(rawAmount, (0, utils_1.wethToEth)(collInfo.symbol));
|
package/cjs/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/cjs/portfolio/index.js
CHANGED
|
@@ -27,6 +27,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.getPortfolioData = getPortfolioData;
|
|
30
|
+
exports.getShifterPortfolioData = getShifterPortfolioData;
|
|
30
31
|
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
31
32
|
const common_1 = require("../types/common");
|
|
32
33
|
const markets_1 = require("../markets");
|
|
@@ -623,4 +624,290 @@ function getPortfolioData(provider_1, network_1, defaultProvider_1, addresses_1)
|
|
|
623
624
|
};
|
|
624
625
|
});
|
|
625
626
|
}
|
|
627
|
+
function getShifterPortfolioData(provider_1, network_1, defaultProvider_1, addresses_1) {
|
|
628
|
+
return __awaiter(this, arguments, void 0, function* (provider, network, defaultProvider, addresses, isSim = false) {
|
|
629
|
+
const isMainnet = network === common_1.NetworkNumber.Eth;
|
|
630
|
+
const isFluidSupported = [common_1.NetworkNumber.Eth, common_1.NetworkNumber.Arb, common_1.NetworkNumber.Base, common_1.NetworkNumber.Plasma].includes(network);
|
|
631
|
+
const morphoMarkets = Object.values((0, markets_1.MorphoBlueMarkets)(network)).filter((market) => market.chainIds.includes(network));
|
|
632
|
+
const morphoMidnightMarkets = Object.values((0, markets_1.MorphoMidnightMarkets)(network)).filter((market) => market.chainIds.includes(network));
|
|
633
|
+
const compoundV3Markets = Object.values((0, markets_1.CompoundMarkets)(network)).filter((market) => market.chainIds.includes(network) && market.value !== types_1.CompoundVersions.CompoundV2);
|
|
634
|
+
const sparkMarkets = Object.values((0, markets_1.SparkMarkets)(network)).filter((market) => market.chainIds.includes(network));
|
|
635
|
+
const aaveV3Markets = [types_1.AaveVersions.AaveV3, types_1.AaveVersions.AaveV3Lido, types_1.AaveVersions.AaveV3Etherfi].map((version) => (0, markets_1.AaveMarkets)(network)[version]).filter((market) => market.chainIds.includes(network));
|
|
636
|
+
const aaveV2Markets = [types_1.AaveVersions.AaveV2].map((version) => (0, markets_1.AaveMarkets)(network)[version]).filter((market) => market.chainIds.includes(network));
|
|
637
|
+
const compoundV2Markets = [types_1.CompoundVersions.CompoundV2].map((version) => (0, markets_1.CompoundMarkets)(network)[version]).filter((market) => market.chainIds.includes(network));
|
|
638
|
+
const crvUsdMarkets = Object.values((0, markets_1.CrvUsdMarkets)(network)).filter((market) => market.chainIds.includes(network));
|
|
639
|
+
const llamaLendMarkets = [common_1.NetworkNumber.Eth, common_1.NetworkNumber.Arb].includes(network) ? Object.values((0, markets_1.LlamaLendMarkets)(network)).filter((market) => market.chainIds.includes(network)) : [];
|
|
640
|
+
const liquityV2Markets = [common_1.NetworkNumber.Eth].includes(network) ? Object.values((0, markets_1.LiquityV2Markets)(network)) : [];
|
|
641
|
+
const aaveV4Spokes = Object.values((0, markets_1.AaveV4Spokes)(network)).filter((market) => market.chainIds.includes(network));
|
|
642
|
+
const args = [network, { batch: { multicall: { batchSize: isSim ? 2000 : 2500000 } } }];
|
|
643
|
+
const client = (0, viem_1.getViemProvider)(provider, ...args);
|
|
644
|
+
const defaultClient = (0, viem_1.getViemProvider)(defaultProvider, ...args);
|
|
645
|
+
const markets = {
|
|
646
|
+
morphoMarketsData: {},
|
|
647
|
+
morphoMidnightMarketsData: {},
|
|
648
|
+
compoundV3MarketsData: {},
|
|
649
|
+
sparkMarketsData: {},
|
|
650
|
+
aaveV3MarketsData: {},
|
|
651
|
+
aaveV2MarketsData: {},
|
|
652
|
+
compoundV2MarketsData: {},
|
|
653
|
+
crvUsdMarketsData: {},
|
|
654
|
+
llamaLendMarketsData: {},
|
|
655
|
+
liquityV2MarketsData: {},
|
|
656
|
+
aaveV4SpokesData: {},
|
|
657
|
+
fluidMarketsData: {},
|
|
658
|
+
makerMarketsData: {},
|
|
659
|
+
};
|
|
660
|
+
const makerCdps = {};
|
|
661
|
+
const positions = {};
|
|
662
|
+
for (const address of addresses) {
|
|
663
|
+
positions[address.toLowerCase()] = {
|
|
664
|
+
aaveV3: {},
|
|
665
|
+
aaveV4: {},
|
|
666
|
+
morphoBlue: {},
|
|
667
|
+
morphoMidnight: {},
|
|
668
|
+
compoundV3: {},
|
|
669
|
+
spark: {},
|
|
670
|
+
maker: {},
|
|
671
|
+
aaveV2: {},
|
|
672
|
+
compoundV2: {},
|
|
673
|
+
liquity: {},
|
|
674
|
+
crvUsd: {},
|
|
675
|
+
llamaLend: {},
|
|
676
|
+
fluid: {
|
|
677
|
+
error: '',
|
|
678
|
+
data: {},
|
|
679
|
+
},
|
|
680
|
+
};
|
|
681
|
+
}
|
|
682
|
+
yield Promise.allSettled([
|
|
683
|
+
// === MARKET DATA (needs to be fetched first) ===
|
|
684
|
+
...morphoMarkets.map((market) => __awaiter(this, void 0, void 0, function* () {
|
|
685
|
+
markets.morphoMarketsData[market.value] = yield (0, morphoBlue_1._getMorphoBluePortfolioMarketData)(client, network, market);
|
|
686
|
+
})),
|
|
687
|
+
...morphoMidnightMarkets.map((market) => __awaiter(this, void 0, void 0, function* () {
|
|
688
|
+
markets.morphoMidnightMarketsData[market.value] = yield (0, morphoMidnight_1._getMorphoMidnightMarketData)(client, network, market);
|
|
689
|
+
})),
|
|
690
|
+
...compoundV3Markets.map((market) => __awaiter(this, void 0, void 0, function* () {
|
|
691
|
+
markets.compoundV3MarketsData[market.value] = yield (0, compoundV3_1._getCompoundV3MarketsData)(client, network, market, defaultClient);
|
|
692
|
+
})),
|
|
693
|
+
...sparkMarkets.map((market) => __awaiter(this, void 0, void 0, function* () {
|
|
694
|
+
markets.sparkMarketsData[market.value] = yield (0, spark_1._getSparkMarketsData)(client, network, market);
|
|
695
|
+
})),
|
|
696
|
+
...aaveV3Markets.map((market) => __awaiter(this, void 0, void 0, function* () {
|
|
697
|
+
markets.aaveV3MarketsData[market.value] = yield (0, aaveV3_1._getAaveV3MarketData)(client, network, market);
|
|
698
|
+
})),
|
|
699
|
+
...aaveV4Spokes.map((spoke) => __awaiter(this, void 0, void 0, function* () {
|
|
700
|
+
markets.aaveV4SpokesData[spoke.value] = yield (0, aaveV4_1._getAaveV4SpokeData)(client, network, spoke);
|
|
701
|
+
})),
|
|
702
|
+
...aaveV2Markets.map((market) => __awaiter(this, void 0, void 0, function* () {
|
|
703
|
+
markets.aaveV2MarketsData[market.value] = yield (0, aaveV2_1._getAaveV2MarketsData)(client, network, market);
|
|
704
|
+
})),
|
|
705
|
+
...compoundV2Markets.map((market) => __awaiter(this, void 0, void 0, function* () {
|
|
706
|
+
markets.compoundV2MarketsData[market.value] = yield (0, compoundV2_1._getCompoundV2MarketsData)(client, network);
|
|
707
|
+
})),
|
|
708
|
+
...crvUsdMarkets.map((market) => __awaiter(this, void 0, void 0, function* () {
|
|
709
|
+
markets.crvUsdMarketsData[market.value] = yield (0, curveUsd_1._getCurveUsdGlobalData)(client, network, market);
|
|
710
|
+
})),
|
|
711
|
+
...llamaLendMarkets.map((market) => __awaiter(this, void 0, void 0, function* () {
|
|
712
|
+
markets.llamaLendMarketsData[market.value] = yield (0, llamaLend_1._getLlamaLendGlobalData)(client, network, market);
|
|
713
|
+
})),
|
|
714
|
+
...liquityV2Markets.map((market) => __awaiter(this, void 0, void 0, function* () {
|
|
715
|
+
markets.liquityV2MarketsData[market.value] = yield (0, liquityV2_1._getLiquityV2MarketData)(client, network, market);
|
|
716
|
+
})),
|
|
717
|
+
(() => __awaiter(this, void 0, void 0, function* () {
|
|
718
|
+
if (!isFluidSupported)
|
|
719
|
+
return;
|
|
720
|
+
try {
|
|
721
|
+
markets.fluidMarketsData = yield (0, fluid_1._getAllFluidMarketDataPortfolio)(client, network);
|
|
722
|
+
}
|
|
723
|
+
catch (error) {
|
|
724
|
+
console.error('Error fetching Fluid markets data:', error);
|
|
725
|
+
}
|
|
726
|
+
}))(),
|
|
727
|
+
(() => __awaiter(this, void 0, void 0, function* () {
|
|
728
|
+
if (!isMainnet)
|
|
729
|
+
return; // Maker CDPs are only available on mainnet
|
|
730
|
+
try {
|
|
731
|
+
markets.makerMarketsData = yield (0, maker_1._getMakerIlksData)(client, network, markets_1.MakerActiveIlks);
|
|
732
|
+
}
|
|
733
|
+
catch (error) {
|
|
734
|
+
console.error('Error fetching Maker ilks data:', error);
|
|
735
|
+
}
|
|
736
|
+
}))(),
|
|
737
|
+
// === INDEPENDENT USER DATA (doesn't depend on market data) ===
|
|
738
|
+
...addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
|
|
739
|
+
if (!isMainnet)
|
|
740
|
+
return; // Maker CDPs are only available on mainnet
|
|
741
|
+
const makerCdp = yield (0, maker_1._getUserCdps)(client, network, address);
|
|
742
|
+
makerCdps[address.toLowerCase()] = makerCdp;
|
|
743
|
+
})),
|
|
744
|
+
...addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
|
|
745
|
+
try {
|
|
746
|
+
if (!isFluidSupported)
|
|
747
|
+
return; // Fluid is not available on Optimism
|
|
748
|
+
const userPositions = (yield (0, fluid_1._getUserPositionsPortfolio)(client, network, address));
|
|
749
|
+
for (const position of userPositions) {
|
|
750
|
+
if (position.userData && new decimal_js_1.default(position.userData.suppliedUsd).gt(0)) {
|
|
751
|
+
positions[address.toLowerCase()].fluid.data[position.userData.nftId] = position.userData;
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
catch (error) {
|
|
756
|
+
console.error(`Error fetching Fluid positions for address ${address}:`, error);
|
|
757
|
+
positions[address.toLowerCase()].fluid = {
|
|
758
|
+
error: `Error fetching Fluid positions for address ${address}`,
|
|
759
|
+
data: {},
|
|
760
|
+
};
|
|
761
|
+
}
|
|
762
|
+
})),
|
|
763
|
+
]);
|
|
764
|
+
yield Promise.all([
|
|
765
|
+
...aaveV3Markets.map((market) => addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
|
|
766
|
+
try {
|
|
767
|
+
const accData = yield (0, aaveV3_1._getAaveV3AccountData)(client, network, address, Object.assign({ selectedMarket: market }, markets.aaveV3MarketsData[market.value]));
|
|
768
|
+
if (new decimal_js_1.default(accData.suppliedUsd).gt(0))
|
|
769
|
+
positions[address.toLowerCase()].aaveV3[market.value] = { error: '', data: accData };
|
|
770
|
+
}
|
|
771
|
+
catch (error) {
|
|
772
|
+
console.error(`Error fetching AaveV3 account data for address ${address} on market ${market.value}:`, error);
|
|
773
|
+
positions[address.toLowerCase()].aaveV3[market.value] = { error: `Error fetching AaveV3 account data for address ${address} on market ${market.value}`, data: null };
|
|
774
|
+
}
|
|
775
|
+
}))).flat(),
|
|
776
|
+
...aaveV4Spokes.map((spoke) => addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
|
|
777
|
+
try {
|
|
778
|
+
const accData = yield (0, aaveV4_1._getAaveV4AccountData)(client, network, markets.aaveV4SpokesData[spoke.value], address);
|
|
779
|
+
if (new decimal_js_1.default(accData.suppliedUsd).gt(0))
|
|
780
|
+
positions[address.toLowerCase()].aaveV4[spoke.value] = { error: '', data: accData };
|
|
781
|
+
}
|
|
782
|
+
catch (error) {
|
|
783
|
+
console.error(`Error fetching AaveV4 account data for address ${address} on spoke ${spoke.value}:`, error);
|
|
784
|
+
positions[address.toLowerCase()].aaveV4[spoke.value] = { error: `Error fetching AaveV4 account data for address ${address} on spoke ${spoke.value}`, data: null };
|
|
785
|
+
}
|
|
786
|
+
}))).flat(),
|
|
787
|
+
...morphoMarkets.map((market) => addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
|
|
788
|
+
try {
|
|
789
|
+
const accData = yield (0, morphoBlue_1._getMorphoBlueAccountData)(client, network, address, market, markets.morphoMarketsData[market.value]);
|
|
790
|
+
if (new decimal_js_1.default(accData.suppliedUsd).gt(0))
|
|
791
|
+
positions[address.toLowerCase()].morphoBlue[market.value] = { error: '', data: accData };
|
|
792
|
+
}
|
|
793
|
+
catch (error) {
|
|
794
|
+
console.error(`Error fetching MorphoBlue account data for address ${address} on market ${market.value}:`, error);
|
|
795
|
+
positions[address.toLowerCase()].morphoBlue[market.value] = { error: `Error fetching MorphoBlue account data for address ${address} on market ${market.value}`, data: null };
|
|
796
|
+
}
|
|
797
|
+
}))).flat(),
|
|
798
|
+
...morphoMidnightMarkets.map((market) => addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
|
|
799
|
+
try {
|
|
800
|
+
const accData = yield (0, morphoMidnight_1._getMorphoMidnightAccountData)(client, network, address, market, markets.morphoMidnightMarketsData[market.value]);
|
|
801
|
+
if (new decimal_js_1.default(accData.suppliedUsd).gt(0))
|
|
802
|
+
positions[address.toLowerCase()].morphoMidnight[market.value] = { error: '', data: accData };
|
|
803
|
+
}
|
|
804
|
+
catch (error) {
|
|
805
|
+
console.error(`Error fetching MorphoMidnight account data for address ${address} on market ${market.value}:`, error);
|
|
806
|
+
positions[address.toLowerCase()].morphoMidnight[market.value] = { error: `Error fetching MorphoMidnight account data for address ${address} on market ${market.value}`, data: null };
|
|
807
|
+
}
|
|
808
|
+
}))).flat(),
|
|
809
|
+
...compoundV3Markets.map((market) => addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
|
|
810
|
+
try {
|
|
811
|
+
const accData = yield (0, compoundV3_1._getCompoundV3AccountData)(client, network, address, constants_1.ZERO_ADDRESS, { selectedMarket: market, assetsData: markets.compoundV3MarketsData[market.value].assetsData });
|
|
812
|
+
if (new decimal_js_1.default(accData.suppliedUsd).gt(0))
|
|
813
|
+
positions[address.toLowerCase()].compoundV3[market.value] = { error: '', data: accData };
|
|
814
|
+
}
|
|
815
|
+
catch (error) {
|
|
816
|
+
console.error(`Error fetching CompoundV3 account data for address ${address} on market ${market.value}:`, error);
|
|
817
|
+
positions[address.toLowerCase()].compoundV3[market.value] = { error: `Error fetching CompoundV3 account data for address ${address} on market ${market.value}`, data: null };
|
|
818
|
+
}
|
|
819
|
+
}))).flat(),
|
|
820
|
+
...sparkMarkets.map((market) => addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
|
|
821
|
+
try {
|
|
822
|
+
const accData = yield (0, spark_1._getSparkAccountData)(client, network, address, { selectedMarket: market, assetsData: markets.sparkMarketsData[market.value].assetsData, eModeCategoriesData: markets.sparkMarketsData[market.value].eModeCategoriesData });
|
|
823
|
+
if (new decimal_js_1.default(accData.suppliedUsd).gt(0))
|
|
824
|
+
positions[address.toLowerCase()].spark[market.value] = { error: '', data: accData };
|
|
825
|
+
}
|
|
826
|
+
catch (error) {
|
|
827
|
+
console.error(`Error fetching Spark account data for address ${address} on market ${market.value}:`, error);
|
|
828
|
+
positions[address.toLowerCase()].spark[market.value] = { error: `Error fetching Spark account data for address ${address} on market ${market.value}`, data: null };
|
|
829
|
+
}
|
|
830
|
+
}))).flat(),
|
|
831
|
+
...addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
|
|
832
|
+
var _a;
|
|
833
|
+
return (_a = makerCdps[address.toLowerCase()]) === null || _a === void 0 ? void 0 : _a.map((cdpInfo) => __awaiter(this, void 0, void 0, function* () {
|
|
834
|
+
try {
|
|
835
|
+
// reuse ilk data fetched for the markets payload; ilks outside the active set are fetched on demand
|
|
836
|
+
const cdpData = yield (0, maker_1._getMakerCdpData)(client, network, cdpInfo, markets.makerMarketsData[cdpInfo.ilkLabel]);
|
|
837
|
+
if (cdpData) {
|
|
838
|
+
positions[address.toLowerCase()].maker[cdpInfo.id] = { error: '', data: cdpData };
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
catch (error) {
|
|
842
|
+
console.error(`Error fetching Maker CDP data for address ${address} with ID ${cdpInfo.id}:`, error);
|
|
843
|
+
positions[address.toLowerCase()].maker[cdpInfo.id] = { error: `Error fetching Maker CDP data for address ${address} with ID ${cdpInfo.id}`, data: null };
|
|
844
|
+
}
|
|
845
|
+
}));
|
|
846
|
+
})).flat(),
|
|
847
|
+
...aaveV2Markets.map((market) => addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
|
|
848
|
+
try {
|
|
849
|
+
const accData = yield (0, aaveV2_1._getAaveV2AccountData)(client, network, address, markets.aaveV2MarketsData[market.value].assetsData, market);
|
|
850
|
+
if (new decimal_js_1.default(accData.suppliedUsd).gt(0))
|
|
851
|
+
positions[address.toLowerCase()].aaveV2[market.value] = { error: '', data: accData };
|
|
852
|
+
}
|
|
853
|
+
catch (error) {
|
|
854
|
+
console.error(`Error fetching AaveV2 account data for address ${address}:`, error);
|
|
855
|
+
positions[address.toLowerCase()].aaveV2[market.value] = { error: `Error fetching AaveV2 account data for address ${address}`, data: null };
|
|
856
|
+
}
|
|
857
|
+
}))).flat(),
|
|
858
|
+
...compoundV2Markets.map((market) => addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
|
|
859
|
+
try {
|
|
860
|
+
const accData = yield (0, compoundV2_1._getCompoundV2AccountData)(client, network, address, markets.compoundV2MarketsData[market.value].assetsData);
|
|
861
|
+
if (new decimal_js_1.default(accData.suppliedUsd).gt(0))
|
|
862
|
+
positions[address.toLowerCase()].compoundV2[market.value] = { error: '', data: accData };
|
|
863
|
+
}
|
|
864
|
+
catch (error) {
|
|
865
|
+
console.error(`Error fetching CompoundV2 account data for address ${address}:`, error);
|
|
866
|
+
positions[address.toLowerCase()].compoundV2[market.value] = { error: `Error fetching CompoundV2 account data for address ${address}`, data: null };
|
|
867
|
+
}
|
|
868
|
+
}))).flat(),
|
|
869
|
+
...addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
|
|
870
|
+
try {
|
|
871
|
+
if (!isMainnet)
|
|
872
|
+
return; // Liquity trove info is only available on mainnet
|
|
873
|
+
const troveInfo = yield (0, liquity_1._getLiquityTroveInfo)(client, network, address);
|
|
874
|
+
if (new decimal_js_1.default(troveInfo.collateral).gt(0))
|
|
875
|
+
positions[address.toLowerCase()].liquity = { error: '', data: troveInfo };
|
|
876
|
+
}
|
|
877
|
+
catch (error) {
|
|
878
|
+
console.error(`Error fetching Liquity trove info for address ${address}:`, error);
|
|
879
|
+
positions[address.toLowerCase()].liquity = { error: `Error fetching Liquity trove info for address ${address}`, data: null };
|
|
880
|
+
}
|
|
881
|
+
})),
|
|
882
|
+
...crvUsdMarkets.map((market) => addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
|
|
883
|
+
try {
|
|
884
|
+
const accData = yield (0, curveUsd_1._getCurveUsdUserData)(client, network, address, market, markets.crvUsdMarketsData[market.value].activeBand);
|
|
885
|
+
if (new decimal_js_1.default(accData.suppliedUsd).gt(0) || new decimal_js_1.default(accData.borrowedUsd).gt(0)) {
|
|
886
|
+
positions[address.toLowerCase()].crvUsd[market.value] = { error: '', data: Object.assign(Object.assign({}, accData), { borrowRate: markets.crvUsdMarketsData[market.value].borrowRate }) };
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
catch (error) {
|
|
890
|
+
console.error(`Error fetching Curve USD account data for address ${address} on market ${market.value}:`, error);
|
|
891
|
+
positions[address.toLowerCase()].crvUsd[market.value] = { error: `Error fetching Curve USD account data for address ${address} on market ${market.value}`, data: null };
|
|
892
|
+
}
|
|
893
|
+
}))).flat(),
|
|
894
|
+
...llamaLendMarkets.map((market) => addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
|
|
895
|
+
try {
|
|
896
|
+
const accData = yield (0, llamaLend_1._getLlamaLendUserData)(client, network, address, market, markets.llamaLendMarketsData[market.value]);
|
|
897
|
+
if (new decimal_js_1.default(accData.suppliedUsd).gt(0) || new decimal_js_1.default(accData.borrowedUsd).gt(0)) {
|
|
898
|
+
positions[address.toLowerCase()].llamaLend[market.value] = { error: '', data: Object.assign(Object.assign({}, accData), { borrowRate: markets.llamaLendMarketsData[market.value].borrowRate }) };
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
catch (error) {
|
|
902
|
+
console.error(`Error fetching LlamaLend account data for address ${address} on market ${market.value}:`, error);
|
|
903
|
+
positions[address.toLowerCase()].llamaLend[market.value] = { error: `Error fetching LlamaLend account data for address ${address} on market ${market.value}`, data: null };
|
|
904
|
+
}
|
|
905
|
+
}))).flat(),
|
|
906
|
+
]);
|
|
907
|
+
return {
|
|
908
|
+
positions,
|
|
909
|
+
markets,
|
|
910
|
+
};
|
|
911
|
+
});
|
|
912
|
+
}
|
|
626
913
|
__exportStar(require("./discovery"), exports);
|
|
@@ -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;
|
|
@@ -39,6 +39,51 @@ var MorphoMidnightVersions;
|
|
|
39
39
|
MorphoMidnightVersions["MorphoMidnightTenorCbETHWETH_20261127_Base"] = "morphomidnighttenorcbethweth_20261127_base";
|
|
40
40
|
MorphoMidnightVersions["MorphoMidnightTenorCbETHWETH_20261225_Base"] = "morphomidnighttenorcbethweth_20261225_base";
|
|
41
41
|
MorphoMidnightVersions["MorphoMidnightTenorCbETHWETH_20270129_Base"] = "morphomidnighttenorcbethweth_20270129_base";
|
|
42
|
+
// ETHEREUM
|
|
43
|
+
// Sourced from the official listing at https://markets.morpho.org/fixed?chains=1
|
|
44
|
+
MorphoMidnightVersions["MorphoMidnightWBTCUSDC_860_20260925_Eth"] = "morphomidnightwbtcusdc_860_20260925_eth";
|
|
45
|
+
MorphoMidnightVersions["MorphoMidnightWBTCUSDC_860_20261030_Eth"] = "morphomidnightwbtcusdc_860_20261030_eth";
|
|
46
|
+
MorphoMidnightVersions["MorphoMidnightWBTCUSDC_860_20261127_Eth"] = "morphomidnightwbtcusdc_860_20261127_eth";
|
|
47
|
+
MorphoMidnightVersions["MorphoMidnightWBTCUSDC_860_20261225_Eth"] = "morphomidnightwbtcusdc_860_20261225_eth";
|
|
48
|
+
MorphoMidnightVersions["MorphoMidnightWBTCUSDC_860_20270129_Eth"] = "morphomidnightwbtcusdc_860_20270129_eth";
|
|
49
|
+
MorphoMidnightVersions["MorphoMidnightWBTCUSDC_860_20270226_Eth"] = "morphomidnightwbtcusdc_860_20270226_eth";
|
|
50
|
+
MorphoMidnightVersions["MorphoMidnightWBTCUSDC_860_20270326_Eth"] = "morphomidnightwbtcusdc_860_20270326_eth";
|
|
51
|
+
MorphoMidnightVersions["MorphoMidnightCbBTCUSDC_860_20260925_Eth"] = "morphomidnightcbbtcusdc_860_20260925_eth";
|
|
52
|
+
MorphoMidnightVersions["MorphoMidnightCbBTCUSDC_860_20261030_Eth"] = "morphomidnightcbbtcusdc_860_20261030_eth";
|
|
53
|
+
MorphoMidnightVersions["MorphoMidnightCbBTCUSDC_860_20261127_Eth"] = "morphomidnightcbbtcusdc_860_20261127_eth";
|
|
54
|
+
MorphoMidnightVersions["MorphoMidnightCbBTCUSDC_860_20261225_Eth"] = "morphomidnightcbbtcusdc_860_20261225_eth";
|
|
55
|
+
MorphoMidnightVersions["MorphoMidnightCbBTCUSDC_860_20270129_Eth"] = "morphomidnightcbbtcusdc_860_20270129_eth";
|
|
56
|
+
MorphoMidnightVersions["MorphoMidnightCbBTCUSDC_860_20270226_Eth"] = "morphomidnightcbbtcusdc_860_20270226_eth";
|
|
57
|
+
MorphoMidnightVersions["MorphoMidnightCbBTCUSDC_860_20270326_Eth"] = "morphomidnightcbbtcusdc_860_20270326_eth";
|
|
58
|
+
// Tenor-hosted Midnight markets (same core, different order book)
|
|
59
|
+
MorphoMidnightVersions["MorphoMidnightTenorReUSDUSDC_20260925_Eth"] = "morphomidnighttenorreusdusdc_20260925_eth";
|
|
60
|
+
MorphoMidnightVersions["MorphoMidnightTenorReUSDUSDC_20261030_Eth"] = "morphomidnighttenorreusdusdc_20261030_eth";
|
|
61
|
+
MorphoMidnightVersions["MorphoMidnightTenorReUSDUSDC_20261127_Eth"] = "morphomidnighttenorreusdusdc_20261127_eth";
|
|
62
|
+
MorphoMidnightVersions["MorphoMidnightTenorReUSDUSDC_20261225_Eth"] = "morphomidnighttenorreusdusdc_20261225_eth";
|
|
63
|
+
MorphoMidnightVersions["MorphoMidnightTenorSiUSDUSDC_20260925_Eth"] = "morphomidnighttenorsiusdusdc_20260925_eth";
|
|
64
|
+
MorphoMidnightVersions["MorphoMidnightTenorSiUSDUSDC_20261030_Eth"] = "morphomidnighttenorsiusdusdc_20261030_eth";
|
|
65
|
+
MorphoMidnightVersions["MorphoMidnightTenorSiUSDUSDC_20261127_Eth"] = "morphomidnighttenorsiusdusdc_20261127_eth";
|
|
66
|
+
MorphoMidnightVersions["MorphoMidnightTenorSiUSDUSDC_20261225_Eth"] = "morphomidnighttenorsiusdusdc_20261225_eth";
|
|
67
|
+
MorphoMidnightVersions["MorphoMidnightTenorStrUSDUSDC_20260925_Eth"] = "morphomidnighttenorstrusdusdc_20260925_eth";
|
|
68
|
+
MorphoMidnightVersions["MorphoMidnightTenorStrUSDUSDC_20261030_Eth"] = "morphomidnighttenorstrusdusdc_20261030_eth";
|
|
69
|
+
MorphoMidnightVersions["MorphoMidnightTenorStrUSDUSDC_20261127_Eth"] = "morphomidnighttenorstrusdusdc_20261127_eth";
|
|
70
|
+
MorphoMidnightVersions["MorphoMidnightTenorStrUSDUSDC_20261225_Eth"] = "morphomidnighttenorstrusdusdc_20261225_eth";
|
|
71
|
+
MorphoMidnightVersions["MorphoMidnightTenorUSD3USDC_20260925_Eth"] = "morphomidnighttenorusd3usdc_20260925_eth";
|
|
72
|
+
MorphoMidnightVersions["MorphoMidnightTenorUSD3USDC_20261030_Eth"] = "morphomidnighttenorusd3usdc_20261030_eth";
|
|
73
|
+
MorphoMidnightVersions["MorphoMidnightTenorUSD3USDC_20261127_Eth"] = "morphomidnighttenorusd3usdc_20261127_eth";
|
|
74
|
+
MorphoMidnightVersions["MorphoMidnightTenorUSD3USDC_20261225_Eth"] = "morphomidnighttenorusd3usdc_20261225_eth";
|
|
75
|
+
MorphoMidnightVersions["MorphoMidnightTenorWETHUSDC_20260925_Eth"] = "morphomidnighttenorwethusdc_20260925_eth";
|
|
76
|
+
MorphoMidnightVersions["MorphoMidnightTenorWETHUSDC_20261030_Eth"] = "morphomidnighttenorwethusdc_20261030_eth";
|
|
77
|
+
MorphoMidnightVersions["MorphoMidnightTenorWETHUSDC_20261127_Eth"] = "morphomidnighttenorwethusdc_20261127_eth";
|
|
78
|
+
MorphoMidnightVersions["MorphoMidnightTenorWETHUSDC_20261225_Eth"] = "morphomidnighttenorwethusdc_20261225_eth";
|
|
79
|
+
MorphoMidnightVersions["MorphoMidnightTenorWsrUSDUSDC_20260925_Eth"] = "morphomidnighttenorwsrusdusdc_20260925_eth";
|
|
80
|
+
MorphoMidnightVersions["MorphoMidnightTenorWsrUSDUSDC_20261030_Eth"] = "morphomidnighttenorwsrusdusdc_20261030_eth";
|
|
81
|
+
MorphoMidnightVersions["MorphoMidnightTenorWsrUSDUSDC_20261127_Eth"] = "morphomidnighttenorwsrusdusdc_20261127_eth";
|
|
82
|
+
MorphoMidnightVersions["MorphoMidnightTenorWsrUSDUSDC_20261225_Eth"] = "morphomidnighttenorwsrusdusdc_20261225_eth";
|
|
83
|
+
MorphoMidnightVersions["MorphoMidnightTenorWstETHWETH_20260925_Eth"] = "morphomidnighttenorwstethweth_20260925_eth";
|
|
84
|
+
MorphoMidnightVersions["MorphoMidnightTenorWstETHWETH_20261030_Eth"] = "morphomidnighttenorwstethweth_20261030_eth";
|
|
85
|
+
MorphoMidnightVersions["MorphoMidnightTenorWstETHWETH_20261127_Eth"] = "morphomidnighttenorwstethweth_20261127_eth";
|
|
86
|
+
MorphoMidnightVersions["MorphoMidnightTenorWstETHWETH_20261225_Eth"] = "morphomidnighttenorwstethweth_20261225_eth";
|
|
42
87
|
})(MorphoMidnightVersions || (exports.MorphoMidnightVersions = MorphoMidnightVersions = {}));
|
|
43
88
|
/**
|
|
44
89
|
* How much weight `borrowRate` / `debtBase` / `debtInterest` carry on a given position. They fall back to
|
package/cjs/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/claiming/compV3.js
CHANGED
|
@@ -15,7 +15,6 @@ import { ClaimType } from '../types/claiming';
|
|
|
15
15
|
// `rewardConfig` set - such a market never accrues COMP, so there is nothing to claim.
|
|
16
16
|
// Not decodable by name, since the error lives in CometRewards' ABI and we call through CompV3View.
|
|
17
17
|
const NOT_SUPPORTED_ERROR_SIG = '0x9c58e3b6';
|
|
18
|
-
// Only an actual on-chain revert counts - viem reports transport failures as ContractFunctionExecutionError too.
|
|
19
18
|
const isMarketWithoutRewardsConfig = (err) => {
|
|
20
19
|
var _a;
|
|
21
20
|
if (!(err instanceof BaseError))
|
|
@@ -89746,6 +89746,10 @@ export declare const MidnightView: {
|
|
|
89746
89746
|
readonly type: "function";
|
|
89747
89747
|
}];
|
|
89748
89748
|
readonly networks: {
|
|
89749
|
+
readonly "1": {
|
|
89750
|
+
readonly address: "0xB64FBf011343961D9AC4A04b714414E35ebE6BE0";
|
|
89751
|
+
readonly createdBlock: 25938908;
|
|
89752
|
+
};
|
|
89749
89753
|
readonly "8453": {
|
|
89750
89754
|
readonly address: "0x3aa272f329E8B562A3bA56Bb6979a44D23A28839";
|
|
89751
89755
|
readonly createdBlock: 48932293;
|
package/esm/config/contracts.js
CHANGED
|
@@ -1126,6 +1126,10 @@ export const MorphoBlueView = {
|
|
|
1126
1126
|
export const MidnightView = {
|
|
1127
1127
|
"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" }],
|
|
1128
1128
|
"networks": {
|
|
1129
|
+
"1": {
|
|
1130
|
+
"address": "0xB64FBf011343961D9AC4A04b714414E35ebE6BE0",
|
|
1131
|
+
"createdBlock": 25938908,
|
|
1132
|
+
},
|
|
1129
1133
|
"8453": {
|
|
1130
1134
|
"address": "0x3aa272f329E8B562A3bA56Bb6979a44D23A28839",
|
|
1131
1135
|
"createdBlock": 48932293,
|
package/esm/fluid/index.d.ts
CHANGED
|
@@ -221,3 +221,5 @@ export declare const _getUserPositionsPortfolio: (provider: PublicClient, networ
|
|
|
221
221
|
nftId: string;
|
|
222
222
|
} | undefined;
|
|
223
223
|
}[]>;
|
|
224
|
+
export declare const _getAllFluidMarketDataPortfolio: (provider: PublicClient, network: NetworkNumber) => Promise<Record<string, FluidMarketData>>;
|
|
225
|
+
export declare const getAllFluidMarketDataPortfolio: (provider: EthereumProvider, network: NetworkNumber) => Promise<Record<string, FluidMarketData>>;
|
package/esm/fluid/index.js
CHANGED
|
@@ -1381,3 +1381,36 @@ export const _getUserPositionsPortfolio = (provider, network, user) => __awaiter
|
|
|
1381
1381
|
userData: userData[i],
|
|
1382
1382
|
})).filter(md => md.marketData !== undefined);
|
|
1383
1383
|
});
|
|
1384
|
+
export const _getAllFluidMarketDataPortfolio = (provider, network) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1385
|
+
const versions = getFluidVersionsDataForNetwork(network);
|
|
1386
|
+
if (versions.length === 0)
|
|
1387
|
+
return {};
|
|
1388
|
+
const view = FluidViewContractViem(provider, network);
|
|
1389
|
+
const vaultsData = yield Promise.all(versions.map((version) => view.read.getVaultData([version.marketAddress])));
|
|
1390
|
+
const tokens = Array.from(new Set(vaultsData.map((vaultData) => {
|
|
1391
|
+
const vaultTokens = [getAssetInfoByAddress(vaultData.supplyToken0, network).symbol, getAssetInfoByAddress(vaultData.borrowToken0, network).symbol];
|
|
1392
|
+
if (vaultData.supplyToken1 && !compareAddresses(ZERO_ADDRESS, vaultData.supplyToken1))
|
|
1393
|
+
vaultTokens.push(getAssetInfoByAddress(vaultData.supplyToken1, network).symbol);
|
|
1394
|
+
if (vaultData.borrowToken1 && !compareAddresses(ZERO_ADDRESS, vaultData.borrowToken1))
|
|
1395
|
+
vaultTokens.push(getAssetInfoByAddress(vaultData.borrowToken1, network).symbol);
|
|
1396
|
+
return vaultTokens;
|
|
1397
|
+
}).flat()));
|
|
1398
|
+
// ETH and WBTC needed for other tokens prices
|
|
1399
|
+
if (!tokens.includes('ETH'))
|
|
1400
|
+
tokens.push('ETH');
|
|
1401
|
+
if (!tokens.includes('WBTC'))
|
|
1402
|
+
tokens.push('WBTC');
|
|
1403
|
+
const [tokenPrices, merklCampaigns] = yield Promise.all([
|
|
1404
|
+
getTokensPricesForPortfolio(tokens, provider, network),
|
|
1405
|
+
getFluidMerklCampaigns(network),
|
|
1406
|
+
]);
|
|
1407
|
+
const parsedMarketsData = yield Promise.all(vaultsData.map((vaultData) => __awaiter(void 0, void 0, void 0, function* () { return parseMarketData(provider, vaultData, network, tokenPrices); })));
|
|
1408
|
+
const marketsData = {};
|
|
1409
|
+
parsedMarketsData.forEach((marketData, i) => {
|
|
1410
|
+
if (!marketData)
|
|
1411
|
+
return;
|
|
1412
|
+
marketsData[versions[i].value] = attachFluidMerklIncentives(marketData, merklCampaigns);
|
|
1413
|
+
});
|
|
1414
|
+
return marketsData;
|
|
1415
|
+
});
|
|
1416
|
+
export const getAllFluidMarketDataPortfolio = (provider, network) => __awaiter(void 0, void 0, void 0, function* () { return _getAllFluidMarketDataPortfolio(getViemProvider(provider, network, { batch: { multicall: true } }), network); });
|