Skip to content
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

[VEN-1462]: Risk Fund and XVS Converter #9

Merged
merged 213 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
213 commits
Select commit Hold shift + click to select a range
f473ffc
refactor: removed duplicate folders and files
Debugger022 Jul 17, 2023
89138f0
upgrade: oracle dependency verion
Debugger022 Jul 18, 2023
848271f
feat: absract token transformer
Debugger022 Jul 18, 2023
08d449b
feat: risk fund contract
Debugger022 Jul 18, 2023
89c4bf8
feat: ven-1471 risk fund transformer
Debugger022 Jul 18, 2023
6a90a8a
tests: ven-1471 risk fund transformer
Debugger022 Jul 18, 2023
78c27c7
refactor: upgrade oracle dependency version
Debugger022 Jul 18, 2023
b380587
refactor: risk fund storage layout
Debugger022 Jul 19, 2023
443eedb
refactor: folder and files structure
Debugger022 Jul 19, 2023
57a465e
refactor: changes name from swap to transform
Debugger022 Jul 19, 2023
23b6698
refactor: files names
Debugger022 Jul 19, 2023
f18c2a0
refactor: ven-1748 risk fund V2
Debugger022 Jul 19, 2023
a2ddf1e
tests: ven-1748 riskfund unit tests
Debugger022 Jul 20, 2023
8319971
feat: ven-1472 xvs vault transformer
Debugger022 Jul 21, 2023
cf8f101
feat: ven-1473 xvs vault treasury
Debugger022 Jul 21, 2023
66b33fe
refactor: added preSweepToken and updateAssetsPrice
Debugger022 Jul 24, 2023
ecbb1ab
fix: pr comments
Debugger022 Jul 25, 2023
c3f500e
refactor: abstract transformer
Debugger022 Jul 26, 2023
1f7fa40
refactor: RiskFund and AbstractTransformer
Debugger022 Jul 26, 2023
6622481
refactor: remove redundant reading of assetsReserves storage
Debugger022 Jul 26, 2023
3b21bc7
fix: get amount method
Debugger022 Jul 26, 2023
f64f521
tests: fixed transformer tests
Debugger022 Jul 27, 2023
759887a
wip
Debugger022 Jul 27, 2023
a348fc0
tests: ven-1785 getAmount() risk fund transformer
Debugger022 Jul 31, 2023
631c1a9
tests: ven-1785 risk fund transformer
Debugger022 Aug 1, 2023
e80fbf4
refactor: abstract transformer tests
Debugger022 Aug 2, 2023
e45db93
refactor: added reserve helpers methods
Debugger022 Aug 3, 2023
3743f49
fix: lint issues
Debugger022 Aug 3, 2023
20ccc98
refactor: ven-1790 transformer to converter
Debugger022 Aug 3, 2023
caf7c41
fix: updatedsolidity-coverage depedency package
Debugger022 Aug 4, 2023
628a46c
Merge branch 'develop' into feat/passive-swap
Debugger022 Aug 4, 2023
b6ba439
update: yarn.lock
Debugger022 Aug 4, 2023
cbb1651
fix: gas optimization for riskfundv2
Debugger022 Aug 16, 2023
81bfa06
fix: pr comments
Debugger022 Aug 16, 2023
1d037fd
merge branch 'develop' into feat/passive-swap
Debugger022 Aug 16, 2023
57dceb0
feat: ven-1827 added core pool in risk fund converter
Debugger022 Aug 16, 2023
91bbfbb
feat: ven-1828 added sweep token in risk fund
Debugger022 Aug 16, 2023
a8068a7
tests: ven-1827 added core pool in the risk fund
Debugger022 Aug 16, 2023
64218e3
tests: ven-1828 added sweepToken method for risk fund v2
Debugger022 Aug 16, 2023
bbaf19a
feat: ven-1834 functionality for multiple assets in risk fund
Debugger022 Aug 17, 2023
e9a5c0f
refactor: undo base asset changes
Debugger022 Aug 18, 2023
46cd2cb
feat: added setter for the direct transfer assets for riskfund
Debugger022 Aug 18, 2023
e1bd562
refactor: ensure market listed in any pool
Debugger022 Aug 18, 2023
5cc6107
refactor: risk fund storage
Debugger022 Aug 18, 2023
0fb7f1d
Merge pull request #12 from VenusProtocol/VEN-1827/1828
Debugger022 Aug 20, 2023
d4240a0
refactor: is market listed for core pool logic
Debugger022 Aug 21, 2023
e766511
refactor: added functionality to set false in pool assets direct tran…
Debugger022 Aug 23, 2023
3d64345
fix: pr comments
Debugger022 Aug 24, 2023
3ca655c
Merge pull request #13 from VenusProtocol/fix/ven-1827
Debugger022 Aug 25, 2023
d099e97
tests: refactor converter fork tests
Debugger022 Aug 25, 2023
255e01a
fix: fork tests for risk fund converter
Debugger022 Aug 28, 2023
6871238
fix: make comptroller and vBNB immutable
Debugger022 Aug 29, 2023
1a41ef5
feat: support for native wrapped token
Debugger022 Aug 29, 2023
571b3bb
Merge pull request #15 from VenusProtocol/fix/ven-1827
chechu Aug 29, 2023
a314d49
Merge branch 'develop' into feat/passive-swap
chechu Aug 29, 2023
cc3d674
refactor: fixing the order of functions following linter
chechu Aug 29, 2023
f05bba5
refactor: isMarketListed method
Debugger022 Sep 1, 2023
a45d994
tests: fork tests for resume/pause and set oracle in conversion
Debugger022 Sep 1, 2023
aee3c6c
feat: ven-1883 deployment script for riskFundConverter
Debugger022 Sep 1, 2023
cdf4466
fix: resolved merge conflicts
Debugger022 Sep 3, 2023
14d56fb
fix: postConversionHook error
Debugger022 Sep 3, 2023
22865a0
tests: fork tests for native wrapped tokens
Debugger022 Sep 3, 2023
15c252d
fix: post conversion hook bug
Debugger022 Sep 4, 2023
26e3828
feat: add getters for getAmountIn and getAmountOut
Debugger022 Sep 8, 2023
7fd547e
fix: n1
Debugger022 Sep 9, 2023
2d18458
fix: n2
Debugger022 Sep 9, 2023
624b0f1
fix: n3
Debugger022 Sep 9, 2023
a1e6697
fix: pve-001
Debugger022 Sep 9, 2023
fd20124
fix: pve-002
Debugger022 Sep 9, 2023
74f9cb2
fix: pve-005
Debugger022 Sep 9, 2023
92342eb
fix: pve-003
Debugger022 Sep 9, 2023
057dcee
fix: pve-003-2
Debugger022 Sep 9, 2023
3de3561
Merge pull request #17 from VenusProtocol/VEN-1911
Debugger022 Sep 11, 2023
5d1c6b3
fix: added miannet addresses in the convertor script
Debugger022 Sep 11, 2023
0e46af5
Merge pull request #16 from VenusProtocol/VEN-1882/1883
Debugger022 Sep 11, 2023
87f0532
merge branch 'feat/passive-swap' into feat/abstract-token-converter-g…
Debugger022 Sep 11, 2023
a0d3f2a
fix: pr comments
Debugger022 Sep 11, 2023
ca8f8ba
Merge pull request #19 from VenusProtocol/feat/abstract-token-convert…
Debugger022 Sep 11, 2023
b467b46
fix:ven-2007 l-01
Debugger022 Sep 26, 2023
0f58716
fix: ven-2007 l-02
Debugger022 Sep 26, 2023
a555053
fix: ven-2007 l-04
Debugger022 Sep 26, 2023
e558b15
fix: ven-2007 l-06
Debugger022 Sep 26, 2023
5d0f03b
fix: ven-2007 n-01
Debugger022 Sep 26, 2023
91eb7a6
fix: ven-2007 n-02
Debugger022 Sep 26, 2023
1e367e1
fix: ven-2007 n-03
Debugger022 Sep 26, 2023
8d6389c
fix: ven-2007 n-04
Debugger022 Sep 26, 2023
8227f4b
fix: ven-2007 n-06
Debugger022 Sep 26, 2023
78150be
fix: ven-2007 n-09
Debugger022 Sep 27, 2023
bda9bea
fix: ven-2007 n-08
Debugger022 Sep 27, 2023
3876d3b
fix: ven-2007 n-10
Debugger022 Sep 27, 2023
2be108d
fix: ven-2007 l-08
Debugger022 Sep 27, 2023
35dc0a1
fix: ven-2007 l-05
Debugger022 Sep 27, 2023
4025db0
fix: ven-2007 m-01
Debugger022 Sep 27, 2023
939da0a
fix: ven-2007 m-02
Debugger022 Sep 27, 2023
a842667
fix: ven-2007 l-03
Debugger022 Sep 27, 2023
7c18feb
fix: minor fixes
Debugger022 Sep 28, 2023
39eea6f
refactor: used unchecked for variables and added netspec for events
Debugger022 Oct 3, 2023
08bacb3
fix: ven-2007 n-07
Debugger022 Oct 3, 2023
9c2d122
Merge pull request #24 from VenusProtocol/VEN-2007
Debugger022 Oct 3, 2023
e5ad0df
fix: resolved conflicts
Debugger022 Oct 4, 2023
a71fe6f
fix: ATC-05
Debugger022 Oct 11, 2023
ecc0c21
fix: VPB-04
Debugger022 Oct 11, 2023
2848374
fix: VPB-05
Debugger022 Oct 11, 2023
20cd1b1
fix: VPB-12
Debugger022 Oct 11, 2023
83e5e1b
fix: RFC-04
Debugger022 Oct 11, 2023
42e67b7
fix: RFV-06
Debugger022 Oct 11, 2023
17a377c
fix: VPB-03
Debugger022 Oct 11, 2023
f76345d
fix: ATC-01
Debugger022 Oct 11, 2023
9f579b1
fix: TCV-01
Debugger022 Oct 11, 2023
06914bd
fix: RFC-02
Debugger022 Oct 11, 2023
df2eeb4
fix: VPB-10
Debugger022 Oct 11, 2023
e991342
fix: VPB-14
Debugger022 Oct 12, 2023
ade9bda
fix: VPB-01
Debugger022 Oct 12, 2023
cf5e371
fix: RFV-03
Debugger022 Oct 12, 2023
e37341c
fix: ATC-04
Debugger022 Oct 12, 2023
b04357d
fix: VPB-06
Debugger022 Oct 16, 2023
1c558e8
fix: ATC-04
Debugger022 Oct 16, 2023
9145119
fix: VPB-09
Debugger022 Oct 16, 2023
dc70688
fix: pr comments
Debugger022 Oct 16, 2023
6205aac
refactor: updated deployment script for riskFundConverter
Debugger022 Oct 16, 2023
a5caf65
fix: ATC-03
Debugger022 Oct 18, 2023
b8e3e7b
fix: VPB-13
Debugger022 Oct 18, 2023
91402dc
refactor: VEN-2064
Debugger022 Oct 18, 2023
7f289d0
refactor: added some checks for the non supporting fee tokens
Debugger022 Oct 20, 2023
df13780
refactor: updated function names and getters for token amount to not …
Debugger022 Oct 23, 2023
98779f0
refactor: updated deployment script to add poolLiquidStakedBNB
Debugger022 Oct 23, 2023
bcf659b
chore: updated natspec comments for AbstractTokenConverter
Debugger022 Oct 25, 2023
188562d
feat: added ConverterNetwork contract and tests
Debugger022 Oct 26, 2023
268a107
feat: added private conversion functionality
Debugger022 Oct 26, 2023
fa43b9a
refactor: added checks for private conversion
Debugger022 Oct 27, 2023
e139c4b
refactor: added or updated some checks for the token converter
Debugger022 Oct 27, 2023
2d3c3f8
tests: added integration tests for converter and converterNetwork
Debugger022 Oct 27, 2023
108897b
tests: added tests for checks in token converter
Debugger022 Oct 30, 2023
7458733
fixup: VPB-03
Debugger022 Oct 31, 2023
b483870
fixup: VPB-06
Debugger022 Oct 31, 2023
d0c5d17
fixup: VPU-01
Debugger022 Oct 31, 2023
f2021e5
fixup: ATC-06
Debugger022 Oct 31, 2023
24aa165
tests: added ut for private conversions
Debugger022 Nov 1, 2023
cd353bd
fix: resolved merge conflicts
Debugger022 Nov 1, 2023
edd7361
fixup: undo ATC-06
Debugger022 Nov 1, 2023
3e60089
fix: resolve comments
Debugger022 Nov 1, 2023
5e6aa8b
fix: merge conflicts
Debugger022 Nov 2, 2023
176a6f5
fix: pr comments
Debugger022 Nov 2, 2023
921b5d8
refactor: added states for conversion accessibility
Debugger022 Nov 5, 2023
3aebab5
Merge pull request #29 from VenusProtocol/VEN-2043
Debugger022 Nov 6, 2023
23d4e99
fix: pr comments
Debugger022 Nov 6, 2023
f8a8179
fix: TCP-04
Debugger022 Nov 9, 2023
cdd9e14
fix: TCP-05
Debugger022 Nov 9, 2023
11352cd
fix: ATT-02
Debugger022 Nov 9, 2023
abe7ead
fix: ATT-01
Debugger022 Nov 9, 2023
f52d56a
fix: CNC-02
Debugger022 Nov 9, 2023
2ba7503
fix: CNC-04
chechu Nov 20, 2023
73bc544
fix: TCP-06
Debugger022 Nov 21, 2023
f4c8d1e
fix: TCP-03
Debugger022 Nov 21, 2023
72e1b37
fix: add reentrancy guard to getPoolAssetReserve function
Debugger022 Nov 22, 2023
8467d36
Merge pull request #38 from VenusProtocol/VEN-2140
Debugger022 Nov 22, 2023
3a6c78e
refactor: gas optimizations
Debugger022 Nov 23, 2023
c8588a0
fix: ATT-02
Debugger022 Nov 23, 2023
8b8c5a1
tests: added tests for quicksort
Debugger022 Nov 24, 2023
dd07dae
Merge pull request #40 from VenusProtocol/fix/VEN-2140
chechu Nov 27, 2023
23662c0
fix: resolved merge conflicts
Debugger022 Nov 29, 2023
b9c63a8
Merge branch 'develop' into feat/passive-swap
Debugger022 Nov 29, 2023
b176ddb
fix: pr comments
Debugger022 Dec 4, 2023
8d8f8c7
fix: pr comments
Debugger022 Dec 4, 2023
9a915e7
Merge branch 'develop' into feat/passive-swap
Debugger022 Dec 4, 2023
4d93597
Merge branch 'feat/passive-swap' into feat/private-conversions
Debugger022 Dec 5, 2023
5088e0f
fix: convertForExactTokens bug regarding deflationary token
Debugger022 Dec 5, 2023
e6578b3
test: added commented tests for convertForExactTokensSupportingFeeOnT…
Debugger022 Dec 5, 2023
d550be6
Merge branch 'feat/passive-swap' into feat/private-conversions
Debugger022 Dec 5, 2023
1af57c2
fix: N-01
Debugger022 Dec 6, 2023
b1244b3
fix: N-02
Debugger022 Dec 6, 2023
9994f12
fix: N-03
Debugger022 Dec 6, 2023
a265d02
fix: N-07
Debugger022 Dec 7, 2023
af3d4fc
fix: N-04
Debugger022 Dec 7, 2023
ae9e07b
fix: N-05
Debugger022 Dec 7, 2023
84cbf18
fix: N-06
Debugger022 Dec 7, 2023
52eb722
fix: L-01
Debugger022 Dec 7, 2023
6b6e9e4
fix: L-02
Debugger022 Dec 7, 2023
6bd7f9a
fix: L-03
Debugger022 Dec 7, 2023
f7dd3a2
refactor: remove immutability from baseAsset
Debugger022 Dec 7, 2023
f3e40c3
fix: L-04
Debugger022 Dec 7, 2023
166d40b
fix: minor fixes
Debugger022 Dec 7, 2023
554d804
fix: pr comments
Debugger022 Dec 7, 2023
6286a0a
feat: add deployment scripts for converters, ConverterNetwork and XVS…
Debugger022 Dec 8, 2023
baf6dfb
feat: add conversion config method for setting configs in batch
Debugger022 Dec 11, 2023
8ef869a
fix: pr comments
Debugger022 Dec 13, 2023
66d11be
Merge branch 'develop' into feat/passive-swap
Debugger022 Dec 13, 2023
136714d
Merge branch 'feat/passive-swap' into feat/private-conversions
Debugger022 Dec 13, 2023
1b16c45
Merge branch 'feat/private-conversions' into VEN-2226
Debugger022 Dec 13, 2023
511c89d
refactor: variable name in singleTokenConverter deployment script and…
Debugger022 Dec 13, 2023
fc27510
Merge pull request #48 from VenusProtocol/VEN-2226
Debugger022 Dec 18, 2023
27569a3
Merge pull request #35 from VenusProtocol/feat/private-conversions
Debugger022 Dec 18, 2023
34ca45a
feat: updating deployment files
Debugger022 Dec 18, 2023
5468dc9
fix: deployment scripts and updated deployment files
Debugger022 Dec 19, 2023
13813be
feat: updating deployment files
Debugger022 Dec 19, 2023
22a231a
fix: N-05
Debugger022 Dec 22, 2023
605f5b6
refactor: replace conditional check with ensureNonzeroAddress function
Debugger022 Dec 22, 2023
2339328
fix: pr comments
Debugger022 Jan 9, 2024
7b31bf4
Merge branch 'develop' into feat/passive-swap
Debugger022 Jan 9, 2024
2ba62d3
refactor: deployment scripts to be compatible for non-live networks
Debugger022 Jan 9, 2024
781890c
refactor: replace local file validators with solidity-utilities function
Debugger022 Jan 10, 2024
343dd16
Merge pull request #52 from VenusProtocol/fix/oz-audit-private-conver…
Debugger022 Jan 10, 2024
2abea71
feat: add deployment files for bsc mainnet
Debugger022 Jan 11, 2024
45481a3
feat: updating deployment files
Debugger022 Jan 11, 2024
bbb9661
refactor: updated addresses in deployment files for bsc testnet
Debugger022 Jan 11, 2024
7f148a9
feat: updating deployment files
Debugger022 Jan 11, 2024
72ebb08
refactor: add comment in hardhat config about preventing deployment e…
Debugger022 Jan 12, 2024
768a392
feat: sweep token for pools
Debugger022 Jan 22, 2024
f31dc8b
docs: add audit reports for token converter and private conversions
chechu Jan 22, 2024
f11b8e9
fixup! : update method name SweepTokenToPool to SweepTokenFromPool
Debugger022 Jan 23, 2024
6be027e
fixup! : riskFundV2 natspec
Debugger022 Jan 24, 2024
7bd2a5e
Merge pull request #58 from VenusProtocol/refactor/sweep-token
Debugger022 Jan 24, 2024
e5b95c4
Merge branch 'develop' into feat/passive-swap
Debugger022 Jan 24, 2024
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
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,9 @@ Deployed contract abis and addresses are exported in the `deployments` directory
```
$ yarn hardhat export --network <network-name> --export ./deployments/<network-name>.json
```

### Discussion

For any concerns with the protocol, open an issue or visit us on [Telegram](https://t.me/venusprotocol) to discuss.

For security concerns, please contact the administrators of our telegram chat.
Binary file not shown.
Binary file added audits/067_tokenConverter_fairyproof_20230828.pdf
Binary file not shown.
Binary file not shown.
Binary file added audits/074_tokenConverter_certik_20231107.pdf
Binary file not shown.
Binary file added audits/081_privateConversions_certik_20231127.pdf
Binary file not shown.
Binary file not shown.
6 changes: 0 additions & 6 deletions contracts/Interfaces/ComptrollerInterface.sol

This file was deleted.

10 changes: 10 additions & 0 deletions contracts/Interfaces/IComptroller.sol
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);
}
46 changes: 46 additions & 0 deletions contracts/Interfaces/IConverterNetwork.sol
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);
}
10 changes: 10 additions & 0 deletions contracts/Interfaces/IPoolRegistry.sol
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);
}
28 changes: 28 additions & 0 deletions contracts/Interfaces/IRiskFund.sol
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;

Check warning on line 2 in contracts/Interfaces/IRiskFund.sol

View workflow job for this annotation

GitHub Actions / Lint

Found more than One contract per file. 2 contracts found!

/**
* @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);
}
8 changes: 8 additions & 0 deletions contracts/Interfaces/IRiskFundConverter.sol
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);
}
11 changes: 11 additions & 0 deletions contracts/Interfaces/IShortfall.sol
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);
web3rover marked this conversation as resolved.
Show resolved Hide resolved
}
9 changes: 9 additions & 0 deletions contracts/Interfaces/IXVSVault.sol
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);
}
7 changes: 0 additions & 7 deletions contracts/Interfaces/PoolRegistryInterface.sol

This file was deleted.

27 changes: 15 additions & 12 deletions contracts/ProtocolReserve/ProtocolShareReserve.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
import { AccessControlledV8 } from "@venusprotocol/governance-contracts/contracts/Governance/AccessControlledV8.sol";
import { ReentrancyGuardUpgradeable } from "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol";
import { MaxLoopsLimitHelper } from "@venusprotocol/solidity-utilities/contracts/MaxLoopsLimitHelper.sol";
import { ensureNonzeroAddress } from "@venusprotocol/solidity-utilities/contracts/validators.sol";

import { IProtocolShareReserve } from "../Interfaces/IProtocolShareReserve.sol";
import { ComptrollerInterface } from "../Interfaces/ComptrollerInterface.sol";
import { PoolRegistryInterface } from "../Interfaces/PoolRegistryInterface.sol";
import { IComptroller } from "../Interfaces/IComptroller.sol";
import { IPoolRegistry } from "../Interfaces/IPoolRegistry.sol";
import { IVToken } from "../Interfaces/IVToken.sol";
import { IIncomeDestination } from "../Interfaces/IIncomeDestination.sol";

Expand Down Expand Up @@ -50,7 +51,7 @@

/// @notice address of vBNB contract
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
address public immutable vBNB;

Check warning on line 54 in contracts/ProtocolReserve/ProtocolShareReserve.sol

View workflow job for this annotation

GitHub Actions / Lint

Immutable variables name are set to be in capitalized SNAKE_CASE

/// @notice address of pool registry contract
address public poolRegistry;
Expand All @@ -69,7 +70,7 @@
/// @notice Emitted when pool registry address is updated
event PoolRegistryUpdated(address indexed oldPoolRegistry, address indexed newPoolRegistry);

/// @notice Event emitted after the updation of the assets reserves.
/// @notice Event emitted after updating of the assets reserves.
event AssetsReservesUpdated(
address indexed comptroller,
address indexed asset,
Expand Down Expand Up @@ -122,9 +123,9 @@
address _wbnb,
address _vbnb
) {
if (_corePoolComptroller == address(0)) revert InvalidAddress();
if (_wbnb == address(0)) revert InvalidAddress();
if (_vbnb == address(0)) revert InvalidAddress();
ensureNonzeroAddress(_corePoolComptroller);
ensureNonzeroAddress(_wbnb);
ensureNonzeroAddress(_vbnb);

CORE_POOL_COMPTROLLER = _corePoolComptroller;
WBNB = _wbnb;
Expand All @@ -149,9 +150,10 @@
/**
* @dev Pool registry setter.
* @param _poolRegistry Address of the pool registry
* @custom:error ZeroAddressNotAllowed is thrown when pool registry address is zero
*/
function setPoolRegistry(address _poolRegistry) external onlyOwner {
if (_poolRegistry == address(0)) revert InvalidAddress();
ensureNonzeroAddress(_poolRegistry);
emit PoolRegistryUpdated(poolRegistry, _poolRegistry);
poolRegistry = _poolRegistry;
}
Expand All @@ -165,7 +167,7 @@

