Skip to content

Commit

Permalink
feat(protocol): reduce gas cost by skipping reading storage for `dele…
Browse files Browse the repository at this point in the history
…gates()` (#17487)

Co-authored-by: Daniel Wang <[email protected]>
  • Loading branch information
dantaik and dong77 authored Jun 6, 2024
1 parent 1655aef commit f58d22f
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/protocol/contracts/tko/TaikoToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@ import "./TaikoTokenBase.sol";
/// 0x10dea67478c5F8C5E2D90e5E9B26dBe60c54d800 (token.taiko.eth)
/// @custom:security-contact [email protected]
contract TaikoToken is TaikoTokenBase {
address private constant _TAIKO_L1 = 0x06a9Ab27c7e2255df1815E6CC0168d7755Feb19a;
address private constant _ERC20_VAULT = 0x996282cA11E5DEb6B5D122CC3B9A1FcAAD4415Ab;

/// @notice Initializes the contract.
/// @param _owner The owner of this contract. msg.sender will be used if this value is zero.
/// @param _recipient The address to receive initial token minting.

function init(address _owner, address _recipient) public initializer {
__Essential_init(_owner);
__ERC20_init("Taiko Token", "TKO");
Expand All @@ -22,4 +26,10 @@ contract TaikoToken is TaikoTokenBase {
// Mint 1 billion tokens
_mint(_recipient, 1_000_000_000 ether);
}

function delegates(address account) public view virtual override returns (address) {
// Special checks to avoid reading from storage slots
if (account == _TAIKO_L1 || account == _ERC20_VAULT) return address(0);
else return super.delegates(account);
}
}

0 comments on commit f58d22f

Please sign in to comment.