@defisaver/positions-sdk 2.1.151 → 2.1.152-shifter-v2-2-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/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 +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/morphoBlueHelpers/index.js +2 -0
- package/cjs/helpers/morphoMidnightHelpers/index.js +2 -0
- package/cjs/helpers/morphoMidnightHelpers/tenor.d.ts +6 -2
- package/cjs/helpers/morphoMidnightHelpers/tenor.js +5 -1
- 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 +30 -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/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 +58 -4
- package/cjs/types/morphoMidnight.js +45 -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/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 +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/morphoBlueHelpers/index.js +2 -0
- package/esm/helpers/morphoMidnightHelpers/index.js +2 -0
- package/esm/helpers/morphoMidnightHelpers/tenor.d.ts +6 -2
- package/esm/helpers/morphoMidnightHelpers/tenor.js +6 -2
- 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 +29 -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/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 +58 -4
- package/esm/types/morphoMidnight.js +45 -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/compV3.ts +0 -1
- package/src/config/contracts.ts +4 -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/morphoBlueHelpers/index.ts +2 -0
- package/src/helpers/morphoMidnightHelpers/index.ts +2 -0
- package/src/helpers/morphoMidnightHelpers/tenor.ts +6 -2
- package/src/helpers/sparkHelpers/index.ts +1 -0
- package/src/liquity/index.ts +8 -1
- package/src/maker/index.ts +59 -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/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 +60 -3
- package/src/types/portfolio.ts +31 -12
- package/src/types/spark.ts +2 -0
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/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
|
@@ -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)
|
|
@@ -40,6 +40,8 @@ export const getMorphoBlueAggregatedPositionData = ({ usedAssets, assetsData, ma
|
|
|
40
40
|
payload.ltv = new Dec(((_c = usedAssets[loanToken]) === null || _c === void 0 ? void 0 : _c.borrowed) || 0).div(oracle).div(((_d = usedAssets[collateralToken]) === null || _d === void 0 ? void 0 : _d.supplied) || 1).toString(); // default to 1 because can't div 0
|
|
41
41
|
payload.ratio = new Dec(((_e = usedAssets[collateralToken]) === null || _e === void 0 ? void 0 : _e.supplied) || 0).mul(oracle).div(((_f = usedAssets[loanToken]) === null || _f === void 0 ? void 0 : _f.borrowed) || 1).mul(100)
|
|
42
42
|
.toString();
|
|
43
|
+
// Borrow limit over debt, so 100 sits on the market's LLTV however low it is (`ratio` is the raw collateral ratio).
|
|
44
|
+
payload.safetyRatio = +payload.borrowedUsd > 0 ? new Dec(payload.borrowLimitUsd).div(payload.borrowedUsd).mul(100).toString() : '0';
|
|
43
45
|
const { leveragedType, leveragedAsset } = isLeveragedPos(usedAssets);
|
|
44
46
|
payload.leveragedType = leveragedType;
|
|
45
47
|
payload.liquidationPrice = '';
|
|
@@ -58,6 +58,8 @@ export const getMorphoMidnightAggregatedPositionData = ({ usedAssets, assetsData
|
|
|
58
58
|
payload.ltv = new Dec(payload.suppliedCollateralUsd).eq(0) ? '0' : new Dec(payload.borrowedUsd).div(payload.suppliedCollateralUsd).toString();
|
|
59
59
|
payload.ratio = new Dec(payload.borrowedUsd).eq(0) ? '0' : new Dec(payload.suppliedCollateralUsd).div(payload.borrowedUsd).mul(100).toString();
|
|
60
60
|
payload.healthRatio = new Dec(payload.borrowedUsd).eq(0) ? 'Infinity' : new Dec(payload.liquidationLimitUsd).div(payload.borrowedUsd).toDP(4).toString();
|
|
61
|
+
// Borrow limit over debt, so 100 sits on the market's LLTV however low it is (`ratio` is the raw collateral ratio).
|
|
62
|
+
payload.safetyRatio = +payload.borrowedUsd > 0 ? new Dec(payload.borrowLimitUsd).div(payload.borrowedUsd).mul(100).toString() : '0';
|
|
61
63
|
const { leveragedType, leveragedAsset } = isLeveragedPos(usedAssets);
|
|
62
64
|
payload.leveragedType = leveragedType;
|
|
63
65
|
payload.liquidationPrice = '';
|
|
@@ -41,11 +41,15 @@ interface TenorOfferFill {
|
|
|
41
41
|
/**
|
|
42
42
|
* Tenor's offer JSON is flat (market fields live on the offer). Morpho's is nested, and that nested
|
|
43
43
|
* shape is what the app encodes for `Midnight.take`. Map Tenor into that shape so recipes stay on one encoder.
|
|
44
|
+
*
|
|
45
|
+
* The core address is the one field Tenor's offer does not carry, so it is derived from the offer's own
|
|
46
|
+
* `chain_id` rather than the caller's network — an offer names the chain it was made on, and taking it
|
|
47
|
+
* against another chain's core would address a market that does not exist.
|
|
44
48
|
*/
|
|
45
49
|
export declare const tenorOfferToApiOffer: (offer: TenorOffer) => {
|
|
46
50
|
market: {
|
|
47
51
|
chain_id: string | number;
|
|
48
|
-
midnight: "0xAdedD8ab6dE832766Fedf0FaC4992E5C4D3EA18A";
|
|
52
|
+
midnight: "0xAdedD8ab6dE832766Fedf0FaC4992E5C4D3EA18A" | "0x471686c42792F93528B000beF54bC10E3aa2045f";
|
|
49
53
|
loan_token: string;
|
|
50
54
|
collaterals: TenorOfferCollateral[];
|
|
51
55
|
maturity: string | number;
|
|
@@ -73,7 +77,7 @@ export declare const tenorOfferFillToApiFill: (fill: TenorOfferFill) => {
|
|
|
73
77
|
offer: {
|
|
74
78
|
market: {
|
|
75
79
|
chain_id: string | number;
|
|
76
|
-
midnight: "0xAdedD8ab6dE832766Fedf0FaC4992E5C4D3EA18A";
|
|
80
|
+
midnight: "0xAdedD8ab6dE832766Fedf0FaC4992E5C4D3EA18A" | "0x471686c42792F93528B000beF54bC10E3aa2045f";
|
|
77
81
|
loan_token: string;
|
|
78
82
|
collaterals: TenorOfferCollateral[];
|
|
79
83
|
maturity: string | number;
|
|
@@ -11,7 +11,7 @@ import Dec from 'decimal.js';
|
|
|
11
11
|
import { assetAmountInEth, getAssetInfoByAddress } from '@defisaver/tokens';
|
|
12
12
|
import { ZERO_ADDRESS, ZERO_BYTES32 } from '../../constants';
|
|
13
13
|
import { NetworkNumber, } from '../../types';
|
|
14
|
-
import { isTenorMidnightMarket,
|
|
14
|
+
import { isTenorMidnightMarket, midnightCoreAddress } from '../../markets/morphoMidnight';
|
|
15
15
|
import { buildMidnightParsedBook, midnightApyFromPrice, midnightBoundPrice, midnightTimeToMaturityDays, } from './rate';
|
|
16
16
|
// Notion doc by Rajko: https://app.notion.com/p/defisaver/Tenor-API-3ba0be682adc80dfad35c81a9a4cb442
|
|
17
17
|
const TENOR_QUOTES_URL = 'https://router.tenor.finance/v1/quotes';
|
|
@@ -26,11 +26,15 @@ const tenorFillPrice = (assets, units) => (new Dec(units).lte(0) ? '0' : new Dec
|
|
|
26
26
|
/**
|
|
27
27
|
* Tenor's offer JSON is flat (market fields live on the offer). Morpho's is nested, and that nested
|
|
28
28
|
* shape is what the app encodes for `Midnight.take`. Map Tenor into that shape so recipes stay on one encoder.
|
|
29
|
+
*
|
|
30
|
+
* The core address is the one field Tenor's offer does not carry, so it is derived from the offer's own
|
|
31
|
+
* `chain_id` rather than the caller's network — an offer names the chain it was made on, and taking it
|
|
32
|
+
* against another chain's core would address a market that does not exist.
|
|
29
33
|
*/
|
|
30
34
|
export const tenorOfferToApiOffer = (offer) => ({
|
|
31
35
|
market: {
|
|
32
36
|
chain_id: offer.chain_id,
|
|
33
|
-
midnight:
|
|
37
|
+
midnight: midnightCoreAddress(Number(offer.chain_id)),
|
|
34
38
|
loan_token: offer.loan_token_address,
|
|
35
39
|
collaterals: offer.collaterals || [],
|
|
36
40
|
maturity: offer.maturity,
|
|
@@ -70,6 +70,7 @@ export const sparkGetAggregatedPositionData = (_a) => {
|
|
|
70
70
|
payload.leftToBorrowUsd = leftToBorrowUsd.lte('0') ? '0' : leftToBorrowUsd.toString();
|
|
71
71
|
payload.ratio = +payload.suppliedUsd ? new Dec(payload.borrowLimitUsd).div(payload.borrowedUsd).mul(100).toString() : '0';
|
|
72
72
|
payload.collRatio = +payload.suppliedUsd ? new Dec(payload.suppliedCollateralUsd).div(payload.borrowedUsd).mul(100).toString() : '0';
|
|
73
|
+
payload.safetyRatio = payload.ratio;
|
|
73
74
|
const { netApy, incentiveUsd, totalInterestUsd } = calculateNetApy({ usedAssets, assetsData });
|
|
74
75
|
payload.netApy = netApy;
|
|
75
76
|
payload.incentiveUsd = incentiveUsd;
|
package/esm/liquity/index.js
CHANGED
|
@@ -68,6 +68,11 @@ export const _getLiquityTroveInfo = (provider, network, address) => __awaiter(vo
|
|
|
68
68
|
_getDebtInFront(viewContract, address),
|
|
69
69
|
]);
|
|
70
70
|
const recoveryMode = troveInfo[6];
|
|
71
|
+
const minCollateralRatio = recoveryMode ? LIQUITY_RECOVERY_MODE_RATIO : LIQUITY_NORMAL_MODE_RATIO;
|
|
72
|
+
const collateral = assetAmountInEth(troveInfo[1].toString());
|
|
73
|
+
const debtInAsset = assetAmountInEth(troveInfo[2].toString());
|
|
74
|
+
const collRatio = +debtInAsset ? new Dec(collateral).mul(assetAmountInEth(assetPrice.toString())).div(debtInAsset).mul(100)
|
|
75
|
+
.toString() : '0';
|
|
71
76
|
const payload = {
|
|
72
77
|
troveStatus: LIQUITY_TROVE_STATUS_ENUM[+(troveInfo[0].toString())],
|
|
73
78
|
collateral: assetAmountInEth(troveInfo[1].toString()),
|
|
@@ -80,7 +85,9 @@ export const _getLiquityTroveInfo = (provider, network, address) => __awaiter(vo
|
|
|
80
85
|
totalETH: totalETH.toString(),
|
|
81
86
|
totalLUSD: totalLUSD.toString(),
|
|
82
87
|
debtInFront: debtInFront.toString(),
|
|
83
|
-
minCollateralRatio
|
|
88
|
+
minCollateralRatio,
|
|
89
|
+
// Collateral ratio rebased so 100 sits on the trove's minimum collateral ratio (normalised safety ratio).
|
|
90
|
+
safetyRatio: +minCollateralRatio > 0 ? new Dec(collRatio).div(minCollateralRatio).mul(100).toString() : '0',
|
|
84
91
|
priceForRecovery: new Dec(recoveryMode ? LIQUITY_RECOVERY_MODE_RATIO : LIQUITY_NORMAL_MODE_RATIO).mul(totalLUSD).div(totalETH).div(100)
|
|
85
92
|
.toString(),
|
|
86
93
|
exposure: getExposure(assetAmountInEth(troveInfo[2].toString()), new Dec(assetAmountInEth(troveInfo[1].toString())).mul(assetPrice).toString()),
|
package/esm/maker/index.d.ts
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { Client, PublicClient } from 'viem';
|
|
2
2
|
import { Blockish, EthAddress, EthereumProvider, NetworkNumber, PositionBalances } from '../types/common';
|
|
3
|
-
import { CdpData, CdpInfo } from '../types';
|
|
3
|
+
import { CdpData, CdpInfo, IlkInfo } from '../types';
|
|
4
4
|
export declare const _getMakerAccountBalances: (provider: PublicClient, network: NetworkNumber, block: Blockish, addressMapping: boolean, cdpId: string, _managerAddress?: EthAddress) => Promise<PositionBalances>;
|
|
5
5
|
export declare const getMakerAccountBalances: (provider: EthereumProvider, network: NetworkNumber, block: Blockish, addressMapping: boolean, cdpId: string, _managerAddress?: EthAddress) => Promise<PositionBalances>;
|
|
6
6
|
export declare const _getUserCdps: (provider: Client, network: NetworkNumber, userAddress: EthAddress) => Promise<CdpInfo[]>;
|
|
7
7
|
export declare const getUserCdps: (provider: EthereumProvider, network: NetworkNumber, userAddress: EthAddress) => Promise<CdpInfo[]>;
|
|
8
|
-
export declare const
|
|
8
|
+
export declare const _getMakerIlksData: (provider: Client, network: NetworkNumber, ilkLabels: string[]) => Promise<Record<string, IlkInfo>>;
|
|
9
|
+
export declare const getMakerIlksData: (provider: EthereumProvider, network: NetworkNumber, ilkLabels: string[]) => Promise<Record<string, IlkInfo>>;
|
|
10
|
+
/**
|
|
11
|
+
* @param ilkInfo optional precomputed ilk data (from `_getMakerIlksData`); when provided the per-ilk reads are skipped
|
|
12
|
+
*/
|
|
13
|
+
export declare const _getMakerCdpData: (provider: Client, network: NetworkNumber, cdp: CdpInfo, ilkInfo?: IlkInfo) => Promise<CdpData>;
|
|
9
14
|
export declare const getMakerCdpData: (provider: EthereumProvider, network: NetworkNumber, cdp: CdpInfo) => Promise<CdpData>;
|
package/esm/maker/index.js
CHANGED
|
@@ -8,9 +8,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import Dec from 'decimal.js';
|
|
11
|
-
import { assetAmountInEth, bytesToString, getAssetInfo, ilkToAsset, } from '@defisaver/tokens';
|
|
11
|
+
import { assetAmountInEth, bytesToString, getAssetInfo, ilkToAsset, stringToBytes, } from '@defisaver/tokens';
|
|
12
12
|
import { getConfigContractAddress, McdDogContractViem, McdGetCdpsContractViem, McdJugContractViem, McdSpotterContractViem, McdVatContractViem, McdViewContractViem, } from '../contracts';
|
|
13
|
-
import { CdpType } from '../types';
|
|
13
|
+
import { CdpType, } from '../types';
|
|
14
14
|
import { wethToEth } from '../services/utils';
|
|
15
15
|
import { parseCollateralInfo } from '../helpers/makerHelpers';
|
|
16
16
|
import { getViemProvider, setViemBlockNumber } from '../services/viem';
|
|
@@ -80,22 +80,37 @@ export const _getUserCdps = (provider, network, userAddress) => __awaiter(void 0
|
|
|
80
80
|
return parsedStandardCdps;
|
|
81
81
|
});
|
|
82
82
|
export const getUserCdps = (provider, network, userAddress) => __awaiter(void 0, void 0, void 0, function* () { return _getUserCdps(getViemProvider(provider, network), network, userAddress); });
|
|
83
|
-
export const
|
|
83
|
+
export const _getMakerIlksData = (provider, network, ilkLabels) => __awaiter(void 0, void 0, void 0, function* () {
|
|
84
84
|
const vatContract = McdVatContractViem(provider, network);
|
|
85
85
|
const spotterContract = McdSpotterContractViem(provider, network);
|
|
86
86
|
const dogContract = McdDogContractViem(provider, network);
|
|
87
87
|
const jugContract = McdJugContractViem(provider, network);
|
|
88
|
-
const
|
|
88
|
+
const par = yield spotterContract.read.par();
|
|
89
|
+
const ilksInfo = yield Promise.all(ilkLabels.map((ilkLabel) => __awaiter(void 0, void 0, void 0, function* () {
|
|
90
|
+
const ilk = stringToBytes(ilkLabel);
|
|
91
|
+
const [[_, mat], [artGlobal, rate, spot, line], [duty], futureRate, chop,] = yield Promise.all([
|
|
92
|
+
spotterContract.read.ilks([ilk]),
|
|
93
|
+
vatContract.read.ilks([ilk]),
|
|
94
|
+
jugContract.read.ilks([ilk]),
|
|
95
|
+
jugContract.read.drip([ilk]),
|
|
96
|
+
dogContract.read.chop([ilk]),
|
|
97
|
+
]);
|
|
98
|
+
return parseCollateralInfo(ilk, par.toString(), mat.toString(), artGlobal.toString(), rate.toString(), spot.toString(), line.toString(), duty.toString(), futureRate.toString(), chop.toString());
|
|
99
|
+
})));
|
|
100
|
+
return Object.fromEntries(ilksInfo.map((ilkInfo) => [ilkInfo.ilkLabel, ilkInfo]));
|
|
101
|
+
});
|
|
102
|
+
export const getMakerIlksData = (provider, network, ilkLabels) => __awaiter(void 0, void 0, void 0, function* () { return _getMakerIlksData(getViemProvider(provider, network, { batch: { multicall: true } }), network, ilkLabels); });
|
|
103
|
+
/**
|
|
104
|
+
* @param ilkInfo optional precomputed ilk data (from `_getMakerIlksData`); when provided the per-ilk reads are skipped
|
|
105
|
+
*/
|
|
106
|
+
export const _getMakerCdpData = (provider, network, cdp, ilkInfo) => __awaiter(void 0, void 0, void 0, function* () {
|
|
107
|
+
const vatContract = McdVatContractViem(provider, network);
|
|
108
|
+
const [[ink, art], coll, fetchedIlkInfo,] = yield Promise.all([
|
|
89
109
|
vatContract.read.urns([cdp.ilk, cdp.urn]),
|
|
90
110
|
vatContract.read.gem([cdp.ilk, cdp.urn]),
|
|
91
|
-
|
|
92
|
-
spotterContract.read.ilks([cdp.ilk]),
|
|
93
|
-
vatContract.read.ilks([cdp.ilk]),
|
|
94
|
-
jugContract.read.ilks([cdp.ilk]),
|
|
95
|
-
jugContract.read.drip([cdp.ilk]),
|
|
96
|
-
dogContract.read.chop([cdp.ilk]),
|
|
111
|
+
ilkInfo || _getMakerIlksData(provider, network, [cdp.ilkLabel]).then((ilks) => ilks[cdp.ilkLabel]),
|
|
97
112
|
]);
|
|
98
|
-
const collInfo =
|
|
113
|
+
const collInfo = fetchedIlkInfo;
|
|
99
114
|
const collateral = assetAmountInEth(ink.toString(), `MCD-${cdp.asset}`);
|
|
100
115
|
const collateralUsd = new Dec(collateral).mul(collInfo.assetPrice).toString();
|
|
101
116
|
const debt = new Dec(art).times(collInfo.currentRate).div(1e27).floor()
|
|
@@ -107,6 +122,8 @@ export const _getMakerCdpData = (provider, network, cdp) => __awaiter(void 0, vo
|
|
|
107
122
|
.toString();
|
|
108
123
|
if (new Dec(debt).eq(0))
|
|
109
124
|
ratio = '0';
|
|
125
|
+
// Collateral ratio rebased so 100 sits on the ilk's liquidation ratio (normalised safety ratio).
|
|
126
|
+
const safetyRatio = +collInfo.liqPercent > 0 ? new Dec(ratio).div(collInfo.liqPercent).mul(100).toString() : '0';
|
|
110
127
|
const debtTooLow = new Dec(debt).gt(0) && new Dec(assetAmountInEth(debt, 'DAI')).lt(collInfo.minDebt);
|
|
111
128
|
return {
|
|
112
129
|
owner: cdp.owner,
|
|
@@ -126,6 +143,7 @@ export const _getMakerCdpData = (provider, network, cdp) => __awaiter(void 0, vo
|
|
|
126
143
|
debtAssetMarketPrice: '1',
|
|
127
144
|
liquidationPrice,
|
|
128
145
|
ratio,
|
|
146
|
+
safetyRatio,
|
|
129
147
|
liqRatio: collInfo.liqRatio.toString(),
|
|
130
148
|
liqPercent: parseFloat(collInfo.liqPercent.toString()),
|
|
131
149
|
assetPrice: collInfo.assetPrice,
|
package/esm/markets/index.d.ts
CHANGED
|
@@ -3,8 +3,9 @@ export { CompoundMarkets, compoundV2CollateralAssets, v3ETHCollAssets, v3USDbCCo
|
|
|
3
3
|
export { SparkMarkets } from './spark';
|
|
4
4
|
export { CrvUsdMarkets } from './curveUsd';
|
|
5
5
|
export { MorphoBlueMarkets, findMorphoBlueMarket } from './morphoBlue';
|
|
6
|
-
export { MorphoMidnightMarkets, findMorphoMidnightMarket, isTenorMidnightMarket, morphoMidnightMarketCollateralParams, } from './morphoMidnight';
|
|
6
|
+
export { MorphoMidnightMarkets, findMorphoMidnightMarket, isTenorMidnightMarket, morphoMidnightMarketCollateralParams, morphoMidnightVisibleCollaterals, } from './morphoMidnight';
|
|
7
7
|
export { LlamaLendMarkets } from './llamaLend';
|
|
8
8
|
export { LiquityV2Markets, findLiquityV2MarketByAddress } from './liquityV2';
|
|
9
9
|
export { FluidMarkets, getFluidVersionsDataForNetwork, getFluidMarketInfoById, getFTokenAddress, getFluidMarketInfoByAddress, } from './fluid';
|
|
10
10
|
export { AaveV4Spokes, findAaveV4SpokeByAddress } from './aaveV4';
|
|
11
|
+
export { MakerActiveIlks } from './maker';
|
package/esm/markets/index.js
CHANGED
|
@@ -3,8 +3,9 @@ export { CompoundMarkets, compoundV2CollateralAssets, v3ETHCollAssets, v3USDbCCo
|
|
|
3
3
|
export { SparkMarkets } from './spark';
|
|
4
4
|
export { CrvUsdMarkets } from './curveUsd';
|
|
5
5
|
export { MorphoBlueMarkets, findMorphoBlueMarket } from './morphoBlue';
|
|
6
|
-
export { MorphoMidnightMarkets, findMorphoMidnightMarket, isTenorMidnightMarket, morphoMidnightMarketCollateralParams, } from './morphoMidnight';
|
|
6
|
+
export { MorphoMidnightMarkets, findMorphoMidnightMarket, isTenorMidnightMarket, morphoMidnightMarketCollateralParams, morphoMidnightVisibleCollaterals, } from './morphoMidnight';
|
|
7
7
|
export { LlamaLendMarkets } from './llamaLend';
|
|
8
8
|
export { LiquityV2Markets, findLiquityV2MarketByAddress } from './liquityV2';
|
|
9
9
|
export { FluidMarkets, getFluidVersionsDataForNetwork, getFluidMarketInfoById, getFTokenAddress, getFluidMarketInfoByAddress, } from './fluid';
|
|
10
10
|
export { AaveV4Spokes, findAaveV4SpokeByAddress } from './aaveV4';
|
|
11
|
+
export { MakerActiveIlks } from './maker';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const MakerActiveIlks: string[];
|