diff --git a/contracts/MinimumDepositController/IMinimumDepositController.sol b/contracts/MinimumDepositController/IMinimumDepositController.sol index 172f3d5..a84145f 100644 --- a/contracts/MinimumDepositController/IMinimumDepositController.sol +++ b/contracts/MinimumDepositController/IMinimumDepositController.sol @@ -66,13 +66,15 @@ interface IMinimumDepositController { * @param _depositFeeRate Deposit fee rate (in BPS) * @param _minimumDeposit Minimum deposit value (in assets) * @param _ceiling Ceiling value + * @param _areLiveDepositsAllowed Value indicating whether deposits should be allowed during live portfolio status */ function initialize( address manager, address _lenderVerifier, uint256 _depositFeeRate, uint256 _minimumDeposit, - uint256 _ceiling + uint256 _ceiling, + bool _areLiveDepositsAllowed ) external; /** diff --git a/contracts/MinimumDepositController/MinimumDepositController.sol b/contracts/MinimumDepositController/MinimumDepositController.sol index 060037e..b377103 100644 --- a/contracts/MinimumDepositController/MinimumDepositController.sol +++ b/contracts/MinimumDepositController/MinimumDepositController.sol @@ -28,13 +28,15 @@ contract MinimumDepositController is IMinimumDepositController, Initializable, A address _lenderVerifier, uint256 _depositFeeRate, uint256 _minimumDeposit, - uint256 _ceiling + uint256 _ceiling, + bool _areLiveDepositsAllowed ) external initializer { _grantRole(MANAGER_ROLE, manager); lenderVerifier = ILenderVerifier(_lenderVerifier); depositFeeRate = _depositFeeRate; minimumDeposit = _minimumDeposit; depositAllowed[Status.CapitalFormation] = true; + depositAllowed[Status.Live] = _areLiveDepositsAllowed; ceiling = _ceiling; } diff --git a/deployments-goerli.json b/deployments-goerli.json index 48de304..7b1fbd2 100644 --- a/deployments-goerli.json +++ b/deployments-goerli.json @@ -1,8 +1,8 @@ { "goerli": { "minimumDepositController": { - "txHash": "0x6fb8081d4e6128a73c6c3db194bd3acd3966a1af33cb9814c9202d6c1f6d46b3", - "address": "0x5e51693fAe780A9Ec7A999F6d46C9935695e4f12", + "txHash": "0x1fd568cb6338fa8c26ee4cc0f6a6568a04b44b0788df636f06e14e76f0dd961f", + "address": "0xD810708e4A02c8C58e3955510f1c9B77A33fA8B8", "multisig": false } } diff --git a/deployments-optimism_goerli.json b/deployments-optimism_goerli.json index f411872..d9c3609 100644 --- a/deployments-optimism_goerli.json +++ b/deployments-optimism_goerli.json @@ -1,8 +1,8 @@ { "optimism_goerli": { "minimumDepositController": { - "txHash": "0x162d7b478390cc8444a7b8564f770e13b67d596bb071a84785945f0afea61f23", - "address": "0xb7DaEb7232795C7e59A8CC2fb0e6A1CEe43DBD5F", + "txHash": "0x590114e56a32c91946d2c5420621c1a6f29c6d3eefc7d84be0ad9bb08377e9ea", + "address": "0xd07ab981B8F8f3a89D8D0A6a4318Df9BBB7c546D", "multisig": false } } diff --git a/test/contracts/initialize.test.ts b/test/contracts/initialize.test.ts index 8f9f1e3..402e16c 100644 --- a/test/contracts/initialize.test.ts +++ b/test/contracts/initialize.test.ts @@ -2,6 +2,8 @@ import { expect } from 'chai' import { minimumDepositControllerFixture } from 'fixtures/minimumDepositControllerFixture' import { PortfolioStatus } from 'fixtures/structuredPortfolioFixture' import { setupFixtureLoader } from 'test/setup' +import { AllowAllLenderVerifier__factory, MinimumDepositController__factory } from 'contracts' +import { Wallet } from 'ethers' describe('MinimumDepositController.initialize', () => { const loadFixture = setupFixtureLoader() @@ -49,4 +51,17 @@ describe('MinimumDepositController.initialize', () => { expect(await depositController.depositAllowed(status)).to.deep.eq(defaultValue) } }) + + it('sets deposit allowed in live status based on initialize argument', async () => { + const areLiveDepositsAllowed = true + + const { depositController } = await loadFixture(async ([wallet]: Wallet[]) => { + const lenderVerifier = await new AllowAllLenderVerifier__factory(wallet).deploy() + const depositController = await new MinimumDepositController__factory(wallet).deploy() + await depositController.initialize(wallet.address, lenderVerifier.address, 500, 100, 0, areLiveDepositsAllowed) + return { depositController } + }) + + expect(await depositController.depositAllowed(PortfolioStatus.Live)).to.deep.eq(areLiveDepositsAllowed) + }) }) diff --git a/test/fixtures/minimumDepositControllerFixture.ts b/test/fixtures/minimumDepositControllerFixture.ts index f8a044f..43dd797 100644 --- a/test/fixtures/minimumDepositControllerFixture.ts +++ b/test/fixtures/minimumDepositControllerFixture.ts @@ -7,6 +7,6 @@ export async function minimumDepositControllerFixture([wallet]: Wallet[]) { const depositController = await new MinimumDepositController__factory(wallet).deploy() const depositFeeRate = 500 const minimumDeposit = 100 - await depositController.initialize(wallet.address, lenderVerifier.address, depositFeeRate, minimumDeposit, 0) + await depositController.initialize(wallet.address, lenderVerifier.address, depositFeeRate, minimumDeposit, 0, false) return { depositController, depositFeeRate, minimumDeposit, lenderVerifier } } diff --git a/test/fixtures/structuredPortfolioFactoryFixture.ts b/test/fixtures/structuredPortfolioFactoryFixture.ts index 9516a7e..7d7974d 100644 --- a/test/fixtures/structuredPortfolioFactoryFixture.ts +++ b/test/fixtures/structuredPortfolioFactoryFixture.ts @@ -88,6 +88,7 @@ export const getStructuredPortfolioFactoryFixture = (tokenDecimals: number, mini 0, minimumDeposit, parseTokenUnits(1e10), + false, ]), withdrawControllerImplementation: withdrawController.address, withdrawControllerInitData: withdrawController.interface.encodeFunctionData('initialize', [wallet.address, 0, 1]), @@ -108,6 +109,7 @@ export const getStructuredPortfolioFactoryFixture = (tokenDecimals: number, mini 0, minimumDeposit, parseTokenUnits(1e10), + false, ]), withdrawControllerImplementation: withdrawController.address, withdrawControllerInitData: withdrawController.interface.encodeFunctionData('initialize', [wallet.address, 0, 1]), @@ -128,6 +130,7 @@ export const getStructuredPortfolioFactoryFixture = (tokenDecimals: number, mini 0, minimumDeposit, parseTokenUnits(1e10), + false, ]), withdrawControllerImplementation: withdrawController.address, withdrawControllerInitData: withdrawController.interface.encodeFunctionData('initialize', [wallet.address, 0, 1]),