-
Notifications
You must be signed in to change notification settings - Fork 1
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
Feat/liquidity manager #26
Conversation
kinrezC
commented
Jun 13, 2024
- adds liquidity manager contract for zapping into positions
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.
The calls seem pretty straightforward:
- pull tokens from user
- approve rmm to spend those pulled tokens
- do rmm swap
- approve swap output tokens to be spent by rmm
- do allocate
Which gives me an idea:
- add multicall and make a public function for each single step (i.e. swap, allocate).
- in frontend, we build a multicall of: deposit tokens (pull from user), swap, allocate
- this would make it so the only difference between allocate from sy or allocate from pt is in the swap call we put in the multicall
Make sure there is no usage of msg.value in multicall stack trace
src/LiquidityManager.sol
Outdated
} | ||
} | ||
|
||
function allocateFromSy(IRMM rmm, uint256 amountSy, uint256 minPtOut, uint256 minLiquidityDelta, uint256 initialGuess, uint256 epsilon) external returns (uint256 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.
Address arguments should be addresses, not interfaces. interfaces make it clunky
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.
Multiple places with this
src/LiquidityManager.sol
Outdated
uint256 rY = rmm.reserveY(); | ||
|
||
// validate swap approximation | ||
(uint256 syToSwap,) = computeSyToPtToAddLiquidity(rmm, rX, rY, index, amountSy, block.timestamp, initialGuess, epsilon); |
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 do we compute syToSwap?
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.
you have some maxSy
and you want to swap some amount of it to approximate the correct proportion of PT and SY for adding liquidity.
src/LiquidityManager.sol
Outdated
|
||
import "./lib/RmmErrors.sol"; | ||
|
||
interface IRMM { |
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.
Since we already import RMM, we can cast it to RMM
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.
That was causing weird stack issues with via-ir, no clue why
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.
Missing reentrancy guard and the tests dont test anything