@defisaver/positions-sdk 2.1.153 → 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/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 -0
- package/cjs/types/aave.d.ts +2 -0
- package/cjs/types/aaveV4.d.ts +1 -0
- 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/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 -3
- package/esm/types/aave.d.ts +2 -0
- package/esm/types/aaveV4.d.ts +1 -0
- 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/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 -2
- package/src/types/aave.ts +3 -0
- package/src/types/aaveV4.ts +1 -0
- 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/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");
|
|
@@ -610,4 +611,290 @@ function getPortfolioData(provider_1, network_1, defaultProvider_1, addresses_1)
|
|
|
610
611
|
};
|
|
611
612
|
});
|
|
612
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
|
+
}
|
|
613
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/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/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); });
|
|
@@ -125,6 +125,9 @@ export const aaveAnyGetAggregatedPositionData = (_a) => {
|
|
|
125
125
|
return new Dec(suppliedUsd).mul(effectiveLtv);
|
|
126
126
|
});
|
|
127
127
|
payload.safetyRatioWithLtvZeroFallback = +payload.suppliedUsd ? new Dec(payload.borrowLimitWithLtvZeroFallbackUsd).div(payload.borrowedUsd).mul(100).toString() : '0';
|
|
128
|
+
// Normalised safety ratio (100 = liquidation on every protocol): the automation ratio above, falling back
|
|
129
|
+
// to the regular ratio when the fallback carries its '0' placeholder.
|
|
130
|
+
payload.safetyRatio = +payload.safetyRatioWithLtvZeroFallback ? payload.safetyRatioWithLtvZeroFallback : payload.ratio;
|
|
128
131
|
payload.liqRatio = new Dec(payload.borrowLimitUsd).div(payload.liquidationLimitUsd).toString();
|
|
129
132
|
payload.liqPercent = new Dec(payload.borrowLimitUsd).div(payload.liquidationLimitUsd).mul(100).toString();
|
|
130
133
|
const { leveragedType, leveragedAsset } = isLeveragedPos(usedAssets);
|
|
@@ -198,6 +198,7 @@ export const aaveV4GetAggregatedPositionData = ({ usedAssets, assetsData, networ
|
|
|
198
198
|
payload.ratio = +payload.suppliedUsd ? new Dec(payload.borrowLimitUsd).div(payload.borrowedUsd).mul(100).toString() : '0';
|
|
199
199
|
payload.minRatio = '100';
|
|
200
200
|
payload.collRatio = +payload.suppliedUsd ? new Dec(payload.suppliedCollateralUsd).div(payload.borrowedUsd).mul(100).toString() : '0';
|
|
201
|
+
payload.safetyRatio = payload.ratio;
|
|
201
202
|
payload.liqRatio = new Dec(payload.borrowLimitUsd).div(payload.liquidationLimitUsd).toString();
|
|
202
203
|
payload.liqPercent = new Dec(payload.borrowLimitUsd).div(payload.liquidationLimitUsd).mul(100).toString();
|
|
203
204
|
const { leveragedType, leveragedAsset } = isLeveragedPosAaveV4(usedAssets);
|
|
@@ -93,6 +93,7 @@ export const getCompoundV2AggregatedData = (_a) => {
|
|
|
93
93
|
payload.collRatio = payload.borrowedUsd && payload.borrowedUsd !== '0'
|
|
94
94
|
? new Dec(payload.suppliedCollateralUsd).div(payload.borrowedUsd).mul(100).toString()
|
|
95
95
|
: '0';
|
|
96
|
+
payload.safetyRatio = payload.ratio;
|
|
96
97
|
// Calculate borrow limits per asset
|
|
97
98
|
Object.values(usedAssets).forEach((item) => {
|
|
98
99
|
if (item.isBorrowed) {
|
|
@@ -134,6 +135,7 @@ export const getCompoundV3AggregatedData = (_a) => {
|
|
|
134
135
|
payload.incentiveUsd = incentiveUsd;
|
|
135
136
|
payload.totalInterestUsd = totalInterestUsd;
|
|
136
137
|
payload.minRatio = '100';
|
|
138
|
+
payload.safetyRatio = payload.ratio;
|
|
137
139
|
payload.liqRatio = new Dec(payload.borrowLimitUsd).div(payload.liquidationLimitUsd).toString();
|
|
138
140
|
payload.liqPercent = new Dec(payload.borrowLimitUsd).div(payload.liquidationLimitUsd).mul(100).toString();
|
|
139
141
|
payload.minDebt = assetsData[selectedMarket.baseAsset].minDebt;
|
|
@@ -28,6 +28,8 @@ export const getCrvUsdAggregatedData = (_a) => {
|
|
|
28
28
|
: '0';
|
|
29
29
|
// this is all approximation
|
|
30
30
|
payload.minAllowedRatio = mapRange(numOfBands, 4, 50, 115, 140); // collateral ratio
|
|
31
|
+
// Collateral ratio rebased so 100 sits on the band-derived minimum (normalised safety ratio, same scale as the other protocols).
|
|
32
|
+
payload.safetyRatio = loanExists && payload.minAllowedRatio ? new Dec(payload.ratio).div(payload.minAllowedRatio).mul(100).toString() : '0';
|
|
31
33
|
payload.collFactor = new Dec(1).div(payload.minAllowedRatio).mul(100).toString(); // collateral factor = 1 / collateral ratio
|
|
32
34
|
// only take in consideration collAsset
|
|
33
35
|
payload.borrowLimitUsd = ((_b = usedAssets === null || usedAssets === void 0 ? void 0 : usedAssets[selectedMarket.collAsset]) === null || _b === void 0 ? void 0 : _b.isSupplied)
|
|
@@ -78,6 +78,7 @@ export const getFluidAggregatedData = ({ usedAssets, assetsData, marketData, },
|
|
|
78
78
|
payload.ratio = +payload.suppliedUsd ? new Dec(payload.borrowLimitUsd).div(payload.borrowedUsd).mul(100).toString() : '0';
|
|
79
79
|
payload.collRatio = +payload.suppliedUsd ? new Dec(payload.suppliedUsd).div(payload.borrowedUsd).mul(100).toString() : '0';
|
|
80
80
|
payload.minRatio = marketData.minRatio;
|
|
81
|
+
payload.safetyRatio = payload.ratio;
|
|
81
82
|
const { leveragedType, leveragedAsset } = isLeveragedPos(usedAssets);
|
|
82
83
|
payload.leveragedType = leveragedType;
|
|
83
84
|
payload.liquidationPrice = '';
|
|
@@ -41,6 +41,7 @@ export const getLiquityV2AggregatedPositionData = ({ usedAssets, assetsData, min
|
|
|
41
41
|
payload.leftToBorrowUsd = leftToBorrowUsd.lte('0') ? '0' : leftToBorrowUsd.toString();
|
|
42
42
|
payload.ratio = (+payload.suppliedUsd && +payload.borrowedUsd) ? new Dec(payload.borrowLimitUsd).div(payload.borrowedUsd).mul(100).toString() : '0';
|
|
43
43
|
payload.collRatio = (+payload.suppliedUsd && +payload.borrowedUsd) ? new Dec(payload.suppliedUsd).div(payload.borrowedUsd).mul(100).toString() : '0';
|
|
44
|
+
payload.safetyRatio = payload.ratio;
|
|
44
45
|
const { netApy, incentiveUsd, totalInterestUsd } = calculateNetApyLiquityV2(usedAssets, assetsData, interestRate);
|
|
45
46
|
payload.netApy = netApy;
|
|
46
47
|
payload.incentiveUsd = incentiveUsd;
|
|
@@ -36,6 +36,8 @@ export const getLlamaLendAggregatedData = (_a) => {
|
|
|
36
36
|
: '0';
|
|
37
37
|
// this is all approximation
|
|
38
38
|
payload.minAllowedRatio = mapRange(numOfBands, 4, 50, 115, 140); // collateral ratio
|
|
39
|
+
// Collateral ratio rebased so 100 sits on the band-derived minimum (normalised safety ratio, same scale as the other protocols).
|
|
40
|
+
payload.safetyRatio = loanExists && payload.minAllowedRatio ? new Dec(payload.ratio).div(payload.minAllowedRatio).mul(100).toString() : '0';
|
|
39
41
|
payload.collFactor = new Dec(1).div(payload.minAllowedRatio).mul(100).toString(); // collateral factor = 1 / collateral ratio
|
|
40
42
|
// only take in consideration collAsset
|
|
41
43
|
payload.borrowLimitUsd = ((_b = usedAssets === null || usedAssets === void 0 ? void 0 : usedAssets[collAsset]) === null || _b === void 0 ? void 0 : _b.isSupplied)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const parseCollateralInfo: (ilk: string, _par: string, _mat: string, _art: string, _rate: string, _spot: string, _line: string, _duty: string, _futureRate: string, _chop: string) => {
|
|
1
|
+
export declare const parseCollateralInfo: (ilk: string, _par: string, _mat: string, _art: string, _rate: string, _spot: string, _line: string, _dust: string, _duty: string, _futureRate: string, _chop: string) => {
|
|
2
2
|
ilkLabel: string;
|
|
3
3
|
currentRate: string;
|
|
4
4
|
futureRate: string;
|