Since you're already familiar with how the "Deposit & Withdraw" and "Repay & Borrow" functions operate as a swap mechanism on @0xfluid, let’s dive into how buy and sell orders work through Smart Debt and Smart Collateral.

Imagine an 80-20 wstETH-ETH Smart Debt pool. In this scenario, 80% of the Smart Debt is in wstETH and 20% is in ETH. But what does it mean to have 80% of the debt in wstETH?

Smart Debt functions like an inverse Automated Market Maker (AMM). This means that 80% of the wstETH in the debt pool corresponds to 80% of the selling liquidity for wstETH. In other words, selling wstETH here is equivalent to repaying wstETH debt and borrowing ETH debt (which is done on behalf of the borrower, as you might recall).

Similarly, when a trader sells wstETH on the Smart Collateral side, they deposit wstETH and withdraw ETH. Since 80% of Smart Collateral is in ETH, wstETH gets access to 80% of the selling liquidity from the collateral side as well.

Let’s run through an example with actual numbers. Suppose a user deposits $3M into the wstETH-ETH pool and leverages it 20 times. The final DEX liquidity pool (LP) would total $117M, consisting of $93.6M in ETH liquidity and $23.4M in wstETH liquidity. This setup results in more ETH liquidity than any existing wstETH-ETH pool!