-
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
Add basic maxSwimUSDFee validation, fix rate limit bug #18
base: swim-v2
Are you sure you want to change the base?
Conversation
* To prevent exploits, we automatically reject any payload with a maxSwimUSDFee that is less than 0.01 swimUSD (10000) | ||
*/ | ||
verifyMaxSwimUSDFeeIsValid(payload: ParsedTransferWithArbDataPayload<ParsedSwimData>): boolean { | ||
if (payload.extraPayload.maxSwimUSDFee && payload.extraPayload.maxSwimUSDFee < 10000n) { |
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.
two thoughts:
- why not just
return <condition>
- if the extraPayload has no maxSwimUSDFee it should default to 0 and so you should also reject the transaction
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.
Makes sense.
I wasn't sure how to handle the default 0 case when I initially wrote this, synced with Andrew to figure it out
* Sanity check the maxSwimUSDFee field. | ||
* To prevent exploits, we automatically reject any payload with a maxSwimUSDFee that is less than 0.01 swimUSD (10000) | ||
*/ | ||
verifyMaxSwimUSDFeeIsValid(payload: ParsedTransferWithArbDataPayload<ParsedSwimData>): boolean { |
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.
1/ Should we log anything if we reject an invalid maxSwimUSDFee?
2/ Can you add a TODO here that vaguely denotes all the conditions we wanna check (doesn't have to be super specific or anything). In an ideal world, we'll want to test this method for all conditions.
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 can add a debug log
- Yeah i'll add a TODO
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.
Didn't review super extensively but changes look reasonable as far as I'm concerned.
verifyMaxSwimUSDFeeIsValid
true
if there is no rate limit set instead offalse