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

docs: add leverage lp module specs #545

Closed
wants to merge 3 commits into from
Closed

Conversation

cosmic-vagabond
Copy link
Contributor

Description

What has Changed?

Leverage LP module specifications


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

Deployment Notes

Are there any specific considerations to take into account when deploying these changes? This may include new dependencies, scripts that need to be executed, or any aspects that can only be evaluated in a deployed environment.

Screenshots and Videos

Please provide any relevant before and after screenshots by uploading them here. Additionally, demo videos can be highly beneficial in demonstrating the process.

@cosmic-vagabond cosmic-vagabond requested a review from jelysn June 4, 2024 08:55
Copy link
Contributor

@amityadav0 amityadav0 left a comment

Choose a reason for hiding this comment

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

I was wondering if we can add the equations/mechanism for leverage open, close. for example: similar to how in amm x*y = k should be maintained. Is it possible here ?

@cosmic-vagabond
Copy link
Contributor Author

I was wondering if we can add the equations/mechanism for leverage open, close. for example: similar to how in amm x*y = k should be maintained. Is it possible here ?

@amityadav0 Good call out. The LeverageLP module operates in conjunction with two other modules: StableStake and AMM.

  • In this system, some participants will bond their USDC tokens to the StableStake module, while others will use LeverageLP to borrow those bonded tokens to enhance their liquidity position in the AMM pool. This results in a debt that is recorded within the StableStake module.
  • Therefore, the AMM module is utilized by participants opening a Leverage LP position to join a pool with the leveraged amount of USDC (borrowed from StableStake).

The crucial equation that helps maintain balance is:

$\text{Pool Health} = \frac{\text{Total Shares} - \text{Leveraged LP Amount}}{\text{Total Shares}}$

We ensure that Pool Health does not fall below the Safety Factor threshold, which is set at 10%.

As more leveraged liquidity is added to the pool, the Pool Health decreases, putting the underlying liquidity pool at risk of having the leveraged position liquidated.

Another important concept is the liquidation mechanism. If the position health falls below the safety factor (10%), the leverage LP position is liquidated.

$\text{Position Health} = \frac{\text{Position Value}}{\text{Borrowed Amount} + \text{Interest Staked} + \text{Interest Paid}}$

Let me update the documentation in order to include those concepts.

@cosmic-vagabond
Copy link
Contributor Author

I was wondering if we can add the equations/mechanism for leverage open, close. for example: similar to how in amm x*y = k should be maintained. Is it possible here ?

@amityadav0 you can find the new section mechanism here bc851ac

@amityadav0
Copy link
Contributor

thanks!

@jelysn
Copy link
Contributor

jelysn commented Jun 7, 2024

Leveragelp and Masterchef docs are coming in #544 and I recommend to close this PR or update the base to post_v32_fix to avoid conflict. These changes are applied in post_v32_fix branch already.

@cosmic-vagabond
Copy link
Contributor Author

duplicated #544

@cosmic-vagabond cosmic-vagabond deleted the docs/leverage-lp branch June 14, 2024 12:48
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