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

implement calculate_remove_liquidity #22

Closed
ryangoree opened this issue Mar 20, 2024 · 7 comments · Fixed by #100
Closed

implement calculate_remove_liquidity #22

ryangoree opened this issue Mar 20, 2024 · 7 comments · Fixed by #100
Assignees

Comments

@ryangoree
Copy link
Member

Add a function to the Rust SDK that calculates the amount of proceeds and withdrawal_shares received for removing liquidity. Traders and UIs could use this to preview their returns without hitting the chain.

@jalextowle
Copy link
Contributor

This is related to #23. Both of these will require _distributeExcessIdle to be ported over.

@DannyDelott
Copy link
Contributor

DannyDelott commented Mar 20, 2024

Being able to calculate this two ways would be helpful:

  • proceeds and withdrawal_shares given lpShares in, (we use this to calculate utilization ratio on your portfolio card)
  • proceeds and withdrawal_shares given baseOut/SharesOut, (how users interact with removing LP, see screenshot)
image

@sentilesdal
Copy link
Contributor

Several PRs in flight for this:

#17
#11
One landed:
#7

Will need to wait for updateLiquidity update due to k-inflation changes, then I'll put up a PR for calculate_distribute_excess_idle_share_proceeds and calculate_distribue_excess_idle. The functions are written already, but need to add testing and wait for these PRs to land.

@ryangoree ryangoree transferred this issue from delvtech/hyperdrive May 1, 2024
@dpaiton dpaiton changed the title calculate_remove_liquidity implement calculate_remove_liquidity May 3, 2024
@sentilesdal
Copy link
Contributor

Delayed a bit by the 1.0.5 upgrade but,

Two landed:
#7, #11
One ready to go:
#17 - ShouldShortCircuit and LongEdgeCase helpers

Not in PR, but code written:
DistributeExcessIdleShortProceeds, DistributeExcessIdle

@sentilesdal
Copy link
Contributor

Delayed a bit by the 1.0.5 upgrade but,

Two landed:
#7, #11
One ready to go:
#17 - distribute_excess_idle
One draft PR:
#100 - calculate_remove_liquidity

@dpaiton dpaiton linked a pull request Jun 5, 2024 that will close this issue
6 tasks
@sentilesdal
Copy link
Contributor

Three landed:
#7, #11
#17 - distribute_excess_idle
One Ready to Go:
#100 - calculate_remove_liquidity

@sentilesdal
Copy link
Contributor

#100 needs delvtech/hyperdrive#1049 to land first in order to have the exact results

sentilesdal added a commit that referenced this issue Jun 13, 2024
# Resolved Issues
#22

# Description
Adds `calculate_remove_liquidity` and a test.

# Review Checklists

Please check each item **before approving** the pull request. While
going
through the checklist, it is recommended to leave comments on items that
are
referenced in the checklist to make sure that they are reviewed.

- [ ] **Testing**
    - [ ] Are there new or updated unit or integration tests?
    - [ ] Do the tests cover the happy paths?
    - [ ] Do the tests cover the unhappy paths?
- [ ] Are there an adequate number of fuzz tests to ensure that we are
          covering the full input space?
- [ ] If matching Solidity behavior, are there differential fuzz tests
that
          ensure that Rust matches Solidity?
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 a pull request may close this issue.

5 participants