forked from ToucanProtocol/dynamic-fee-pools
-
Notifications
You must be signed in to change notification settings - Fork 0
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 ToucanProtocol#56 from 0xmichalis/audit-review
[LILA-6854] Address Team Omega comments, update emails and versions
- Loading branch information
Showing
4 changed files
with
14 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
// | ||
// SPDX-License-Identifier: UNLICENSED | ||
|
||
// If you encounter a vulnerability or an issue, please contact <[email protected]> | ||
// If you encounter a vulnerability or an issue, please contact <[email protected]> or visit security.toucan.earth | ||
pragma solidity 0.8.19; | ||
|
||
import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; | ||
|
@@ -20,7 +20,7 @@ contract FeeCalculator is IFeeCalculator, Ownable { | |
/// @dev Version-related parameters. VERSION keeps track of production | ||
/// releases. VERSION_RELEASE_CANDIDATE keeps track of iterations | ||
/// of a VERSION in our staging environment. | ||
string public constant VERSION = "1.0.0"; | ||
string public constant VERSION = "1.1.0"; | ||
uint256 public constant VERSION_RELEASE_CANDIDATE = 1; | ||
|
||
SD59x18 private _zero = sd(0); | ||
|
@@ -169,8 +169,6 @@ contract FeeCalculator is IFeeCalculator, Ownable { | |
override | ||
returns (FeeDistribution memory feeDistribution) | ||
{ | ||
require(depositAmount > 0, "depositAmount must be > 0"); | ||
|
||
feeDistribution = | ||
_calculateFee(depositAmount, IPool(pool).totalPerProjectSupply(tco2), _getTotalSupply(pool), _getDepositFee); | ||
} | ||
|
@@ -180,11 +178,11 @@ contract FeeCalculator is IFeeCalculator, Ownable { | |
/// @return feeDistribution The recipients and the amount of fees each | ||
/// recipient should receive. | ||
function calculateFeeShares(uint256 totalFee) internal view returns (FeeDistribution memory feeDistribution) { | ||
uint256 recipientsLenght = _recipients.length; | ||
uint256[] memory shares = new uint256[](recipientsLenght); | ||
uint256 recipientsLength = _recipients.length; | ||
uint256[] memory shares = new uint256[](recipientsLength); | ||
|
||
uint256 restFee = totalFee; | ||
for (uint256 i = 0; i < recipientsLenght; i++) { | ||
for (uint256 i = 0; i < recipientsLength; i++) { | ||
shares[i] = (totalFee * _shares[i]) / 100; | ||
restFee -= shares[i]; | ||
} | ||
|
@@ -233,8 +231,6 @@ contract FeeCalculator is IFeeCalculator, Ownable { | |
override | ||
returns (FeeDistribution memory feeDistribution) | ||
{ | ||
require(depositAmount > 0, "depositAmount must be > 0"); | ||
|
||
feeDistribution = _calculateFee( | ||
depositAmount, IPool(pool).totalPerProjectSupply(erc1155, tokenId), _getTotalSupply(pool), _getDepositFee | ||
); | ||
|
@@ -405,12 +401,12 @@ contract FeeCalculator is IFeeCalculator, Ownable { | |
uint256 totalPoolSupply, | ||
function(uint256, uint256, uint256) view returns (uint256) calculator | ||
) internal view returns (FeeDistribution memory) { | ||
require(requestedAmount > 0, "requested amount must be > 0"); | ||
require(requestedAmount != 0, "requested amount must be > 0"); | ||
|
||
uint256 feeAmount = calculator(requestedAmount, projectSupply, totalPoolSupply); | ||
|
||
require(feeAmount <= requestedAmount, "Fee must be lower or equal to requested amount"); | ||
require(feeAmount > 0, "Fee must be greater than 0"); | ||
require(feeAmount != 0, "Fee must be greater than 0"); | ||
|
||
return calculateFeeShares(feeAmount); | ||
} | ||
|
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 |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
// | ||
// SPDX-License-Identifier: UNLICENSED | ||
|
||
// If you encounter a vulnerability or an issue, please contact <[email protected]> | ||
// If you encounter a vulnerability or an issue, please contact <[email protected]> or visit security.toucan.earth | ||
pragma solidity 0.8.19; | ||
|
||
import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; | ||
|
@@ -20,7 +20,7 @@ contract FlatFeeCalculator is IFeeCalculator, Ownable { | |
/// releases. VERSION_RELEASE_CANDIDATE keeps track of iterations | ||
/// of a VERSION in our staging environment. | ||
string public constant VERSION = "1.0.0"; | ||
uint256 public constant VERSION_RELEASE_CANDIDATE = 1; | ||
uint256 public constant VERSION_RELEASE_CANDIDATE = 2; | ||
|
||
uint256 public feeBasisPoints = 300; | ||
|
||
|
@@ -39,7 +39,7 @@ contract FlatFeeCalculator is IFeeCalculator, Ownable { | |
constructor() Ownable() {} | ||
|
||
function setFeeToUnderlyingDecimalsScale(uint256 _feeToUnderlyingDecimalsScale) external onlyOwner { | ||
require(_feeToUnderlyingDecimalsScale > 0, "Fee to underlying decimals scale must be greater than 0"); | ||
require(_feeToUnderlyingDecimalsScale != 0, "Fee to underlying decimals scale must be greater than 0"); | ||
|
||
feeToUnderlyingDecimalsScale = _feeToUnderlyingDecimalsScale; | ||
} | ||
|
@@ -79,8 +79,6 @@ contract FlatFeeCalculator is IFeeCalculator, Ownable { | |
override | ||
returns (FeeDistribution memory feeDistribution) | ||
{ | ||
require(depositAmount > 0, "depositAmount must be > 0"); | ||
|
||
feeDistribution = _calculateFee(depositAmount); | ||
} | ||
|
||
|
@@ -135,8 +133,6 @@ contract FlatFeeCalculator is IFeeCalculator, Ownable { | |
override | ||
returns (FeeDistribution memory feeDistribution) | ||
{ | ||
require(depositAmount > 0, "depositAmount must be > 0"); | ||
|
||
feeDistribution = _calculateFee(depositAmount); | ||
} | ||
|
||
|
@@ -171,13 +167,13 @@ contract FlatFeeCalculator is IFeeCalculator, Ownable { | |
/// @param requestedAmount The amount to be used for the fee calculation. | ||
/// @return feeDistribution How the fee is meant to be | ||
function _calculateFee(uint256 requestedAmount) internal view returns (FeeDistribution memory) { | ||
require(requestedAmount > 0, "requested amount must be > 0"); | ||
require(requestedAmount != 0, "requested amount must be > 0"); | ||
|
||
uint256 adjustedAmount = requestedAmount * feeToUnderlyingDecimalsScale; | ||
uint256 feeAmount = adjustedAmount * feeBasisPoints / 10000; | ||
|
||
require(feeAmount <= adjustedAmount, "Fee must be lower or equal to requested amount"); | ||
require(feeAmount > 0, "Fee must be greater than 0"); | ||
require(feeAmount != 0, "Fee must be greater than 0"); | ||
|
||
return calculateFeeShares(feeAmount); | ||
} | ||
|
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