---
name: coinmargin-agent-math
description: Use CoinMargin's paid x402 endpoints for fee-aware break-even, tiny-trade, DCA, position-size, and risk/reward calculations.
---

# CoinMargin Agent Math

Use the OpenAPI contract at https://coinmargin-lab.ak10082247.workers.dev/openapi.json to choose a calculator and construct its query. Each successful response costs $0.001 USDC on Base mainnet through x402 v2. No account or API key is required.

The same five tools are also listed at https://payanagent.com/agents/j570p15f0dvyzt2w129s2qgn698bg8zd for $0.01 USDC per successful marketplace call.

## Workflow

1. Read https://coinmargin-lab.ak10082247.workers.dev/api or https://coinmargin-lab.ak10082247.workers.dev/openapi.json.
2. Choose the narrowest endpoint for the requested calculation.
3. Send a GET request with its numeric query parameters.
4. Handle the 402 challenge with an x402-compatible client, then retry with the payment signature.
5. Treat the JSON as deterministic scenario maths, not a prediction or recommendation.

## Endpoints

- `/api/tiny-trade` — Calculate fee-aware break-even, profit or loss, ROI, and the exit needed to make a target profit on a small crypto trade.
- `/api/break-even` — Find the exact exit price that recovers buy fees, sell fees, fixed costs, and an optional target profit.
- `/api/dca-average` — Combine three purchases into a fee-aware average entry, total quantity, current value, and unrealised profit or loss.
- `/api/position-size` — Calculate a position quantity and notional value from account size, risk percentage, entry price, stop price, and a fee buffer.
- `/api/risk-reward` — Compare a target and stop around an entry price, including transaction fees, to calculate net reward, net risk, and their ratio.
