|
| 1 | +// SPDX-License-Identifier: BSD-3-Clause |
| 2 | +pragma solidity 0.8.28; |
| 3 | + |
| 4 | +/** |
| 5 | + * @title ISwapRouter |
| 6 | + * @author Venus Protocol |
| 7 | + * @notice Interface for the SwapRouter contract implementing swap features |
| 8 | + */ |
| 9 | +interface ISwapRouter { |
| 10 | + /** |
| 11 | + * @notice Swaps tokens and supplies the result to a Venus market |
| 12 | + * @param vToken The vToken market to supply to |
| 13 | + * @param tokenIn The input token to swap from |
| 14 | + * @param amountIn The amount of input tokens to swap |
| 15 | + * @param minAmountOut The minimum amount of output tokens expected |
| 16 | + * @param swapCallData Array of bytes containing swap instructions |
| 17 | + * @custom:event Emits SwapAndSupply event |
| 18 | + */ |
| 19 | + function swapAndSupply( |
| 20 | + address vToken, |
| 21 | + address tokenIn, |
| 22 | + uint256 amountIn, |
| 23 | + uint256 minAmountOut, |
| 24 | + bytes calldata swapCallData |
| 25 | + ) external payable; |
| 26 | + |
| 27 | + /** |
| 28 | + * @notice Swaps native tokens (BNB) and supplies to a Venus market |
| 29 | + * @param vToken The vToken market to supply to |
| 30 | + * @param minAmountOut The minimum amount of output tokens expected |
| 31 | + * @param swapCallData Array of bytes containing swap instructions |
| 32 | + * @custom:event Emits SwapAndSupply event |
| 33 | + */ |
| 34 | + function swapNativeAndSupply(address vToken, uint256 minAmountOut, bytes calldata swapCallData) external payable; |
| 35 | + |
| 36 | + /** |
| 37 | + * @notice Swaps tokens and repays debt to a Venus market |
| 38 | + * @param vToken The vToken market to repay debt to |
| 39 | + * @param tokenIn The input token to swap from |
| 40 | + * @param amountIn The amount of input tokens to swap |
| 41 | + * @param minAmountOut The minimum amount of output tokens expected |
| 42 | + * @param swapCallData Array of bytes containing swap instructions |
| 43 | + * @custom:event Emits SwapAndRepay event |
| 44 | + */ |
| 45 | + function swapAndRepay( |
| 46 | + address vToken, |
| 47 | + address tokenIn, |
| 48 | + uint256 amountIn, |
| 49 | + uint256 minAmountOut, |
| 50 | + bytes calldata swapCallData |
| 51 | + ) external payable; |
| 52 | + |
| 53 | + /** |
| 54 | + * @notice Swaps native tokens and repays debt to a Venus market |
| 55 | + * @param vToken The vToken market to repay debt to |
| 56 | + * @param minAmountOut The minimum amount of output tokens expected |
| 57 | + * @param swapCallData Array of bytes containing swap instructions |
| 58 | + * @custom:event Emits SwapAndRepay event |
| 59 | + */ |
| 60 | + function swapNativeAndRepay(address vToken, uint256 minAmountOut, bytes calldata swapCallData) external payable; |
| 61 | + |
| 62 | + /** |
| 63 | + * @notice Swaps tokens and repays the full debt for a user |
| 64 | + * @param vToken The vToken market to repay full debt to |
| 65 | + * @param tokenIn The input token to swap from |
| 66 | + * @param maxAmountIn The maximum amount of input tokens to use |
| 67 | + * @param swapCallData Array of bytes containing swap instructions |
| 68 | + * @custom:event Emits SwapAndRepay event |
| 69 | + */ |
| 70 | + function swapAndRepayFull( |
| 71 | + address vToken, |
| 72 | + address tokenIn, |
| 73 | + uint256 maxAmountIn, |
| 74 | + bytes calldata swapCallData |
| 75 | + ) external payable; |
| 76 | + |
| 77 | + /** |
| 78 | + * @notice Swaps native tokens and repays the full debt for a user |
| 79 | + * @param vToken The vToken market to repay full debt to |
| 80 | + * @param swapCallData Array of bytes containing swap instructions |
| 81 | + * @custom:event Emits SwapAndRepay event |
| 82 | + */ |
| 83 | + function swapNativeAndRepayFull(address vToken, bytes calldata swapCallData) external payable; |
| 84 | + |
| 85 | + /** |
| 86 | + * @notice Sweeps leftover ERC-20 tokens from the contract |
| 87 | + * @param token The token to sweep |
| 88 | + * @custom:event Emits SweepToken event |
| 89 | + */ |
| 90 | + function sweepToken(address token) external; |
| 91 | + |
| 92 | + /** |
| 93 | + * @notice Sweeps leftover native tokens from the contract |
| 94 | + * @custom:event Emits SweepNative event |
| 95 | + */ |
| 96 | + function sweepNative() external; |
| 97 | +} |
0 commit comments