-
Notifications
You must be signed in to change notification settings - Fork 3
[VPD-113]: add NativeTokenGateway compatible with BNB Core pool #8
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
chechu
wants to merge
20
commits into
develop
Choose a base branch
from
feat/VPD-113
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 8 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
6933be7
feat: add original NativeTokenGateway
chechu 83edda0
feat: make the NTG compatible with the BNB Chain Core pool
chechu 381604a
feat: add NTG fork tests and deployments for bsctestnet
Debugger022 e74b6e3
feat: updating deployment files
Debugger022 e00d353
fix: minor fix
Debugger022 299c505
refactor: update deployment of NTG in bsctestnet
Debugger022 452ae55
feat: updating deployment files
Debugger022 6d5b8ca
fix: minor fix
Debugger022 9f8dd2f
feat: add imports for tests
Debugger022 b6eb96c
feat: add unit tests for NTG
Debugger022 04da95d
fix: resolve comments
Debugger022 e00d398
refactor: vlu-02 use constant to NO_ERROR code
chechu 1390846
docs: vlu-01 add missing natspect comments
chechu 2964a5c
feat: add isolated pool NTG contract
Debugger022 9667442
feat: add deployment script for isolated pool NTG
Debugger022 5504dae
feat: add unit and fork tests for isolated pool NTG
Debugger022 32c296b
feat: add NTG deployment for bscmainnet
Debugger022 0a705cf
feat: updating deployment files
Debugger022 fb401ca
docs: audit for NativeTokenGateway compatible with Core pool
chechu 95e157b
refactor: update fork and unit tests of NTG for core pool
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
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,95 @@ | ||
| // SPDX-License-Identifier: BSD-3-Clause | ||
| pragma solidity ^0.8.25; | ||
|
|
||
| import { IERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; | ||
|
|
||
| /** | ||
| * @title INativeTokenGateway | ||
| * @author Venus | ||
| * @notice Interface for NativeTokenGateway contract | ||
| */ | ||
| interface INativeTokenGateway { | ||
| /** | ||
| * @dev Emitted when native currency is supplied | ||
| */ | ||
| event TokensWrappedAndSupplied(address indexed sender, address indexed vToken, uint256 amount); | ||
|
|
||
| /** | ||
| * @dev Emitted when tokens are redeemed and then unwrapped to be sent to user | ||
| */ | ||
| event TokensRedeemedAndUnwrapped(address indexed sender, address indexed vToken, uint256 amount); | ||
|
|
||
| /** | ||
| * @dev Emitted when native tokens are borrowed and unwrapped | ||
| */ | ||
| event TokensBorrowedAndUnwrapped(address indexed sender, address indexed vToken, uint256 amount); | ||
|
|
||
| /** | ||
| * @dev Emitted when native currency is wrapped and repaid | ||
| */ | ||
| event TokensWrappedAndRepaid(address indexed sender, address indexed vToken, uint256 amount); | ||
|
|
||
| /** | ||
| * @dev Emitted when token is swept from the contract | ||
| */ | ||
| event SweepToken(address indexed token, address indexed receiver, uint256 amount); | ||
|
|
||
| /** | ||
| * @dev Emitted when native asset is swept from the contract | ||
| */ | ||
| event SweepNative(address indexed receiver, uint256 amount); | ||
|
|
||
| /** | ||
| * @notice Thrown if transfer of native token fails | ||
| */ | ||
| error NativeTokenTransferFailed(); | ||
|
|
||
| /** | ||
| * @notice Thrown if the supplied address is a zero address where it is not allowed | ||
| */ | ||
| error ZeroAddressNotAllowed(); | ||
|
|
||
| /** | ||
| * @notice Thrown if the supplied value is 0 where it is not allowed | ||
| */ | ||
| error ZeroValueNotAllowed(); | ||
|
|
||
| /** | ||
| * @dev Wrap Native Token, get wNativeToken, mint vWNativeTokens, and supply to the market | ||
| * @param minter The address on behalf of whom the supply is performed | ||
| */ | ||
| function wrapAndSupply(address minter) external payable; | ||
|
|
||
| /** | ||
| * @dev Redeem vWNativeTokens, unwrap to Native Token, and send to the user | ||
| * @param redeemAmount The amount of underlying tokens to redeem | ||
| */ | ||
| function redeemUnderlyingAndUnwrap(uint256 redeemAmount) external; | ||
|
|
||
| /** | ||
| * @dev Redeem vWNativeTokens, unwrap to Native Token, and send to the user | ||
| * @param redeemTokens The amount of vWNative tokens to redeem | ||
| */ | ||
| function redeemAndUnwrap(uint256 redeemTokens) external; | ||
|
|
||
| /** | ||
| * @dev Borrow wNativeToken, unwrap to Native Token, and send to the user | ||
| * @param amount The amount of underlying tokens to borrow | ||
| */ | ||
| function borrowAndUnwrap(uint256 amount) external; | ||
|
|
||
| /** | ||
| * @dev Wrap Native Token, repay borrow in the market, and send remaining Native Token to the user | ||
| */ | ||
| function wrapAndRepay() external payable; | ||
|
|
||
| /** | ||
| * @dev Sweeps input token address tokens from the contract and sends them to the owner | ||
| */ | ||
| function sweepToken(IERC20 token) external; | ||
|
|
||
| /** | ||
| * @dev Sweeps native assets (Native Token) from the contract and sends them to the owner | ||
| */ | ||
| function sweepNative() external; | ||
| } |
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,24 @@ | ||
| // SPDX-License-Identifier: BSD-3-Clause | ||
| pragma solidity ^0.8.25; | ||
|
|
||
| interface IVToken { | ||
| function mintBehalf(address receiver, uint256 mintAmount) external returns (uint256); | ||
|
|
||
| function redeemUnderlyingBehalf(address redeemer, uint256 redeemAmount) external returns (uint256); | ||
|
|
||
| function redeemBehalf(address redeemer, uint256 redeemTokens) external returns (uint256); | ||
|
|
||
| function repayBorrowBehalf(address borrower, uint256 repayAmount) external returns (uint256); | ||
|
|
||
| function borrowBehalf(address borrower, uint256 borrowAmount) external returns (uint256); | ||
|
|
||
| function borrowBalanceCurrent(address account) external returns (uint256); | ||
|
|
||
| function underlying() external returns (address); | ||
|
|
||
| function exchangeRateCurrent() external returns (uint256); | ||
|
|
||
| function transferFrom(address from, address to, uint256 amount) external returns (bool); | ||
|
|
||
| function redeem(uint256 redeemTokens) external 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,16 @@ | ||
| // SPDX-License-Identifier: BSD-3-Clause | ||
| pragma solidity ^0.8.25; | ||
|
|
||
| interface IWrappedNative { | ||
| function deposit() external payable; | ||
|
|
||
| function withdraw(uint256) external; | ||
|
|
||
| function approve(address guy, uint256 wad) external returns (bool); | ||
|
|
||
| function transferFrom(address src, address dst, uint256 wad) external returns (bool); | ||
|
|
||
| function transfer(address dst, uint256 wad) external returns (bool); | ||
|
|
||
| function balanceOf(address account) 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,5 @@ | ||
| pragma solidity ^0.5.16; | ||
|
|
||
| import { ComptrollerHarness } from "@venusprotocol/venus-protocol/contracts/test/ComptrollerHarness.sol"; | ||
| import { VToken } from "@venusprotocol/venus-protocol/contracts/Tokens/VTokens/VToken.sol"; | ||
| import { VBep20Delegator } from "@venusprotocol/venus-protocol/contracts/Tokens/VTokens/VBep20Delegator.sol"; | ||
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,3 @@ | ||
| pragma solidity ^0.8.0; | ||
|
|
||
| import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; | ||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should mix tests and no-tests contracts in the same folder. Moreover, can we replace these imports with any configuration in hardhat?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
04da95d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that we can replace Solidity import statements with Hardhat configuration, as it cannot substitute for actual Solidity imports in the source files.