Skip to content

Commit

Permalink
fix: pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Debugger022 committed Dec 4, 2023
1 parent dd07dae commit b176ddb
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 16 deletions.
2 changes: 1 addition & 1 deletion contracts/Test/Mocks/MockConverter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ contract MockConverter is AbstractTokenConverter {
tokenBalance = token.balanceOf(address(this));
}

function _postPrivateConversion(
function _postPrivateConversionHook(
address comptroller,
address tokenAddressIn,
uint256 convertedTokenInBalance,
Expand Down
4 changes: 2 additions & 2 deletions contracts/Test/Mocks/MockRiskFundConverter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
26 changes: 16 additions & 10 deletions contracts/TokenConverter/AbstractTokenConverter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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:
*
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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,
Expand All @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions contracts/TokenConverter/RiskFundConverter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit b176ddb

Please sign in to comment.