From d2714410a8dfb5bb598479ac7aa58171945652b3 Mon Sep 17 00:00:00 2001 From: lgalende Date: Wed, 22 Nov 2023 16:55:04 -0300 Subject: [PATCH] tasks: add min amount out and erc4626 parameters --- .../interfaces/erc4626/IERC4626Connector.sol | 5 - .../liquidity/erc4626/IERC4626Exiter.sol | 7 +- .../liquidity/erc4626/IERC4626Joiner.sol | 6 +- .../liquidity/erc4626/ERC4626Exiter.sol | 28 ++- .../liquidity/erc4626/ERC4626Joiner.sol | 25 ++- .../test/liquidity/ERC4626ConnectorMock.sol | 31 ++- .../liquidity/erc4626/ERC4626Exiter.test.ts | 186 +++++++++--------- .../liquidity/erc4626/ERC4626Joiner.test.ts | 59 +++--- 8 files changed, 180 insertions(+), 167 deletions(-) diff --git a/packages/connectors/contracts/interfaces/erc4626/IERC4626Connector.sol b/packages/connectors/contracts/interfaces/erc4626/IERC4626Connector.sol index d71f674b..a35a91c4 100644 --- a/packages/connectors/contracts/interfaces/erc4626/IERC4626Connector.sol +++ b/packages/connectors/contracts/interfaces/erc4626/IERC4626Connector.sol @@ -43,11 +43,6 @@ interface IERC4626Connector { */ function getToken(address erc4626) external view returns (address); - /** - * @dev Tells the underlying token of an ERC4626 - */ - function getToken(address erc4626) external view returns (address); - /** * @dev Deposits assets to the underlying ERC4626 * @param erc4626 Address of the ERC4626 to join diff --git a/packages/tasks/contracts/interfaces/liquidity/erc4626/IERC4626Exiter.sol b/packages/tasks/contracts/interfaces/liquidity/erc4626/IERC4626Exiter.sol index 22adf19e..60a380d1 100644 --- a/packages/tasks/contracts/interfaces/liquidity/erc4626/IERC4626Exiter.sol +++ b/packages/tasks/contracts/interfaces/liquidity/erc4626/IERC4626Exiter.sol @@ -20,13 +20,8 @@ import './IBaseERC4626Task.sol'; * @dev ERC4626 exiter task interface */ interface IERC4626Exiter is IBaseERC4626Task { - /** - * The token is not the ERC4626 token - */ - error TaskTokenNotERC4626(address token, address erc4626); - /** * @dev Executes the ERC4626 exiter task */ - function call(address token, uint256 amount) external; + function call(address erc4626, uint256 amount, uint256 minAmountOut) external; } diff --git a/packages/tasks/contracts/interfaces/liquidity/erc4626/IERC4626Joiner.sol b/packages/tasks/contracts/interfaces/liquidity/erc4626/IERC4626Joiner.sol index 7568ce27..e6caec6a 100644 --- a/packages/tasks/contracts/interfaces/liquidity/erc4626/IERC4626Joiner.sol +++ b/packages/tasks/contracts/interfaces/liquidity/erc4626/IERC4626Joiner.sol @@ -21,12 +21,12 @@ import './IBaseERC4626Task.sol'; */ interface IERC4626Joiner is IBaseERC4626Task { /** - * @dev The token is not the ERC4626 underlying token + * The ERC4626 reference is zero */ - error TaskTokenNotUnderlying(address token, address underlying); + error TaskERC4626Zero(); /** * @dev Executes the ERC4626 joiner task */ - function call(address toke, uint256 amount) external; + function call(address erc4626, address token, uint256 amount, uint256 minAmountOut) external; } diff --git a/packages/tasks/contracts/liquidity/erc4626/ERC4626Exiter.sol b/packages/tasks/contracts/liquidity/erc4626/ERC4626Exiter.sol index be8249fe..7a847785 100644 --- a/packages/tasks/contracts/liquidity/erc4626/ERC4626Exiter.sol +++ b/packages/tasks/contracts/liquidity/erc4626/ERC4626Exiter.sol @@ -14,7 +14,7 @@ pragma solidity ^0.8.0; -import '@mimic-fi/v3-connectors/contracts/interfaces/liquidity/erc4626/IERC4626Connector.sol'; +import '@mimic-fi/v3-connectors/contracts/interfaces/erc4626/IERC4626Connector.sol'; import './BaseERC4626Task.sol'; import '../../interfaces/liquidity/erc4626/IERC4626Exiter.sol'; @@ -60,17 +60,27 @@ contract ERC4626Exiter is IERC4626Exiter, BaseERC4626Task { } /** - * @dev Executes the ERC4626 exiter task - * @param token Address of the token to be exited with + * @dev Executes the ERC4626 exiter task. Note that the ERC4626 is also the token. + * @param erc4626 Address of the ERC4626 to be exited * @param amount Amount of shares to be exited with + * @param minAmountOut Minimum amount of assets willing to receive */ - function call(address token, uint256 amount) external override authP(authParams(token, amount)) { - if (amount == 0) amount = getTaskAmount(token); - _beforeERC4626Exiter(token, amount); - bytes memory connectorData = abi.encodeWithSelector(IERC4626Connector.exit.selector, amount); + function call(address erc4626, uint256 amount, uint256 minAmountOut) + external + override + authP(authParams(erc4626, amount)) + { + if (amount == 0) amount = getTaskAmount(erc4626); + _beforeERC4626Exiter(erc4626, amount); + bytes memory connectorData = abi.encodeWithSelector( + IERC4626Connector.exit.selector, + erc4626, + amount, + minAmountOut + ); bytes memory result = ISmartVault(smartVault).execute(connector, connectorData); (address tokenOut, uint256 amountOut) = abi.decode(result, (address, uint256)); - _afterERC4626Exiter(token, amount, tokenOut, amountOut); + _afterERC4626Exiter(erc4626, amount, tokenOut, amountOut); } /** @@ -78,8 +88,6 @@ contract ERC4626Exiter is IERC4626Exiter, BaseERC4626Task { */ function _beforeERC4626Exiter(address token, uint256 amount) internal virtual { _beforeBaseERC4626Task(token, amount); - address erc4626 = IERC4626Connector(connector).erc4626(); - if (token != erc4626) revert TaskTokenNotERC4626(token, erc4626); } /** diff --git a/packages/tasks/contracts/liquidity/erc4626/ERC4626Joiner.sol b/packages/tasks/contracts/liquidity/erc4626/ERC4626Joiner.sol index f8bad3dc..07280710 100644 --- a/packages/tasks/contracts/liquidity/erc4626/ERC4626Joiner.sol +++ b/packages/tasks/contracts/liquidity/erc4626/ERC4626Joiner.sol @@ -14,7 +14,7 @@ pragma solidity ^0.8.0; -import '@mimic-fi/v3-connectors/contracts/interfaces/liquidity/erc4626/IERC4626Connector.sol'; +import '@mimic-fi/v3-connectors/contracts/interfaces/erc4626/IERC4626Connector.sol'; import './BaseERC4626Task.sol'; import '../../interfaces/liquidity/erc4626/IERC4626Joiner.sol'; @@ -61,13 +61,25 @@ contract ERC4626Joiner is IERC4626Joiner, BaseERC4626Task { /** * @dev Executes the ERC4626 joiner task + * @param erc4626 Address of the ERC4626 to be joined * @param token Address of the token to be joined with * @param amount Amount of assets to be joined with + * @param minAmountOut Minimum amount of shares willing to receive */ - function call(address token, uint256 amount) external override authP(authParams(token, amount)) { + function call(address erc4626, address token, uint256 amount, uint256 minAmountOut) + external + override + authP(authParams(erc4626, token, amount)) + { if (amount == 0) amount = getTaskAmount(token); - _beforeERC4626Joiner(token, amount); - bytes memory connectorData = abi.encodeWithSelector(IERC4626Connector.join.selector, amount); + _beforeERC4626Joiner(erc4626, token, amount); + bytes memory connectorData = abi.encodeWithSelector( + IERC4626Connector.join.selector, + erc4626, + token, + amount, + minAmountOut + ); bytes memory result = ISmartVault(smartVault).execute(connector, connectorData); (address tokenOut, uint256 amountOut) = abi.decode(result, (address, uint256)); _afterERC4626Joiner(token, amount, tokenOut, amountOut); @@ -76,10 +88,9 @@ contract ERC4626Joiner is IERC4626Joiner, BaseERC4626Task { /** * @dev Before ERC4626 joiner hook */ - function _beforeERC4626Joiner(address token, uint256 amount) internal virtual { + function _beforeERC4626Joiner(address erc4626, address token, uint256 amount) internal virtual { _beforeBaseERC4626Task(token, amount); - address underlying = IERC4626Connector(connector).getToken(); - if (token != underlying) revert TaskTokenNotUnderlying(token, underlying); + if (erc4626 == address(0)) revert TaskERC4626Zero(); } /** diff --git a/packages/tasks/contracts/test/liquidity/ERC4626ConnectorMock.sol b/packages/tasks/contracts/test/liquidity/ERC4626ConnectorMock.sol index e40fbf9e..bc519970 100644 --- a/packages/tasks/contracts/test/liquidity/ERC4626ConnectorMock.sol +++ b/packages/tasks/contracts/test/liquidity/ERC4626ConnectorMock.sol @@ -15,29 +15,26 @@ pragma solidity ^0.8.0; contract ERC4626ConnectorMock { - address public erc4626; + address public immutable tokenOut; - address public getToken; + event LogJoin(address erc4626, address token, uint256 amount, uint256 minAmountOut); - event LogJoin(uint256 amount); + event LogExit(address erc4626, uint256 amount, uint256 minAmountOut); - event LogExit(uint256 amount); - - function setERC4626(address newERC4626) external { - erc4626 = newERC4626; - } - - function setToken(address newToken) external { - getToken = newToken; + constructor(address _tokenOut) { + tokenOut = _tokenOut; } - function join(uint256 assets) external returns (address, uint256) { - emit LogJoin(assets); - return (erc4626, assets); + function join(address erc4626, address token, uint256 assets, uint256 minSharesOut) + external + returns (address, uint256) + { + emit LogJoin(erc4626, token, assets, minSharesOut); + return (erc4626, minSharesOut); } - function exit(uint256 shares) external returns (address, uint256) { - emit LogExit(shares); - return (getToken, shares); + function exit(address erc4626, uint256 shares, uint256 minAssetsOut) external returns (address, uint256) { + emit LogExit(erc4626, shares, minAssetsOut); + return (tokenOut, minAssetsOut); } } diff --git a/packages/tasks/test/liquidity/erc4626/ERC4626Exiter.test.ts b/packages/tasks/test/liquidity/erc4626/ERC4626Exiter.test.ts index c81a3207..d4b202fc 100644 --- a/packages/tasks/test/liquidity/erc4626/ERC4626Exiter.test.ts +++ b/packages/tasks/test/liquidity/erc4626/ERC4626Exiter.test.ts @@ -23,6 +23,8 @@ describe('ERC4626Exiter', () => { let task: Contract let smartVault: Contract, authorizer: Contract, connector: Contract, owner: SignerWithAddress + const tokenOut = ONES_ADDRESS + before('setup', async () => { // eslint-disable-next-line prettier/prettier ([, owner] = await getSigners()) @@ -30,7 +32,7 @@ describe('ERC4626Exiter', () => { }) before('deploy connector', async () => { - connector = await deploy('ERC4626ConnectorMock') + connector = await deploy('ERC4626ConnectorMock', [tokenOut]) const overrideConnectorCheckRole = smartVault.interface.getSighash('overrideConnectorCheck') await authorizer.connect(owner).authorize(owner.address, smartVault.address, overrideConnectorCheckRole, []) await smartVault.connect(owner).overrideConnectorCheck(connector.address, true) @@ -76,134 +78,128 @@ describe('ERC4626Exiter', () => { }) context('when the token is not zero', () => { - let token: Contract, tokenOut: Contract + let erc4626: Contract beforeEach('deploy tokens', async () => { - token = await deployTokenMock('ERC4626') - tokenOut = await deployTokenMock('WETH') - }) - - beforeEach('set connector tokens', async () => { - await connector.setToken(tokenOut.address) - await connector.setERC4626(token.address) + erc4626 = await deployTokenMock('ERC4626') // token in }) context('when the amount is not zero', () => { const amount = fp(10) + const shareValue = fp(2.5) + const minAmountOut = amount.mul(shareValue) beforeEach('fund smart vault', async () => { - await token.mint(smartVault.address, amount) + await erc4626.mint(smartVault.address, amount) }) - context('when the token is the ERC4626 token', () => { - context('when the threshold has passed', () => { - const threshold = amount + context('when the threshold has passed', () => { + const threshold = amount - beforeEach('set token threshold', async () => { - const setDefaultTokenThresholdRole = task.interface.getSighash('setDefaultTokenThreshold') - await authorizer.connect(owner).authorize(owner.address, task.address, setDefaultTokenThresholdRole, []) - await task.connect(owner).setDefaultTokenThreshold(token.address, threshold, 0) - }) + beforeEach('set token threshold', async () => { + const setDefaultTokenThresholdRole = task.interface.getSighash('setDefaultTokenThreshold') + await authorizer.connect(owner).authorize(owner.address, task.address, setDefaultTokenThresholdRole, []) + await task.connect(owner).setDefaultTokenThreshold(erc4626.address, threshold, 0) + }) - const itExecutesTheTaskProperly = (requestedAmount: BigNumberish) => { - it('executes the expected connector', async () => { - const tx = await task.call(token.address, requestedAmount) + const itExecutesTheTaskProperly = (requestedAmount: BigNumberish) => { + it('executes the expected connector', async () => { + const tx = await task.call(erc4626.address, requestedAmount, minAmountOut) - const connectorData = connector.interface.encodeFunctionData('exit', [amount]) + const connectorData = connector.interface.encodeFunctionData('exit', [ + erc4626.address, + amount, + minAmountOut, + ]) - await assertIndirectEvent(tx, smartVault.interface, 'Executed', { connector, data: connectorData }) + await assertIndirectEvent(tx, smartVault.interface, 'Executed', { connector, data: connectorData }) - await assertIndirectEvent(tx, connector.interface, 'LogExit', { - amount, - }) + await assertIndirectEvent(tx, connector.interface, 'LogExit', { + erc4626, + amount, + minAmountOut, }) + }) - it('emits an Executed event', async () => { - const tx = await task.call(token.address, requestedAmount) - await assertEvent(tx, 'Executed') - }) - } + it('emits an Executed event', async () => { + const tx = await task.call(erc4626.address, requestedAmount, minAmountOut) + await assertEvent(tx, 'Executed') + }) + } - context('without balance connectors', () => { - const requestedAmount = amount + context('without balance connectors', () => { + const requestedAmount = amount - itExecutesTheTaskProperly(requestedAmount) + itExecutesTheTaskProperly(requestedAmount) - it('does not update any balance connectors', async () => { - const tx = await task.call(token.address, requestedAmount) + it('does not update any balance connectors', async () => { + const tx = await task.call(erc4626.address, requestedAmount, minAmountOut) - await assertNoEvent(tx, 'BalanceConnectorUpdated') - }) + await assertNoEvent(tx, 'BalanceConnectorUpdated') }) + }) - context('with balance connectors', () => { - const requestedAmount = 0 - const prevConnectorId = '0x0000000000000000000000000000000000000000000000000000000000000001' - const nextConnectorId = '0x0000000000000000000000000000000000000000000000000000000000000002' + context('with balance connectors', () => { + const requestedAmount = 0 + const prevConnectorId = '0x0000000000000000000000000000000000000000000000000000000000000001' + const nextConnectorId = '0x0000000000000000000000000000000000000000000000000000000000000002' - beforeEach('set balance connectors', async () => { - const setBalanceConnectorsRole = task.interface.getSighash('setBalanceConnectors') - await authorizer.connect(owner).authorize(owner.address, task.address, setBalanceConnectorsRole, []) - await task.connect(owner).setBalanceConnectors(prevConnectorId, nextConnectorId) - }) + beforeEach('set balance connectors', async () => { + const setBalanceConnectorsRole = task.interface.getSighash('setBalanceConnectors') + await authorizer.connect(owner).authorize(owner.address, task.address, setBalanceConnectorsRole, []) + await task.connect(owner).setBalanceConnectors(prevConnectorId, nextConnectorId) + }) - beforeEach('authorize task to update balance connectors', async () => { - const updateBalanceConnectorRole = smartVault.interface.getSighash('updateBalanceConnector') - await authorizer - .connect(owner) - .authorize(task.address, smartVault.address, updateBalanceConnectorRole, []) - }) + beforeEach('authorize task to update balance connectors', async () => { + const updateBalanceConnectorRole = smartVault.interface.getSighash('updateBalanceConnector') + await authorizer + .connect(owner) + .authorize(task.address, smartVault.address, updateBalanceConnectorRole, []) + }) - beforeEach('assign amount in to previous balance connector', async () => { - const updateBalanceConnectorRole = smartVault.interface.getSighash('updateBalanceConnector') - await authorizer - .connect(owner) - .authorize(owner.address, smartVault.address, updateBalanceConnectorRole, []) - await smartVault.connect(owner).updateBalanceConnector(prevConnectorId, token.address, amount, true) - }) + beforeEach('assign amount in to previous balance connector', async () => { + const updateBalanceConnectorRole = smartVault.interface.getSighash('updateBalanceConnector') + await authorizer + .connect(owner) + .authorize(owner.address, smartVault.address, updateBalanceConnectorRole, []) + await smartVault.connect(owner).updateBalanceConnector(prevConnectorId, erc4626.address, amount, true) + }) - itExecutesTheTaskProperly(requestedAmount) + itExecutesTheTaskProperly(requestedAmount) - it('updates the balance connectors properly', async () => { - const tx = await task.call(token.address, requestedAmount) + it('updates the balance connectors properly', async () => { + const tx = await task.call(erc4626.address, requestedAmount, minAmountOut) - await assertIndirectEvent(tx, smartVault.interface, 'BalanceConnectorUpdated', { - id: prevConnectorId, - token, - amount, - added: false, - }) + await assertIndirectEvent(tx, smartVault.interface, 'BalanceConnectorUpdated', { + id: prevConnectorId, + token: erc4626.address, + amount, + added: false, + }) - await assertIndirectEvent(tx, smartVault.interface, 'BalanceConnectorUpdated', { - id: nextConnectorId, - token: tokenOut.address, - amount, - added: true, - }) + await assertIndirectEvent(tx, smartVault.interface, 'BalanceConnectorUpdated', { + id: nextConnectorId, + token: tokenOut, + amount: minAmountOut, + added: true, }) }) }) + }) - context('when the threshold has not passed', () => { - const threshold = amount.add(1) - - beforeEach('set token threshold', async () => { - const setDefaultTokenThresholdRole = task.interface.getSighash('setDefaultTokenThreshold') - await authorizer.connect(owner).authorize(owner.address, task.address, setDefaultTokenThresholdRole, []) - await task.connect(owner).setDefaultTokenThreshold(token.address, threshold, 0) - }) + context('when the threshold has not passed', () => { + const threshold = amount.add(1) - it('reverts', async () => { - await expect(task.call(token.address, amount)).to.be.revertedWith('TaskTokenThresholdNotMet') - }) + beforeEach('set token threshold', async () => { + const setDefaultTokenThresholdRole = task.interface.getSighash('setDefaultTokenThreshold') + await authorizer.connect(owner).authorize(owner.address, task.address, setDefaultTokenThresholdRole, []) + await task.connect(owner).setDefaultTokenThreshold(erc4626.address, threshold, 0) }) - }) - - context('when the token is not the ERC4626 token', () => { - const token = ONES_ADDRESS it('reverts', async () => { - await expect(task.call(token, amount)).to.be.revertedWith('TaskTokenNotERC4626') + await expect(task.call(erc4626.address, amount, minAmountOut)).to.be.revertedWith( + 'TaskTokenThresholdNotMet' + ) }) }) }) @@ -212,23 +208,23 @@ describe('ERC4626Exiter', () => { const amount = 0 it('reverts', async () => { - await expect(task.call(token.address, amount)).to.be.revertedWith('TaskAmountZero') + await expect(task.call(erc4626.address, amount, 0)).to.be.revertedWith('TaskAmountZero') }) }) }) context('when the token is zero', () => { - const token = ZERO_ADDRESS + const erc4626 = ZERO_ADDRESS it('reverts', async () => { - await expect(task.call(token, 0)).to.be.revertedWith('TaskTokenZero') + await expect(task.call(erc4626, 0, 0)).to.be.revertedWith('TaskTokenZero') }) }) }) context('when the sender is not authorized', () => { it('reverts', async () => { - await expect(task.call(ZERO_ADDRESS, 0)).to.be.revertedWith('AuthSenderNotAllowed') + await expect(task.call(ZERO_ADDRESS, 0, 0)).to.be.revertedWith('AuthSenderNotAllowed') }) }) }) diff --git a/packages/tasks/test/liquidity/erc4626/ERC4626Joiner.test.ts b/packages/tasks/test/liquidity/erc4626/ERC4626Joiner.test.ts index d4ed1172..c580c27f 100644 --- a/packages/tasks/test/liquidity/erc4626/ERC4626Joiner.test.ts +++ b/packages/tasks/test/liquidity/erc4626/ERC4626Joiner.test.ts @@ -30,7 +30,7 @@ describe('ERC4626Joiner', () => { }) before('deploy connector', async () => { - connector = await deploy('ERC4626ConnectorMock') + connector = await deploy('ERC4626ConnectorMock', [ONES_ADDRESS]) const overrideConnectorCheckRole = smartVault.interface.getSighash('overrideConnectorCheck') await authorizer.connect(owner).authorize(owner.address, smartVault.address, overrideConnectorCheckRole, []) await smartVault.connect(owner).overrideConnectorCheck(connector.address, true) @@ -76,26 +76,23 @@ describe('ERC4626Joiner', () => { }) context('when the token is not zero', () => { - let token: Contract, tokenOut: Contract + let token: Contract, erc4626: Contract beforeEach('deploy tokens', async () => { token = await deployTokenMock('WETH') - tokenOut = await deployTokenMock('ERC4626') - }) - - beforeEach('set connector tokens', async () => { - await connector.setToken(token.address) - await connector.setERC4626(tokenOut.address) + erc4626 = await deployTokenMock('ERC4626') // token out }) context('when the amount is not zero', () => { const amount = fp(10) + const shareValue = fp(2.5) + const minAmountOut = amount.div(shareValue) beforeEach('fund smart vault', async () => { await token.mint(smartVault.address, amount) }) - context('when the token is the underlying token', () => { + context('when the ERC4626 is not zero', () => { context('when the threshold has passed', () => { const threshold = amount @@ -107,15 +104,25 @@ describe('ERC4626Joiner', () => { const itExecutesTheTaskProperly = (requestedAmount: BigNumberish) => { it('executes the expected connector', async () => { - const tx = await task.call(token.address, requestedAmount) + const tx = await task.call(erc4626.address, token.address, requestedAmount, minAmountOut) - const connectorData = connector.interface.encodeFunctionData('join', [amount]) + const connectorData = connector.interface.encodeFunctionData('join', [ + erc4626.address, + token.address, + amount, + minAmountOut, + ]) await assertIndirectEvent(tx, smartVault.interface, 'Executed', { connector, data: connectorData }) - await assertIndirectEvent(tx, connector.interface, 'LogJoin', { amount }) + await assertIndirectEvent(tx, connector.interface, 'LogJoin', { + erc4626, + token, + amount, + minAmountOut, + }) }) it('emits an Executed event', async () => { - const tx = await task.call(token.address, requestedAmount) + const tx = await task.call(erc4626.address, token.address, requestedAmount, minAmountOut) await assertEvent(tx, 'Executed') }) } @@ -126,7 +133,7 @@ describe('ERC4626Joiner', () => { itExecutesTheTaskProperly(requestedAmount) it('does not update any balance connectors', async () => { - const tx = await task.call(token.address, requestedAmount) + const tx = await task.call(erc4626.address, token.address, requestedAmount, minAmountOut) await assertNoEvent(tx, 'BalanceConnectorUpdated') }) @@ -161,7 +168,7 @@ describe('ERC4626Joiner', () => { itExecutesTheTaskProperly(requestedAmount) it('updates the balance connectors properly', async () => { - const tx = await task.call(token.address, amount) + const tx = await task.call(erc4626.address, token.address, amount, minAmountOut) await assertIndirectEvent(tx, smartVault.interface, 'BalanceConnectorUpdated', { id: prevConnectorId, @@ -172,8 +179,8 @@ describe('ERC4626Joiner', () => { await assertIndirectEvent(tx, smartVault.interface, 'BalanceConnectorUpdated', { id: nextConnectorId, - token: tokenOut.address, - amount, + token: erc4626.address, + amount: minAmountOut, added: true, }) }) @@ -190,16 +197,20 @@ describe('ERC4626Joiner', () => { }) it('reverts', async () => { - await expect(task.call(token.address, amount)).to.be.revertedWith('TaskTokenThresholdNotMet') + await expect(task.call(erc4626.address, token.address, amount, minAmountOut)).to.be.revertedWith( + 'TaskTokenThresholdNotMet' + ) }) }) }) - context('when the token is not the underlying token', () => { - const token = ONES_ADDRESS + context('when the ERC4626 is zero', () => { + const erc4626 = ZERO_ADDRESS it('reverts', async () => { - await expect(task.call(token, amount)).to.be.revertedWith('TaskTokenNotUnderlying') + await expect(task.call(erc4626, token.address, amount, minAmountOut)).to.be.revertedWith( + 'TaskERC4626Zero' + ) }) }) }) @@ -208,7 +219,7 @@ describe('ERC4626Joiner', () => { const amount = 0 it('reverts', async () => { - await expect(task.call(token.address, amount)).to.be.revertedWith('TaskAmountZero') + await expect(task.call(ZERO_ADDRESS, token.address, amount, 0)).to.be.revertedWith('TaskAmountZero') }) }) }) @@ -217,14 +228,14 @@ describe('ERC4626Joiner', () => { const token = ZERO_ADDRESS it('reverts', async () => { - await expect(task.call(token, 0)).to.be.revertedWith('TaskTokenZero') + await expect(task.call(ZERO_ADDRESS, token, 0, 0)).to.be.revertedWith('TaskTokenZero') }) }) }) context('when the sender is not authorized', () => { it('reverts', async () => { - await expect(task.call(ZERO_ADDRESS, 0)).to.be.revertedWith('AuthSenderNotAllowed') + await expect(task.call(ZERO_ADDRESS, ZERO_ADDRESS, 0, 0)).to.be.revertedWith('AuthSenderNotAllowed') }) }) })