# Case Study: Osmosis

## Cosmoswap

Here is a quick overview of how [Cosmoswap](https://blog.nabla.studio/nabla-ogp-present-cosmoswap-91b83464f285) works on the Osmosis decentralized exchange:

Cosmoswap leverages Osmosis's pooled liquidity infrastructure to enable customizable "outposts" - IBC-connected DEX deployments on other chains.

For example, Landslide functions as a Cosmoswap outpost on Avalanche. Landslide, built with the Cosmos SDK, handles the Avalanche-side transactions and liquidity routing.

Osmosis manages the core liquidity pools and validation logic. Landslide contains router contracts directing trades to Osmosis over IBC.

This allows users on Avalanche to tap into swaps powered by Osmosis's deep liquidity pools in a decentralized manner. Avalanche validators handle trades while Osmosis validators govern pool actions.

Cosmoswap outposts like Landslide go beyond basic bridges. They create customizable DEX environments tuned to each chain's needs while benefiting from Osmosis's back-end infrastructure.

Active transaction listening via WebSockets provides rich insights into swap status and performance. This enhances user experience with timely notifications.

Overall, Cosmoswap unlocks new horizons for multi-chain decentralization by deploying adaptable outposts that harness Osmosis's liquidity. This delivers on the vision of fluid interoperability across heterogeneous networks.

{% @mermaid/diagram content="sequenceDiagram
participant Osmosis
participant IBC Module
participant Relayer
participant Landslide

Osmosis ->> IBC Module: Create packet data
IBC Module ->> Relayer: Send packet to Relayer
Relayer ->> IBC Module: Relay packet to destination chain
IBC Module ->> Landslide: Receive packet on AVAX subnet
Landslide ->> IBC Module: Acknowledge packet receipt
IBC Module ->> Relayer: Send acknowledgement to relayer
Relayer ->> IBC Module: Relay acknowledgement to source chain
IBC Module ->> Osmosis: Deliver acknowledgement to dApp
" %}

<figure><img src="https://2042960397-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPdxSILrJhVcwwtZuvGHo%2Fuploads%2FzO6QtmdFZInyHzynatJt%2Fmermaid-diagram-2023-08-23-170644.png?alt=media&#x26;token=619629f8-09fb-430d-b0fa-10ce175d5a8f" alt=""><figcaption></figcaption></figure>

## Cross Chain Validation

When utilizing Cosmoswap's outpost architecture, transaction validation occurs across both chains:

{% @mermaid/diagram content="sequenceDiagram
participant User
participant Landslide
participant Osmosis
participant Avalanche

```
User->>Landslide: Initiates swap on Avalanche

Landslide->>Osmosis: Checks liquidity on Osmosis

Osmosis-->>Landslide: Approves withdrawal from core pools

Avalanche->>Avalanche: Validates swap transaction

Osmosis->>Osmosis: Validates IBC transfers

Landslide-->>User: Returns swap result

Osmosis->>Landslide: Relays IBC packets

Avalanche->>Osmosis: Confirms IBC packets" %}
```

* Trades executed on the Landslide outpost on Avalanche are validated by Avalanche validators, not Osmosis validators.
* However, the IBC packet transfers enabling asset flows between Osmosis and Landslide are validated on both sides:
  * Osmosis validators validate escrowing, transferring, and releasing assets on the Osmosis chain side.
  * Avalanche validators validate unwrapping assets and confirming token releases on Landslide.
* The core liquidity pools reside on Osmosis. Osmosis validators govern deposit and withdrawal transactions for these pools.
* Landslide contains router contracts that direct trades to the Osmosis pools while handling the user-facing Avalanche side.
* This separation of duties retains security while maximizing performance. Osmosis secures the central pools while Avalanche validators handle end-user trades.

In summary, Osmosis validators secure core pool liquidity and IBC transactions while Avalanche/Landslide validators govern swap execution and finality on the user front-end. This hybrid validation approach powers decentralized cross-chain swaps.
