Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tasks: Implement ERC4626 liquidity tasks #126

Merged
merged 4 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ interface IERC4626Joiner is IBaseERC4626Task {
/**
* @dev Executes the ERC4626 joiner task
*/
function call(address erc4626, address token, uint256 amount, uint256 minAmountOut) external;
function call(address token, uint256 amount, address erc4626, uint256 minAmountOut) external;
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ contract ERC4626Exiter is IERC4626Exiter, BaseERC4626Task {
function call(address erc4626, uint256 amount, uint256 minAmountOut)
external
override
authP(authParams(erc4626, amount))
authP(authParams(erc4626, amount, minAmountOut))
{
if (amount == 0) amount = getTaskAmount(erc4626);
_beforeERC4626Exiter(erc4626, amount);
Expand Down
10 changes: 5 additions & 5 deletions packages/tasks/contracts/liquidity/erc4626/ERC4626Joiner.sol
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,18 @@ 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 erc4626 Address of the ERC4626 to be joined
* @param minAmountOut Minimum amount of shares willing to receive
*/
function call(address erc4626, address token, uint256 amount, uint256 minAmountOut)
function call(address token, uint256 amount, address erc4626, uint256 minAmountOut)
external
override
authP(authParams(erc4626, token, amount))
authP(authParams(erc4626, token, amount, minAmountOut))
lgalende marked this conversation as resolved.
Show resolved Hide resolved
{
if (amount == 0) amount = getTaskAmount(token);
_beforeERC4626Joiner(erc4626, token, amount);
_beforeERC4626Joiner(token, amount, erc4626);
bytes memory connectorData = abi.encodeWithSelector(
IERC4626Connector.join.selector,
erc4626,
Expand All @@ -88,7 +88,7 @@ contract ERC4626Joiner is IERC4626Joiner, BaseERC4626Task {
/**
* @dev Before ERC4626 joiner hook
*/
function _beforeERC4626Joiner(address erc4626, address token, uint256 amount) internal virtual {
function _beforeERC4626Joiner(address token, uint256 amount, address erc4626) internal virtual {
_beforeBaseERC4626Task(token, amount);
if (erc4626 == address(0)) revert TaskERC4626Zero();
}
Expand Down
18 changes: 9 additions & 9 deletions packages/tasks/test/liquidity/erc4626/ERC4626Joiner.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ describe('ERC4626Joiner', () => {

const itExecutesTheTaskProperly = (requestedAmount: BigNumberish) => {
it('executes the expected connector', async () => {
const tx = await task.call(erc4626.address, token.address, requestedAmount, minAmountOut)
const tx = await task.call(token.address, requestedAmount, erc4626.address, minAmountOut)

const connectorData = connector.interface.encodeFunctionData('join', [
erc4626.address,
Expand All @@ -122,7 +122,7 @@ describe('ERC4626Joiner', () => {
})

it('emits an Executed event', async () => {
const tx = await task.call(erc4626.address, token.address, requestedAmount, minAmountOut)
const tx = await task.call(token.address, requestedAmount, erc4626.address, minAmountOut)
await assertEvent(tx, 'Executed')
})
}
Expand All @@ -133,7 +133,7 @@ describe('ERC4626Joiner', () => {
itExecutesTheTaskProperly(requestedAmount)

it('does not update any balance connectors', async () => {
const tx = await task.call(erc4626.address, token.address, requestedAmount, minAmountOut)
const tx = await task.call(token.address, requestedAmount, erc4626.address, minAmountOut)

await assertNoEvent(tx, 'BalanceConnectorUpdated')
})
Expand Down Expand Up @@ -168,7 +168,7 @@ describe('ERC4626Joiner', () => {
itExecutesTheTaskProperly(requestedAmount)

it('updates the balance connectors properly', async () => {
const tx = await task.call(erc4626.address, token.address, amount, minAmountOut)
const tx = await task.call(token.address, amount, erc4626.address, minAmountOut)

await assertIndirectEvent(tx, smartVault.interface, 'BalanceConnectorUpdated', {
id: prevConnectorId,
Expand Down Expand Up @@ -197,7 +197,7 @@ describe('ERC4626Joiner', () => {
})

it('reverts', async () => {
await expect(task.call(erc4626.address, token.address, amount, minAmountOut)).to.be.revertedWith(
await expect(task.call(token.address, amount, erc4626.address, minAmountOut)).to.be.revertedWith(
'TaskTokenThresholdNotMet'
)
})
Expand All @@ -208,7 +208,7 @@ describe('ERC4626Joiner', () => {
const erc4626 = ZERO_ADDRESS

it('reverts', async () => {
await expect(task.call(erc4626, token.address, amount, minAmountOut)).to.be.revertedWith(
await expect(task.call(token.address, amount, erc4626, minAmountOut)).to.be.revertedWith(
'TaskERC4626Zero'
)
})
Expand All @@ -219,7 +219,7 @@ describe('ERC4626Joiner', () => {
const amount = 0

it('reverts', async () => {
await expect(task.call(ZERO_ADDRESS, token.address, amount, 0)).to.be.revertedWith('TaskAmountZero')
await expect(task.call(token.address, amount, ZERO_ADDRESS, 0)).to.be.revertedWith('TaskAmountZero')
})
})
})
Expand All @@ -228,14 +228,14 @@ describe('ERC4626Joiner', () => {
const token = ZERO_ADDRESS

it('reverts', async () => {
await expect(task.call(ZERO_ADDRESS, token, 0, 0)).to.be.revertedWith('TaskTokenZero')
await expect(task.call(token, 0, ZERO_ADDRESS, 0)).to.be.revertedWith('TaskTokenZero')
})
})
})

context('when the sender is not authorized', () => {
it('reverts', async () => {
await expect(task.call(ZERO_ADDRESS, ZERO_ADDRESS, 0, 0)).to.be.revertedWith('AuthSenderNotAllowed')
await expect(task.call(ZERO_ADDRESS, 0, ZERO_ADDRESS, 0)).to.be.revertedWith('AuthSenderNotAllowed')
})
})
})
Expand Down
Loading