Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 4 additions & 0 deletions contracts/destination/xreceivers/AuthForwarderXReceiver.sol
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ abstract contract AuthForwarderXReceiver is IXReceiver, Ownable {
* @param _amount - The amount of funds received in this transfer
* @param _asset - The asset of the funds received in this transfer
* @param _callData - The data to be prepared and forwarded
* @return the success status of the forwardFunctionCall
*/
function xReceive(
bytes32 _transferId,
Expand Down Expand Up @@ -179,6 +180,7 @@ abstract contract AuthForwarderXReceiver is IXReceiver, Ownable {
* @param _data - The data to be prepared
* @param _amount - The amount of funds received in this transfer
* @param _asset - The asset of the funds received in this transfer
* @return The result of the forward Function call
*/
function prepareAndForward(
bytes32 _transferId,
Expand Down Expand Up @@ -209,6 +211,7 @@ abstract contract AuthForwarderXReceiver is IXReceiver, Ownable {
* @param _data - The data to be prepared
* @param _amount - The amount of funds received in this transfer
* @param _asset - The asset of the funds received in this transfer
* @return encoded data
*/
function _prepare(
bytes32 _transferId,
Expand All @@ -229,6 +232,7 @@ abstract contract AuthForwarderXReceiver is IXReceiver, Ownable {
* @param _transferId - The transfer ID of the transfer that triggered this call
* @param _amount - The amount of funds received in this transfer
* @param _asset - The asset of the funds received in this transfer
* @return the result of the call
*/
function _forwardFunctionCall(
bytes memory _preparedData,
Expand Down
4 changes: 4 additions & 0 deletions contracts/destination/xreceivers/ForwarderXReceiver.sol
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ abstract contract ForwarderXReceiver is IXReceiver {
* @param _amount - The amount of funds received in this transfer.
* @param _asset - The asset of the funds received in this transfer.
* @param _callData - The data to be prepared and forwarded. Fallback address needs to be encoded in the data to be used in case the forward fails.
* @return the success status of the forwardFunctionCall
*/
function xReceive(
bytes32 _transferId,
Expand Down Expand Up @@ -110,6 +111,7 @@ abstract contract ForwarderXReceiver is IXReceiver {
* @param _data - The data to be prepared
* @param _amount - The amount of funds received in this transfer
* @param _asset - The asset of the funds received in this transfer
* @return The result of the forward Function call
*/
function prepareAndForward(
bytes32 _transferId,
Expand Down Expand Up @@ -140,6 +142,7 @@ abstract contract ForwarderXReceiver is IXReceiver {
* @param _data - The data to be prepared
* @param _amount - The amount of funds received in this transfer
* @param _asset - The asset of the funds received in this transfer
* @return encoded data
*/
function _prepare(
bytes32 _transferId,
Expand All @@ -160,6 +163,7 @@ abstract contract ForwarderXReceiver is IXReceiver {
* @param _transferId - The transfer ID of the transfer that triggered this call
* @param _amount - The amount of funds received in this transfer
* @param _asset - The asset of the funds received in this transfer
* @return the result of the call
*/
function _forwardFunctionCall(
bytes memory _preparedData,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ abstract contract SwapForwarderXReceiver is ForwarderXReceiver, SwapAdapter {
* @param _data The data to be swapped.
* @param _amount The amount to be swapped.
* @param _asset The incoming asset to be swapped.
* @return prepared data
*/
function _prepare(
bytes32 _transferId,
Expand Down
2 changes: 2 additions & 0 deletions contracts/shared/Swap/OneInch/OneInchUniswapV3.sol
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ contract OneInchUniswapV3 is ISwapper {
* @param _fromAsset Address of the token to swap from.
* @param _toAsset Address of the token to swap to.
* @param _swapData Data to pass to the 1inch aggregator router.
* @return amountOut Amount of the token received
*/
function swap(
uint256 _amountIn,
Expand Down Expand Up @@ -82,6 +83,7 @@ contract OneInchUniswapV3 is ISwapper {
* @param _amountIn Amount of tokens to swap.
* @param _toAsset Address of the token to swap to.
* @param _swapData Data to pass to the 1inch aggregator router.
* @return amountOut Amount of the token received
*/
function swapETH(
uint256 _amountIn,
Expand Down
2 changes: 2 additions & 0 deletions contracts/shared/Swap/SwapAdapter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ contract SwapAdapter is Ownable2Step {
* @param _toAsset Address of the token to swap to.
* @param _swapData Data to pass to the swapper. This data is encoded for a particular swap router, usually given
* by an API. The swapper will decode the data and re-encode it with the new amountIn.
* @return amountOut Amount that is expected to get received in the swap
*/
function exactSwap(
address _swapper,
Expand Down Expand Up @@ -89,6 +90,7 @@ contract SwapAdapter is Ownable2Step {
* easy swaps on the source side where the amount does not need to be changed.
* @param _swapper Address of the swapper to use.
* @param swapData Data to pass to the swapper. This data is encoded for a particular swap router.
* @return amountOut Amount that is expected to get received in the swap
*/
function directSwapperCall(address _swapper, bytes calldata swapData) external payable returns (uint256 amountOut) {
bytes memory ret = _swapper.functionCallWithValue(swapData, msg.value, "!directSwapperCallFailed");
Expand Down
2 changes: 2 additions & 0 deletions contracts/shared/Swap/Uniswap/UniV2Swapper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ contract UniV2Swapper is ISwapper {
* @param _fromAsset Address of the token to swap from.
* @param _toAsset Address of the token to swap to.
* @param _swapData Data to pass to the UniV2 router.
* @return amountOut Amount of the token received
*/
function swap(
uint256 _amountIn,
Expand Down Expand Up @@ -73,6 +74,7 @@ contract UniV2Swapper is ISwapper {
* @param _amountIn Amount of tokens to swap.
* @param _toAsset Address of the token to swap to.
* @param _swapData Data to pass to the UniV2 router.
* @return amountOut Amount of the token received
*/
function swapETH(
uint256 _amountIn,
Expand Down
2 changes: 2 additions & 0 deletions contracts/shared/Swap/Uniswap/UniV3Swapper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ contract UniV3Swapper is ISwapper {
* @param _fromAsset Address of the token to swap from.
* @param _toAsset Address of the token to swap to.
* @param _swapData Data to pass to the UniV3 router.
* @return amountOut Amount of the token received
*/
function swap(
uint256 _amountIn,
Expand Down Expand Up @@ -82,6 +83,7 @@ contract UniV3Swapper is ISwapper {
* @param _amountIn Amount of tokens to swap.
* @param _toAsset Address of the token to swap to.
* @param _swapData Data to pass to the UniV3 router.
* @return amountOut Amount of the token received
*/
function swapETH(
uint256 _amountIn,
Expand Down
9 changes: 9 additions & 0 deletions contracts/shared/Swap/interfaces/ISwapper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,22 @@
pragma solidity ^0.8.17;

interface ISwapper {
/// @notice Swaps `amountIn` of _tokenIn for as much as possible of _tokenOut
/// @param _amountIn The amount of the token to swap
/// @param _tokenIn The address of the token0
/// @param _tokenOut The amount of the token1
/// @return amountOut The amount of the received token
function swap(
uint256 _amountIn,
address _tokenIn,
address _tokenOut,
bytes calldata _swapData
) external returns (uint256 amountOut);

/// @notice Swaps `amountIn` of ETH for as much as possible of _tokenOut
/// @param _amountIn The amount of the token to swap
/// @param _tokenOut The amount of the token1
/// @return amountOut The amount of the received token
function swapETH(
uint256 _amountIn,
address _tokenOut,
Expand Down