-
Notifications
You must be signed in to change notification settings - Fork 84
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
audit(9): Round gas adjustments in favor of swapper #302
Conversation
src/reactors/V3DutchOrderReactor.sol
Outdated
@@ -112,15 +112,19 @@ contract V3DutchOrderReactor is BaseReactor { | |||
// positive means an increase in gas | |||
int256 gasDeltaGwei = block.basefee.sub(order.startingBaseFee); | |||
|
|||
// Gas increase should increase input | |||
int256 inputDelta = int256(order.baseInput.adjustmentPerGweiBaseFee) * gasDeltaGwei / 1 gwei; | |||
// Gas increase should increase input (round up when positive, down when negative) |
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.
nit: add comment here about how less input = favoring swapper
assertEq(resolvedOrder.input.amount, 100 ether - 0.08 gwei, "Input should handle small negative gas changes"); | ||
assertEq(resolvedOrder.outputs[0].amount, 100 ether + 0.08 gwei, "Output should handle small negative gas changes"); |
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.
is there a test that specifically tests the rounding down / up?
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.
accidentally tested using gwei instead of wei. fixed
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. I'm surprised that this lowered the gas costs!
Round gas adjustments in favor of swappers based on input/output and gas price increasing/decreasing