import type { AssetFinalityResolver , Dispatcher , GasRelayPaymasterFactory , ValueInterpreter , } from '@enzymefinance/protocol' ; import { ComptrollerLib , ExternalPositionManager , FeeManager , FundDeployer , IntegrationManager , PolicyManager , ProtocolFeeTracker , VaultLib , } from '@enzymefinance/protocol' ; import type { Signer } from 'ethers' ; export async function createFundDeployer ( { deployer , assetFinalityResolver , externalPositionManager , dispatcher , gasRelayPaymasterFactory , valueInterpreter , vaultLib , setOnDispatcher = true , setReleaseLive = true , } ) { const mlnToken = await vaultLib . getMlnToken ( ) ; const wethToken = await vaultLib . getWethToken ( ) ; const protocolFeeReserve = await vaultLib . getProtocolFeeReserve ( ) ; const nextFundDeployer = await FundDeployer . deploy ( deployer , dispatcher , gasRelayPaymasterFactory ) ; const nextPolicyManager = await PolicyManager . deploy ( deployer , nextFundDeployer , gasRelayPaymasterFactory ) ; const nextExternalPositionManager = await ExternalPositionManager . deploy ( deployer , nextFundDeployer , await externalPositionManager . getExternalPositionFactory ( ) , nextPolicyManager ) ; const nextFeeManager = await FeeManager . deploy ( deployer , nextFundDeployer ) ; const nextIntegrationManager = await IntegrationManager . deploy ( deployer , nextFundDeployer , nextPolicyManager , valueInterpreter ) ; const nextComptrollerLib = await ComptrollerLib . deploy ( deployer , dispatcher , protocolFeeReserve , nextFundDeployer , valueInterpreter , nextExternalPositionManager , nextFeeManager , nextIntegrationManager , nextPolicyManager , assetFinalityResolver , gasRelayPaymasterFactory , mlnToken , wethToken ) ; await nextFundDeployer . setComptrollerLib ( nextComptrollerLib ) ; const nextProtocolFeeTracker = await ProtocolFeeTracker . deploy ( deployer , nextFundDeployer ) ; await nextFundDeployer . setProtocolFeeTracker ( nextProtocolFeeTracker ) ; const nextVaultLib = await VaultLib . deploy ( deployer , externalPositionManager , await vaultLib . getGasRelayPaymasterFactory ( ) , await vaultLib . getProtocolFeeReserve ( ) , nextProtocolFeeTracker , await vaultLib . getMlnToken ( ) , await vaultLib . getWethToken ( ) ) ; await nextFundDeployer . setVaultLib ( nextVaultLib ) ; if ( setReleaseLive ) { await nextFundDeployer . setReleaseLive ( ) ; } if ( setOnDispatcher ) { await dispatcher . setCurrentFundDeployer ( nextFundDeployer ) ; } return nextFundDeployer ; }