Skip to content
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

Merged
merged 17 commits into from
Jun 25, 2024
Merged

Feat/liquidity manager #26

merged 17 commits into from
Jun 25, 2024

Conversation

kinrezC
Copy link
Contributor

@kinrezC kinrezC commented Jun 13, 2024

  • adds liquidity manager contract for zapping into positions

@kinrezC kinrezC requested review from Alexangelj and clemlak June 13, 2024 18:25
Copy link
Contributor

@Alexangelj Alexangelj left a 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

}
}

function allocateFromSy(IRMM rmm, uint256 amountSy, uint256 minPtOut, uint256 minLiquidityDelta, uint256 initialGuess, uint256 epsilon) external returns (uint256 liquidity) {
Copy link
Contributor

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Multiple places with this

uint256 rY = rmm.reserveY();

// validate swap approximation
(uint256 syToSwap,) = computeSyToPtToAddLiquidity(rmm, rX, rY, index, amountSy, block.timestamp, initialGuess, epsilon);
Copy link
Contributor

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?

Copy link
Contributor Author

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.


import "./lib/RmmErrors.sol";

interface IRMM {
Copy link
Contributor

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

Copy link
Contributor Author

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

Copy link
Contributor

@Alexangelj Alexangelj left a 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

@clemlak clemlak merged commit d89b753 into main Jun 25, 2024
1 of 2 checks passed
@clemlak clemlak deleted the feat/liquidity-manager branch July 16, 2024 07:57
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