Skip to content
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 95 additions & 0 deletions contracts/Gateway/INativeTokenGateway.sol
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;
}
24 changes: 24 additions & 0 deletions contracts/Gateway/Interfaces/IVToken.sol
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);
}
16 changes: 16 additions & 0 deletions contracts/Gateway/Interfaces/IWrappedNative.sol
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);
}
5 changes: 5 additions & 0 deletions contracts/Gateway/Interfaces/imports.sol

Copy link
Copy Markdown
Contributor Author

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?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor

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.

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";

Check warning on line 3 in contracts/Gateway/Interfaces/imports.sol

View workflow job for this annotation

GitHub Actions / Lint

imported name ComptrollerHarness is not used
import { VToken } from "@venusprotocol/venus-protocol/contracts/Tokens/VTokens/VToken.sol";

Check warning on line 4 in contracts/Gateway/Interfaces/imports.sol

View workflow job for this annotation

GitHub Actions / Lint

imported name VToken is not used
import { VBep20Delegator } from "@venusprotocol/venus-protocol/contracts/Tokens/VTokens/VBep20Delegator.sol";

Check warning on line 5 in contracts/Gateway/Interfaces/imports.sol

View workflow job for this annotation

GitHub Actions / Lint

imported name VBep20Delegator is not used
3 changes: 3 additions & 0 deletions contracts/Gateway/Interfaces/openzeppelinImports.sol
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";

Check warning on line 3 in contracts/Gateway/Interfaces/openzeppelinImports.sol

View workflow job for this annotation

GitHub Actions / Lint

imported name ERC20 is not used
Loading
Loading