-
Notifications
You must be signed in to change notification settings - Fork 0
[VEN-3174]: ERC4626 wrapper for VToken contracts- Core Pool on BNB Chain #2
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
Open
Debugger022
wants to merge
43
commits into
develop
Choose a base branch
from
feat/VEN-3174
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
54d42a0
feat: single factory for bnb chain
Debugger022 a4eadc2
feat: separate wrappers for core and isolated pools
Debugger022 b71d4ad
feat: update interface
Debugger022 317d77a
refactor: rename comptroller interface
Debugger022 0790ebf
fix: lint
Debugger022 3967140
refactor: removing unused functions
Debugger022 b9d7bb9
fix: lint
Debugger022 a650344
feat: update deployment script for factory
Debugger022 33c6f56
feat: updated VenusERC4626 contracts for Core and Isolated
Debugger022 e8c47a2
feat: abstract contract for VenusERC4626
Debugger022 c55995f
refactor: separated initialize logic
Debugger022 aa4c7b4
test: tests for VenusERC4626Isolated
Debugger022 3b57fe3
refactor: change initialize logic for Core wrapper
Debugger022 75c937b
fix: minor changes
Debugger022 5e846b4
test: tests for VenusERC4626Core
Debugger022 a71fa9d
add deployment chain id for networks
Debugger022 2f95779
feat: updating deployment files
Debugger022 e8fd665
refactor: align solidity version and some minor changes
Debugger022 2f91b86
Merge branch 'main' into feat/VEN-3174
Debugger022 f289c15
fix: detailed natspec comments
Debugger022 f65eb09
fix: correct storage layout
Debugger022 98e05be
refactor: remove isCore param
Debugger022 81e7994
fix: use interface instead of abstract contract
Debugger022 199de53
fix: minor fixes
Debugger022 666f288
refactor: remove try-catch
Debugger022 f238e6e
refactor: make coreComptroller immutable
Debugger022 e33dfad
refactor: add storage gap in VenusERC4626
Debugger022 7184421
refactor: make xvsAddress immutable
Debugger022 b602274
fix: update deployment script
Debugger022 b23cf0d
fix: minor fix
Debugger022 3abc1ba
feat: add check for vBNB
Debugger022 4668f44
feat: vew-05
Debugger022 18e5f42
feat: vew-06 and vew-08
Debugger022 74f607f
feat: vew-09
Debugger022 f5dd69b
feat: vew-07 and vew-12
Debugger022 f2e1457
feat: vew-01 and vew-10
Debugger022 9827ccc
feat: vew-02 and vew-03
Debugger022 2f7dd00
feat: vew-04
Debugger022 8d561e6
feat: vew-14
Debugger022 2500fab
fix: vew-03
chechu 32e2cbc
feat: I01
Debugger022 31d358f
fix: vew-08
Debugger022 b835b64
Merge pull request #5 from VenusProtocol/feat/audit-mitigations
Debugger022 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
186 changes: 74 additions & 112 deletions
186
contracts/ERC4626/VenusERC4626.sol → contracts/ERC4626/Base/VenusERC4626.sol
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| pragma solidity 0.8.25; | ||
|
|
||
| import { IComptroller } from "./IComptroller.sol"; | ||
|
|
||
| interface VTokenInterface { | ||
| function mint(uint256 mintAmount) external returns (uint256); | ||
|
|
||
| function redeem(uint256 redeemTokens) external returns (uint256); | ||
|
|
||
| function redeemUnderlying(uint256 redeemAmount) external returns (uint256); | ||
|
|
||
| function accrueInterest() external returns (uint256); | ||
|
|
||
| function balanceOf(address owner) external view returns (uint256); | ||
|
|
||
| function comptroller() external view returns (IComptroller); | ||
|
|
||
| function totalSupply() external view returns (uint256); | ||
|
|
||
| function underlying() external view returns (address); | ||
|
|
||
| function getCash() external view returns (uint256); | ||
|
|
||
| function exchangeRateStored() external view returns (uint256); | ||
|
|
||
| function totalReserves() external view returns (uint256); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| // SPDX-License-Identifier: BSD-3-Clause | ||
| pragma solidity 0.8.25; | ||
|
|
||
| import { VenusERC4626 } from "./Base/VenusERC4626.sol"; | ||
| import { IERC20Upgradeable, SafeERC20Upgradeable } from "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol"; | ||
| import { IProtocolShareReserve } from "./Interfaces/IProtocolShareReserve.sol"; | ||
| import { ensureNonzeroAddress } from "@venusprotocol/solidity-utilities/contracts/validators.sol"; | ||
| import { VTokenInterface } from "./Interfaces/VTokenInterface.sol"; | ||
|
|
||
| /// @title VenusERC4626Core | ||
| /// @notice ERC4626 wrapper for Venus Core Pool vTokens | ||
| contract VenusERC4626Core is VenusERC4626 { | ||
| /// @notice Immutable XVS token address | ||
| /// @custom:oz-upgrades-unsafe-allow state-variable-immutable | ||
| address public immutable XVS_ADDRESS; | ||
|
|
||
| /// @notice Constructor | ||
| /// @custom:oz-upgrades-unsafe-allow constructor | ||
| constructor(address xvsAddress_) { | ||
| ensureNonzeroAddress(xvsAddress_); | ||
| XVS_ADDRESS = xvsAddress_; | ||
| _disableInitializers(); | ||
| } | ||
|
|
||
| /// @notice Initializes the VenusERC4626Core contract | ||
| /// @dev `initialize2` should be invoked to complete the configuration of the vault | ||
| /// @param vToken_ The address of the vToken to be wrapped | ||
| function initialize(address vToken_) public virtual initializer { | ||
| __VenusERC4626_init(vToken_); | ||
| } | ||
|
|
||
| /// @inheritdoc VenusERC4626 | ||
| function claimRewards() external override { | ||
| address[] memory holders = new address[](1); | ||
| holders[0] = address(this); | ||
| VTokenInterface[] memory vTokens = new VTokenInterface[](1); | ||
| vTokens[0] = vToken; | ||
| comptroller.claimVenus(holders, vTokens, false, true); | ||
|
|
||
| IERC20Upgradeable xvs = IERC20Upgradeable(XVS_ADDRESS); | ||
| uint256 rewardAmount = xvs.balanceOf(address(this)); | ||
|
|
||
| if (rewardAmount > 0) { | ||
| SafeERC20Upgradeable.safeTransfer(xvs, rewardRecipient, rewardAmount); | ||
|
|
||
| try | ||
| IProtocolShareReserve(rewardRecipient).updateAssetsState( | ||
| address(comptroller), | ||
| XVS_ADDRESS, | ||
| IProtocolShareReserve.IncomeType.ERC4626_WRAPPER_REWARDS | ||
| ) | ||
| {} catch {} | ||
|
Check warning on line 52 in contracts/ERC4626/VenusERC4626Core.sol
|
||
|
|
||
| emit ClaimRewards(rewardAmount, XVS_ADDRESS); | ||
| } | ||
| } | ||
|
|
||
| /// @notice second function to invoke to complete the initialization | ||
| /// @param accessControlManager_ The address of the access control manager | ||
| /// @param rewardRecipient_ The address that will receive rewards | ||
| /// @param vaultOwner_ The owner of the vault | ||
| function initialize2( | ||
| address accessControlManager_, | ||
| address rewardRecipient_, | ||
| address vaultOwner_ | ||
| ) public virtual reinitializer(2) { | ||
| __VenusERC4626_init2(accessControlManager_, rewardRecipient_, vaultOwner_); | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.