import { BigNumberish, Signer } from "ethers"; import { Controller, IntegrationRegistry, PriceOracle, SetToken, SetTokenCreator, SetValuer } from "./../contracts"; import { Address } from "./../types"; import { Controller__factory } from "../../typechain/factories/Controller__factory"; import { IntegrationRegistry__factory } from "../../typechain/factories/IntegrationRegistry__factory"; import { PriceOracle__factory } from "../../typechain/factories/PriceOracle__factory"; import { SetToken__factory } from "../../typechain/factories/SetToken__factory"; import { SetTokenCreator__factory } from "../../typechain/factories/SetTokenCreator__factory"; import { SetValuer__factory } from "../../typechain/factories/SetValuer__factory"; export default class DeployCoreContracts { private _deployerSigner: Signer; constructor(deployerSigner: Signer) { this._deployerSigner = deployerSigner; } public async deployController(feeRecipient: Address): Promise { return await new Controller__factory(this._deployerSigner).deploy(feeRecipient); } public async getController(controllerAddress: Address): Promise { return await new Controller__factory(this._deployerSigner).attach(controllerAddress); } public async deploySetTokenCreator(controller: Address): Promise { return await new SetTokenCreator__factory(this._deployerSigner).deploy(controller); } public async getSetTokenCreator(setTokenCreatorAddress: Address): Promise { return await new SetTokenCreator__factory(this._deployerSigner).attach(setTokenCreatorAddress); } public async deploySetToken( _components: Address[], _units: BigNumberish[], _modules: Address[], _controller: Address, _manager: Address, _name: string, _symbol: string, ): Promise { return await new SetToken__factory(this._deployerSigner).deploy( _components, _units, _modules, _controller, _manager, _name, _symbol, ); } public async getSetToken(setTokenAddress: Address): Promise { return await new SetToken__factory(this._deployerSigner).attach(setTokenAddress); } public async deployPriceOracle( controller: Address, masterQuoteAsset: Address, adapters: Address[], assetOnes: Address[], assetTwos: Address[], oracles: Address[], ): Promise { return await new PriceOracle__factory(this._deployerSigner).deploy( controller, masterQuoteAsset, adapters, assetOnes, assetTwos, oracles, ); } public async getPriceOracle(priceOracleAddress: Address): Promise { return await new PriceOracle__factory(this._deployerSigner).attach(priceOracleAddress); } public async deployIntegrationRegistry(controller: Address): Promise { return await new IntegrationRegistry__factory(this._deployerSigner).deploy(controller); } public async getIntegrationRegistry(integrationRegistryAddress: Address): Promise { return await new IntegrationRegistry__factory(this._deployerSigner).attach(integrationRegistryAddress); } public async deploySetValuer(controller: Address): Promise { return await new SetValuer__factory(this._deployerSigner).deploy(controller); } }