Skip to content

Commit

Permalink
fix: gas optimization on initialization revert
Browse files Browse the repository at this point in the history
- use 4 bytes encoding error instead of string for gas savings on pool with base token deployment.
  • Loading branch information
gabririgo committed Nov 9, 2023
1 parent d6ca8d5 commit 7a36acd
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion contracts/protocol/core/sys/MixinInitializer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import "../../interfaces/IERC20.sol";
import "../../interfaces/IRigoblockPoolProxyFactory.sol";

abstract contract MixinInitializer is MixinImmutables, MixinStorage {
error BaseTokenDecimals();

modifier onlyUninitialized() {
// pool proxy is always initialized in the constructor, therefore
// empty code means the pool has not been initialized
Expand All @@ -25,7 +27,7 @@ abstract contract MixinInitializer is MixinImmutables, MixinStorage {
try IERC20(initParams.baseToken).decimals() returns (uint8 decimals) {
tokenDecimals = decimals;
} catch {
revert("NO_DECIMALS_RETURNED_ERROR");
revert BaseTokenDecimals();
}
// a pool with small decimals could easily underflow.
assert(tokenDecimals >= 6);
Expand Down

0 comments on commit 7a36acd

Please sign in to comment.