-
Notifications
You must be signed in to change notification settings - Fork 0
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
build: deposit limit #17
base: master
Are you sure you want to change the base?
Conversation
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.
looks good, minor questions/comments
@@ -120,10 +134,12 @@ contract L1YearnEscrow is L1Escrow { | |||
function _receiveTokens( | |||
uint256 amount | |||
) internal virtual override whenNotPaused { | |||
VaultStorage storage $ = _getVaultStorage(); | |||
require($.deposited + amount <= $.depositLimit, "deposit limit"); |
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.
I personally like to use string error codes when using requires (e.g. "DEPOSIT_LIMIT") - or custom errors with reverts.
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.
not sure i follow.
Are you saying just change the revert string to "DEPOSIT_LIMIT" instead of "deposit limit" ?
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.
yeah, but it's minor
I find it easier to integrate with frontends etc
src/L1YearnEscrow.sol
Outdated
* @param _minimumBuffer The new minimum buffer to enforce. | ||
*/ | ||
function updateMinimumBuffer( | ||
uint256 _minimumBuffer | ||
) external virtual onlyRole(DEFAULT_ADMIN_ROLE) { | ||
VaultStorage storage $ = _getVaultStorage(); | ||
$.minimumBuffer = _minimumBuffer; | ||
require(_minimumBuffer <= type(uint128).max, "max size"); |
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.
why not change the parameter's type to uint128?
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.
I tend to prefer keeping the external types the generic versions to make integrations and interfaces easier.
But can change it to 128 to make is clearer
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.
); | ||
mockEscrow = deployMockL1Escrow(); | ||
|
||
vm.expectRevert(); |
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.
some comments would be helpful :)
// reverts because caller does is not allowed to change the deposit limit
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.
@@ -154,7 +154,92 @@ contract EscrowTest is Setup { | |||
assertEq(vault.balanceOf(address(mockEscrow)), 0); | |||
} | |||
|
|||
function test_bridgeAsset_maxDepositLimit(uint256 _amount) public { | |||
function test_bridgeAsset_escrowDepositLimit(uint256 _amount) public { | |||
_amount = bound(_amount, minFuzzAmount, maxFuzzAmount); |
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.
can _amount be 0?
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.
yes, will add a section to show that
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.
Test using a 0 deposit limit is here https://github.com/yearn/yearn-stb/pull/17/files#diff-52b3b649a24d8bf5f33c53bf9546c7aee0a6133a5503d8525a1a1e5dab36f656R170
No description provided.