for (uint256 i = 0; i < configs.length; ) {
DistributionConfig memory _config = configs[i];
if (_config.destination == address(0)) revert InvalidAddress();
ensureNonzeroAddress(_config.destination);

bool updated = false;
uint256 distributionTargetsLength = distributionTargets.length;
Expand Down Expand Up @@ -313,7 +315,7 @@

/**
* @dev Update the reserve of the asset for the specific pool after transferring to the protocol share reserve.
* @param comptroller Comptroller address(pool)
* @param comptroller Comptroller address (pool)
* @param asset Asset address.
* @param incomeType type of income
*/
Expand All @@ -322,11 +324,12 @@
address asset,
IncomeType incomeType
) public override(IProtocolShareReserve) nonReentrant {
if (!ComptrollerInterface(comptroller).isComptroller()) revert InvalidAddress();
if (asset == address(0)) revert InvalidAddress();
if (!IComptroller(comptroller).isComptroller()) revert InvalidAddress();
ensureNonzeroAddress(asset);

if (
comptroller != CORE_POOL_COMPTROLLER &&
PoolRegistryInterface(poolRegistry).getVTokenForAsset(comptroller, asset) == address(0)
IPoolRegistry(poolRegistry).getVTokenForAsset(comptroller, asset) == address(0)
) revert InvalidAddress();

Schema schema = _getSchema(incomeType);
Expand Down
67 changes: 67 additions & 0 deletions contracts/ProtocolReserve/RiskFundStorage.sol
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;

Check warning on line 2 in contracts/ProtocolReserve/RiskFundStorage.sol

View workflow job for this annotation

GitHub Actions / Lint

Found more than One contract per file. 4 contracts found!

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;
web3rover marked this conversation as resolved.
Show resolved Hide resolved

/// @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;
}
kkirka marked this conversation as resolved.
Show resolved Hide resolved
Loading
Loading