> For the complete documentation index, see [llms.txt](https://sharwa.gitbook.io/sharwa-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sharwa.gitbook.io/sharwa-docs/margin-account/liquidity-providers.md).

# Liquidity Providers

### How liquidity providers earn yield <a href="#how-liquidity-providers-earn-yield" id="how-liquidity-providers-earn-yield"></a>

<figure><img src="/files/1kwX5ssMwhbBZwSUDbqK" alt=""><figcaption></figcaption></figure>

Traders on Sharwa can borrow up to 10x their collateral. For example, if a trader provides 10,000 $USDC, they can borrow up to 100,000 $USDC (10x leverage) from the liquidity pools. While this may seem unusual, even with 10x leverage, all debts on Sharwa are OVER-COLLATERALIZED.

**Here’s how it works:**

1. The trader provides 100 $USDC of collateral to the margin account (funds are sent from their wallet to a smart contract).
2. When funds are deposited into the margin account, the system allows borrowing up to 10x the capital. In this case, 1,000 borrowed $USDC are sent to the margin account.
3. The user’s account now holds a total value of 1,100 $USDC (collateral + borrowed tokens). At this point, the margin ratio is 110%, meaning the account is over-collateralized by 10%.
4. The trader decides to use the borrowed funds. Since the funds are within the margin account, they can only be used for a limited set of options—in this case, Uniswap v3. The user can swap tokens from their margin account for $WBTC, $WETH, or $USDC.
5. Since the user has already borrowed $USDC, they decide to bet on the rise of $ETH and swap the 1,100 $USDC to $ETH. For simplicity, let’s say they purchase 1.1 $ETH at 1,000 $USDC per $ETH.

**ETH Price Change Example**

If the price of $ETH drops from 1,000 $USDC to 940 $USDC, the account value will decrease accordingly.

* New account value: 1,034 $USDC
* Debt: 1,003 $USDC (1,000 borrowed + 3 $USDC interest)
* Margin Ratio: 1,034 / 1,003 = 103%

If the margin ratio falls below 105%, liquidation occurs, and all assets in the margin account will be sold for $USDC, resulting in 1,034 $USDC.

* Liquidity providers receive their 1,000 $USDC (principal) plus 3 $USDC of interest.
* The remaining 34 $USDC is returned to the margin account.
* With the debt cleared, the trader can withdraw funds or borrow again.

## Liquidation

<figure><img src="/files/pDJF6XrBJxgtF5Bi22nj" alt=""><figcaption></figcaption></figure>

To make sure margin accounts are liquidated promptly, we’ve set up two separate liquidation systems to monitor and act on all margin accounts:

* **Server-Side Script:** A classic script runs on a server, continuously pulling real-time data. When a margin account becomes eligible for liquidation, the script automatically triggers the liquidation mechanism.
* **Chainlink Automation:** This decentralized solution adds another level of reliability. When a margin account is ready for liquidation, Chainlink Automation steps in and triggers the liquidation process.

The liquidation mechanism described in detail in this [section](#liquidation).

## Risks

Liquidity providers face several risks when participating in the protocol:

1. **Technical Risks**: Liquidity providers are exposed to the risk of bugs or vulnerabilities in the protocol, which could result in the loss of funds.
2. **Bad Debt Risk**: Liquidity providers may encounter bad debt if a margin account is liquidated and the amount repaid to the liquidity pools is less than the borrowed funds plus the interest.

To mitigate these risks, Sharwa employs an [insurance pool](/sharwa-docs/margin-account/liquidity-providers/insurance-pool.md) In the event of bad debt, the insurance pool is used to cover the shortfall.

## How we addressed the risks

1. To reduce technical risks, we have been [audited by Pashov Group](/sharwa-docs/margin-account/security.md). Security audits help protect the protocol from bugs and hackers, but it’s important to keep in mind that security audits do not guarantee 100% security.
2. To ensure margin accounts are liquidated promptly, we’ve set up two separate liquidation systems to monitor and act on all margin accounts:
   * Server-Side Script: A classic script runs on a server, continuously pulling real-time data. When a margin account becomes eligible for liquidation, the script automatically triggers the liquidation mechanism.
   * Chainlink Automation: This decentralized solution adds another level of reliability. When a margin account is ready for liquidation, Chainlink Automation steps in and triggers the liquidation process.
