Can AMMs Be Built on Brollup?

3 min readJul 1, 2024


Brollup allows us to introduce payable types and enables smart contracts to accept Bitcoin payments. Unlike Ethereum, however, smart contracts in the Brollup context do not hold custody of Bitcoin; instead, they facilitate atomic trades between two parties using introspective assertion logic.

Our payable construction enables non-Bitcoin asset types, such as collectibles, stablecoins, or even financial derivatives, to be atomically exchanged for Bitcoin. As outlined in the earlier announcement, this covers over 90% of DeFi use cases, whether it’s building an NFT marketplace, where the buyer pays with Bitcoin upon execution, or creating a decentralized order book, where the filler pays with Bitcoin upon execution.

And you may have been wondering whether it is also possible to build an AMM. The answer is yes!

First of all, it is certainly possible to build liquidity pools for token-to-token pairs, since this type of construction does not involve a Bitcoin payment; it involves swapping a non-Bitcoin asset for another non-Bitcoin asset.

Suppose we have a $PEPE token issued on Brollup, and our Italian overlords have also issued $USDT. We can deploy an AMM contract as follows:

PEPE<>USDT AMM contract

With this contract, we can swap between $PEPE and $USDT or add/remove liquidity in a CPMM fashion. However, we can’t swap between $BTC and $PEPE because this contract does not support a payable construction.

To facilitate swaps involving the $BTC pair, we can create another contract designed for swapping $BTC and $USDT in an orderbook fashion, then route through the AMM contract to execute the $USDT -> $PEPE swap.

We can deploy a $BTC<>$USDT orderbook as follows:

USDT<>BTC Orderbook Contract

With this contract, we can swap between $BTC and $USDT in an orderbook fashion. Due to $BTC <> $USDT being a primary trading pair, this contract is anticipated to be highly liquid.

Given that contracts can call each other, we can initiate the swap by first converting $BTC to $USDT through the orderbook contract, then route through the AMM contract to execute the $USDT -> $PEPE swap.

This setup allows us to execute the $BTC -> $USDT -> $PEPE route when swapping $BTC for $PEPE, or the $PEPE -> $USDT -> $BTC route when swapping $PEPE for $BTC. Either both contracts succeed, or the transaction terminates due to an asserted failure.