# For stablecoin apps

Let your users move between dollars and native Bitcoin. They buy BTC with USDC and pay no gas, or sell BTC for USDC, USDT or USDG with the payout locked before their BTC moves. For stablecoin wallets, dollar accounts and payment apps whose users hold stablecoins and want real BTC at their own address.

## What each stablecoin does

| Chain | Buy BTC with | Sell BTC into |
| --- | --- | --- |
| Base | USDC, gasless | USDC, USDT |
| Arbitrum | USDC, gasless | USDC, USDT |
| BNB Chain | — | USDC, USDT, both with 18 decimals |
| Avalanche | — | USDC, USDt |
| Robinhood Chain | — | USDG |

`GET /pairs` is always the current list, and `GET /tokens?chain=…` gives each token's address and decimals. Read `decimals` from the API rather than assuming 6: [Chains and tokens](https://maxy.co/docs/chains-and-tokens).

## What to build

1. **Show both directions live.** Price buys and sells as the user types, as below.
2. **Buy with USDC, no gas.** The wallet signs a permit when needed and a transfer bound to the order, and sends nothing. The solver opens the escrow and pays its gas, so a user who has never held ETH can finish: [Pay with USDC](https://maxy.co/docs/pay-with-usdc).
3. **Sell into a stablecoin.** The user's EVM wallet signs one sell order, with no gas. The solver locks the payout in the settler, then the user pays one Bitcoin output of exactly `sats`, and a proof releases the payout to them: [Sell BTC](https://maxy.co/docs/sell-btc).
4. **Follow every order.** Webhooks keep your activity list right when the user closes the app: [Webhooks](https://maxy.co/docs/webhooks).

## Price both directions

Prices need your key and no wallet, and reserve nothing. `BASE` and `KEY` are as on [Get a price](https://maxy.co/docs/buy-btc#get-a-price).

```sh
curl -sG -H "x-maxy-key: $MAXY_API_KEY" "$BASE/price" --data-urlencode "from=USDC on arbitrum" -d to=BTC -d amount=100 | jq -c '{route, receive: .formatted.receive}'
curl -sG -H "x-maxy-key: $MAXY_API_KEY" "$BASE/price" -d from=BTC --data-urlencode "to=USDT on arbitrum" -d amount=0.001 | jq -c '{route, receive: .formatted.receive}'
```

```ts
const price = (q: Record<string, string>) => fetch(`${BASE}/price?${new URLSearchParams(q)}`, { headers: { 'x-maxy-key': KEY } }).then((r) => r.json());
const buy = await price({ from: 'USDC on arbitrum', to: 'BTC', amount: '100' });
const sell = await price({ from: 'BTC', to: 'USDT on arbitrum', amount: '0.001' });
console.log(buy.route, buy.formatted.receive, sell.route, sell.formatted.receive);
```

```python
def price(**q):
    return requests.get(f"{BASE}/price", headers={"x-maxy-key": KEY}, params=q).json()

buy = price(**{"from": "USDC on arbitrum", "to": "BTC", "amount": "100"})
sell = price(**{"from": "BTC", "to": "USDT on arbitrum", "amount": "0.001"})
print(buy["route"], buy["formatted"]["receive"], sell["route"], sell["formatted"]["receive"])
```

## Amounts

Every amount is a string in the smallest unit: 6-decimal units for USDC, USDT and USDG, except 18 decimals for USDC and USDT on BNB Chain, and sats for BTC. `formatted` has the same amounts in words, such as `61.96 USDT on Arbitrum`. A sell is at least about $10; a buy with USDC starts at 546 sats after costs; the largest order is your key's cap: [Order size](https://maxy.co/docs/keys-and-limits#order-size).

## When something goes wrong

If the solver never opens a USDC escrow, the USDC never left the wallet, and the signature lapses after 2 hours. A sell must be paid exactly and on time, or the payout cannot be released to the user: show the exact amount and the time left from `expiresAt`, and ask for one payment. Both cases, and who acts: [When it fails](https://maxy.co/docs/when-it-fails).

## Keys

Prices and quotes can come from the page with a publishable key; orders go through your server with the secret key: [Keys and limits](https://maxy.co/docs/keys-and-limits).

---
Source: https://maxy.co/docs/for-stablecoin-apps (Maxy Docs › Maxy for your app › Use cases)
