1+ import { FlashLoanLogic } from './../types/FlashLoanLogic.d' ;
12import { DRE } from './misc-utils' ;
23import { eContractid , tEthereumAddress , TokenContractId , tStringTokenSmallUnits } from './types' ;
34import { getFirstSigner } from './wallet-helpers' ;
@@ -57,8 +58,8 @@ export const deployMintableERC20 = async (
5758 verify
5859 ) ;
5960
60- export const deployGenericATokenImpl = async ( ) =>
61- withSave ( await new AToken__factory ( await getFirstSigner ( ) ) . deploy ( ) , eContractid . AToken ) ;
61+ export const deployGenericATokenImpl = async ( pool : tEthereumAddress ) =>
62+ withSave ( await new AToken__factory ( await getFirstSigner ( ) ) . deploy ( pool ) , eContractid . AToken ) ;
6263
6364export const deployPoolAddressesProvider = async ( marketId : string , verify ?: boolean ) =>
6465 withSaveAndVerify (
@@ -166,12 +167,32 @@ export const deployEModeLogic = async () => {
166167 return withSave ( eModeLogic , eContractid . EModeLogic ) ;
167168} ;
168169
170+ export const deployFlashLoanLogic = async ( borrowLogicAddress : tEthereumAddress ) => {
171+ const flashLoanLogicArtifact = await readArtifact ( eContractid . FlashLoanLogic ) ;
172+
173+ const linkedFlashLoanLogicByteCode = linkBytecode ( flashLoanLogicArtifact , {
174+ [ eContractid . BorrowLogic ] : borrowLogicAddress ,
175+ } ) ;
176+
177+ const flashLoanLogicFactory = await DRE . ethers . getContractFactory (
178+ flashLoanLogicArtifact . abi ,
179+ linkedFlashLoanLogicByteCode
180+ ) ;
181+
182+ const flashLoanLogic = await (
183+ await flashLoanLogicFactory . connect ( await getFirstSigner ( ) ) . deploy ( )
184+ ) . deployed ( ) ;
185+
186+ return withSave ( flashLoanLogic , eContractid . FlashLoanLogic ) ;
187+ } ;
188+
169189export const deployAaveLibraries = async ( ) : Promise < PoolLibraryAddresses > => {
170190 const supplyLogic = await deploySupplyLogic ( ) ;
171191 const borrowLogic = await deployBorrowLogic ( ) ;
172192 const liquidationLogic = await deployLiquidationLogic ( ) ;
173193 const bridgeLogic = await deployBridgeLogic ( ) ;
174194 const eModeLogic = await deployEModeLogic ( ) ;
195+ const flashLoanLogic = await deployFlashLoanLogic ( borrowLogic . address ) ;
175196 // Hardcoded solidity placeholders, if any library changes path this will fail.
176197 // The '__$PLACEHOLDER$__ can be calculated via solidity keccak, but the PoolLibraryAddresses Type seems to
177198 // require a hardcoded string.
@@ -190,6 +211,8 @@ export const deployAaveLibraries = async (): Promise<PoolLibraryAddresses> => {
190211 [ 'contracts/protocol/libraries/logic/EModeLogic.sol:EModeLogic' ] : eModeLogic . address ,
191212 [ 'contracts/protocol/libraries/logic/BorrowLogic.sol:BorrowLogic' ] : borrowLogic . address ,
192213 [ 'contracts/protocol/libraries/logic/BridgeLogic.sol:BridgeLogic' ] : bridgeLogic . address ,
214+ [ 'contracts/protocol/libraries/logic/FlashLoanLogic.sol:FlashLoanLogic' ] :
215+ flashLoanLogic . address ,
193216 } ;
194217} ;
195218
@@ -246,7 +269,14 @@ export const deployMockAggregator = async (price: tStringTokenSmallUnits, verify
246269 ) ;
247270
248271export const deployAaveOracle = async (
249- args : [ tEthereumAddress [ ] , tEthereumAddress [ ] , tEthereumAddress , tEthereumAddress , string ] ,
272+ args : [
273+ tEthereumAddress ,
274+ tEthereumAddress [ ] ,
275+ tEthereumAddress [ ] ,
276+ tEthereumAddress ,
277+ tEthereumAddress ,
278+ string
279+ ] ,
250280 verify ?: boolean
251281) =>
252282 withSaveAndVerify (
@@ -296,7 +326,7 @@ export const deployWalletBalancerProvider = async (verify?: boolean) =>
296326
297327export const deployDefaultReserveInterestRateStrategy = async (
298328 args : [ tEthereumAddress , string , string , string , string , string , string , string , string , string ] ,
299- verify : boolean
329+ verify ? : boolean
300330) =>
301331 withSaveAndVerify (
302332 await new DefaultReserveInterestRateStrategy__factory ( await getFirstSigner ( ) ) . deploy ( ...args ) ,
@@ -311,28 +341,28 @@ export const deployReservesSetupHelper = async () =>
311341 eContractid . ReservesSetupHelper
312342 ) ;
313343
314- export const deployDelegationAwareATokenImpl = async ( verify ?: boolean ) =>
344+ export const deployDelegationAwareATokenImpl = async ( pool : tEthereumAddress , verify ?: boolean ) =>
315345 withSaveAndVerify (
316- await new DelegationAwareAToken__factory ( await getFirstSigner ( ) ) . deploy ( ) ,
346+ await new DelegationAwareAToken__factory ( await getFirstSigner ( ) ) . deploy ( pool ) ,
317347 eContractid . DelegationAwareAToken ,
318- [ ] ,
348+ [ pool ] ,
319349 verify
320350 ) ;
321351
322- export const deployGenericStableDebtToken = async ( ) =>
352+ export const deployGenericStableDebtToken = async ( pool : tEthereumAddress , verify ?: boolean ) =>
323353 withSaveAndVerify (
324- await new StableDebtToken__factory ( await getFirstSigner ( ) ) . deploy ( ) ,
354+ await new StableDebtToken__factory ( await getFirstSigner ( ) ) . deploy ( pool ) ,
325355 eContractid . StableDebtToken ,
326- [ ] ,
327- false
356+ [ pool ] ,
357+ verify
328358 ) ;
329359
330- export const deployGenericVariableDebtToken = async ( ) =>
360+ export const deployGenericVariableDebtToken = async ( pool : tEthereumAddress , verify ?: boolean ) =>
331361 withSaveAndVerify (
332- await new VariableDebtToken__factory ( await getFirstSigner ( ) ) . deploy ( ) ,
362+ await new VariableDebtToken__factory ( await getFirstSigner ( ) ) . deploy ( pool ) ,
333363 eContractid . VariableDebtToken ,
334- [ ] ,
335- false
364+ [ pool ] ,
365+ verify
336366 ) ;
337367
338368export const deployAllMockTokens = async ( ) => {
0 commit comments