mirror of
				https://github.com/Instadapp/aave-protocol-v2.git
				synced 2024-07-29 21:47:30 +00:00 
			
		
		
		
	refactor: updated configs and tests for feat caps disabled by default
This commit is contained in:
		
							parent
							
								
									62f3f47b84
								
							
						
					
					
						commit
						4b256f1c25
					
				|  | @ -1,4 +1,3 @@ | |||
| import { MAX_BORROW_CAP, MAX_SUPPLY_CAP } from '../../helpers/constants'; | ||||
| import { eContractid, IReserveParams } from '../../helpers/types'; | ||||
| 
 | ||||
| import { | ||||
|  | @ -23,8 +22,8 @@ export const strategyBUSD: IReserveParams = { | |||
|   reserveDecimals: '18', | ||||
|   aTokenImpl: eContractid.AToken, | ||||
|   reserveFactor: '1000', | ||||
|   borrowCap: MAX_BORROW_CAP, | ||||
|   supplyCap: MAX_SUPPLY_CAP, | ||||
|   borrowCap: '0', | ||||
|   supplyCap: '0', | ||||
| }; | ||||
| 
 | ||||
| export const strategyDAI: IReserveParams = { | ||||
|  | @ -37,8 +36,8 @@ export const strategyDAI: IReserveParams = { | |||
|   reserveDecimals: '18', | ||||
|   aTokenImpl: eContractid.AToken, | ||||
|   reserveFactor: '1000', | ||||
|   borrowCap: MAX_BORROW_CAP, | ||||
|   supplyCap: MAX_SUPPLY_CAP, | ||||
|   borrowCap: '0', | ||||
|   supplyCap: '0', | ||||
| }; | ||||
| 
 | ||||
| export const strategySUSD: IReserveParams = { | ||||
|  | @ -51,8 +50,8 @@ export const strategySUSD: IReserveParams = { | |||
|   reserveDecimals: '18', | ||||
|   aTokenImpl: eContractid.AToken, | ||||
|   reserveFactor: '2000', | ||||
|   borrowCap: MAX_BORROW_CAP, | ||||
|   supplyCap: MAX_SUPPLY_CAP, | ||||
|   borrowCap: '0', | ||||
|   supplyCap: '0', | ||||
| }; | ||||
| 
 | ||||
| export const strategyTUSD: IReserveParams = { | ||||
|  | @ -65,8 +64,8 @@ export const strategyTUSD: IReserveParams = { | |||
|   reserveDecimals: '18', | ||||
|   aTokenImpl: eContractid.AToken, | ||||
|   reserveFactor: '1000', | ||||
|   borrowCap: MAX_BORROW_CAP, | ||||
|   supplyCap: MAX_SUPPLY_CAP, | ||||
|   borrowCap: '0', | ||||
|   supplyCap: '0', | ||||
| }; | ||||
| 
 | ||||
| export const strategyUSDC: IReserveParams = { | ||||
|  | @ -79,8 +78,8 @@ export const strategyUSDC: IReserveParams = { | |||
|   reserveDecimals: '6', | ||||
|   aTokenImpl: eContractid.AToken, | ||||
|   reserveFactor: '1000', | ||||
|   borrowCap: MAX_BORROW_CAP, | ||||
|   supplyCap: MAX_SUPPLY_CAP, | ||||
|   borrowCap: '0', | ||||
|   supplyCap: '0', | ||||
| }; | ||||
| 
 | ||||
| export const strategyUSDT: IReserveParams = { | ||||
|  | @ -93,8 +92,8 @@ export const strategyUSDT: IReserveParams = { | |||
|   reserveDecimals: '6', | ||||
|   aTokenImpl: eContractid.AToken, | ||||
|   reserveFactor: '1000', | ||||
|   borrowCap: MAX_BORROW_CAP, | ||||
|   supplyCap: MAX_SUPPLY_CAP, | ||||
|   borrowCap: '0', | ||||
|   supplyCap: '0', | ||||
| }; | ||||
| 
 | ||||
| export const strategyAAVE: IReserveParams = { | ||||
|  | @ -107,8 +106,8 @@ export const strategyAAVE: IReserveParams = { | |||
|   reserveDecimals: '18', | ||||
|   aTokenImpl: eContractid.AToken, | ||||
|   reserveFactor: '0', | ||||
|   borrowCap: MAX_BORROW_CAP, | ||||
|   supplyCap: MAX_SUPPLY_CAP, | ||||
|   borrowCap: '0', | ||||
|   supplyCap: '0', | ||||
| }; | ||||
| 
 | ||||
| export const strategyBAT: IReserveParams = { | ||||
|  | @ -121,8 +120,8 @@ export const strategyBAT: IReserveParams = { | |||
|   reserveDecimals: '18', | ||||
|   aTokenImpl: eContractid.AToken, | ||||
|   reserveFactor: '2000', | ||||
|   borrowCap: MAX_BORROW_CAP, | ||||
|   supplyCap: MAX_SUPPLY_CAP, | ||||
|   borrowCap: '0', | ||||
|   supplyCap: '0', | ||||
| }; | ||||
| 
 | ||||
| export const strategyENJ: IReserveParams = { | ||||
|  | @ -135,8 +134,8 @@ export const strategyENJ: IReserveParams = { | |||
|   reserveDecimals: '18', | ||||
|   aTokenImpl: eContractid.AToken, | ||||
|   reserveFactor: '2000', | ||||
|   borrowCap: MAX_BORROW_CAP, | ||||
|   supplyCap: MAX_SUPPLY_CAP, | ||||
|   borrowCap: '0', | ||||
|   supplyCap: '0', | ||||
| }; | ||||
| 
 | ||||
| export const strategyWETH: IReserveParams = { | ||||
|  | @ -149,8 +148,8 @@ export const strategyWETH: IReserveParams = { | |||
|   reserveDecimals: '18', | ||||
|   aTokenImpl: eContractid.AToken, | ||||
|   reserveFactor: '1000', | ||||
|   borrowCap: MAX_BORROW_CAP, | ||||
|   supplyCap: MAX_SUPPLY_CAP, | ||||
|   borrowCap: '0', | ||||
|   supplyCap: '0', | ||||
| }; | ||||
| 
 | ||||
| export const strategyKNC: IReserveParams = { | ||||
|  | @ -163,8 +162,8 @@ export const strategyKNC: IReserveParams = { | |||
|   reserveDecimals: '18', | ||||
|   aTokenImpl: eContractid.AToken, | ||||
|   reserveFactor: '2000', | ||||
|   borrowCap: MAX_BORROW_CAP, | ||||
|   supplyCap: MAX_SUPPLY_CAP, | ||||
|   borrowCap: '0', | ||||
|   supplyCap: '0', | ||||
| }; | ||||
| 
 | ||||
| export const strategyLINK: IReserveParams = { | ||||
|  | @ -177,8 +176,8 @@ export const strategyLINK: IReserveParams = { | |||
|   reserveDecimals: '18', | ||||
|   aTokenImpl: eContractid.AToken, | ||||
|   reserveFactor: '2000', | ||||
|   borrowCap: MAX_BORROW_CAP, | ||||
|   supplyCap: MAX_SUPPLY_CAP, | ||||
|   borrowCap: '0', | ||||
|   supplyCap: '0', | ||||
| }; | ||||
| 
 | ||||
| export const strategyMANA: IReserveParams = { | ||||
|  | @ -191,8 +190,8 @@ export const strategyMANA: IReserveParams = { | |||
|   reserveDecimals: '18', | ||||
|   aTokenImpl: eContractid.AToken, | ||||
|   reserveFactor: '3500', | ||||
|   borrowCap: MAX_BORROW_CAP, | ||||
|   supplyCap: MAX_SUPPLY_CAP, | ||||
|   borrowCap: '0', | ||||
|   supplyCap: '0', | ||||
| }; | ||||
| 
 | ||||
| export const strategyMKR: IReserveParams = { | ||||
|  | @ -205,8 +204,8 @@ export const strategyMKR: IReserveParams = { | |||
|   reserveDecimals: '18', | ||||
|   aTokenImpl: eContractid.AToken, | ||||
|   reserveFactor: '2000', | ||||
|   borrowCap: MAX_BORROW_CAP, | ||||
|   supplyCap: MAX_SUPPLY_CAP, | ||||
|   borrowCap: '0', | ||||
|   supplyCap: '0', | ||||
| }; | ||||
| 
 | ||||
| export const strategyREN: IReserveParams = { | ||||
|  | @ -219,8 +218,8 @@ export const strategyREN: IReserveParams = { | |||
|   reserveDecimals: '18', | ||||
|   aTokenImpl: eContractid.AToken, | ||||
|   reserveFactor: '2000', | ||||
|   borrowCap: MAX_BORROW_CAP, | ||||
|   supplyCap: MAX_SUPPLY_CAP, | ||||
|   borrowCap: '0', | ||||
|   supplyCap: '0', | ||||
| }; | ||||
| 
 | ||||
| export const strategySNX: IReserveParams = { | ||||
|  | @ -233,8 +232,8 @@ export const strategySNX: IReserveParams = { | |||
|   reserveDecimals: '18', | ||||
|   aTokenImpl: eContractid.AToken, | ||||
|   reserveFactor: '3500', | ||||
|   borrowCap: MAX_BORROW_CAP, | ||||
|   supplyCap: MAX_SUPPLY_CAP, | ||||
|   borrowCap: '0', | ||||
|   supplyCap: '0', | ||||
| }; | ||||
| 
 | ||||
| // Invalid borrow rates in params currently, replaced with snx params
 | ||||
|  | @ -248,8 +247,8 @@ export const strategyUNI: IReserveParams = { | |||
|   reserveDecimals: '18', | ||||
|   aTokenImpl: eContractid.DelegationAwareAToken, | ||||
|   reserveFactor: '2000', | ||||
|   borrowCap: MAX_BORROW_CAP, | ||||
|   supplyCap: MAX_SUPPLY_CAP, | ||||
|   borrowCap: '0', | ||||
|   supplyCap: '0', | ||||
| }; | ||||
| 
 | ||||
| export const strategyWBTC: IReserveParams = { | ||||
|  | @ -262,8 +261,8 @@ export const strategyWBTC: IReserveParams = { | |||
|   reserveDecimals: '8', | ||||
|   aTokenImpl: eContractid.AToken, | ||||
|   reserveFactor: '2000', | ||||
|   borrowCap: MAX_BORROW_CAP, | ||||
|   supplyCap: MAX_SUPPLY_CAP, | ||||
|   borrowCap: '0', | ||||
|   supplyCap: '0', | ||||
| }; | ||||
| 
 | ||||
| export const strategyYFI: IReserveParams = { | ||||
|  | @ -276,8 +275,8 @@ export const strategyYFI: IReserveParams = { | |||
|   reserveDecimals: '18', | ||||
|   aTokenImpl: eContractid.AToken, | ||||
|   reserveFactor: '2000', | ||||
|   borrowCap: MAX_BORROW_CAP, | ||||
|   supplyCap: MAX_SUPPLY_CAP, | ||||
|   borrowCap: '0', | ||||
|   supplyCap: '0', | ||||
| }; | ||||
| 
 | ||||
| export const strategyZRX: IReserveParams = { | ||||
|  | @ -290,8 +289,8 @@ export const strategyZRX: IReserveParams = { | |||
|   reserveDecimals: '18', | ||||
|   aTokenImpl: eContractid.AToken, | ||||
|   reserveFactor: '2000', | ||||
|   borrowCap: MAX_BORROW_CAP, | ||||
|   supplyCap: MAX_SUPPLY_CAP, | ||||
|   borrowCap: '0', | ||||
|   supplyCap: '0', | ||||
| }; | ||||
| 
 | ||||
| export const strategyXSUSHI: IReserveParams = { | ||||
|  | @ -304,6 +303,6 @@ export const strategyXSUSHI: IReserveParams = { | |||
|   reserveDecimals: '18', | ||||
|   aTokenImpl: eContractid.AToken, | ||||
|   reserveFactor: '3500', | ||||
|   borrowCap: MAX_BORROW_CAP, | ||||
|   supplyCap: MAX_SUPPLY_CAP, | ||||
|   borrowCap: '0', | ||||
|   supplyCap: '0', | ||||
| }; | ||||
|  |  | |||
|  | @ -1,11 +1,5 @@ | |||
| import { MAX_BORROW_CAP, MAX_SUPPLY_CAP } from '../../helpers/constants'; | ||||
| import { eContractid, IReserveParams} from '../../helpers/types'; | ||||
| import { | ||||
|   rateStrategyAmmBase, | ||||
|   rateStrategyStable, | ||||
|   rateStrategyBaseOne, | ||||
| } from './rateStrategies'; | ||||
| 
 | ||||
| import { eContractid, IReserveParams } from '../../helpers/types'; | ||||
| import { rateStrategyAmmBase, rateStrategyStable, rateStrategyBaseOne } from './rateStrategies'; | ||||
| 
 | ||||
| export const strategyWETH: IReserveParams = { | ||||
|   strategy: rateStrategyBaseOne, | ||||
|  | @ -17,8 +11,8 @@ export const strategyWETH: IReserveParams = { | |||
|   reserveDecimals: '18', | ||||
|   aTokenImpl: eContractid.AToken, | ||||
|   reserveFactor: '1000', | ||||
|   borrowCap: MAX_BORROW_CAP, | ||||
|   supplyCap: MAX_SUPPLY_CAP, | ||||
|   borrowCap: '0', | ||||
|   supplyCap: '0', | ||||
| }; | ||||
| 
 | ||||
| export const strategyWBTC: IReserveParams = { | ||||
|  | @ -31,8 +25,8 @@ export const strategyWBTC: IReserveParams = { | |||
|   reserveDecimals: '8', | ||||
|   aTokenImpl: eContractid.AToken, | ||||
|   reserveFactor: '2000', | ||||
|   borrowCap: MAX_BORROW_CAP, | ||||
|   supplyCap: MAX_SUPPLY_CAP, | ||||
|   borrowCap: '0', | ||||
|   supplyCap: '0', | ||||
| }; | ||||
| 
 | ||||
| export const strategyDAI: IReserveParams = { | ||||
|  | @ -45,8 +39,8 @@ export const strategyDAI: IReserveParams = { | |||
|   reserveDecimals: '18', | ||||
|   aTokenImpl: eContractid.AToken, | ||||
|   reserveFactor: '1000', | ||||
|   borrowCap: MAX_BORROW_CAP, | ||||
|   supplyCap: MAX_SUPPLY_CAP, | ||||
|   borrowCap: '0', | ||||
|   supplyCap: '0', | ||||
| }; | ||||
| 
 | ||||
| export const strategyUSDC: IReserveParams = { | ||||
|  | @ -59,8 +53,8 @@ export const strategyUSDC: IReserveParams = { | |||
|   reserveDecimals: '6', | ||||
|   aTokenImpl: eContractid.AToken, | ||||
|   reserveFactor: '1000', | ||||
|   borrowCap: MAX_BORROW_CAP, | ||||
|   supplyCap: MAX_SUPPLY_CAP, | ||||
|   borrowCap: '0', | ||||
|   supplyCap: '0', | ||||
| }; | ||||
| 
 | ||||
| export const strategyUSDT: IReserveParams = { | ||||
|  | @ -73,8 +67,8 @@ export const strategyUSDT: IReserveParams = { | |||
|   reserveDecimals: '6', | ||||
|   aTokenImpl: eContractid.AToken, | ||||
|   reserveFactor: '1000', | ||||
|   borrowCap: MAX_BORROW_CAP, | ||||
|   supplyCap: MAX_SUPPLY_CAP, | ||||
|   borrowCap: '0', | ||||
|   supplyCap: '0', | ||||
| }; | ||||
| 
 | ||||
| export const strategyDAIWETH: IReserveParams = { | ||||
|  | @ -87,8 +81,8 @@ export const strategyDAIWETH: IReserveParams = { | |||
|   reserveDecimals: '18', | ||||
|   aTokenImpl: eContractid.AToken, | ||||
|   reserveFactor: '1000', | ||||
|   borrowCap: MAX_BORROW_CAP, | ||||
|   supplyCap: MAX_SUPPLY_CAP, | ||||
|   borrowCap: '0', | ||||
|   supplyCap: '0', | ||||
| }; | ||||
| 
 | ||||
| export const strategyWBTCWETH: IReserveParams = { | ||||
|  | @ -101,8 +95,8 @@ export const strategyWBTCWETH: IReserveParams = { | |||
|   reserveDecimals: '18', | ||||
|   aTokenImpl: eContractid.AToken, | ||||
|   reserveFactor: '1500', | ||||
|   borrowCap: MAX_BORROW_CAP, | ||||
|   supplyCap: MAX_SUPPLY_CAP, | ||||
|   borrowCap: '0', | ||||
|   supplyCap: '0', | ||||
| }; | ||||
| 
 | ||||
| export const strategyAAVEWETH: IReserveParams = { | ||||
|  | @ -115,8 +109,8 @@ export const strategyAAVEWETH: IReserveParams = { | |||
|   reserveDecimals: '18', | ||||
|   aTokenImpl: eContractid.AToken, | ||||
|   reserveFactor: '500', | ||||
|   borrowCap: MAX_BORROW_CAP, | ||||
|   supplyCap: MAX_SUPPLY_CAP, | ||||
|   borrowCap: '0', | ||||
|   supplyCap: '0', | ||||
| }; | ||||
| 
 | ||||
| export const strategyBATWETH: IReserveParams = { | ||||
|  | @ -129,8 +123,8 @@ export const strategyBATWETH: IReserveParams = { | |||
|   reserveDecimals: '18', | ||||
|   aTokenImpl: eContractid.AToken, | ||||
|   reserveFactor: '1500', | ||||
|   borrowCap: MAX_BORROW_CAP, | ||||
|   supplyCap: MAX_SUPPLY_CAP, | ||||
|   borrowCap: '0', | ||||
|   supplyCap: '0', | ||||
| }; | ||||
| 
 | ||||
| export const strategyDAIUSDC: IReserveParams = { | ||||
|  | @ -143,8 +137,8 @@ export const strategyDAIUSDC: IReserveParams = { | |||
|   reserveDecimals: '18', | ||||
|   aTokenImpl: eContractid.AToken, | ||||
|   reserveFactor: '1000', | ||||
|   borrowCap: MAX_BORROW_CAP, | ||||
|   supplyCap: MAX_SUPPLY_CAP, | ||||
|   borrowCap: '0', | ||||
|   supplyCap: '0', | ||||
| }; | ||||
| 
 | ||||
| export const strategyCRVWETH: IReserveParams = { | ||||
|  | @ -157,8 +151,8 @@ export const strategyCRVWETH: IReserveParams = { | |||
|   reserveDecimals: '18', | ||||
|   aTokenImpl: eContractid.AToken, | ||||
|   reserveFactor: '1500', | ||||
|   borrowCap: MAX_BORROW_CAP, | ||||
|   supplyCap: MAX_SUPPLY_CAP, | ||||
|   borrowCap: '0', | ||||
|   supplyCap: '0', | ||||
| }; | ||||
| 
 | ||||
| export const strategyLINKWETH: IReserveParams = { | ||||
|  | @ -171,8 +165,8 @@ export const strategyLINKWETH: IReserveParams = { | |||
|   reserveDecimals: '18', | ||||
|   aTokenImpl: eContractid.AToken, | ||||
|   reserveFactor: '1500', | ||||
|   borrowCap: MAX_BORROW_CAP, | ||||
|   supplyCap: MAX_SUPPLY_CAP, | ||||
|   borrowCap: '0', | ||||
|   supplyCap: '0', | ||||
| }; | ||||
| 
 | ||||
| export const strategyMKRWETH: IReserveParams = { | ||||
|  | @ -185,8 +179,8 @@ export const strategyMKRWETH: IReserveParams = { | |||
|   reserveDecimals: '18', | ||||
|   aTokenImpl: eContractid.AToken, | ||||
|   reserveFactor: '1500', | ||||
|   borrowCap: MAX_BORROW_CAP, | ||||
|   supplyCap: MAX_SUPPLY_CAP, | ||||
|   borrowCap: '0', | ||||
|   supplyCap: '0', | ||||
| }; | ||||
| 
 | ||||
| export const strategyRENWETH: IReserveParams = { | ||||
|  | @ -199,8 +193,8 @@ export const strategyRENWETH: IReserveParams = { | |||
|   reserveDecimals: '18', | ||||
|   aTokenImpl: eContractid.AToken, | ||||
|   reserveFactor: '1500', | ||||
|   borrowCap: MAX_BORROW_CAP, | ||||
|   supplyCap: MAX_SUPPLY_CAP, | ||||
|   borrowCap: '0', | ||||
|   supplyCap: '0', | ||||
| }; | ||||
| 
 | ||||
| export const strategySNXWETH: IReserveParams = { | ||||
|  | @ -213,8 +207,8 @@ export const strategySNXWETH: IReserveParams = { | |||
|   reserveDecimals: '18', | ||||
|   aTokenImpl: eContractid.AToken, | ||||
|   reserveFactor: '2000', | ||||
|   borrowCap: MAX_BORROW_CAP, | ||||
|   supplyCap: MAX_SUPPLY_CAP, | ||||
|   borrowCap: '0', | ||||
|   supplyCap: '0', | ||||
| }; | ||||
| 
 | ||||
| export const strategyUNIWETH: IReserveParams = { | ||||
|  | @ -227,8 +221,8 @@ export const strategyUNIWETH: IReserveParams = { | |||
|   reserveDecimals: '18', | ||||
|   aTokenImpl: eContractid.AToken, | ||||
|   reserveFactor: '1500', | ||||
|   borrowCap: MAX_BORROW_CAP, | ||||
|   supplyCap: MAX_SUPPLY_CAP, | ||||
|   borrowCap: '0', | ||||
|   supplyCap: '0', | ||||
| }; | ||||
| 
 | ||||
| export const strategyUSDCWETH: IReserveParams = { | ||||
|  | @ -241,8 +235,8 @@ export const strategyUSDCWETH: IReserveParams = { | |||
|   reserveDecimals: '18', | ||||
|   aTokenImpl: eContractid.AToken, | ||||
|   reserveFactor: '1000', | ||||
|   borrowCap: MAX_BORROW_CAP, | ||||
|   supplyCap: MAX_SUPPLY_CAP, | ||||
|   borrowCap: '0', | ||||
|   supplyCap: '0', | ||||
| }; | ||||
| 
 | ||||
| export const strategyWBTCUSDC: IReserveParams = { | ||||
|  | @ -255,8 +249,8 @@ export const strategyWBTCUSDC: IReserveParams = { | |||
|   reserveDecimals: '18', | ||||
|   aTokenImpl: eContractid.AToken, | ||||
|   reserveFactor: '1500', | ||||
|   borrowCap: MAX_BORROW_CAP, | ||||
|   supplyCap: MAX_SUPPLY_CAP, | ||||
|   borrowCap: '0', | ||||
|   supplyCap: '0', | ||||
| }; | ||||
| 
 | ||||
| export const strategyYFIWETH: IReserveParams = { | ||||
|  | @ -269,8 +263,8 @@ export const strategyYFIWETH: IReserveParams = { | |||
|   reserveDecimals: '18', | ||||
|   aTokenImpl: eContractid.AToken, | ||||
|   reserveFactor: '1500', | ||||
|   borrowCap: MAX_BORROW_CAP, | ||||
|   supplyCap: MAX_SUPPLY_CAP, | ||||
|   borrowCap: '0', | ||||
|   supplyCap: '0', | ||||
| }; | ||||
| 
 | ||||
| export const strategyBALWETH: IReserveParams = { | ||||
|  | @ -283,6 +277,6 @@ export const strategyBALWETH: IReserveParams = { | |||
|   reserveDecimals: '18', | ||||
|   aTokenImpl: eContractid.AToken, | ||||
|   reserveFactor: '1500', | ||||
|   borrowCap: MAX_BORROW_CAP, | ||||
|   supplyCap: MAX_SUPPLY_CAP, | ||||
| } | ||||
|   borrowCap: '0', | ||||
|   supplyCap: '0', | ||||
| }; | ||||
|  |  | |||
|  | @ -1,6 +1,5 @@ | |||
| // import BigNumber from 'bignumber.js';
 | ||||
| // import { oneRay } from '../../helpers/constants';
 | ||||
| import { MAX_BORROW_CAP, MAX_SUPPLY_CAP } from '../../helpers/constants'; | ||||
| import { eContractid, IReserveParams } from '../../helpers/types'; | ||||
| import { | ||||
|   rateStrategyStableTwo, | ||||
|  | @ -21,8 +20,8 @@ export const strategyDAI: IReserveParams = { | |||
|   reserveDecimals: '18', | ||||
|   aTokenImpl: eContractid.AToken, | ||||
|   reserveFactor: '1000', | ||||
|   borrowCap: MAX_BORROW_CAP, | ||||
|   supplyCap: MAX_SUPPLY_CAP, | ||||
|   borrowCap: '0', | ||||
|   supplyCap: '0', | ||||
| }; | ||||
| 
 | ||||
| export const strategyUSDC: IReserveParams = { | ||||
|  | @ -35,8 +34,8 @@ export const strategyUSDC: IReserveParams = { | |||
|   reserveDecimals: '6', | ||||
|   aTokenImpl: eContractid.AToken, | ||||
|   reserveFactor: '1000', | ||||
|   borrowCap: MAX_BORROW_CAP, | ||||
|   supplyCap: MAX_SUPPLY_CAP, | ||||
|   borrowCap: '0', | ||||
|   supplyCap: '0', | ||||
| }; | ||||
| 
 | ||||
| export const strategyUSDT: IReserveParams = { | ||||
|  | @ -49,8 +48,8 @@ export const strategyUSDT: IReserveParams = { | |||
|   reserveDecimals: '6', | ||||
|   aTokenImpl: eContractid.AToken, | ||||
|   reserveFactor: '1000', | ||||
|   borrowCap: MAX_BORROW_CAP, | ||||
|   supplyCap: MAX_SUPPLY_CAP, | ||||
|   borrowCap: '0', | ||||
|   supplyCap: '0', | ||||
| }; | ||||
| 
 | ||||
| export const strategyWETH: IReserveParams = { | ||||
|  | @ -63,8 +62,8 @@ export const strategyWETH: IReserveParams = { | |||
|   reserveDecimals: '18', | ||||
|   aTokenImpl: eContractid.AToken, | ||||
|   reserveFactor: '1000', | ||||
|   borrowCap: MAX_BORROW_CAP, | ||||
|   supplyCap: MAX_SUPPLY_CAP, | ||||
|   borrowCap: '0', | ||||
|   supplyCap: '0', | ||||
| }; | ||||
| 
 | ||||
| export const strategyWBTC: IReserveParams = { | ||||
|  | @ -77,8 +76,8 @@ export const strategyWBTC: IReserveParams = { | |||
|   reserveDecimals: '8', | ||||
|   aTokenImpl: eContractid.AToken, | ||||
|   reserveFactor: '2000', | ||||
|   borrowCap: MAX_BORROW_CAP, | ||||
|   supplyCap: MAX_SUPPLY_CAP, | ||||
|   borrowCap: '0', | ||||
|   supplyCap: '0', | ||||
| }; | ||||
| 
 | ||||
| export const strategyMATIC: IReserveParams = { | ||||
|  | @ -90,8 +89,8 @@ export const strategyMATIC: IReserveParams = { | |||
|   stableBorrowRateEnabled: false, | ||||
|   reserveDecimals: '18', | ||||
|   aTokenImpl: eContractid.AToken, | ||||
|   borrowCap: MAX_BORROW_CAP, | ||||
|   supplyCap: MAX_SUPPLY_CAP, | ||||
|   borrowCap: '0', | ||||
|   supplyCap: '0', | ||||
|   reserveFactor: '2000', | ||||
| }; | ||||
| 
 | ||||
|  | @ -104,7 +103,7 @@ export const strategyAAVE: IReserveParams = { | |||
|   stableBorrowRateEnabled: false, | ||||
|   reserveDecimals: '18', | ||||
|   aTokenImpl: eContractid.AToken, | ||||
|   borrowCap: MAX_BORROW_CAP, | ||||
|   supplyCap: MAX_SUPPLY_CAP, | ||||
|   borrowCap: '0', | ||||
|   supplyCap: '0', | ||||
|   reserveFactor: '0', | ||||
| }; | ||||
|  |  | |||
|  | @ -16,10 +16,9 @@ const { expect } = require('chai'); | |||
| makeSuite('Borrow Cap', (testEnv: TestEnv) => { | ||||
|   const { VL_BORROW_CAP_EXCEEDED, RC_INVALID_BORROW_CAP } = ProtocolErrors; | ||||
| 
 | ||||
|   const miliUnitToPrecision = async (token: WETH9Mocked | MintableERC20, nb: string) => | ||||
|   const unitParse = async (token: WETH9Mocked | MintableERC20, nb: string) => | ||||
|     BigNumber.from(nb).mul(BigNumber.from('10').pow((await token.decimals()) - 3)); | ||||
| 
 | ||||
|   it('Sets the borrow cap for Weth and DAI to 0 Units, deposits weth', async () => { | ||||
|   it('Reserves should initially have borrow cap disabled (borrowCap = 0)', async () => { | ||||
|     const { | ||||
|       configurator, | ||||
|       weth, | ||||
|  | @ -30,61 +29,111 @@ makeSuite('Borrow Cap', (testEnv: TestEnv) => { | |||
|       helpersContract, | ||||
|       users: [user1], | ||||
|     } = testEnv; | ||||
|     const mintedMiliAmount = '1000000000000'; | ||||
|     const daiMinted = await miliUnitToPrecision(dai, mintedMiliAmount); | ||||
|     const wethMinted = await miliUnitToPrecision(weth, mintedMiliAmount); | ||||
|     const usdcMinted = await miliUnitToPrecision(usdc, mintedMiliAmount); | ||||
|     await dai.mint(daiMinted); | ||||
|     await weth.mint(wethMinted); | ||||
|     await usdc.mint(usdcMinted); | ||||
|     await dai.connect(user1.signer).mint(daiMinted); | ||||
|     await weth.connect(user1.signer).mint(wethMinted); | ||||
|     await usdc.connect(user1.signer).mint(usdcMinted); | ||||
| 
 | ||||
|     const mintedAmount = parseEther('1000000000'); | ||||
|     // minting for main user
 | ||||
|     await dai.mint(mintedAmount); | ||||
|     await weth.mint(mintedAmount); | ||||
|     await usdc.mint(mintedAmount); | ||||
|     // minting for lp user
 | ||||
|     await dai.connect(user1.signer).mint(mintedAmount); | ||||
|     await weth.connect(user1.signer).mint(mintedAmount); | ||||
|     await usdc.connect(user1.signer).mint(mintedAmount); | ||||
| 
 | ||||
|     await dai.approve(pool.address, MAX_UINT_AMOUNT); | ||||
|     await weth.approve(pool.address, MAX_UINT_AMOUNT); | ||||
|     await usdc.approve(pool.address, MAX_UINT_AMOUNT); | ||||
|     await dai.connect(user1.signer).approve(pool.address, MAX_UINT_AMOUNT); | ||||
|     await weth.connect(user1.signer).approve(pool.address, MAX_UINT_AMOUNT); | ||||
|     await usdc.connect(user1.signer).approve(pool.address, MAX_UINT_AMOUNT); | ||||
| 
 | ||||
|     let usdcBorrowCap = (await helpersContract.getReserveCaps(usdc.address)).borrowCap; | ||||
|     let daiBorrowCap = (await helpersContract.getReserveCaps(dai.address)).borrowCap; | ||||
|     expect(usdcBorrowCap).to.be.equal(MAX_BORROW_CAP); | ||||
|     expect(daiBorrowCap).to.be.equal(MAX_BORROW_CAP); | ||||
|     let wethBorrowCap = (await helpersContract.getReserveCaps(weth.address)).borrowCap; | ||||
|     let wethSupplyCap = (await helpersContract.getReserveCaps(weth.address)).supplyCap; | ||||
|     expect(wethBorrowCap).to.be.equal(MAX_BORROW_CAP); | ||||
|     expect(wethSupplyCap).to.be.equal(MAX_SUPPLY_CAP); | ||||
| 
 | ||||
|     const depositedMiliAmount = (1e9).toString(); | ||||
|     expect(usdcBorrowCap).to.be.equal('0'); | ||||
|     expect(daiBorrowCap).to.be.equal('0'); | ||||
|   }); | ||||
|   it('Should be able to borrow 10 Dai stable, 10 USDC variable', async () => { | ||||
|     const { | ||||
|       configurator, | ||||
|       weth, | ||||
|       pool, | ||||
|       dai, | ||||
|       usdc, | ||||
|       deployer, | ||||
|       helpersContract, | ||||
|       users: [user1], | ||||
|     } = testEnv; | ||||
| 
 | ||||
|     await configurator.setBorrowCap(usdc.address, 0); | ||||
|     await configurator.setBorrowCap(dai.address, 0); | ||||
|     const suppliedAmount = 1000; | ||||
|     const precisionSuppliedAmount = (suppliedAmount * 1000).toString(); | ||||
| 
 | ||||
|     usdcBorrowCap = (await helpersContract.getReserveCaps(usdc.address)).borrowCap; | ||||
|     daiBorrowCap = (await helpersContract.getReserveCaps(dai.address)).borrowCap; | ||||
| 
 | ||||
|     expect(usdcBorrowCap).to.be.equal(0); | ||||
|     expect(daiBorrowCap).to.be.equal(0); | ||||
|     const borrowedAmount = 10; | ||||
|     const precisionBorrowedAmount = (borrowedAmount * 1000).toString(); | ||||
| 
 | ||||
|     // deposit collateral
 | ||||
|     await pool.deposit( | ||||
|       weth.address, | ||||
|       await miliUnitToPrecision(weth, depositedMiliAmount), | ||||
|       await unitParse(weth, precisionSuppliedAmount), | ||||
|       deployer.address, | ||||
|       0 | ||||
|     ); | ||||
|     await pool.connect(user1.signer).deposit(weth.address, wethMinted, user1.address, 0); | ||||
|     await pool.connect(user1.signer).deposit(dai.address, daiMinted, user1.address, 0); | ||||
|     await pool.connect(user1.signer).deposit(usdc.address, usdcMinted, user1.address, 0); | ||||
|     // user 1 deposit more dai and usdc to be able to borrow
 | ||||
|     await pool | ||||
|       .connect(user1.signer) | ||||
|       .deposit(dai.address, await unitParse(dai, precisionSuppliedAmount), user1.address, 0); | ||||
| 
 | ||||
|     await pool | ||||
|       .connect(user1.signer) | ||||
|       .deposit(usdc.address, await unitParse(usdc, precisionSuppliedAmount), user1.address, 0); | ||||
| 
 | ||||
|     // borrow
 | ||||
|     await pool.borrow( | ||||
|       usdc.address, | ||||
|       await unitParse(usdc, precisionBorrowedAmount), | ||||
|       2, | ||||
|       0, | ||||
|       deployer.address | ||||
|     ); | ||||
| 
 | ||||
|     await pool.borrow( | ||||
|       dai.address, | ||||
|       await unitParse(dai, precisionBorrowedAmount), | ||||
|       1, | ||||
|       0, | ||||
|       deployer.address | ||||
|     ); | ||||
|   }); | ||||
|   it('Sets the borrow cap for Weth and DAI to 10 Units', async () => { | ||||
|     const { | ||||
|       configurator, | ||||
|       weth, | ||||
|       pool, | ||||
|       dai, | ||||
|       usdc, | ||||
|       deployer, | ||||
|       helpersContract, | ||||
|       users: [user1], | ||||
|     } = testEnv; | ||||
| 
 | ||||
|     await configurator.setBorrowCap(usdc.address, 10); | ||||
|     await configurator.setBorrowCap(dai.address, 10); | ||||
| 
 | ||||
|     const usdcBorrowCap = (await helpersContract.getReserveCaps(usdc.address)).borrowCap; | ||||
|     const daiBorrowCap = (await helpersContract.getReserveCaps(dai.address)).borrowCap; | ||||
| 
 | ||||
|     expect(usdcBorrowCap).to.be.equal(10); | ||||
|     expect(daiBorrowCap).to.be.equal(10); | ||||
|   }); | ||||
|   it('should fail to borrow any dai or usdc, stable or variable', async () => { | ||||
|     const { usdc, pool, dai, deployer, helpersContract } = testEnv; | ||||
|     const borrowedAmount = 10; | ||||
|     const borrowedMilimount = (borrowedAmount * 1000).toString(); | ||||
|     const precisionBorrowedAmount = (borrowedAmount * 1000).toString(); | ||||
| 
 | ||||
|     await expect( | ||||
|       pool.borrow( | ||||
|         usdc.address, | ||||
|         await miliUnitToPrecision(usdc, borrowedMilimount), | ||||
|         await unitParse(usdc, precisionBorrowedAmount), | ||||
|         2, | ||||
|         0, | ||||
|         deployer.address | ||||
|  | @ -94,7 +143,7 @@ makeSuite('Borrow Cap', (testEnv: TestEnv) => { | |||
|     await expect( | ||||
|       pool.borrow( | ||||
|         dai.address, | ||||
|         await miliUnitToPrecision(dai, borrowedMilimount), | ||||
|         await unitParse(dai, precisionBorrowedAmount), | ||||
|         2, | ||||
|         0, | ||||
|         deployer.address | ||||
|  | @ -104,11 +153,6 @@ makeSuite('Borrow Cap', (testEnv: TestEnv) => { | |||
|   it('Should fail to set the borrow cap for usdc and DAI to max cap + 1 Units', async () => { | ||||
|     const { configurator, usdc, pool, dai, deployer, helpersContract } = testEnv; | ||||
|     const newCap = Number(MAX_BORROW_CAP) + 1; | ||||
|     let usdcBorrowCap = (await helpersContract.getReserveCaps(usdc.address)).borrowCap; | ||||
|     let daiBorrowCap = (await helpersContract.getReserveCaps(dai.address)).borrowCap; | ||||
| 
 | ||||
|     expect(usdcBorrowCap).to.be.equal(0); | ||||
|     expect(daiBorrowCap).to.be.equal(0); | ||||
| 
 | ||||
|     await expect(configurator.setBorrowCap(usdc.address, newCap)).to.be.revertedWith( | ||||
|       RC_INVALID_BORROW_CAP | ||||
|  | @ -116,24 +160,16 @@ makeSuite('Borrow Cap', (testEnv: TestEnv) => { | |||
|     await expect(configurator.setBorrowCap(dai.address, newCap)).to.be.revertedWith( | ||||
|       RC_INVALID_BORROW_CAP | ||||
|     ); | ||||
| 
 | ||||
|     usdcBorrowCap = (await helpersContract.getReserveCaps(usdc.address)).borrowCap; | ||||
|     daiBorrowCap = (await helpersContract.getReserveCaps(dai.address)).borrowCap; | ||||
|   }); | ||||
|   it('Sets the borrow cap for usdc and DAI to 110 Units', async () => { | ||||
|   it('Sets the borrow cap for usdc and DAI to 120 Units', async () => { | ||||
|     const { configurator, usdc, pool, dai, deployer, helpersContract } = testEnv; | ||||
|     const newCap = '110'; | ||||
|     let usdcBorrowCap = (await helpersContract.getReserveCaps(usdc.address)).borrowCap; | ||||
|     let daiBorrowCap = (await helpersContract.getReserveCaps(dai.address)).borrowCap; | ||||
| 
 | ||||
|     expect(usdcBorrowCap).to.be.equal(0); | ||||
|     expect(daiBorrowCap).to.be.equal(0); | ||||
|     const newCap = '120'; | ||||
| 
 | ||||
|     await configurator.setBorrowCap(usdc.address, newCap); | ||||
|     await configurator.setBorrowCap(dai.address, newCap); | ||||
| 
 | ||||
|     usdcBorrowCap = (await helpersContract.getReserveCaps(usdc.address)).borrowCap; | ||||
|     daiBorrowCap = (await helpersContract.getReserveCaps(dai.address)).borrowCap; | ||||
|     const usdcBorrowCap = (await helpersContract.getReserveCaps(usdc.address)).borrowCap; | ||||
|     const daiBorrowCap = (await helpersContract.getReserveCaps(dai.address)).borrowCap; | ||||
| 
 | ||||
|     expect(usdcBorrowCap).to.be.equal(newCap); | ||||
|     expect(daiBorrowCap).to.be.equal(newCap); | ||||
|  | @ -141,10 +177,10 @@ makeSuite('Borrow Cap', (testEnv: TestEnv) => { | |||
|   it('Should succeed to borrow 10 stable dai and 10 variable usdc', async () => { | ||||
|     const { usdc, pool, dai, deployer, helpersContract } = testEnv; | ||||
|     const borrowedAmount = 10; | ||||
|     const borrowedMilimount = (borrowedAmount * 1000).toString(); | ||||
|     const precisionBorrowedAmount = (borrowedAmount * 1000).toString(); | ||||
|     await pool.borrow( | ||||
|       usdc.address, | ||||
|       await miliUnitToPrecision(usdc, borrowedMilimount), | ||||
|       await unitParse(usdc, precisionBorrowedAmount), | ||||
|       2, | ||||
|       0, | ||||
|       deployer.address | ||||
|  | @ -152,7 +188,7 @@ makeSuite('Borrow Cap', (testEnv: TestEnv) => { | |||
| 
 | ||||
|     await pool.borrow( | ||||
|       dai.address, | ||||
|       await miliUnitToPrecision(dai, borrowedMilimount), | ||||
|       await unitParse(dai, precisionBorrowedAmount), | ||||
|       1, | ||||
|       0, | ||||
|       deployer.address | ||||
|  | @ -161,12 +197,12 @@ makeSuite('Borrow Cap', (testEnv: TestEnv) => { | |||
|   it('should fail to borrow 100 variable dai and 100 stable usdc', async () => { | ||||
|     const { usdc, pool, dai, deployer, helpersContract } = testEnv; | ||||
|     const borrowedAmount = 100; | ||||
|     const borrowedMilimount = (borrowedAmount * 1000).toString(); | ||||
|     const precisionBorrowedAmount = (borrowedAmount * 1000).toString(); | ||||
| 
 | ||||
|     await expect( | ||||
|       pool.borrow( | ||||
|         usdc.address, | ||||
|         await miliUnitToPrecision(usdc, borrowedMilimount), | ||||
|         await unitParse(usdc, precisionBorrowedAmount), | ||||
|         1, | ||||
|         0, | ||||
|         deployer.address | ||||
|  | @ -176,7 +212,7 @@ makeSuite('Borrow Cap', (testEnv: TestEnv) => { | |||
|     await expect( | ||||
|       pool.borrow( | ||||
|         dai.address, | ||||
|         await miliUnitToPrecision(dai, borrowedMilimount), | ||||
|         await unitParse(dai, precisionBorrowedAmount), | ||||
|         2, | ||||
|         0, | ||||
|         deployer.address | ||||
|  | @ -186,10 +222,10 @@ makeSuite('Borrow Cap', (testEnv: TestEnv) => { | |||
|   it('Should succeed to borrow 99 variable dai and 99 stable usdc', async () => { | ||||
|     const { usdc, pool, dai, deployer, helpersContract } = testEnv; | ||||
|     const borrowedAmount = 99; | ||||
|     const borrowedMilimount = (borrowedAmount * 1000).toString(); | ||||
|     const precisionBorrowedAmount = (borrowedAmount * 1000).toString(); | ||||
|     await pool.borrow( | ||||
|       usdc.address, | ||||
|       await miliUnitToPrecision(usdc, borrowedMilimount), | ||||
|       await unitParse(usdc, precisionBorrowedAmount), | ||||
|       2, | ||||
|       0, | ||||
|       deployer.address | ||||
|  | @ -197,7 +233,7 @@ makeSuite('Borrow Cap', (testEnv: TestEnv) => { | |||
| 
 | ||||
|     await pool.borrow( | ||||
|       dai.address, | ||||
|       await miliUnitToPrecision(dai, borrowedMilimount), | ||||
|       await unitParse(dai, precisionBorrowedAmount), | ||||
|       1, | ||||
|       0, | ||||
|       deployer.address | ||||
|  | @ -221,11 +257,11 @@ makeSuite('Borrow Cap', (testEnv: TestEnv) => { | |||
|   it('should succeed to borrow 100 variable dai and 100 stable usdc', async () => { | ||||
|     const { usdc, pool, dai, deployer, helpersContract } = testEnv; | ||||
|     const borrowedAmount = 100; | ||||
|     const borrowedMilimount = (borrowedAmount * 1000).toString(); | ||||
|     const precisionBorrowedAmount = (borrowedAmount * 1000).toString(); | ||||
| 
 | ||||
|     await pool.borrow( | ||||
|       usdc.address, | ||||
|       await miliUnitToPrecision(usdc, borrowedMilimount), | ||||
|       await unitParse(usdc, precisionBorrowedAmount), | ||||
|       1, | ||||
|       0, | ||||
|       deployer.address | ||||
|  | @ -233,7 +269,7 @@ makeSuite('Borrow Cap', (testEnv: TestEnv) => { | |||
| 
 | ||||
|     await pool.borrow( | ||||
|       dai.address, | ||||
|       await miliUnitToPrecision(dai, borrowedMilimount), | ||||
|       await unitParse(dai, precisionBorrowedAmount), | ||||
|       2, | ||||
|       0, | ||||
|       deployer.address | ||||
|  | @ -257,12 +293,12 @@ makeSuite('Borrow Cap', (testEnv: TestEnv) => { | |||
|   it('should fail to borrow 100 variable dai and 100 stable usdc', async () => { | ||||
|     const { usdc, pool, dai, deployer, helpersContract } = testEnv; | ||||
|     const borrowedAmount = 100; | ||||
|     const borrowedMilimount = (borrowedAmount * 1000).toString(); | ||||
|     const precisionBorrowedAmount = (borrowedAmount * 1000).toString(); | ||||
| 
 | ||||
|     await expect( | ||||
|       pool.borrow( | ||||
|         usdc.address, | ||||
|         await miliUnitToPrecision(usdc, borrowedMilimount), | ||||
|         await unitParse(usdc, precisionBorrowedAmount), | ||||
|         1, | ||||
|         0, | ||||
|         deployer.address | ||||
|  | @ -272,7 +308,7 @@ makeSuite('Borrow Cap', (testEnv: TestEnv) => { | |||
|     await expect( | ||||
|       pool.borrow( | ||||
|         dai.address, | ||||
|         await miliUnitToPrecision(dai, borrowedMilimount), | ||||
|         await unitParse(dai, precisionBorrowedAmount), | ||||
|         2, | ||||
|         0, | ||||
|         deployer.address | ||||
|  | @ -297,11 +333,11 @@ makeSuite('Borrow Cap', (testEnv: TestEnv) => { | |||
|   it('should succeed to borrow 100 variable dai and 100 stable usdc', async () => { | ||||
|     const { usdc, pool, dai, deployer, helpersContract } = testEnv; | ||||
|     const borrowedAmount = 100; | ||||
|     const borrowedMilimount = (borrowedAmount * 1000).toString(); | ||||
|     const precisionBorrowedAmount = (borrowedAmount * 1000).toString(); | ||||
| 
 | ||||
|     await pool.borrow( | ||||
|       usdc.address, | ||||
|       await miliUnitToPrecision(usdc, borrowedMilimount), | ||||
|       await unitParse(usdc, precisionBorrowedAmount), | ||||
|       1, | ||||
|       0, | ||||
|       deployer.address | ||||
|  | @ -309,7 +345,7 @@ makeSuite('Borrow Cap', (testEnv: TestEnv) => { | |||
| 
 | ||||
|     await pool.borrow( | ||||
|       dai.address, | ||||
|       await miliUnitToPrecision(dai, borrowedMilimount), | ||||
|       await unitParse(dai, precisionBorrowedAmount), | ||||
|       2, | ||||
|       0, | ||||
|       deployer.address | ||||
|  |  | |||
|  | @ -173,7 +173,7 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => { | |||
| 
 | ||||
|   it('Activates the ETH reserve for borrowing', async () => { | ||||
|     const { configurator, weth, helpersContract } = testEnv; | ||||
|     await configurator.enableBorrowingOnReserve(weth.address, MAX_BORROW_CAP, true); | ||||
|     await configurator.enableBorrowingOnReserve(weth.address, '0', true); | ||||
|     const { variableBorrowIndex } = await helpersContract.getReserveData(weth.address); | ||||
| 
 | ||||
|     const { | ||||
|  | @ -215,9 +215,7 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => { | |||
|   it('Check the onlyAaveAdmin on enableBorrowingOnReserve ', async () => { | ||||
|     const { configurator, users, weth } = testEnv; | ||||
|     await expect( | ||||
|       configurator | ||||
|         .connect(users[2].signer) | ||||
|         .enableBorrowingOnReserve(weth.address, MAX_BORROW_CAP, true), | ||||
|       configurator.connect(users[2].signer).enableBorrowingOnReserve(weth.address, '0', true), | ||||
|       CALLER_NOT_POOL_ADMIN | ||||
|     ).to.be.revertedWith(CALLER_NOT_POOL_ADMIN); | ||||
|   }); | ||||
|  |  | |||
|  | @ -15,10 +15,10 @@ const { expect } = require('chai'); | |||
| makeSuite('supply Cap', (testEnv: TestEnv) => { | ||||
|   const { VL_SUPPLY_CAP_EXCEEDED, RC_INVALID_SUPPLY_CAP } = ProtocolErrors; | ||||
| 
 | ||||
|   const miliUnitToPrecision = async (token: WETH9Mocked | MintableERC20, nb: string) => | ||||
|   const unitParse = async (token: WETH9Mocked | MintableERC20, nb: string) => | ||||
|     BigNumber.from(nb).mul(BigNumber.from('10').pow((await token.decimals()) - 3)); | ||||
| 
 | ||||
|   it('Sets the supply cap for Weth and DAI to 0 Units, deposits weth', async () => { | ||||
|   it('Reserves should initially have supply cap disabled (supplyCap = 0)', async () => { | ||||
|     const { | ||||
|       configurator, | ||||
|       weth, | ||||
|  | @ -29,61 +29,101 @@ makeSuite('supply Cap', (testEnv: TestEnv) => { | |||
|       helpersContract, | ||||
|       users: [user1], | ||||
|     } = testEnv; | ||||
| 
 | ||||
|     const mintedAmount = parseEther('1000000000'); | ||||
|     await dai.mint(mintedAmount); | ||||
|     await weth.mint(mintedAmount); | ||||
|     await usdc.mint(mintedAmount); | ||||
| 
 | ||||
|     await dai.approve(pool.address, MAX_UINT_AMOUNT); | ||||
|     await weth.approve(pool.address, MAX_UINT_AMOUNT); | ||||
|     await usdc.approve(pool.address, MAX_UINT_AMOUNT); | ||||
|     let usdcsupplyCap = (await helpersContract.getReserveCaps(usdc.address)).supplyCap; | ||||
|     let daisupplyCap = (await helpersContract.getReserveCaps(dai.address)).supplyCap; | ||||
| 
 | ||||
|     expect(usdcsupplyCap).to.be.equal(MAX_SUPPLY_CAP); | ||||
|     expect(daisupplyCap).to.be.equal(MAX_SUPPLY_CAP); | ||||
|     let usdcSupplyCap = (await helpersContract.getReserveCaps(usdc.address)).supplyCap; | ||||
|     let daiSupplyCap = (await helpersContract.getReserveCaps(dai.address)).supplyCap; | ||||
| 
 | ||||
|     const depositedMiliAmount = (1e9).toString(); | ||||
|     expect(usdcSupplyCap).to.be.equal('0'); | ||||
|     expect(daiSupplyCap).to.be.equal('0'); | ||||
|   }); | ||||
|   it('Should be able to deposit 1000 Dai, 1000 USDC and 1000 Weth', async () => { | ||||
|     const { | ||||
|       configurator, | ||||
|       weth, | ||||
|       pool, | ||||
|       dai, | ||||
|       usdc, | ||||
|       deployer, | ||||
|       helpersContract, | ||||
|       users: [user1], | ||||
|     } = testEnv; | ||||
| 
 | ||||
|     await configurator.setSupplyCap(usdc.address, 0); | ||||
|     await configurator.setSupplyCap(dai.address, 0); | ||||
|     const suppliedAmount = 1000; | ||||
|     const precisionSuppliedAmount = (suppliedAmount * 1000).toString(); | ||||
| 
 | ||||
|     usdcsupplyCap = (await helpersContract.getReserveCaps(usdc.address)).supplyCap; | ||||
|     daisupplyCap = (await helpersContract.getReserveCaps(dai.address)).supplyCap; | ||||
|     await pool.deposit( | ||||
|       usdc.address, | ||||
|       await unitParse(usdc, precisionSuppliedAmount), | ||||
|       deployer.address, | ||||
|       0 | ||||
|     ); | ||||
| 
 | ||||
|     expect(usdcsupplyCap).to.be.equal(0); | ||||
|     expect(daisupplyCap).to.be.equal(0); | ||||
|     await pool.deposit( | ||||
|       dai.address, | ||||
|       await unitParse(dai, precisionSuppliedAmount), | ||||
|       deployer.address, | ||||
|       0 | ||||
|     ); | ||||
|     await pool.deposit( | ||||
|       weth.address, | ||||
|       await unitParse(weth, precisionSuppliedAmount), | ||||
|       deployer.address, | ||||
|       0 | ||||
|     ); | ||||
|   }); | ||||
|   it('Sets the supply cap for Weth and DAI to 1000 Unit', async () => { | ||||
|     const { | ||||
|       configurator, | ||||
|       weth, | ||||
|       pool, | ||||
|       dai, | ||||
|       usdc, | ||||
|       deployer, | ||||
|       helpersContract, | ||||
|       users: [user1], | ||||
|     } = testEnv; | ||||
| 
 | ||||
|     const newCap = '1000'; | ||||
| 
 | ||||
|     await configurator.setSupplyCap(usdc.address, newCap); | ||||
|     await configurator.setSupplyCap(dai.address, newCap); | ||||
| 
 | ||||
|     const usdcSupplyCap = (await helpersContract.getReserveCaps(usdc.address)).supplyCap; | ||||
|     const daiSupplyCap = (await helpersContract.getReserveCaps(dai.address)).supplyCap; | ||||
| 
 | ||||
|     expect(usdcSupplyCap).to.be.equal(newCap); | ||||
|     expect(daiSupplyCap).to.be.equal(newCap); | ||||
|   }); | ||||
|   it('should fail to supply any dai or usdc', async () => { | ||||
|     const { usdc, pool, dai, deployer, helpersContract } = testEnv; | ||||
|     const suppliedAmount = 10; | ||||
|     const suppliedMilimount = (suppliedAmount * 1000).toString(); | ||||
|     const precisionSuppliedAmount = (suppliedAmount * 1000).toString(); | ||||
| 
 | ||||
|     await expect( | ||||
|       pool.deposit( | ||||
|         usdc.address, | ||||
|         await miliUnitToPrecision(usdc, suppliedMilimount), | ||||
|         await unitParse(usdc, precisionSuppliedAmount), | ||||
|         deployer.address, | ||||
|         0 | ||||
|       ) | ||||
|     ).to.be.revertedWith(VL_SUPPLY_CAP_EXCEEDED); | ||||
| 
 | ||||
|     await expect( | ||||
|       pool.deposit( | ||||
|         dai.address, | ||||
|         await miliUnitToPrecision(dai, suppliedMilimount), | ||||
|         deployer.address, | ||||
|         0 | ||||
|       ) | ||||
|       pool.deposit(dai.address, await unitParse(dai, precisionSuppliedAmount), deployer.address, 0) | ||||
|     ).to.be.revertedWith(VL_SUPPLY_CAP_EXCEEDED); | ||||
|   }); | ||||
|   it('Should fail to set the supply cap for usdc and DAI to max cap + 1 Units', async () => { | ||||
|     const { configurator, usdc, pool, dai, deployer, helpersContract } = testEnv; | ||||
|     const newCap = Number(MAX_SUPPLY_CAP) + 1; | ||||
|     let usdcsupplyCap = (await helpersContract.getReserveCaps(usdc.address)).supplyCap; | ||||
|     let daisupplyCap = (await helpersContract.getReserveCaps(dai.address)).supplyCap; | ||||
| 
 | ||||
|     expect(usdcsupplyCap).to.be.equal(0); | ||||
|     expect(daisupplyCap).to.be.equal(0); | ||||
| 
 | ||||
|     await expect(configurator.setSupplyCap(usdc.address, newCap)).to.be.revertedWith( | ||||
|       RC_INVALID_SUPPLY_CAP | ||||
|  | @ -92,38 +132,33 @@ makeSuite('supply Cap', (testEnv: TestEnv) => { | |||
|       RC_INVALID_SUPPLY_CAP | ||||
|     ); | ||||
|   }); | ||||
|   it('Sets the supply cap for usdc and DAI to 110 Units', async () => { | ||||
|   it('Sets the supply cap for usdc and DAI to 1110 Units', async () => { | ||||
|     const { configurator, usdc, pool, dai, deployer, helpersContract } = testEnv; | ||||
|     const newCap = '110'; | ||||
|     let usdcsupplyCap = (await helpersContract.getReserveCaps(usdc.address)).supplyCap; | ||||
|     let daisupplyCap = (await helpersContract.getReserveCaps(dai.address)).supplyCap; | ||||
| 
 | ||||
|     expect(usdcsupplyCap).to.be.equal(0); | ||||
|     expect(daisupplyCap).to.be.equal(0); | ||||
|     const newCap = '1110'; | ||||
| 
 | ||||
|     await configurator.setSupplyCap(usdc.address, newCap); | ||||
|     await configurator.setSupplyCap(dai.address, newCap); | ||||
| 
 | ||||
|     usdcsupplyCap = (await helpersContract.getReserveCaps(usdc.address)).supplyCap; | ||||
|     daisupplyCap = (await helpersContract.getReserveCaps(dai.address)).supplyCap; | ||||
|     const usdcSupplyCap = (await helpersContract.getReserveCaps(usdc.address)).supplyCap; | ||||
|     const daiSupplyCap = (await helpersContract.getReserveCaps(dai.address)).supplyCap; | ||||
| 
 | ||||
|     expect(usdcsupplyCap).to.be.equal(newCap); | ||||
|     expect(daisupplyCap).to.be.equal(newCap); | ||||
|     expect(usdcSupplyCap).to.be.equal(newCap); | ||||
|     expect(daiSupplyCap).to.be.equal(newCap); | ||||
|   }); | ||||
|   it('Should succeed to supply 10  dai and 10  usdc', async () => { | ||||
|     const { usdc, pool, dai, deployer, helpersContract } = testEnv; | ||||
|     const suppliedAmount = 10; | ||||
|     const suppliedMilimount = (suppliedAmount * 1000).toString(); | ||||
|     const precisionSuppliedAmount = (suppliedAmount * 1000).toString(); | ||||
|     await pool.deposit( | ||||
|       usdc.address, | ||||
|       await miliUnitToPrecision(usdc, suppliedMilimount), | ||||
|       await unitParse(usdc, precisionSuppliedAmount), | ||||
|       deployer.address, | ||||
|       0 | ||||
|     ); | ||||
| 
 | ||||
|     await pool.deposit( | ||||
|       dai.address, | ||||
|       await miliUnitToPrecision(dai, suppliedMilimount), | ||||
|       await unitParse(dai, precisionSuppliedAmount), | ||||
|       deployer.address, | ||||
|       0 | ||||
|     ); | ||||
|  | @ -131,144 +166,132 @@ makeSuite('supply Cap', (testEnv: TestEnv) => { | |||
|   it('should fail to supply 100 dai and 100 usdc', async () => { | ||||
|     const { usdc, pool, dai, deployer, helpersContract } = testEnv; | ||||
|     const suppliedAmount = 100; | ||||
|     const suppliedMilimount = (suppliedAmount * 1000).toString(); | ||||
|     const precisionSuppliedAmount = (suppliedAmount * 1000).toString(); | ||||
| 
 | ||||
|     await expect( | ||||
|       pool.deposit( | ||||
|         usdc.address, | ||||
|         await miliUnitToPrecision(usdc, suppliedMilimount), | ||||
|         await unitParse(usdc, precisionSuppliedAmount), | ||||
|         deployer.address, | ||||
|         0 | ||||
|       ) | ||||
|     ).to.be.revertedWith(VL_SUPPLY_CAP_EXCEEDED); | ||||
| 
 | ||||
|     await expect( | ||||
|       pool.deposit( | ||||
|         dai.address, | ||||
|         await miliUnitToPrecision(dai, suppliedMilimount), | ||||
|         deployer.address, | ||||
|         0 | ||||
|       ) | ||||
|       pool.deposit(dai.address, await unitParse(dai, precisionSuppliedAmount), deployer.address, 0) | ||||
|     ).to.be.revertedWith(VL_SUPPLY_CAP_EXCEEDED); | ||||
|   }); | ||||
|   it('Should succeed to supply 99 dai and 99 usdc', async () => { | ||||
|     const { usdc, pool, dai, deployer, helpersContract } = testEnv; | ||||
|     const suppliedAmount = 99; | ||||
|     const suppliedMilimount = (suppliedAmount * 1000).toString(); | ||||
|     const precisionSuppliedAmount = (suppliedAmount * 1000).toString(); | ||||
|     await pool.deposit( | ||||
|       usdc.address, | ||||
|       await miliUnitToPrecision(usdc, suppliedMilimount), | ||||
|       await unitParse(usdc, precisionSuppliedAmount), | ||||
|       deployer.address, | ||||
|       0 | ||||
|     ); | ||||
| 
 | ||||
|     await pool.deposit( | ||||
|       dai.address, | ||||
|       await miliUnitToPrecision(dai, suppliedMilimount), | ||||
|       await unitParse(dai, precisionSuppliedAmount), | ||||
|       deployer.address, | ||||
|       0 | ||||
|     ); | ||||
|   }); | ||||
|   it('Raises the supply cap for usdc and DAI to 1000 Units', async () => { | ||||
|   it('Raises the supply cap for usdc and DAI to 2000 Units', async () => { | ||||
|     const { configurator, usdc, pool, dai, deployer, helpersContract } = testEnv; | ||||
|     const newCap = '1000'; | ||||
|     let usdcsupplyCap = (await helpersContract.getReserveCaps(usdc.address)).supplyCap; | ||||
|     let daisupplyCap = (await helpersContract.getReserveCaps(dai.address)).supplyCap; | ||||
|     const newCap = '2000'; | ||||
| 
 | ||||
|     await configurator.setSupplyCap(usdc.address, newCap); | ||||
|     await configurator.setSupplyCap(dai.address, newCap); | ||||
| 
 | ||||
|     usdcsupplyCap = (await helpersContract.getReserveCaps(usdc.address)).supplyCap; | ||||
|     daisupplyCap = (await helpersContract.getReserveCaps(dai.address)).supplyCap; | ||||
|     const usdcSupplyCap = (await helpersContract.getReserveCaps(usdc.address)).supplyCap; | ||||
|     const daiSupplyCap = (await helpersContract.getReserveCaps(dai.address)).supplyCap; | ||||
| 
 | ||||
|     expect(usdcsupplyCap).to.be.equal(newCap); | ||||
|     expect(daisupplyCap).to.be.equal(newCap); | ||||
|     expect(usdcSupplyCap).to.be.equal(newCap); | ||||
|     expect(daiSupplyCap).to.be.equal(newCap); | ||||
|   }); | ||||
|   it('should succeed to supply 100 dai and 100 usdc', async () => { | ||||
|     const { usdc, pool, dai, deployer, helpersContract } = testEnv; | ||||
|     const suppliedAmount = 100; | ||||
|     const suppliedMilimount = (suppliedAmount * 1000).toString(); | ||||
|     const precisionSuppliedAmount = (suppliedAmount * 1000).toString(); | ||||
|     await pool.deposit( | ||||
|       usdc.address, | ||||
|       await miliUnitToPrecision(usdc, suppliedMilimount), | ||||
|       await unitParse(usdc, precisionSuppliedAmount), | ||||
|       deployer.address, | ||||
|       0 | ||||
|     ); | ||||
| 
 | ||||
|     await pool.deposit( | ||||
|       dai.address, | ||||
|       await miliUnitToPrecision(dai, suppliedMilimount), | ||||
|       await unitParse(dai, precisionSuppliedAmount), | ||||
|       deployer.address, | ||||
|       0 | ||||
|     ); | ||||
|   }); | ||||
|   it('Lowers the supply cap for usdc and DAI to 200 Units', async () => { | ||||
|   it('Lowers the supply cap for usdc and DAI to 1200 Units', async () => { | ||||
|     const { configurator, usdc, pool, dai, deployer, helpersContract } = testEnv; | ||||
|     const newCap = '200'; | ||||
|     let usdcsupplyCap = (await helpersContract.getReserveCaps(usdc.address)).supplyCap; | ||||
|     let daisupplyCap = (await helpersContract.getReserveCaps(dai.address)).supplyCap; | ||||
|     const newCap = '1200'; | ||||
|     let usdcSupplyCap = (await helpersContract.getReserveCaps(usdc.address)).supplyCap; | ||||
|     let daiSupplyCap = (await helpersContract.getReserveCaps(dai.address)).supplyCap; | ||||
| 
 | ||||
|     await configurator.setSupplyCap(usdc.address, newCap); | ||||
|     await configurator.setSupplyCap(dai.address, newCap); | ||||
| 
 | ||||
|     usdcsupplyCap = (await helpersContract.getReserveCaps(usdc.address)).supplyCap; | ||||
|     daisupplyCap = (await helpersContract.getReserveCaps(dai.address)).supplyCap; | ||||
|     usdcSupplyCap = (await helpersContract.getReserveCaps(usdc.address)).supplyCap; | ||||
|     daiSupplyCap = (await helpersContract.getReserveCaps(dai.address)).supplyCap; | ||||
| 
 | ||||
|     expect(usdcsupplyCap).to.be.equal(newCap); | ||||
|     expect(daisupplyCap).to.be.equal(newCap); | ||||
|     expect(usdcSupplyCap).to.be.equal(newCap); | ||||
|     expect(daiSupplyCap).to.be.equal(newCap); | ||||
|   }); | ||||
|   it('should fail to supply 100 dai and 100 usdc', async () => { | ||||
|     const { usdc, pool, dai, deployer, helpersContract } = testEnv; | ||||
|     const suppliedAmount = 100; | ||||
|     const suppliedMilimount = (suppliedAmount * 1000).toString(); | ||||
|     const precisionSuppliedAmount = (suppliedAmount * 1000).toString(); | ||||
| 
 | ||||
|     await expect( | ||||
|       pool.deposit( | ||||
|         usdc.address, | ||||
|         await miliUnitToPrecision(usdc, suppliedMilimount), | ||||
|         await unitParse(usdc, precisionSuppliedAmount), | ||||
|         deployer.address, | ||||
|         0 | ||||
|       ) | ||||
|     ).to.be.revertedWith(VL_SUPPLY_CAP_EXCEEDED); | ||||
| 
 | ||||
|     await expect( | ||||
|       pool.deposit( | ||||
|         dai.address, | ||||
|         await miliUnitToPrecision(dai, suppliedMilimount), | ||||
|         deployer.address, | ||||
|         0 | ||||
|       ) | ||||
|       pool.deposit(dai.address, await unitParse(dai, precisionSuppliedAmount), deployer.address, 0) | ||||
|     ).to.be.revertedWith(VL_SUPPLY_CAP_EXCEEDED); | ||||
|   }); | ||||
|   it('Raises the supply cap for usdc and DAI to max cap Units', async () => { | ||||
|     const { configurator, usdc, pool, dai, deployer, helpersContract } = testEnv; | ||||
|     const newCap = MAX_SUPPLY_CAP; | ||||
|     let usdcsupplyCap = (await helpersContract.getReserveCaps(usdc.address)).supplyCap; | ||||
|     let daisupplyCap = (await helpersContract.getReserveCaps(dai.address)).supplyCap; | ||||
|     let usdcSupplyCap = (await helpersContract.getReserveCaps(usdc.address)).supplyCap; | ||||
|     let daiSupplyCap = (await helpersContract.getReserveCaps(dai.address)).supplyCap; | ||||
| 
 | ||||
|     await configurator.setSupplyCap(usdc.address, newCap); | ||||
|     await configurator.setSupplyCap(dai.address, newCap); | ||||
| 
 | ||||
|     usdcsupplyCap = (await helpersContract.getReserveCaps(usdc.address)).supplyCap; | ||||
|     daisupplyCap = (await helpersContract.getReserveCaps(dai.address)).supplyCap; | ||||
|     usdcSupplyCap = (await helpersContract.getReserveCaps(usdc.address)).supplyCap; | ||||
|     daiSupplyCap = (await helpersContract.getReserveCaps(dai.address)).supplyCap; | ||||
| 
 | ||||
|     expect(usdcsupplyCap).to.be.equal(newCap); | ||||
|     expect(daisupplyCap).to.be.equal(newCap); | ||||
|     expect(usdcSupplyCap).to.be.equal(newCap); | ||||
|     expect(daiSupplyCap).to.be.equal(newCap); | ||||
|   }); | ||||
|   it('should succeed to supply 100 dai and 100 usdc', async () => { | ||||
|     const { usdc, pool, dai, deployer, helpersContract } = testEnv; | ||||
|     const suppliedAmount = 100; | ||||
|     const suppliedMilimount = (suppliedAmount * 1000).toString(); | ||||
|     const precisionSuppliedAmount = (suppliedAmount * 1000).toString(); | ||||
|     await pool.deposit( | ||||
|       usdc.address, | ||||
|       await miliUnitToPrecision(usdc, suppliedMilimount), | ||||
|       await unitParse(usdc, precisionSuppliedAmount), | ||||
|       deployer.address, | ||||
|       0 | ||||
|     ); | ||||
| 
 | ||||
|     await pool.deposit( | ||||
|       dai.address, | ||||
|       await miliUnitToPrecision(dai, suppliedMilimount), | ||||
|       await unitParse(dai, precisionSuppliedAmount), | ||||
|       deployer.address, | ||||
|       0 | ||||
|     ); | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Hadrien Charlanes
						Hadrien Charlanes