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

feat: swap adapter #281

Draft
wants to merge 28 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
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
Prev Previous commit
Next Next commit
Add natspec
viatrix committed Oct 23, 2024
commit abe40cfe6781987663ddec5442bb41a1be40425c
24 changes: 24 additions & 0 deletions contracts/adapters/SwapAdapter.sol
Original file line number Diff line number Diff line change
@@ -11,6 +11,11 @@ import "../../contracts/adapters/interfaces/INativeTokenAdapter.sol";
import "../../contracts/adapters/interfaces/IWETH.sol";
import "../../contracts/adapters/interfaces/IV3SwapRouter.sol";

/**
@title Contract that swaps tokens to ETH or ETH to tokens using Uniswap
and then makes a deposit to the Bridge.
@author ChainSafe Systems.
*/
contract SwapAdapter is AccessControl {

using SafeERC20 for IERC20;
@@ -59,6 +64,16 @@ contract SwapAdapter is AccessControl {
emit TokenResourceIDSet(token, resourceID);
}

/**
@notice Function for depositing tokens, performing swap to ETH and bridging the ETH.
@param destinationDomainID ID of chain deposit will be bridged to.
@param recipient Recipient of the deposit.
@param token Input token to be swapped.
@param tokenAmount Amount of tokens to be swapped.
@param amountOutMinimum Minimal amount of ETH to be accepted as a swap output.
@param pathTokens Addresses of the tokens for Uniswap swap. WETH address is used for ETH.
@param pathFees Fees for Uniswap pools.
*/
function depositTokensToEth(
uint8 destinationDomainID,
address recipient,
@@ -109,6 +124,15 @@ contract SwapAdapter is AccessControl {
}
}

/**
@notice Function for depositing tokens, performing swap to ETH and bridging the ETH.
MakMuftic marked this conversation as resolved.
Show resolved Hide resolved
@param destinationDomainID ID of chain deposit will be bridged to.
@param recipient Recipient of the deposit.
@param token Output token to be deposited after swapping.
@param amountOutMinimum Minimal amount of tokens to be accepted as a swap output.
@param pathTokens Addresses of the tokens for Uniswap swap. WETH address is used for ETH.
@param pathFees Fees for Uniswap pools.
*/
function depositEthToTokens(
uint8 destinationDomainID,
address recipient,
Loading