|
| 1 | +import { setupFixtureLoader } from 'test/setup' |
| 2 | +import { PortfolioStatus, structuredPortfolioFixture } from 'fixtures/structuredPortfolioFixture' |
| 3 | +import { parseUSDC } from 'utils' |
| 4 | +import { expect } from 'chai' |
| 5 | +import { MinimumDepositController__factory } from 'build/types' |
| 6 | + |
| 7 | +describe('MinimumDepositController.maxDeposit', () => { |
| 8 | + const loadFixture = setupFixtureLoader() |
| 9 | + const minimumDeposit = parseUSDC(100) |
| 10 | + const ceiling = parseUSDC(5e9) |
| 11 | + |
| 12 | + it('previews max deposit', async () => { |
| 13 | + const { equityTranche, wallet } = await loadFixture(structuredPortfolioFixture(minimumDeposit)) |
| 14 | + |
| 15 | + expect(await equityTranche.maxDeposit(wallet.address)).to.eq(ceiling) |
| 16 | + }) |
| 17 | + |
| 18 | + it('previews current max deposit', async () => { |
| 19 | + const { equityTranche, wallet, depositToTranche } = await loadFixture(structuredPortfolioFixture(minimumDeposit)) |
| 20 | + await depositToTranche(equityTranche, minimumDeposit) |
| 21 | + |
| 22 | + expect(await equityTranche.maxDeposit(wallet.address)).to.eq(ceiling.sub(minimumDeposit)) |
| 23 | + }) |
| 24 | + |
| 25 | + it('returns zero if deposit is not allowed', async () => { |
| 26 | + const { equityTranche, wallet } = await loadFixture(structuredPortfolioFixture(minimumDeposit)) |
| 27 | + const depositController = MinimumDepositController__factory.connect(await equityTranche.depositController(), wallet) |
| 28 | + await depositController.setDepositAllowed(false, PortfolioStatus.CapitalFormation) |
| 29 | + |
| 30 | + expect(await equityTranche.maxDeposit(wallet.address)).to.eq(0) |
| 31 | + }) |
| 32 | + |
| 33 | + it('returns zero if tranche is full', async () => { |
| 34 | + const { equityTranche, wallet, depositToTranche } = await loadFixture(structuredPortfolioFixture(minimumDeposit)) |
| 35 | + const depositController = MinimumDepositController__factory.connect(await equityTranche.depositController(), wallet) |
| 36 | + const amount = parseUSDC(150) |
| 37 | + await depositController.setCeiling(amount) |
| 38 | + await depositToTranche(equityTranche, amount) |
| 39 | + |
| 40 | + expect(await equityTranche.maxDeposit(wallet.address)).to.eq(0) |
| 41 | + }) |
| 42 | +}) |
0 commit comments