import { Address , Bytes } from "../types" ; import { BigNumberish , BigNumber , Signer } from "ethers" ; import { AaveLendingPoolCoreMock , AaveLendingPoolMock , AddressArrayUtilsMock , AmmAdapterMock , ChainlinkAggregatorMock , ClaimAdapterMock , ContractCallerMock , CompoundMock , ComptrollerMock , CustomSetValuerMock , DebtIssuanceMock , DebtModuleMock , ExplicitERC20Mock , ForceFunderMock , GaugeControllerMock , GodModeMock , GovernanceAdapterMock , InvokeMock , KyberNetworkProxyMock , ManagerIssuanceHookMock , ModuleIssuanceHookMock , ModuleBaseMock , NAVIssuanceCaller , NAVIssuanceHookMock , OneInchExchangeMock , OracleAdapterMock , OracleMock , YearnVaultMock , PerpV2Mock , PositionMock , PreciseUnitMathMock , ResourceIdentifierMock , StakingAdapterMock , StandardTokenMock , StandardTokenWithRoundingErrorMock , StandardTokenWithFeeMock , TradeAdapterMock , SynthMock , SynthetixExchangerMock , Uint256ArrayUtilsMock , WrapAdapterMock , WrapV2AdapterMock , ZeroExMock , YearnStrategyMock , AaveV2Mock , UniswapV3MathMock , UnitConversionUtilsMock , SetTokenAccessibleMock } from "../contracts" ; import { ether } from "../common" ; import dependencies from "./dependencies" ; import { AaveLendingPoolCoreMock__factory } from "../../typechain/factories/AaveLendingPoolCoreMock__factory" ; import { AaveLendingPoolMock__factory } from "../../typechain/factories/AaveLendingPoolMock__factory" ; import { AddressArrayUtilsMock__factory } from "../../typechain/factories/AddressArrayUtilsMock__factory" ; import { AmmAdapterMock__factory } from "../../typechain/factories/AmmAdapterMock__factory" ; import { ChainlinkAggregatorMock__factory } from "../../typechain/factories/ChainlinkAggregatorMock__factory" ; import { ClaimAdapterMock__factory } from "../../typechain/factories/ClaimAdapterMock__factory" ; import { CompoundMock__factory } from "../../typechain/factories/CompoundMock__factory" ; import { ComptrollerMock__factory } from "../../typechain/factories/ComptrollerMock__factory" ; import { ContractCallerMock__factory } from "../../typechain/factories/ContractCallerMock__factory" ; import { CustomSetValuerMock__factory } from "../../typechain/factories/CustomSetValuerMock__factory" ; import { DebtIssuanceMock__factory } from "../../typechain/factories/DebtIssuanceMock__factory" ; import { DebtModuleMock__factory } from "../../typechain/factories/DebtModuleMock__factory" ; import { ExplicitERC20Mock__factory } from "../../typechain/factories/ExplicitERC20Mock__factory" ; import { ForceFunderMock__factory } from "../../typechain/factories/ForceFunderMock__factory" ; import { GaugeControllerMock__factory } from "../../typechain/factories/GaugeControllerMock__factory" ; import { GodModeMock__factory } from "../../typechain/factories/GodModeMock__factory" ; import { GovernanceAdapterMock__factory } from "../../typechain/factories/GovernanceAdapterMock__factory" ; import { InvokeMock__factory } from "../../typechain/factories/InvokeMock__factory" ; import { KyberNetworkProxyMock__factory } from "../../typechain/factories/KyberNetworkProxyMock__factory" ; import { ManagerIssuanceHookMock__factory } from "../../typechain/factories/ManagerIssuanceHookMock__factory" ; import { ModuleBaseMock__factory } from "../../typechain/factories/ModuleBaseMock__factory" ; import { ModuleIssuanceHookMock__factory } from "../../typechain/factories/ModuleIssuanceHookMock__factory" ; import { NAVIssuanceCaller__factory } from "../../typechain/factories/NAVIssuanceCaller__factory" ; import { NAVIssuanceHookMock__factory } from "../../typechain/factories/NAVIssuanceHookMock__factory" ; import { OneInchExchangeMock__factory } from "../../typechain/factories/OneInchExchangeMock__factory" ; import { OracleAdapterMock__factory } from "../../typechain/factories/OracleAdapterMock__factory" ; import { OracleMock__factory } from "../../typechain/factories/OracleMock__factory" ; import { YearnVaultMock__factory } from "../../typechain/factories/YearnVaultMock__factory" ; import { PerpV2Mock__factory } from "../../typechain/factories/PerpV2Mock__factory" ; import { PositionMock__factory } from "../../typechain/factories/PositionMock__factory" ; import { PreciseUnitMathMock__factory } from "../../typechain/factories/PreciseUnitMathMock__factory" ; import { ResourceIdentifierMock__factory } from "../../typechain/factories/ResourceIdentifierMock__factory" ; import { StakingAdapterMock__factory } from "../../typechain/factories/StakingAdapterMock__factory" ; import { StandardTokenMock__factory } from "../../typechain/factories/StandardTokenMock__factory" ; import { StandardTokenWithRoundingErrorMock__factory } from "../../typechain/factories/StandardTokenWithRoundingErrorMock__factory" ; import { StandardTokenWithFeeMock__factory } from "../../typechain/factories/StandardTokenWithFeeMock__factory" ; import { TradeAdapterMock__factory } from "../../typechain/factories/TradeAdapterMock__factory" ; import { Uint256ArrayUtilsMock__factory } from "../../typechain/factories/Uint256ArrayUtilsMock__factory" ; import { WrapAdapterMock__factory } from "../../typechain/factories/WrapAdapterMock__factory" ; import { WrapV2AdapterMock__factory } from "../../typechain/factories/WrapV2AdapterMock__factory" ; import { ZeroExMock__factory } from "../../typechain/factories/ZeroExMock__factory" ; import { SynthMock__factory } from "../../typechain/factories/SynthMock__factory" ; import { SynthetixExchangerMock__factory } from "../../typechain/factories/SynthetixExchangerMock__factory" ; import { YearnStrategyMock__factory } from "../../typechain/factories/YearnStrategyMock__factory" ; import { AaveV2Mock__factory } from "../../typechain/factories/AaveV2Mock__factory" ; import { UniswapV3MathMock__factory } from "../../typechain/factories/UniswapV3MathMock__factory" ; import { UnitConversionUtilsMock__factory } from "../../typechain/factories/UnitConversionUtilsMock__factory" ; import { SetTokenAccessibleMock__factory } from "../../typechain/factories/SetTokenAccessibleMock__factory" ; export default class DeployMocks { private _deployerSigner : Signer ; constructor ( deployerSigner ) { this . _deployerSigner = deployerSigner ; } public async deployExplicitErc20Mock ( ) { return await new ExplicitERC20Mock__factory ( this . _deployerSigner ) . deploy ( ) ; } public async deployInvokeMock ( ) { return await new InvokeMock__factory ( this . _deployerSigner ) . deploy ( ) ; } public async deployManagerIssuanceHookMock ( ) { return await new ManagerIssuanceHookMock__factory ( this . _deployerSigner ) . deploy ( ) ; } public async deployModuleIssuanceHookMock ( ) { return await new ModuleIssuanceHookMock__factory ( this . _deployerSigner ) . deploy ( ) ; } public async deployNavIssuanceHookMock ( ) { return await new NAVIssuanceHookMock__factory ( this . _deployerSigner ) . deploy ( ) ; } public async deployNAVIssuanceCaller ( navIssuanceModule ) { return await new NAVIssuanceCaller__factory ( this . _deployerSigner ) . deploy ( navIssuanceModule ) ; } public async deployAddressArrayUtilsMock ( ) { return await new AddressArrayUtilsMock__factory ( this . _deployerSigner ) . deploy ( ) ; } public async deployUint256ArrayUtilsMock ( ) { return await new Uint256ArrayUtilsMock__factory ( this . _deployerSigner ) . deploy ( ) ; } public async deployKyberNetworkProxyMock ( mockWethAddress ) { return await new KyberNetworkProxyMock__factory ( this . _deployerSigner ) . deploy ( mockWethAddress ) ; } public async deployModuleBaseMock ( controllerAddress ) { return await new ModuleBaseMock__factory ( this . _deployerSigner ) . deploy ( controllerAddress ) ; } public async deployGodModeMock ( controllerAddress ) { return await new GodModeMock__factory ( this . _deployerSigner ) . deploy ( controllerAddress ) ; } public async deployDebtModuleMock ( controllerAddress , moduleAddress ) { return await new DebtModuleMock__factory ( this . _deployerSigner ) . deploy ( controllerAddress , moduleAddress ) ; } public async deployGovernanceAdapterMock ( initialProposalId ) { return await new GovernanceAdapterMock__factory ( this . _deployerSigner ) . deploy ( initialProposalId ) ; } public async deployOneInchExchangeMock ( sendToken , receiveToken , sendQuantity , receiveQuantity ) { return await new OneInchExchangeMock__factory ( this . _deployerSigner ) . deploy ( sendToken , receiveToken , sendQuantity , receiveQuantity ) ; } public async deployZeroExMock ( sendToken , receiveToken , sendQuantity , receiveQuantity ) { return await new ZeroExMock__factory ( this . _deployerSigner ) . deploy ( sendToken , receiveToken , sendQuantity , receiveQuantity ) ; } public async deployOracleMock ( initialValue ) { return await new OracleMock__factory ( this . _deployerSigner ) . deploy ( initialValue ) ; } public async deployYearnVaultMock ( pricePerShare ) { return await new YearnVaultMock__factory ( this . _deployerSigner ) . deploy ( pricePerShare ) ; } public async deployOracleAdapterMock ( asset , dummyPrice ) { return await new OracleAdapterMock__factory ( this . _deployerSigner ) . deploy ( asset , dummyPrice ) ; } public async deployPositionMock ( ) { return await new PositionMock__factory ( this . _deployerSigner ) . deploy ( ) ; } public async deployPreciseUnitMathMock ( ) { return await new PreciseUnitMathMock__factory ( this . _deployerSigner ) . deploy ( ) ; } public async deployResourceIdentifierMock ( ) { return await new ResourceIdentifierMock__factory ( this . _deployerSigner ) . deploy ( ) ; } public async deployStakingAdapterMock ( stakingAsset ) { return await new StakingAdapterMock__factory ( this . _deployerSigner ) . deploy ( stakingAsset ) ; } public async deployTokenMock ( initialAccount , initialBalance = ether ( 1000000000 ) , decimals = 18 , name = "Token" , symbol = "Symbol" ) { return await new StandardTokenMock__factory ( this . _deployerSigner ) . deploy ( initialAccount , initialBalance , name , symbol , decimals ) ; } public async deployTokenWithFeeMock ( initialAccount , initialBalance = ether ( 1000000000 ) , fee = ether ( 0.1 ) , name = "Token" , symbol = "Symbol" ) { return await new StandardTokenWithFeeMock__factory ( this . _deployerSigner ) . deploy ( initialAccount , initialBalance , name , symbol , fee ) ; } public async deployTokenWithErrorMock ( initialAccount , initialBalance , error , name = "Token" , symbol = "Symbol" , decimals = BigNumber . from ( 18 ) ) { return await new StandardTokenWithRoundingErrorMock__factory ( this . _deployerSigner ) . deploy ( initialAccount , initialBalance , error , name , symbol , decimals ) ; } public async deployTradeAdapterMock ( ) { return await new TradeAdapterMock__factory ( this . _deployerSigner ) . deploy ( ) ; } public async deployAmmAdapterMock ( _underlyingTokens ) { return await new AmmAdapterMock__factory ( this . _deployerSigner ) . deploy ( _underlyingTokens ) ; } public async deployWrapAdapterMock ( ) { return await new WrapAdapterMock__factory ( this . _deployerSigner ) . deploy ( ) ; } public async deployAaveLendingPoolCoreMock ( ) { return await new AaveLendingPoolCoreMock__factory ( this . _deployerSigner ) . deploy ( ) ; } public async deployAaveLendingPoolMock ( aaveLendingPoolCore ) { return await new AaveLendingPoolMock__factory ( this . _deployerSigner ) . deploy ( aaveLendingPoolCore ) ; } public async deployAaveV2Mock ( libraryName , libraryAddress ) { return await new AaveV2Mock__factory ( { [ libraryName ] : libraryAddress , } , this . _deployerSigner ) . deploy ( ) ; } public async deployPerpV2Mock ( libraryName , libraryAddress ) { return await new PerpV2Mock__factory ( { [ libraryName ] : libraryAddress , } , this . _deployerSigner ) . deploy ( ) ; } public async deployUniswapV3MathMock ( ) { return await new UniswapV3MathMock__factory ( this . _deployerSigner ) . deploy ( ) ; } public async deployUnitConversionUtilsMock ( ) { return await new UnitConversionUtilsMock__factory ( this . _deployerSigner ) . deploy ( ) ; } public async deploySetTokenAccessibleMock ( controller ) { return await new SetTokenAccessibleMock__factory ( this . _deployerSigner ) . deploy ( controller ) ; } public async deployClaimAdapterMock ( ) { return await new ClaimAdapterMock__factory ( this . _deployerSigner ) . deploy ( ) ; } public async deployGaugeControllerMock ( ) { return await new GaugeControllerMock__factory ( this . _deployerSigner ) . deploy ( ) ; } public async deployContractCallerMock ( ) { return await new ContractCallerMock__factory ( this . _deployerSigner ) . deploy ( ) ; } public async deployDebtIssuanceMock ( ) { return await new DebtIssuanceMock__factory ( this . _deployerSigner ) . deploy ( ) ; } public async deployComptrollerMock ( comp , compAmount , cToken ) { return await new ComptrollerMock__factory ( this . _deployerSigner ) . deploy ( comp , compAmount , cToken ) ; } public async deployCompoundMock ( libraryName , libraryAddress ) { return await new CompoundMock__factory ( { [ libraryName ] : libraryAddress , } , this . _deployerSigner ) . deploy ( ) ; } public async deploySynthMock ( initialAccount , currencyKey , initialBalance = ether ( 1000000000 ) , name = "Token" , symbol = "Symbol" ) { return await new SynthMock__factory ( this . _deployerSigner ) . deploy ( initialAccount , initialBalance , name , symbol , 18 , currencyKey ) ; } public async deploySynthetixExchangerMock ( sUsd , sEth , sBtc , currencyKeys , rates ) { return await new SynthetixExchangerMock__factory ( this . _deployerSigner ) . deploy ( sUsd , sEth , sBtc , currencyKeys . sUsd , currencyKeys . sEth , currencyKeys . sBtc , rates . usd . eth , rates . eth . usd , rates . usd . btc , rates . btc . usd ) ; } public async deployCustomSetValuerMock ( ) { return await new CustomSetValuerMock__factory ( this . _deployerSigner ) . deploy ( ) ; } public async deployYearnStrategyMock ( vault ) { return await new YearnStrategyMock__factory ( this . _deployerSigner ) . deploy ( vault ) ; } public async deployForceFunderMock ( ) { return await new ForceFunderMock__factory ( this . _deployerSigner ) . deploy ( ) ; } public async deployWrapV2AdapterMock ( ) { return await new WrapV2AdapterMock__factory ( this . _deployerSigner ) . deploy ( ) ; } public async deployChainlinkAggregatorMock ( decimals ) { return await new ChainlinkAggregatorMock__factory ( this . _deployerSigner ) . deploy ( decimals ) ; } /** ***********************************
     * Instance getters
     ************************************/ public async getTokenMock ( token ) { return await new StandardTokenMock__factory ( this . _deployerSigner ) . attach ( token ) ; } public async getForkedZeroExExchange ( ) { return await ZeroExMock__factory . connect ( dependencies . ZERO_EX_EXCHANGE [ 1 ] , this . _deployerSigner ) ; } }