Skip to content

Commit

Permalink
docs: add mechanism section
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmic-vagabond committed Jun 6, 2024
1 parent ffd9d9a commit bc851ac
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 8 deletions.
52 changes: 52 additions & 0 deletions x/leveragelp/spec/02_mechanism.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<!--
order: 2
-->

# Mechanism

The LeverageLP module enables participants to leverage their liquidity position in the AMM pool by borrowing USDC tokens bonded in the StableStake module. This interaction results in a leveraged position that is tracked and managed within the LeverageLP module.

## Dependencies

The LeverageLP module depends on two other modules:

1. **StableStake**: Manages the bonding of USDC tokens by participants.
2. **AMM**: Facilitates liquidity provision and trading.

## Overview

Participants in the system engage with the modules as follows:

1. **Bonding USDC to StableStake**:

- Participants bond their USDC tokens to the StableStake module.
- These bonded tokens become available for borrowing by other participants.

2. **Leveraging Liquidity with LeverageLP**:
- Participants borrow USDC tokens from the StableStake module using the LeverageLP module.
- The borrowed tokens are used to enhance their liquidity position in the AMM pool.
- This results in a debt recorded within the StableStake module.

## Key Equations

To maintain the stability and health of the pool, the following equations are used:

1. **Pool Health**:

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

- **Total Shares**: The total number of shares in the pool.
- **Leveraged LP Amount**: The amount of liquidity added to the pool through leveraged positions.

The Pool Health metric is monitored to ensure it does not fall below the Safety Factor threshold, which is set at 10%. Lower Pool Health indicates higher risk of leveraged positions being liquidated.

2. **Position Health and Liquidation Mechanism**:

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

- **Position Value**: The current value of the leveraged position.
- **Borrowed Amount**: The total amount of USDC borrowed from the StableStake module.
- **Interest Staked**: The amount of interest accrued on the borrowed amount.
- **Interest Paid**: The amount of interest paid by the participant.

If Position Health falls below the Safety Factor threshold (10%), the leveraged LP position is automatically liquidated to protect the underlying liquidity pool.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!--
order: 2
order: 3
-->

# Usage
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!--
order: 3
order: 4
-->

# Keeper
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!--
order: 4
order: 5
-->

# Types, Messages, Queries, and States
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!--
order: 5
order: 6
-->

# Functions
Expand Down
9 changes: 5 additions & 4 deletions x/leveragelp/spec/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
## Contents

1. **[Concepts](01_concepts.md)**
2. **[Usage](02_usage.md)**
3. **[Keeper](03_keeper.md)**
4. **[Protobuf Definitions](04_protobuf_definitions.md)**
5. **[Functions](05_functions.md)**
2. **[Mechanism](02_mechanism.md)**
3. **[Usage](03_usage.md)**
4. **[Keeper](04_keeper.md)**
5. **[Protobuf Definitions](05_protobuf_definitions.md)**
6. **[Functions](06_functions.md)**

## References

Expand Down

0 comments on commit bc851ac

Please sign in to comment.