← Protocols
ALEX
01Description

Bitcoin DeFi protocol on Stacks: AMM, orderbook, launchpad, and BRC-20/Runes/Stacks cross-chain swaps. Provides REST market data and a typed TS SDK for swap routing.

02Best for
  • 01BTC/STX/sBTC swaps
  • 02BRC-20 and Runes liquidity
  • 03Bitcoin DeFi aggregation
  • 04AMM + orderbook hybrid
  • 05Bitcoin-native launchpad
03Install
  • pnpm add alex-sdk @stacks/transactions @stacks/connect
04Environment variables
VariableScopeDescription
ALEX_API_BASE_URLClientALEX REST API base URL (defaults to https://api.alexgo.io).
05Prompt snippet
Use ALEX for Bitcoin DeFi swaps and liquidity on Stacks. Install `alex-sdk` and instantiate `const alex = new AlexSDK()`; call `alex.getAllPossibleRoutes(fromCurrency, toCurrency)` to find a route, then `alex.getAmountTo(from, fromAmount, to)` to quote, and `alex.runSwap(stxAddress, from, to, fromAmount, minDy, route)` to build the contract-call payload. Pass the result to `@stacks/connect` `openContractCall` for user signing. For market data without swapping, hit the REST API at `ALEX_API_BASE_URL/v1/...` (pools, prices, volume).
06Gotchas
  • Slippage on lower-liquidity pairs (BRC-20, smaller Runes) can be brutal — always set `minDy` from a fresh quote with a sensible buffer.
  • Cross-chain swaps that touch native BTC are not atomic with the Stacks contract call: the BTC leg settles on Bitcoin's timeline (~1 hour for safe confirmation).
  • ALEX runs on Stacks (Clarity), so post-conditions matter — failing to set them can let contracts move tokens you didn't intend; the SDK helpers configure these for you, but custom flows must add them manually.
  • ALEX historically suffered a bridge exploit in 2024; review the latest audit and bridge architecture before integrating peg-in/peg-out flows.
  • Token identifiers in the SDK use ALEX's currency enum, not contract principals — don't hard-code asset addresses.
07Alternatives