@defisaver/positions-sdk 2.1.136 → 2.1.137-audit-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/config/contracts.d.ts +0 -938
- package/cjs/config/contracts.js +1 -8
- package/cjs/contracts.d.ts +3823 -27499
- package/cjs/contracts.js +2 -3
- package/cjs/helpers/index.d.ts +0 -1
- package/cjs/helpers/index.js +1 -2
- package/cjs/index.d.ts +1 -2
- package/cjs/index.js +1 -3
- package/cjs/markets/index.d.ts +0 -1
- package/cjs/markets/index.js +1 -3
- package/cjs/markets/morphoBlue/index.d.ts +4 -0
- package/cjs/markets/morphoBlue/index.js +36 -2
- package/cjs/portfolio/discovery.d.ts +1 -1
- package/cjs/portfolio/discovery.js +1 -1
- package/cjs/portfolio/index.js +0 -32
- package/cjs/savings/morphoVaults/index.js +19 -2
- package/cjs/services/viem.d.ts +918 -2679
- package/cjs/staking/staking.js +1 -2
- package/cjs/types/index.d.ts +0 -1
- package/cjs/types/index.js +0 -1
- package/cjs/types/morphoBlue.d.ts +2 -0
- package/cjs/types/morphoBlue.js +2 -0
- package/cjs/types/portfolio.d.ts +0 -4
- package/esm/config/contracts.d.ts +0 -938
- package/esm/config/contracts.js +0 -6
- package/esm/contracts.d.ts +3823 -27499
- package/esm/contracts.js +0 -1
- package/esm/helpers/index.d.ts +0 -1
- package/esm/helpers/index.js +0 -1
- package/esm/index.d.ts +1 -2
- package/esm/index.js +1 -2
- package/esm/markets/index.d.ts +0 -1
- package/esm/markets/index.js +0 -1
- package/esm/markets/morphoBlue/index.d.ts +4 -0
- package/esm/markets/morphoBlue/index.js +32 -0
- package/esm/portfolio/discovery.d.ts +1 -1
- package/esm/portfolio/discovery.js +1 -1
- package/esm/portfolio/index.js +1 -33
- package/esm/savings/morphoVaults/index.js +19 -2
- package/esm/services/viem.d.ts +916 -2667
- package/esm/staking/staking.js +1 -2
- package/esm/types/index.d.ts +0 -1
- package/esm/types/index.js +0 -1
- package/esm/types/morphoBlue.d.ts +2 -0
- package/esm/types/morphoBlue.js +2 -0
- package/esm/types/portfolio.d.ts +0 -4
- package/package.json +9 -2
- package/src/config/contracts.ts +0 -6
- package/src/contracts.ts +2 -3
- package/src/helpers/index.ts +0 -1
- package/src/index.ts +0 -2
- package/src/markets/index.ts +0 -1
- package/src/markets/morphoBlue/index.ts +32 -0
- package/src/portfolio/discovery.ts +1 -1
- package/src/portfolio/index.ts +0 -33
- package/src/savings/morphoVaults/index.ts +18 -2
- package/src/staking/staking.ts +1 -2
- package/src/types/index.ts +0 -1
- package/src/types/morphoBlue.ts +2 -0
- package/src/types/portfolio.ts +0 -4
- package/cjs/eulerV2/index.d.ts +0 -47
- package/cjs/eulerV2/index.js +0 -225
- package/cjs/helpers/eulerHelpers/index.d.ts +0 -22
- package/cjs/helpers/eulerHelpers/index.js +0 -231
- package/cjs/markets/euler/index.d.ts +0 -8
- package/cjs/markets/euler/index.js +0 -30
- package/cjs/types/euler.d.ts +0 -153
- package/cjs/types/euler.js +0 -14
- package/esm/eulerV2/index.d.ts +0 -47
- package/esm/eulerV2/index.js +0 -215
- package/esm/helpers/eulerHelpers/index.d.ts +0 -22
- package/esm/helpers/eulerHelpers/index.js +0 -218
- package/esm/markets/euler/index.d.ts +0 -8
- package/esm/markets/euler/index.js +0 -24
- package/esm/types/euler.d.ts +0 -153
- package/esm/types/euler.js +0 -11
- package/src/eulerV2/index.ts +0 -331
- package/src/helpers/eulerHelpers/index.ts +0 -232
- package/src/markets/euler/index.ts +0 -27
- package/src/types/euler.ts +0 -178
|
@@ -1,232 +0,0 @@
|
|
|
1
|
-
import Dec from 'decimal.js';
|
|
2
|
-
import { assetAmountInWei } from '@defisaver/tokens';
|
|
3
|
-
import {
|
|
4
|
-
EthAddress, EthereumProvider, LeverageType, MMAssetsData, NetworkNumber,
|
|
5
|
-
} from '../../types/common';
|
|
6
|
-
import {
|
|
7
|
-
calcLeverageLiqPrice, getAssetsTotal, getExposure, STABLE_ASSETS,
|
|
8
|
-
} from '../../moneymarket';
|
|
9
|
-
import { calculateNetApy } from '../../staking';
|
|
10
|
-
import {
|
|
11
|
-
EulerV2AggregatedPositionData,
|
|
12
|
-
EulerV2AssetsData,
|
|
13
|
-
EulerV2UsedAsset,
|
|
14
|
-
EulerV2UsedAssets,
|
|
15
|
-
} from '../../types';
|
|
16
|
-
import { EulerV2ViewContractViem } from '../../contracts';
|
|
17
|
-
import { borrowOperations } from '../../constants';
|
|
18
|
-
import { getViemProvider } from '../../services/viem';
|
|
19
|
-
|
|
20
|
-
export const isLeveragedPos = (usedAssets: EulerV2UsedAssets, dustLimit = 5) => {
|
|
21
|
-
let borrowUnstable = 0;
|
|
22
|
-
let supplyStable = 0;
|
|
23
|
-
let borrowStable = 0;
|
|
24
|
-
let supplyUnstable = 0;
|
|
25
|
-
let longAsset = '';
|
|
26
|
-
let shortAsset = '';
|
|
27
|
-
let leverageAssetVault = '';
|
|
28
|
-
Object.values(usedAssets).forEach(({
|
|
29
|
-
symbol, suppliedUsd, borrowedUsd, collateral, vaultAddress,
|
|
30
|
-
}) => {
|
|
31
|
-
const isSupplied = (+suppliedUsd) > dustLimit; // ignore dust like <limit leftover supply
|
|
32
|
-
const isBorrowed = (+borrowedUsd) > dustLimit; // ignore dust like <limit leftover supply
|
|
33
|
-
if (isSupplied && STABLE_ASSETS.includes(symbol) && collateral) supplyStable += 1;
|
|
34
|
-
if (isBorrowed && STABLE_ASSETS.includes(symbol)) borrowStable += 1;
|
|
35
|
-
if (isBorrowed && !STABLE_ASSETS.includes(symbol)) {
|
|
36
|
-
borrowUnstable += 1;
|
|
37
|
-
shortAsset = symbol;
|
|
38
|
-
leverageAssetVault = vaultAddress;
|
|
39
|
-
}
|
|
40
|
-
if (isSupplied && !STABLE_ASSETS.includes(symbol) && collateral) {
|
|
41
|
-
supplyUnstable += 1;
|
|
42
|
-
longAsset = symbol;
|
|
43
|
-
leverageAssetVault = vaultAddress;
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
const isLong = borrowStable > 0 && borrowUnstable === 0 && supplyUnstable === 1 && supplyStable === 0;
|
|
47
|
-
const isShort = supplyStable > 0 && supplyUnstable === 0 && borrowUnstable === 1 && borrowStable === 0;
|
|
48
|
-
const isVolatilePair = supplyUnstable === 1 && borrowUnstable === 1 && supplyStable === 0 && borrowStable === 0;
|
|
49
|
-
if (isLong) {
|
|
50
|
-
return {
|
|
51
|
-
leveragedType: LeverageType.Long,
|
|
52
|
-
leveragedAsset: longAsset,
|
|
53
|
-
leveragedVault: leverageAssetVault,
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
if (isShort) {
|
|
57
|
-
return {
|
|
58
|
-
leveragedType: LeverageType.Short,
|
|
59
|
-
leveragedAsset: shortAsset,
|
|
60
|
-
leveragedVault: leverageAssetVault,
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
if (isVolatilePair) {
|
|
64
|
-
return {
|
|
65
|
-
leveragedType: LeverageType.VolatilePair,
|
|
66
|
-
leveragedAsset: longAsset,
|
|
67
|
-
leveragedVault: leverageAssetVault,
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
return {
|
|
71
|
-
leveragedType: LeverageType.None,
|
|
72
|
-
leveragedAsset: '',
|
|
73
|
-
leveragedVault: '',
|
|
74
|
-
};
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
export const getEulerV2AggregatedData = ({
|
|
78
|
-
usedAssets, assetsData, network, ...rest
|
|
79
|
-
}: { usedAssets: EulerV2UsedAssets, assetsData: EulerV2AssetsData, network: NetworkNumber }) => {
|
|
80
|
-
const payload = {} as EulerV2AggregatedPositionData;
|
|
81
|
-
payload.suppliedUsd = getAssetsTotal(usedAssets, ({ isSupplied }: { isSupplied: boolean }) => isSupplied, ({ suppliedUsd }: { suppliedUsd: string }) => suppliedUsd);
|
|
82
|
-
payload.suppliedCollateralUsd = getAssetsTotal(usedAssets, ({ isSupplied, collateral }: { isSupplied: boolean, collateral: boolean }) => isSupplied && collateral, ({ suppliedUsd }: { suppliedUsd: string }) => suppliedUsd);
|
|
83
|
-
payload.borrowedUsd = getAssetsTotal(usedAssets, ({ isBorrowed }: { isBorrowed: boolean }) => isBorrowed, ({ borrowedUsd }: { borrowedUsd: string }) => borrowedUsd);
|
|
84
|
-
payload.borrowLimitUsd = getAssetsTotal(usedAssets, ({ isSupplied, collateral }: { isSupplied: boolean, collateral: boolean }) => isSupplied && collateral, ({ vaultAddress, suppliedUsd }: { vaultAddress: string, suppliedUsd: string }) => new Dec(suppliedUsd).mul(assetsData[vaultAddress.toLowerCase()].collateralFactor));
|
|
85
|
-
payload.liquidationLimitUsd = getAssetsTotal(usedAssets, ({ isSupplied, collateral }: { isSupplied: boolean, collateral: boolean }) => isSupplied && collateral, ({ vaultAddress, suppliedUsd }: { vaultAddress: string, suppliedUsd: string }) => new Dec(suppliedUsd).mul(assetsData[vaultAddress.toLowerCase()].liquidationRatio));
|
|
86
|
-
const leftToBorrowUsd = new Dec(payload.borrowLimitUsd).sub(payload.borrowedUsd);
|
|
87
|
-
payload.leftToBorrowUsd = leftToBorrowUsd.lte('0') ? '0' : leftToBorrowUsd.toString();
|
|
88
|
-
payload.ratio = +payload.suppliedUsd ? new Dec(payload.borrowLimitUsd).div(payload.borrowedUsd).mul(100).toString() : '0';
|
|
89
|
-
payload.collRatio = +payload.suppliedUsd ? new Dec(payload.suppliedCollateralUsd).div(payload.borrowedUsd).mul(100).toString() : '0';
|
|
90
|
-
const { netApy, incentiveUsd, totalInterestUsd } = calculateNetApy({ usedAssets, assetsData: assetsData as unknown as MMAssetsData });
|
|
91
|
-
payload.netApy = netApy;
|
|
92
|
-
payload.incentiveUsd = incentiveUsd;
|
|
93
|
-
payload.totalInterestUsd = totalInterestUsd;
|
|
94
|
-
payload.minRatio = '100';
|
|
95
|
-
payload.liqRatio = new Dec(payload.borrowLimitUsd).div(payload.liquidationLimitUsd).toString();
|
|
96
|
-
payload.liqPercent = new Dec(payload.borrowLimitUsd).div(payload.liquidationLimitUsd).mul(100).toString();
|
|
97
|
-
const { leveragedType, leveragedAsset, leveragedVault } = isLeveragedPos(usedAssets);
|
|
98
|
-
payload.leveragedType = leveragedType;
|
|
99
|
-
payload.liquidationPrice = '';
|
|
100
|
-
if (leveragedType !== '') {
|
|
101
|
-
payload.leveragedAsset = leveragedAsset;
|
|
102
|
-
let assetPrice = assetsData[leveragedVault.toLowerCase()].price;
|
|
103
|
-
if (leveragedType === LeverageType.VolatilePair) {
|
|
104
|
-
const borrowedAsset = (Object.values(usedAssets) as EulerV2UsedAsset[]).find(({ borrowedUsd }: { borrowedUsd: string }) => +borrowedUsd > 0);
|
|
105
|
-
const borrowedAssetPrice = assetsData[borrowedAsset!.vaultAddress.toLowerCase()].price;
|
|
106
|
-
const leveragedAssetPrice = assetsData[leveragedVault.toLowerCase()].price;
|
|
107
|
-
const isReverse = new Dec(leveragedAssetPrice).lt(borrowedAssetPrice);
|
|
108
|
-
if (isReverse) {
|
|
109
|
-
payload.leveragedType = LeverageType.VolatilePairReverse;
|
|
110
|
-
payload.currentVolatilePairRatio = new Dec(borrowedAssetPrice).div(leveragedAssetPrice).toDP(18).toString();
|
|
111
|
-
assetPrice = new Dec(borrowedAssetPrice).div(assetPrice).toString();
|
|
112
|
-
} else {
|
|
113
|
-
assetPrice = new Dec(assetPrice).div(borrowedAssetPrice).toString();
|
|
114
|
-
payload.currentVolatilePairRatio = new Dec(leveragedAssetPrice).div(borrowedAssetPrice).toDP(18).toString();
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
payload.liquidationPrice = calcLeverageLiqPrice(payload.leveragedType, assetPrice, payload.borrowedUsd, payload.liquidationLimitUsd);
|
|
118
|
-
}
|
|
119
|
-
payload.minCollRatio = new Dec(payload.suppliedCollateralUsd).div(payload.borrowLimitUsd).mul(100).toString();
|
|
120
|
-
payload.collLiquidationRatio = new Dec(payload.suppliedCollateralUsd).div(payload.liquidationLimitUsd).mul(100).toString();
|
|
121
|
-
payload.exposure = getExposure(payload.borrowedUsd, payload.suppliedUsd);
|
|
122
|
-
return payload;
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
export const getEulerV2BorrowRate = (interestRate: string) => {
|
|
126
|
-
const _interestRate = new Dec(interestRate).div(1e27).toString();
|
|
127
|
-
const secondsPerYear = 31556953;
|
|
128
|
-
const a = new Dec(1).plus(_interestRate).pow(secondsPerYear - 1).toString();
|
|
129
|
-
return new Dec(new Dec(a).minus(1)).mul(100).toString();
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
export const getUtilizationRate = (totalBorrows: string, totalAssets: string) => new Dec(totalBorrows).div(totalAssets).toString();
|
|
133
|
-
|
|
134
|
-
export const getEulerV2SupplyRate = (borrowRate: string, utilizationRate: string, _interestFee: string) => {
|
|
135
|
-
const interestFee = new Dec(_interestFee).div(10000);
|
|
136
|
-
const fee = new Dec(1).minus(interestFee);
|
|
137
|
-
return new Dec(borrowRate).mul(utilizationRate).mul(fee).toString();
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
const getLiquidityChanges = (action: string, amount: string, isBorrowOperation: boolean) => {
|
|
141
|
-
let liquidityAdded;
|
|
142
|
-
let liquidityRemoved;
|
|
143
|
-
if (isBorrowOperation) {
|
|
144
|
-
liquidityAdded = action === 'payback' ? amount : '0';
|
|
145
|
-
liquidityRemoved = action === 'borrow' ? amount : '0';
|
|
146
|
-
} else {
|
|
147
|
-
liquidityAdded = action === 'collateral' ? amount : '0';
|
|
148
|
-
liquidityRemoved = action === 'withdraw' ? amount : '0';
|
|
149
|
-
}
|
|
150
|
-
return { liquidityAdded, liquidityRemoved };
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
export const getApyAfterValuesEstimationEulerV2 = async (actions: { action: string, amount: string, asset: string, vaultAddress: EthAddress }[], provider: EthereumProvider, network: NetworkNumber) => {
|
|
154
|
-
const client = getViemProvider(provider, network, { batch: { multicall: true } });
|
|
155
|
-
const eulerV2ViewContract = EulerV2ViewContractViem(client, network);
|
|
156
|
-
const apyAfterValuesEstimationParams: {
|
|
157
|
-
vault: EthAddress;
|
|
158
|
-
isBorrowOperation: boolean;
|
|
159
|
-
liquidityAdded: BigInt;
|
|
160
|
-
liquidityRemoved: BigInt;
|
|
161
|
-
}[] = [];
|
|
162
|
-
actions.forEach(({
|
|
163
|
-
action, amount, asset, vaultAddress,
|
|
164
|
-
}) => {
|
|
165
|
-
const amountInWei = assetAmountInWei(amount, asset);
|
|
166
|
-
const isBorrowOperation = borrowOperations.includes(action);
|
|
167
|
-
const { liquidityAdded, liquidityRemoved } = getLiquidityChanges(action, amountInWei, isBorrowOperation);
|
|
168
|
-
apyAfterValuesEstimationParams.push({
|
|
169
|
-
vault: vaultAddress,
|
|
170
|
-
isBorrowOperation: borrowOperations.includes(action),
|
|
171
|
-
liquidityAdded: BigInt(liquidityAdded),
|
|
172
|
-
liquidityRemoved: BigInt(liquidityRemoved),
|
|
173
|
-
});
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
const res = await Promise.all([
|
|
177
|
-
...actions.map(({ vaultAddress }) => eulerV2ViewContract.read.getVaultInfoFull([vaultAddress])) as any,
|
|
178
|
-
// @ts-ignore
|
|
179
|
-
eulerV2ViewContract.read.getApyAfterValuesEstimation([apyAfterValuesEstimationParams]),
|
|
180
|
-
]);
|
|
181
|
-
const numOfActions = actions.length;
|
|
182
|
-
const data: any = {};
|
|
183
|
-
for (let i = 0; i < numOfActions; i += 1) {
|
|
184
|
-
// @ts-ignore
|
|
185
|
-
const _interestRate = res[numOfActions][i].toString();
|
|
186
|
-
// @ts-ignore
|
|
187
|
-
const vaultInfo = res[i];
|
|
188
|
-
const decimals = vaultInfo.decimals.toString();
|
|
189
|
-
const borrowRate = getEulerV2BorrowRate(_interestRate);
|
|
190
|
-
|
|
191
|
-
const amount = new Dec(actions[i].amount).mul(10 ** decimals).toString();
|
|
192
|
-
const action = actions[i].action;
|
|
193
|
-
const isBorrowOperation = borrowOperations.includes(action);
|
|
194
|
-
const { liquidityAdded, liquidityRemoved } = getLiquidityChanges(action, amount, isBorrowOperation);
|
|
195
|
-
|
|
196
|
-
const totalBorrows = new Dec(vaultInfo.totalBorrows.toString()).add(isBorrowOperation ? liquidityRemoved : '0').sub(isBorrowOperation ? liquidityAdded : '0').toString();
|
|
197
|
-
const totalAssets = new Dec(vaultInfo.totalAssets.toString()).add(isBorrowOperation ? '0' : liquidityAdded).sub(isBorrowOperation ? '0' : liquidityRemoved).toString();
|
|
198
|
-
const utilizationRate = getUtilizationRate(totalBorrows, totalAssets);
|
|
199
|
-
data[vaultInfo.vaultAddr.toLowerCase()] = {
|
|
200
|
-
borrowRate,
|
|
201
|
-
supplyRate: getEulerV2SupplyRate(borrowRate, utilizationRate, vaultInfo.interestFee.toString()),
|
|
202
|
-
};
|
|
203
|
-
}
|
|
204
|
-
return data;
|
|
205
|
-
};
|
|
206
|
-
|
|
207
|
-
const xorLastByte = (address: string, xorValue: string): EthAddress => {
|
|
208
|
-
// Extract the last byte (2 hex characters)
|
|
209
|
-
const lastByte = address.slice(-2);
|
|
210
|
-
|
|
211
|
-
// XOR the last byte with the given xorValue
|
|
212
|
-
|
|
213
|
-
// eslint-disable-next-line no-bitwise
|
|
214
|
-
const xorResult = [...lastByte].map((char, i) => (parseInt(char, 16) ^ parseInt(xorValue[i], 16)).toString(16),
|
|
215
|
-
).join('');
|
|
216
|
-
|
|
217
|
-
// Return the full address with the last byte XORed
|
|
218
|
-
return `0x${address.slice(0, -2)}${xorResult.padStart(2, '0')}`;
|
|
219
|
-
};
|
|
220
|
-
|
|
221
|
-
export const getEulerV2SubAccounts = (address: EthAddress): EthAddress[] => {
|
|
222
|
-
// Clean the address by removing "0x"
|
|
223
|
-
const cleanAddress = address.toLowerCase().replace(/^0x/, '');
|
|
224
|
-
|
|
225
|
-
// XOR the last byte with 0x01, 0x02, and 0x03
|
|
226
|
-
const xorWith01 = xorLastByte(cleanAddress, '01');
|
|
227
|
-
const xorWith02 = xorLastByte(cleanAddress, '02');
|
|
228
|
-
const xorWith03 = xorLastByte(cleanAddress, '03');
|
|
229
|
-
|
|
230
|
-
// Return an array with all three modified addresses
|
|
231
|
-
return [xorWith01, xorWith02, xorWith03];
|
|
232
|
-
};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { NetworkNumber } from '../../types/common';
|
|
2
|
-
import { EulerV2Market, EulerV2Versions } from '../../types';
|
|
3
|
-
|
|
4
|
-
export const eUSDC2 = (networkId: NetworkNumber): EulerV2Market => ({
|
|
5
|
-
chainIds: [NetworkNumber.Eth],
|
|
6
|
-
label: 'Euler Prime USDC',
|
|
7
|
-
shortLabel: 'eUSDC-2',
|
|
8
|
-
value: EulerV2Versions.eUSDC2,
|
|
9
|
-
asset: 'USDC',
|
|
10
|
-
secondLabel: 'Market',
|
|
11
|
-
marketAddress: '0x797DD80692c3b2dAdabCe8e30C07fDE5307D48a9',
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
export const eWETH2 = (networkId: NetworkNumber): EulerV2Market => ({
|
|
15
|
-
chainIds: [NetworkNumber.Eth],
|
|
16
|
-
label: 'Euler Prime WETH',
|
|
17
|
-
shortLabel: 'eWETH-2',
|
|
18
|
-
value: EulerV2Versions.eWETH2,
|
|
19
|
-
asset: 'WETH',
|
|
20
|
-
secondLabel: 'Market',
|
|
21
|
-
marketAddress: '0xD8b27CF359b7D15710a5BE299AF6e7Bf904984C2',
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
export const EulerV2Markets = (networkId: NetworkNumber) => ({
|
|
25
|
-
[EulerV2Versions.eUSDC2]: eUSDC2(networkId),
|
|
26
|
-
[EulerV2Versions.eWETH2]: eWETH2(networkId),
|
|
27
|
-
}) as const;
|
package/src/types/euler.ts
DELETED
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
EthAddress,
|
|
3
|
-
IncentiveData,
|
|
4
|
-
LeverageType,
|
|
5
|
-
MMPositionData, NetworkNumber,
|
|
6
|
-
} from './common';
|
|
7
|
-
|
|
8
|
-
export enum EulerV2Versions {
|
|
9
|
-
eUSDC2 = 'eUSDC-2',
|
|
10
|
-
eWETH2 = 'eWETH-2',
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export enum EulerV2VaultType {
|
|
14
|
-
Escrow = 'Escrow',
|
|
15
|
-
Governed = 'Governed',
|
|
16
|
-
Ungoverned = 'Ungoverned',
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export interface EulerV2Market {
|
|
20
|
-
chainIds: NetworkNumber[],
|
|
21
|
-
label: string,
|
|
22
|
-
shortLabel: string,
|
|
23
|
-
asset: string,
|
|
24
|
-
value: EulerV2Versions,
|
|
25
|
-
secondLabel: string,
|
|
26
|
-
marketAddress: EthAddress,
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export interface EulerV2PositionData extends MMPositionData {
|
|
30
|
-
ratio: string,
|
|
31
|
-
minRatio: string,
|
|
32
|
-
suppliedUsd: string,
|
|
33
|
-
borrowedUsd: string,
|
|
34
|
-
borrowLimitUsd: string,
|
|
35
|
-
incentiveUsd: string,
|
|
36
|
-
totalInterestUsd: string,
|
|
37
|
-
isSubscribedToAutomation?: boolean,
|
|
38
|
-
automationResubscribeRequired?: boolean,
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export interface EulerV2AssetData {
|
|
42
|
-
vaultAddress: string,
|
|
43
|
-
vaultSymbol: string
|
|
44
|
-
sortIndex?: number
|
|
45
|
-
liquidationRatio: string
|
|
46
|
-
cash: string
|
|
47
|
-
supplyCap: string
|
|
48
|
-
assetAddress: string
|
|
49
|
-
decimals: string
|
|
50
|
-
symbol: string
|
|
51
|
-
price: string
|
|
52
|
-
borrowCap: string
|
|
53
|
-
canBeBorrowed: boolean
|
|
54
|
-
canBeSupplied: boolean
|
|
55
|
-
supplyIncentives: IncentiveData[]
|
|
56
|
-
borrowIncentives: IncentiveData[]
|
|
57
|
-
totalBorrow: string
|
|
58
|
-
collateralFactor: string
|
|
59
|
-
borrowRate: string
|
|
60
|
-
supplyRate: string
|
|
61
|
-
utilization: string
|
|
62
|
-
governorAdmin: string
|
|
63
|
-
vaultType: EulerV2VaultType
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export interface EulerV2UsedAsset {
|
|
67
|
-
isSupplied: boolean
|
|
68
|
-
isBorrowed: boolean
|
|
69
|
-
supplied: string
|
|
70
|
-
suppliedUsd: string
|
|
71
|
-
borrowed: string
|
|
72
|
-
borrowedUsd: string
|
|
73
|
-
symbol: string
|
|
74
|
-
collateral: boolean
|
|
75
|
-
vaultAddress: string
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export interface EulerV2MarketInfoData {
|
|
79
|
-
name: string,
|
|
80
|
-
symbol: string,
|
|
81
|
-
decimals: string,
|
|
82
|
-
vaultAddress: string,
|
|
83
|
-
irm: string,
|
|
84
|
-
creator: string,
|
|
85
|
-
governorAdmin: string,
|
|
86
|
-
unitOfAccount: string,
|
|
87
|
-
unitOfAccountUsdPrice: string,
|
|
88
|
-
isInUSD: boolean,
|
|
89
|
-
oracle: string,
|
|
90
|
-
collaterals: string[],
|
|
91
|
-
isEscrow: boolean,
|
|
92
|
-
isGoverned: boolean,
|
|
93
|
-
vaultType: EulerV2VaultType,
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export type EulerV2AssetsData = { [key: string]: EulerV2AssetData };
|
|
97
|
-
export type EulerV2UsedAssets = { [key: string]: EulerV2UsedAsset };
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
export interface EulerV2CollateralInfo {
|
|
101
|
-
lltv: string
|
|
102
|
-
borrowLtv: string
|
|
103
|
-
totalBorrows: string
|
|
104
|
-
cash: string
|
|
105
|
-
supplyCap: string
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
export interface EulerV2MarketData {
|
|
109
|
-
name: string
|
|
110
|
-
symbol: string
|
|
111
|
-
decimals: number
|
|
112
|
-
|
|
113
|
-
totalSupplyShares: string
|
|
114
|
-
cash: string
|
|
115
|
-
totalBorrows: string
|
|
116
|
-
totalAssets: string
|
|
117
|
-
supplyCap: string
|
|
118
|
-
borrowCap: string
|
|
119
|
-
|
|
120
|
-
collaterals: string[]
|
|
121
|
-
|
|
122
|
-
badDebtSocializationEnabled: boolean
|
|
123
|
-
|
|
124
|
-
unitOfAccount: string
|
|
125
|
-
oracle: string
|
|
126
|
-
assetPrice: string
|
|
127
|
-
|
|
128
|
-
interestRate: string
|
|
129
|
-
irm: string
|
|
130
|
-
|
|
131
|
-
creator: string
|
|
132
|
-
|
|
133
|
-
governorAdmin: string
|
|
134
|
-
|
|
135
|
-
interestFee: string
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
export interface EulerV2FullMarketData {
|
|
139
|
-
marketData: EulerV2MarketInfoData
|
|
140
|
-
assetsData: EulerV2AssetsData
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
export interface EulerV2AccountData {
|
|
144
|
-
owner: string
|
|
145
|
-
inLockDownMode: boolean
|
|
146
|
-
inPermitDisabledMode: boolean
|
|
147
|
-
|
|
148
|
-
borrowVault: string
|
|
149
|
-
borrowAmountInUnit: string
|
|
150
|
-
|
|
151
|
-
collaterals: string[] // all collaterals user has enabled on main evc contract (globally - not only collaterals for his borrow market)
|
|
152
|
-
collateralAmountsInUnit: string[] // only amounts used as collateral for his debt (empty array if no debt)
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
export interface EulerV2AggregatedPositionData {
|
|
156
|
-
suppliedUsd: string,
|
|
157
|
-
suppliedCollateralUsd: string,
|
|
158
|
-
borrowedUsd: string,
|
|
159
|
-
borrowLimitUsd: string,
|
|
160
|
-
liquidationLimitUsd: string,
|
|
161
|
-
leftToBorrowUsd: string,
|
|
162
|
-
ratio: string,
|
|
163
|
-
collRatio: string,
|
|
164
|
-
netApy: string,
|
|
165
|
-
incentiveUsd: string,
|
|
166
|
-
totalInterestUsd: string,
|
|
167
|
-
liqRatio: string,
|
|
168
|
-
liqPercent: string,
|
|
169
|
-
leveragedType: LeverageType,
|
|
170
|
-
leveragedAsset?: string,
|
|
171
|
-
currentVolatilePairRatio?: string,
|
|
172
|
-
liquidationPrice?: string,
|
|
173
|
-
minRatio: string,
|
|
174
|
-
minDebt: string,
|
|
175
|
-
minCollRatio: string,
|
|
176
|
-
collLiquidationRatio: string,
|
|
177
|
-
exposure: string,
|
|
178
|
-
}
|