-
Notifications
You must be signed in to change notification settings - Fork 33
Swaps depositor helper #294
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
Open
dglowinski
wants to merge
12
commits into
development
Choose a base branch
from
swaps-depositor-helper
base: development
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
425307e
add TransferFromSender
dglowinski 10d2602
add transferFromSender tests
dglowinski c14b303
update natspec
dglowinski 96af6ff
fix: rename file
kasperpawlowski 223b8c3
add TransferFromSender
dglowinski 3b46c31
add transferFromSender tests
dglowinski adf2588
update natspec
dglowinski 57d4f87
update natspec and script
dglowinski fd828fa
Merge branch 'development' into swaps-depositor-helper
kasperpawlowski f44c263
Merge branch 'swaps-depositor-helper' of https://github.com/euler-xyz…
kasperpawlowski 6d5a5af
feat: use SafeERC20Permit2Lib
kasperpawlowski 0467fb7
fix: remove redundant file
kasperpawlowski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,17 +3,23 @@ | |
| pragma solidity ^0.8.0; | ||
|
|
||
| import {IEVault, IERC20} from "evk/EVault/IEVault.sol"; | ||
| import {TransferFromSender} from "./TransferFromSender.sol"; | ||
|
|
||
| /// @title SwapVerifier | ||
| /// @custom:security-contact [email protected] | ||
| /// @author Euler Labs (https://www.eulerlabs.com/) | ||
| /// @notice Simple contract used to verify post swap conditions | ||
| /// @dev This contract is the only trusted code in the EVK swap periphery | ||
| contract SwapVerifier { | ||
| contract SwapVerifier is TransferFromSender { | ||
| error SwapVerifier_skimMin(); | ||
| error SwapVerifier_debtMax(); | ||
| error SwapVerifier_pastDeadline(); | ||
|
|
||
| /// @notice Contract constructor | ||
| /// @param evc Address of the EthereumVaultConnector contract | ||
| /// @param permit2 Address of the Permit2 contract | ||
| constructor(address evc, address permit2) TransferFromSender(evc, permit2) {} | ||
|
|
||
| /// @notice Verify results of a regular swap, when bought tokens are sent to the vault and skim for the buyer | ||
| /// @param vault The EVault to query | ||
| /// @param receiver Account to skim to | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| // SPDX-License-Identifier: GPL-2.0-or-later | ||
|
|
||
| pragma solidity ^0.8.0; | ||
|
|
||
| import {IERC20} from "evk/EVault/IEVault.sol"; | ||
| import {SafeERC20Lib} from "evk/EVault/shared/lib/SafeERC20Lib.sol"; | ||
| import {EVCUtil} from "ethereum-vault-connector/utils/EVCUtil.sol"; | ||
|
|
||
| /// @title TransferFromSender | ||
| /// @custom:security-contact [email protected] | ||
| /// @author Euler Labs (https://www.eulerlabs.com/) | ||
| /// @notice Simple contract used to pull tokens from the sender. | ||
| /// @dev This contract is trusted and can safely receive allowance on token transfers from users. | ||
| contract TransferFromSender is EVCUtil { | ||
| using SafeERC20Lib for IERC20; | ||
|
|
||
| error TransferFromSender_InvalidAddress(); | ||
|
|
||
| /// @notice Address of Permit2 contract | ||
| address public immutable permit2; | ||
|
|
||
| /// @notice Contract constructor | ||
| /// @param _permit2 Address of the Permit2 contract | ||
| constructor(address _evc, address _permit2) EVCUtil(_evc) { | ||
| if (_permit2 == address(0)) revert TransferFromSender_InvalidAddress(); | ||
| permit2 = _permit2; | ||
| } | ||
|
|
||
| /// @notice Pull tokens from sender to the designated receiver | ||
| /// @param token ERC20 token address | ||
| /// @param amount Amount of the token to transfer | ||
| /// @param to Receiver of the token | ||
| function transferFromSender(address token, uint256 amount, address to) public { | ||
| IERC20(token).safeTransferFrom(_msgSender(), to, amount, permit2); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.