You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
⭐ = Areas of concern
✔️ = Audited Contract
✅ = Semi-Audited Contract(< 100%)
Issues
[G-01] != 0 to > 0 for uint in require() statements
RubiconMarket.sol, lines: 840, 879, 921, 945
Gas save: 6 for each require
* For the pragma versions minor than 0.8.13
[G-01] Repeated logged parameters
In BathToken.sol:
L575-L584, The events LogDeposit and Deposit log repeated the assets, shares and msg.sender
L607-L623, The events LogWithdraw and Withdraw log repeated the amountWithdrawn, _shares and msg.sender
Can remove from this parameters from LogDeposit and LogWithdraw events to save gas and clarify code
[G-02] Unnecessary type casting
In BathToken.sol L205: Remove the bytes cast
[G-03] Use function parameter
In BathToken.sol L214: Use market instead of RubiconMarketAddress to save the SLOAD
[G-04] <var>++ or <var> += 1 to ++<var>
In BathPair.sol, lines 311, 427, 480, 582
In BathToken.sol, line 635
In RubiconRouter.sol, line 169, 227
Use ++index instead of index++ and unchecked the increment:
for (...; i++) {
...
}
to
unchecked {
for (...;) {
...
unchecked {
++i;
}
}
[G-05] Caching length on for
In BathPair.sol, lines 311, 582
In BathToken.sol, line 635
In RubiconRouter.sol, line 169, 227
Caching the array length is more gas efficient:
for (uint256 i =0; i < array.length; i++) {
...
to
uint256 arrayLength = array.length;
for (uint256 i =0; i < arrayLength; i++) {
...
[G-06] Save the rewardsVestingWallet, feeBPS and bonusTokens.length in vars and directly bonusTokens[index] in release function call
In BathToken.sol, L629distributeBonusTokenRewardsfunction:
function distributeBonusTokenRewards(
addressreceiver,
uint256sharesWithdrawn,
uint256initialTotalSupply
) internal {
uint256 bonusTokensLength = bonusTokens.length;
IBathBuddy _rewardsVestingWallet = rewardsVestingWallet;
uint256 _feeBPS = feeBPS;
if (bonusTokensLength >0) {
for (uint256 index =0; index < bonusTokensLength; index++) {
// Note: Shares already burned in Bath Token _withdraw// Pair each bonus token with a lightly adapted OZ Vesting wallet. Each time a user withdraws, they// are released their relative share of this pool, of vested BathBuddy rewards// The BathBuddy pool should accrue ERC-20 rewards just like OZ VestingWallet and simply just release the withdrawer's relative share of releaseable() tokensif (_rewardsVestingWallet !=IBathBuddy(0)) {
_rewardsVestingWallet.release(
IERC20(bonusTokens[index]),
receiver,
sharesWithdrawn,
initialTotalSupply,
_feeBPS
);
}
}
}
}
[G-07] Save allowance[from][msg.sender] in var to save SLOAD gas cost
In BathToken.sol, L698transferFromfunction:
function transferFrom(
addressfrom,
addressto,
uint256value
) externalreturns (bool) {
uint256 currentAllowance = allowance[from][msg.sender];
if (currentAllowance !=uint256(-1)) {
allowance[from][msg.sender] = currentAllowance.sub(
value
);
}
_transfer(from, to, value);
returntrue;
}
[G-08] Save IBathHouse(_bathHouse).getMarket() in a var
In BathToken.sol, L115: In initialize function save in a var and use msg.sender instead of _bathHouse to save SLOAD gas
function initialize(uint256_maxOrderSizeBPS, int128_shapeCoefNum)
external
{
require(!initialized);
address _bathHouse =msg.sender; //Assume the initializer is BathHouse
_rubiconMarket =IBathHouse(msg.sender).getMarket();
require(
_rubiconMarket !=address(0x0000000000000000000000000000000000000000) &&IBathHouse(msg.sender).initialized(),
"BathHouse not initialized"
);
bathHouse =msg.sender;
RubiconMarketAddress = _rubiconMarket;
...
The text was updated successfully, but these errors were encountered:
Gas report
Contest: Rubicon
Autor: Rotcivegaf
Scope:
Core:
Peripheral:
⭐ = Areas of concern
✔️ = Audited Contract
✅ = Semi-Audited Contract(< 100%)
Issues
[G-01] != 0 to > 0 for uint in require() statements
Gas save: 6 for each require
* For the pragma versions minor than 0.8.13
[G-01] Repeated logged parameters
In BathToken.sol:
LogDeposit
andDeposit
log repeated theassets
,shares
andmsg.sender
LogWithdraw
andWithdraw
log repeated theamountWithdrawn
,_shares
andmsg.sender
Can remove from this parameters from
LogDeposit
andLogWithdraw
events to save gas and clarify code[G-02] Unnecessary type casting
In BathToken.sol L205: Remove the
bytes
cast[G-03] Use function parameter
In BathToken.sol L214: Use
market
instead ofRubiconMarketAddress
to save the SLOAD[G-04] <var>++ or <var> += 1 to ++<var>
Use
++index
instead ofindex++
and unchecked the increment:to
[G-05] Caching length on for
Caching the array length is more gas efficient:
to
[G-06] Save the
rewardsVestingWallet
,feeBPS
andbonusTokens.length
in vars and directlybonusTokens[index]
inrelease
function callIn BathToken.sol, L629
distributeBonusTokenRewards
function:[G-07] Save
allowance[from][msg.sender]
in var to save SLOAD gas costIn BathToken.sol, L698
transferFrom
function:[G-08] Save
IBathHouse(_bathHouse).getMarket()
in a varIn BathToken.sol, L115: In
initialize
function save in a var and usemsg.sender
instead of_bathHouse
to save SLOAD gasThe text was updated successfully, but these errors were encountered: