import DeployHelper from "../deploys" ; import { providers , Signer , BigNumber } from "ethers" ; import { Address } from "../types" ; import { Account } from "../test/types" ; import { StandardTokenMock } from "../contracts" ; import { DMMPool , DMMFactory , DMMRouter02 } from "../contracts/kyberV3" ; import { ether } from "../common" ; import { DMMPool__factory } from "../../typechain/factories/DMMPool__factory" ; export class KyberV3DMMFixture { private _deployer : DeployHelper ; private _ownerSigner : Signer ; public owner : Account ; public knc : StandardTokenMock ; public dmmFactory : DMMFactory ; public dmmRouter : DMMRouter02 ; public kncWethPool : DMMPool ; public wethDaiPool : DMMPool ; public wethWbtcPool : DMMPool ; constructor ( provider , ownerAddress ) { this . _ownerSigner = provider . getSigner ( ownerAddress ) ; this . _deployer = new DeployHelper ( this . _ownerSigner ) ; } public async initialize ( _owner , _weth , _wbtc , _dai ) { this . owner = _owner ; this . dmmFactory = await this . _deployer . external . deployDMMFactory ( this . owner . address ) ; this . dmmRouter = await this . _deployer . external . deployDMMRouter02 ( this . dmmFactory . address , _weth ) ; this . knc = await this . _deployer . mocks . deployTokenMock ( this . owner . address , ether ( 100000 ) , 18 ) ; this . kncWethPool = await this . createNewPool ( _weth , this . knc . address , BigNumber . from ( 19000 ) ) ; this . wethDaiPool = await this . createNewPool ( _weth , _dai , BigNumber . from ( 10000 ) ) ; this . wethWbtcPool = await this . createNewPool ( _weth , _wbtc , BigNumber . from ( 15000 ) ) ; } param _token0 param _token1 param _ampBps public async createNewPool ( _tokenA , _tokenB , _ampBps ) { await this . dmmFactory . createPool ( _tokenA , _tokenB , _ampBps ) ; const poolAddress = await this . dmmFactory . allPools ( ( await this . dmmFactory . allPoolsLength ( ) ) . sub ( 1 ) ) ; return new DMMPool__factory ( this . _ownerSigner ) . attach ( poolAddress ) ; } public getTokenOrder ( _tokenOne , _tokenTwo ) { return _tokenOne . toLowerCase ( ) < _tokenTwo . toLowerCase ( ) ? [ _tokenOne , _tokenTwo ] : [ _tokenTwo , _tokenOne ] ; } }