From c720444718504c11c969fed1c9fb67747621ed0c Mon Sep 17 00:00:00 2001 From: bajpai244 Date: Tue, 14 Dec 2021 20:22:20 +0530 Subject: [PATCH] use the `gonsForBalance` function in `transfer` function of sOlympusERC20.sol, instead of writing the code again The first line of transfer function in the sOlympusERC20.sol contract calculates the gonValue of the given fragments representated by the value parameter. The contract has a function `gonsForBalance` for this purpose and using this can help maintain consistency in the codebase and can help avoid any bugs in future if `gonsForBalance` goes through some change! old code => ``` uint256 gonValue = value.mul( _gonsPerFragment ); ``` new change => ``` uint256 gonValue = gonsForBalance(value); ``` --- contracts/sOlympusERC20.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/sOlympusERC20.sol b/contracts/sOlympusERC20.sol index 011ccbd28..717e04253 100644 --- a/contracts/sOlympusERC20.sol +++ b/contracts/sOlympusERC20.sol @@ -1136,7 +1136,7 @@ contract sOlympus is ERC20Permit, Ownable { } function transfer( address to, uint256 value ) public override returns (bool) { - uint256 gonValue = value.mul( _gonsPerFragment ); + uint256 gonValue = gonsForBalance(value); _gonBalances[ msg.sender ] = _gonBalances[ msg.sender ].sub( gonValue ); _gonBalances[ to ] = _gonBalances[ to ].add( gonValue ); emit Transfer( msg.sender, to, value );