Skip to main content

AMM Functions

SUBFROST uses the OYL protocol as its AMM backend. For more information on OYL and to view metrics on liquidity, please visit https://oyl.io.

The subrail-cli provides a suite of commands for interacting with the Automated Market Maker (AMM) functionality of the Alkanes metaprotocol. This allows you to create liquidity pools, add and remove liquidity, and swap tokens.

AMM Commands

Create a Pool

subrail-cli alkanes create-pool --calldata <DATA> --tokens <TOKENS>

This command creates a new liquidity pool with the specified tokens. The --calldata argument is used to pass additional data to the AMM contract, and the --tokens argument is a list of the tokens to include in the pool.

Add Liquidity

subrail-cli alkanes add-liquidity --calldata <DATA> --tokens <TOKENS>

This command adds liquidity to an existing pool. The --tokens argument specifies the amount of each token to add.

Remove Liquidity

subrail-cli alkanes remove-liquidity --calldata <DATA> --token <TOKEN> --amount <AMOUNT>

This command removes liquidity from a pool. You specify the pool token you want to remove and the amount.

Swap Tokens

subrail-cli alkanes swap --calldata <DATA> --token <TOKEN> --amount <AMOUNT>

This command swaps one token for another in a liquidity pool.

Private Transactions with Rebar

The subrail-cli integrates with Rebar Labs' Shield product to provide private transaction broadcasting. This is useful for protecting your privacy when interacting with the AMM. For more information on Rebar Labs, please visit https://rebarlabs.io.

To use Rebar, simply add the --rebar flag to your alkanes execute command.

subrail-cli alkanes execute --rebar --to ... --inputs ... ...

Note: The --rebar flag is only available on the Bitcoin mainnet.

When you use the --rebar flag, your transaction will be sent to the Rebar Labs Shield endpoint (https://shield.rebarlabs.io/v1/rpc) instead of being broadcast directly to the Bitcoin network. This helps to obscure the origin of your transaction.

AMM in subfrost-cli

The subfrost-cli provides a set of commands for interacting with the AMM. These commands allow you to:

  • Create a liquidity pool: The subfrost-cli amm create-pool command allows you to create a new liquidity pool.
  • Add liquidity: The subfrost-cli amm add-liquidity command allows you to add liquidity to an existing pool.
  • Remove liquidity: The subfrost-cli amm remove-liquidity command allows you to remove liquidity from a pool.
  • Swap tokens: The subfrost-cli amm swap command allows you to swap one token for another in a liquidity pool.

Swapping frBTC for dxBTC

Here is an example of how to use the subfrost-cli to swap frBTC for dxBTC:

subfrost-cli amm swap --from frBTC --to dxBTC --amount 1.0

This command will swap 1.0 frBTC for dxBTC in the frBTC/dxBTC liquidity pool.