-
Notifications
You must be signed in to change notification settings - Fork 504
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
Take command in router #261
Conversation
@@ -128,69 +128,75 @@ contract PositionManager is | |||
} | |||
|
|||
function _handleAction(uint256 action, bytes calldata params) internal virtual override { | |||
if (action == Actions.INCREASE_LIQUIDITY) { |
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.
this looks bad but i just split the command into a nested if for gas. If you view it in codespace itll make it much easier to see what i did lol.
its like:
if (action > settle) {
... all liquidity / mint / burn commands ...
} else {
... all payment commands ...
}
@@ -82,16 +82,14 @@ abstract contract DeltaResolver is ImmutableState { | |||
/// @notice Calculates the amount for a take action | |||
function _mapTakeAmount(uint256 amount, Currency currency) internal view returns (uint256) { | |||
if (amount == Constants.OPEN_DELTA) { | |||
return _getFullCredit(currency).toUint128(); |
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 think this was accidentally copied from the mapInputAmount
function which returns a uint128
src/base/DeltaResolver.sol
Outdated
function _mapInputAmount(uint128 amount, Currency currency) internal view returns (uint128) { | ||
if (amount == Constants.CONTRACT_BALANCE) { | ||
return currency.balanceOfSelf().toUint128(); | ||
} else if (amount == Constants.OPEN_DELTA) { | ||
if (amount == Constants.OPEN_DELTA) { | ||
return _getFullCredit(currency).toUint128(); | ||
} | ||
return amount; |
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.
this function is now exactly the same as _mapTakeAmount()
(minus casting)
-
why did we get rid of
amount == Constants.CONTRACT_BALANCE
-
can we natspec why
_getFullCredit
is used for fetching input amounts? (i'm assuming its for multihop -- the inputs of an intermediate swap is the output (credit) of the previous step)
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.
why did we get rid of amount == Constants.CONTRACT_BALANCE
I just cant see a time it will be used. The entire point in this function is for 1 usecase:
- USDC traded on v2 for UNI. UNI is left in the router
- Now we want to trade UNI for PEPE on v4 how do we do that?
Previously i thought we would do swap with input Constants.CONTRACT_BALANCE
... and then do settle OPEN_DELTA
. But Ive realised we're duplicating logic because you can do settle CONTRACT_BALANCE
and then swap OPEN_DELTA
.
Maybe its worth having both? idk just feels like a lot of options
No description provided.