Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
f53f493
unit tests for invalid transfers, no claimable yield, proper principa…
mesozoic-technology Aug 20, 2025
aaf1a71
added _disableInitializers() to constructor, fixes to test
mesozoic-technology Aug 26, 2025
b8bc884
returning if totalPrincipal is zero before index update
mesozoic-technology Aug 26, 2025
b64bee5
added test_claimYield()
mesozoic-technology Aug 26, 2025
cb5fffb
added test_claimYieldMultipleUsers()
mesozoic-technology Aug 26, 2025
d67e1b5
added test_claimYieldAfterTransfer()
mesozoic-technology Aug 26, 2025
6e21279
added test_indexUpdateWithZeroTotalPrincipal()
mesozoic-technology Aug 26, 2025
9e17f6c
added test_indexUpdateAfterBurn()
mesozoic-technology Aug 26, 2025
93db590
updated tests, passing with forked state
mesozoic-technology Aug 27, 2025
6e94ce3
comments in burn test
mesozoic-technology Aug 27, 2025
46f6869
included min256() in claim() to never dos a claim
mesozoic-technology Sep 12, 2025
f65ac1d
changed NobleDollar.sol pragma to be 0.8.22 to allow compilation in l…
mesozoic-technology Sep 12, 2025
8f47134
changing pragma back to 0.8.20 since this is fixed by another branch
mesozoic-technology Sep 12, 2025
fb82a58
included word on rounding behavior in readme
mesozoic-technology Sep 16, 2025
56a5e11
Merge pull request #2 from m0-foundation/sherlock-5
mesozoic-technology Sep 17, 2025
2b51f88
Merge pull request #3 from m0-foundation/sherlock-6
mesozoic-technology Sep 17, 2025
b84f0bb
Merge pull request #4 from m0-foundation/sherlock-7
mesozoic-technology Sep 17, 2025
a11037c
Fix formatting issues and delete commented out code
toninorair Oct 1, 2025
9aaf923
Fix compilation warnings
toninorair Oct 1, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion contracts/src/NobleDollar.sol
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ contract NobleDollar is HypERC20 {
}
}

constructor(address mailbox_) HypERC20(6, 1, mailbox_) {}
constructor(address mailbox_) HypERC20(6, 1, mailbox_) {
_disableInitializers();
}

function initialize(address hook_, address ism_) public virtual initializer {
super.initialize("Noble Dollar", "USDN", hook_, ism_, msg.sender);
Expand Down Expand Up @@ -187,6 +189,9 @@ contract NobleDollar is HypERC20 {
// Distribute yield, derive new index from the adjusted total supply.
// NOTE: We don't want to perform any principal updates in the case of yield accrual.
if (to == address(this)) {

if ($.totalPrincipal == 0) return;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have doubts this is needed, getIndexRoundedDown should revert with DivisionByZero

Copy link
Copy Markdown

@toninorair toninorair Sep 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we were to revert, we'd be doing this on a cross chain message. In that case, what would happen to the yield the message intended to send? By returning instead, there is no ambiguity here, the yield is received by the contract, and the next time there is principal present to avoid a division by zero, the index is still updated to the correct value.

Maybe this would not be a problem given how Hyperlane works, but I chose this as I am not 100% familiar with that - would be good to know that, though.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fair take, worth adding comment for auditors, just in case


uint128 oldIndex = $.index;

$.index = IndexingMath.getIndexRoundedDown(totalSupply(), $.totalPrincipal);
Expand Down
Loading