From b176ddb864628c56f5eee1bd58d6f165b8ab7a1a Mon Sep 17 00:00:00 2001 From: Debugger022 Date: Mon, 4 Dec 2023 13:14:55 +0530 Subject: [PATCH] fix: pr comments --- contracts/Test/Mocks/MockConverter.sol | 2 +- .../Test/Mocks/MockRiskFundConverter.sol | 4 +-- .../TokenConverter/AbstractTokenConverter.sol | 26 ++++++++++++------- .../TokenConverter/RiskFundConverter.sol | 6 ++--- 4 files changed, 22 insertions(+), 16 deletions(-) diff --git a/contracts/Test/Mocks/MockConverter.sol b/contracts/Test/Mocks/MockConverter.sol index c0120b2d..14821a26 100644 --- a/contracts/Test/Mocks/MockConverter.sol +++ b/contracts/Test/Mocks/MockConverter.sol @@ -43,7 +43,7 @@ contract MockConverter is AbstractTokenConverter { tokenBalance = token.balanceOf(address(this)); } - function _postPrivateConversion( + function _postPrivateConversionHook( address comptroller, address tokenAddressIn, uint256 convertedTokenInBalance, diff --git a/contracts/Test/Mocks/MockRiskFundConverter.sol b/contracts/Test/Mocks/MockRiskFundConverter.sol index fbce4f5e..432b1910 100644 --- a/contracts/Test/Mocks/MockRiskFundConverter.sol +++ b/contracts/Test/Mocks/MockRiskFundConverter.sol @@ -16,11 +16,11 @@ contract MockRiskFundConverter is RiskFundConverter { uint256 amountIn, uint256 amountOut ) external { - super.postConversionHook(tokenInAddress, tokenOutAddress, amountIn, amountOut); + super._postConversionHook(tokenInAddress, tokenOutAddress, amountIn, amountOut); } function preTransferHookMock(address tokenOutAddress, uint256 amountOut) external { - super.preTransferHook(tokenOutAddress, amountOut); + super._preTransferHook(tokenOutAddress, amountOut); } function setAssetsReserves(address asset, uint256 amount) external { diff --git a/contracts/TokenConverter/AbstractTokenConverter.sol b/contracts/TokenConverter/AbstractTokenConverter.sol index 1520f9bb..5bf7168d 100644 --- a/contracts/TokenConverter/AbstractTokenConverter.sol +++ b/contracts/TokenConverter/AbstractTokenConverter.sol @@ -74,7 +74,7 @@ import { IConverterNetwork } from "../Interfaces/IConverterNetwork.sol"; * existing converters to save incentive and lower the dependency of users for conversion. So Private Conversion will be executed * by converters on it's own whenever funds are received from PSR. No incentive will be offered during private conversion. * - * It will execute on UpdateAssetsState() function call in Converter Contracts. After this function call, converter will first + * It will execute on updateAssetsState() function call in Converter Contracts. After this function call, converter will first * check for the amount received. If base asset is received then it will be directly sent to the destination address and no private * conversion will happen otherwise converter will interact with ConverterNetwork contract to find other valid converters who are providing the conversion for: * @@ -356,7 +356,7 @@ abstract contract AbstractTokenConverter is AccessControlledV8, IAbstractTokenCo revert AmountInMismatched(); } - postConversionHook(tokenAddressIn, tokenAddressOut, actualAmountIn, actualAmountOut); + _postConversionHook(tokenAddressIn, tokenAddressOut, actualAmountIn, actualAmountOut); emit ConvertedExactTokens(actualAmountIn, actualAmountOut); } @@ -399,7 +399,7 @@ abstract contract AbstractTokenConverter is AccessControlledV8, IAbstractTokenCo revert AmountOutMismatched(); } - postConversionHook(tokenAddressIn, tokenAddressOut, actualAmountIn, actualAmountOut); + _postConversionHook(tokenAddressIn, tokenAddressOut, actualAmountIn, actualAmountOut); emit ConvertedForExactTokens(actualAmountIn, actualAmountOut); } @@ -434,7 +434,7 @@ abstract contract AbstractTokenConverter is AccessControlledV8, IAbstractTokenCo to ); - postConversionHook(tokenAddressIn, tokenAddressOut, actualAmountIn, actualAmountOut); + _postConversionHook(tokenAddressIn, tokenAddressOut, actualAmountIn, actualAmountOut); emit ConvertedExactTokensSupportingFeeOnTransferTokens(actualAmountIn, actualAmountOut); } @@ -471,7 +471,7 @@ abstract contract AbstractTokenConverter is AccessControlledV8, IAbstractTokenCo to ); - postConversionHook(tokenAddressIn, tokenAddressOut, actualAmountIn, actualAmountOut); + _postConversionHook(tokenAddressIn, tokenAddressOut, actualAmountIn, actualAmountOut); emit ConvertedForExactTokensSupportingFeeOnTransferTokens(actualAmountIn, actualAmountOut); } @@ -723,7 +723,7 @@ abstract contract AbstractTokenConverter is AccessControlledV8, IAbstractTokenCo revert InsufficientPoolLiquidity(); } - preTransferHook(tokenAddressOut, amountConvertedMantissa); + _preTransferHook(tokenAddressOut, amountConvertedMantissa); IERC20Upgradeable tokenOut = IERC20Upgradeable(tokenAddressOut); tokenOut.safeTransfer(to, amountConvertedMantissa); @@ -776,7 +776,7 @@ abstract contract AbstractTokenConverter is AccessControlledV8, IAbstractTokenCo /// @param tokenAddressOut Address of the token to get after conversion /// @param amountIn Amount of tokenIn converted /// @param amountOut Amount of tokenOut converted - function postConversionHook( + function _postConversionHook( address tokenAddressIn, address tokenAddressOut, uint256 amountIn, @@ -863,7 +863,13 @@ abstract contract AbstractTokenConverter is AccessControlledV8, IAbstractTokenCo } } - _postPrivateConversion(comptroller, tokenAddressIn, convertedTokenInBalance, tokenAddressOut, amountToConvert); + _postPrivateConversionHook( + comptroller, + tokenAddressIn, + convertedTokenInBalance, + tokenAddressOut, + amountToConvert + ); } /// @dev This hook is used to update states for the converter after the privateConversion @@ -872,7 +878,7 @@ abstract contract AbstractTokenConverter is AccessControlledV8, IAbstractTokenCo /// @param convertedTokenInBalance Amount of the base asset received after the conversion /// @param tokenAddressOut Address of the asset transferred to other converter in exchange of base asset /// @param convertedTokenOutBalance Amount of tokenAddressOut transferred from this converter - function _postPrivateConversion( + function _postPrivateConversionHook( address comptroller, address tokenAddressIn, uint256 convertedTokenInBalance, @@ -883,7 +889,7 @@ abstract contract AbstractTokenConverter is AccessControlledV8, IAbstractTokenCo /// @notice This hook is used to update the state for asset reserves before transferring tokenOut to user /// @param tokenOutAddress Address of the asset to be transferred to the user /// @param amountOut Amount of tokenAddressOut transferred from this converter - function preTransferHook(address tokenOutAddress, uint256 amountOut) internal virtual {} + function _preTransferHook(address tokenOutAddress, uint256 amountOut) internal virtual {} /// @notice To get the amount of tokenAddressOut tokens sender could receive on providing amountInMantissa tokens of tokenAddressIn /// @dev This function retrieves values without altering token prices. diff --git a/contracts/TokenConverter/RiskFundConverter.sol b/contracts/TokenConverter/RiskFundConverter.sol index 72608d1c..aa92f7d0 100644 --- a/contracts/TokenConverter/RiskFundConverter.sol +++ b/contracts/TokenConverter/RiskFundConverter.sol @@ -191,7 +191,7 @@ contract RiskFundConverter is AbstractTokenConverter { /// @notice This hook is used to update the state for asset reserves before transferring tokenOut to user /// @param tokenOutAddress Address of the asset to be transferred to the user /// @param amountOut Amount of tokenAddressOut transferred from this converter - function preTransferHook(address tokenOutAddress, uint256 amountOut) internal override { + function _preTransferHook(address tokenOutAddress, uint256 amountOut) internal override { assetsReserves[tokenOutAddress] -= amountOut; } @@ -202,7 +202,7 @@ contract RiskFundConverter is AbstractTokenConverter { /// @param amountIn Amount of tokenIn transferred /// @param amountOut Amount of tokenOut transferred /// @custom:event AssetTransferredToDestination emits on success for each pool which has share - function postConversionHook( + function _postConversionHook( address tokenInAddress, address tokenOutAddress, uint256 amountIn, @@ -376,7 +376,7 @@ contract RiskFundConverter is AbstractTokenConverter { /// @param convertedTokenInBalance Amount of the base asset received after the conversion /// @param tokenAddressOut Address of the asset transferred to other converter in exchange of base asset /// @param convertedTokenOutBalance Amount of tokenAddressOut transferred from this converter - function _postPrivateConversion( + function _postPrivateConversionHook( address comptroller, address tokenAddressIn, uint256 convertedTokenInBalance,