> For the complete documentation index, see [llms.txt](https://wiki.shellprotocol.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wiki.shellprotocol.io/getting-started/developers/aggregating-pools.md).

# Aggregating Pools

## Quick Links

* [Contract Addresses](/getting-started/overview/contract-addresses.md)
* [Native Primitives](/getting-started/integrations/shell-native-primitives.md)
* [Example of sending a swap through the Ocean](https://github.com/Shell-Protocol/Shell-Protocol/blob/bfbba01472200a4a34ace4cb131f775018cf47c2/test/Interaction.js#L346)
* [Shell Protocol GitHub](https://github.com/Shell-Protocol/Shell-Protocol/)

## Swap through Shell-native fractal pools

<figure><img src="/files/KoJAyat10fvX0c1vsWIT" alt=""><figcaption><p>You can swap any ERC-20s by creating a path through this graph.</p></figcaption></figure>

You can use Shell pools to swap any ERC-20 (or ERC-721 or ERC-1155) tokens, as long as there exists a viable path of AMMs.

Fractal pools can serve as a stepping stone in swapping between ERC-20 tokens. A fractal pool uses LP tokens as one or both of its reserve assets. For example:

* The two reserve assets of <mark style="background-color:green;">**`Stablepool`**</mark> are <mark style="background-color:orange;">**`DAI+USDC`**</mark> LP token and `USDT+USDC` LP token.
* The two reserve assets for <mark style="background-color:purple;">**`ETH+USD`**</mark> pool are <mark style="background-color:blue;">**`shETH`**</mark> and <mark style="background-color:green;">**`Stablepool`**</mark> LP token.

Let's swap <mark style="background-color:yellow;">**`shDAI`**</mark> to <mark style="background-color:blue;">**`shETH`**</mark>. You must deposit <mark style="background-color:yellow;">**`shDAI`**</mark> into the <mark style="background-color:orange;">**`DAI+USDC`**</mark> pool to get the <mark style="background-color:orange;">**`DAI+USDC`**</mark> LP token, then take that LP token and deposit it into <mark style="background-color:green;">**`Stablepool`**</mark> to get the <mark style="background-color:green;">**`Stablepool`**</mark> LP token, then swap that LP token to <mark style="background-color:blue;">**`shETH`**</mark> using the fractal pool (<mark style="background-color:purple;">**`ETH+USD`**</mark>).

{% hint style="info" %}
**Tip:** Depositing or withdrawing from a pool is functionally the same as swapping. You call `computeOutputAmount` but with the LP token ID as the output token instead of a wrapped token.
{% endhint %}

Remember in Shell Protocol, ERC-20 (or 721 or 1155) tokens are wrapped onto a shared ERC-1155 ledger ([the Ocean](/how-shell-works/the-ocean-accounting-hub.md)). Shell pools always use the Shell-wrapped ERC-1155 version of these tokens.

Shell LP tokens are also ERC-1155. They each have their own Ocean IDs, just as the Shell-wrapped ERC-20s do.

{% hint style="info" %}
**Tip:** You can get the LP token ID from the LP pool contract. There is a read function called `lpTokenId`.
{% endhint %}

Whenever you swap from one ERC-20 token to another through Shell pools, there will be a wrap and unwrap in that transaction. For example, trading <mark style="color:yellow;">**`DAI`**</mark> for <mark style="color:blue;">**`ETH`**</mark> would look like this:

1. wrap <mark style="color:yellow;">**`DAI`**</mark> -> <mark style="background-color:yellow;">**`shDAI`**</mark>
2. deposit <mark style="background-color:yellow;">**`shDAI`**</mark> -> <mark style="background-color:orange;">**`DAI+USDC`**</mark> LP
3. deposit <mark style="background-color:orange;">**`DAI+USDC`**</mark> LP -> <mark style="background-color:green;">**`Stablepool`**</mark> LP
4. swap <mark style="background-color:green;">**`Stablepool`**</mark> LP -> <mark style="background-color:blue;">**`shETH`**</mark> (through <mark style="background-color:purple;">**`ETH+USD`**</mark> pool)
5. unwrap <mark style="background-color:blue;">**`shETH`**</mark> -> <mark style="color:blue;">**`ETH`**</mark>

{% hint style="info" %}
**Tip:** All of this can be done in one function call with `doMultipleInteractions`.
{% endhint %}

The fractal design makes querying the prices of token pairs somewhat complicated.

{% hint style="info" %}
**Coming soon:** Sample code for finding the price between two tokens.
{% endhint %}
