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

Create a router to add liquidity with underlying to an initialized buffer #1267

Open
joaobrunoah opened this issue Jan 31, 2025 · 0 comments

Comments

@joaobrunoah
Copy link
Contributor

joaobrunoah commented Jan 31, 2025

ZenDragon mentioned that it's hard to add liquidity to an already initialized buffer, since you can be frontrun when posting the add liquidity transaction and it's hard to tell how much underlying and wrapped token to have. A solution would be to create a router function that makes it easier to add liquidity using only the underlying.

This router should receive underlying amount and wrapped token as argument, and follow the step-by-step:

  • Get the buffer balance;
  • get the wrapped token rate;
  • Calculate the amount of tokens to wrap, so that the add liquidity is proportional
  • Wrap tokens using the wrapped token directly
  • Add liquidity to the buffer proportionally
  • Return "leftovers" to the sender
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

No branches or pull requests

1 participant