@defisaver/positions-sdk 2.1.153-dev → 2.1.154-shifter-v2-dev
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/aaveV2/index.js +2 -0
- package/cjs/claiming/index.d.ts +1 -2
- package/cjs/claiming/index.js +1 -3
- package/cjs/fluid/index.d.ts +5 -0
- package/cjs/fluid/index.js +36 -1
- package/cjs/helpers/aaveHelpers/index.js +3 -0
- package/cjs/helpers/aaveV4Helpers/index.js +1 -0
- package/cjs/helpers/compoundHelpers/index.js +2 -0
- package/cjs/helpers/curveUsdHelpers/index.js +2 -0
- package/cjs/helpers/fluidHelpers/index.js +1 -0
- package/cjs/helpers/liquityV2Helpers/index.js +1 -0
- package/cjs/helpers/llamaLendHelpers/index.js +2 -0
- package/cjs/helpers/makerHelpers/index.d.ts +1 -1
- package/cjs/helpers/makerHelpers/index.js +2 -2
- package/cjs/helpers/morphoBlueHelpers/index.js +2 -0
- package/cjs/helpers/morphoMidnightHelpers/index.js +2 -0
- package/cjs/helpers/sparkHelpers/index.js +1 -0
- package/cjs/liquity/index.js +8 -1
- package/cjs/maker/index.d.ts +7 -2
- package/cjs/maker/index.js +32 -12
- package/cjs/markets/index.d.ts +1 -0
- package/cjs/markets/index.js +3 -1
- package/cjs/markets/maker/index.d.ts +1 -0
- package/cjs/markets/maker/index.js +13 -0
- package/cjs/markets/spark/marketAssets.js +1 -1
- package/cjs/portfolio/index.d.ts +5 -1
- package/cjs/portfolio/index.js +287 -13
- package/cjs/types/aave.d.ts +2 -0
- package/cjs/types/aaveV4.d.ts +1 -0
- package/cjs/types/claiming.d.ts +1 -9
- package/cjs/types/claiming.js +0 -2
- package/cjs/types/compound.d.ts +2 -0
- package/cjs/types/fluid.d.ts +1 -0
- package/cjs/types/liquity.d.ts +1 -0
- package/cjs/types/liquityV2.d.ts +2 -0
- package/cjs/types/maker.d.ts +1 -0
- package/cjs/types/morphoBlue.d.ts +2 -0
- package/cjs/types/morphoMidnight.d.ts +1 -0
- package/cjs/types/portfolio.d.ts +26 -10
- package/cjs/types/spark.d.ts +2 -0
- package/esm/aaveV2/index.js +2 -0
- package/esm/claiming/index.d.ts +1 -2
- package/esm/claiming/index.js +1 -2
- package/esm/fluid/index.d.ts +5 -0
- package/esm/fluid/index.js +33 -0
- package/esm/helpers/aaveHelpers/index.js +3 -0
- package/esm/helpers/aaveV4Helpers/index.js +1 -0
- package/esm/helpers/compoundHelpers/index.js +2 -0
- package/esm/helpers/curveUsdHelpers/index.js +2 -0
- package/esm/helpers/fluidHelpers/index.js +1 -0
- package/esm/helpers/liquityV2Helpers/index.js +1 -0
- package/esm/helpers/llamaLendHelpers/index.js +2 -0
- package/esm/helpers/makerHelpers/index.d.ts +1 -1
- package/esm/helpers/makerHelpers/index.js +2 -2
- package/esm/helpers/morphoBlueHelpers/index.js +2 -0
- package/esm/helpers/morphoMidnightHelpers/index.js +2 -0
- package/esm/helpers/sparkHelpers/index.js +1 -0
- package/esm/liquity/index.js +8 -1
- package/esm/maker/index.d.ts +7 -2
- package/esm/maker/index.js +31 -13
- package/esm/markets/index.d.ts +1 -0
- package/esm/markets/index.js +1 -0
- package/esm/markets/maker/index.d.ts +1 -0
- package/esm/markets/maker/index.js +10 -0
- package/esm/markets/spark/marketAssets.js +1 -1
- package/esm/portfolio/index.d.ts +5 -1
- package/esm/portfolio/index.js +289 -16
- package/esm/types/aave.d.ts +2 -0
- package/esm/types/aaveV4.d.ts +1 -0
- package/esm/types/claiming.d.ts +1 -9
- package/esm/types/claiming.js +0 -2
- package/esm/types/compound.d.ts +2 -0
- package/esm/types/fluid.d.ts +1 -0
- package/esm/types/liquity.d.ts +1 -0
- package/esm/types/liquityV2.d.ts +2 -0
- package/esm/types/maker.d.ts +1 -0
- package/esm/types/morphoBlue.d.ts +2 -0
- package/esm/types/morphoMidnight.d.ts +1 -0
- package/esm/types/portfolio.d.ts +26 -10
- package/esm/types/spark.d.ts +2 -0
- package/package.json +1 -1
- package/src/aaveV2/index.ts +2 -0
- package/src/claiming/index.ts +0 -2
- package/src/fluid/index.ts +40 -0
- package/src/helpers/aaveHelpers/index.ts +3 -0
- package/src/helpers/aaveV4Helpers/index.ts +1 -0
- package/src/helpers/compoundHelpers/index.ts +2 -0
- package/src/helpers/curveUsdHelpers/index.ts +2 -0
- package/src/helpers/fluidHelpers/index.ts +1 -0
- package/src/helpers/liquityV2Helpers/index.ts +1 -0
- package/src/helpers/llamaLendHelpers/index.ts +2 -0
- package/src/helpers/makerHelpers/index.ts +2 -1
- package/src/helpers/morphoBlueHelpers/index.ts +2 -0
- package/src/helpers/morphoMidnightHelpers/index.ts +2 -0
- package/src/helpers/sparkHelpers/index.ts +1 -0
- package/src/liquity/index.ts +8 -1
- package/src/maker/index.ts +62 -29
- package/src/markets/index.ts +2 -1
- package/src/markets/maker/index.ts +10 -0
- package/src/markets/spark/marketAssets.ts +1 -1
- package/src/portfolio/index.ts +270 -14
- package/src/types/aave.ts +3 -0
- package/src/types/aaveV4.ts +1 -0
- package/src/types/claiming.ts +0 -10
- package/src/types/compound.ts +2 -0
- package/src/types/fluid.ts +1 -0
- package/src/types/liquity.ts +2 -0
- package/src/types/liquityV2.ts +2 -0
- package/src/types/maker.ts +2 -0
- package/src/types/morphoBlue.ts +2 -0
- package/src/types/morphoMidnight.ts +1 -0
- package/src/types/portfolio.ts +31 -12
- package/src/types/spark.ts +2 -0
- package/cjs/claiming/compV3.d.ts +0 -15
- package/cjs/claiming/compV3.js +0 -50
- package/esm/claiming/compV3.d.ts +0 -15
- package/esm/claiming/compV3.js +0 -46
- package/src/claiming/compV3.ts +0 -37
package/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");
|
|
@@ -48,7 +49,6 @@ const liquityV2_1 = require("../liquityV2");
|
|
|
48
49
|
const fluid_1 = require("../fluid");
|
|
49
50
|
const umbrella_1 = require("../umbrella");
|
|
50
51
|
const aaveV3_2 = require("../claiming/aaveV3");
|
|
51
|
-
const compV3_1 = require("../claiming/compV3");
|
|
52
52
|
const spark_2 = require("../claiming/spark");
|
|
53
53
|
const king_1 = require("../claiming/king");
|
|
54
54
|
const ethena_1 = require("../claiming/ethena");
|
|
@@ -141,7 +141,6 @@ function getPortfolioData(provider_1, network_1, defaultProvider_1, addresses_1)
|
|
|
141
141
|
rewardsData[address.toLowerCase()] = {
|
|
142
142
|
merkl: {},
|
|
143
143
|
aaveV3: {},
|
|
144
|
-
compV3: {},
|
|
145
144
|
spark: {},
|
|
146
145
|
spk: {},
|
|
147
146
|
king: {},
|
|
@@ -351,17 +350,6 @@ function getPortfolioData(provider_1, network_1, defaultProvider_1, addresses_1)
|
|
|
351
350
|
rewardsData[address.toLowerCase()].spark[market.value] = { error: `Error fetching Spark rewards data for address ${address}`, data: null };
|
|
352
351
|
}
|
|
353
352
|
}))).flat(),
|
|
354
|
-
// CompV3 rewards
|
|
355
|
-
...compoundV3Markets.map(market => addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
|
|
356
|
-
try {
|
|
357
|
-
const compV3Rewards = yield (0, compV3_1.getCompoundV3Rewards)(client, network, address, market.baseMarketAddress);
|
|
358
|
-
rewardsData[address.toLowerCase()].compV3[market.value] = { error: '', data: compV3Rewards };
|
|
359
|
-
}
|
|
360
|
-
catch (error) {
|
|
361
|
-
console.error(`Error fetching Compound V3 rewards data for address ${address}:`, error);
|
|
362
|
-
rewardsData[address.toLowerCase()].compV3[market.value] = { error: `Error fetching Compound V3 rewards data for address ${address}`, data: null };
|
|
363
|
-
}
|
|
364
|
-
}))).flat(),
|
|
365
353
|
...addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
|
|
366
354
|
try {
|
|
367
355
|
const merklData = yield (0, aaveV3_2.getMerklUnclaimedRewards)(address, network);
|
|
@@ -623,4 +611,290 @@ function getPortfolioData(provider_1, network_1, defaultProvider_1, addresses_1)
|
|
|
623
611
|
};
|
|
624
612
|
});
|
|
625
613
|
}
|
|
614
|
+
function getShifterPortfolioData(provider_1, network_1, defaultProvider_1, addresses_1) {
|
|
615
|
+
return __awaiter(this, arguments, void 0, function* (provider, network, defaultProvider, addresses, isSim = false) {
|
|
616
|
+
const isMainnet = network === common_1.NetworkNumber.Eth;
|
|
617
|
+
const isFluidSupported = [common_1.NetworkNumber.Eth, common_1.NetworkNumber.Arb, common_1.NetworkNumber.Base, common_1.NetworkNumber.Plasma].includes(network);
|
|
618
|
+
const morphoMarkets = Object.values((0, markets_1.MorphoBlueMarkets)(network)).filter((market) => market.chainIds.includes(network));
|
|
619
|
+
const morphoMidnightMarkets = Object.values((0, markets_1.MorphoMidnightMarkets)(network)).filter((market) => market.chainIds.includes(network));
|
|
620
|
+
const compoundV3Markets = Object.values((0, markets_1.CompoundMarkets)(network)).filter((market) => market.chainIds.includes(network) && market.value !== types_1.CompoundVersions.CompoundV2);
|
|
621
|
+
const sparkMarkets = Object.values((0, markets_1.SparkMarkets)(network)).filter((market) => market.chainIds.includes(network));
|
|
622
|
+
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));
|
|
623
|
+
const aaveV2Markets = [types_1.AaveVersions.AaveV2].map((version) => (0, markets_1.AaveMarkets)(network)[version]).filter((market) => market.chainIds.includes(network));
|
|
624
|
+
const compoundV2Markets = [types_1.CompoundVersions.CompoundV2].map((version) => (0, markets_1.CompoundMarkets)(network)[version]).filter((market) => market.chainIds.includes(network));
|
|
625
|
+
const crvUsdMarkets = Object.values((0, markets_1.CrvUsdMarkets)(network)).filter((market) => market.chainIds.includes(network));
|
|
626
|
+
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)) : [];
|
|
627
|
+
const liquityV2Markets = [common_1.NetworkNumber.Eth].includes(network) ? Object.values((0, markets_1.LiquityV2Markets)(network)) : [];
|
|
628
|
+
const aaveV4Spokes = Object.values((0, markets_1.AaveV4Spokes)(network)).filter((market) => market.chainIds.includes(network));
|
|
629
|
+
const args = [network, { batch: { multicall: { batchSize: isSim ? 2000 : 2500000 } } }];
|
|
630
|
+
const client = (0, viem_1.getViemProvider)(provider, ...args);
|
|
631
|
+
const defaultClient = (0, viem_1.getViemProvider)(defaultProvider, ...args);
|
|
632
|
+
const markets = {
|
|
633
|
+
morphoMarketsData: {},
|
|
634
|
+
morphoMidnightMarketsData: {},
|
|
635
|
+
compoundV3MarketsData: {},
|
|
636
|
+
sparkMarketsData: {},
|
|
637
|
+
aaveV3MarketsData: {},
|
|
638
|
+
aaveV2MarketsData: {},
|
|
639
|
+
compoundV2MarketsData: {},
|
|
640
|
+
crvUsdMarketsData: {},
|
|
641
|
+
llamaLendMarketsData: {},
|
|
642
|
+
liquityV2MarketsData: {},
|
|
643
|
+
aaveV4SpokesData: {},
|
|
644
|
+
fluidMarketsData: {},
|
|
645
|
+
makerMarketsData: {},
|
|
646
|
+
};
|
|
647
|
+
const makerCdps = {};
|
|
648
|
+
const positions = {};
|
|
649
|
+
for (const address of addresses) {
|
|
650
|
+
positions[address.toLowerCase()] = {
|
|
651
|
+
aaveV3: {},
|
|
652
|
+
aaveV4: {},
|
|
653
|
+
morphoBlue: {},
|
|
654
|
+
morphoMidnight: {},
|
|
655
|
+
compoundV3: {},
|
|
656
|
+
spark: {},
|
|
657
|
+
maker: {},
|
|
658
|
+
aaveV2: {},
|
|
659
|
+
compoundV2: {},
|
|
660
|
+
liquity: {},
|
|
661
|
+
crvUsd: {},
|
|
662
|
+
llamaLend: {},
|
|
663
|
+
fluid: {
|
|
664
|
+
error: '',
|
|
665
|
+
data: {},
|
|
666
|
+
},
|
|
667
|
+
};
|
|
668
|
+
}
|
|
669
|
+
yield Promise.allSettled([
|
|
670
|
+
// === MARKET DATA (needs to be fetched first) ===
|
|
671
|
+
...morphoMarkets.map((market) => __awaiter(this, void 0, void 0, function* () {
|
|
672
|
+
markets.morphoMarketsData[market.value] = yield (0, morphoBlue_1._getMorphoBluePortfolioMarketData)(client, network, market);
|
|
673
|
+
})),
|
|
674
|
+
...morphoMidnightMarkets.map((market) => __awaiter(this, void 0, void 0, function* () {
|
|
675
|
+
markets.morphoMidnightMarketsData[market.value] = yield (0, morphoMidnight_1._getMorphoMidnightMarketData)(client, network, market);
|
|
676
|
+
})),
|
|
677
|
+
...compoundV3Markets.map((market) => __awaiter(this, void 0, void 0, function* () {
|
|
678
|
+
markets.compoundV3MarketsData[market.value] = yield (0, compoundV3_1._getCompoundV3MarketsData)(client, network, market, defaultClient);
|
|
679
|
+
})),
|
|
680
|
+
...sparkMarkets.map((market) => __awaiter(this, void 0, void 0, function* () {
|
|
681
|
+
markets.sparkMarketsData[market.value] = yield (0, spark_1._getSparkMarketsData)(client, network, market);
|
|
682
|
+
})),
|
|
683
|
+
...aaveV3Markets.map((market) => __awaiter(this, void 0, void 0, function* () {
|
|
684
|
+
markets.aaveV3MarketsData[market.value] = yield (0, aaveV3_1._getAaveV3MarketData)(client, network, market);
|
|
685
|
+
})),
|
|
686
|
+
...aaveV4Spokes.map((spoke) => __awaiter(this, void 0, void 0, function* () {
|
|
687
|
+
markets.aaveV4SpokesData[spoke.value] = yield (0, aaveV4_1._getAaveV4SpokeData)(client, network, spoke);
|
|
688
|
+
})),
|
|
689
|
+
...aaveV2Markets.map((market) => __awaiter(this, void 0, void 0, function* () {
|
|
690
|
+
markets.aaveV2MarketsData[market.value] = yield (0, aaveV2_1._getAaveV2MarketsData)(client, network, market);
|
|
691
|
+
})),
|
|
692
|
+
...compoundV2Markets.map((market) => __awaiter(this, void 0, void 0, function* () {
|
|
693
|
+
markets.compoundV2MarketsData[market.value] = yield (0, compoundV2_1._getCompoundV2MarketsData)(client, network);
|
|
694
|
+
})),
|
|
695
|
+
...crvUsdMarkets.map((market) => __awaiter(this, void 0, void 0, function* () {
|
|
696
|
+
markets.crvUsdMarketsData[market.value] = yield (0, curveUsd_1._getCurveUsdGlobalData)(client, network, market);
|
|
697
|
+
})),
|
|
698
|
+
...llamaLendMarkets.map((market) => __awaiter(this, void 0, void 0, function* () {
|
|
699
|
+
markets.llamaLendMarketsData[market.value] = yield (0, llamaLend_1._getLlamaLendGlobalData)(client, network, market);
|
|
700
|
+
})),
|
|
701
|
+
...liquityV2Markets.map((market) => __awaiter(this, void 0, void 0, function* () {
|
|
702
|
+
markets.liquityV2MarketsData[market.value] = yield (0, liquityV2_1._getLiquityV2MarketData)(client, network, market);
|
|
703
|
+
})),
|
|
704
|
+
(() => __awaiter(this, void 0, void 0, function* () {
|
|
705
|
+
if (!isFluidSupported)
|
|
706
|
+
return;
|
|
707
|
+
try {
|
|
708
|
+
markets.fluidMarketsData = yield (0, fluid_1._getAllFluidMarketDataPortfolio)(client, network);
|
|
709
|
+
}
|
|
710
|
+
catch (error) {
|
|
711
|
+
console.error('Error fetching Fluid markets data:', error);
|
|
712
|
+
}
|
|
713
|
+
}))(),
|
|
714
|
+
(() => __awaiter(this, void 0, void 0, function* () {
|
|
715
|
+
if (!isMainnet)
|
|
716
|
+
return; // Maker CDPs are only available on mainnet
|
|
717
|
+
try {
|
|
718
|
+
markets.makerMarketsData = yield (0, maker_1._getMakerIlksData)(client, network, markets_1.MakerActiveIlks);
|
|
719
|
+
}
|
|
720
|
+
catch (error) {
|
|
721
|
+
console.error('Error fetching Maker ilks data:', error);
|
|
722
|
+
}
|
|
723
|
+
}))(),
|
|
724
|
+
// === INDEPENDENT USER DATA (doesn't depend on market data) ===
|
|
725
|
+
...addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
|
|
726
|
+
if (!isMainnet)
|
|
727
|
+
return; // Maker CDPs are only available on mainnet
|
|
728
|
+
const makerCdp = yield (0, maker_1._getUserCdps)(client, network, address);
|
|
729
|
+
makerCdps[address.toLowerCase()] = makerCdp;
|
|
730
|
+
})),
|
|
731
|
+
...addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
|
|
732
|
+
try {
|
|
733
|
+
if (!isFluidSupported)
|
|
734
|
+
return; // Fluid is not available on Optimism
|
|
735
|
+
const userPositions = (yield (0, fluid_1._getUserPositionsPortfolio)(client, network, address));
|
|
736
|
+
for (const position of userPositions) {
|
|
737
|
+
if (position.userData && new decimal_js_1.default(position.userData.suppliedUsd).gt(0)) {
|
|
738
|
+
positions[address.toLowerCase()].fluid.data[position.userData.nftId] = position.userData;
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
catch (error) {
|
|
743
|
+
console.error(`Error fetching Fluid positions for address ${address}:`, error);
|
|
744
|
+
positions[address.toLowerCase()].fluid = {
|
|
745
|
+
error: `Error fetching Fluid positions for address ${address}`,
|
|
746
|
+
data: {},
|
|
747
|
+
};
|
|
748
|
+
}
|
|
749
|
+
})),
|
|
750
|
+
]);
|
|
751
|
+
yield Promise.all([
|
|
752
|
+
...aaveV3Markets.map((market) => addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
|
|
753
|
+
try {
|
|
754
|
+
const accData = yield (0, aaveV3_1._getAaveV3AccountData)(client, network, address, Object.assign({ selectedMarket: market }, markets.aaveV3MarketsData[market.value]));
|
|
755
|
+
if (new decimal_js_1.default(accData.suppliedUsd).gt(0))
|
|
756
|
+
positions[address.toLowerCase()].aaveV3[market.value] = { error: '', data: accData };
|
|
757
|
+
}
|
|
758
|
+
catch (error) {
|
|
759
|
+
console.error(`Error fetching AaveV3 account data for address ${address} on market ${market.value}:`, error);
|
|
760
|
+
positions[address.toLowerCase()].aaveV3[market.value] = { error: `Error fetching AaveV3 account data for address ${address} on market ${market.value}`, data: null };
|
|
761
|
+
}
|
|
762
|
+
}))).flat(),
|
|
763
|
+
...aaveV4Spokes.map((spoke) => addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
|
|
764
|
+
try {
|
|
765
|
+
const accData = yield (0, aaveV4_1._getAaveV4AccountData)(client, network, markets.aaveV4SpokesData[spoke.value], address);
|
|
766
|
+
if (new decimal_js_1.default(accData.suppliedUsd).gt(0))
|
|
767
|
+
positions[address.toLowerCase()].aaveV4[spoke.value] = { error: '', data: accData };
|
|
768
|
+
}
|
|
769
|
+
catch (error) {
|
|
770
|
+
console.error(`Error fetching AaveV4 account data for address ${address} on spoke ${spoke.value}:`, error);
|
|
771
|
+
positions[address.toLowerCase()].aaveV4[spoke.value] = { error: `Error fetching AaveV4 account data for address ${address} on spoke ${spoke.value}`, data: null };
|
|
772
|
+
}
|
|
773
|
+
}))).flat(),
|
|
774
|
+
...morphoMarkets.map((market) => addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
|
|
775
|
+
try {
|
|
776
|
+
const accData = yield (0, morphoBlue_1._getMorphoBlueAccountData)(client, network, address, market, markets.morphoMarketsData[market.value]);
|
|
777
|
+
if (new decimal_js_1.default(accData.suppliedUsd).gt(0))
|
|
778
|
+
positions[address.toLowerCase()].morphoBlue[market.value] = { error: '', data: accData };
|
|
779
|
+
}
|
|
780
|
+
catch (error) {
|
|
781
|
+
console.error(`Error fetching MorphoBlue account data for address ${address} on market ${market.value}:`, error);
|
|
782
|
+
positions[address.toLowerCase()].morphoBlue[market.value] = { error: `Error fetching MorphoBlue account data for address ${address} on market ${market.value}`, data: null };
|
|
783
|
+
}
|
|
784
|
+
}))).flat(),
|
|
785
|
+
...morphoMidnightMarkets.map((market) => addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
|
|
786
|
+
try {
|
|
787
|
+
const accData = yield (0, morphoMidnight_1._getMorphoMidnightAccountData)(client, network, address, market, markets.morphoMidnightMarketsData[market.value]);
|
|
788
|
+
if (new decimal_js_1.default(accData.suppliedUsd).gt(0))
|
|
789
|
+
positions[address.toLowerCase()].morphoMidnight[market.value] = { error: '', data: accData };
|
|
790
|
+
}
|
|
791
|
+
catch (error) {
|
|
792
|
+
console.error(`Error fetching MorphoMidnight account data for address ${address} on market ${market.value}:`, error);
|
|
793
|
+
positions[address.toLowerCase()].morphoMidnight[market.value] = { error: `Error fetching MorphoMidnight account data for address ${address} on market ${market.value}`, data: null };
|
|
794
|
+
}
|
|
795
|
+
}))).flat(),
|
|
796
|
+
...compoundV3Markets.map((market) => addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
|
|
797
|
+
try {
|
|
798
|
+
const accData = yield (0, compoundV3_1._getCompoundV3AccountData)(client, network, address, constants_1.ZERO_ADDRESS, { selectedMarket: market, assetsData: markets.compoundV3MarketsData[market.value].assetsData });
|
|
799
|
+
if (new decimal_js_1.default(accData.suppliedUsd).gt(0))
|
|
800
|
+
positions[address.toLowerCase()].compoundV3[market.value] = { error: '', data: accData };
|
|
801
|
+
}
|
|
802
|
+
catch (error) {
|
|
803
|
+
console.error(`Error fetching CompoundV3 account data for address ${address} on market ${market.value}:`, error);
|
|
804
|
+
positions[address.toLowerCase()].compoundV3[market.value] = { error: `Error fetching CompoundV3 account data for address ${address} on market ${market.value}`, data: null };
|
|
805
|
+
}
|
|
806
|
+
}))).flat(),
|
|
807
|
+
...sparkMarkets.map((market) => addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
|
|
808
|
+
try {
|
|
809
|
+
const accData = yield (0, spark_1._getSparkAccountData)(client, network, address, { selectedMarket: market, assetsData: markets.sparkMarketsData[market.value].assetsData, eModeCategoriesData: markets.sparkMarketsData[market.value].eModeCategoriesData });
|
|
810
|
+
if (new decimal_js_1.default(accData.suppliedUsd).gt(0))
|
|
811
|
+
positions[address.toLowerCase()].spark[market.value] = { error: '', data: accData };
|
|
812
|
+
}
|
|
813
|
+
catch (error) {
|
|
814
|
+
console.error(`Error fetching Spark account data for address ${address} on market ${market.value}:`, error);
|
|
815
|
+
positions[address.toLowerCase()].spark[market.value] = { error: `Error fetching Spark account data for address ${address} on market ${market.value}`, data: null };
|
|
816
|
+
}
|
|
817
|
+
}))).flat(),
|
|
818
|
+
...addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
|
|
819
|
+
var _a;
|
|
820
|
+
return (_a = makerCdps[address.toLowerCase()]) === null || _a === void 0 ? void 0 : _a.map((cdpInfo) => __awaiter(this, void 0, void 0, function* () {
|
|
821
|
+
try {
|
|
822
|
+
// reuse ilk data fetched for the markets payload; ilks outside the active set are fetched on demand
|
|
823
|
+
const cdpData = yield (0, maker_1._getMakerCdpData)(client, network, cdpInfo, markets.makerMarketsData[cdpInfo.ilkLabel]);
|
|
824
|
+
if (cdpData) {
|
|
825
|
+
positions[address.toLowerCase()].maker[cdpInfo.id] = { error: '', data: cdpData };
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
catch (error) {
|
|
829
|
+
console.error(`Error fetching Maker CDP data for address ${address} with ID ${cdpInfo.id}:`, error);
|
|
830
|
+
positions[address.toLowerCase()].maker[cdpInfo.id] = { error: `Error fetching Maker CDP data for address ${address} with ID ${cdpInfo.id}`, data: null };
|
|
831
|
+
}
|
|
832
|
+
}));
|
|
833
|
+
})).flat(),
|
|
834
|
+
...aaveV2Markets.map((market) => addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
|
|
835
|
+
try {
|
|
836
|
+
const accData = yield (0, aaveV2_1._getAaveV2AccountData)(client, network, address, markets.aaveV2MarketsData[market.value].assetsData, market);
|
|
837
|
+
if (new decimal_js_1.default(accData.suppliedUsd).gt(0))
|
|
838
|
+
positions[address.toLowerCase()].aaveV2[market.value] = { error: '', data: accData };
|
|
839
|
+
}
|
|
840
|
+
catch (error) {
|
|
841
|
+
console.error(`Error fetching AaveV2 account data for address ${address}:`, error);
|
|
842
|
+
positions[address.toLowerCase()].aaveV2[market.value] = { error: `Error fetching AaveV2 account data for address ${address}`, data: null };
|
|
843
|
+
}
|
|
844
|
+
}))).flat(),
|
|
845
|
+
...compoundV2Markets.map((market) => addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
|
|
846
|
+
try {
|
|
847
|
+
const accData = yield (0, compoundV2_1._getCompoundV2AccountData)(client, network, address, markets.compoundV2MarketsData[market.value].assetsData);
|
|
848
|
+
if (new decimal_js_1.default(accData.suppliedUsd).gt(0))
|
|
849
|
+
positions[address.toLowerCase()].compoundV2[market.value] = { error: '', data: accData };
|
|
850
|
+
}
|
|
851
|
+
catch (error) {
|
|
852
|
+
console.error(`Error fetching CompoundV2 account data for address ${address}:`, error);
|
|
853
|
+
positions[address.toLowerCase()].compoundV2[market.value] = { error: `Error fetching CompoundV2 account data for address ${address}`, data: null };
|
|
854
|
+
}
|
|
855
|
+
}))).flat(),
|
|
856
|
+
...addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
|
|
857
|
+
try {
|
|
858
|
+
if (!isMainnet)
|
|
859
|
+
return; // Liquity trove info is only available on mainnet
|
|
860
|
+
const troveInfo = yield (0, liquity_1._getLiquityTroveInfo)(client, network, address);
|
|
861
|
+
if (new decimal_js_1.default(troveInfo.collateral).gt(0))
|
|
862
|
+
positions[address.toLowerCase()].liquity = { error: '', data: troveInfo };
|
|
863
|
+
}
|
|
864
|
+
catch (error) {
|
|
865
|
+
console.error(`Error fetching Liquity trove info for address ${address}:`, error);
|
|
866
|
+
positions[address.toLowerCase()].liquity = { error: `Error fetching Liquity trove info for address ${address}`, data: null };
|
|
867
|
+
}
|
|
868
|
+
})),
|
|
869
|
+
...crvUsdMarkets.map((market) => addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
|
|
870
|
+
try {
|
|
871
|
+
const accData = yield (0, curveUsd_1._getCurveUsdUserData)(client, network, address, market, markets.crvUsdMarketsData[market.value].activeBand);
|
|
872
|
+
if (new decimal_js_1.default(accData.suppliedUsd).gt(0) || new decimal_js_1.default(accData.borrowedUsd).gt(0)) {
|
|
873
|
+
positions[address.toLowerCase()].crvUsd[market.value] = { error: '', data: Object.assign(Object.assign({}, accData), { borrowRate: markets.crvUsdMarketsData[market.value].borrowRate }) };
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
catch (error) {
|
|
877
|
+
console.error(`Error fetching Curve USD account data for address ${address} on market ${market.value}:`, error);
|
|
878
|
+
positions[address.toLowerCase()].crvUsd[market.value] = { error: `Error fetching Curve USD account data for address ${address} on market ${market.value}`, data: null };
|
|
879
|
+
}
|
|
880
|
+
}))).flat(),
|
|
881
|
+
...llamaLendMarkets.map((market) => addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
|
|
882
|
+
try {
|
|
883
|
+
const accData = yield (0, llamaLend_1._getLlamaLendUserData)(client, network, address, market, markets.llamaLendMarketsData[market.value]);
|
|
884
|
+
if (new decimal_js_1.default(accData.suppliedUsd).gt(0) || new decimal_js_1.default(accData.borrowedUsd).gt(0)) {
|
|
885
|
+
positions[address.toLowerCase()].llamaLend[market.value] = { error: '', data: Object.assign(Object.assign({}, accData), { borrowRate: markets.llamaLendMarketsData[market.value].borrowRate }) };
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
catch (error) {
|
|
889
|
+
console.error(`Error fetching LlamaLend account data for address ${address} on market ${market.value}:`, error);
|
|
890
|
+
positions[address.toLowerCase()].llamaLend[market.value] = { error: `Error fetching LlamaLend account data for address ${address} on market ${market.value}`, data: null };
|
|
891
|
+
}
|
|
892
|
+
}))).flat(),
|
|
893
|
+
]);
|
|
894
|
+
return {
|
|
895
|
+
positions,
|
|
896
|
+
markets,
|
|
897
|
+
};
|
|
898
|
+
});
|
|
899
|
+
}
|
|
626
900
|
__exportStar(require("./discovery"), exports);
|
package/cjs/types/aave.d.ts
CHANGED
|
@@ -126,6 +126,7 @@ export interface AavePositionData extends MMPositionData {
|
|
|
126
126
|
minRatio: string;
|
|
127
127
|
collRatio: string;
|
|
128
128
|
safetyRatioWithLtvZeroFallback?: string;
|
|
129
|
+
safetyRatio?: string;
|
|
129
130
|
suppliedUsd: string;
|
|
130
131
|
borrowedUsd: string;
|
|
131
132
|
borrowLimitUsd: string;
|
|
@@ -159,6 +160,7 @@ export interface AaveV3AggregatedPositionData {
|
|
|
159
160
|
collRatio: string;
|
|
160
161
|
borrowLimitWithLtvZeroFallbackUsd: string;
|
|
161
162
|
safetyRatioWithLtvZeroFallback: string;
|
|
163
|
+
safetyRatio: string;
|
|
162
164
|
netApy: string;
|
|
163
165
|
incentiveUsd: string;
|
|
164
166
|
totalInterestUsd: string;
|
package/cjs/types/aaveV4.d.ts
CHANGED
package/cjs/types/claiming.d.ts
CHANGED
|
@@ -6,8 +6,6 @@ export declare enum ClaimType {
|
|
|
6
6
|
AAVE_MERIT_REWARDS = "AAVE_MERIT_REWARDS",
|
|
7
7
|
/** Rewards distributed through Merkl across supported protocols */
|
|
8
8
|
MERKL_REWARDS = "MERKL_REWARDS",
|
|
9
|
-
/** Rewards from Compound V3 (only in COMP) */
|
|
10
|
-
COMPOUND_V3_COMP = "COMPOUND_V3_COMP",
|
|
11
9
|
/** Rewards from Spark (wstETH only for now) */
|
|
12
10
|
SPARK_REWARDS = "SPARK_REWARDS",
|
|
13
11
|
/** Rewards from King (prev LTR^2 - received for weETH holding) */
|
|
@@ -68,12 +66,6 @@ export type KingRewardsClaimableToken = _ClaimableTokenPartial & {
|
|
|
68
66
|
merkleProofs: string[];
|
|
69
67
|
};
|
|
70
68
|
};
|
|
71
|
-
export type CompoundV3CompClaimableToken = _ClaimableTokenPartial & {
|
|
72
|
-
claimType: ClaimType.COMPOUND_V3_COMP;
|
|
73
|
-
additionalClaimFields: {
|
|
74
|
-
marketAddress: EthAddress;
|
|
75
|
-
};
|
|
76
|
-
};
|
|
77
69
|
export declare enum SparkAirdropType {
|
|
78
70
|
SPARK_IGNITION = "spark-ignition",
|
|
79
71
|
PRE_FARMING_AND_SOCIAL = "pre-farming-and-social"
|
|
@@ -102,5 +94,5 @@ export type UniswapAirdropClaimableToken = _ClaimableTokenPartial & {
|
|
|
102
94
|
proof: string[];
|
|
103
95
|
};
|
|
104
96
|
};
|
|
105
|
-
export type ClaimableToken = AaveRewardsClaimableToken | AaveMeritRewardsClaimableToken | MerklRewardsClaimableToken |
|
|
97
|
+
export type ClaimableToken = AaveRewardsClaimableToken | AaveMeritRewardsClaimableToken | MerklRewardsClaimableToken | SparkRewardsClaimableToken | KingRewardsClaimableToken | SparkAirdropClaimableToken | SparkWstEthRewardsClaimableToken | EthenaAirdropClaimableToken;
|
|
106
98
|
export {};
|
package/cjs/types/claiming.js
CHANGED
|
@@ -9,8 +9,6 @@ var ClaimType;
|
|
|
9
9
|
ClaimType["AAVE_MERIT_REWARDS"] = "AAVE_MERIT_REWARDS";
|
|
10
10
|
/** Rewards distributed through Merkl across supported protocols */
|
|
11
11
|
ClaimType["MERKL_REWARDS"] = "MERKL_REWARDS";
|
|
12
|
-
/** Rewards from Compound V3 (only in COMP) */
|
|
13
|
-
ClaimType["COMPOUND_V3_COMP"] = "COMPOUND_V3_COMP";
|
|
14
12
|
/** Rewards from Spark (wstETH only for now) */
|
|
15
13
|
ClaimType["SPARK_REWARDS"] = "SPARK_REWARDS";
|
|
16
14
|
/** Rewards from King (prev LTR^2 - received for weETH holding) */
|
package/cjs/types/compound.d.ts
CHANGED
|
@@ -96,6 +96,7 @@ export interface CompoundAggregatedPositionData {
|
|
|
96
96
|
leftToBorrowUsd: string;
|
|
97
97
|
ratio: string;
|
|
98
98
|
collRatio: string;
|
|
99
|
+
safetyRatio: string;
|
|
99
100
|
netApy: string;
|
|
100
101
|
incentiveUsd: string;
|
|
101
102
|
totalInterestUsd: string;
|
|
@@ -115,6 +116,7 @@ export interface CompoundAggregatedPositionData {
|
|
|
115
116
|
export interface CompoundPositionData extends MMPositionData {
|
|
116
117
|
ratio: string;
|
|
117
118
|
minRatio: string;
|
|
119
|
+
safetyRatio?: string;
|
|
118
120
|
suppliedUsd: string;
|
|
119
121
|
borrowedUsd: string;
|
|
120
122
|
borrowLimitUsd: string;
|
package/cjs/types/fluid.d.ts
CHANGED
package/cjs/types/liquity.d.ts
CHANGED
package/cjs/types/liquityV2.d.ts
CHANGED
|
@@ -94,6 +94,7 @@ export interface LiquityV2AggregatedTroveData {
|
|
|
94
94
|
liquidationPrice: string;
|
|
95
95
|
ratio: string;
|
|
96
96
|
collRatio: string;
|
|
97
|
+
safetyRatio: string;
|
|
97
98
|
exposure: string;
|
|
98
99
|
}
|
|
99
100
|
export interface LiquityV2TroveData {
|
|
@@ -101,6 +102,7 @@ export interface LiquityV2TroveData {
|
|
|
101
102
|
troveId: string;
|
|
102
103
|
ratio: string;
|
|
103
104
|
collRatio: string;
|
|
105
|
+
safetyRatio?: string;
|
|
104
106
|
liqRatio: string;
|
|
105
107
|
borrowLimitRatio: string;
|
|
106
108
|
interestRate: string;
|
package/cjs/types/maker.d.ts
CHANGED
|
@@ -185,6 +185,7 @@ export interface MorphoBlueAggregatedPositionData {
|
|
|
185
185
|
totalInterestUsd: string;
|
|
186
186
|
ltv: string;
|
|
187
187
|
ratio: string;
|
|
188
|
+
safetyRatio: string;
|
|
188
189
|
leveragedType: LeverageType;
|
|
189
190
|
leveragedAsset?: string;
|
|
190
191
|
currentVolatilePairRatio?: string;
|
|
@@ -207,6 +208,7 @@ export interface MorphoBluePositionData {
|
|
|
207
208
|
totalInterestUsd: string;
|
|
208
209
|
ltv: string;
|
|
209
210
|
ratio: string;
|
|
211
|
+
safetyRatio?: string;
|
|
210
212
|
leveragedType: LeverageType;
|
|
211
213
|
leveragedAsset?: string;
|
|
212
214
|
currentVolatilePairRatio?: string;
|
package/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/cjs/types/spark.d.ts
CHANGED
|
@@ -85,6 +85,7 @@ export interface SparkAggregatedPositionData {
|
|
|
85
85
|
leftToBorrowUsd: string;
|
|
86
86
|
ratio: string;
|
|
87
87
|
collRatio: string;
|
|
88
|
+
safetyRatio: string;
|
|
88
89
|
netApy: string;
|
|
89
90
|
incentiveUsd: string;
|
|
90
91
|
totalInterestUsd: string;
|
|
@@ -104,6 +105,7 @@ export interface SparkPositionData extends MMPositionData {
|
|
|
104
105
|
ratio: string;
|
|
105
106
|
minRatio: string;
|
|
106
107
|
collRatio: string;
|
|
108
|
+
safetyRatio?: string;
|
|
107
109
|
suppliedUsd: string;
|
|
108
110
|
borrowedUsd: string;
|
|
109
111
|
borrowLimitUsd: string;
|
package/esm/aaveV2/index.js
CHANGED
|
@@ -167,6 +167,8 @@ export const _getAaveV2AccountData = (provider, network, address, assetsData, ma
|
|
|
167
167
|
payload.collRatio = payload.borrowedUsd && payload.borrowedUsd !== '0'
|
|
168
168
|
? new Dec(payload.suppliedCollateralUsd).div(payload.borrowedUsd).mul(100).toString()
|
|
169
169
|
: '0';
|
|
170
|
+
// Aave v2 has no LTV-0 fallback (AaveV3View only), so its safety ratio is the plain ratio.
|
|
171
|
+
payload.safetyRatio = payload.ratio;
|
|
170
172
|
// Calculate borrow limits per asset
|
|
171
173
|
Object.values(payload.usedAssets).forEach((item) => {
|
|
172
174
|
if (item.isBorrowed) {
|
package/esm/claiming/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as aaveV3Claim from './aaveV3';
|
|
2
|
-
import * as compV3Claim from './compV3';
|
|
3
2
|
import * as kingV3Claim from './king';
|
|
4
3
|
import * as sparkClaim from './spark';
|
|
5
4
|
import * as uniswapClaim from './uniswap';
|
|
6
|
-
export { aaveV3Claim,
|
|
5
|
+
export { aaveV3Claim, kingV3Claim, sparkClaim, uniswapClaim, };
|
package/esm/claiming/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as aaveV3Claim from './aaveV3';
|
|
2
|
-
import * as compV3Claim from './compV3';
|
|
3
2
|
import * as kingV3Claim from './king';
|
|
4
3
|
import * as sparkClaim from './spark';
|
|
5
4
|
import * as uniswapClaim from './uniswap';
|
|
6
|
-
export { aaveV3Claim,
|
|
5
|
+
export { aaveV3Claim, kingV3Claim, sparkClaim, uniswapClaim, };
|
package/esm/fluid/index.d.ts
CHANGED
|
@@ -133,6 +133,7 @@ export declare const _getUserPositions: (provider: PublicClient, network: Networ
|
|
|
133
133
|
merklBorrowIncentives: import("../types").IncentiveData[];
|
|
134
134
|
ratio: string;
|
|
135
135
|
collRatio: string;
|
|
136
|
+
safetyRatio: string;
|
|
136
137
|
minRatio: string;
|
|
137
138
|
totalInterestUsd: string;
|
|
138
139
|
leveragedType?: import("../types").LeverageType;
|
|
@@ -167,6 +168,7 @@ export declare const getUserPositions: (provider: EthereumProvider, network: Net
|
|
|
167
168
|
merklBorrowIncentives: import("../types").IncentiveData[];
|
|
168
169
|
ratio: string;
|
|
169
170
|
collRatio: string;
|
|
171
|
+
safetyRatio: string;
|
|
170
172
|
minRatio: string;
|
|
171
173
|
totalInterestUsd: string;
|
|
172
174
|
leveragedType?: import("../types").LeverageType;
|
|
@@ -201,6 +203,7 @@ export declare const _getUserPositionsPortfolio: (provider: PublicClient, networ
|
|
|
201
203
|
merklBorrowIncentives: import("../types").IncentiveData[];
|
|
202
204
|
ratio: string;
|
|
203
205
|
collRatio: string;
|
|
206
|
+
safetyRatio: string;
|
|
204
207
|
minRatio: string;
|
|
205
208
|
totalInterestUsd: string;
|
|
206
209
|
leveragedType?: import("../types").LeverageType;
|
|
@@ -221,3 +224,5 @@ export declare const _getUserPositionsPortfolio: (provider: PublicClient, networ
|
|
|
221
224
|
nftId: string;
|
|
222
225
|
} | undefined;
|
|
223
226
|
}[]>;
|
|
227
|
+
export declare const _getAllFluidMarketDataPortfolio: (provider: PublicClient, network: NetworkNumber) => Promise<Record<string, FluidMarketData>>;
|
|
228
|
+
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); });
|