|
| 1 | +// SPDX-License-Identifier: BUSL-1.1 |
| 2 | +pragma solidity 0.6.10; |
| 3 | + |
| 4 | +library DataTypes { |
| 5 | + struct ReserveData { |
| 6 | + //stores the reserve configuration |
| 7 | + ReserveConfigurationMap configuration; |
| 8 | + //the liquidity index. Expressed in ray |
| 9 | + uint128 liquidityIndex; |
| 10 | + //the current supply rate. Expressed in ray |
| 11 | + uint128 currentLiquidityRate; |
| 12 | + //variable borrow index. Expressed in ray |
| 13 | + uint128 variableBorrowIndex; |
| 14 | + //the current variable borrow rate. Expressed in ray |
| 15 | + uint128 currentVariableBorrowRate; |
| 16 | + //the current stable borrow rate. Expressed in ray |
| 17 | + uint128 currentStableBorrowRate; |
| 18 | + //timestamp of last update |
| 19 | + uint40 lastUpdateTimestamp; |
| 20 | + //the id of the reserve. Represents the position in the list of the active reserves |
| 21 | + uint16 id; |
| 22 | + //aToken address |
| 23 | + address aTokenAddress; |
| 24 | + //stableDebtToken address |
| 25 | + address stableDebtTokenAddress; |
| 26 | + //variableDebtToken address |
| 27 | + address variableDebtTokenAddress; |
| 28 | + //address of the interest rate strategy |
| 29 | + address interestRateStrategyAddress; |
| 30 | + //the current treasury balance, scaled |
| 31 | + uint128 accruedToTreasury; |
| 32 | + //the outstanding unbacked aTokens minted through the bridging feature |
| 33 | + uint128 unbacked; |
| 34 | + //the outstanding debt borrowed against this asset in isolation mode |
| 35 | + uint128 isolationModeTotalDebt; |
| 36 | + } |
| 37 | + |
| 38 | + struct ReserveConfigurationMap { |
| 39 | + //bit 0-15: LTV |
| 40 | + //bit 16-31: Liq. threshold |
| 41 | + //bit 32-47: Liq. bonus |
| 42 | + //bit 48-55: Decimals |
| 43 | + //bit 56: reserve is active |
| 44 | + //bit 57: reserve is frozen |
| 45 | + //bit 58: borrowing is enabled |
| 46 | + //bit 59: stable rate borrowing enabled |
| 47 | + //bit 60: asset is paused |
| 48 | + //bit 61: borrowing in isolation mode is enabled |
| 49 | + //bit 62-63: reserved |
| 50 | + //bit 64-79: reserve factor |
| 51 | + //bit 80-115 borrow cap in whole tokens, borrowCap == 0 => no cap |
| 52 | + //bit 116-151 supply cap in whole tokens, supplyCap == 0 => no cap |
| 53 | + //bit 152-167 liquidation protocol fee |
| 54 | + //bit 168-175 eMode category |
| 55 | + //bit 176-211 unbacked mint cap in whole tokens, unbackedMintCap == 0 => minting disabled |
| 56 | + //bit 212-251 debt ceiling for isolation mode with (ReserveConfiguration::DEBT_CEILING_DECIMALS) decimals |
| 57 | + //bit 252-255 unused |
| 58 | + |
| 59 | + uint256 data; |
| 60 | + } |
| 61 | + |
| 62 | + struct UserConfigurationMap { |
| 63 | + /** |
| 64 | + * @dev Bitmap of the users collaterals and borrows. It is divided in pairs of bits, one pair per asset. |
| 65 | + * The first bit indicates if an asset is used as collateral by the user, the second whether an |
| 66 | + * asset is borrowed by the user. |
| 67 | + */ |
| 68 | + uint256 data; |
| 69 | + } |
| 70 | + |
| 71 | + struct EModeCategory { |
| 72 | + // each eMode category has a custom ltv and liquidation threshold |
| 73 | + uint16 ltv; |
| 74 | + uint16 liquidationThreshold; |
| 75 | + uint16 liquidationBonus; |
| 76 | + // each eMode category may or may not have a custom oracle to override the individual assets price oracles |
| 77 | + address priceSource; |
| 78 | + string label; |
| 79 | + } |
| 80 | + |
| 81 | + enum InterestRateMode { |
| 82 | + NONE, |
| 83 | + STABLE, |
| 84 | + VARIABLE |
| 85 | + } |
| 86 | + |
| 87 | + struct ReserveCache { |
| 88 | + uint256 currScaledVariableDebt; |
| 89 | + uint256 nextScaledVariableDebt; |
| 90 | + uint256 currPrincipalStableDebt; |
| 91 | + uint256 currAvgStableBorrowRate; |
| 92 | + uint256 currTotalStableDebt; |
| 93 | + uint256 nextAvgStableBorrowRate; |
| 94 | + uint256 nextTotalStableDebt; |
| 95 | + uint256 currLiquidityIndex; |
| 96 | + uint256 nextLiquidityIndex; |
| 97 | + uint256 currVariableBorrowIndex; |
| 98 | + uint256 nextVariableBorrowIndex; |
| 99 | + uint256 currLiquidityRate; |
| 100 | + uint256 currVariableBorrowRate; |
| 101 | + uint256 reserveFactor; |
| 102 | + ReserveConfigurationMap reserveConfiguration; |
| 103 | + address aTokenAddress; |
| 104 | + address stableDebtTokenAddress; |
| 105 | + address variableDebtTokenAddress; |
| 106 | + uint40 reserveLastUpdateTimestamp; |
| 107 | + uint40 stableDebtLastUpdateTimestamp; |
| 108 | + } |
| 109 | + |
| 110 | + struct ExecuteLiquidationCallParams { |
| 111 | + uint256 reservesCount; |
| 112 | + uint256 debtToCover; |
| 113 | + address collateralAsset; |
| 114 | + address debtAsset; |
| 115 | + address user; |
| 116 | + bool receiveAToken; |
| 117 | + address priceOracle; |
| 118 | + uint8 userEModeCategory; |
| 119 | + address priceOracleSentinel; |
| 120 | + } |
| 121 | + |
| 122 | + struct ExecuteSupplyParams { |
| 123 | + address asset; |
| 124 | + uint256 amount; |
| 125 | + address onBehalfOf; |
| 126 | + uint16 referralCode; |
| 127 | + } |
| 128 | + |
| 129 | + struct ExecuteBorrowParams { |
| 130 | + address asset; |
| 131 | + address user; |
| 132 | + address onBehalfOf; |
| 133 | + uint256 amount; |
| 134 | + InterestRateMode interestRateMode; |
| 135 | + uint16 referralCode; |
| 136 | + bool releaseUnderlying; |
| 137 | + uint256 maxStableRateBorrowSizePercent; |
| 138 | + uint256 reservesCount; |
| 139 | + address oracle; |
| 140 | + uint8 userEModeCategory; |
| 141 | + address priceOracleSentinel; |
| 142 | + } |
| 143 | + |
| 144 | + struct ExecuteRepayParams { |
| 145 | + address asset; |
| 146 | + uint256 amount; |
| 147 | + InterestRateMode interestRateMode; |
| 148 | + address onBehalfOf; |
| 149 | + bool useATokens; |
| 150 | + } |
| 151 | + |
| 152 | + struct ExecuteWithdrawParams { |
| 153 | + address asset; |
| 154 | + uint256 amount; |
| 155 | + address to; |
| 156 | + uint256 reservesCount; |
| 157 | + address oracle; |
| 158 | + uint8 userEModeCategory; |
| 159 | + } |
| 160 | + |
| 161 | + struct ExecuteSetUserEModeParams { |
| 162 | + uint256 reservesCount; |
| 163 | + address oracle; |
| 164 | + uint8 categoryId; |
| 165 | + } |
| 166 | + |
| 167 | + struct FinalizeTransferParams { |
| 168 | + address asset; |
| 169 | + address from; |
| 170 | + address to; |
| 171 | + uint256 amount; |
| 172 | + uint256 balanceFromBefore; |
| 173 | + uint256 balanceToBefore; |
| 174 | + uint256 reservesCount; |
| 175 | + address oracle; |
| 176 | + uint8 fromEModeCategory; |
| 177 | + } |
| 178 | + |
| 179 | + struct FlashloanParams { |
| 180 | + address receiverAddress; |
| 181 | + address[] assets; |
| 182 | + uint256[] amounts; |
| 183 | + uint256[] interestRateModes; |
| 184 | + address onBehalfOf; |
| 185 | + bytes params; |
| 186 | + uint16 referralCode; |
| 187 | + uint256 flashLoanPremiumToProtocol; |
| 188 | + uint256 flashLoanPremiumTotal; |
| 189 | + uint256 maxStableRateBorrowSizePercent; |
| 190 | + uint256 reservesCount; |
| 191 | + address addressesProvider; |
| 192 | + uint8 userEModeCategory; |
| 193 | + bool isAuthorizedFlashBorrower; |
| 194 | + } |
| 195 | + |
| 196 | + struct FlashloanSimpleParams { |
| 197 | + address receiverAddress; |
| 198 | + address asset; |
| 199 | + uint256 amount; |
| 200 | + bytes params; |
| 201 | + uint16 referralCode; |
| 202 | + uint256 flashLoanPremiumToProtocol; |
| 203 | + uint256 flashLoanPremiumTotal; |
| 204 | + } |
| 205 | + |
| 206 | + struct FlashLoanRepaymentParams { |
| 207 | + uint256 amount; |
| 208 | + uint256 totalPremium; |
| 209 | + uint256 flashLoanPremiumToProtocol; |
| 210 | + address asset; |
| 211 | + address receiverAddress; |
| 212 | + uint16 referralCode; |
| 213 | + } |
| 214 | + |
| 215 | + struct CalculateUserAccountDataParams { |
| 216 | + UserConfigurationMap userConfig; |
| 217 | + uint256 reservesCount; |
| 218 | + address user; |
| 219 | + address oracle; |
| 220 | + uint8 userEModeCategory; |
| 221 | + } |
| 222 | + |
| 223 | + struct ValidateBorrowParams { |
| 224 | + ReserveCache reserveCache; |
| 225 | + UserConfigurationMap userConfig; |
| 226 | + address asset; |
| 227 | + address userAddress; |
| 228 | + uint256 amount; |
| 229 | + InterestRateMode interestRateMode; |
| 230 | + uint256 maxStableLoanPercent; |
| 231 | + uint256 reservesCount; |
| 232 | + address oracle; |
| 233 | + uint8 userEModeCategory; |
| 234 | + address priceOracleSentinel; |
| 235 | + bool isolationModeActive; |
| 236 | + address isolationModeCollateralAddress; |
| 237 | + uint256 isolationModeDebtCeiling; |
| 238 | + } |
| 239 | + |
| 240 | + struct ValidateLiquidationCallParams { |
| 241 | + ReserveCache debtReserveCache; |
| 242 | + uint256 totalDebt; |
| 243 | + uint256 healthFactor; |
| 244 | + address priceOracleSentinel; |
| 245 | + } |
| 246 | + |
| 247 | + struct CalculateInterestRatesParams { |
| 248 | + uint256 unbacked; |
| 249 | + uint256 liquidityAdded; |
| 250 | + uint256 liquidityTaken; |
| 251 | + uint256 totalStableDebt; |
| 252 | + uint256 totalVariableDebt; |
| 253 | + uint256 averageStableBorrowRate; |
| 254 | + uint256 reserveFactor; |
| 255 | + address reserve; |
| 256 | + address aToken; |
| 257 | + } |
| 258 | + |
| 259 | + struct InitReserveParams { |
| 260 | + address asset; |
| 261 | + address aTokenAddress; |
| 262 | + address stableDebtAddress; |
| 263 | + address variableDebtAddress; |
| 264 | + address interestRateStrategyAddress; |
| 265 | + uint16 reservesCount; |
| 266 | + uint16 maxNumberReserves; |
| 267 | + } |
| 268 | +} |
0 commit comments