Skip to content

Commit

Permalink
🗽 Allow for allowing deposits in portfolio live status (#1602)
Browse files Browse the repository at this point in the history
  • Loading branch information
truefibot committed Jul 28, 2023
1 parent d6f26d9 commit 12bd2ff
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions deployments-goerli.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"goerli": {
"minimumDepositController": {
"txHash": "0x6fb8081d4e6128a73c6c3db194bd3acd3966a1af33cb9814c9202d6c1f6d46b3",
"address": "0x5e51693fAe780A9Ec7A999F6d46C9935695e4f12",
"txHash": "0x1fd568cb6338fa8c26ee4cc0f6a6568a04b44b0788df636f06e14e76f0dd961f",
"address": "0xD810708e4A02c8C58e3955510f1c9B77A33fA8B8",
"multisig": false
}
}
Expand Down
4 changes: 2 additions & 2 deletions deployments-optimism_goerli.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"optimism_goerli": {
"minimumDepositController": {
"txHash": "0x162d7b478390cc8444a7b8564f770e13b67d596bb071a84785945f0afea61f23",
"address": "0xb7DaEb7232795C7e59A8CC2fb0e6A1CEe43DBD5F",
"txHash": "0x590114e56a32c91946d2c5420621c1a6f29c6d3eefc7d84be0ad9bb08377e9ea",
"address": "0xd07ab981B8F8f3a89D8D0A6a4318Df9BBB7c546D",
"multisig": false
}
}
Expand Down
15 changes: 15 additions & 0 deletions test/contracts/initialize.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)
})
})
2 changes: 1 addition & 1 deletion test/fixtures/minimumDepositControllerFixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}
3 changes: 3 additions & 0 deletions test/fixtures/structuredPortfolioFactoryFixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]),
Expand All @@ -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]),
Expand All @@ -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]),
Expand Down

0 comments on commit 12bd2ff

Please sign in to comment.