Skip to content

Add basic maxSwimUSDFee validation, fix rate limit bug#18

Open
swimalick wants to merge 3 commits into
swim-v2from
max_fee_validation
Open

Add basic maxSwimUSDFee validation, fix rate limit bug#18
swimalick wants to merge 3 commits into
swim-v2from
max_fee_validation

Conversation

@swimalick

@swimalick swimalick commented Oct 24, 2022

Copy link
Copy Markdown
  • 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) {

Copy link
Copy Markdown

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
Copy Markdown
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

@swimalick
swimalick requested a review from swimivan October 26, 2022 17:38
* 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 {

Copy link
Copy Markdown

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
Copy Markdown
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

@swimdrew swimdrew left a comment

Copy link
Copy Markdown

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