# Coinbase Prime

Source: https://docs.formance.com/modules/payments/connectors/exchange/coinbaseprime

Stack: v3.2

Coinbase Prime is available in Connectivity. From Stack v4.0, the Connectivity module records Coinbase Prime activity directly in Ledger. [See the Coinbase Prime connector](https://docs.formance.com/v4.0/modules/connectivity/connectors/coinbaseprime)

The Coinbase Prime connector polls a Coinbase Prime portfolio and surfaces its wallets, balances, payments, trading orders, and conversions to the Payments service. It is read-only.

## Prerequisites

You need a Coinbase Prime account and an API key with the minimum permissions for the capabilities you use.

To create an API key in the Coinbase Prime console:

Navigate to API settings

Go to **Settings**, then **API**.

Create a new API key

Click **Create API Key** and select the portfolio you want to connect.

Set expiration

Choose an expiration date as needed.

If you set an expiration date, you will need to update the connector configuration with new credentials when the key expires.

Set permissions

Set **Read** permissions — the connector is read-only and polls Accounts, Balances, Payments, Orders, and Conversions. Configure IP restrictions if your environment requires them.

Save the **API key**, **API secret**, and **passphrase** — all three are required for the connector configuration.

Make sure to create an API key dedicated to Formance. Doing so will improve your auditability and security and will allow you to revoke access to Formance at any time if needed.

## Installation

curl

```bash
curl -X POST $FORMANCE_API_URL/api/payments/v3/connectors/install/coinbaseprime \
  -H "Content-Type: application/json" \
  -d @'config.json'
```

fctl

```bash
fctl payments connectors install coinbaseprime config.json
```

With `config.json` containing:

```json
{
  "apiKey": "string",
  "apiSecret": "string",
  "name": "string",
  "passphrase": "string",
  "pollingPeriod": "30m",
  "portfolioId": "string"
}
```

### Configuration fields

| Field           | Required | Default | Description                                                                                 |
| --------------- | -------- | ------- | ------------------------------------------------------------------------------------------- |
| `apiKey`        | yes      | —       | Coinbase Prime API key.                                                                     |
| `apiSecret`     | yes      | —       | Secret key from API-key creation.                                                           |
| `name`          | yes      | —       | Unique name for this connector instance.                                                    |
| `passphrase`    | yes      | —       | Passphrase from API-key creation.                                                           |
| `pollingPeriod` | no       | `30m`   | Sync cadence.                                                                               |
| `portfolioId`   | yes      | —       | Portfolio to connect. One connector per portfolio — install several to track more than one. |

## Capabilities

- `FETCH_ACCOUNTS` — portfolio wallets.
- `FETCH_BALANCES` — per-wallet balances.
- `FETCH_PAYMENTS` — deposits, withdrawals, internal transfers, rewards, and staking flows.
- `FETCH_ORDERS` — spot trading orders with full fill lifecycle. Requires Payments 3.3.0+.
- `FETCH_CONVERSIONS` — atomic two-asset swaps (e.g. stablecoin redemption). Requires Payments 3.3.0+.

Outbound initiation, webhooks, and external-account creation are not implemented — see [Known gaps](#known-gaps).

## Account model

Every Payments internal account is one Coinbase Prime wallet in the configured portfolio. Coinbase Prime distinguishes wallet types — trading, vault, onchain, custody (`QC`), and `WALLET_TYPE_OTHER` — and only **trading wallets** settle orders. Order resolution is therefore restricted to trading wallets so each asset symbol resolves unambiguously.

The `reference` is the `walletID`; `defaultAsset` is the wallet's symbol (e.g. `BTC/8`, `USD/2`). No EXTERNAL accounts are emitted — counterparty addresses surface in Payment metadata only. See [Accounts](https://docs.formance.com/modules/payments/accounts) for the cross-connector model.

## Payments

Coinbase Prime transactions land on the [Payments](https://docs.formance.com/modules/payments/payments) stream, **excluding** rows of type `CONVERSION` (which feed [Conversions](#conversions)). Each upstream transaction lands on exactly one stream.

### Transaction type to Payment type

| Coinbase transaction type                                                                                                                          | Payment `type` |
| -------------------------------------------------------------------------------------------------------------------------------------------------- | -------------- |
| `DEPOSIT`, `COINBASE_DEPOSIT`, `COINBASE_REFUND`, `REWARD`, `DEPOSIT_ADJUSTMENT`, `CLAIM_REWARDS`                                                  | `PAY-IN`       |
| `WITHDRAWAL`, `SWEEP_WITHDRAWAL`, `PROXY_WITHDRAWAL`, `BILLING_WITHDRAWAL`, `WITHDRAWAL_ADJUSTMENT`, `SLASH`                                       | `PAYOUT`       |
| `INTERNAL_DEPOSIT`, `INTERNAL_WITHDRAWAL`, `SWEEP_DEPOSIT`, `PROXY_DEPOSIT`, `STAKE`, `RESTAKE`, `PORTFOLIO_STAKE`, `UNSTAKE`, `PORTFOLIO_UNSTAKE` | `TRANSFER`     |
| Chain-level events (`KEY_REGISTRATION`, `DELEGATION`, `VOTE_AUTHORIZE`, `ONCHAIN_TRANSACTION`, …) and any unrecognized type                        | `OTHER`        |

### Status mapping

Successful transactions → `SUCCEEDED`; failures and rejections → `FAILED`; mid-flight → `PENDING`. Cancellations and expirations map distinctly for dashboarding.

Full Coinbase status to Payment status table

| Coinbase transaction status                                                                                                                                                                                                                                                                                                                                | Payment `status` |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------- |
| `TRANSACTION_PENDING`, `TRANSACTION_CREATED`, `TRANSACTION_REQUESTED`, `TRANSACTION_APPROVED`, `TRANSACTION_GASSING`, `TRANSACTION_GASSED`, `TRANSACTION_PROVISIONED`, `TRANSACTION_PLANNED`, `TRANSACTION_PROCESSING`, `TRANSACTION_RESTORED`, `TRANSACTION_IMPORT_PENDING`, `TRANSACTION_DELAYED`, `TRANSACTION_BROADCASTING`, `TRANSACTION_CONSTRUCTED` | `PENDING`        |
| `TRANSACTION_DONE`, `TRANSACTION_IMPORTED`                                                                                                                                                                                                                                                                                                                 | `SUCCEEDED`      |
| `TRANSACTION_CANCELLED`                                                                                                                                                                                                                                                                                                                                    | `CANCELLED`      |
| `TRANSACTION_EXPIRED`                                                                                                                                                                                                                                                                                                                                      | `EXPIRED`        |
| `TRANSACTION_FAILED`, `TRANSACTION_REJECTED`                                                                                                                                                                                                                                                                                                               | `FAILED`         |
| `OTHER_TRANSACTION_STATUS`                                                                                                                                                                                                                                                                                                                                 | `OTHER`          |
| anything else                                                                                                                                                                                                                                                                                                                                              | `UNKNOWN`        |

### Amount and asset

Amounts use the precision from Coinbase Prime's asset catalogue (`GetAssets` provides `decimal_precision` per symbol). Common assets: `BTC/8`, `ETH/18`, `USDC/6`, `USD/2`. Always trust the `asset` field on the Payment rather than assuming a precision.

Transactions referencing an asset not in the catalogue are skipped (logged) and don't produce a Payment.

### Account resolution

Each leg resolves independently:

1. If Coinbase populates `transfer_from.value` (or `transfer_to.value`) with `type == WALLET`, that wallet ID becomes the leg's account reference.
2. Otherwise the connector falls back to the transaction's `wallet_id`: `PAY-IN` → destination, `PAYOUT` → source.
3. External blockchain addresses (e.g. self-custody withdrawal) land in Payment metadata as `source_address` / `deposit_address`, never as account references.

### Metadata

Under `com.formance.connectors.coinbaseprime.`:

- **Always present**: `type`, `status`.
- **Present when populated**: `wallet_id`, `portfolio_id`, `network`, `external_tx_id`, `source_address`, `deposit_address`, `completed_at`, `blockchain_ids`.
- **Present when any fee is non-zero**: `fees`, `network_fees` (only non-zero), `fee_symbol`.

### Example response

A 1.5 ETH withdrawal from a trading wallet to an external address:

```json
{
  "id": "<formance-payment-id>",
  "connectorID": "<connector-id>",
  "provider": "coinbaseprime",
  "reference": "tx_4f3a8e9d1c",
  "createdAt": "2026-04-30T08:14:22Z",
  "type": "PAYOUT",
  "amount": 1500000000000000000,
  "initialAmount": 1500000000000000000,
  "asset": "ETH/18",
  "scheme": "OTHER",
  "status": "SUCCEEDED",
  "sourceAccountID": "<formance-account-id-of-eth-trading-wallet>",
  "destinationAccountID": null,
  "metadata": {
    "com.formance.connectors.coinbaseprime.type": "WITHDRAWAL",
    "com.formance.connectors.coinbaseprime.status": "TRANSACTION_DONE",
    "com.formance.connectors.coinbaseprime.wallet_id": "wlt_eth_abc123",
    "com.formance.connectors.coinbaseprime.deposit_address": "0xabc1234567890def...",
    "com.formance.connectors.coinbaseprime.fees": "0.0021",
    "com.formance.connectors.coinbaseprime.fee_symbol": "ETH"
  }
}
```

`destinationAccountID` is `null` because the destination is an external blockchain address, preserved in `metadata.deposit_address`.

## Orders

Coinbase Prime trading orders land on the [Orders](https://docs.formance.com/v3.2/modules/payments/orders) stream — one record per Coinbase order with an append-only `adjustments` list capturing each fill or status change.

### Direction and account legs

| Direction | `sourceAsset` | `destinationAsset` | `sourceAccountID`             | `destinationAccountID`        |
| --------- | ------------- | ------------------ | ----------------------------- | ----------------------------- |
| `BUY`     | quote         | base               | quote-currency trading wallet | base-currency trading wallet  |
| `SELL`    | base          | quote              | base-currency trading wallet  | quote-currency trading wallet |

Both legs are restricted to **trading** wallets — vault, onchain, and custody are ineligible. If the trading wallet for a symbol hasn't been synced yet, the order page retries on the next cycle (no row is dropped).

### Status mapping

Coinbase Prime statuses map directly to Payments statuses, with one exception: `PARTIALLY_FILLED` is computed locally — Coinbase doesn't expose it. An order becomes `PARTIALLY_FILLED` when the upstream status is `OPEN` and the filled quantity sits strictly between zero and the ordered quantity.

Full Coinbase status to Order status table

| Coinbase status                                   | Order `status`                |
| ------------------------------------------------- | ----------------------------- |
| `PENDING`                                         | `PENDING`                     |
| `OPEN` with no fills                              | `OPEN`                        |
| `OPEN` with `0 < filled_quantity < base_quantity` | `PARTIALLY_FILLED` (computed) |
| `FILLED`                                          | `FILLED`                      |
| `CANCELLED`                                       | `CANCELLED`                   |
| `EXPIRED`                                         | `EXPIRED`                     |
| `FAILED`                                          | `FAILED`                      |

### Quantities, amounts, and prices

| Coinbase field    | Order field                     | Precision   |
| ----------------- | ------------------------------- | ----------- |
| `base_quantity`   | `baseQuantityOrdered`           | base asset  |
| `filled_quantity` | `baseQuantityFilled`            | base asset  |
| `filled_value`    | `quoteAmount`                   | quote asset |
| `commission`      | `fee` (with `feeAsset` = quote) | quote asset |

Why prices use a dynamic precision

Coinbase Prime returns price strings derived from `float64`, so values like `"1825.6099999998417653"` carry float-encoding noise past roughly 10 decimals. The connector picks a **dynamic precision** equal to the maximum number of decimals across `limit_price`, `stop_price`, and `average_filled_price`, capped at 10, and parses prices with a truncating decimal parser. `priceAsset` may therefore declare a higher precision than `quoteAsset` (e.g. `quoteAsset = USD/2`, `priceAsset = USD/6`).

### Metadata

Under `com.formance.connectors.coinbaseprime.`:

`product_id`, `portfolio_id`, `client_order_id`, `quote_value`, `filled_value`, `order_total`, `exchange_fee`, `net_average_filled_price`, `historical_pov`, `quote_currency`, `price_asset`, `base_wallet_id`, `quote_wallet_id`, optional `post_only`. Commission breakdown adds `commission_total`, `commission_client`, `commission_venue`, `commission_ces`, `commission_financing`, `commission_regulatory`, `commission_clearing` when Coinbase returns the detail block.

### Example response

A partially-then-fully-filled `BUY` of 0.5 BTC on `BTC-USD` at a 50,000 USD limit:

```json
{
  "id": "<formance-order-id>",
  "reference": "ord_9c7e1a4b3d",
  "direction": "BUY",
  "sourceAsset": "USD/2",
  "destinationAsset": "BTC/8",
  "type": "LIMIT",
  "status": "FILLED",
  "timeInForce": "GOOD_UNTIL_CANCELLED",
  "baseQuantityOrdered": 50000000,
  "baseQuantityFilled": 50000000,
  "limitPrice": 5000000,
  "averageFillPrice": 4998750,
  "quoteAmount": 2499375,
  "quoteAsset": "USD/2",
  "priceAsset": "USD/2",
  "fee": 1250,
  "feeAsset": "USD/2",
  "adjustments": [
    { "createdAt": "2026-04-30T09:00:05Z", "status": "PENDING", "baseQuantityFilled": 0 },
    { "createdAt": "2026-04-30T09:00:30Z", "status": "OPEN",    "baseQuantityFilled": 0 },
    { "createdAt": "2026-04-30T09:08:45Z", "status": "PARTIALLY_FILLED", "baseQuantityFilled": 22500000, "fee": 562 },
    { "createdAt": "2026-04-30T09:12:30Z", "status": "FILLED", "baseQuantityFilled": 50000000, "fee": 1250 }
  ]
}
```

## Conversions

The connector queries Coinbase Prime's transactions feed filtered to type `CONVERSION` and emits one [Conversion](https://docs.formance.com/v3.2/modules/payments/conversions) per row. Coinbase Prime exposes a single `amount` field per conversion, so `sourceAmount` and `destinationAmount` are populated **1:1** (parsed at each side's precision) — correct for stablecoin redemption (USDC ↔ USD) where nominal value is identical.

### Asset and account resolution

| Coinbase field        | Conversion field       |
| --------------------- | ---------------------- |
| `symbol`              | `sourceAsset`          |
| `destination_symbol`  | `destinationAsset`     |
| `transfer_from.value` | `sourceAccountID`      |
| `transfer_to.value`   | `destinationAccountID` |

Rows with a missing symbol or one absent from the catalogue are skipped (logged). Account references are used directly without gating on `transfer_*.type`; either may be empty without blocking emission.

### Status mapping

Conversions have a tighter lifecycle than Payments — no `CANCELLED` or `EXPIRED`.

Full Coinbase status to Conversion status table

| Coinbase transaction status                                           | Conversion `status` |
| --------------------------------------------------------------------- | ------------------- |
| `TRANSACTION_DONE`, `TRANSACTION_IMPORTED`                            | `COMPLETED`         |
| `TRANSACTION_FAILED`, `TRANSACTION_REJECTED`, `TRANSACTION_CANCELLED` | `FAILED`            |
| anything else                                                         | `PENDING`           |

### Fees

`fees` is parsed at the precision of `fee_symbol`, falling back to the source symbol when absent. If the fee currency isn't in the catalogue, only the fee is dropped — the conversion itself is still emitted.

### Metadata

Under `com.formance.connectors.coinbaseprime.`: `transaction_id`, `type` (always present); `portfolio_id` (when populated).

### Example response

A 10,000 USDC → USD conversion (no fee on stablecoin redemption):

```json
{
  "id": "<formance-conversion-id>",
  "reference": "tx_d2b4a17e9c",
  "sourceAsset": "USDC/6",
  "destinationAsset": "USD/2",
  "sourceAmount": 10000000000,
  "destinationAmount": 1000000,
  "fee": null,
  "feeAsset": null,
  "status": "COMPLETED",
  "sourceAccountID": "<formance-account-id-of-usdc-wallet>",
  "destinationAccountID": "<formance-account-id-of-usd-wallet>"
}
```

## Troubleshooting

An Order or Conversion never appears in the API

Orders and Conversions resolve their account legs against wallets pulled by Accounts. On a fresh install, the first Accounts cycle must complete before Order and Conversion pages succeed — they retry until then.

Verify the trading wallet has synced:

```bash
fctl payments accounts list --connector-id $CONNECTOR_ID | grep TRADING
```

If still missing after several cycles, check connector logs for an unsupported asset or a Coinbase API error.

A Conversion is stuck in PENDING

`PENDING` covers everything other than `TRANSACTION_DONE` / `TRANSACTION_IMPORTED` (success) or the failure family. Inspect the conversion's metadata for the exact upstream status:

```bash
curl -s "$STACK/api/payments/v3/conversions/$CONVERSION_ID" \
  -H "Authorization: Bearer $TOKEN" | jq '.data.metadata'
```

Cross-reference `transaction_id` against the Coinbase Prime portal.

A transaction's asset is missing or the row never shows up

Amounts use the precision from Coinbase Prime's `GetAssets` (plus a small fiat fallback). Transactions referencing an asset not in the catalogue are **silently skipped** and logged — no Payment, Order, or Conversion is produced.

Look for `unsupported currency` in connector logs. The asset starts flowing once Coinbase publishes precision metadata; re-trigger an Accounts sync to refresh the catalogue.

When was the connector last polled?

Each capability schedule exposes its run history via the schedule APIs. See [Monitoring connector schedules](https://docs.formance.com/v3.2/modules/payments/operations#monitoring-connector-schedules).

## Known gaps

- **Outbound initiation** — Coinbase Prime exposes withdrawal APIs, but the connector is read-only. `CreateTransfer` and `CreatePayout` are not wired.
- **Webhooks** — not consumed; refresh runs on the polling cycle.
- **Historical Orders and Conversions** — read from the activity feed forward from the first install cycle; pre-install activity is not back-filled.
- **Cross-portfolio aggregation** — one connector per `portfolioID`. Install several to track multiple portfolios.
