-
Notifications
You must be signed in to change notification settings - Fork 507
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
Pay with balance, and use delta as amount in #249
Conversation
src/V4Router.sol
Outdated
@@ -63,12 +65,11 @@ abstract contract V4Router is IV4Router, BaseActionsRouter, DeltaResolver { | |||
} | |||
|
|||
function _swapExactInputSingle(IV4Router.ExactInputSingleParams memory params) private { | |||
uint128 amountIn = (params.amountIn == OPEN_DELTA) |
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.
can this be moved to a library? this is for sure shared logic / will be shared logic
src/V4Router.sol
Outdated
Currency currencyIn = params.currencyIn; | ||
uint128 amountIn = |
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.
lib could be used here too
so we dont have to repeat amount == OPEN_DELTA ? __ : ___
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 like, also just my comments about shared lib from before
src/base/BaseActionsRouter.sol
Outdated
@@ -11,6 +11,10 @@ import {Actions} from "../libraries/Actions.sol"; | |||
abstract contract BaseActionsRouter is SafeCallback { | |||
using CalldataDecoder for bytes; | |||
|
|||
/// @notice used to signal that the recipient of an action should be the _msgSender of address(this) | |||
address internal constant MSG_SENDER = address(1); |
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.
can we just have a shared constants file with all of these?
msg sender, address this, contract balance, open delta?
test/BaseActionsRouter.t.sol
Outdated
assertEq(mappedRecipient, address(0xdeadbeef)); | ||
} else if (recipient == Actions.ADDRESS_THIS) { | ||
} else if (recipient == router.ADDRESS_THIS_()) { |
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 would prefer this is Constants.ADDRESS_THIS/ Constants.MSG_SENDER
esp for msg sender its confusing bc you can actually query the true msg sender on the router/posm contract with router.msgSender()
src/base/DeltaResolver.sol
Outdated
} | ||
|
||
/// @notice Calculates the amount for a swap action | ||
function _mapSwapAmount(uint128 amount, Currency currency) internal view returns (uint128) { |
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: Since I believe we will use this function we can use a more neutral name like mapInputAmount
No description provided.