Skip to content

Commit c4a7e6b

Browse files
authored
Merge pull request #16 from VenusProtocol/feat/swapRouter
[VPD-479]: Swap Router
2 parents 20676c0 + 65165ef commit c4a7e6b

29 files changed

+10894
-42
lines changed

.gitignore

Lines changed: 44 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,73 @@
11
node_modules
2+
node_modules_tmp
23
.env
3-
coverage
4-
coverage.json
5-
typechain
6-
.openzeppelin
7-
#Hardhat files
4+
secrets.json
5+
6+
# Hardhat
87
cache
98
cache-zk
109
artifacts
1110
artifacts-zk
11+
typechain
12+
.openzeppelin
1213

13-
#Compound
14-
allFiredEvents
15-
.build-temp
14+
# Coverage
15+
coverage
16+
coverage.json
17+
coverageEnv
18+
19+
# Build
20+
dist
21+
docs
1622
build
1723
build_
18-
node_modules
19-
.env
24+
.build
25+
.build-temp
26+
.tsbuilt
27+
28+
# Certora
2029
.certora*
2130
certora_*
22-
coverage/
23-
coverage.json
24-
coverageEnv/
25-
emv-*/
26-
formulas/
27-
outputs/
28-
Reports/
29-
scTopics
30-
test-results.xml
31-
.tsbuilt
32-
yarn-error.log
33-
scenario/build/webpack.js
34-
.scencache
35-
.solcache
36-
.solcachecov
37-
scenario/.tscache
3831
script/certora
32+
33+
# Tests
34+
test-results.xml
35+
junit.xml
36+
allFiredEvents
3937
tests/scenarios/
4038
tests/Scenarios/
41-
junit.xml
42-
.build
43-
.last_confs
44-
node_modules_tmp
45-
.idea
4639

47-
secrets.json
40+
# Solidity
41+
.solcache
42+
.solcachecov
43+
formulas
44+
outputs
45+
Reports
46+
scTopics
47+
48+
# Scenario
49+
scenario/build/webpack.js
50+
scenario/.tscache
51+
.scencache
52+
emv-*/
4853

49-
# yarn
54+
# Yarn
55+
yarn-error.log
5056
.yarn/*
5157
!.yarn/patches
5258
!.yarn/releases
5359
!.yarn/plugins
5460
!.yarn/sdks
5561
!.yarn/versions
5662

57-
# Build
58-
dist
59-
docs
60-
63+
# Generated/External
6164
contracts/oracle/*
6265
contracts/generated
6366
deployments/localhost
6467

68+
# IDE
69+
.idea
70+
.last_confs
71+
6572
# OSX
6673
.DS_Store
200 KB
Binary file not shown.
218 KB
Binary file not shown.

contracts/Interfaces.sol

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// SPDX-License-Identifier: BSD-3-Clause
2+
pragma solidity ^0.8.25;
3+
4+
import { IVToken } from "./Interfaces/IVToken.sol";
5+
import { IComptroller } from "./Interfaces/IComptroller.sol";
6+
import { IVBNB } from "./Interfaces/IVBNB.sol";
7+
import { IWBNB } from "./Interfaces/IWBNB.sol";
8+
import { IFlashLoanReceiver } from "./Interfaces/IFlashLoanReceiver.sol";
9+
import { IProtocolShareReserve } from "./Interfaces/IProtocolShareReserve.sol";

contracts/Interfaces/IVBNB.sol

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ pragma solidity ^0.8.25;
44
import { IVToken } from "../Interfaces/IVToken.sol";
55

66
interface IVBNB is IVToken {
7+
function mint() external payable;
8+
79
function repayBorrowBehalf(address borrower) external payable;
810

911
function liquidateBorrow(address borrower, IVToken vTokenCollateral) external payable;
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
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

Comments
 (0)