Skip to content

Commit 7c50632

Browse files
authored
Merge pull request #12 from VenusProtocol/feat/VPD-70
[VPD-70] Leverage Manager contract
2 parents 2546af2 + 6fc7438 commit 7c50632

35 files changed

+11629
-1647
lines changed

.prettierignore

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,4 @@ scenario
1010
typechain
1111
contracts/oracle
1212
CHANGELOG.md
13-
docs
14-
15-
# Ignore SwapHelper.sol since it was already audited
16-
contracts/SwapHelper/SwapHelper.sol
13+
docs

.prettierrc

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,30 @@
22
"arrowParens": avoid,
33
"bracketSpacing": true,
44
"endOfLine": "auto",
5-
"importOrder": ["module-alias/register", "<THIRD_PARTY_MODULES>", "^[./]"],
6-
"importOrderParserPlugins": ["typescript"],
5+
"importOrder": [
6+
"module-alias/register",
7+
"<THIRD_PARTY_MODULES>",
8+
"^[./]"
9+
],
10+
"importOrderParserPlugins": [
11+
"typescript"
12+
],
713
"importOrderSeparation": true,
814
"importOrderSortSpecifiers": true,
915
"printWidth": 120,
1016
"singleQuote": false,
1117
"tabWidth": 2,
1218
"trailingComma": all,
13-
"overrides": [{ "files": "*.sol", "options": { "tabWidth": 4 } }],
14-
}
19+
"overrides": [
20+
{
21+
"files": "*.sol",
22+
"options": {
23+
"tabWidth": 4
24+
}
25+
}
26+
],
27+
"plugins": [
28+
"prettier-plugin-solidity",
29+
"@trivago/prettier-plugin-sort-imports"
30+
]
31+
}

.solhint.json

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,26 @@
44
"code-complexity": ["error", 15],
55
"compiler-version": ["error", ">=0.5.0"],
66
"const-name-snakecase": "error",
7+
"immutable-vars-naming": "off",
78
"constructor-syntax": "error",
8-
"func-visibility": ["error", { "ignoreConstructors": true }],
9+
"func-visibility": [
10+
"error",
11+
{
12+
"ignoreConstructors": true
13+
}
14+
],
15+
"function-max-lines": ["warn", 60],
916
"max-line-length": ["error", 175],
1017
"not-rely-on-time": "off",
1118
"no-global-import": "error",
12-
"reason-string": ["warn", { "maxLength": 64 }],
13-
"ordering": "warn"
19+
"reason-string": [
20+
"warn",
21+
{
22+
"maxLength": 64
23+
}
24+
],
25+
"ordering": "warn",
26+
"state-visibility": "off",
27+
"avoid-low-level-calls": "off"
1428
}
1529
}
208 KB
Binary file not shown.
556 KB
Binary file not shown.
3.23 MB
Binary file not shown.
3.6 MB
Binary file not shown.
340 KB
Binary file not shown.
646 KB
Binary file not shown.

contracts/Interfaces.sol

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ interface IVToken is IERC20Upgradeable {
2323

2424
function repayBorrowBehalf(address borrower, uint repayAmount) external returns (uint256);
2525

26+
function redeemUnderlyingBehalf(address redeemer, uint redeemAmount) external returns (uint);
27+
2628
function comptroller() external view returns (IComptroller);
2729

2830
function borrowBalanceStored(address account) external view returns (uint256);
@@ -53,6 +55,8 @@ interface IComptroller {
5355

5456
function enterMarkets(address[] calldata vTokens) external returns (uint256[] memory);
5557

58+
function enterMarketBehalf(address onBehalf, address vToken) external returns (uint256);
59+
5660
function enterMarket(address user, address vToken) external returns (uint256);
5761

5862
function liquidationIncentiveMantissa() external view returns (uint256);
@@ -74,10 +78,60 @@ interface IComptroller {
7478
function getAccountLiquidity(address account) external view returns (uint256, uint256, uint256);
7579

7680
function checkMembership(address account, IVToken vToken) external view returns (bool);
81+
82+
function getBorrowingPower(
83+
address account
84+
) external view returns (uint256 error, uint256 liquidity, uint256 shortfall);
85+
86+
function treasuryPercent() external view returns (uint256);
87+
88+
function executeFlashLoan(
89+
address payable onBehalf,
90+
address payable receiver,
91+
IVToken[] memory vTokens,
92+
uint256[] memory underlyingAmounts,
93+
bytes memory param
94+
) external;
95+
}
96+
97+
interface IFlashLoanReceiver {
98+
/**
99+
* @notice Executes an operation after receiving the flash-borrowed assets.
100+
* @dev Implementation of this function must ensure at least the premium (fee) is repaid within the same transaction.
101+
* Any unpaid balance (principal + premium - repaid amount) will be added to the onBehalf address's borrow balance.
102+
* @param vTokens The vToken contracts corresponding to the flash-borrowed underlying assets.
103+
* @param amounts The amounts of each underlying asset that were flash-borrowed.
104+
* @param premiums The premiums (fees) associated with each flash-borrowed asset.
105+
* @param initiator The address that initiated the flash loan.
106+
* @param onBehalf The address of the user whose debt position will be used for any unpaid flash loan balance.
107+
* @param param Additional parameters encoded as bytes. These can be used to pass custom data to the receiver contract.
108+
* @return success True if the operation succeeds (regardless of repayment amount), false if the operation fails.
109+
* @return repayAmounts Array of uint256 representing the amounts to be repaid for each asset. The receiver contract
110+
* must approve these amounts to the respective vToken contracts before this function returns.
111+
*/
112+
function executeOperation(
113+
IVToken[] calldata vTokens,
114+
uint256[] calldata amounts,
115+
uint256[] calldata premiums,
116+
address initiator,
117+
address onBehalf,
118+
bytes calldata param
119+
) external returns (bool success, uint256[] memory repayAmounts);
77120
}
78121

79122
interface IWBNB is IERC20Upgradeable {
80123
function deposit() external payable;
81124

82125
function withdraw(uint256 amount) external;
83126
}
127+
128+
interface IProtocolShareReserve {
129+
enum IncomeType {
130+
SPREAD,
131+
LIQUIDATION,
132+
ERC4626_WRAPPER_REWARDS,
133+
FLASHLOAN
134+
}
135+
136+
function updateAssetsState(address comptroller, address asset, IncomeType incomeType) external;
137+
}

0 commit comments

Comments
 (0)