Aggregating Pools
Tips on integrating fractal pools in your aggregator

You can swap any ERC-20s by creating a path through this graph.
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
Stablepool
areDAI+USDC
LP token andUSDT+USDC
LP token. - The two reserve assets for
ETH+USD
pool areshETH
andStablepool
LP token.
Let's swap
shDAI
to shETH
. You must deposit shDAI
into the DAI+USDC
pool to get the DAI+USDC
LP token, then take that LP token and deposit it into Stablepool
to get the Stablepool
LP token, then swap that LP token to shETH
using the fractal pool (ETH+USD
).Tip: Depositing or withdrawing from a pool is functionally the same as swapping. You callcomputeOutputAmount
but with the LP token ID as the output token instead of a wrapped token.
Remember in Shell Protocol, ERC-20 (or 721 or 1155) tokens are wrapped onto a shared ERC-1155 ledger (the Ocean). 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.
Tip: You can get the LP token ID from the LP pool contract. There is a read function calledlpTokenId
.
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
DAI
for ETH
would look like this:- 1.wrap
DAI
->shDAI
- 2.deposit
shDAI
->DAI+USDC
LP - 3.deposit
DAI+USDC
LP ->Stablepool
LP - 4.swap
Stablepool
LP ->shETH
(throughETH+USD
pool) - 5.unwrap
shETH
->ETH
Tip: All of this can be done in one function call withdoMultipleInteractions
.
The fractal design makes querying the prices of token pairs somewhat complicated. Coming soon: sample code for finding the price between two tokens.
Last modified 27d ago