> ## Documentation Index
> Fetch the complete documentation index at: https://arcpay-somnia.vercel.app/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Somnia DeFi Adapters

> Somnia-native swap, liquidity, and yield adapter map for ArcPay treasury agents.

ArcPay Somnia treats DeFi execution as a policy-bound adapter flow, not a fake
fill. Operators and agents can prepare route or yield intents, but an action is
only complete after real Somnia evidence is attached.

## Adapter Map

| Adapter                   | Role                                            | Execution Mode                                                  | Evidence Required                                                                         |
| ------------------------- | ----------------------------------------------- | --------------------------------------------------------------- | ----------------------------------------------------------------------------------------- |
| dreamDEX CLOB             | Fully on-chain central limit order book         | REST/CLI market discovery plus wallet-signed Somnia transaction | Market quote, pool address, signed order tx hash, order/fill status, before/after balance |
| Somnia Exchange           | Native swap venue                               | Wallet-signed route execution                                   | Quote, wallet simulation, tx hash, before/after balance                                   |
| Somnex                    | Aggregator, liquidity, and perps venue          | Agent-prepared route or strategy intent                         | Venue quote, position/risk summary, tx hash, risk snapshot                                |
| Potion Swap               | Testnet DEX candidate                           | Manual signer or agent handoff                                  | Quote screenshot, pool route, tx hash                                                     |
| Custom Somnia DEX adapter | Builder-owned router from Somnia's DEX tutorial | Contract adapter                                                | Adapter address, quote response, fill transaction hash                                    |

## Swap Flow

1. Operator or agent chooses a venue on `/swaps`.
2. ArcPay records source asset, target asset, amount, slippage, executor, and venue.
3. Treasury policy checks run before wallet signing or agent order creation.
4. Execution happens through the selected venue or a custom adapter.
5. Audit record is completed only after tx hash and route evidence are attached.

## Yield / Liquidity Flow

1. Operator chooses a strategy on `/yield`: dreamDEX maker yield, Somnia Exchange LP, Somnex liquidity/perps, Potion Swap LP, or treasury hold.
2. ArcPay records risk limit, max drawdown, asset, amount, and executor agent.
3. Operator approval is required before any LP, perps, or strategy action.
4. Final audit requires venue evidence, tx hash, final balance, and risk snapshot.

## Developer Tools

HTTP developer tool:

```bash theme={null}
curl https://arcpay-somnia.vercel.app/api/developer/tools/somnia_defi_adapters
```

Public adapter status:

```bash theme={null}
curl https://arcpay-somnia.vercel.app/api/somnia/defi/status
```

CLI:

```bash theme={null}
npm install -g @arcpaylabs/somnia-cli
arcpay-somnia defi-adapters
```

MCP:

```text theme={null}
Tool: somnia_defi_adapters
```

## Boundary

ArcPay does not claim an official private Somnia DeFi SDK where one is not
published. The adapter layer is designed to be honest and useful:

* use dreamDEX's documented REST/CLI/contract flow for CLOB market discovery and signed order transactions
* use live Somnia venues when they expose usable testnet flows
* use a custom router when building directly from Somnia's DEX tutorial
* never mark execution done without transaction evidence
* keep all route and strategy actions inside treasury policy controls

## Source References

* dreamDEX docs: [https://docs.dreamdex.io/ld25g222WKDrLlJMcR41](https://docs.dreamdex.io/ld25g222WKDrLlJMcR41)
* dreamDEX quick start: [https://docs.dreamdex.io/ld25g222WKDrLlJMcR41/welcome/quick-start.md](https://docs.dreamdex.io/ld25g222WKDrLlJMcR41/welcome/quick-start.md)
* dreamDEX contracts: [https://docs.dreamdex.io/ld25g222WKDrLlJMcR41/developers/contracts.md](https://docs.dreamdex.io/ld25g222WKDrLlJMcR41/developers/contracts.md)
* dreamDEX contract specs and testnet pools: [https://docs.dreamdex.io/ld25g222WKDrLlJMcR41/trading/readme-1/contract-specifications.md](https://docs.dreamdex.io/ld25g222WKDrLlJMcR41/trading/readme-1/contract-specifications.md)
* Somnia network information and faucet: [https://docs.somnia.network/developer/network-info](https://docs.somnia.network/developer/network-info)
* Somnia DEX tutorial: [https://docs.somnia.network/developer/tutorials/build-a-dex-on-somnia](https://docs.somnia.network/developer/tutorials/build-a-dex-on-somnia)
* Somnia MCP transaction tooling: [https://somniamcp.xyz/mcp/](https://somniamcp.xyz/mcp/)
* Potion Swap overview: [https://docs.uprisinglabs.io/games-and-products/potion-swap-dex](https://docs.uprisinglabs.io/games-and-products/potion-swap-dex)
