This repository was archived by the owner on Dec 9, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 781
Expand file tree
/
Copy pathtypes.ts
More file actions
389 lines (355 loc) · 13.7 KB
/
Copy pathtypes.ts
File metadata and controls
389 lines (355 loc) · 13.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
import BigNumber from 'bignumber.js';
export interface SymbolMap<T> {
[symbol: string]: T;
}
export enum eEthereumNetwork {
buidlerevm = 'buidlerevm',
kovan = 'kovan',
ropsten = 'ropsten',
main = 'main',
coverage = 'coverage',
hardhat = 'hardhat',
tenderlyMain = 'tenderlyMain',
}
export enum EthereumNetworkNames {
kovan = 'kovan',
ropsten = 'ropsten',
main = 'main',
}
export enum AavePools {
proto = 'proto',
}
export enum eContractid {
Example = 'Example',
LendingPoolAddressesProvider = 'LendingPoolAddressesProvider',
MintableERC20 = 'MintableERC20',
MintableDelegationERC20 = 'MintableDelegationERC20',
LendingPoolAddressesProviderRegistry = 'LendingPoolAddressesProviderRegistry',
LendingPoolParametersProvider = 'LendingPoolParametersProvider',
LendingPoolConfigurator = 'LendingPoolConfigurator',
ValidationLogic = 'ValidationLogic',
ReserveLogic = 'ReserveLogic',
GenericLogic = 'GenericLogic',
LendingPool = 'LendingPool',
PriceOracle = 'PriceOracle',
Proxy = 'Proxy',
MockAggregator = 'MockAggregator',
LendingRateOracle = 'LendingRateOracle',
AaveOracle = 'AaveOracle',
DefaultReserveInterestRateStrategy = 'DefaultReserveInterestRateStrategy',
LendingPoolCollateralManager = 'LendingPoolCollateralManager',
InitializableAdminUpgradeabilityProxy = 'InitializableAdminUpgradeabilityProxy',
MockFlashLoanReceiver = 'MockFlashLoanReceiver',
WalletBalanceProvider = 'WalletBalanceProvider',
AToken = 'AToken',
MockAToken = 'MockAToken',
DelegationAwareAToken = 'DelegationAwareAToken',
MockStableDebtToken = 'MockStableDebtToken',
MockVariableDebtToken = 'MockVariableDebtToken',
AaveProtocolDataProvider = 'AaveProtocolDataProvider',
IERC20Detailed = 'IERC20Detailed',
StableDebtToken = 'StableDebtToken',
VariableDebtToken = 'VariableDebtToken',
FeeProvider = 'FeeProvider',
TokenDistributor = 'TokenDistributor',
StableAndVariableTokensHelper = 'StableAndVariableTokensHelper',
ATokensAndRatesHelper = 'ATokensAndRatesHelper',
UiPoolDataProvider = 'UiPoolDataProvider',
WETHGateway = 'WETHGateway',
WETH = 'WETH',
WETHMocked = 'WETHMocked',
SelfdestructTransferMock = 'SelfdestructTransferMock',
LendingPoolImpl = 'LendingPoolImpl',
LendingPoolConfiguratorImpl = 'LendingPoolConfiguratorImpl',
LendingPoolCollateralManagerImpl = 'LendingPoolCollateralManagerImpl',
MockUniswapV2Router02 = 'MockUniswapV2Router02',
UniswapLiquiditySwapAdapter = 'UniswapLiquiditySwapAdapter',
UniswapRepayAdapter = 'UniswapRepayAdapter',
FlashLiquidationAdapter = 'FlashLiquidationAdapter',
}
/*
* Error messages prefix glossary:
* - VL = ValidationLogic
* - MATH = Math libraries
* - AT = aToken or DebtTokens
* - LP = LendingPool
* - LPAPR = LendingPoolAddressesProviderRegistry
* - LPC = LendingPoolConfiguration
* - RL = ReserveLogic
* - LPCM = LendingPoolCollateralManager
* - P = Pausable
*/
export enum ProtocolErrors {
//common errors
CALLER_NOT_POOL_ADMIN = '33', // 'The caller must be the pool admin'
//contract specific errors
VL_INVALID_AMOUNT = '1', // 'Amount must be greater than 0'
VL_NO_ACTIVE_RESERVE = '2', // 'Action requires an active reserve'
VL_RESERVE_FROZEN = '3', // 'Action requires an unfrozen reserve'
VL_CURRENT_AVAILABLE_LIQUIDITY_NOT_ENOUGH = '4', // 'The current liquidity is not enough'
VL_NOT_ENOUGH_AVAILABLE_USER_BALANCE = '5', // 'User cannot withdraw more than the available balance'
VL_TRANSFER_NOT_ALLOWED = '6', // 'Transfer cannot be allowed.'
VL_BORROWING_NOT_ENABLED = '7', // 'Borrowing is not enabled'
VL_INVALID_INTEREST_RATE_MODE_SELECTED = '8', // 'Invalid interest rate mode selected'
VL_COLLATERAL_BALANCE_IS_0 = '9', // 'The collateral balance is 0'
VL_HEALTH_FACTOR_LOWER_THAN_LIQUIDATION_THRESHOLD = '10', // 'Health factor is lesser than the liquidation threshold'
VL_COLLATERAL_CANNOT_COVER_NEW_BORROW = '11', // 'There is not enough collateral to cover a new borrow'
VL_STABLE_BORROWING_NOT_ENABLED = '12', // stable borrowing not enabled
VL_COLLATERAL_SAME_AS_BORROWING_CURRENCY = '13', // collateral is (mostly) the same currency that is being borrowed
VL_AMOUNT_BIGGER_THAN_MAX_LOAN_SIZE_STABLE = '14', // 'The requested amount is greater than the max loan size in stable rate mode
VL_NO_DEBT_OF_SELECTED_TYPE = '15', // 'for repayment of stable debt, the user needs to have stable debt, otherwise, he needs to have variable debt'
VL_NO_EXPLICIT_AMOUNT_TO_REPAY_ON_BEHALF = '16', // 'To repay on behalf of an user an explicit amount to repay is needed'
VL_NO_STABLE_RATE_LOAN_IN_RESERVE = '17', // 'User does not have a stable rate loan in progress on this reserve'
VL_NO_VARIABLE_RATE_LOAN_IN_RESERVE = '18', // 'User does not have a variable rate loan in progress on this reserve'
VL_UNDERLYING_BALANCE_NOT_GREATER_THAN_0 = '19', // 'The underlying balance needs to be greater than 0'
VL_DEPOSIT_ALREADY_IN_USE = '20', // 'User deposit is already being used as collateral'
LP_NOT_ENOUGH_STABLE_BORROW_BALANCE = '21', // 'User does not have any stable rate loan for this reserve'
LP_INTEREST_RATE_REBALANCE_CONDITIONS_NOT_MET = '22', // 'Interest rate rebalance conditions were not met'
LP_LIQUIDATION_CALL_FAILED = '23', // 'Liquidation call failed'
LP_NOT_ENOUGH_LIQUIDITY_TO_BORROW = '24', // 'There is not enough liquidity available to borrow'
LP_REQUESTED_AMOUNT_TOO_SMALL = '25', // 'The requested amount is too small for a FlashLoan.'
LP_INCONSISTENT_PROTOCOL_ACTUAL_BALANCE = '26', // 'The actual balance of the protocol is inconsistent'
LP_CALLER_NOT_LENDING_POOL_CONFIGURATOR = '27', // 'The caller is not the lending pool configurator'
LP_INCONSISTENT_FLASHLOAN_PARAMS = '28',
CT_CALLER_MUST_BE_LENDING_POOL = '29', // 'The caller of this function must be a lending pool'
CT_CANNOT_GIVE_ALLOWANCE_TO_HIMSELF = '30', // 'User cannot give allowance to himself'
CT_TRANSFER_AMOUNT_NOT_GT_0 = '31', // 'Transferred amount needs to be greater than zero'
RL_RESERVE_ALREADY_INITIALIZED = '32', // 'Reserve has already been initialized'
LPC_RESERVE_LIQUIDITY_NOT_0 = '34', // 'The liquidity of the reserve needs to be 0'
LPC_INVALID_ATOKEN_POOL_ADDRESS = '35', // 'The liquidity of the reserve needs to be 0'
LPC_INVALID_STABLE_DEBT_TOKEN_POOL_ADDRESS = '36', // 'The liquidity of the reserve needs to be 0'
LPC_INVALID_VARIABLE_DEBT_TOKEN_POOL_ADDRESS = '37', // 'The liquidity of the reserve needs to be 0'
LPC_INVALID_STABLE_DEBT_TOKEN_UNDERLYING_ADDRESS = '38', // 'The liquidity of the reserve needs to be 0'
LPC_INVALID_VARIABLE_DEBT_TOKEN_UNDERLYING_ADDRESS = '39', // 'The liquidity of the reserve needs to be 0'
LPC_INVALID_ADDRESSES_PROVIDER_ID = '40', // 'The liquidity of the reserve needs to be 0'
LPC_CALLER_NOT_EMERGENCY_ADMIN = '76', // 'The caller must be the emergencya admin'
LPAPR_PROVIDER_NOT_REGISTERED = '41', // 'Provider is not registered'
LPCM_HEALTH_FACTOR_NOT_BELOW_THRESHOLD = '42', // 'Health factor is not below the threshold'
LPCM_COLLATERAL_CANNOT_BE_LIQUIDATED = '43', // 'The collateral chosen cannot be liquidated'
LPCM_SPECIFIED_CURRENCY_NOT_BORROWED_BY_USER = '44', // 'User did not borrow the specified currency'
LPCM_NOT_ENOUGH_LIQUIDITY_TO_LIQUIDATE = '45', // "There isn't enough liquidity available to liquidate"
LPCM_NO_ERRORS = '46', // 'No errors'
LP_INVALID_FLASHLOAN_MODE = '47', //Invalid flashloan mode selected
MATH_MULTIPLICATION_OVERFLOW = '48',
MATH_ADDITION_OVERFLOW = '49',
MATH_DIVISION_BY_ZERO = '50',
RL_LIQUIDITY_INDEX_OVERFLOW = '51', // Liquidity index overflows uint128
RL_VARIABLE_BORROW_INDEX_OVERFLOW = '52', // Variable borrow index overflows uint128
RL_LIQUIDITY_RATE_OVERFLOW = '53', // Liquidity rate overflows uint128
RL_VARIABLE_BORROW_RATE_OVERFLOW = '54', // Variable borrow rate overflows uint128
RL_STABLE_BORROW_RATE_OVERFLOW = '55', // Stable borrow rate overflows uint128
CT_INVALID_MINT_AMOUNT = '56', //invalid amount to mint
LP_FAILED_REPAY_WITH_COLLATERAL = '57',
CT_INVALID_BURN_AMOUNT = '58', //invalid amount to burn
LP_BORROW_ALLOWANCE_NOT_ENOUGH = '59', // User borrows on behalf, but allowance are too small
LP_FAILED_COLLATERAL_SWAP = '60',
LP_INVALID_EQUAL_ASSETS_TO_SWAP = '61',
LP_REENTRANCY_NOT_ALLOWED = '62',
LP_CALLER_MUST_BE_AN_ATOKEN = '63',
LP_IS_PAUSED = '64', // 'Pool is paused'
LP_NO_MORE_RESERVES_ALLOWED = '65',
LP_INVALID_FLASH_LOAN_EXECUTOR_RETURN = '66',
RC_INVALID_LTV = '67',
RC_INVALID_LIQ_THRESHOLD = '68',
RC_INVALID_LIQ_BONUS = '69',
RC_INVALID_DECIMALS = '70',
RC_INVALID_RESERVE_FACTOR = '71',
LPAPR_INVALID_ADDRESSES_PROVIDER_ID = '72',
// old
INVALID_FROM_BALANCE_AFTER_TRANSFER = 'Invalid from balance after transfer',
INVALID_TO_BALANCE_AFTER_TRANSFER = 'Invalid from balance after transfer',
INVALID_OWNER_REVERT_MSG = 'Ownable: caller is not the owner',
INVALID_HF = 'Invalid health factor',
TRANSFER_AMOUNT_EXCEEDS_BALANCE = 'ERC20: transfer amount exceeds balance',
SAFEERC20_LOWLEVEL_CALL = 'SafeERC20: low-level call failed',
}
export type tEthereumAddress = string;
export type tStringTokenBigUnits = string; // 1 ETH, or 10e6 USDC or 10e18 DAI
export type tBigNumberTokenBigUnits = BigNumber;
export type tStringTokenSmallUnits = string; // 1 wei, or 1 basic unit of USDC, or 1 basic unit of DAI
export type tBigNumberTokenSmallUnits = BigNumber;
export interface iAssetCommon<T> {
[key: string]: T;
}
export interface iAssetBase<T> {
WETH: T;
DAI: T;
TUSD: T;
USDC: T;
USDT: T;
SUSD: T;
AAVE: T;
BAT: T;
MKR: T;
LINK: T;
KNC: T;
WBTC: T;
MANA: T;
ZRX: T;
SNX: T;
BUSD: T;
YFI: T;
UNI: T;
USD: T;
REN: T;
ENJ: T;
xSUSHI: T;
ENS: T;
}
export type iAssetsWithoutETH<T> = Omit<iAssetBase<T>, 'ETH'>;
export type iAssetsWithoutUSD<T> = Omit<iAssetBase<T>, 'USD'>;
export type iAavePoolAssets<T> = Pick<
iAssetsWithoutUSD<T>,
| 'DAI'
| 'TUSD'
| 'USDC'
| 'USDT'
| 'SUSD'
| 'AAVE'
| 'BAT'
| 'MKR'
| 'LINK'
| 'KNC'
| 'WBTC'
| 'MANA'
| 'ZRX'
| 'SNX'
| 'BUSD'
| 'WETH'
| 'YFI'
| 'UNI'
| 'REN'
| 'ENJ'
| 'xSUSHI'
| 'ENS'
>;
export type iMultiPoolsAssets<T> = iAssetCommon<T> | iAavePoolAssets<T>;
export type iAavePoolTokens<T> = Omit<iAavePoolAssets<T>, 'ETH'>;
export type iAssetAggregatorBase<T> = iAssetsWithoutETH<T>;
export enum TokenContractId {
DAI = 'DAI',
AAVE = 'AAVE',
TUSD = 'TUSD',
BAT = 'BAT',
WETH = 'WETH',
USDC = 'USDC',
USDT = 'USDT',
SUSD = 'SUSD',
ZRX = 'ZRX',
MKR = 'MKR',
WBTC = 'WBTC',
LINK = 'LINK',
KNC = 'KNC',
MANA = 'MANA',
REN = 'REN',
SNX = 'SNX',
BUSD = 'BUSD',
USD = 'USD',
YFI = 'YFI',
UNI = 'UNI',
ENJ = 'ENJ',
xSUSHI = 'xSUSHI',
ENS = 'ENS'
}
export interface IReserveParams extends IReserveBorrowParams, IReserveCollateralParams {
aTokenImpl: eContractid;
reserveFactor: string;
}
export interface IReserveBorrowParams {
optimalUtilizationRate: string;
baseVariableBorrowRate: string;
variableRateSlope1: string;
variableRateSlope2: string;
stableRateSlope1: string;
stableRateSlope2: string;
borrowingEnabled: boolean;
stableBorrowRateEnabled: boolean;
reserveDecimals: string;
}
export interface IReserveCollateralParams {
baseLTVAsCollateral: string;
liquidationThreshold: string;
liquidationBonus: string;
}
export interface IMarketRates {
borrowRate: string;
}
export interface iParamsPerNetwork<T> {
[eEthereumNetwork.coverage]: T;
[eEthereumNetwork.buidlerevm]: T;
[eEthereumNetwork.kovan]: T;
[eEthereumNetwork.ropsten]: T;
[eEthereumNetwork.main]: T;
[eEthereumNetwork.hardhat]: T;
[eEthereumNetwork.tenderlyMain]: T;
}
export interface iParamsPerPool<T> {
[AavePools.proto]: T;
}
export interface iBasicDistributionParams {
receivers: string[];
percentages: string[];
}
export enum RateMode {
None = '0',
Stable = '1',
Variable = '2',
}
export interface ObjectString {
[key: string]: string;
}
export enum EthereumNetwork {
kovan = 'kovan',
ropsten = 'ropsten',
development = 'development',
main = 'main',
coverage = 'soliditycoverage',
tenderlyMain = 'tenderlyMain',
}
export interface IProtocolGlobalConfig {
TokenDistributorPercentageBase: string;
MockUsdPriceInWei: string;
UsdAddress: tEthereumAddress;
NilAddress: tEthereumAddress;
OneAddress: tEthereumAddress;
AaveReferral: string;
}
export interface IMocksConfig {
AllAssetsInitialPrices: iAssetBase<string>;
}
export interface ILendingRateOracleRatesCommon {
[token: string]: ILendingRate;
}
export interface ILendingRate {
borrowRate: string;
}
export interface ICommonConfiguration {
MarketId: string;
ProviderId: number;
ProtocolGlobalParams: IProtocolGlobalConfig;
Mocks: IMocksConfig;
ProviderRegistry: iParamsPerNetwork<tEthereumAddress | undefined>;
ProviderRegistryOwner: iParamsPerNetwork<tEthereumAddress | undefined>;
LendingRateOracleRatesCommon: iMultiPoolsAssets<IMarketRates>;
LendingRateOracle: iParamsPerNetwork<tEthereumAddress>;
TokenDistributor: iParamsPerNetwork<tEthereumAddress>;
AaveOracle: iParamsPerNetwork<tEthereumAddress>;
FallbackOracle: iParamsPerNetwork<tEthereumAddress>;
ChainlinkAggregator: iParamsPerNetwork<ITokenAddress>;
PoolAdmin: iParamsPerNetwork<tEthereumAddress | undefined>;
PoolAdminIndex: number;
EmergencyAdmin: iParamsPerNetwork<tEthereumAddress | undefined>;
EmergencyAdminIndex: number;
ReserveAssets: iParamsPerNetwork<SymbolMap<tEthereumAddress>>;
ReservesConfig: iMultiPoolsAssets<IReserveParams>;
ATokenDomainSeparator: iParamsPerNetwork<string>;
WETH: iParamsPerNetwork<tEthereumAddress>;
ReserveFactorTreasuryAddress: iParamsPerNetwork<tEthereumAddress>;
}
export interface IAaveConfiguration extends ICommonConfiguration {
ReservesConfig: iAavePoolAssets<IReserveParams>;
}
export interface ITokenAddress {
[token: string]: tEthereumAddress;
}
export type PoolConfiguration = ICommonConfiguration | IAaveConfiguration;