Skip to content
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

Open
wants to merge 3 commits into
base: swim-v2
Choose a base branch
from

Conversation

swimalick
Copy link

@swimalick swimalick commented Oct 24, 2022

  • Creates verifyMaxSwimUSDFeeIsValid
  • Returns true if there is no rate limit set instead of false
  • Updates tests

* 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) {

Choose a reason for hiding this comment

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

two thoughts:

  1. why not just return <condition>
  2. if the extraPayload has no maxSwimUSDFee it should default to 0 and so you should also reject the transaction

Copy link
Author

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 {

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.

Copy link
Author

Choose a reason for hiding this comment

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

  1. I can add a debug log
  2. Yeah i'll add a TODO

Copy link

@swimdrew swimdrew left a 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.

@swimalick swimalick changed the title Add basic maxSwimUSDFee validation Add basic maxSwimUSDFee validation, fix rate limit bug Oct 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants