> For the complete documentation index, see [llms.txt](https://ibran-fi.gitbook.io/ibran-fi-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ibran-fi.gitbook.io/ibran-fi-docs/documentation/how-it-works/swap-collateral.md).

# Swap Collateral

<figure><img src="https://1706890399-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fut1KR5gBsYRStYYEyRyp%2Fuploads%2FJlDnLxiuFG3PxbR3JJpM%2Fswapcollibranfarcaster.png?alt=media&amp;token=382ba5c7-408c-417d-9d9b-ddb041351c0b" alt=""><figcaption></figcaption></figure>

## Collateral Swap Mechanism

Ibran Finance features a built-in collateral swap mechanism that allows users to adjust their collateral composition directly within the protocol, without closing existing lending or borrowing positions. This capability is particularly valuable for managing **WETH-backed loans** and stablecoin positions without triggering unnecessary withdrawals or deposits.

Inspired by the architecture of Automated Market Makers (AMMs), the swap system is fully integrated into the Ibran Finance Pool to enable real-time, on-chain asset exchanges with minimal friction.

#### 1. Liquidity Provision and Pool Structure

Liquidity Providers (LPs) supply token pairs such as **WETH–USDC** or **WETH–USDT** to the Ibran Finance Pool, which acts as the central liquidity reserve for collateral swap operations.

In return, LPs receive Pool Tokens representing their proportional ownership, entitling them to a share of transaction fees generated from swaps. The Ibran Finance Pool maintains segregated reserves for each supported asset and dynamically updates these balances as swaps are executed.

#### 2. Collateral-Linked Access Control

Only users with active lending or borrowing positions are allowed to access the swap functionality. This ensures that swaps are used for **collateral optimization** rather than speculative trading.

When a user initiates a swap (for example, swapping **WETH for USDC** to reduce volatility risk), the swap logic references current reserve ratios and applies an AMM pricing formula such as the constant product model to determine the output amount.

#### 3. Oracle Integration for Price Validation

To guarantee accurate valuation of swapped collateral, Ibran Finance integrates **Chainlink oracles**. Chainlink delivers tamper-resistant, real-time price feeds for all supported assets, including **WETH and stablecoins**.

This ensures that each swap reflects fair market value, helping maintain healthy collateralization ratios and reducing systemic risk across lending positions.

#### 4. Incentivization through Fees

Each swap transaction incurs a small liquidity fee, which is distributed proportionally among active LPs based on their share of the pool.

This fee structure encourages continuous liquidity provision, sustains the swap module over the long term, and supports a healthy cross-asset collateral market within Ibran Finance.
