Add basic maxSwimUSDFee validation, fix rate limit bug#18
Open
swimalick wants to merge 3 commits into
Open
Conversation
swimivan
requested changes
Oct 26, 2022
| * 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.
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
Author
There was a problem hiding this comment.
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
swimdrew
reviewed
Oct 27, 2022
| * 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.
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.
Author
There was a problem hiding this comment.
- I can add a debug log
- Yeah i'll add a TODO
swimdrew
approved these changes
Oct 27, 2022
swimdrew
left a comment
There was a problem hiding this comment.
Didn't review super extensively but changes look reasonable as far as I'm concerned.
swimivan
approved these changes
Oct 28, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
verifyMaxSwimUSDFeeIsValidtrueif there is no rate limit set instead offalse