-
Notifications
You must be signed in to change notification settings - Fork 342
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(contracts): add rebasing compatibility for HypERC4626
#4524
base: main
Are you sure you want to change the base?
Conversation
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #4524 +/- ##
==========================================
- Coverage 82.33% 74.08% -8.25%
==========================================
Files 100 100
Lines 1421 1428 +7
Branches 180 180
==========================================
- Hits 1170 1058 -112
- Misses 251 349 +98
- Partials 0 21 +21
|
@@ -172,6 +177,108 @@ | |||
); | |||
} | |||
|
|||
function testTransferFrom() public { |
Check notice
Code scanning / Olympix Integrated Security
Reentrant functions which emit events after making an external call may lead to out-of-order events. For more information, visit: http://detectors.olympixdevsectools.com/article/web3-vulnerability/reentrancy-events
|
||
event Transfer(address indexed from, address indexed to, uint256 value); | ||
|
||
function testTransferEvent() public { |
Check notice
Code scanning / Olympix Integrated Security
Reentrant functions which emit events after making an external call may lead to out-of-order events. For more information, visit: http://detectors.olympixdevsectools.com/article/web3-vulnerability/reentrancy-events
); | ||
} | ||
|
||
function testTotalShares() public { |
Check notice
Code scanning / Olympix Integrated Security
Reentrant functions which emit events after making an external call may lead to out-of-order events. For more information, visit: http://detectors.olympixdevsectools.com/article/web3-vulnerability/reentrancy-events
); | ||
} | ||
|
||
function testShareBalanceOf() public { |
Check notice
Code scanning / Olympix Integrated Security
Reentrant functions which emit events after making an external call may lead to out-of-order events. For more information, visit: http://detectors.olympixdevsectools.com/article/web3-vulnerability/reentrancy-events
@@ -385,6 +492,32 @@ | |||
); | |||
} | |||
|
|||
function testTotalSupply() public { |
Check notice
Code scanning / Olympix Integrated Security
Reentrant functions which emit events after making an external call may lead to out-of-order events. For more information, visit: http://detectors.olympixdevsectools.com/article/web3-vulnerability/reentrancy-events
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
annoying that this is showing up here
address owner = _msgSender(); | ||
_transfer(owner, to, assetsToShares(amount)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: unnecessary intermediate variable
address owner = _msgSender(); | |
_transfer(owner, to, assetsToShares(amount)); | |
_transfer(_msgSender(), to, assetsToShares(amount)); |
function totalSupply() public view virtual override returns (uint256) { | ||
return sharesToAssets(super.totalSupply()); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
function totalSupply() public view virtual override returns (uint256) { | |
return sharesToAssets(super.totalSupply()); | |
} | |
function totalSupply() public view virtual override returns (uint256) { | |
return sharesToAssets(totalShares()); | |
} |
function balanceOf( | ||
address account | ||
) public view virtual override returns (uint256) { | ||
return sharesToAssets(super.balanceOf(account)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
function balanceOf( | |
address account | |
) public view virtual override returns (uint256) { | |
return sharesToAssets(super.balanceOf(account)); | |
} | |
function balanceOf( | |
address account | |
) public view virtual override returns (uint256) { | |
return sharesToAssets(shareBalanceOf(account)); | |
} |
function sharesToAssets(uint256 _shares) public view returns (uint256) { | ||
return _shares.mulDiv(exchangeRate, PRECISION); | ||
) internal virtual override { | ||
super._transfer(sender, recipient, amount); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this not already emit an event?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does but the event will shares amount as transferAmount in the event which is not desirable
@@ -385,6 +492,32 @@ | |||
); | |||
} | |||
|
|||
function testTotalSupply() public { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
annoying that this is showing up here
Description
Drive-by changes
_transfer
to update the Transfer event to display the asset being transfers as amount not the internal shares.Related issues
Backward compatibility
Yes
Testing
Fuzz testing