-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from VenusProtocol/feat/passive-swap
[VEN-1462]: Risk Fund and XVS Converter
- Loading branch information
Showing
97 changed files
with
50,976 additions
and
2,734 deletions.
There are no files selected for viewing
This file contains 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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file contains 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,10 @@ | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
pragma solidity 0.8.13; | ||
|
||
interface IComptroller { | ||
function isComptroller() external view returns (bool); | ||
|
||
function markets(address) external view returns (bool); | ||
|
||
function getAllMarkets() external view returns (address[] memory); | ||
} |
This file contains 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,46 @@ | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
pragma solidity 0.8.13; | ||
|
||
import { IAbstractTokenConverter } from "../TokenConverter/IAbstractTokenConverter.sol"; | ||
|
||
/** | ||
* @title IConverterNetwork | ||
* @author Venus | ||
* @notice Interface implemented by `ConverterNetwork`. | ||
*/ | ||
interface IConverterNetwork { | ||
/// @notice Adds new converter to the array | ||
/// @param _tokenConverter Address of the token converter | ||
function addTokenConverter(IAbstractTokenConverter _tokenConverter) external; | ||
|
||
/// @notice Removes converter from the array | ||
/// @param _tokenConverter Address of the token converter | ||
function removeTokenConverter(IAbstractTokenConverter _tokenConverter) external; | ||
|
||
/// @notice Used to get the array of converters supporting conversions, arranged in descending order based on token balances | ||
/// @param _tokenAddressIn Address of tokenIn | ||
/// @param _tokenAddressOut Address of tokenOut | ||
/// @return converters Array of the conveters on the basis of the tokens pair | ||
/// @return convertersBalance Array of balances with respect to token out | ||
function findTokenConverters(address _tokenAddressIn, address _tokenAddressOut) | ||
external | ||
returns (address[] memory converters, uint256[] memory convertersBalance); | ||
|
||
/// @notice Used to get the array of converters supporting conversions, arranged in descending order based on token balances | ||
/// @param _tokenAddressIn Address of tokenIn | ||
/// @param _tokenAddressOut Address of tokenOut | ||
/// @return converters Array of the conveters on the basis of the tokens pair | ||
/// @return convertersBalance Array of balances with respect to token out | ||
function findTokenConvertersForConverters(address _tokenAddressIn, address _tokenAddressOut) | ||
external | ||
returns (address[] memory converters, uint256[] memory convertersBalance); | ||
|
||
/// @notice This function returns the array containing all the converters addresses | ||
/// @return Array containing all the converters addresses | ||
function getAllConverters() external view returns (IAbstractTokenConverter[] memory); | ||
|
||
/// @notice This function checks for given address is converter or not | ||
/// @param _tokenConverter Address of the token converter | ||
/// @return boolean true if given address is converter otherwise false | ||
function isTokenConverter(address _tokenConverter) external view returns (bool); | ||
} |
This file contains 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,10 @@ | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
pragma solidity 0.8.13; | ||
|
||
interface IPoolRegistry { | ||
/// @notice Get VToken in the Pool for an Asset | ||
function getVTokenForAsset(address comptroller, address asset) external view returns (address); | ||
|
||
/// @notice Get the addresss of the Pools supported that include a market for the provided asset | ||
function getPoolsSupportedByAsset(address asset) external view returns (address[] memory); | ||
} |
This file contains 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,28 @@ | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
pragma solidity 0.8.13; | ||
|
||
/** | ||
* @title IRiskFund | ||
* @author Venus | ||
* @notice Interface implemented by `RiskFund`. | ||
*/ | ||
interface IRiskFund { | ||
function transferReserveForAuction(address comptroller, uint256 amount) external returns (uint256); | ||
|
||
function updatePoolState( | ||
address comptroller, | ||
address asset, | ||
uint256 amount | ||
) external; | ||
|
||
function getPoolsBaseAssetReserves(address comptroller) external view returns (uint256); | ||
} | ||
|
||
/** | ||
* @title IRiskFundGetters | ||
* @author Venus | ||
* @notice Interface implemented by `RiskFund` for getter methods. | ||
*/ | ||
interface IRiskFundGetters { | ||
function convertibleBaseAsset() external view returns (address); | ||
} |
This file contains 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,8 @@ | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
pragma solidity 0.8.13; | ||
|
||
interface IRiskFundConverter { | ||
function updateAssetsState(address comptroller, address asset) external; | ||
|
||
function getPools(address asset) external view returns (address[] memory); | ||
} |
This file contains 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,11 @@ | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
pragma solidity 0.8.13; | ||
|
||
/** | ||
* @title IShortfall | ||
* @author Venus | ||
* @notice Interface implemented by `Shortfall`. | ||
*/ | ||
interface IShortfall { | ||
function convertibleBaseAsset() external returns (address); | ||
} |
This file contains 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,9 @@ | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
pragma solidity 0.8.13; | ||
|
||
/// @title IXVSVaultProxy | ||
/// @author Venus | ||
/// @notice Interface implemented by `XVSVault`. | ||
interface IXVSVault { | ||
function xvsStore() external view returns (address); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains 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 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,67 @@ | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
pragma solidity 0.8.13; | ||
|
||
import { Ownable2StepUpgradeable } from "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol"; | ||
import { ReentrancyGuardUpgradeable } from "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol"; | ||
|
||
/// @title ReserveHelpersStorage | ||
/// @author Venus | ||
/// @dev Reserve helpers storage | ||
/// @custom:security-contact https://github.com/VenusProtocol/protocol-reserve#discussion | ||
contract ReserveHelpersStorage is Ownable2StepUpgradeable { | ||
/// @notice Deprecated slot for assetReserves mapping | ||
bytes32 private __deprecatedSlot1; | ||
|
||
/// @notice Available asset's fund per pool in RiskFund | ||
/// Comptroller(pool) -> Asset -> amount | ||
mapping(address => mapping(address => uint256)) public poolAssetsFunds; | ||
|
||
/// @notice Deprecated slot for poolRegistry address | ||
bytes32 private __deprecatedSlot2; | ||
/// @notice Deprecated slot for status variable | ||
bytes32 private __deprecatedSlot3; | ||
|
||
/// @dev This empty reserved space is put in place to allow future versions to add new | ||
/// variables without shifting down storage in the inheritance chain. | ||
uint256[46] private __gap; | ||
} | ||
|
||
/// @title MaxLoopsLimitHelpersStorage | ||
/// @author Venus | ||
/// @dev Max loop limit helpers storage | ||
/// @custom:security-contact https://github.com/VenusProtocol/protocol-reserve#discussion | ||
contract MaxLoopsLimitHelpersStorage { | ||
/// @notice Limit for the loops to avoid the DOS | ||
/// @notice This state is deprecated, using it to prevent storage collision | ||
uint256 public maxLoopsLimit; | ||
|
||
/// @dev This empty reserved space is put in place to allow future versions to add new | ||
/// variables without shifting down storage in the inheritance chain. | ||
/// See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps | ||
uint256[49] private __gap; | ||
} | ||
|
||
/// @title RiskFundV1Storage | ||
/// @author Venus | ||
/// @dev Risk fund V1 storage | ||
/// @custom:security-contact https://github.com/VenusProtocol/protocol-reserve#discussion | ||
contract RiskFundV1Storage is ReserveHelpersStorage, MaxLoopsLimitHelpersStorage { | ||
/// @notice Address of base asset | ||
address public convertibleBaseAsset; | ||
/// @notice Address of shortfall contract | ||
address public shortfall; | ||
|
||
/// @notice This state is deprecated, using it to prevent storage collision | ||
address private pancakeSwapRouter; | ||
/// @notice This state is deprecated, using it to prevent storage collision | ||
uint256 private minAmountToConvert; | ||
} | ||
|
||
/// @title RiskFundV2Storage | ||
/// @author Venus | ||
/// @dev Risk fund V2 storage | ||
/// @custom:security-contact https://github.com/VenusProtocol/protocol-reserve#discussion | ||
contract RiskFundV2Storage is RiskFundV1Storage, ReentrancyGuardUpgradeable { | ||
/// @notice Risk fund converter address | ||
address public riskFundConverter; | ||
} |
Oops, something went wrong.