Skip to content

Commit

Permalink
Gas optimization in IpRoyaltyVault (#114)
Browse files Browse the repository at this point in the history
* adjust yarn.lock

* make timestamp a uint40
  • Loading branch information
Spablob authored Apr 16, 2024
1 parent c785b19 commit 0135408
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 3 additions & 3 deletions contracts/modules/royalty/policies/IpRoyaltyVault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ contract IpRoyaltyVault is IIpRoyaltyVault, ERC20SnapshotUpgradeable, Reentrancy
struct IpRoyaltyVaultStorage {
address ipId;
uint32 unclaimedRoyaltyTokens;
uint256 lastSnapshotTimestamp;
uint40 lastSnapshotTimestamp;
mapping(address token => uint256 amount) ancestorsVaultAmount;
mapping(address ancestorIpId => bool) isCollectedByAncestor;
mapping(address token => uint256 amount) claimVaultAmount;
Expand Down Expand Up @@ -96,7 +96,7 @@ contract IpRoyaltyVault is IIpRoyaltyVault, ERC20SnapshotUpgradeable, Reentrancy
IpRoyaltyVaultStorage storage $ = _getIpRoyaltyVaultStorage();

$.ipId = ipIdAddress;
$.lastSnapshotTimestamp = block.timestamp;
$.lastSnapshotTimestamp = uint40(block.timestamp);
$.unclaimedRoyaltyTokens = unclaimedTokens;

_mint(address(this), unclaimedTokens);
Expand Down Expand Up @@ -130,7 +130,7 @@ contract IpRoyaltyVault is IIpRoyaltyVault, ERC20SnapshotUpgradeable, Reentrancy
revert Errors.IpRoyaltyVault__SnapshotIntervalTooShort();

uint256 snapshotId = _snapshot();
$.lastSnapshotTimestamp = block.timestamp;
$.lastSnapshotTimestamp = uint40(block.timestamp);

uint32 unclaimedTokens = $.unclaimedRoyaltyTokens;
$.unclaimedAtSnapshot[snapshotId] = unclaimedTokens;
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4936,6 +4936,11 @@ slice-ansi@^4.0.0:
astral-regex "^2.0.0"
is-fullwidth-code-point "^3.0.0"

solady@^0.0.191:
version "0.0.191"
resolved "https://registry.yarnpkg.com/solady/-/solady-0.0.191.tgz#a4a285ddbcc0d5a8860128ffdd6ea1564b673199"
integrity sha512-wiab1exBWHT7tLv8m+MnIppa0cn1PBhYskdYqe9/WYgL5Tn2cph5uZVLgy3H3fXXrya68Y5K5oe17hvOyrU87Q==

solc@0.7.3:
version "0.7.3"
resolved "https://registry.yarnpkg.com/solc/-/solc-0.7.3.tgz#04646961bd867a744f63d2b4e3c0701ffdc7d78a"
Expand Down

0 comments on commit 0135408

Please sign in to comment.