# Overview
Source: https://docs.pacifica.fi/api-documentation/api
Welcome to Pacifica's API documentation. We offer complete REST and Websocket APIs to suit your trading needs.\
\
The documentation includes clear descriptions, parameter requirements, example responses, and code snippets to help developers quickly implement these endpoints in their applications.\
\
You can also use the API via the Pacifica Python SDK: [https://github.com/pacifica-fi/python-sdk](https://github.com/pacifica-fi/python-sdk)\
\
For any feedback, suggestions, and additional help with integration into Pacifica's API, please let us know in our [discord API channel](https://discord.com/channels/1325864651816435822/1378723526957334548)!\ \
# API FAQ
Source: https://docs.pacifica.fi/api-documentation/api/api-faq
* [403 CloudFront](/api-documentation/api/api-faq/403-cloudfront): Common error caused by GET requests with an empty request body.
* [Delayed account\_positions](/api-documentation/api/api-faq/delayed-account_positions): Potential delay of snapshot endpoints and best practice for reconstructing local state
# 403 CloudFront
Source: https://docs.pacifica.fi/api-documentation/api/api-faq/403-cloudfront
Common error caused by GET requests with an empty request body.
**Question:**\
Why am I getting a 403 "The request could not be satisfied" error from CloudFront?\\
\
**Answer:**\
After our migration to CloudFront, GET requests with an empty request body will be rejected with a 403 error (while previously accepted).\
\
Using `curl` as an example, remove the `-d '{}'` or any empty payload from your GET requests. GET requests should not include a request body.\
\
**Example:**
This **will not** work:
```shellscript theme={null}
curl -X GET -H "PF-API-KEY: your-api-key" -H "Content-Type: application/json" -d '{}' "https://api.pacifica.fi/api/v1/positions?account=..."
```
This **will** work:
```shellscript theme={null}
curl -X GET -H "PF-API-KEY: your-api-key" "https://api.pacifica.fi/api/v1/positions?account=..."
```
# Delayed account\_positions
Source: https://docs.pacifica.fi/api-documentation/api/api-faq/delayed-account_positions
Potential delay of snapshot endpoints and best practice for reconstructing local state
**Question:**\
My `account_positions`/`account_orders` updates are sometimes delayed. What should I do to reliably construct a local state based on Pacifica's WS feeds?\
\
**Answer:**\
`account_positions` and `account_orders` are snapshot-driven channels. They show your current state but can be delayed under high load.\
\
For real-time updates with no delay, use our event-driven channels:
* `account_trades` - update on every fill as it happens
* `account_order_updates` - update on every order state change
We recommend using our snapshot-driven channels for initialization/checks, and our event-driven channels to construct a real-time local state.
# Error Codes
Source: https://docs.pacifica.fi/api-documentation/api/error-codes
This section provides a comprehensive list and definition of all error codes generated by the Pacifica API
### Pacifica API Response Codes (REST API)
| 400 | Bad Request |
| - | - |
| 403 | Forbidden: restricted region |
| 404 | Not Found |
| 409 | Conflict |
| 422 | Business Logic Error - See below |
| 429 | Too Many Requests - Rate limit exceeded |
| 500 | Internal Server Error |
| 503 | Service Unavailable |
| 504 | Gateway Timeout |
### Error Response Format
Error responses can carry an `error_id`: a stable string that names the failure. Match on `error_id`, not on `error`, because the message text can change.
```json theme={null}
{
"success": false,
"data": null,
"error": "Invalid message: signature expired; timestamp + expiry_window is before current time.",
"code": 400,
"error_id": "signature_expired"
}
```
Signature failures return status `400` with one of these `error_id` values:
| `error_id` | Meaning |
| - | - |
| `signature_malformed` | The signature is not valid base58 or has the wrong length |
| `signature_expired` | `timestamp` + `expiry_window` is before the current time |
| `signature_verification_failed` | The signature does not match the signer and the payload |
| `signed_message_invalid` | The signed payload has an invalid format |
| `signer_invalid` | The signer's public key is invalid |
A request with an invalid field returns status `400` and lists each bad field in `details`:
```json theme={null}
{
"success": false,
"data": null,
"error": "...",
"code": 400,
"error_id": "input_too_long",
"details": {
"type": "invalid_fields",
"fields": [
{
"loc": ["body", "symbol"],
"error_id": "input_too_long",
"message": "..."
}
]
}
}
```
### Business Logic Errors (Code 422)
These values are returned in the `code` field of a `422` response.
| Code | Name |
| - | - |
| 0 | `INTERNAL` |
| 1 | `ACCOUNT_NOT_FOUND` |
| 2 | `ACCOUNT_ALREADY_EXISTS` |
| 3 | `BOOK_NOT_FOUND` |
| 4 | `INVALID_TICK_LEVEL` |
| 5 | `INSUFFICIENT_BALANCE` |
| 6 | `ORDER_NOT_FOUND` |
| 7 | `ORDER_AMOUNT_TOO_LOW` |
| 8 | `ORDER_AMOUNT_TOO_HIGH` |
| 9 | `OVER_WITHDRAWAL` |
| 10 | `OPEN_ORDER_LIMIT_REACHED` |
| 11 | `INVALID_LEVERAGE` |
| 12 | `CANNOT_UPDATE_MARGIN` |
| 13 | `POSITION_NOT_FOUND` |
| 14 | `DATABASE_ERROR` |
| 15 | `INVALID_DEPOSIT_NONCE` |
| 16 | `INVALID_STOP_TICK` |
| 17 | `INVALID_STOP_ORDER_SIDE` |
| 18 | `INVALID_STOP_ORDER_AMOUNT` |
| 19 | `INVALID_STOP_ORDER_REDUCE_ONLY` |
| 20 | `INVALID_ORDER_TYPE` |
| 21 | `INVALID_REDUCE_ONLY_ORDER_SIDE` |
| 22 | `INVALID_REDUCE_ONLY_ORDER_AMOUNT` |
| 23 | `NO_POSITION_FOR_REDUCE_ONLY_ORDER` |
| 24 | `INVALID_LIQUIDATION_SIDE` |
| 25 | `NO_REASONABLE_PRICE` |
| 26 | `CHANNEL_CLOSED` |
| 27 | `RESPONSE_DROPPED` |
| 28 | `IMMEDIATE_LIQUIDATION` |
| 29 | `WITHDRAW_AMOUNT_TOO_LOW` |
| 30 | `PRICE_TOO_FAR_FROM_MARK` |
| 31 | `DAILY_WITHDRAW_LIMIT_EXCEEDED` |
| 32 | `WITHDRAWAL_BLOCKED` |
| 33 | `INVALID_TRANSFER_RELATIONSHIP` |
| 34 | `SUBACCOUNT_WITHDRAWAL_NOT_ALLOWED` |
| 35 | `SUBACCOUNT_CANNOT_CREATE_SUBACCOUNT` |
| 36 | `DUPLICATE_CLIENT_ORDER_ID` |
| 37 | `UNUSED_CLIENT_ORDER_ID` |
| 38 | `TRADING_DISABLED` |
| 39 | `INVALID_FEE_MODE` |
| 40 | `NOT_MAIN_ACCOUNT` |
| 41 | `OPEN_INTEREST_LIMIT_EXCEEDED` |
| 42 | `EXCHANGE_WITHDRAW_LIMIT_REACHED` |
| 43 | `TWAP_DUPLICATE_CLIENT_ORDER_ID` |
| 44 | `TWAP_UNUSED_CLIENT_ORDER_ID` |
| 45 | `TWAP_ORDER_FAIL_TO_GET_SUB_ORDER_AMOUNT` |
| 46 | `TWAP_ORDER_DURATION_TOO_SHORT` |
| 47 | `TWAP_ORDER_NOT_FOUND` |
| 48 | `TWAP_ORDER_COUNT_PER_SYMBOL_LIMIT_EXCEEDED` |
| 49 | `POSITION_TPSL_LIMIT_EXCEEDED` |
| 50 | `INVALID_BUILDER_CODE` |
| 51 | `UNSUPPORTED_OPERATION` |
| 52 | `INVALID_TICK_SIZE` |
| 53 | `ORDER_BLOCKED_BY_LOAN_POOL_STRESS` |
| 54 | `ASSET_ALREADY_EXISTS` |
| 55 | `ASSET_NOT_FOUND` |
| 56 | `ASSET_NOT_ACTIVE` |
| 59 | `INVALID_AMOUNT` |
| 61 | `SPOT_WITHDRAWAL_EXCEEDS_COLLATERAL` |
| 62 | `INSUFFICIENT_SPOT_BALANCE` |
| 63 | `MISSING_MARK_PRICE` |
| 64 | `INVALID_FLOOR_PRICE_PCT` |
| 65 | `SPOT_EXCLUSION_BREACHES_COLLATERAL` |
| 66 | `LAKE_NOT_FOUND` |
| 67 | `LAKE_ADDRESS_COLLISION` |
| 68 | `LAKE_MIN_DEPOSIT_AMOUNT` |
| 69 | `LAKE_INVALID_SHARES` |
| 70 | `LAKE_OVER_WITHDRAWAL` |
| 71 | `LAKE_NICKNAME_ALREADY_EXISTS` |
| 72 | `LAKE_WITHDRAWAL_NOT_ALLOWED` |
| 73 | `LAKE_MANAGER_IS_SUBLAKE` |
| 74 | `LAKE_NOT_CREATOR` |
| 75 | `LAKE_DEPOSIT_CAP_EXCEEDED` |
| 76 | `LAKE_WITHDRAW_TOO_EARLY` |
| 77 | `LAKE_INVALID_REV_SHARE_CONFIG` |
| 78 | `LAKE_DEPOSITOR_OVER_WITHDRAWAL` |
| 79 | `LAKE_ALREADY_HAS_MANAGER` |
| 80 | `LAKE_MANAGER_BALANCE_PORTION_TOO_LOW` |
| 81 | `LAKE_INVALID_BALANCE_PORTION_CONFIG` |
| 82 | `LAKE_LIQUIDATION_PORTION_ABOVE_MIN_PORTION` |
| 83 | `LAKE_TRADING_HALTED` |
| 84 | `INVALID_WITHDRAW_NONCE` |
| 85 | `LAKE_INVALID_WITHDRAW_WINDOW_CONFIG` |
| 86 | `LAKE_WITHDRAW_DURATION_ABOVE_WINDOW` |
| 87 | `LAKE_WITHDRAW_WINDOW_CLOSED` |
| 88 | `INVALID_SPOT_DEPOSIT_NONCE` |
| 89 | `SPOT_DEPOSIT_NONCE_GAP` |
| 90 | `INVALID_SPOT_WITHDRAW_NONCE` |
| 91 | `SPOT_BRIDGE_NOT_FOUND` |
| 92 | `SPOT_BRIDGE_INACTIVE` |
| 93 | `LAKE_SYMBOL_NOT_ALLOWED` |
| 94 | `LAKE_MAX_LEVERAGE_EXCEEDED` |
| 95 | `GAME_CONFIG_NOT_FOUND` |
| 96 | `GAME_ACCOUNT_NOT_FOUND` |
| 97 | `GAME_ACCOUNT_ADDRESS_COLLISION` |
| 99 | `GAME_DEPOSIT_CAP_EXCEEDED` |
| 100 | `GAME_OPERATION_NOT_ALLOWED` |
| 101 | `GAME_ALREADY_ENDED` |
| 102 | `GAME_INVALID_CONFIG` |
| 103 | `GAME_ACCOUNT_WITHDRAWAL_NOT_ALLOWED` |
| 104 | `GAME_LEVERAGE_EXCEEDED` |
| 105 | `GAME_DEPOSIT_BELOW_MINIMUM` |
| 106 | `REDUCE_ONLY_NOT_SUPPORTED_FOR_SPOT` |
| 107 | `TP_SL_NOT_SUPPORTED_FOR_SPOT` |
| 108 | `BUILDER_CODE_NOT_SUPPORTED_FOR_SPOT` |
| 109 | `MARGIN_SETTINGS_NOT_APPLICABLE_FOR_SPOT` |
| 110 | `INVALID_BOOK_CONFIG` |
| 111 | `TAP_GAME_NOT_ACTIVE` |
| 112 | `TAP_GAME_INVALID_AMOUNT` |
| 113 | `TAP_GAME_ERROR` |
| 114 | `INVALID_COLLATERAL_LIMIT` / `LAKE_SELF_DEPOSIT_NOT_ALLOWED` |
| 115 | `SPOT_COLLATERAL_LIMIT_BREACHES_COLLATERAL` / `LAKE_DEPOSITOR_NOT_WHITELISTED` |
| 116 | `DAILY_SPOT_WITHDRAW_LIMIT_EXCEEDED` / `RFQ_SELF_QUOTE_NOT_ALLOWED` |
| 117 | `EXCHANGE_SPOT_WITHDRAW_LIMIT_REACHED` / `RFQ_NOT_SUPPORTED_FOR_SPOT` |
| 118 | `INVALID_SPOT_LIMIT` / `RFQ_MISSING_CLIENT_ORDER_ID` |
| 119 | `ORACLE_NOT_AVAILABLE` |
| 120 | `VAULT_WITHDRAWAL_NOT_ALLOWED` |
| 121 | `RFQ_QUOTE_WORSE_THAN_BOOK` |
| 122 | `SYMBOL_REDUCE_ONLY` |
| 123 | `LAKE_WITHDRAWAL_REQUEST_NOT_FOUND` |
| 124 | `LAKE_WITHDRAWAL_REQUEST_TOO_EARLY` |
| 130 | `GAME_STRIKE_OUT_OF_BOUNDS` |
| 131 | `INVALID_ORDER_EXPIRY` |
| 132 | `GAME_LAKE_DEPOSIT_CAP_EXCEEDED` |
| 133 | `GAME_TEMPORARILY_UNAVAILABLE` |
| 134 | `POSITION_ID_MISMATCH` |
| 150 | `TWAP_ORDER_VALUE_OUT_OF_RANGE` |
| 151 | `LAKE_TRADABLE_SYMBOL_LIMIT_EXCEEDED` |
| 152 | `LAKE_MATH_OVERFLOW` |
| 153 | `LAKE_POOL_DEAD` |
| 154 | `LAKE_DEPOSIT_MINTS_NO_SHARES` |
| 155 | `LAKE_POOL_INSOLVENT` |
| 156 | `LAKE_CLAIMER_HOLDS_LP_SHARES` |
| 157 | `LAKE_DEPOSIT_CYCLE` |
| 158 | `LAKE_OPTIONS_NOT_ALLOWED` |
Note: codes 57, 58, 60, and 98 are currently unused/reserved. Codes 114–118 are each shared by two distinct error variants in the backend.
### WebSocket Error Codes
| 200 | SUCCESS\_CODE |
| - | - |
| 400 | INVALID\_REQUEST\_CODE |
| 401 | INVALID\_SIGNATURE\_CODE |
| 402 | INVALID\_SIGNER\_CODE |
| 403 | UNAUTHORIZED\_REQUEST\_CODE |
| 420 | ENGINE\_ERROR\_CODE |
| 429 | RATE\_LIMIT\_EXCEEDED\_CODE |
| 500 | UNKNOWN\_ERROR\_CODE |
# Last ID
Source: https://docs.pacifica.fi/api-documentation/api/last-id
Last ID (LI) is a per-symbol sequence number used to order events and detect gaps
### Overview
**Last ID** (LI) is a sequence number Pacifica stamps on exchange events. It increases monotonically within a symbol (and within an account or order), so you can order updates, detect gaps, and correlate effects of the same event across streams. It is not a timestamp, so it is unaffected by clock drift.
It is the `li` field on WebSocket messages and snapshot rows, and the `last_order_id` key on REST snapshot responses.
### Usage
* Order events and detect gaps within the same symbol, account, or order — a larger LI is strictly later.
* Correlate effects of one event: a trade, its order update, and the resulting position change share the same LI.
* Compare LI only within the same symbol/account/order — not across them.
### Snapshots
Snapshot responses carry LI on each row (the latest event for that position or order; `null` for rows the engine has not touched yet) and once on the envelope — `last_order_id` (REST) or the outer `li` (WebSocket `account_positions`) — for the whole set. The envelope advances on closes and labels an empty set.
On reconnect, treat the snapshot as your baseline: replace local state with it, apply live snapshots with an equal or newer LI, and discard older ones.
### Where it appears
* REST: [`/api/v1/positions`](/api-documentation/api/rest-api/account/get-positions), [`/api/v1/orders`](/api-documentation/api/rest-api/orders/get-open-orders), [`/api/v1/trades`](/api-documentation/api/rest-api/markets/get-recent-trades)
* WebSocket: [`bbo`](/api-documentation/api/websocket/subscriptions/best-bid-offer-bbo), [`trades`](/api-documentation/api/websocket/subscriptions/trades), [`orderbook`](/api-documentation/api/websocket/subscriptions/orderbook), [`account_positions`](/api-documentation/api/websocket/subscriptions/account-positions), [`account_order_updates`](/api-documentation/api/websocket/subscriptions/account-order-updates), [`account_trades`](/api-documentation/api/websocket/subscriptions/account-trades)
# Market Symbols
Source: https://docs.pacifica.fi/api-documentation/api/market-symbols
Symbols accepted by the Pacifica API are CASE SENSITIVE.
For example, `'BTC'` is the expected form in requests, whereas requests with symbol field `'Btc'` or`'btc'` will fail.\
\
All market symbols are capitalized, except for markets with abbreviated numerical prefixes such as `'kBONK'` and `'kPEPE'` , which have the prefix in lower-case. Requests containing symbol fields such as `'KBONK'`, `'kbonk'`, or `'kBonk'` will fail.
# MCP Server
Source: https://docs.pacifica.fi/api-documentation/api/mcp
The Pacifica MCP server exposes the REST API as Model Context Protocol tools for AI agents.
The Pacifica MCP server is a [Model Context Protocol](https://modelcontextprotocol.io) server that exposes Pacifica's REST API as MCP tools.\
An MCP client such as Claude Desktop, Claude Code, or OpenAI Codex can then read the markets and place trades on your behalf, using natural language.
It wraps the same REST endpoints documented elsewhere in this section, covering:
* **Market data:** exchange info, prices, orderbook, candles, funding rates, and more.
* **Account and positions:** balances, settings, positions, and history queries.
* **Order management:** limit, market, stop, TP/SL, and TWAP orders, plus batch operations.
* **Spot:** spot asset data, balances, and withdrawals.
It also adds **on-chain funding** tools that act on Solana directly: mint test USDP on testnet and deposit USDC/USDP into your exchange balance.
The server is open source and published to npm:
* Source: [github.com/pacifica-fi/pacifica-mcp](https://github.com/pacifica-fi/pacifica-mcp)
* Package: [`@pacifica-fi/mcp-server`](https://www.npmjs.com/package/@pacifica-fi/mcp-server)
## Prerequisites
* **Node.js 18 or newer**
* A **Pacifica account address** (your main account or a subaccount)
* For trading (optional): a signing key, either your main wallet's secret key or, recommended, a revocable **agent key** bound to your account
Read-only access (market data and account queries) needs only the account address.\
Placing or cancelling orders requires a signing key. See [Configuration](/api-documentation/api/mcp/configuration).
## Quickstart
The server runs the same way in every client: the command is `npx -y @pacifica-fi/mcp-server`, which downloads and runs the latest published version automatically (no manual install step), configured through environment variables.
At minimum, set `ADDRESS` to your account. Add a signing key (`AGENT_PRIVATE_KEY`, recommended, or `PRIVATE_KEY`) to place trades, or omit it for read-only access.
Only the config format differs per client. See [Client Setup](/api-documentation/api/mcp/clients) for step-by-step instructions for Claude Desktop, Claude Code, OpenAI Codex, Factory, Hermes, and Crush.
On startup the server logs the active account and auth mode to stderr (visible in the MCP logs), e.g. `[pacifica-mcp] account=
mode=agent-key`.
> **Note:** By default the server targets the Pacifica **testnet** (`https://test-api.pacifica.fi`). To trade on production, set `PACIFICA_BASE_URL=https://api.pacifica.fi` in the `env` block. See [Configuration](/api-documentation/api/mcp/configuration) for all environment variables.
## Next Steps
* [Configuration](/api-documentation/api/mcp/configuration): environment variables, auth modes, and security.
* [Client Setup](/api-documentation/api/mcp/clients): configs for Claude Desktop, Claude Code, OpenAI Codex, Factory, Hermes, and Crush.
* [Tools](/api-documentation/api/mcp/tools): the full list of tools the server exposes.
# Client Setup
Source: https://docs.pacifica.fi/api-documentation/api/mcp/clients
Configure the Pacifica MCP server in Claude Desktop, Claude Code, OpenAI Codex, Factory, Hermes, and Crush.
Every MCP client runs the server the same way - the command is `npx -y @pacifica-fi/mcp-server` with the environment variables from [Configuration](/api-documentation/api/mcp/configuration) (`ADDRESS` plus `AGENT_PRIVATE_KEY` or `PRIVATE_KEY`; omit the key for read-only).
Only the config format differs per client.
The examples below use agent-key mode; swap in `PRIVATE_KEY`, or drop the key entirely for read-only.
## Claude Desktop
Go to **Settings → Developer → Edit Config** to open `claude_desktop_config.json`, then add the `pacifica` server:
```json theme={null}
{
"mcpServers": {
"pacifica": {
"command": "npx",
"args": ["-y", "@pacifica-fi/mcp-server"],
"env": {
"ADDRESS": "",
"AGENT_PRIVATE_KEY": ""
}
}
}
}
```
Restart Claude Desktop after saving. On startup the server logs the active account and auth mode to the MCP logs, e.g. `[pacifica-mcp] account= mode=agent-key`.
## Claude Code
Add it with the CLI:
```bash theme={null}
claude mcp add pacifica \
--transport stdio \
--env ADDRESS= \
--env AGENT_PRIVATE_KEY= \
-- npx -y @pacifica-fi/mcp-server
```
Or create `.mcp.json` in your project root (commit it to share with your team):
```json theme={null}
{
"mcpServers": {
"pacifica": {
"type": "stdio",
"command": "npx",
"args": ["-y", "@pacifica-fi/mcp-server"],
"env": {
"ADDRESS": "",
"AGENT_PRIVATE_KEY": ""
}
}
}
}
```
Verify with `claude mcp list`. Docs: [code.claude.com/docs/en/mcp](https://code.claude.com/docs/en/mcp)
## OpenAI Codex
Add it with the CLI:
```bash theme={null}
codex mcp add pacifica \
--env ADDRESS= \
--env AGENT_PRIVATE_KEY= \
-- npx -y @pacifica-fi/mcp-server
```
Or edit `~/.codex/config.toml` (note the nested `.env` table):
```toml theme={null}
[mcp_servers.pacifica]
command = "npx"
args = ["-y", "@pacifica-fi/mcp-server"]
[mcp_servers.pacifica.env]
ADDRESS = ""
AGENT_PRIVATE_KEY = ""
```
Docs: [developers.openai.com/codex/mcp](https://developers.openai.com/codex/mcp)
## Factory (droid)
Add it with the CLI:
```bash theme={null}
droid mcp add pacifica "npx -y @pacifica-fi/mcp-server" \
--env ADDRESS= \
--env AGENT_PRIVATE_KEY=
```
Or edit `~/.factory/mcp.json` (user-level) or `.factory/mcp.json` (project-level):
```json theme={null}
{
"mcpServers": {
"pacifica": {
"command": "npx",
"args": ["-y", "@pacifica-fi/mcp-server"],
"env": {
"ADDRESS": "",
"AGENT_PRIVATE_KEY": ""
}
}
}
}
```
Docs: [docs.factory.ai/cli/configuration/mcp](https://docs.factory.ai/cli/configuration/mcp)
## Hermes Agent
Edit `~/.hermes/config.yaml` (YAML, top-level `mcp_servers` key):
```yaml theme={null}
mcp_servers:
pacifica:
command: "npx"
args: ["-y", "@pacifica-fi/mcp-server"]
env:
ADDRESS: ""
AGENT_PRIVATE_KEY: ""
```
Reload with `/reload-mcp` inside Hermes, or restart it.
Docs: [hermes-agent.nousresearch.com/docs/user-guide/features/mcp](https://hermes-agent.nousresearch.com/docs/user-guide/features/mcp)
## Crush
Edit `crush.json` in your project root (or `~/.config/crush/crush.json` for all projects).
The top-level key is `mcp` (not `mcpServers`), and Crush expands `$VAR` shell references in values - so keep secrets in your environment rather than in the file:
```json theme={null}
{
"$schema": "https://charm.land/crush.json",
"mcp": {
"pacifica": {
"type": "stdio",
"command": "npx",
"args": ["-y", "@pacifica-fi/mcp-server"],
"env": {
"ADDRESS": "$PACIFICA_ADDRESS",
"AGENT_PRIVATE_KEY": "$PACIFICA_AGENT_PRIVATE_KEY"
}
}
}
}
```
Docs: [github.com/charmbracelet/crush](https://github.com/charmbracelet/crush)
# Configuration
Source: https://docs.pacifica.fi/api-documentation/api/mcp/configuration
Environment variables, authentication modes, and security for the Pacifica MCP server.
The MCP server is configured entirely through environment variables passed in your MCP client's config.\
Which keys you provide determines the [mode](#modes) the server runs in.
## Environment Variables
| Variable | Required | Description |
| - | - | - |
| `ADDRESS` | yes | Public address the actions apply to, your main account or a subaccount. Sent as the `account` field. |
| `PRIVATE_KEY` | no | Base58 Solana secret key (Ed25519) of the main account. Signs POST requests when no agent key is set. |
| `AGENT_PRIVATE_KEY` | no | Base58 secret key of an API **agent wallet** (revocable). When set, signs POST requests and sends `agent_wallet`, so you never expose your main key. The agent must already be bound to `ADDRESS`. Takes precedence over `PRIVATE_KEY`. |
| `AGENT_WALLET` | no | Agent wallet public key. Defaults to the value derived from `AGENT_PRIVATE_KEY`; only set this to override. |
| `PACIFICA_BASE_URL` | no | API host. Defaults to testnet `https://test-api.pacifica.fi`. Set to `https://api.pacifica.fi` for production. |
| `SOLANA_RPC_URL` | no | Solana RPC endpoint used by the on-chain funding tools (`mintUsdp`, `depositUsdp`). Defaults to public devnet `https://api.devnet.solana.com`; set a dedicated RPC to avoid public rate limits. |
| `PACIFICA_PROGRAM_ID` | no | Override the Pacifica on-chain program id used by `depositUsdp`. Defaults per network: the shipped testnet program on testnet, the Pacifica mainnet program on mainnet. |
| `PACIFICA_USDC_MINT` | no | Override the collateral mint used by `depositUsdp`. Defaults per network: testnet USDP on testnet, Circle USDC on mainnet. |
## Modes
The server picks a mode from the keys you provide:
* **Read-only:** set only `ADDRESS`. All read (GET) tools work; write (POST) tools return a clear "read-only mode" error.
* **Agent-key (recommended):** set `ADDRESS` + `AGENT_PRIVATE_KEY`. Full trading without ever putting your main wallet's private key in the config.
* **Main-key:** set `ADDRESS` + `PRIVATE_KEY`. Full trading, signing with the main wallet key (legacy behavior).
On startup the server logs the active account and mode to stderr (visible in the MCP logs), e.g. `[pacifica-mcp] account= mode=agent-key`.
## On-Chain Funding Tools
Two tools - `mintUsdp` and `depositUsdp` - sign and send Solana transactions directly instead of calling the REST API, so they have their own requirements:
* They require `PRIVATE_KEY`. An agent key signs API requests only and cannot sign on-chain transactions, so it does not work for these tools - this is the one case where the main key is required.
* They use `SOLANA_RPC_URL` for the Solana connection. It defaults to public devnet; set a dedicated RPC to avoid rate limits.
* `mintUsdp` is testnet only and is registered only when `PACIFICA_BASE_URL` targets testnet. `depositUsdp` works on both networks; on **mainnet it moves real USDC**.
On testnet, a typical flow is `mintUsdp` to credit your wallet, then `depositUsdp` to move those funds into your exchange balance. See [Tools](/api-documentation/api/mcp/tools#funding) for the tool list.
## Recommended: Agent Key
An agent key is a revocable key bound to your account: it can trade, but it cannot move funds the way your main wallet can, and you can revoke it at any time.\
Generate and bind one once at [app.pacifica.fi/apikey](https://app.pacifica.fi/apikey). You sign the binding in-browser, so your main secret never leaves your wallet.\
Then configure the MCP with only your account address and the agent key:
```json theme={null}
{
"mcpServers": {
"pacifica": {
"command": "npx",
"args": ["-y", "@pacifica-fi/mcp-server"],
"env": {
"ADDRESS": "",
"AGENT_PRIVATE_KEY": ""
}
}
}
}
```
For more on how agent keys work in Pacifica's signing scheme, see [API Agent Keys](/api-documentation/api/signing/api-agent-keys).
## Security
> **Important:** Never commit or paste your `PRIVATE_KEY` or `AGENT_PRIVATE_KEY` anywhere public. Treat any key that has been exposed as compromised and rotate it.
* Prefer an **agent key** over your main key: it is revocable and limited in scope.
* The config file holds your key in plaintext, so protect it like any other secret.
# Tools
Source: https://docs.pacifica.fi/api-documentation/api/mcp/tools
The full list of tools the Pacifica MCP server exposes, grouped by category.
The server exposes the tools below, grouped by category.
**Access** indicates the mode required:
* **Read** tools are GET requests and work in any mode, including read-only (`ADDRESS` only).
* **Write** tools are signed POST requests and require a signing key (`AGENT_PRIVATE_KEY` or `PRIVATE_KEY`). In read-only mode they return a clear "read-only mode" error.
* **On-chain** tools sign and send a Solana transaction directly rather than calling the REST API, so they require `PRIVATE_KEY` specifically - an agent key cannot sign on-chain transactions.
See [Configuration](/api-documentation/api/mcp/configuration) for how to set the mode.
## Markets
Market data and exchange info. All read-only.
| Tool | Access | Description |
| - | - | - |
| `getInfo` | Read | Exchange/market info (tick and lot size, max leverage, order limits) for all tradable pairs. |
| `getPrices` | Read | Funding, mark, oracle, and mid prices, plus open interest and 24h volume, for all pairs. |
| `getOrderbook` | Read | Current orderbook snapshot (bids and asks) for a pair. |
| `getRecentTrades` | Read | Recent trades for a pair. |
| `getKline` | Read | Candlestick (K-line) data for a pair and time interval. |
| `getMarkPriceKline` | Read | Mark-price candlestick data for a pair and time interval. |
| `getSparklines` | Read | Compact sparkline price series for one or more pairs. |
| `getFees` | Read | Fee tiers and their maker/taker fee rates. |
| `getFundingRateHistory` | Read | Funding rate history for a pair (cursor-paginated). |
| `getAggregatedFundingRates` | Read | Aggregated funding rates across exchanges. |
| `getLoanPool` | Read | Loan pool statistics (borrowed, borrowable, utilization, APR/APY). |
| `getPositionLiquidationPrices` | Read | Liquidation prices for the account's open positions. |
| `getCurrentTime` | Read | Current server time in milliseconds since the Unix epoch. |
## Account
Account info, settings, and history.
| Tool | Access | Description |
| - | - | - |
| `getAccountInfo` | Read | High-level account info: balance, equity, margin usage, fee tier, and spot balances. |
| `getAccountSettings` | Read | Non-default margin/leverage settings, auto-lend status, and per-asset spot settings. |
| `getAccountLoanInfo` | Read | Loan info: borrowed amounts, pending interest, and collateral utilization. |
| `getPortfolioHistory` | Read | Account equity and PnL history over a time range. |
| `getBalanceHistory` | Read | Balance-change history: deposits, withdrawals, transfers, and payouts. |
| `getFundingHistory` | Read | Funding-payment history on perpetual positions (cursor-paginated). |
| `getDailyAccountActivity` | Read | Daily activity summary (points, fees, volume) for a time range. |
| `getPayoutHistory` | Read | Payout history (cursor-paginated). |
| `getDepositHistory` | Read | Deposit history (cursor-paginated). |
| `getWithdrawalHistory` | Read | Withdrawal history (cursor-paginated). |
| `getPendingWithdrawals` | Read | Pending withdrawals not yet batched. |
| `updateLeverage` | Write | Set the leverage multiplier for a pair. |
| `updateMarginMode` | Write | Switch a pair between isolated and cross margin. |
| `updateSpotSettings` | Write | Set whether a spot asset is included in unified margin collateral. |
| `setAutoLendDisabled` | Write | Set the auto-lend preference for spot collateral. |
| `withdraw` | Write | Withdraw funds from the perp account. |
| `bindAgentWallet` | Write | Bind an agent wallet to the account (legacy direct-bind endpoint). |
## Orders & Positions
Order management and position tools.
| Tool | Access | Description |
| - | - | - |
| `getOpenOrders` | Read | All open (unfilled) orders for the account. |
| `getOrderHistory` | Read | Summarized order history (cursor-paginated). |
| `getOrderHistoryById` | Read | Full event history of a single order by ID. |
| `getCurrentPositions` | Read | All currently held positions. |
| `getPositionHistory` | Read | Per-fill trade/position history (cursor-paginated, max 30-day range). |
| `getOpenTwapOrders` | Read | All running TWAP orders. |
| `getTwapOrderHistory` | Read | Summarized TWAP order history (cursor-paginated). |
| `getTwapOrderHistoryById` | Read | Full per-event history of a single TWAP order by ID. |
| `openOrder` | Write | Create a limit order, optionally with an attached take-profit and/or stop-loss. |
| `createMarketOrder` | Write | Create a market order with max slippage, optionally with TP/SL. |
| `editOrder` | Write | Edit a limit order (cancels the original and creates a new post-only order). |
| `cancelOrder` | Write | Cancel an unfilled order by symbol and order ID. |
| `cancelAllOrders` | Write | Cancel all unfilled orders, or all for a single pair. |
| `createStopOrder` | Write | Create a standalone stop-loss/take-profit order. |
| `cancelStopOrder` | Write | Cancel a stop-loss/take-profit order by ID. |
| `setPositionTpsl` | Write | Attach take-profit and/or stop-loss to an existing position. |
| `addIsolatedMargin` | Write | Add USDC margin to an isolated position. |
| `createTwapOrder` | Write | Create a TWAP order that splits the total amount into market sub-orders over a duration. |
| `cancelTwapOrder` | Write | Cancel a running TWAP order by ID. |
| `batchOrders` | Write | Execute up to 10 order actions (create, cancel, edit, TP/SL) in one request. |
## Spot
Spot asset data, balances, and withdrawals.
| Tool | Access | Description |
| - | - | - |
| `getSpotAssets` | Read | List available spot assets and their parameters. |
| `getBridgeInfo` | Read | Bridge parameters for all spot assets. |
| `getBridgeParameters` | Read | Bridge parameters for a single spot asset. |
| `getSpotBalanceHistory` | Read | Spot asset balance history (cursor-paginated). |
| `getSpotDepositHistory` | Read | Spot asset deposit history (cursor-paginated). |
| `getSpotWithdrawalHistory` | Read | Spot asset withdrawal history (cursor-paginated). |
| `getPendingSpotWithdrawals` | Read | Pending spot asset withdrawals not yet batched. |
| `withdrawSpotAsset` | Write | Queue an on-chain spot asset withdrawal to your wallet (not reversible). |
## Funding
On-chain tools that fund your wallet and exchange balance. They sign and send Solana transactions directly rather than calling the REST API, so they require `PRIVATE_KEY` - an agent key cannot sign on-chain transactions - and they use `SOLANA_RPC_URL` (defaults to public devnet). See [Configuration](/api-documentation/api/mcp/configuration).
| Tool | Access | Description |
| - | - | - |
| `mintUsdp` | On-chain | Mint test USDP into your wallet's token account. Testnet only - registered only when `PACIFICA_BASE_URL` targets testnet. |
| `depositUsdp` | On-chain | Deposit your wallet's USDC/USDP into the Pacifica exchange balance used for trading. Works on testnet and mainnet; on mainnet it moves real USDC. |
On testnet, a typical flow is `mintUsdp` to credit your wallet, then `depositUsdp` to move those funds into your exchange balance.
# Rate Limits
Source: https://docs.pacifica.fi/api-documentation/api/rate-limits
Pacifica uses a credit-based rate limiting system with a 60-second rolling window.
### Credit Quotas
The API config key system allows Pacifica to provision higher rate limits to verified users, ensuring real traders have adequate resources while protecting against abuse.
| Tier | Base Credits/60s |
| - | - |
| Unidentified IP | 100 |
| Valid API Config Key | 300 |
These are base quotas and may be increased based on account reputation. The credit is shared across a main account and all its subaccounts. Naturally, higher [fee tier](/trading-on-pacifica/trading-fees) grants an account higher rate limits.
| Tier | Credits/60s |
| - | - |
| 1 | 300 |
| 2 | 600 |
| 3 | 1200 |
| 4 | 2400 |
| 5 | 6000 |
| VIP1 | 12000 |
| VIP2 | 24000 |
| VIP3 | 30000 |
### Credit Costs
| Action | Unidentified IP | API Config Key |
| - | - | - |
| Standard request/action | 1 | 1 |
| Order cancellation | 0.5 | 0.5 |
| Heavy GET requests | 3-12 | 1-4 |
When credits are exhausted, requests return HTTP 429.
### WebSocket Limits
| Limit | Value | When exceeded |
| - | - | - |
| Concurrent connections per IP | 255 | Connection upgrade fails with `429` |
| New connections per IP per minute | 255 | Connection upgrade fails with `429` |
| Subscriptions per connection | 500 | Subscribe fails with code `429` |
| Distinct accounts per connection | 500 | Subscribe fails with code `429` |
| Subscribe and unsubscribe messages per minute | 200 | Message fails with code `429` |
Subscription limits apply to each connection. Quotas can be raised for specific accounts.
### Open Order Limits
Each account can hold a limited number of open orders in each market:
| Account | Open orders per market |
| - | - |
| [Fee tier](/trading-on-pacifica/trading-fees) 1 | 300 |
| Fee tier 2 and above, and market makers | 1,000 |
An order that would go over the limit fails with code `10` (`OPEN_ORDER_LIMIT_REACHED`). Market and IOC orders do not rest on the book, so the limit does not apply to them.
### Checking Your Quota
> **Note:** All credit values are multiplied by 10 to support fractional costs (e.g., `r=1200` = 120.0 credits).
**REST API** - Response headers:
```
ratelimit: "credits";r=1200;t=32
ratelimit-policy: "credits";q=1250;w=60
```
**WebSocket** - `rl` field in action responses:
```json theme={null}
{"rl": {"r": 1200, "q": 1250, "t": 32}}
```
| Field | Description |
| - | - |
| `r` | Remaining credits |
| `t` | Seconds until refresh |
| `q` | Total quota per window |
| `w` | Window size in seconds |
# API Config Keys
Source: https://docs.pacifica.fi/api-documentation/api/rate-limits/api-config-keys
The following guide covers the creation and usage of Pacifica API Config Keys.
Pacifica offers API Config Key rate limiting on APIs that allows for more flexible limits.\
For more information around API Config Key limits, please reach out to us in the [Discord API channel](https://discord.com/channels/1325864651816435822/1378723526957334548).\
\
API Config Keys are generated via REST API. The Python SDK provides examples for how API Config Key can be generated, listed and revoked: [https://github.com/pacifica-fi/python-sdk/blob/main/rest/api\_config\_keys.py](https://github.com/pacifica-fi/python-sdk/blob/main/rest/api_config_keys.py).\
\
Each account can have up to 5 API Config Keys.
```http theme={null}
POST /api/v1/account/api_keys/create
POST /api/v1/account/api_keys/revoke
POST /api/v1/account/api_keys
```
#### Request Body
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | User's wallet address | `42trU9A5...` |
| `"signature"` | string | required | Cryptographic signature | `5j1Vy9Uq...` |
| `"timestamp"` | integer | required | Current timestamp in milliseconds | `1716200000000` |
| `"expiry_window"` | integer | optional | Signature expiry in milliseconds | `30000` |
#### Response
```json theme={null}
{
"data": {
"api_key": "AbCdEfGh_2mT8x..."
}
}
```
Note:\
API Config Keys are generated with a prefix for fast lookup\
Format: `"{8_char_prefix}_{base58_encoded_uuid}"`
### Using a Pacifica API Config Key
Pacifica's API Config Keys are used to enhance websocket rate-limiting. The default rate for an API Config Key follows the same restrictions as IP-based rate limits.\
\
Pacifica API Config Keys are used in the connection header to specify API Config Key rate limiting. Using the Python SDK as an example,
* for Websockets, add `extra_headers={"PF-API-KEY": "your_rate_limit_key"}`into `websockets.connect`
* for REST APIs, add `"PF-API-KEY": "your_rate_limit_key"` into `headers` with `{"Content-Type": "application/json"}`
# REST API
Source: https://docs.pacifica.fi/api-documentation/api/rest-api
All example API calls use the Pacifica Mainnet URL, but you can make the same requests against Testnet using the Pacifica Testnet URL.
Mainnet REST endpoint URL: [https://api.pacifica.fi/api/v1](https://api.pacifica.fi/api/v1)\
Testnet REST endpoint URL: [https://test-api.pacifica.fi/api/v1](https://test-api.pacifica.fi/api/v1)
Requests and responses use JSON.
# Account
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/account
This section covers details for interacting with user accounts on Pacifica.
* [Get account info](/api-documentation/api/rest-api/account/get-account-info): This endpoint allows users to get all high-level account info such as balance, fee level, equity, etc.
* [Get account settings](/api-documentation/api/rest-api/account/get-account-settings): This endpoint allows users to get account margin and leverage settings (if they are not at default values)
* [Update account settings](/api-documentation/api/rest-api/account/update-account-settings): This endpoint allows users to update account settings, such as their leaderboard privacy mode.
* [Update leverage](/api-documentation/api/rest-api/account/update-leverage): This endpoint allows users to change their account leverage for a specific trading pair. For open positions, users can only increase the leverage setting.
* [Update margin mode](/api-documentation/api/rest-api/account/update-margin-mode): This endpoint allows users to switch between isolated and cross margin modes for a specific trading pair. For open positions, users cannot change the margin mode.
* [Get positions](/api-documentation/api/rest-api/account/get-positions): This endpoint allows users to get current positions.
* [Get trade history](/api-documentation/api/rest-api/account/get-trade-history): This endpoint allows users to get trade history
* [Get funding history](/api-documentation/api/rest-api/account/get-funding-history): This endpoint allows users to get funding history.
* [Get account equity history](/api-documentation/api/rest-api/account/get-account-equity-history): This endpoint allows users to get account equity and PnL history (over time).
* [Get account balance history](/api-documentation/api/rest-api/account/get-account-balance-history): This endpoint allows users to get account balance history. Returns all balance effects that affect the queried account.
* [Request withdrawal](/api-documentation/api/rest-api/account/request-withdrawal): This endpoint allows users to request withdrawal.
* [Get account loan info](/api-documentation/api/rest-api/account/get-account-loan-info): This endpoint returns loan and collateral information for a given account under unified margin.
* [Add isolated margin](/api-documentation/api/rest-api/account/add-isolated-margin): This endpoint allows users to add margin to an isolated position.
* [Update spot settings](/api-documentation/api/rest-api/account/update-spot-settings): This endpoint allows users to update spot asset settings for unified margin.
* [Toggle auto-lending](/api-documentation/api/rest-api/account/toggle-auto-lending): This endpoint allows users to enable or disable automatic lending.
* [Get spot balance history](/api-documentation/api/rest-api/account/get-spot-balance-history): This endpoint allows users to get spot asset balance history.
* [Withdraw spot asset](/api-documentation/api/rest-api/account/withdraw-spot-asset): This endpoint allows users to withdraw a spot asset.
* [Get pending spot withdrawals](/api-documentation/api/rest-api/account/get-pending-spot-withdrawals): This endpoint returns pending spot asset withdrawals.
* [Get spot deposit history](/api-documentation/api/rest-api/account/get-spot-deposit-history): This endpoint returns spot asset deposit history.
* [Get spot withdrawal history](/api-documentation/api/rest-api/account/get-spot-withdrawal-history): This endpoint returns spot asset withdrawal history.
# Add Isolated Margin
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/account/add-isolated-margin
This endpoint allows users to add margin to an isolated position.
```http theme={null}
POST /api/v1/positions/add_isolated_margin
```
The operation type for signing is `"add_isolated_margin"`.
Transfers USDC from free balance into the isolated margin pool for the specified position.
#### Request Body
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | User's wallet address | `42trU9A5...` |
| `"signature"` | string | required | Cryptographic signature | `5J3mBbAH...` |
| `"timestamp"` | integer | required | Current timestamp in milliseconds | `1716200000000` |
| `"symbol"` | string | required | Trading pair symbol | `BTC` |
| `"amount"` | string | required | Amount of USDC to add as margin | `100.000000` |
| `"agent_wallet"` | string | optional | Agent wallet address | `8zFqj1Kp...` |
| `"expiry_window"` | integer | optional | Signature expiry in milliseconds | `10000` |
#### Response
* Status 200: Successfully added isolated margin
```json theme={null}
{
"success": true
}
```
* Status 400: Invalid request parameters
* Status 401: Unauthorized access
* Status 500: Internal server error
#### Code Example (Python)
```python theme={null}
import requests
payload = {
"account": "42trU9A5...",
"signature": "5J3mBbAH...",
"timestamp": 1716200000000,
"symbol": "BTC",
"amount": "100.000000",
}
response = requests.post(
"/api/v1/positions/add_isolated_margin",
json=payload,
headers={"Accept": "*/*"},
)
data = response.json()
```
# Get Account Balance History
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/account/get-account-balance-history
This endpoint allows users to get account balance history. Returns all balance effects that affect the queried account.
```http theme={null}
GET /api/v1/account/balance/history
```
#### Query Parameters
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | User's wallet address | `42trU9A5...` |
| `"limit"` | integer | optional | Maximum number of records to return, defaults to system defined limit | `100` |
| `"cursor"` | string | optional | Cursor pagination to access records. Default to none | `1115hVka` |
| `"include_trades"` | boolean | optional | If true, includes trade events. By default only shows deposit, withdraw, subaccount transfer, and payout events | `false` |
```http theme={null}
/api/v1/account/balance/history?account=42trU9A5...
```
#### Response
* Status 200: Successfully retrieved balance history
```json theme={null}
{
"success": true,
"data": [
{
"amount": "100.000000",
"balance": "1200.000000",
"pending_balance": "0.000000",
"event_type": "deposit",
"created_at": 1716200000000
}
...
],
"next_cursor": "11114Lz77",
"has_more": true
}
```
| Field | Type | Description |
| - | - | - |
| `'amount'` | decimal string | Amount change to balance after event |
| `'balance'` | decimal string | Account balance after event |
| `'pending_balance'` | decimal string | Pending balance after event |
| `'event_type'` | string | Type of balance event (see below) |
| `'created_at'` | integer | Timestamp in milliseconds of when the balance event occurred |
| `'next_cursor'` | string | Next cursor for pagination |
| `'has_more'` | boolean | True if there exists a `'next_cursor'` |
| Event Type (String) | Description |
| - | - |
| `'deposit'` | Deposit funds to account |
| `'deposit_release'` | Release of previously pending deposit |
| `'withdraw'` | Withdrawal of funds from account |
| `'trade'` | Trading activity (fees, realized PnL) |
| `'market_liquidation'` | Liquidation by market orders |
| `'backstop_liquidation'` | Liquidation by backstop liquidator |
| `'adl_liquidation'` | Liquidation by auto-deleveraging |
| `'subaccount_transfer'` | Transfer between subaccounts |
| `'funding'` | Funding payment |
| `'payout'` | Payout event (from e.g. affiliate program) |
* Status 400: Invalid request parameters
* Status 401: Unauthorized access
* Status 500: Internal server error
#### Code Example (Python)
```python theme={null}
import requests
response = requests.get(
"/api/v1/portfolio?account/balance/history?account=42trU9A5..."
headers={"Accept": "*/*"},
)
data = response.json()
```
# Get Account Equity History
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/account/get-account-equity-history
This endpoint allows users to get account equity and PnL history (over time).
```http theme={null}
GET /api/v1/portfolio
```
#### Query Parameters
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | User's wallet address | `42trU9A5...` |
| `"time_range"` | string | required | Time range of history: `1d`, `7d`, `14d`, `30d`, `all` | `7d` |
| `"start_time"` | integer | optional | Start time in milliseconds | `1760271000000` |
| `"end_time"` | integer | optional | End time in milliseconds | `1761842220000` |
| `"limit"` | integer | optional | Maximum number of records to return, defaults to 100 | `100` |
| `"cursor"` | string | optional | Cursor pagination to access records. Default to none | `1115hVka` |
```http theme={null}
/api/v1/portfolio?account=42trU9A5...&time_range=7d
```
#### Response
* Status 200: Successfully retrieved portfolio history
```json theme={null}
{
"success": true,
"data": [
{
"account_equity": "61046.308885",
"pnl": "9297.553505",
"timestamp": 1761177600000
},
...
],
"error": null,
"code": null
}
```
| Field | Type | Description |
| - | - | - |
| `'account_equity'` | decimal string | Account equity (balance + unrealized PnL) at last update |
| `'PnL'` | decimal string | PnL of account since creation |
| `'timestamp'` | integer | Timestamp in milliseconds of last account equity update |
* Status 400: Invalid request parameters
* Status 401: Unauthorized access
* Status 500: Internal server error
#### Code Example (Python)
```python theme={null}
import requests
response = requests.get(
"/api/v1/portfolio?account=42trU9A5...&time_range=7d",
headers={"Accept": "*/*"},
)
data = response.json()
```
# Get Account Info
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/account/get-account-info
This endpoint allows users to get all high-level account info such as balance, fee level, equity, etc.
```http theme={null}
GET /api/v1/account
```
#### Query Parameters
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | Account address | `42trU9A5...` |
| `"full"` | boolean | no | Adds `print_order_equity` and `total_account_equity`. Defaults to `false` | `true` |
```http theme={null}
/api/v1/account?account=42trU9A5...
```
#### Response
* Status 200: Successfully retrieved account information
```json theme={null}
{
"success": true,
"data": {
"balance": "2000.000000",
"fee_level": 0,
"maker_fee": "0.00015",
"taker_fee": "0.0004",
"account_equity": "2150.250000",
"available_to_spend": "1800.750000",
"available_to_withdraw": "1500.850000",
"pending_balance": "0.000000",
"pending_interest": "0.000000",
"spot_collateral": "0.000000",
"cross_account_equity": "2100.500000",
"spot_market_value": "250.000000",
"total_margin_used": "349.500000",
"cross_mmr": "420.690000",
"positions_count": 2,
"orders_count": 3,
"stop_orders_count": 1,
"updated_at": 1716200000000,
"spot_balances": [
{
"symbol": "SOL",
"amount": "1.50000000",
"available_to_withdraw": "1.00000000",
"pending_balance": "0.50000000",
"daily_withdraw_amount_usd": "250.000000",
"effective_daily_deposit_limit_usd": "50000.000000",
"effective_daily_withdraw_limit_usd": "250000.000000"
}
]
},
"error": null,
"code": null
}
```
| Field | Type | Description |
| - | - | - |
| `'balance'` | decimal string | Current account balance, defined as amount of USD in account before settlement |
| `'fee_level'` | integer | Current fee tier of account, determined by trading volume |
| `'maker_fee'` | decimal string | Current maker fee rate of account, determined by trading volume |
| `'taker_fee'` | decimal string | Current taker fee rate of account, determined by trading volume |
| `'account_equity'` | decimal string | Account balance + unrealized PnL + isolated margin + raw spot market value |
| `'available_to_spend'` | decimal string | Amount of account equity that is available to be used to margin for open positions and orders |
| `'available_to_withdraw'` | decimal string | Amount that is available to withdraw out from the exchange |
| `'pending_balance'` | decimal string | Amount of account balance in pending status (deposit request is successful, waiting on confirmation) |
| `'total_margin_used'` | decimal string | Amount of account equity currently being used to margin for open positions and orders |
| `'cross_mmr'` | decimal string | The maintenance margin required under the cross mode |
| `'positions_count'` | integer | Number of open positions (isolated and cross) |
| `'orders_count'` | integer | Number of open orders across all markets (excludes stop orders) |
| `'stop_orders_count'` | integer | Number of open stop orders across markets |
| `'pending_interest'` | decimal string | Accrued loan interest not yet repaid |
| `'spot_collateral'` | decimal string | Total USD value of spot assets used as collateral for unified margin |
| `'cross_account_equity'` | decimal string or null | Cross-margin equity after applying unified-margin collateral rules. `null` if not applicable |
| `'spot_market_value'` | decimal string | Raw marked-to-market value of positive spot balances before collateral haircuts |
| `'print_order_equity'` | decimal string | Equity locked in open [Print](/print) orders. Only with `full=true` |
| `'total_account_equity'` | decimal string | `account_equity` plus `print_order_equity`. Only with `full=true` |
| `'spot_balances'` | array | List of spot asset balances held by the account (see below) |
| `'updated_at'` | integer | Timestamp in milliseconds of last account info update |
**Spot Balance Fields**
| Field | Type | Description |
| - | - | - |
| `'symbol'` | string | Spot asset symbol |
| `'amount'` | decimal string | Total amount of the spot asset held |
| `'available_to_withdraw'` | decimal string | Amount available to withdraw |
| `'pending_balance'` | decimal string | Amount pending confirmation |
| `'daily_withdraw_amount_usd'` | decimal string | USD value of withdrawals made today |
| `'effective_daily_deposit_limit_usd'` | decimal string | Daily deposit limit in USD |
| `'effective_daily_withdraw_limit_usd'` | decimal string | Daily withdrawal limit in USD |
* Status 400: Invalid request parameters
* Status 401: Unauthorized access
* Status 500: Internal server error
* Status 503: With `full=true`, the equity components are not available yet (`error_id`: `full_components_unavailable`)
#### Code Example (Python)
```python theme={null}
import requests
response = requests.get(
"/api/v1/account?account=42trU9A5...",
headers={"Accept": "*/*"},
)
data = response.json()
```
# Get Account Loan Info
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/account/get-account-loan-info
This endpoint returns loan and collateral information for a given account under unified margin.
```http theme={null}
GET /api/v1/account/loan
```
#### Query Parameters
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | Account address | `42trU9A5...` |
```http theme={null}
/api/v1/account/loan?account=42trU9A5...
```
#### Response
* Status 200: Successfully retrieved account loan info
```json theme={null}
{
"success": true,
"data": {
"borrowed": "1250.500000",
"pending_interest": "3.250000",
"collateral_utilization": "0.45",
"total_interest_earned": "120.750000",
"total_interest_paid": "85.300000",
"spot_balances": [
{
"symbol": "SOL",
"amount": "10.00000000",
"ltv_ratio": "0.90",
"market_value": "1500.000000",
"collateral_value": "1350.000000"
}
],
"updated_at": 1716200000000
},
"error": null,
"code": null
}
```
| Field | Type | Description |
| - | - | - |
| `'borrowed'` | decimal string | Current borrowed amount in USD |
| `'pending_interest'` | decimal string | Accrued interest not yet repaid |
| `'collateral_utilization'` | decimal string | Ratio of borrowed amount to total spot collateral capacity |
| `'total_interest_earned'` | decimal string | Total interest earned as a lender (cumulative) |
| `'total_interest_paid'` | decimal string | Total interest paid as a borrower (cumulative, returned as positive) |
| `'spot_balances'` | array | Spot balances with their effective LTV and collateral contribution (see below) |
| `'updated_at'` | integer | Timestamp in milliseconds of last data update |
**Spot Balance Fields**
| Field | Type | Description |
| - | - | - |
| `'symbol'` | string | Spot asset symbol |
| `'amount'` | decimal string | Spot balance amount |
| `'ltv_ratio'` | decimal string | Effective LTV ratio used for loan collateral |
| `'market_value'` | decimal string | Raw marked-to-market USD value of this positive spot balance |
| `'collateral_value'` | decimal string | Effective collateral contribution of this asset after LTV/cap logic |
* Status 404: Account loan cache not found
* Status 500: Internal server error
#### Code Example (Python)
```python theme={null}
import requests
response = requests.get(
"/api/v1/account/loan",
params={"account": "42trU9A5..."},
headers={"Accept": "*/*"},
)
data = response.json()
```
# Get Account Settings
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/account/get-account-settings
This endpoint allows users to get account margin and leverage settings (if they are not at default values)
```http theme={null}
GET /api/v1/account/settings
```
#### Query Parameters
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | Account address | `42trU9A5...` |
```http theme={null}
/api/v1/account/settings?account=42trU9A5...
```
#### Response
NOTE: Upon account creation, all markets have margin settings default to cross margin and leverage default to max. When querying this endpoint, all markets with default margin and leverage settings on this account will return blank.
* Status 200: Successfully retrieved account settings
```json theme={null}
{
"success": true,
"data": {
"auto_lend_disabled": null,
"privacy_mode": "none",
"margin_settings": [
{
"symbol": "WLFI",
"isolated": false,
"leverage": 5,
"created_at": 1758085929703,
"updated_at": 1758086074002
}
],
"spot_settings": [
{
"symbol": "SOL",
"unified_margin_excluded": false
}
],
"error": null,
"code": null
}
}
```
| Field | Type | Description |
|---|
| `"auto_lend_disabled"` | boolean or null | Whether automatic lending is disabled for this account. `null` means default (enabled) |
| `"privacy_mode"` | string | Leaderboard privacy level: `"none"`, `"anonymous"` or `"hidden"`. Returns `"none"` if you have not set it. See [Update account settings](/api-documentation/api/rest-api/account/update-account-settings) |
| `"spot_settings"` | array | Per-asset spot settings for unified margin (see below) |
| `"symbol"` | string | Trading pair symbol |
| `"isolated"` | boolean | If the account is set to isolated margining for this symbol |
| `"leverage"` | integer | Current leverage set by the user (default to max) |
| `"created_at"` | integer | Timestamp in milliseconds when these settings were adjusted from their default |
| `"updated_at"` | integer | Timestamp in milliseconds when these settings were last updated |
**Spot Settings Fields**
| Field | Type | Description |
| - | - | - |
| `"symbol"` | string | Spot asset symbol |
| `"unified_margin_excluded"` | boolean | If `true`, this spot asset is excluded from unified margin collateral calculations |
* Status 400: Invalid request parameters
* Status 401: Unauthorized access
* Status 500: Internal server error
#### Code Example (Python)
```python theme={null}
import requests
response = requests.get(
"/api/v1/account/settings?account=42trU9A5...",
headers={"Accept": "*/*"},
)
data = response.json()
```
# Get Funding History
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/account/get-funding-history
This endpoint allows users to get funding history.
```http theme={null}
GET /api/v1/funding/history
```
#### Query Parameters
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | User's wallet address | `42trU9A5...` |
| `"limit"` | integer | optional | Maximum number of records to return default system defined limit | `100` |
| `"cursor"` | string | optional | Cursor pagination to access records. Default to none | `1115hVka` |
```http theme={null}
/api/v1/funding/history?account=42trU9A5...&limit=20&cursor=11115hVka
```
#### Response
* Status 200: Successfully retrieved funding history
```json theme={null}
{
"success": true,
"data": [
{
"history_id": 2287920,
"symbol": "PUMP",
"side": "ask",
"amount": "39033804",
"payout": "2.617479",
"rate": "0.0000125",
"created_at": 1759222804122
},
...
],
"next_cursor": "11114Lz77",
"has_more": true
}
```
| Field | Type | Description |
|---|
| `"history_id"` | integer | History id of trade |
| `"symbol"` | string | Trading pair symbol |
| `"side"` | string | If the position resulting in the funding payment was long or short (bid or ask) |
| `"amount"` | decimal string | Amount (in token denomination) of the position that resulted in the funding payment |
| `"payout"` | decimal string | Funding paid (in USD) |
| `"rate"` | decimal string | Funding rate that was used to calculate the payout |
| `"created_at"` | integer | Timestamp in milliseconds when the funding payment was logged |
| `'next_cursor'` | string | Next cursor for pagination |
| `'has_more'` | boolean | True if there exists a `'next_cursor'` |
* Status 400: Invalid request parameters
* Status 401: Unauthorized access
* Status 500: Internal server error
#### Code Example (Python)
```python theme={null}
import requests
response = requests.get(
"/api/v1/funding/history?account=42trU9A5...&limit=20&cursor=11115hVka",
headers={"Accept": "*/*"},
)
data = response.json()
```
# Get Pending Spot Withdrawals
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/account/get-pending-spot-withdrawals
This endpoint returns pending spot asset withdrawals.
```http theme={null}
GET /api/v1/account/spot_asset/withdraw/pending
```
#### Query Parameters
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | User's wallet address | `42trU9A5...` |
```http theme={null}
/api/v1/account/spot_asset/withdraw/pending?account=42trU9A5...
```
#### Response
* Status 200: Successfully retrieved pending spot withdrawals
```json theme={null}
{
"success": true,
"data": [
{
"symbol": "SOL",
"amount": "1.00000000",
"amount_requested": "1.00100000",
"fee_amount": "0.00100000",
"batch_nonce": 42,
"created_at": 1716200000000
}
...
]
}
```
| Field | Type | Description |
| - | - | - |
| `'symbol'` | string | Spot asset symbol |
| `'amount'` | decimal string | Net amount to be received after fees |
| `'amount_requested'` | decimal string | Original amount requested for withdrawal |
| `'fee_amount'` | decimal string | Fee deducted from the withdrawal |
| `'batch_nonce'` | integer | Nonce of the withdrawal batch |
| `'created_at'` | integer | Timestamp in milliseconds of when the withdrawal was created |
* Status 400: Invalid request parameters
* Status 401: Unauthorized access
* Status 500: Internal server error
#### Code Example (Python)
```python theme={null}
import requests
response = requests.get(
"/api/v1/account/spot_asset/withdraw/pending",
params={"account": "42trU9A5..."},
headers={"Accept": "*/*"},
)
data = response.json()
```
# Get Positions
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/account/get-positions
This endpoint allows users to get current positions.
```http theme={null}
GET /api/v1/positions
```
#### Query Parameters
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | Connected wallet address | `42trU9A5...` |
```http theme={null}
/api/v1/positions?account=42trU9A5...
```
#### Response
* Status 200: Successfully retrieved account information
```json theme={null}
{
"success": true,
"data": [
{
"symbol": "AAVE",
"side": "ask",
"amount": "223.72",
"entry_price": "279.283134",
"margin": "0", // only shown for isolated margin
"funding": "13.159593",
"isolated": false,
"liquidation_price": null,
"created_at": 1754928414996,
"updated_at": 1759223365538,
"li": 1557431179
}
],
"error": null,
"code": null,
"last_order_id": 1557431179
}
```
| Field | Type | Description |
|---|
| `"id"` | string | Position ID (UUID). A new ID starts each time the position opens from flat |
| `"symbol"` | string | Trading pair symbol |
| `"side"` | string | Position side: `bid` (long) or `ask` (short) |
| `"amount"` | decimal string | Position size in the asset's base unit |
| `"entry_price"` | decimal string | Entry price of the position. Takes VWAP if position was opened by multiple trades executed at different prices. |
| `"margin"` | decimal string | Amount of margin allocated to an isolated position (only shown when isolated) |
| `"funding"` | decimal string | Funding paid by this position since open |
| `"isolated"` | boolean | If the position is opened in isolated margin mode |
| `"liquidation_price"` | decimal string or null | Estimated liquidation price for the position. `null` if not applicable |
| `"realized_pnl"` | decimal string or null | Realized PnL since the position opened: close PnL, minus trading fees, plus funding. It already includes `funding`. `null` for a position opened before 2026-10-04 |
| `"created_at"` | integer | Timestamp in milliseconds when the position was opened |
| `"updated_at"` | integer | Timestamp in milliseconds when these settings were last updated |
| `"li"` | integer or null | [Last ID](/api-documentation/api/last-id) — sequence number for this `(account, symbol)` position. `null` if the engine has not touched the row yet. |
| `"last_order_id"` | integer | [Last ID](/api-documentation/api/last-id) — sequence number for the account's whole position set. Advances when a position closes. |
* Status 400: Invalid request parameters
* Status 401: Unauthorized access
* Status 500: Internal server error
#### Code Example (Python)
```python theme={null}
import requests
response = requests.get(
"/api/v1/positions?account=42trU9A5...",
headers={"Accept": "*/*"},
)
data = response.json()
```
# Get Spot Balance History
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/account/get-spot-balance-history
This endpoint allows users to get spot asset balance history.
```http theme={null}
GET /api/v1/account/spot_balance/history
```
#### Query Parameters
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | User's wallet address | `42trU9A5...` |
| `"symbol"` | string | optional | Filter by spot asset symbol | `SOL` |
| `"limit"` | integer | optional | Maximum number of records to return, defaults to system defined limit | `100` |
| `"cursor"` | string | optional | Cursor for pagination. Default to none | `1115hVka` |
```http theme={null}
/api/v1/account/spot_balance/history?account=42trU9A5...
```
#### Response
* Status 200: Successfully retrieved spot balance history
```json theme={null}
{
"success": true,
"data": [
{
"amount": "1.00000000",
"balance": "5.50000000",
"symbol": "SOL",
"event_type": "deposit",
"created_at": 1716200000000
}
...
],
"next_cursor": "11114Lz77",
"has_more": true
}
```
| Field | Type | Description |
| - | - | - |
| `'amount'` | decimal string | Amount change to balance after event |
| `'balance'` | decimal string | Balance after event |
| `'symbol'` | string | Spot asset symbol |
| `'event_type'` | string | Type of balance event |
| `'created_at'` | integer | Timestamp in milliseconds of when the event occurred |
| `'next_cursor'` | string | Next cursor for pagination |
| `'has_more'` | boolean | True if there exists a `'next_cursor'` |
* Status 400: Invalid request parameters
* Status 500: Internal server error
#### Code Example (Python)
```python theme={null}
import requests
response = requests.get(
"/api/v1/account/spot_balance/history",
params={"account": "42trU9A5..."},
headers={"Accept": "*/*"},
)
data = response.json()
```
# Get Spot Deposit History
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/account/get-spot-deposit-history
This endpoint returns spot asset deposit history.
```http theme={null}
GET /api/v1/account/spot_asset/deposit/history
```
#### Query Parameters
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | User's wallet address | `42trU9A5...` |
| `"limit"` | integer | optional | Maximum number of records to return, defaults to system defined limit | `100` |
| `"cursor"` | string | optional | Cursor for pagination. Default to none | `1115hVka` |
```http theme={null}
/api/v1/account/spot_asset/deposit/history?account=42trU9A5...
```
#### Response
* Status 200: Successfully retrieved spot deposit history
```json theme={null}
{
"success": true,
"data": [
{
"symbol": "SOL",
"amount": "1.50000000",
"transaction_id": "5xGk...",
"created_at": 1716200000000
}
...
],
"next_cursor": "11114Lz77",
"has_more": true
}
```
| Field | Type | Description |
| - | - | - |
| `'symbol'` | string | Spot asset symbol |
| `'amount'` | decimal string | Amount deposited |
| `'transaction_id'` | string | On-chain transaction identifier |
| `'created_at'` | integer | Timestamp in milliseconds of when the deposit occurred |
| `'next_cursor'` | string | Next cursor for pagination |
| `'has_more'` | boolean | True if there exists a `'next_cursor'` |
* Status 400: Invalid request parameters
* Status 401: Unauthorized access
* Status 500: Internal server error
#### Code Example (Python)
```python theme={null}
import requests
response = requests.get(
"/api/v1/account/spot_asset/deposit/history",
params={"account": "42trU9A5..."},
headers={"Accept": "*/*"},
)
data = response.json()
```
# Get Spot Withdrawal History
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/account/get-spot-withdrawal-history
This endpoint returns spot asset withdrawal history.
```http theme={null}
GET /api/v1/account/spot_asset/withdraw/history
```
#### Query Parameters
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | User's wallet address | `42trU9A5...` |
| `"limit"` | integer | optional | Maximum number of records to return, defaults to system defined limit | `100` |
| `"cursor"` | string | optional | Cursor for pagination. Default to none | `1115hVka` |
```http theme={null}
/api/v1/account/spot_asset/withdraw/history?account=42trU9A5...
```
#### Response
* Status 200: Successfully retrieved spot withdrawal history
```json theme={null}
{
"success": true,
"data": [
{
"symbol": "SOL",
"amount": "1.00000000",
"batch_nonce": 42,
"transaction_id": "5xGk...",
"created_at": 1716200000000
}
...
],
"next_cursor": "11114Lz77",
"has_more": true
}
```
| Field | Type | Description |
| - | - | - |
| `'symbol'` | string | Spot asset symbol |
| `'amount'` | decimal string | Amount withdrawn |
| `'batch_nonce'` | integer | Nonce of the withdrawal batch |
| `'transaction_id'` | string | On-chain transaction identifier |
| `'created_at'` | integer | Timestamp in milliseconds of when the withdrawal occurred |
| `'next_cursor'` | string | Next cursor for pagination |
| `'has_more'` | boolean | True if there exists a `'next_cursor'` |
* Status 400: Invalid request parameters
* Status 401: Unauthorized access
* Status 500: Internal server error
#### Code Example (Python)
```python theme={null}
import requests
response = requests.get(
"/api/v1/account/spot_asset/withdraw/history",
params={"account": "42trU9A5..."},
headers={"Accept": "*/*"},
)
data = response.json()
```
# Get Trade History
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/account/get-trade-history
This endpoint allows users to get trade history
```http theme={null}
GET /api/v1/trades/history
```
#### Query Parameters
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | optional | User's wallet address | `42trU9A5...` |
| `"symbol"` | string | optional | Market symbol to filter by | `BTC` |
| `"builder_code"` | string | optional | Only return trades with this builder code | `BUILDER1` |
| `"start_time"` | integer | optional | Start time in milliseconds | `1625097600000` |
| `"end_time"` | integer | optional | End time in milliseconds | `1759215599188` |
| `"limit"` | integer | optional | Maximum number of records to return, defaults to 100 | `100` |
| `"cursor"` | string | optional | Cursor pagination to access records. Default to none | `1115hVka` |
```http theme={null}
/api/v1/trades/history?account=42trU9A5...&start_time=1625097600000&end_time=1759215599188
```
#### Response
* Status 200: Successfully retrieved portfolio position history
```json theme={null}
{
"success": true,
"data": [
{
"history_id": 19329801,
"order_id": 315293920,
"client_order_id": "acf...",
"symbol": "LDO",
"amount": "0.1",
"price": "1.1904",
"entry_price": "1.176247",
"fee": "0",
"pnl": "-0.001415",
"event_type": "fulfill_maker",
"side": "close_short",
"created_at": 1759215599188,
"cause": "normal"
},
...
],
"next_cursor": "11111Z5RK",
"has_more": true
}
```
| Field | Type | Description |
|---|
| `"history_id"` | integer | History id of trade |
| `"order_id"` | integer | Order id of order that resulted in the trade |
| `"client_order_id"` | UUID | CLOID of order that resulted in the trade |
| `"symbol"` | string | Trading pair symbol |
| `"amount"` | decimal string | Amount (in token denomination) of the trade event |
| `"price"` | decimal string | Current price of the specified symbol |
| `"entry_price"` | decimal string | Price at which the trade event was executed |
| `"fee"` | decimal string | Fee paid by the trade event |
| `"spot_fee"` | decimal string or null | Native spot fee paid for this trade; only set for spot-buy fills |
| `"pnl"` | decimal string | PnL generated by the trade event |
| `"event_type"` | string | `"fulfill_taker"` if taker\
`"fulfill_maker"` if maker |
| `"side"` | string | `"open_long"`\
`"open_short"`\
`"close_long"`\
`"close_short"` |
| `"created_at"` | integer | Timestamp in milliseconds when the trade event occurred |
| `"cause"` | string | `"normal"`\
regular user-initiated trading\
`"market_liquidation"` position was liquidated due to insufficient margin\
`"backstop_liquidation"` position was liquidated by backstop mechanism\
`"settlement"`\
position was closed due to Auto-Deleveraging (ADL) or other settlement |
| `'next_cursor'` | string | Next cursor for pagination |
| `'has_more'` | boolean | True if there exists a `'next_cursor'` |
| Field | Type | Description |
| - | - | - |
| `'event_type'` | string | `"fulfill_taker"` if taker `"fulfill_maker"` if maker |
| `'side'` | string | `"open_long"` `"open_short"` `"close_long"` `"close_short"` |
| `'cause'` | string | `"normal"` regular user-initiated trading `"market_liquidation"` position was liquidated due to insufficient margin `"backstop_liquidation"` position was liquidated by backstop mechanism `"settlement"` position was closed due to Auto-Deleveraging (ADL) or other settlement |
* Status 400: Invalid request parameters
* Status 401: Unauthorized access
* Status 500: Internal server error
#### Code Example (Python)
```python theme={null}
import requests
response = requests.get(
"/api/v1/trades/history?account=42trU9A5...&symbol=BTC&limit=20&cursor=11115hVka",
headers={"Accept": "*/*"},
)
data = response.json()
```
# Request Withdrawal
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/account/request-withdrawal
This endpoint allows users to request withdrawal.
```http theme={null}
POST /api/v1/account/withdraw
```
#### Request Body
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | User's wallet address | `42trU9A5...` |
| `"signature"` | string | required | Cryptographic signature | `5j1Vy9Uq...` |
| `"timestamp"` | integer | required | Current timestamp in milliseconds | `1716200000000` |
| `"amount"` | string | required | Amount to withdraw in USDC | `100.50` |
| `"idempotency_key"` | string | optional | Full UUID string. Prevents duplicate withdrawals. Required when the account has two-factor authentication on | `550e8400-e29b-41d4-a716-446655440000` |
| `"agent_wallet"` | string | optional | Agent wallet address | `69trU9A5...` |
| `"expiry_window"` | integer | optional | Signature expiry in milliseconds | `30000` |
| `"two_factor"` | object | conditional | Two-factor proof. Required when the account has two-factor authentication on. Not part of the signed payload. See below | `{"type": "totp", "code": "123456"}` |
```json theme={null}
{
"account": "42trU9A5...",
"signature": "5j1Vy9Uq...",
"timestamp": 1716200000000,
"amount": "100.50",
"agent_wallet": "69trU9A5...",
"expiry_window": 30000
}
```
#### Two-factor authentication
If the account's owner has turned on two-factor authentication, every withdrawal needs a proof, including withdrawals that an agent wallet signs.
To turn it on or manage factors, see [Two-factor authentication](/api-documentation/api/rest-api/two-factor).
* Send an `idempotency_key`. A retry with the same key and the same request returns the first result, so a retry does not need a new code.
* Send the proof in `two_factor`, outside the signed `data`. For an authenticator app, use `{"type": "totp", "code": "123456"}`. Recovery keys do not authorize withdrawals.
| Status | Meaning |
| - | - |
| `428` | Proof required: send `two_factor` |
| `401` | Proof is wrong, expired, or already used |
| `429` | Too many proof attempts. Each signer gets 5 attempts per 5 minutes |
| `400` | `idempotency_key` is missing |
| `409` | The `idempotency_key` was used for a different request |
| `422` | The proof can't be used here, for example a recovery key |
| `503` | Two-factor checks are unavailable. Retry later |
#### Response
* Status 200: Success
```json theme={null}
{
"success": true,
"data": {
"batch_nonce": 42,
"requested_amount": "100.500000",
"fee_amount": "1.000000"
}
}
```
| Field | Type | Description |
| - | - | - |
| `'batch_nonce'` | integer | Nonce of the withdrawal batch |
| `'requested_amount'` | decimal string | Amount requested for withdrawal |
| `'fee_amount'` | decimal string | Fee deducted from the withdrawal |
* Status 400: Invalid request parameters
* Status 409: `idempotency_key` already used for a different request. A retry of the same request returns the first result
* Status 500: Internal server error
#### Code Example (Python)
```python theme={null}
import requests
payload = {
"account": "42trU9A5...",
"signature": "5j1Vy9Uq...",
"timestamp": 1716200000000,
"amount": "100.50"
}
response = requests.post(
"/api/v1/account/withdraw",
json=payload,
headers={"Content-Type": "application/json"}
)
data = response.json()
```
# Toggle Auto-Lending
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/account/toggle-auto-lending
This endpoint allows users to enable or disable automatic lending.
```http theme={null}
POST /api/v1/account/settings/auto_lend_disabled
```
The operation type for signing is `"set_auto_lend_disabled"`.
#### Request Body
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | User's wallet address | `42trU9A5...` |
| `"signature"` | string | required | Cryptographic signature | `5J3mBbAH...` |
| `"timestamp"` | integer | required | Current timestamp in milliseconds | `1716200000000` |
| `"disabled"` | boolean or null | optional | Set to `true` to disable auto-lending, `false` to enable, or `null` to clear (return to default) | `true` |
| `"agent_wallet"` | string | optional | Agent wallet address | `8zFqj1Kp...` |
| `"expiry_window"` | integer | optional | Signature expiry in milliseconds | `10000` |
#### Response
* Status 200: Successfully updated auto-lending setting
```json theme={null}
{
"success": true
}
```
* Status 400: Invalid request parameters
* Status 401: Unauthorized access
* Status 500: Internal server error
#### Code Example (Python)
```python theme={null}
import requests
# Disable auto-lending
payload = {
"account": "42trU9A5...",
"signature": "5J3mBbAH...",
"timestamp": 1716200000000,
"disabled": True,
}
response = requests.post(
"/api/v1/account/settings/auto_lend_disabled",
json=payload,
headers={"Accept": "*/*"},
)
data = response.json()
```
# Update Account Settings
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/account/update-account-settings
This endpoint allows users to update account settings, such as their leaderboard privacy mode.
```http theme={null}
POST /api/v1/account/settings
```
#### Operation Type (for Signing)
| Header Field | Type | Content |
| - | - | - |
| `"type"` | string | `"update_account_settings"` |
#### Request Body
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | User's wallet address | `42trU9A5...` |
| `"privacy_mode"` | string | required | Leaderboard privacy level:\
`"none"`\
`"anonymous"`\
`"hidden"` | `hidden` |
| `"timestamp"` | integer | required | Current timestamp in milliseconds | `1716200000000` |
| `"expiry_window"` | integer | optional | Signature expiry in milliseconds | `30000` |
| `"agent_wallet"` | string | optional | Agent wallet address | `69trU9A5...` |
| `"signature"` | string | required | Cryptographic signature | `5j1Vy9Uq...` |
```json theme={null}
{
"account": "42trU9A5...",
"privacy_mode": "hidden",
"timestamp": 1716200000000,
"expiry_window": 30000,
"agent_wallet": "69trU9A5...",
"signature": "5j1Vy9UqY..."
}
```
This endpoint changes only the settings that you send. Settings that you leave out keep their current value. The request must contain at least one setting. `privacy_mode` is currently the only setting, so you must send it.
You can sign this request with the account key or with an [agent wallet](/api-documentation/api/signing/api-agent-keys).
**Privacy Modes**
| Value | Leaderboard | Portfolio |
| - | - | - |
| `"none"` | Your row is listed. This is the default. | Public |
| `"anonymous"` | Your row is listed with `privacy_mode: true`. | Private |
| `"hidden"` | Your row is removed from the leaderboard and contest leaderboard responses. | Private |
To read the current value, call [Get account settings](/api-documentation/api/rest-api/account/get-account-settings).
#### Response
* Status 200: Account settings updated successfully
```json theme={null}
{
"success": true,
"data": null,
"error": null,
"code": null
}
```
* Status 400: Invalid request parameters or signature. A request without a setting returns this error:
```json theme={null}
{
"success": false,
"data": null,
"error": "At least one setting must be provided",
"code": 400,
"error_id": "unspecified"
}
```
* Status 500: Internal server error
#### Code Example (Python)
```python theme={null}
import requests
payload = {
"account": "42trU9A5...",
"signature": "5j1Vy9Uq...",
"timestamp": 1716200000000,
"privacy_mode": "hidden"
}
response = requests.post(
"/api/v1/account/settings",
json=payload,
headers={"Content-Type": "application/json"}
)
data = response.json()
```
# Update Leverage
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/account/update-leverage
This endpoint allows users to change their account leverage for a specific trading pair. For open positions, users can only increase the leverage setting.
```http theme={null}
POST /api/v1/account/leverage
```
#### Operation Type (for Signing)
| Header Field | Type | Content |
| - | - | - |
| `"type"` | string | `"update_leverage"` |
Request Body
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | User's wallet address | `42trU9A5...` |
| `"symbol"` | string | required | Trading pair symbol | `BTC` |
| `"leverage"` | integer | required | New leverage value | `10` |
| `"timestamp"` | integer | required | Current timestamp in milliseconds | `1716200000000` |
| `"expiry_window"` | integer | optional | Signature expiry in milliseconds | `30000` |
| `"agent_wallet"` | string | optional | Agent wallet address | `69trU9A5...` |
| `"signature"` | string | required | Cryptographic signature | `5j1Vy9Uq...` |
```json theme={null}
{
"account": "42trU9A5...",
"symbol": "BTC",
"leverage": 10,
"timestamp": 1716200000000,
"expiry_window": 30000,
"agent_wallet": "69trU9A5...",
"signature": "5j1Vy9UqY..."
}
```
#### Response
* Status 200: Leverage updated successfully
```json theme={null}
{
"success": true
}
```
* Status 400: Invalid request parameters
```json theme={null}
{
"error": "Invalid leverage",
"code": 400
}
```
* Status 500: Internal server error
#### Code Example (Python)
```python theme={null}
import requests
payload = {
"account": "42trU9A5...",
"signature": "5j1Vy9Uq...",
"timestamp": 1716200000000,
"symbol": "BTC",
"leverage": 10
}
response = requests.post(
"/api/v1/account/leverage",
json=payload,
headers={"Content-Type": "application/json"}
)
data = response.json()
```
# Update Margin Mode
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/account/update-margin-mode
This endpoint allows users to switch between isolated and cross margin modes for a specific trading pair. For open positions, users cannot change the margin mode.
```http theme={null}
POST /api/v1/account/margin
```
#### Operation Type (for Signing)
| Header Field | Type | Content |
| - | - | - |
| "type" | string | `"update_margin_mode"` |
#### Request Body
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | User's wallet address | `42trU9A5...` |
| `"symbol"` | string | required | Trading pair symbol | `BTC` |
| `"is_isolated"` | boolean | required | Margin mode (true for isolated, false for cross) | `false` |
| `"timestamp"` | integer | required | Current timestamp in milliseconds | `1716200000000` |
| `"expiry_window"` | integer | optional | Signature expiry in milliseconds | `30000` |
| `"agent_wallet"` | string | optional | Agent wallet address | `69trU9A5...` |
| `"signature"` | string | required | Cryptographic signature | `5j1Vy9Uq...` |
```json theme={null}
{
"account": "42trU9A5...",
"symbol": "BTC",
"is_isolated": false,
"timestamp": 1716200000000,
"expiry_window": 30000,
"agent_wallet": "69trU9A5...",
"signature": "5j1Vy9Uq..."
}
```
#### Response
* Status 200: Margin mode updated successfully
```json theme={null}
{
"success": true
}
```
* Status 400: Invalid request parameters
```json theme={null}
{
"error": "Invalid margin mode",
"code": 400
}
```
* Status 500: Internal server error
#### Code Example (Python)
```python theme={null}
import requests
payload = {
"account": "42trU9A5...",
"signature": "5j1Vy9Uq",
"timestamp": 1716200000000,
"symbol": "BTC",
"is_isolated": false
}
response = requests.post(
"/api/v1/account/margin",
json=payload,
headers={"Content-Type": "application/json"}
)
data = response.json()
```
# Update Spot Settings
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/account/update-spot-settings
This endpoint allows users to update spot asset settings for unified margin.
```http theme={null}
POST /api/v1/account/settings/spot
```
The operation type for signing is `"update_account_spot_settings"`.
#### Request Body
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | User's wallet address | `42trU9A5...` |
| `"signature"` | string | required | Cryptographic signature | `5J3mBbAH...` |
| `"timestamp"` | integer | required | Current timestamp in milliseconds | `1716200000000` |
| `"symbol"` | string | required | Spot asset symbol | `SOL` |
| `"unified_margin_excluded"` | boolean | required | Whether to exclude this asset from unified margin collateral | `true` |
| `"agent_wallet"` | string | optional | Agent wallet address | `8zFqj1Kp...` |
| `"expiry_window"` | integer | optional | Signature expiry in milliseconds | `10000` |
#### Response
* Status 200: Successfully updated spot settings
```json theme={null}
{
"success": true
}
```
* Status 400: Invalid request parameters
* Status 401: Unauthorized access
* Status 500: Internal server error
#### Code Example (Python)
```python theme={null}
import requests
payload = {
"account": "42trU9A5...",
"signature": "5J3mBbAH...",
"timestamp": 1716200000000,
"symbol": "SOL",
"unified_margin_excluded": True,
}
response = requests.post(
"/api/v1/account/settings/spot",
json=payload,
headers={"Accept": "*/*"},
)
data = response.json()
```
# Withdraw Spot Asset
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/account/withdraw-spot-asset
This endpoint allows users to withdraw a spot asset.
```http theme={null}
POST /api/v1/account/spot_asset/withdraw
```
The operation type for signing is `"withdraw_spot_asset"`.
#### Request Body
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | User's wallet address | `42trU9A5...` |
| `"signature"` | string | required | Cryptographic signature | `5J3mBbAH...` |
| `"timestamp"` | integer | required | Current timestamp in milliseconds | `1716200000000` |
| `"symbol"` | string | required | Spot asset symbol | `SOL` |
| `"amount"` | string | required | Amount to withdraw | `1.00000000` |
| `"idempotency_key"` | string | optional | Full UUID string. Prevents duplicate withdrawals. Required when the account has two-factor authentication on | `550e8400-e29b-41d4-a716-446655440000` |
| `"agent_wallet"` | string | optional | Agent wallet address | `8zFqj1Kp...` |
| `"expiry_window"` | integer | optional | Signature expiry in milliseconds | `10000` |
| `"two_factor"` | object | conditional | Two-factor proof. Required when the account has two-factor authentication on. Not part of the signed payload. See below | `{"type": "totp", "code": "123456"}` |
#### Two-factor authentication
If the account's owner has turned on two-factor authentication, every withdrawal needs a proof, including withdrawals that an agent wallet signs.
To turn it on or manage factors, see [Two-factor authentication](/api-documentation/api/rest-api/two-factor).
* Send an `idempotency_key`. A retry with the same key and the same request returns the first result, so a retry does not need a new code.
* Send the proof in `two_factor`, outside the signed `data`. For an authenticator app, use `{"type": "totp", "code": "123456"}`. Recovery keys do not authorize withdrawals.
| Status | Meaning |
| - | - |
| `428` | Proof required: send `two_factor` |
| `401` | Proof is wrong, expired, or already used |
| `429` | Too many proof attempts. Each signer gets 5 attempts per 5 minutes |
| `400` | `idempotency_key` is missing |
| `409` | The `idempotency_key` was used for a different request |
| `422` | The proof can't be used here, for example a recovery key |
| `503` | Two-factor checks are unavailable. Retry later |
#### Response
* Status 200: Successfully submitted withdrawal
```json theme={null}
{
"success": true,
"data": {
"symbol": "SOL",
"batch_nonce": 42,
"requested_amount": "1.00000000",
"fee_amount": "0.00100000"
}
}
```
| Field | Type | Description |
| - | - | - |
| `'symbol'` | string | Spot asset symbol |
| `'batch_nonce'` | integer | Nonce of the withdrawal batch |
| `'requested_amount'` | decimal string | Amount requested for withdrawal |
| `'fee_amount'` | decimal string | Fee deducted from the withdrawal |
* Status 400: Invalid request parameters
* Status 401: Unauthorized access
* Status 409: `idempotency_key` already used for a different request. A retry of the same request returns the first result
* Status 500: Internal server error
#### Code Example (Python)
```python theme={null}
import requests
payload = {
"account": "42trU9A5...",
"signature": "5J3mBbAH...",
"timestamp": 1716200000000,
"symbol": "SOL",
"amount": "1.00000000",
}
response = requests.post(
"/api/v1/account/spot_asset/withdraw",
json=payload,
headers={"Accept": "*/*"},
)
data = response.json()
```
# Markets
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/markets
This section covers details for interacting with all perpetual futures markets listed on Pacifica.
* [Get market info](/api-documentation/api/rest-api/markets/get-market-info): This endpoint allows users to get exchange information, including market specifications for all available trading pairs.
* [Get prices](/api-documentation/api/rest-api/markets/get-prices): This endpoint allows users to get price information for all symbols, including mark prices, funding rates, and market statistics.
* [Get candle data](/api-documentation/api/rest-api/markets/get-candle-data): This endpoint allows users to get historical price candles for a specific market and time interval.
* [Get mark price candle data](/api-documentation/api/rest-api/markets/get-mark-price-candle-data): This endpoint allows users to get historical mark price candles for a specific market and time interval.
* [Get orderbook](/api-documentation/api/rest-api/markets/get-orderbook): This endpoint allows users to retrieve the current orderbook (bid/ask levels) for a specified trading symbol.
* [Get recent trades](/api-documentation/api/rest-api/markets/get-recent-trades): This endpoint allows users to get recent trades for a specific market.
* [Get historical funding](/api-documentation/api/rest-api/markets/get-historical-funding): This endpoint retrieves the historical funding for a particular symbol
* [Get fee levels](/api-documentation/api/rest-api/markets/get-fee-levels): This endpoint returns all fee level tiers and their corresponding maker and taker fee rates.
* [Get loan pool](/api-documentation/api/rest-api/markets/get-loan-pool): This endpoint returns the current state of the loan pool including utilization, borrow and lend rates.
# Get Candle Data
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/markets/get-candle-data
This endpoint allows users to get historical price candles for a specific market and time interval.
```http theme={null}
/api/v1/kline
```
#### Query Parameters
| Field | Type | Need | Description | Example |
|---|
| `"symbol"` | string | required | Trading pair symbol | `BTC` |
| `"interval"` | string | required | Candlestick interval\
Valid values: 1m, 3m, 5m, 15m, 30m, 1h, 2h, 4h, 8h, 12h, 1d, 1w, 1M | `1m` |
| `"start_time"` | integer | required | Start time in milliseconds | `1716200000000` |
| `"end_time"` | integer | optional | End time in milliseconds, defaults to current time if not provided | `1742243220000` |
| `"limit"` | integer | optional | Maximum number of candles to return. Capped at 4000; defaults to 4000 if not provided | `100` |
```http theme={null}
/api/v1/kline?symbol=BTC&interval=1m&start_time=1742243160000&end_time=1742243220000
```
#### Response
* Status 200: Successfully retrieved candle data
```json theme={null}
{
"success": true,
"data": [
{
"t": 1748954160000,
"T": 1748954220000,
"s": "BTC",
"i": "1m",
"o": "105376",
"c": "105376",
"h": "105376",
"l": "105376",
"v": "0.00022",
"n": 2
}
],
"error": null,
"code": null
}
```
| Field | Type | Description |
| - | - | - |
| `'t'` | number | Candle start time |
| `'T'` | number | Candle end time |
| `'s'` | string | Symbol |
| `'i'` | string | Time interval of candles |
| `'o'` | decimal string | Open price |
| `'c'` | decimal string | Close price |
| `'h'` | decimal string | High price |
| `'l'` | decimal string | Low price |
| `'v'` | decimal string | Volume |
| `'n'` | number | Number of trades on Pacifica for specified symbol |
* Status 400: Invalid request parameters
* Status 401: Unauthorized access
* Status 500: Internal server error
#### Code Example (Python)
```python theme={null}
import requests
response = requests.get(
"/api/v1/kline?symbol=BTC&interval=1m&start_time=1742243160000&end_time=1742243220000",
headers={"Accept": "*/*"},
)
data = response.json()
```
# Get Fee Levels
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/markets/get-fee-levels
This endpoint returns all fee level tiers and their corresponding maker and taker fee rates.
```http theme={null}
GET /api/v1/info/fees
```
#### Response
* Status 200: Success
```json theme={null}
{
"success": true,
"data": [
{
"level": 0,
"maker_fee_rate": "0.00020",
"taker_fee_rate": "0.00050"
},
{
"level": 1,
"maker_fee_rate": "0.00015",
"taker_fee_rate": "0.00040"
}
],
"error": null,
"code": null
}
```
| Field | Type | Description |
|---|
| `"level"` | integer | Fee tier level |
| `"maker_fee_rate"` | decimal string | Maker fee rate for this tier |
| `"taker_fee_rate"` | decimal string | Taker fee rate for this tier |
* Status 500: Internal server error
#### Code Example (Python)
```python theme={null}
import requests
response = requests.get(
"/api/v1/info/fees",
headers={"Accept": "*/*"},
)
data = response.json()
```
# Get Historical Funding
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/markets/get-historical-funding
This endpoint retrieves the historical funding for a particular symbol
```http theme={null}
GET /api/v1/funding_rate/history
```
#### Query Parameters
| Field | Type | Need | Description | Example |
|---|
| `"symbol"` | string | required | Market symbol to query | `BTC` |
| `"limit"` | integer | optional | Number of records to show (default 200, max 4000) | `20` |
| `"cursor"` | string | optional | Cursor pagination to access records. Default to none | `1115hVka` |
```http theme={null}
/api/v1/funding_rate/history?symbol=BTC&limit=20&cursor=11115hVka
```
#### Response
* Status 200: Successfully retrieved funding history
```json theme={null}
{
"success": true,
"data": [
{
"oracle_price": "117170.410304",
"bid_impact_price": "117126",
"ask_impact_price": "117142",
"funding_rate": "0.0000125",
"next_funding_rate": "0.0000125",
"created_at": 1753806934249
},
...
],
"next_cursor": "11114Lz77",
"has_more": true
}
```
| Field | Type | Description |
| - | - | - |
| `'oracle_price'` | decimal string | Oracle price used for [funding rate calculation](/trading-on-pacifica/funding-rates) |
| `'bid_impact_price'` | decimal string | Bid impact price at time of calculation (see funding rate docs) |
| `'ask_impact_price'` | decimal string | Ask impact price at time of calculation (see funding rate docs) |
| `'funding_rate'` | decimal string | Last settled funding rate |
| `'next_funding_rate'` | decimal string | Predicted funding rate for next settlement |
| `'created_at'` | integer | Timestamp in milliseconds |
| `'next_cursor'` | string | Next cursor for pagination |
| `'has_more'` | boolean | True if there exists a `'next_cursor'` |
* Status 400: Invalid request parameters
* Status 401: Unauthorized access
* Status 500: Internal server error
#### Code Example (Python)
```python theme={null}
import requests
response = requests.get(
"/api/v1/funding_rate/history?symbol=BTC",
headers={"Accept": "*/*"},
)
data = response.json()
```
# Get Loan Pool
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/markets/get-loan-pool
This endpoint returns the current state of the loan pool including utilization, borrow and lend rates.
```http theme={null}
GET /api/v1/loan_pool
```
#### Response
* Status 200: Success
```json theme={null}
{
"success": true,
"data": {
"total_borrowed": "500000.000000",
"total_borrowable": "2000000.000000",
"utilization": "0.25",
"borrow_rate_apr": "0.08",
"borrow_rate_apy": "0.0833",
"lend_rate_apr": "0.06",
"lend_rate_apy": "0.0618",
"utilization_max": "0.85",
"auto_lender_entry_threshold": "1000.000000",
"last_interest_accrual_at": 1716200000000,
"last_interest_payout_at": 1716200000000,
"updated_at": 1716200000000
},
"error": null,
"code": null
}
```
| Field | Type | Description |
|---|
| `"total_borrowed"` | decimal string | Total amount currently borrowed from the pool |
| `"total_borrowable"` | decimal string | Total amount available to borrow |
| `"utilization"` | decimal string | Pool utilization ratio (borrowed / total) |
| `"borrow_rate_apr"` | decimal string | Current annualized borrow rate |
| `"borrow_rate_apy"` | decimal string | Current compounded annual borrow rate |
| `"lend_rate_apr"` | decimal string | Current annualized lending rate |
| `"lend_rate_apy"` | decimal string | Current compounded annual lending rate |
| `"utilization_max"` | decimal string | Maximum utilization cap for the pool |
| `"auto_lender_entry_threshold"` | decimal string | Minimum balance threshold to be included in auto-lending |
| `"last_interest_accrual_at"` | integer or null | Timestamp of last interest accrual (ms). `null` if never accrued |
| `"last_interest_payout_at"` | integer or null | Timestamp of last interest payout (ms). `null` if never paid out |
| `"updated_at"` | integer | Timestamp of last update (ms) |
* Status 500: Internal server error
#### Code Example (Python)
```python theme={null}
import requests
response = requests.get(
"/api/v1/loan_pool",
headers={"Accept": "*/*"},
)
data = response.json()
```
# Get Mark Price Candle Data
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/markets/get-mark-price-candle-data
This endpoint allows users to get historical mark price candles for a specific market and time interval.
```http theme={null}
/api/v1/kline/mark
```
#### Query Parameters
| Field | Type | Need | Description | Example |
|---|
| `"symbol"` | string | required | Trading pair symbol | `BTC` |
| `"interval"` | string | required | Candlestick interval\
Valid values: 1m, 3m, 5m, 15m, 30m, 1h, 2h, 4h, 8h, 12h, 1d, 1w, 1M | `1m` |
| `"start_time"` | integer | required | Start time in milliseconds | `1716200000000` |
| `"end_time"` | integer | optional | End time in milliseconds, defaults to current time if not provided | `1742243220000` |
| `"limit"` | integer | optional | Maximum number of candles to return. Capped at 4000; defaults to 4000 if not provided | `100` |
```http theme={null}
/api/v1/kline/mark?symbol=BTC&interval=1m&start_time=1742243160000&end_time=1742243220000
```
#### Response
* Status 200: Successfully retrieved mark price candle data
```json theme={null}
{
"success": true,
"data": [
{
"t": 1764126720000,
"T": 1764126780000,
"s": "BTC",
"i": "1m",
"o": "87701",
"c": "87687.303362",
"h": "87739",
"l": "87687.303362",
"v": "0.84106",
"n": 62
},
{
"t": 1764126780000,
"T": 1764126840000,
"s": "BTC",
"i": "1m",
"o": "87684.118667",
"c": "87654",
"h": "87684.118667",
"l": "87645",
"v": "4.5997",
"n": 91
}
],
"error": null,
"code": null
}
```
| Field | Type | Description |
| - | - | - |
| `'t'` | number | Candle start time |
| `'T'` | number | Candle end time |
| `'s'` | string | Symbol |
| `'i'` | string | Time interval of candles |
| `'o'` | decimal string | Open price |
| `'c'` | decimal string | Close price |
| `'h'` | decimal string | High price |
| `'l'` | decimal string | Low price |
| `'v'` | decimal string | Volume (always `"0"`) |
| `'n'` | number | Number of trades on Pacifica in candle duration |
* Status 400: Invalid request parameters
* Status 401: Unauthorized access
* Status 500: Internal server error
#### Code Example (Python)
```python theme={null}
import requests
response = requests.get(
"/api/v1/kline/mark?symbol=BTC&interval=1m&start_time=1742243160000&end_time=1742243220000",
headers={"Accept": "*/*"},
)
data = response.json()
```
# Get Market Info
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/markets/get-market-info
This endpoint allows users to get exchange information, including market specifications for all available trading pairs.
```http theme={null}
GET /api/v1/info
```
#### Response
* Status 200: Success
```json theme={null}
{
"success": true,
"data": [
{
"symbol": "ETH",
"tick_size": "0.1",
"min_tick": "0",
"max_tick": "1000000",
"lot_size": "0.0001",
"max_leverage": 50,
"isolated_only": false,
"min_order_size": "10",
"max_order_size": "5000000",
"funding_rate": "0.0000125",
"next_funding_rate": "0.0000125",
"created_at": 1748881333944,
"instrument_type": "perpetual",
"base_asset": "ETH"
},
{
"symbol": "BTC",
"tick_size": "1",
"min_tick": "0",
"max_tick": "1000000",
"lot_size": "0.00001",
"max_leverage": 50,
"isolated_only": false,
"min_order_size": "10",
"max_order_size": "5000000",
"funding_rate": "0.0000125",
"next_funding_rate": "0.0000125",
"created_at": 1748881333944,
"instrument_type": "perpetual",
"base_asset": "BTC"
},
....
],
"error": null,
"code": null
}
```
| Field | Type | Description |
|---|
| `"symbol"` | string | Trading pair symbol |
| `"tick_size"` | decimal string | Tick size. All prices are denominated as a multiple of this. |
| `"min_tick"` | decimal string | Minimum tick. API submitted price cannot be below this value |
| `"max_tick"` | decimal string | Maximum tick. API submitted price cannot be above this value |
| `"lot_size"` | decimal string | Lot size. All order sizes (token denominated) are denominated as a multiple of this. |
| `"max_leverage"` | integer | Maximum leverage allowed on this symbol when opening positions |
| `"isolated_only"` | boolean | If the market is set to only allow isolated positions |
| `"min_order_size"` | decimal string | Minimum order size (denominated in USD) |
| `"max_order_size"` | decimal string | Maximum order size (denominated in USD) |
| `"funding_rate"` | decimal string | Funding rate paid in the past funding epoch (hour) |
| `"next_funding_rate"` | decimal string | Estimated funding rate to be paid in the next funding epoch (hour) |
| `"created_at"` | integer | Timestamp (milliseconds) when the market was listed on Pacifica. Markets are returned oldest first. |
| `"instrument_type"` | string | Instrument type for the market (e.g. `perpetual`) |
| `"base_asset"` | string | Base asset of the market |
* Status 500: Internal server error
#### Code Example (Python)
```json theme={null}
import requests
response = requests.get(
"/api/v1/info",
headers={"Accept": "*/*"},
)
data = response.json()
```
# Get Orderbook
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/markets/get-orderbook
This endpoint allows users to retrieve the current orderbook (bid/ask levels) for a specified trading symbol.
```http theme={null}
/api/v1/book
```
#### Query Parameters
| Field | Type | Need | Description | Example |
|---|
| `"symbol"` | string | required | Trading pair symbol | `BTC` |
| `"agg_level"` | integer | no | Aggregation level for price grouping. Defaults to `1` | `1` |
```
api/v1/book?symbol=BTC
```
#### Response
* Status 200: Successfully retrieved book data
```json theme={null}
{
"success": true,
"data": {
"s": "BTC",
"l": [
[
{
"p": "106504",
"a": "0.26203",
"n": 1
},
{
"p": "106498",
"a": "0.29281",
"n": 1
}
],
[
{
"p": "106559",
"a": "0.26802",
"n": 1
},
{
"p": "106564",
"a": "0.3002",
"n": 1
},
]
],
"t": 1751370536325
},
"error": null,
"code": null
}
```
| Field | Type | Description |
| - | - | - |
| `'s'` | string | Symbol |
| `'l'` | array | Two-dimensional array containing bids (index 0) and asks (index 1). Each index contains up to 10 levels. |
| `'t'` | integer | Response timestamp in milliseconds |
| `'p'` | decimal string | Price level |
| `'a'` | decimal string | Total amount at price level |
| `'n'` | integer | Number of orders at level |
* Status 400: Invalid request parameters
* Status 401: Unauthorized access
* Status 500: Internal server error
#### Code Example (Python)
```python theme={null}
import requests
response = requests.get(
"api.pacifica.fi/api/v1/book?symbol=BTC",
headers={"Accept": "*/*"},
)
data = response.json()
```
# Get Prices
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/markets/get-prices
This endpoint allows users to get price information for all symbols, including mark prices, funding rates, and market statistics.
```http theme={null}
GET /api/v1/info/prices
```
#### Response
* Status 200: Success
```json theme={null}
{
"success": true,
"data": [
{
"funding": "0.00010529",
"mark": "1.084819",
"mid": "1.08615",
"next_funding": "0.00011096",
"open_interest": "3634796",
"oracle": "1.084524",
"symbol": "XPL",
"timestamp": 1759222967974,
"volume_24h": "20896698.0672",
"yesterday_price": "1.3412"
}
],
"error": null,
"code": null
}
```
| Field | Type | Description |
|---|
| `"funding"` | decimal string | funding rate paid in the past funding epoch (hour) |
| `"mark"` | decimal string | Mark price, as defined above |
| `"mid"` | decimal string | Mid price, defined as the average of the best bid and best ask price |
| `"next_funding"` | decimal string | estimated funding rate to be paid in the next funding epoch (hour) |
| `"open_interest"` | decimal string | The current open interest on this symbol (in USD) |
| `"oracle"` | decimal string | Oracle price, as defined above |
| `"symbol"` | string | Trading pair symbol |
| `"timestamp"` | integer | Timestamp in Milliseconds |
| `"volume_24h"` | decimal string | Volume (USD) of this market in the past 24 hours |
| `"yesterday_price"` | decimal string | Oracle price of this market 24 hours ago (USD) |
* Status 404: No prices data available
* Status 500: Internal server error
#### Code Example (Python)
```python theme={null}
import requests
response = requests.get(
"/api/v1/info/prices",
headers={"Accept": "*/*"},
)
data = response.json()
```
# Get Recent Trades
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/markets/get-recent-trades
This endpoint allows users to get recent trades for a specific market.
```http theme={null}
GET /api/v1/trades
```
#### Query Parameters
| Field | Type | Need | Description | Example |
|---|
| `"symbol"` | string | optional | Trading pair symbol. If omitted, returns recent trades across all markets. | `BTC` |
```http theme={null}
/api/v1/trades?symbol=BTC
```
#### Response
* Status 200: Successfully retrieved recent trades
```json theme={null}
{
"success": true,
"data": [
{
"event_type": "fulfill_taker",
"price": "104721",
"amount": "0.0001",
"side": "close_long",
"cause": "normal",
"created_at": 1765006315306
}
],
"error": null,
"code": null,
"last_order_id": 1557404170
}
```
| Field | Type | Description |
| - | - | - |
| `'event_type'` | string | `"fulfill_taker"` if maker `"fulfill_maker"` if taker |
| `'price'` | decimal string | Price in USD at which trade event has occurred |
| `'amount'` | decimal string | Amount in token denomination for which the trade has occurred. |
| `'side'` | string | `"open_long"` `"open_short"` `"close_long"` `"close_short"` |
| `'cause'` | string | `"normal"` regular user-initiated trading `"market_liquidation"` position was liquidated due to insufficient margin `"backstop_liquidation"` position was liquidated by backstop mechanism `"settlement"` position was closed due to Auto-Deleveraging (ADL) or other settlement `"insolvency_liquidation"` position was closed due to account insolvency `"game_settlement"` position was settled by the prediction game `"fulfill_rfq"` trade resulted from an RFQ fill |
| `'created_at'` | integer | Timestamp in milliseconds of trade event |
The response also includes a top-level `last_order_id` field (a sibling of `data`, `error`, and `code` — not a member of each trade object):
| Field | Type | Description |
| - | - | - |
| `'last_order_id'` | integer or null | [Last ID](/api-documentation/api/last-id) — the highest sequence number among the returned trades. `null` when the result is empty. |
* Status 400: Invalid request parameters
* Status 401: Unauthorized access
* Status 500: Internal server error
#### Code Example (Python)
```python theme={null}
import requests
response = requests.get(
"/api/v1/trades?symbol=BTC",
headers={"Accept": "*/*"},
)
data = response.json()
```
# Notifications
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/notifications
This section covers push notifications to the mobile app and to browsers, notification preferences, and the in-app notification history.
Pacifica can tell you when something happens on your account, for example when an order fills or a deposit completes. It delivers each notification on one or more channels:
| Channel | Delivery |
| - | - |
| `in_app` | Pacifica keeps the notification in the account's history. Read it with [Get notification history](/api-documentation/api/rest-api/notifications/get-notification-history) |
| `mobile_push` | Pacifica sends a push to the Pacifica mobile app through Expo |
| `web_push` | Pacifica sends a push to browsers and installed web apps (PWAs) through the Web Push protocol |
Notifications are off by default. To get a notification, turn on its channel in the master preference and for its notification type. See [Preferences](#preferences).
* [Register Expo device](/api-documentation/api/rest-api/notifications/register-expo-device): This endpoint allows users to register an Expo push token so that the mobile app receives push notifications.
* [Unregister Expo device](/api-documentation/api/rest-api/notifications/unregister-expo-device): This endpoint allows users to stop push notifications to an Expo push token or app installation.
* [Get Web Push config](/api-documentation/api/rest-api/notifications/get-web-push-config): This endpoint allows users to check if Web Push is available and to get the VAPID public key.
* [Register Web Push subscription](/api-documentation/api/rest-api/notifications/register-web-push-subscription): This endpoint allows users to register a browser's Web Push subscription.
* [Get Web Push subscription status](/api-documentation/api/rest-api/notifications/get-web-push-subscription-status): This endpoint allows users to check if a browser installation gets Web Push notifications.
* [Unregister Web Push subscription](/api-documentation/api/rest-api/notifications/unregister-web-push-subscription): This endpoint allows users to stop Web Push notifications to a browser installation.
* [List notification preferences](/api-documentation/api/rest-api/notifications/list-notification-preferences): This endpoint allows users to get the notification channels that are on for an account.
* [Set notification preference](/api-documentation/api/rest-api/notifications/set-notification-preference): This endpoint allows users to turn a channel on or off for one or more notification types.
* [Set notification master preference](/api-documentation/api/rest-api/notifications/set-notification-master-preference): This endpoint allows users to turn a channel on or off with the account's master switch.
* [Send test notification](/api-documentation/api/rest-api/notifications/send-test-notification): This endpoint allows users to send a test notification on the account's enabled channels.
* [Get notification history](/api-documentation/api/rest-api/notifications/get-notification-history): This endpoint allows users to get an account's recent in-app notifications and unread count.
* [Mark notifications seen](/api-documentation/api/rest-api/notifications/mark-notifications-seen): This endpoint allows users to mark notifications as seen.
### Notification types
Each notification has a `notification_type`. You set preferences for these types:
| `notification_type` | When Pacifica sends it | Title |
| - | - | - |
| `deposit_success` | A USDC or spot deposit completes | `Deposit confirmed` |
| `withdraw_success` | A USDC or spot withdrawal completes | `Withdrawal complete` |
| `order_filled` | An order fills completely | `Order filled` |
| `order_partially_filled` | A non-market order fills in part. Each partial fill sends a notification | `Order partially filled` |
| `order_canceled` | An order is cancelled, force-cancelled, or expires | `Order canceled` |
| `tp_sl_triggered` | A take profit or stop loss order triggers | `TP/SL triggered` |
| `liquidation` | A position is liquidated | `Position liquidated` |
| `strategy_update` | An [order strategy](/api-documentation/api/rest-api/order-strategies) changes state | See below |
Orders that an order strategy places also send order notifications.
[Send test notification](/api-documentation/api/rest-api/notifications/send-test-notification) sends the `test` type. You can't set preferences for `test`.
The API schema also lists `account`, `trading`, `risk`, `price_alert`, and `announcement`. Pacifica doesn't send these types now, and you can't set preferences for them.
**Strategy updates**
A `strategy_update` notification has an `outcome` in its `data`:
| `outcome` | Title | When |
| - | - | - |
| `triggered` | `Strategy triggered` | The strategy's trigger fires and it starts to trade, or an OCO or conditional strategy completes |
| `completed` | `Strategy completed` | Any other strategy type completes |
| `cancelled` | `Strategy stopped` | The strategy is cancelled for a reason other than your cancel |
| `expired` | `Strategy expired` | The strategy expires |
| `failed` | `Strategy failed` | The strategy or its trigger order fails |
Pacifica doesn't send a notification when a strategy starts, pauses, or resumes, or when you cancel it.
### Notification data
Each notification has a `title`, a `body`, and a `data` object. The `title` and `body` are English text for display. Use `data` to route a tap or click in your app.
`data` always contains `notification_type` and `kind`. Both are set to the notification type. The other fields depend on the type. Decimal values are strings. IDs are strings.
**Orders** (`order_filled`, `order_partially_filled`, `order_canceled`, `tp_sl_triggered`)
| Field | Type | Description |
|---|
| `"order_id"` | string | Order ID |
| `"symbol"` | string | Market symbol |
| `"base_symbol"` | string | Same as `"symbol"` |
| `"side"` | string | `"buy"` or `"sell"` |
| `"order_type"` | string | `"limit"`\
`"market"`\
`"stop limit"`\
`"stop market"`\
`"take profit"`\
`"stop loss"` |
| `"price"` | decimal string | Order price |
| `"initial_amount"` | decimal string | `order_partially_filled` only. Order amount |
| `"filled_amount"` | decimal string | `order_partially_filled` and `order_filled` only. Amount filled |
| `"last_filled_price"` | decimal string | `order_filled` only. Price of the last fill |
| `"cancel_reason"` | string | `order_canceled` only:\
`"canceled"`\
`"force_canceled"`\
`"expired"` |
| `"stop_price"` | decimal string | `tp_sl_triggered` only. Trigger price. Omitted when the order has no stop price |
| `"trigger_kind"` | string | `tp_sl_triggered` only. `"take_profit"` or `"stop_loss"` |
**Liquidations** (`liquidation`)
| Field | Type | Description |
|---|
| `"history_id"` | string | Trade history ID |
| `"order_id"` | string or null | Order ID of the liquidation |
| `"symbol"` | string | Market symbol |
| `"base_symbol"` | string | Same as `"symbol"` |
| `"position_side"` | string | `"long"` or `"short"` |
| `"amount"` | decimal string | Amount liquidated |
| `"price"` | decimal string | Liquidation price |
| `"entry_price"` | decimal string | Entry price of the position |
| `"pnl"` | decimal string | Realized PnL |
| `"cause"` | string | `"market_liquidation"`\
`"backstop_liquidation"`\
`"insolvency_liquidation"` |
**Deposits and withdrawals** (`deposit_success`, `withdraw_success`)
| Field | Type | Description |
|---|
| `"history_id"` | string | `deposit_success` only. Deposit history ID |
| `"signature"` | string | `deposit_success` only. Deposit transaction signature |
| `"withdraw_id"` | string | `withdraw_success` only. Withdrawal ID |
| `"tx_hash"` | string | `withdraw_success` only. Withdrawal transaction hash |
| `"asset"` | string | `"USDC"`, or the spot asset |
| `"symbol"` | string | Spot deposits and withdrawals only. Spot asset symbol |
| `"amount"` | decimal string | Amount |
**Strategy updates** (`strategy_update`)
| Field | Type | Description |
|---|
| `"strategy_id"` | UUID | Strategy ID |
| `"type"` | string | Strategy type, for example `"twap"` |
| `"symbol"` | string | Market symbol that the strategy trades |
| `"base_symbol"` | string | Same as `"symbol"` |
| `"lifecycle"` | string | The strategy's [lifecycle](/api-documentation/api/rest-api/order-strategies) after the change |
| `"outcome"` | string | What happened. See Strategy updates above |
| `"terminal_reason"` | string or null | Why the strategy ended, for example `"insufficient_balance"`. Show your own label for this code |
### Preferences
An account has a master preference and a preference for each notification type. Each preference is a set of channels.
* Pacifica uses a channel only when the channel is on in the master preference and in the type's preference.
* All channels start off. A missing preference counts as off.
* The master preference doesn't change the type preferences. You can turn a channel off in the master preference to pause it, and turn it on again later.
* Pacifica picks the channels when it creates a notification. A later preference change doesn't change notifications that already exist.
* Turning on a type doesn't backfill notifications for older events.
* The `test` type uses only the master preference.
For example, to get order fills on the mobile app and in the history, turn on `mobile_push` and `in_app` with [Set notification master preference](/api-documentation/api/rest-api/notifications/set-notification-master-preference). Then turn on the same channels for `order_filled` with [Set notification preference](/api-documentation/api/rest-api/notifications/set-notification-preference).
### Mobile push (Expo)
1. On the first install, generate at least 128 random bits. Encode them as a string, for example hexadecimal. Keep this installation key in the device's secure storage.
2. Get the Expo push token from the Expo SDK.
3. Call [Register Expo device](/api-documentation/api/rest-api/notifications/register-expo-device) with the token, the `platform`, and the installation key as `device_id`.
4. Turn on `mobile_push` in the master preference and for the types that you want.
5. When the user signs out, call [Unregister Expo device](/api-documentation/api/rest-api/notifications/unregister-expo-device).
Keep the installation key secret. Don't use a hardware ID or a user ID. The key proves that a request comes from the installation that owns the token.
The push `data` is the notification's `data` object. Route a tap by `data.notification_type`.
### Web Push
1. Call [Get Web Push config](/api-documentation/api/rest-api/notifications/get-web-push-config). If `enabled` is `false`, hide Web Push in your app. Otherwise, read `vapid_public_key`.
2. Generate an `installation_id` of 32 to 64 characters from `A-Z`, `a-z`, `0-9`, `-`, and `_`. Store it where the page and the service worker can both read it, for example IndexedDB.
3. In the browser, call `pushManager.subscribe({ userVisibleOnly: true, applicationServerKey: vapid_public_key })`.
4. Call [Register Web Push subscription](/api-documentation/api/rest-api/notifications/register-web-push-subscription) with the subscription's endpoint and keys.
5. Turn on `web_push` in the master preference and for the types that you want.
6. In the service worker, show each push with `showNotification`. Use `notification_id` as the `tag`.
7. When the page loads, call [Get Web Push subscription status](/api-documentation/api/rest-api/notifications/get-web-push-subscription-status). If `state` is `expired` or `key_rotated`, subscribe again and register again.
8. When the user signs out or switches account, call [Unregister Web Push subscription](/api-documentation/api/rest-api/notifications/unregister-web-push-subscription).
Each push carries this encrypted JSON payload:
```json theme={null}
{
"version": 1,
"notification_id": 81234,
"subscription_id": "3f1c2a7e-9b4d-4e8a-8c2f-6d5b1a0e9f47",
"title": "Order filled",
"body": "Your buy BTC order filled at 97000.",
"data": {
"notification_type": "order_filled",
"kind": "order_filled",
"order_id": "315992721",
...
},
"created_at_ms": 1716200000000
}
```
`notification_id` is the `id` that [Get notification history](/api-documentation/api/rest-api/notifications/get-notification-history) returns. Route a click by `data.notification_type`.
### History and seen
* [Get notification history](/api-documentation/api/rest-api/notifications/get-notification-history) returns only notifications that Pacifica created with the `in_app` channel on. Push-only notifications aren't in the history.
* It returns the 100 newest notifications, newest first. It has no pagination.
* `unread_count` counts all in-app notifications that aren't seen. It can be more than 100.
* [Mark notifications seen](/api-documentation/api/rest-api/notifications/mark-notifications-seen) marks the IDs that you send. There is no "mark all" call. Send the IDs that you show.
* Seen state belongs to the account. All the account's devices and browsers see the same state.
### Delivery
* Pacifica sends a push only in the first 15 minutes after it creates the notification. After that, it drops the push. The notification stays in the history if `in_app` was on.
* Pacifica sends a `mobile_push` notification to every active Expo token on the account. It turns off a token when Expo reports that the device is no longer registered.
* Pacifica sends a `web_push` notification to every active Web Push subscription on the account. It turns off a subscription when the push service reports that the subscription is gone.
* A push service accepting a push doesn't mean the device showed it.
### Signing and limits
| Endpoint | Who can sign |
| - | - |
| Register Expo device, Register Web Push subscription | The account key only |
| Get Web Push config | No signature |
| All other notification endpoints | The account key or an [agent wallet](/api-documentation/api/signing/api-agent-keys) |
* An account keeps up to 10 active Web Push subscriptions. When you register one more, Pacifica turns off the subscription that was registered longest ago.
* An app installation has one active Expo token for each account. When you register a new token with the same `device_id`, Pacifica turns off the old token.
* The account must exist. An account exists after its first deposit. Other accounts get status 403.
* The standard [rate limits](/api-documentation/api/rate-limits) apply.
# Get Notification History
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/notifications/get-notification-history
This endpoint allows users to get an account's recent in-app notifications and unread count.
```http theme={null}
POST /api/v1/account/notifications/history
```
This endpoint returns your 100 newest in-app notifications, newest first, and the number of notifications that you haven't seen. Use it to build a notification list or a badge.
* The history has only notifications that Pacifica created with the `in_app` channel on. Push-only notifications aren't in it.
* The endpoint has no pagination. It always returns up to the 100 newest notifications.
* `unread_count` counts every in-app notification that isn't seen, so it can be more than 100.
To mark notifications as seen, call [Mark notifications seen](/api-documentation/api/rest-api/notifications/mark-notifications-seen).
#### Operation Type (for Signing)
| Header Field | Type | Content |
| - | - | - |
| `"type"` | string | `"get_notification_history"` |
#### Request Body
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | User's wallet address | `42trU9A5...` |
| `"signature"` | string | required | Cryptographic signature | `5j1Vy9Uq...` |
| `"timestamp"` | integer | required | Current timestamp in milliseconds | `1716200000000` |
| `"expiry_window"` | integer | optional | Signature expiry in milliseconds | `30000` |
| `"agent_wallet"` | string | optional | Agent wallet address | `69trU9A5...` |
```json theme={null}
{
"account": "42trU9A5...",
"signature": "5j1Vy9Uq...",
"timestamp": 1716200000000,
"expiry_window": 30000
}
```
You can sign this request with the account key or with an [agent wallet](/api-documentation/api/signing/api-agent-keys).
#### Signing
This request has no fields of its own. Sign an empty `data` object:
```json theme={null}
{"data":{},"expiry_window":30000,"timestamp":1716200000000,"type":"get_notification_history"}
```
#### Response
* Status 200: Successfully retrieved notification history
```json theme={null}
{
"success": true,
"data": {
"notifications": [
{
"id": 81234,
"notification_type": "order_filled",
"title": "Order filled",
"body": "Your buy BTC order filled at 97000.",
"data": {
"notification_type": "order_filled",
"kind": "order_filled",
"order_id": "315992721",
"symbol": "BTC",
"base_symbol": "BTC",
"side": "buy",
"order_type": "limit",
"price": "97000",
"filled_amount": "0.01",
"last_filled_price": "97000"
},
"created_at_ms": 1716200000000,
"read": false
},
{
"id": 81102,
"notification_type": "deposit_success",
"title": "Deposit confirmed",
"body": "Your deposit of 500 USDC is complete.",
"data": {
"notification_type": "deposit_success",
"kind": "deposit_success",
"history_id": "1840022",
"asset": "USDC",
"amount": "500",
"signature": "5VERv8NM..."
},
"created_at_ms": 1716190000000,
"read": true
},
...
],
"unread_count": 1
},
"error": null,
"code": null
}
```
| Field | Type | Description |
|---|
| `"notifications"` | array | Up to 100 notifications, newest first |
| `"unread_count"` | integer | Number of in-app notifications that aren't seen |
**Notification Fields**
| Field | Type | Description |
|---|
| `"id"` | integer | Notification ID. Send it to [Mark notifications seen](/api-documentation/api/rest-api/notifications/mark-notifications-seen) |
| `"notification_type"` | string | [Notification type](/api-documentation/api/rest-api/notifications#notification-types), or `"test"` |
| `"title"` | string or null | Title for display |
| `"body"` | string or null | Body text for display |
| `"data"` | object | Details of the event. See [Notification data](/api-documentation/api/rest-api/notifications#notification-data) |
| `"created_at_ms"` | integer | Timestamp in milliseconds when Pacifica created the notification |
| `"read"` | boolean | `true` if the notification is marked seen |
* Status 400: Invalid request parameters or signature
* Status 403: The account doesn't exist. An account exists after its first deposit
* Status 429: Rate limit exceeded
* Status 500: Internal server error
#### Code Example (Python)
```python theme={null}
import requests
payload = {
"account": "42trU9A5...",
"signature": "5j1Vy9Uq...",
"timestamp": 1716200000000
}
response = requests.post(
"/api/v1/account/notifications/history",
json=payload,
headers={"Content-Type": "application/json"}
)
data = response.json()
```
# Get Web Push Config
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/notifications/get-web-push-config
This endpoint allows users to check if Web Push is available and to get the VAPID public key.
```http theme={null}
GET /api/v1/account/notifications/web_push/config
```
This endpoint tells you if Pacifica sends Web Push notifications, and gives you the VAPID public key. You need the key to subscribe a browser to push. This request needs no signature and no parameters.
```http theme={null}
/api/v1/account/notifications/web_push/config
```
#### Response
* Status 200: Successfully retrieved the Web Push config
```json theme={null}
{
"success": true,
"data": {
"enabled": true,
"vapid_public_key": "BF6x0Kq2..."
},
"error": null,
"code": null
}
```
| Field | Type | Description |
|---|
| `"enabled"` | boolean | `true` when Pacifica sends Web Push notifications |
| `"vapid_public_key"` | string or null | Base64url VAPID public key. `null` when `"enabled"` is `false` |
If `enabled` is `false`, hide Web Push in your app.
Pass `vapid_public_key` as `applicationServerKey` to `pushManager.subscribe`. Then send the same value as `vapid_public_key` to [Register Web Push subscription](/api-documentation/api/rest-api/notifications/register-web-push-subscription). The response isn't cacheable. Get the key again each time that you subscribe.
* Status 429: Rate limit exceeded
* Status 500: Internal server error
#### Code Example (Python)
```python theme={null}
import requests
response = requests.get(
"/api/v1/account/notifications/web_push/config",
headers={"Accept": "*/*"},
)
data = response.json()
```
# Get Web Push Subscription Status
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/notifications/get-web-push-subscription-status
This endpoint allows users to check if a browser installation gets Web Push notifications.
```http theme={null}
POST /api/v1/account/notifications/web_push/subscription/status
```
This endpoint returns the state of one browser's push subscription on your account. Call it when the page loads to find out if you must subscribe again.
#### Operation Type (for Signing)
| Header Field | Type | Content |
| - | - | - |
| `"type"` | string | `"get_web_push_subscription"` |
#### Request Body
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | User's wallet address | `42trU9A5...` |
| `"signature"` | string | required | Cryptographic signature | `5j1Vy9Uq...` |
| `"timestamp"` | integer | required | Current timestamp in milliseconds | `1716200000000` |
| `"installation_id"` | string | required | The browser's installation ID from [Register Web Push subscription](/api-documentation/api/rest-api/notifications/register-web-push-subscription) | `k3Jx9_Qm...` |
| `"expiry_window"` | integer | optional | Signature expiry in milliseconds | `30000` |
| `"agent_wallet"` | string | optional | Agent wallet address | `69trU9A5...` |
```json theme={null}
{
"account": "42trU9A5...",
"signature": "5j1Vy9Uq...",
"timestamp": 1716200000000,
"installation_id": "k3Jx9_Qm2LpV7nRt4WcY8bZa1HdF6sGe",
"expiry_window": 30000
}
```
You can sign this request with the account key or with an [agent wallet](/api-documentation/api/signing/api-agent-keys).
#### Response
* Status 200: Successfully retrieved the subscription state
```json theme={null}
{
"success": true,
"data": {
"subscription_id": "3f1c2a7e-9b4d-4e8a-8c2f-6d5b1a0e9f47",
"state": "active",
"vapid_public_key": "BF6x0Kq2..."
},
"error": null,
"code": null
}
```
| Field | Type | Description |
|---|
| `"subscription_id"` | UUID or null | Subscription ID. `null` when `"state"` is `"not_registered"` |
| `"state"` | string | Subscription state (see below) |
| `"vapid_public_key"` | string or null | VAPID public key that the subscription was registered with. `null` when `"state"` is `"not_registered"` |
**Subscription States**
| `state` | Meaning | What to do |
| - | - | - |
| `active` | Pacifica sends Web Push to this browser | Nothing |
| `not_registered` | This installation has no subscription on this account | Register if the user wants Web Push |
| `disabled` | The subscription was unregistered, replaced by a newer one over the limit, or reported gone by the push service | Subscribe again only if the user asks |
| `expired` | The subscription's expiration time has passed | Subscribe again and register |
| `key_rotated` | The subscription uses an older VAPID key | Subscribe again with the current key and register |
* Status 400: Invalid request parameters or signature. A bad `installation_id` returns `error_id` `invalid_notification_device_id`
* Status 403: The account doesn't exist. An account exists after its first deposit
* Status 409: Web Push isn't available (`web_push_disabled`)
* Status 429: Rate limit exceeded
* Status 500: Internal server error
#### Code Example (Python)
```python theme={null}
import requests
payload = {
"account": "42trU9A5...",
"signature": "5j1Vy9Uq...",
"timestamp": 1716200000000,
"installation_id": "k3Jx9_Qm2LpV7nRt4WcY8bZa1HdF6sGe"
}
response = requests.post(
"/api/v1/account/notifications/web_push/subscription/status",
json=payload,
headers={"Content-Type": "application/json"}
)
data = response.json()
```
# List Notification Preferences
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/notifications/list-notification-preferences
This endpoint allows users to get the notification channels that are on for an account.
```http theme={null}
POST /api/v1/account/notifications/preferences/list
```
This endpoint returns your master preference and the preference for each notification type. See [Preferences](/api-documentation/api/rest-api/notifications#preferences) for how they work together.
#### Operation Type (for Signing)
| Header Field | Type | Content |
| - | - | - |
| `"type"` | string | `"list_notification_preferences"` |
#### Request Body
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | User's wallet address | `42trU9A5...` |
| `"signature"` | string | required | Cryptographic signature | `5j1Vy9Uq...` |
| `"timestamp"` | integer | required | Current timestamp in milliseconds | `1716200000000` |
| `"expiry_window"` | integer | optional | Signature expiry in milliseconds | `30000` |
| `"agent_wallet"` | string | optional | Agent wallet address | `69trU9A5...` |
```json theme={null}
{
"account": "42trU9A5...",
"signature": "5j1Vy9Uq...",
"timestamp": 1716200000000,
"expiry_window": 30000
}
```
You can sign this request with the account key or with an [agent wallet](/api-documentation/api/signing/api-agent-keys).
#### Signing
This request has no fields of its own. Sign an empty `data` object:
```json theme={null}
{"data":{},"expiry_window":30000,"timestamp":1716200000000,"type":"list_notification_preferences"}
```
#### Response
* Status 200: Successfully retrieved notification preferences
```json theme={null}
{
"success": true,
"data": {
"master_enabled_channels": ["in_app", "mobile_push"],
"preferences": [
{ "notification_type": "deposit_success", "enabled_channels": ["in_app", "mobile_push"] },
{ "notification_type": "withdraw_success", "enabled_channels": ["in_app", "mobile_push"] },
{ "notification_type": "order_filled", "enabled_channels": ["in_app", "mobile_push"] },
{ "notification_type": "order_partially_filled", "enabled_channels": [] },
{ "notification_type": "order_canceled", "enabled_channels": ["in_app"] },
{ "notification_type": "tp_sl_triggered", "enabled_channels": ["in_app", "mobile_push"] },
{ "notification_type": "liquidation", "enabled_channels": ["in_app", "mobile_push"] },
{ "notification_type": "strategy_update", "enabled_channels": [] }
]
},
"error": null,
"code": null
}
```
| Field | Type | Description |
|---|
| `"master_enabled_channels"` | array | Channels that are on in the master preference:\
`"in_app"`\
`"mobile_push"`\
`"web_push"` |
| `"preferences"` | array | One entry for each notification type that you can configure |
| `"notification_type"` | string | [Notification type](/api-documentation/api/rest-api/notifications#notification-types) |
| `"enabled_channels"` | array | Channels that are on for this type |
`preferences` always lists all eight types, in the order above. A type that you never set has an empty `enabled_channels` list. A new account has empty lists everywhere.
* Status 400: Invalid request parameters or signature
* Status 403: The account doesn't exist. An account exists after its first deposit
* Status 429: Rate limit exceeded
* Status 500: Internal server error
#### Code Example (Python)
```python theme={null}
import requests
payload = {
"account": "42trU9A5...",
"signature": "5j1Vy9Uq...",
"timestamp": 1716200000000
}
response = requests.post(
"/api/v1/account/notifications/preferences/list",
json=payload,
headers={"Content-Type": "application/json"}
)
data = response.json()
```
# Mark Notifications Seen
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/notifications/mark-notifications-seen
This endpoint allows users to mark notifications as seen.
```http theme={null}
POST /api/v1/account/notifications/seen
```
This endpoint marks the notifications that you send as seen. After that, [Get notification history](/api-documentation/api/rest-api/notifications/get-notification-history) returns `"read": true` for them and leaves them out of `unread_count`.
* Seen state belongs to the account. All the account's devices and browsers see the same state.
* There is no "mark all" call. Send the IDs that you show, for example when the user opens the list or taps a notification.
* Pacifica ignores unknown IDs, IDs of other accounts, and IDs that aren't in the in-app history.
* The call is idempotent. Marking a seen notification again has no effect.
#### Operation Type (for Signing)
| Header Field | Type | Content |
| - | - | - |
| `"type"` | string | `"mark_notifications_seen"` |
#### Request Body
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | User's wallet address | `42trU9A5...` |
| `"signature"` | string | required | Cryptographic signature | `5j1Vy9Uq...` |
| `"timestamp"` | integer | required | Current timestamp in milliseconds | `1716200000000` |
| `"ids"` | array | required | Notification IDs from [Get notification history](/api-documentation/api/rest-api/notifications/get-notification-history) or from a Web Push payload's `notification_id` | `[81234, 81102]` |
| `"expiry_window"` | integer | optional | Signature expiry in milliseconds | `30000` |
| `"agent_wallet"` | string | optional | Agent wallet address | `69trU9A5...` |
```json theme={null}
{
"account": "42trU9A5...",
"signature": "5j1Vy9Uq...",
"timestamp": 1716200000000,
"ids": [81234, 81102],
"expiry_window": 30000
}
```
You can sign this request with the account key or with an [agent wallet](/api-documentation/api/signing/api-agent-keys).
#### Response
* Status 200: Notifications marked seen
```json theme={null}
{
"success": true,
"data": null,
"error": null,
"code": null
}
```
* Status 400: Invalid request parameters or signature
* Status 403: The account doesn't exist. An account exists after its first deposit
* Status 429: Rate limit exceeded
* Status 500: Internal server error
#### Code Example (Python)
```python theme={null}
import requests
payload = {
"account": "42trU9A5...",
"signature": "5j1Vy9Uq...",
"timestamp": 1716200000000,
"ids": [81234, 81102]
}
response = requests.post(
"/api/v1/account/notifications/seen",
json=payload,
headers={"Content-Type": "application/json"}
)
data = response.json()
```
# Register Expo Device
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/notifications/register-expo-device
This endpoint allows users to register an Expo push token so that the mobile app receives push notifications.
```http theme={null}
POST /api/v1/account/notifications/expo/device
```
This endpoint registers or refreshes an Expo push token for your account. Pacifica sends `mobile_push` [notifications](/api-documentation/api/rest-api/notifications) to every active token on the account.
#### Operation Type (for Signing)
| Header Field | Type | Content |
| - | - | - |
| `"type"` | string | `"register_expo_device"` |
#### Request Body
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | User's wallet address | `42trU9A5...` |
| `"signature"` | string | required | Cryptographic signature | `5j1Vy9Uq...` |
| `"timestamp"` | integer | required | Current timestamp in milliseconds | `1716200000000` |
| `"expo_push_token"` | string | required | Expo push token from the Expo SDK. It must have the form `ExponentPushToken[...]` or `ExpoPushToken[...]`, and up to 512 characters | `ExponentPushToken[xxxx]` |
| `"platform"` | string | required | `"ios"` or `"android"` | `ios` |
| `"device_id"` | string | required | Secret installation key that your app generates once and keeps. 16 to 256 characters | `b7f3c1a9...` |
| `"expiry_window"` | integer | optional | Signature expiry in milliseconds | `30000` |
```json theme={null}
{
"account": "42trU9A5...",
"signature": "5j1Vy9Uq...",
"timestamp": 1716200000000,
"expo_push_token": "ExponentPushToken[xxxxxxxxxxxxxxxxxxxxxx]",
"platform": "ios",
"device_id": "b7f3c1a9e2d84f60b1c5a7e9f3d2c4b8",
"expiry_window": 30000
}
```
You must sign this request with the account key. An [agent wallet](/api-documentation/api/signing/api-agent-keys) can't sign it.
`device_id` identifies one installation of your app. Generate at least 128 random bits on the first install, and keep them in the device's secure storage. Don't use a hardware ID or a user ID. The length check doesn't make a weak key safe.
* When you register again with the same `device_id`, Pacifica refreshes the registration. If the token changed, Pacifica turns off the old token.
* A token belongs to one installation. If a different `device_id` already holds the token, the request fails with status 409. This is also true after that installation unregisters the token.
* If the same installation registers under another account, the token moves to that account. The previous account stops sending to it.
After you register, turn on `mobile_push` with [Set notification master preference](/api-documentation/api/rest-api/notifications/set-notification-master-preference) and [Set notification preference](/api-documentation/api/rest-api/notifications/set-notification-preference).
#### Response
* Status 200: Device registered
```json theme={null}
{
"success": true,
"data": {
"expo_push_token": "ExponentPushToken[xxxxxxxxxxxxxxxxxxxxxx]",
"platform": "ios",
"device_id": "b7f3c1a9e2d84f60b1c5a7e9f3d2c4b8",
"enabled": true
},
"error": null,
"code": null
}
```
| Field | Type | Description |
|---|
| `"expo_push_token"` | string | Registered Expo push token |
| `"platform"` | string | `"ios"` or `"android"` |
| `"device_id"` | string | Installation key that holds the token |
| `"enabled"` | boolean | `true` when Pacifica sends to this token |
* Status 400: Invalid request parameters or signature. A bad token returns `error_id` `invalid_expo_push_token`. A missing or bad `device_id` returns `invalid_notification_device_id`
* Status 403: The account doesn't exist. An account exists after its first deposit
* Status 409: Another installation holds this token
```json theme={null}
{
"success": false,
"data": null,
"error": "Expo push token is registered to another device",
"code": 409,
"error_id": "expo_push_token_conflict"
}
```
* Status 429: Rate limit exceeded
* Status 500: Internal server error
#### Code Example (Python)
```python theme={null}
import requests
payload = {
"account": "42trU9A5...",
"signature": "5j1Vy9Uq...",
"timestamp": 1716200000000,
"expo_push_token": "ExponentPushToken[xxxxxxxxxxxxxxxxxxxxxx]",
"platform": "ios",
"device_id": "b7f3c1a9e2d84f60b1c5a7e9f3d2c4b8"
}
response = requests.post(
"/api/v1/account/notifications/expo/device",
json=payload,
headers={"Content-Type": "application/json"}
)
data = response.json()
```
# Register Web Push Subscription
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/notifications/register-web-push-subscription
This endpoint allows users to register a browser's Web Push subscription.
```http theme={null}
POST /api/v1/account/notifications/web_push/subscription
```
This endpoint registers or refreshes a browser's push subscription for your account. Pacifica sends `web_push` [notifications](/api-documentation/api/rest-api/notifications) to every active subscription on the account.
Before you call it, get the VAPID public key from [Get Web Push config](/api-documentation/api/rest-api/notifications/get-web-push-config). Then subscribe in the browser with `pushManager.subscribe({ userVisibleOnly: true, applicationServerKey: vapid_public_key })`.
#### Operation Type (for Signing)
| Header Field | Type | Content |
| - | - | - |
| `"type"` | string | `"register_web_push_subscription"` |
#### Request Body
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | User's wallet address | `42trU9A5...` |
| `"signature"` | string | required | Cryptographic signature | `5j1Vy9Uq...` |
| `"timestamp"` | integer | required | Current timestamp in milliseconds | `1716200000000` |
| `"installation_id"` | string | required | ID that your app generates once for this browser. 32 to 64 characters from `A-Z`, `a-z`, `0-9`, `-`, and `_` | `k3Jx9_Qm...` |
| `"endpoint"` | string | required | The subscription's `endpoint`. An `https` URL of a supported push service, up to 2048 characters | `https://fcm.googleapis.com/...` |
| `"p256dh"` | string | required | The subscription's `p256dh` key, in base64url without padding | `BNcRdreA...` |
| `"auth"` | string | required | The subscription's `auth` secret, in base64url without padding | `tBHItJI5...` |
| `"expiration_time_ms"` | integer | optional | The subscription's `expirationTime` in milliseconds. Leave it out when the browser returns `null` | `1735689600000` |
| `"vapid_public_key"` | string | required | The VAPID public key that you subscribed with | `BF6x0Kq2...` |
| `"expiry_window"` | integer | optional | Signature expiry in milliseconds | `30000` |
```json theme={null}
{
"account": "42trU9A5...",
"signature": "5j1Vy9Uq...",
"timestamp": 1716200000000,
"installation_id": "k3Jx9_Qm2LpV7nRt4WcY8bZa1HdF6sGe",
"endpoint": "https://fcm.googleapis.com/fcm/send/dX8f...",
"p256dh": "BNcRdreA...",
"auth": "tBHItJI5svbpez7KI4CCXg",
"vapid_public_key": "BF6x0Kq2...",
"expiry_window": 30000
}
```
`subscription.toJSON()` in the browser gives you `endpoint`, `keys.p256dh`, `keys.auth`, and `expirationTime` in the right format.
You must sign this request with the account key. An [agent wallet](/api-documentation/api/signing/api-agent-keys) can't sign it.
**Supported Push Services**
The `endpoint` host must belong to one of these push services. It must have no port, user name, password, or fragment.
| Host | Push service |
| - | - |
| `fcm.googleapis.com` | Google |
| `jmt17.google.com` | Google |
| `*.push.services.mozilla.com` | Mozilla |
| `*.push.apple.com` | Apple |
| `*.notify.windows.com` | Microsoft |
**Registration Rules**
* `installation_id` identifies one browser. Store it where the page and the service worker can both read it, for example IndexedDB.
* When you register again with the same `installation_id`, Pacifica refreshes the subscription.
* If the same `installation_id` registers under another account, the subscription moves to that account.
* If another account has an active subscription with the same `endpoint` and a different `installation_id`, the request fails with status 409. Unregister it from the other account first.
* An account keeps up to 10 active subscriptions. When you register one more, Pacifica turns off the subscription that was registered longest ago.
* `vapid_public_key` must match the current key from [Get Web Push config](/api-documentation/api/rest-api/notifications/get-web-push-config). If it doesn't, subscribe again with the current key.
After you register, turn on `web_push` with [Set notification master preference](/api-documentation/api/rest-api/notifications/set-notification-master-preference) and [Set notification preference](/api-documentation/api/rest-api/notifications/set-notification-preference).
#### Signing
Sign the subscription fields as the `data` object. The secret goes in `data` as `auth`. If you leave out `expiration_time_ms`, leave it out of `data` too. For the request above, the message to sign is:
```json theme={null}
{"data":{"auth":"tBHItJI5svbpez7KI4CCXg","endpoint":"https://fcm.googleapis.com/fcm/send/dX8f...","installation_id":"k3Jx9_Qm2LpV7nRt4WcY8bZa1HdF6sGe","p256dh":"BNcRdreA...","vapid_public_key":"BF6x0Kq2..."},"expiry_window":30000,"timestamp":1716200000000,"type":"register_web_push_subscription"}
```
#### Response
* Status 200: Subscription registered
```json theme={null}
{
"success": true,
"data": {
"subscription_id": "3f1c2a7e-9b4d-4e8a-8c2f-6d5b1a0e9f47",
"vapid_public_key": "BF6x0Kq2..."
},
"error": null,
"code": null
}
```
| Field | Type | Description |
|---|
| `"subscription_id"` | UUID | Subscription ID. Each push carries it as `subscription_id`. It stays the same when you register an active subscription again with the same account, endpoint, keys, and VAPID key. Otherwise Pacifica gives a new ID |
| `"vapid_public_key"` | string | VAPID public key of the subscription |
* Status 400: Invalid request parameters or signature. The `error_id` field says why:
| `error_id` | Meaning |
| - | - |
| `invalid_notification_device_id` | `installation_id` doesn't have 32 to 64 allowed characters |
| `invalid_web_push_subscription` | `endpoint`, `p256dh`, `auth`, or `expiration_time_ms` isn't valid |
| `unsupported_web_push_service` | The `endpoint` host isn't a supported push service |
* Status 403: The account doesn't exist. An account exists after its first deposit
* Status 409: The request conflicts with the current state. The `error_id` field says why:
| `error_id` | Meaning |
| - | - |
| `web_push_key_mismatch` | `vapid_public_key` isn't the current key. Subscribe again with the current key |
| `web_push_endpoint_conflict` | Another account has an active subscription with this `endpoint` |
| `web_push_disabled` | Web Push isn't available |
```json theme={null}
{
"success": false,
"data": null,
"error": "Subscription uses an old VAPID key; resubscribe with the current public key",
"code": 409,
"error_id": "web_push_key_mismatch"
}
```
* Status 429: Rate limit exceeded
* Status 500: Internal server error
#### Code Example (Python)
```python theme={null}
import requests
payload = {
"account": "42trU9A5...",
"signature": "5j1Vy9Uq...",
"timestamp": 1716200000000,
"installation_id": "k3Jx9_Qm2LpV7nRt4WcY8bZa1HdF6sGe",
"endpoint": "https://fcm.googleapis.com/fcm/send/dX8f...",
"p256dh": "BNcRdreA...",
"auth": "tBHItJI5svbpez7KI4CCXg",
"vapid_public_key": "BF6x0Kq2..."
}
response = requests.post(
"/api/v1/account/notifications/web_push/subscription",
json=payload,
headers={"Content-Type": "application/json"}
)
data = response.json()
```
# Send Test Notification
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/notifications/send-test-notification
This endpoint allows users to send a test notification on the account's enabled channels.
```http theme={null}
POST /api/v1/account/notifications/test
```
This endpoint sends a test notification to your account. Use it to check that a device or browser receives pushes.
The test notification uses only the master preference. Pacifica sends it on every channel that is on in [Set notification master preference](/api-documentation/api/rest-api/notifications/set-notification-master-preference). Type preferences don't apply.
| Field | Value |
| - | - |
| `"notification_type"` | `"test"` |
| `"title"` | `"Pacifica"` |
| `"body"` | `"Notifications are enabled."` |
Pacifica sends a `mobile_push` test to every active Expo token and a `web_push` test to every active Web Push subscription on the account. If `in_app` is on, the test also appears in [Get notification history](/api-documentation/api/rest-api/notifications/get-notification-history).
#### Operation Type (for Signing)
| Header Field | Type | Content |
| - | - | - |
| `"type"` | string | `"send_test_notification"` |
#### Request Body
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | User's wallet address | `42trU9A5...` |
| `"signature"` | string | required | Cryptographic signature | `5j1Vy9Uq...` |
| `"timestamp"` | integer | required | Current timestamp in milliseconds | `1716200000000` |
| `"expiry_window"` | integer | optional | Signature expiry in milliseconds | `30000` |
| `"agent_wallet"` | string | optional | Agent wallet address | `69trU9A5...` |
```json theme={null}
{
"account": "42trU9A5...",
"signature": "5j1Vy9Uq...",
"timestamp": 1716200000000,
"expiry_window": 30000
}
```
You can sign this request with the account key or with an [agent wallet](/api-documentation/api/signing/api-agent-keys).
#### Signing
This request has no fields of its own. Sign an empty `data` object:
```json theme={null}
{"data":{},"expiry_window":30000,"timestamp":1716200000000,"type":"send_test_notification"}
```
#### Response
* Status 200: Test notification created
```json theme={null}
{
"success": true,
"data": {
"outbox_id": 81235
},
"error": null,
"code": null
}
```
| Field | Type | Description |
|---|
| `"outbox_id"` | integer | ID of the test notification. It is the `id` in [Get notification history](/api-documentation/api/rest-api/notifications/get-notification-history) and the `notification_id` in a Web Push payload |
A 200 response means that Pacifica created the notification. Delivery to each device happens after the response.
* Status 400: Invalid request parameters or signature
* Status 403: The account doesn't exist. An account exists after its first deposit
* Status 409: No channel is on in the master preference
```json theme={null}
{
"success": false,
"data": null,
"error": "Notifications are disabled",
"code": 409,
"error_id": "notifications_disabled"
}
```
* Status 429: Rate limit exceeded
* Status 500: Internal server error
#### Code Example (Python)
```python theme={null}
import requests
payload = {
"account": "42trU9A5...",
"signature": "5j1Vy9Uq...",
"timestamp": 1716200000000
}
response = requests.post(
"/api/v1/account/notifications/test",
json=payload,
headers={"Content-Type": "application/json"}
)
data = response.json()
```
# Set Notification Master Preference
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/notifications/set-notification-master-preference
This endpoint allows users to turn a channel on or off with the account's master switch.
```http theme={null}
POST /api/v1/account/notifications/preferences/master
```
This endpoint turns one channel on or off in your master preference. Pacifica uses a channel only when it is on in the master preference and in the notification type's preference. Other channels keep their current value.
The master preference doesn't change the type preferences. Turn a channel off here to pause it for all types. When you turn it on again, your type preferences apply again.
#### Operation Type (for Signing)
| Header Field | Type | Content |
| - | - | - |
| `"type"` | string | `"set_notification_master_preference"` |
#### Request Body
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | User's wallet address | `42trU9A5...` |
| `"signature"` | string | required | Cryptographic signature | `5j1Vy9Uq...` |
| `"timestamp"` | integer | required | Current timestamp in milliseconds | `1716200000000` |
| `"channel"` | string | required | Channel to change:\
`"in_app"`\
`"mobile_push"`\
`"web_push"` | `web_push` |
| `"enabled"` | boolean | required | `true` turns the channel on. `false` turns it off | `true` |
| `"expiry_window"` | integer | optional | Signature expiry in milliseconds | `30000` |
| `"agent_wallet"` | string | optional | Agent wallet address | `69trU9A5...` |
```json theme={null}
{
"account": "42trU9A5...",
"signature": "5j1Vy9Uq...",
"timestamp": 1716200000000,
"channel": "web_push",
"enabled": true,
"expiry_window": 30000
}
```
You can sign this request with the account key or with an [agent wallet](/api-documentation/api/signing/api-agent-keys).
#### Response
* Status 200: Master preference updated. The response has all your preferences after the change, in the same format as [List notification preferences](/api-documentation/api/rest-api/notifications/list-notification-preferences)
```json theme={null}
{
"success": true,
"data": {
"master_enabled_channels": ["in_app", "web_push"],
"preferences": [
{ "notification_type": "deposit_success", "enabled_channels": ["in_app", "web_push"] },
{ "notification_type": "withdraw_success", "enabled_channels": ["in_app", "web_push"] },
{ "notification_type": "order_filled", "enabled_channels": ["in_app", "web_push"] },
{ "notification_type": "order_partially_filled", "enabled_channels": [] },
{ "notification_type": "order_canceled", "enabled_channels": [] },
{ "notification_type": "tp_sl_triggered", "enabled_channels": ["in_app", "web_push"] },
{ "notification_type": "liquidation", "enabled_channels": ["in_app", "web_push"] },
{ "notification_type": "strategy_update", "enabled_channels": ["in_app"] }
]
},
"error": null,
"code": null
}
```
* Status 400: Invalid request parameters or signature
* Status 403: The account doesn't exist. An account exists after its first deposit
* Status 409: You tried to turn on `web_push`, but Web Push isn't available. [Get Web Push config](/api-documentation/api/rest-api/notifications/get-web-push-config) returns `enabled: false` in this case
```json theme={null}
{
"success": false,
"data": null,
"error": "Web Push is disabled",
"code": 409,
"error_id": "web_push_disabled"
}
```
* Status 429: Rate limit exceeded
* Status 500: Internal server error
#### Code Example (Python)
```python theme={null}
import requests
payload = {
"account": "42trU9A5...",
"signature": "5j1Vy9Uq...",
"timestamp": 1716200000000,
"channel": "web_push",
"enabled": True
}
response = requests.post(
"/api/v1/account/notifications/preferences/master",
json=payload,
headers={"Content-Type": "application/json"}
)
data = response.json()
```
# Set Notification Preference
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/notifications/set-notification-preference
This endpoint allows users to turn a channel on or off for one or more notification types.
```http theme={null}
POST /api/v1/account/notifications/preferences
```
This endpoint turns one channel on or off for the notification types that you send. Pacifica changes all the types together or none of them. Other channels keep their current value.
A channel also needs to be on in the master preference. See [Set notification master preference](/api-documentation/api/rest-api/notifications/set-notification-master-preference).
#### Operation Type (for Signing)
| Header Field | Type | Content |
| - | - | - |
| `"type"` | string | `"set_notification_preference"` |
#### Request Body
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | User's wallet address | `42trU9A5...` |
| `"signature"` | string | required | Cryptographic signature | `5j1Vy9Uq...` |
| `"timestamp"` | integer | required | Current timestamp in milliseconds | `1716200000000` |
| `"notification_types"` | array | required | One or more notification types:\
`"deposit_success"`\
`"withdraw_success"`\
`"order_filled"`\
`"order_partially_filled"`\
`"order_canceled"`\
`"tp_sl_triggered"`\
`"liquidation"`\
`"strategy_update"` | `["order_filled"]` |
| `"channel"` | string | required | Channel to change:\
`"in_app"`\
`"mobile_push"`\
`"web_push"` | `mobile_push` |
| `"enabled"` | boolean | required | `true` turns the channel on. `false` turns it off | `true` |
| `"expiry_window"` | integer | optional | Signature expiry in milliseconds | `30000` |
| `"agent_wallet"` | string | optional | Agent wallet address | `69trU9A5...` |
```json theme={null}
{
"account": "42trU9A5...",
"signature": "5j1Vy9Uq...",
"timestamp": 1716200000000,
"notification_types": ["order_filled", "tp_sl_triggered", "liquidation"],
"channel": "mobile_push",
"enabled": true,
"expiry_window": 30000
}
```
You can't set a preference for `test` or for types that Pacifica doesn't send. See [Notification types](/api-documentation/api/rest-api/notifications#notification-types).
You can sign this request with the account key or with an [agent wallet](/api-documentation/api/signing/api-agent-keys).
#### Response
* Status 200: Preference updated. The response has all your preferences after the change, in the same format as [List notification preferences](/api-documentation/api/rest-api/notifications/list-notification-preferences)
```json theme={null}
{
"success": true,
"data": {
"master_enabled_channels": ["in_app", "mobile_push"],
"preferences": [
{ "notification_type": "deposit_success", "enabled_channels": [] },
{ "notification_type": "withdraw_success", "enabled_channels": [] },
{ "notification_type": "order_filled", "enabled_channels": ["mobile_push"] },
{ "notification_type": "order_partially_filled", "enabled_channels": [] },
{ "notification_type": "order_canceled", "enabled_channels": [] },
{ "notification_type": "tp_sl_triggered", "enabled_channels": ["mobile_push"] },
{ "notification_type": "liquidation", "enabled_channels": ["mobile_push"] },
{ "notification_type": "strategy_update", "enabled_channels": [] }
]
},
"error": null,
"code": null
}
```
* Status 400: Invalid request parameters or signature. An empty `notification_types` list, or a type that you can't configure, returns this error:
```json theme={null}
{
"success": false,
"data": null,
"error": "notification_types must not be empty",
"code": 400,
"error_id": "invalid_notification_types"
}
```
* Status 403: The account doesn't exist. An account exists after its first deposit
* Status 429: Rate limit exceeded
* Status 500: Internal server error
#### Code Example (Python)
```python theme={null}
import requests
payload = {
"account": "42trU9A5...",
"signature": "5j1Vy9Uq...",
"timestamp": 1716200000000,
"notification_types": ["order_filled", "tp_sl_triggered", "liquidation"],
"channel": "mobile_push",
"enabled": True
}
response = requests.post(
"/api/v1/account/notifications/preferences",
json=payload,
headers={"Content-Type": "application/json"}
)
data = response.json()
```
# Unregister Expo Device
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/notifications/unregister-expo-device
This endpoint allows users to stop push notifications to an Expo push token or app installation.
```http theme={null}
POST /api/v1/account/notifications/expo/device/unregister
```
This endpoint turns off an Expo push token for your account. Pacifica stops sending `mobile_push` notifications to it. Call it when the user signs out of the app.
#### Operation Type (for Signing)
| Header Field | Type | Content |
| - | - | - |
| `"type"` | string | `"unregister_expo_device"` |
#### Request Body
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | User's wallet address | `42trU9A5...` |
| `"signature"` | string | required | Cryptographic signature | `5j1Vy9Uq...` |
| `"timestamp"` | integer | required | Current timestamp in milliseconds | `1716200000000` |
| `"expo_push_token"` | string | optional | Expo push token to turn off. Up to 512 characters | `ExponentPushToken[xxxx]` |
| `"device_id"` | string | optional | Installation key. Turns off the tokens of this installation. Up to 256 characters | `b7f3c1a9...` |
| `"expiry_window"` | integer | optional | Signature expiry in milliseconds | `30000` |
| `"agent_wallet"` | string | optional | Agent wallet address | `69trU9A5...` |
```json theme={null}
{
"account": "42trU9A5...",
"signature": "5j1Vy9Uq...",
"timestamp": 1716200000000,
"device_id": "b7f3c1a9e2d84f60b1c5a7e9f3d2c4b8",
"expiry_window": 30000
}
```
Send `expo_push_token` or `device_id`. If you send both, Pacifica uses `expo_push_token` only. Leave out the field that you don't send, in the request and in the signed `data`.
Pacifica turns off only tokens of the signing account. An unknown token or `device_id` doesn't cause an error.
You can sign this request with the account key or with an [agent wallet](/api-documentation/api/signing/api-agent-keys).
To get notifications on the device again, call [Register Expo device](/api-documentation/api/rest-api/notifications/register-expo-device).
#### Response
* Status 200: Token turned off
```json theme={null}
{
"success": true,
"data": null,
"error": null,
"code": null
}
```
* Status 400: Invalid request parameters or signature. A token with a bad format returns `error_id` `invalid_expo_push_token`. A request without `expo_push_token` or `device_id` returns this error:
```json theme={null}
{
"success": false,
"data": null,
"error": "Either expo_push_token or device_id is required",
"code": 400,
"error_id": "unspecified"
}
```
* Status 403: The account doesn't exist. An account exists after its first deposit
* Status 429: Rate limit exceeded
* Status 500: Internal server error
#### Code Example (Python)
```python theme={null}
import requests
payload = {
"account": "42trU9A5...",
"signature": "5j1Vy9Uq...",
"timestamp": 1716200000000,
"device_id": "b7f3c1a9e2d84f60b1c5a7e9f3d2c4b8"
}
response = requests.post(
"/api/v1/account/notifications/expo/device/unregister",
json=payload,
headers={"Content-Type": "application/json"}
)
data = response.json()
```
# Unregister Web Push Subscription
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/notifications/unregister-web-push-subscription
This endpoint allows users to stop Web Push notifications to a browser installation.
```http theme={null}
POST /api/v1/account/notifications/web_push/subscription/unregister
```
This endpoint turns off one browser's push subscription on your account. Pacifica stops sending `web_push` notifications to it, and drops pushes that it hasn't sent yet. Call it when the user signs out or switches account.
#### Operation Type (for Signing)
| Header Field | Type | Content |
| - | - | - |
| `"type"` | string | `"unregister_web_push_subscription"` |
#### Request Body
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | User's wallet address | `42trU9A5...` |
| `"signature"` | string | required | Cryptographic signature | `5j1Vy9Uq...` |
| `"timestamp"` | integer | required | Current timestamp in milliseconds | `1716200000000` |
| `"installation_id"` | string | required | The browser's installation ID from [Register Web Push subscription](/api-documentation/api/rest-api/notifications/register-web-push-subscription) | `k3Jx9_Qm...` |
| `"expiry_window"` | integer | optional | Signature expiry in milliseconds | `30000` |
| `"agent_wallet"` | string | optional | Agent wallet address | `69trU9A5...` |
```json theme={null}
{
"account": "42trU9A5...",
"signature": "5j1Vy9Uq...",
"timestamp": 1716200000000,
"installation_id": "k3Jx9_Qm2LpV7nRt4WcY8bZa1HdF6sGe",
"expiry_window": 30000
}
```
Pacifica turns off only a subscription of the signing account. An unknown `installation_id` doesn't cause an error. After you unregister a subscription, [Get Web Push subscription status](/api-documentation/api/rest-api/notifications/get-web-push-subscription-status) returns `disabled`.
You can sign this request with the account key or with an [agent wallet](/api-documentation/api/signing/api-agent-keys).
#### Response
* Status 200: Subscription turned off
```json theme={null}
{
"success": true,
"data": null,
"error": null,
"code": null
}
```
* Status 400: Invalid request parameters or signature. A bad `installation_id` returns `error_id` `invalid_notification_device_id`
* Status 403: The account doesn't exist. An account exists after its first deposit
* Status 429: Rate limit exceeded
* Status 500: Internal server error
#### Code Example (Python)
```python theme={null}
import requests
payload = {
"account": "42trU9A5...",
"signature": "5j1Vy9Uq...",
"timestamp": 1716200000000,
"installation_id": "k3Jx9_Qm2LpV7nRt4WcY8bZa1HdF6sGe"
}
response = requests.post(
"/api/v1/account/notifications/web_push/subscription/unregister",
json=payload,
headers={"Content-Type": "application/json"}
)
data = response.json()
```
# Order Strategies
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/order-strategies
This section covers server-side order strategies such as OCO, conditional, trailing stop, chase, swarm, and TWAP orders.
An order strategy is a rule that Pacifica runs for you on the server. It watches the market and places, reprices, or cancels orders on your account until it finishes. Each strategy has a `strategy_type` and a `params` object. See [Strategy parameters](/api-documentation/api/rest-api/order-strategies/strategy-parameters) for every type.
For how each strategy behaves in the app, see [Order Types](/trading-on-pacifica/order-types).
* [Create order strategy](/api-documentation/api/rest-api/order-strategies/create-order-strategy): This endpoint allows users to create an order strategy.
* [Edit order strategy](/api-documentation/api/rest-api/order-strategies/edit-order-strategy): This endpoint allows users to replace the definition of an open order strategy.
* [Cancel order strategy](/api-documentation/api/rest-api/order-strategies/cancel-order-strategy): This endpoint allows users to cancel an order strategy and its open orders.
* [Get open order strategies](/api-documentation/api/rest-api/order-strategies/get-open-order-strategies): This endpoint allows users to list an account's order strategies that have not finished.
* [Get order strategy history](/api-documentation/api/rest-api/order-strategies/get-order-strategy-history): This endpoint allows users to list an account's finished order strategies.
* [Get order strategy](/api-documentation/api/rest-api/order-strategies/get-order-strategy): This endpoint allows users to get one order strategy by ID.
* [Get order strategy timeline](/api-documentation/api/rest-api/order-strategies/get-order-strategy-timeline): This endpoint allows users to get the lifecycle, order, and trade events of one order strategy.
* [Strategy parameters](/api-documentation/api/rest-api/order-strategies/strategy-parameters): The `params` object for each strategy type.
To stream lifecycle changes, subscribe to [Account order strategy updates](/api-documentation/api/websocket/subscriptions/account-order-strategy-updates).
### Lifecycle
A strategy's `lifecycle` is one of these values:
| `lifecycle` | Meaning |
| - | - |
| `pending` | Waiting for `scheduled_start_at` |
| `open` | Working. `phase` is `armed` while it waits for a trigger, and `running` while it trades |
| `paused` | Paused by a price boundary. It resumes when the price comes back |
| `completed` | Finished its work |
| `cancelled` | Cancelled by you or by the strategy. `terminal_reason` says why |
| `expired` | Reached `expires_at` or `scheduled_end_at` |
| `failed` | Could not continue, for example because its trigger order failed |
When a strategy reaches `cancelled` or `expired`, Pacifica cancels the orders it still has open. Fills that already happened stay.
### Limits
* An account can have up to 100 strategies that have not finished.
* Strategy endpoints accept [agent wallet](/api-documentation/api/signing/api-agent-keys) signatures.
# Cancel Order Strategy
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/order-strategies/cancel-order-strategy
This endpoint allows users to cancel an order strategy and its open orders.
```http theme={null}
POST /api/v1/order_strategies/cancel
```
Cancels the strategy and the orders it still has open. Fills that already happened stay.
#### Operation Type (for Signing)
| Header Field | Type | Content |
| - | - | - |
| `"type"` | string | `"cancel_order_strategy"` |
#### Request Body
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | User's wallet address | `42trU9A5...` |
| `"signature"` | string | required | Cryptographic signature | `5j1Vy9Uq...` |
| `"timestamp"` | integer | required | Current timestamp in milliseconds | `1716200000000` |
| `"strategy_id"` | string | required | Strategy ID (UUID) | `0f8e7c2a-...` |
| `"agent_wallet"` | string | optional | Agent wallet address | `69trU9A5...` |
| `"expiry_window"` | integer | optional | Signature expiry in milliseconds | `30000` |
```json theme={null}
{
"account": "42trU9A5...",
"signature": "5j1Vy9Uq...",
"timestamp": 1716200000000,
"strategy_id": "0f8e7c2a-4b1d-4e5f-9a3b-2c1d0e9f8a7b"
}
```
#### Response
* Status 200: Strategy cancelled
```json theme={null}
{
"success": true,
"data": {
"strategy_id": "0f8e7c2a-4b1d-4e5f-9a3b-2c1d0e9f8a7b"
},
"error": null,
"code": null
}
```
* Status 404: Strategy not found (`STRATEGIST_NOT_FOUND`)
* Status 500: Internal server error
#### Code Example (Python)
```python theme={null}
import requests
payload = {
"account": "42trU9A5...",
"signature": "5j1Vy9Uq...",
"timestamp": 1716200000000,
"strategy_id": "0f8e7c2a-4b1d-4e5f-9a3b-2c1d0e9f8a7b"
}
response = requests.post(
"/api/v1/order_strategies/cancel",
json=payload,
headers={"Content-Type": "application/json"}
)
data = response.json()
```
# Create Order Strategy
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/order-strategies/create-order-strategy
This endpoint allows users to create an order strategy.
```http theme={null}
POST /api/v1/order_strategies/create
```
Creates a server-side [order strategy](/api-documentation/api/rest-api/order-strategies). Pacifica runs it on your account until it completes, is cancelled, or expires.
#### Operation Type (for Signing)
| Header Field | Type | Content |
| - | - | - |
| `"type"` | string | `"create_order_strategy"` |
#### Request Body
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | User's wallet address | `42trU9A5...` |
| `"signature"` | string | required | Cryptographic signature | `5j1Vy9Uq...` |
| `"timestamp"` | integer | required | Current timestamp in milliseconds | `1716200000000` |
| `"strategy_type"` | string | required | Strategy type. See [Strategy parameters](/api-documentation/api/rest-api/order-strategies/strategy-parameters) | `conditional` |
| `"params"` | object | required | Parameters for the strategy type. See [Strategy parameters](/api-documentation/api/rest-api/order-strategies/strategy-parameters) | See below |
| `"scheduled_start_at"` | integer | optional | Start time in milliseconds. Until then, the strategy is `pending` | `1716203600000` |
| `"scheduled_end_at"` | integer | optional | End time in milliseconds. Must be after `scheduled_start_at`. At this time the strategy expires | `1716207200000` |
| `"expires_at"` | integer | optional | Expiry time in milliseconds. At this time the strategy expires | `1716207200000` |
| `"agent_wallet"` | string | optional | Agent wallet address | `69trU9A5...` |
| `"expiry_window"` | integer | optional | Signature expiry in milliseconds | `30000` |
When a strategy expires, Pacifica cancels the orders it still has open.
```json theme={null}
{
"account": "42trU9A5...",
"signature": "5j1Vy9Uq...",
"timestamp": 1716200000000,
"strategy_type": "conditional",
"params": {
"trigger_symbol": "BTC",
"trigger_price_type": "mark",
"trigger_direction": "gte",
"trigger_price": "66000",
"execution_symbol": "BTC",
"side": "bid",
"amount": "0.01",
"order_type": "market",
"reduce_only": false
},
"expires_at": 1716286400000,
"expiry_window": 30000
}
```
#### Signing
Sign `strategy_type`, `params`, and any schedule fields as the `data` object, like any other request. See [Signing](/api-documentation/api/signing/implementation). Keys inside `params` are sorted too. For the request above, the message to sign is:
```json theme={null}
{"data":{"expires_at":1716286400000,"params":{"amount":"0.01","execution_symbol":"BTC","order_type":"market","reduce_only":false,"side":"bid","trigger_direction":"gte","trigger_price":"66000","trigger_price_type":"mark","trigger_symbol":"BTC"},"strategy_type":"conditional"},"expiry_window":30000,"timestamp":1716200000000,"type":"create_order_strategy"}
```
#### Response
* Status 200: Strategy created
```json theme={null}
{
"success": true,
"data": {
"strategy_id": "0f8e7c2a-4b1d-4e5f-9a3b-2c1d0e9f8a7b",
"revision": 1
},
"error": null,
"code": null
}
```
| Field | Type | Description |
| - | - | - |
| `'strategy_id'` | string | Strategy ID (UUID) |
| `'revision'` | integer | Revision of the strategy definition. Send it as `expected_revision` to [edit](/api-documentation/api/rest-api/order-strategies/edit-order-strategy) the strategy |
* Status 400: Invalid parameters, or the account cannot run the strategy. The `error` field says why, for example `invalid strategy definition: clip count must be between 2 and 100` or `STRATEGIST_INSUFFICIENT_BALANCE`
```json theme={null}
{
"success": false,
"data": null,
"error": "invalid strategy definition: exactly two OCO legs are required",
"code": 400
}
```
* Status 429: The account already has 100 strategies that have not finished (`STRATEGIST_ORDER_STRATEGY_LIMIT_REACHED`), or the rate limit is exceeded
* Status 500: Internal server error
* Status 503: The strategy service is not ready. Retry later
Other `error` values with status 400:
| `error` | Meaning |
| - | - |
| `STRATEGIST_BELOW_MIN_NOTIONAL` | An order or clip would be below the market's minimum order size |
| `STRATEGIST_INSUFFICIENT_BALANCE` | The account cannot afford the strategy |
| `STRATEGIST_BOUNDARY_ALREADY_CROSSED` | The swarm boundary is already crossed |
| `STRATEGIST_NO_POSITION` | A position exit has no open position |
| `STRATEGIST_POSITION_ID_MISMATCH` | `position_id` does not match the current position |
| `STRATEGIST_INVALID_POSITION_EXIT` | The position exit side or amount does not fit the position |
| `STRATEGIST_UNSUPPORTED_SIZING` | The `size_mode` is not supported for this strategy |
| `STRATEGIST_STRATEGY_TYPE_DISABLED` | The strategy type is turned off |
#### Code Example (Python)
```python theme={null}
import requests
payload = {
"account": "42trU9A5...",
"signature": "5j1Vy9Uq...",
"timestamp": 1716200000000,
"strategy_type": "twap",
"params": {
"symbol": "BTC",
"side": "ask",
"amount": "1",
"reduce_only": False,
"duration_seconds": 3600,
"randomize": False
}
}
response = requests.post(
"/api/v1/order_strategies/create",
json=payload,
headers={"Content-Type": "application/json"}
)
data = response.json()
```
# Edit Order Strategy
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/order-strategies/edit-order-strategy
This endpoint allows users to replace the definition of an open order strategy.
```http theme={null}
POST /api/v1/order_strategies/edit
```
Replaces a strategy's `params` and schedule. Send the full definition, not only the fields that change.
#### Operation Type (for Signing)
| Header Field | Type | Content |
| - | - | - |
| `"type"` | string | `"edit_order_strategy"` |
#### Request Body
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | User's wallet address | `42trU9A5...` |
| `"signature"` | string | required | Cryptographic signature | `5j1Vy9Uq...` |
| `"timestamp"` | integer | required | Current timestamp in milliseconds | `1716200000000` |
| `"strategy_id"` | string | required | Strategy ID (UUID) | `0f8e7c2a-...` |
| `"expected_revision"` | integer | required | The strategy's current `revision`. The edit fails if the strategy changed since you read it | `1` |
| `"strategy_type"` | string | required | Must match the strategy's current type | `trailing_stop` |
| `"params"` | object | required | New parameters. See [Strategy parameters](/api-documentation/api/rest-api/order-strategies/strategy-parameters) | See below |
| `"scheduled_start_at"` | integer | optional | Start time in milliseconds. Can change only while the strategy is `pending` | `1716203600000` |
| `"scheduled_end_at"` | integer | optional | End time in milliseconds | `1716207200000` |
| `"expires_at"` | integer | optional | Expiry time in milliseconds | `1716207200000` |
| `"agent_wallet"` | string | optional | Agent wallet address | `69trU9A5...` |
| `"expiry_window"` | integer | optional | Signature expiry in milliseconds | `30000` |
```json theme={null}
{
"account": "42trU9A5...",
"signature": "5j1Vy9Uq...",
"timestamp": 1716200000000,
"strategy_id": "0f8e7c2a-4b1d-4e5f-9a3b-2c1d0e9f8a7b",
"expected_revision": 1,
"strategy_type": "trailing_stop",
"params": {
"symbol": "BTC",
"side": "ask",
"direction": "exit",
"size_mode": "defined",
"amount": "0.1",
"trail_bps": 300,
"trigger_price_type": "mid",
"child_order_type": "market",
"reduce_only": true
}
}
```
#### What you can edit
* A strategy that has not placed any orders yet. This includes a strategy that is `pending`, or `open` and waiting for its trigger.
* A trailing stop that is already tracking the price. You can change its trail and other settings, but not `symbol` or `side`.
You cannot edit a strategy that is `paused` or finished, or a trigger swarm that has already triggered.
#### Response
* Status 200: Strategy updated
```json theme={null}
{
"success": true,
"data": {
"strategy_id": "0f8e7c2a-4b1d-4e5f-9a3b-2c1d0e9f8a7b",
"revision": 2
},
"error": null,
"code": null
}
```
| Field | Type | Description |
| - | - | - |
| `'strategy_id'` | string | Strategy ID (UUID) |
| `'revision'` | integer | New revision. Use it for the next edit |
* Status 400: Invalid parameters, or the strategy cannot be edited. `STRATEGIST_NOT_EDITABLE` means the strategy's state does not allow edits. `STRATEGIST_FIELD_NOT_EDITABLE` means you changed a field that is fixed, such as `strategy_type`
* Status 404: Strategy not found (`STRATEGIST_NOT_FOUND`)
* Status 422: `expected_revision` does not match (`STRATEGIST_REVISION_CONFLICT`). Read the strategy again and retry
* Status 500: Internal server error
#### Code Example (Python)
```python theme={null}
import requests
payload = {
"account": "42trU9A5...",
"signature": "5j1Vy9Uq...",
"timestamp": 1716200000000,
"strategy_id": "0f8e7c2a-4b1d-4e5f-9a3b-2c1d0e9f8a7b",
"expected_revision": 1,
"strategy_type": "trailing_stop",
"params": {
"symbol": "BTC",
"side": "ask",
"direction": "exit",
"size_mode": "defined",
"amount": "0.1",
"trail_bps": 300,
"trigger_price_type": "mid",
"child_order_type": "market",
"reduce_only": True
}
}
response = requests.post(
"/api/v1/order_strategies/edit",
json=payload,
headers={"Content-Type": "application/json"}
)
data = response.json()
```
# Get Open Order Strategies
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/order-strategies/get-open-order-strategies
This endpoint allows users to list an account's order strategies that have not finished.
```http theme={null}
GET /api/v1/order_strategies
```
Returns strategies that are `pending`, `open`, or `paused`.
#### Query Parameters
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | Account address | `42trU9A5...` |
| `"type"` | string | optional | Only return this strategy type: `oco`, `conditional`, `trailing_stop`, `auto_chase`, `swarm`, `trigger_swarm`, or `twap` | `twap` |
| `"limit"` | integer | optional | Maximum number of strategies to return, 1 to 500. Defaults to 100 | `100` |
| `"offset"` | integer | optional | Number of strategies to skip. Defaults to 0 | `0` |
```
/api/v1/order_strategies?account=42trU9A5...
```
#### Response
* Status 200: Successfully retrieved strategies
```json theme={null}
{
"success": true,
"data": {
"strategies": [
{
"strategy_id": "0f8e7c2a-4b1d-4e5f-9a3b-2c1d0e9f8a7b",
"revision": 1,
"account": "42trU9A5...",
"strategy_type": "twap",
"definition": {
"strategy_type": "twap",
"params": {
"symbol": "BTC",
"side": "ask",
"amount": "1",
"reduce_only": false,
"duration_seconds": 3600,
"randomize": false
}
},
"lifecycle": "open",
"phase": "running",
"state": {
// Progress for this strategy type
},
"applied_trade_history_id": 0,
"applied_order_history_id": 0,
"expires_at_ms": null,
"scheduled_start_at_ms": null,
"scheduled_end_at_ms": null,
"created_at_ms": 1716200000000,
"updated_at_ms": 1716203600000,
"owned_orders": []
}
],
"total": 1,
"limit": 100,
"offset": 0,
"has_more": false
},
"error": null,
"code": null
}
```
| Field | Type | Description |
| - | - | - |
| `'strategies'` | array | Strategies. Each has the fields in [Get order strategy](/api-documentation/api/rest-api/order-strategies/get-order-strategy) |
| `'total'` | integer | Total number of matching strategies |
| `'limit'` | integer | Limit used |
| `'offset'` | integer | Offset used |
| `'has_more'` | boolean | Whether more strategies exist after this page |
* Status 400: Invalid query parameters, for example an unknown `type`
* Status 500: Internal server error
#### Code Example (Python)
```python theme={null}
import requests
response = requests.get(
"/api/v1/order_strategies?account=42trU9A5...",
headers={"Accept": "*/*"},
)
data = response.json()
```
# Get Order Strategy
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/order-strategies/get-order-strategy
This endpoint allows users to get one order strategy by ID.
```http theme={null}
GET /api/v1/order_strategies/{strategy_id}
```
#### Query Parameters
| Field | Type | Need | Description | Example |
|---|
| `"strategy_id"` | string | required | Strategy ID (UUID), in the path | `0f8e7c2a-...` |
| `"account"` | string | required | Account address that owns the strategy | `42trU9A5...` |
```
/api/v1/order_strategies/0f8e7c2a-4b1d-4e5f-9a3b-2c1d0e9f8a7b?account=42trU9A5...
```
#### Response
* Status 200: Successfully retrieved the strategy
```json theme={null}
{
"success": true,
"data": {
"strategy_id": "0f8e7c2a-4b1d-4e5f-9a3b-2c1d0e9f8a7b",
"revision": 1,
"account": "42trU9A5...",
"strategy_type": "conditional",
"definition": {
"strategy_type": "conditional",
"params": {
"trigger_symbol": "BTC",
"trigger_price_type": "mark",
"trigger_direction": "gte",
"trigger_price": "66000",
"execution_symbol": "BTC",
"side": "bid",
"amount": "0.01",
"order_type": "market",
"reduce_only": false
}
},
"lifecycle": "open",
"phase": "armed",
"state": {
// Progress for this strategy type
},
"applied_trade_history_id": 0,
"applied_order_history_id": 0,
"expires_at_ms": 1716286400000,
"scheduled_start_at_ms": null,
"scheduled_end_at_ms": null,
"created_at_ms": 1716200000000,
"updated_at_ms": 1716200000000,
"owned_orders": []
},
"error": null,
"code": null
}
```
| Field | Type | Description |
| - | - | - |
| `'strategy_id'` | string | Strategy ID (UUID) |
| `'revision'` | integer | Revision of the definition. Increases on each edit |
| `'account'` | string | Account address |
| `'strategy_type'` | string | Strategy type |
| `'definition'` | object | The `strategy_type` and `params` the strategy runs with. See [Strategy parameters](/api-documentation/api/rest-api/order-strategies/strategy-parameters) |
| `'lifecycle'` | string | `pending`, `open`, `paused`, `completed`, `cancelled`, `expired`, or `failed`. See [Lifecycle](/api-documentation/api/rest-api/order-strategies#lifecycle) |
| `'phase'` | string | Only while `open`: `armed` (waiting for a trigger) or `running` |
| `'terminal_reason'` | string | Only for some finished strategies. Why the strategy stopped, for example `user_cancel`, `boundary_cancel`, or `insufficient_balance` |
| `'state'` | object | Progress for this strategy type. The fields depend on the type |
| `'applied_trade_history_id'` | integer | Last trade history ID the strategy has processed |
| `'applied_order_history_id'` | integer | Last order history ID the strategy has processed |
| `'expires_at_ms'` | integer or null | Expiry time in milliseconds |
| `'scheduled_start_at_ms'` | integer or null | Start time in milliseconds |
| `'scheduled_end_at_ms'` | integer or null | End time in milliseconds |
| `'created_at_ms'` | integer | Creation time in milliseconds |
| `'updated_at_ms'` | integer | Last update time in milliseconds |
| `'owned_orders'` | array | Orders the strategy placed. See below |
**Owned order fields**
| Field | Type | Description |
| - | - | - |
| `'order_id'` | integer | Order ID |
| `'prev_order_id'` | integer or null | The order this one replaced, for example when a chase reprices |
| `'is_open'` | boolean | Whether the order is still open |
| `'client_order_id'` | string or null | Client order ID |
| `'take_profit_client_order_id'` | string or null | Client order ID of the attached take profit |
| `'stop_loss_client_order_id'` | string or null | Client order ID of the attached stop loss |
Orders that a strategy places carry its ID as `parent_id` in [Get open orders](/api-documentation/api/rest-api/orders/get-open-orders) and order history.
* Status 404: Strategy not found, or it belongs to another account
* Status 500: Internal server error
#### Code Example (Python)
```python theme={null}
import requests
response = requests.get(
"/api/v1/order_strategies/0f8e7c2a-4b1d-4e5f-9a3b-2c1d0e9f8a7b?account=42trU9A5...",
headers={"Accept": "*/*"},
)
data = response.json()
```
# Get Order Strategy History
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/order-strategies/get-order-strategy-history
This endpoint allows users to list an account's finished order strategies.
```http theme={null}
GET /api/v1/order_strategies/history
```
Returns strategies that are `completed`, `cancelled`, `expired`, or `failed`.
#### Query Parameters
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | Account address | `42trU9A5...` |
| `"type"` | string | optional | Only return this strategy type: `oco`, `conditional`, `trailing_stop`, `auto_chase`, `swarm`, `trigger_swarm`, or `twap` | `twap` |
| `"limit"` | integer | optional | Maximum number of strategies to return, 1 to 500. Defaults to 100 | `100` |
| `"offset"` | integer | optional | Number of strategies to skip. Defaults to 0 | `0` |
```
/api/v1/order_strategies/history?account=42trU9A5...&limit=50
```
#### Response
* Status 200: Successfully retrieved strategies
```json theme={null}
{
"success": true,
"data": {
"strategies": [
{
"strategy_id": "0f8e7c2a-4b1d-4e5f-9a3b-2c1d0e9f8a7b",
"revision": 1,
"account": "42trU9A5...",
"strategy_type": "twap",
"definition": {
"strategy_type": "twap",
"params": {
"symbol": "BTC",
"side": "ask",
"amount": "1",
"reduce_only": false,
"duration_seconds": 3600,
"randomize": false
}
},
"lifecycle": "completed",
"state": {
// Progress for this strategy type
},
"applied_trade_history_id": 0,
"applied_order_history_id": 0,
"expires_at_ms": null,
"scheduled_start_at_ms": null,
"scheduled_end_at_ms": null,
"created_at_ms": 1716200000000,
"updated_at_ms": 1716203600000,
"owned_orders": []
}
],
"total": 1,
"limit": 100,
"offset": 0,
"has_more": false
},
"error": null,
"code": null
}
```
| Field | Type | Description |
| - | - | - |
| `'strategies'` | array | Strategies. Each has the fields in [Get order strategy](/api-documentation/api/rest-api/order-strategies/get-order-strategy) |
| `'total'` | integer | Total number of matching strategies |
| `'limit'` | integer | Limit used |
| `'offset'` | integer | Offset used |
| `'has_more'` | boolean | Whether more strategies exist after this page |
* Status 400: Invalid query parameters, for example an unknown `type`
* Status 500: Internal server error
#### Code Example (Python)
```python theme={null}
import requests
response = requests.get(
"/api/v1/order_strategies/history?account=42trU9A5...&limit=50",
headers={"Accept": "*/*"},
)
data = response.json()
```
# Get Order Strategy Timeline
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/order-strategies/get-order-strategy-timeline
This endpoint allows users to get the lifecycle, order, and trade events of one order strategy.
```http theme={null}
GET /api/v1/order_strategies/{strategy_id}/timeline
```
Returns the strategy's lifecycle changes, the orders it placed, and the trades of those orders, oldest first.
#### Query Parameters
| Field | Type | Need | Description | Example |
|---|
| `"strategy_id"` | string | required | Strategy ID (UUID), in the path | `0f8e7c2a-...` |
| `"account"` | string | required | Account address that owns the strategy | `42trU9A5...` |
```
/api/v1/order_strategies/0f8e7c2a-4b1d-4e5f-9a3b-2c1d0e9f8a7b/timeline?account=42trU9A5...
```
#### Response
* Status 200: Successfully retrieved the timeline
```json theme={null}
{
"success": true,
"data": [
{
"kind": "lifecycle",
"lifecycle": "active",
"terminal_reason": null,
"created_at": "2026-10-20T08:00:00Z"
},
{
"kind": "order",
"order_id": 315979358,
"order_status": "filled",
"order_type": "market",
"price": "66012",
"amount": "0.01",
"created_at": "2026-10-20T09:14:02Z"
},
{
"kind": "trade",
"order_id": 315979358,
"price": "66012",
"amount": "0.01",
"created_at": "2026-10-20T09:14:02Z"
},
{
"kind": "lifecycle",
"lifecycle": "completed",
"terminal_reason": null,
"created_at": "2026-10-20T09:14:02Z"
}
],
"error": null,
"code": null
}
```
Each entry has a `kind` and the fields for that kind:
| `kind` | Fields |
| - | - |
| `lifecycle` | `lifecycle`, `terminal_reason`, `created_at` |
| `order` | `order_id`, `order_status` (`open`, `partially_filled`, `filled`, `cancelled`, `rejected`), `order_type`, `price`, `amount`, `created_at` |
| `trade` | `order_id`, `price`, `amount`, `created_at` |
`created_at` is an ISO 8601 timestamp.
> [!NOTE]
>
> Timeline `lifecycle` values are more detailed than the `lifecycle` field of a strategy: `pending`, `active` (waiting for a trigger), `running`, `paused`, `completed`, `cancelled`, `trigger_failed`, `expired`, and `failed`.
* Status 404: Strategy not found, or it belongs to another account
* Status 500: Internal server error
#### Code Example (Python)
```python theme={null}
import requests
response = requests.get(
"/api/v1/order_strategies/0f8e7c2a-4b1d-4e5f-9a3b-2c1d0e9f8a7b/timeline?account=42trU9A5...",
headers={"Accept": "*/*"},
)
data = response.json()
```
# Strategy Parameters
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/order-strategies/strategy-parameters
The params object for each order strategy type.
[Create order strategy](/api-documentation/api/rest-api/order-strategies/create-order-strategy) and [Edit order strategy](/api-documentation/api/rest-api/order-strategies/edit-order-strategy) take a `strategy_type` and a `params` object. This page lists the `params` fields for each type. Unknown fields are rejected.
| `strategy_type` | Strategy |
| - | - |
| `oco` | [OCO](#oco): two stop legs, the first to trigger cancels the other |
| `conditional` | [Conditional](#conditional): one market or limit order when a price condition is met |
| `trailing_stop` | [Trailing stop](#trailing-stop): a market order when the price retraces by a trail distance |
| `auto_chase` | [Chase](#chase): a post-only limit order that follows the best bid or ask |
| `swarm` | [Swarm](#swarm): an amount split into market orders placed in quick succession |
| `trigger_swarm` | [Trigger swarm](#trigger-swarm): a swarm that starts when a price condition is met |
| `twap` | [TWAP](#twap): an amount split into market orders spread over time |
### Common values
| Field | Values |
| - | - |
| `side` | `bid` (buy) or `ask` (sell) |
| `trigger_direction` | `gte`: trigger when the price is at or above `trigger_price`. `lte`: at or below |
| `trigger_price_type` | `mark`, `mid`, `last`, `best_bid`, `best_ask`. Each type below says which values it accepts |
| `order_type`, `child_order_type` | `market` or `limit` |
| `boundary_action` | `pause` or `cancel` |
| `slippage_percent` | Max slippage for market orders, above 0 and at most 100. If omitted, Pacifica uses a default |
Send prices and amounts as decimal strings, for example `"0.01"`.
#### Take profit and stop loss
`take_profit` and `stop_loss` attach to the position that the strategy opens. You cannot use them with `reduce_only: true`.
| Field | Type | Need | Description |
| - | - | - | - |
| `stop_price` | decimal string | required | Trigger price |
| `limit_price` | decimal string | optional | Limit price. If omitted, the triggered order is a market order |
| `trigger_price_type` | string | optional | `mark`, `mid`, or `last` |
### OCO
Two stop legs on one market. The first leg whose trigger is crossed is placed as an order, and the other leg is cancelled. If both trigger in the same check, the first leg in `legs` wins. See [OCO](/trading-on-pacifica/order-types/strategies/oco).
| Field | Type | Need | Description |
| - | - | - | - |
| `symbol` | string | required | Market |
| `legs` | array | required | Exactly two legs. See below |
| `reduce_only` | boolean | required | Whether the triggered order is reduce-only |
| `slippage_percent` | decimal string | optional | Only allowed if at least one leg is a `market` leg |
Each leg:
| Field | Type | Need | Description |
| - | - | - | - |
| `trigger_price_type` | string | required | `mark` or `mid` |
| `trigger_direction` | string | required | `gte` or `lte` |
| `trigger_price` | decimal string | required | Trigger price |
| `side` | string | required | `bid` or `ask` |
| `amount` | decimal string | required | Order amount |
| `order_type` | string | required | `market`, or `limit` for a GTC limit order |
| `limit_price` | decimal string | conditional | Required for a `limit` leg. Not allowed for a `market` leg |
```json theme={null}
{
"strategy_type": "oco",
"params": {
"symbol": "BTC",
"reduce_only": true,
"legs": [
{"trigger_price_type": "mark", "trigger_direction": "gte", "trigger_price": "70000", "side": "ask", "amount": "0.01", "order_type": "market"},
{"trigger_price_type": "mark", "trigger_direction": "lte", "trigger_price": "60000", "side": "ask", "amount": "0.01", "order_type": "limit", "limit_price": "59950"}
]
}
}
```
### Conditional
Places one order when a price condition is met. The trigger can watch a different market from the one you trade. The strategy places one order and does not trigger again. See [Conditional Market](/trading-on-pacifica/order-types/strategies/conditional-market) and [Conditional Limit](/trading-on-pacifica/order-types/strategies/conditional-limit).
| Field | Type | Need | Description |
| - | - | - | - |
| `trigger_symbol` | string | required | Market whose price is watched |
| `trigger_price_type` | string | required | `mark`, `mid`, `last`, `best_bid`, or `best_ask` |
| `trigger_direction` | string | required | `gte` or `lte` |
| `trigger_price` | decimal string | required | Trigger price |
| `execution_symbol` | string | required | Market to trade |
| `side` | string | required | `bid` or `ask` |
| `amount` | decimal string | required | Order amount |
| `order_type` | string | required | `market` or `limit` |
| `limit_price` | decimal string | conditional | Required for `limit`. Not allowed for `market` |
| `tif` | string | conditional | `GTC`, `IOC`, `ALO`, or `TOB`. Required for `limit`. Not allowed for `market` |
| `reduce_only` | boolean | required | Whether the order is reduce-only |
| `take_profit` | object | optional | See [Take profit and stop loss](#take-profit-and-stop-loss) |
| `stop_loss` | object | optional | See [Take profit and stop loss](#take-profit-and-stop-loss) |
| `slippage_percent` | decimal string | optional | Only for `market` |
```json theme={null}
{
"strategy_type": "conditional",
"params": {
"trigger_symbol": "BTC",
"trigger_price_type": "mid",
"trigger_direction": "lte",
"trigger_price": "62000",
"execution_symbol": "BTC",
"side": "ask",
"amount": "0.02",
"order_type": "limit",
"limit_price": "61950",
"tif": "GTC",
"reduce_only": true
}
}
```
### Trailing stop
Tracks the best price since activation: the peak for a sell, the trough for a buy. When the price retraces by the trail distance, it places a market order. It triggers once. See [Trailing Stop](/trading-on-pacifica/order-types/strategies/trailing-stop).
| Field | Type | Need | Description |
| - | - | - | - |
| `symbol` | string | required | Market |
| `side` | string | required | `bid` or `ask` |
| `direction` | string | required | `exit` to close a position, or `entry` to open one |
| `size_mode` | string | required | `defined` uses `amount`. `full_position` closes the whole position at trigger time and needs `reduce_only: true` |
| `amount` | decimal string | conditional | Required for `defined`. Not allowed for `full_position` |
| `trail_bps` | integer | conditional | Trail distance in basis points, 1 to 9999 (0.01% to 99.99%). Send exactly one of `trail_bps` and `trail_value` |
| `trail_value` | decimal string | conditional | Trail distance as a price amount |
| `trigger_price_type` | string | required | `mark`, `mid`, or `last` |
| `child_order_type` | string | required | Must be `market` |
| `activation_price` | decimal string | optional | Tracking starts when the price reaches this level: rises to it for a sell, falls to it for a buy. If omitted, tracking starts at once |
| `reduce_only` | boolean | required | Whether the order is reduce-only |
| `purpose` | string | optional | `standard` (default) or `position_exit`. See below |
| `position_id` | string | conditional | Required for `position_exit`. Not allowed for `standard` |
| `slippage_percent` | decimal string | optional | Max slippage for the market order |
`position_exit` ties the trailing stop to one position. Set `position_id` to the position's `id` from [Get positions](/api-documentation/api/rest-api/account/get-positions), with `direction: "exit"` and `reduce_only: true`. The strategy is cancelled if that position is gone or has been replaced by a new one.
```json theme={null}
{
"strategy_type": "trailing_stop",
"params": {
"symbol": "BTC",
"side": "ask",
"direction": "exit",
"size_mode": "defined",
"amount": "0.1",
"trail_bps": 200,
"trigger_price_type": "mid",
"child_order_type": "market",
"reduce_only": true
}
}
```
### Chase
Rests a post-only (ALO) limit order at the best bid for a buy, or the best ask for a sell. When that price moves, Pacifica reprices the unfilled amount. See [Chase](/trading-on-pacifica/order-types/strategies/chase).
| Field | Type | Need | Description |
| - | - | - | - |
| `symbol` | string | required | Market |
| `side` | string | required | `bid` or `ask` |
| `amount` | decimal string | required | Total amount |
| `reduce_only` | boolean | required | Whether the orders are reduce-only |
| `mode` | string | required | `till_fill` chases until filled. `to_price` stops at `chase_to_price` |
| `chase_to_price` | decimal string | conditional | Furthest price to chase to: a ceiling for a buy, a floor for a sell. Required for `to_price`. Not allowed for `till_fill` |
| `boundary_action` | string | conditional | What happens past `chase_to_price`: `pause` or `cancel`. Required for `to_price`. Not allowed for `till_fill` |
| `take_profit` | object | optional | See [Take profit and stop loss](#take-profit-and-stop-loss) |
| `stop_loss` | object | optional | See [Take profit and stop loss](#take-profit-and-stop-loss) |
### Swarm
Splits an amount into market orders, called clips, placed in quick succession. See [Swarm](/trading-on-pacifica/order-types/strategies/swarm).
| Field | Type | Need | Description |
| - | - | - | - |
| `symbol` | string | required | Market |
| `side` | string | required | `bid` or `ask` |
| `amount` | decimal string | required | Total amount |
| `reduce_only` | boolean | required | Whether the clips are reduce-only |
| `number_of_clips` | integer | required | 2 to 100. Each clip must meet the market's minimum order size |
| `placement_speed_clips_per_second` | integer | required | 1 to 10 |
| `randomize_clips` | boolean | required | Vary clip sizes and gaps |
| `boundary_price` | decimal string | optional | Mark price limit: a ceiling for a buy, a floor for a sell. Send with `boundary_action` |
| `boundary_action` | string | optional | `pause` or `cancel` when the mark crosses `boundary_price`. Send with `boundary_price` |
| `take_profit` | object | optional | See [Take profit and stop loss](#take-profit-and-stop-loss) |
| `stop_loss` | object | optional | See [Take profit and stop loss](#take-profit-and-stop-loss) |
| `slippage_percent` | decimal string | optional | Max slippage for each clip |
A swarm whose boundary is already crossed when you create it is rejected.
### Trigger swarm
Waits for a price condition, then places clips one at a time. See [Trigger Swarm](/trading-on-pacifica/order-types/strategies/trigger-swarm).
| Field | Type | Need | Description |
| - | - | - | - |
| `trigger_symbol` | string | required | Market whose price is watched |
| `trigger_price_type` | string | required | `mark`, `mid`, `last`, `best_bid`, or `best_ask` |
| `trigger_direction` | string | required | `gte` or `lte` |
| `trigger_price` | decimal string | required | Trigger price |
| `execution_symbol` | string | required | Market to trade |
| `side` | string | required | `bid` or `ask` |
| `size_mode` | string | required | `defined` uses `amount`. `full_position` targets the whole position at trigger time and needs `purpose: "position_exit"` |
| `amount` | decimal string | conditional | Required for `defined`. Not allowed for `full_position` |
| `number_of_clips` | integer | required | 2 to 100 |
| `target_duration_seconds` | integer | optional | Spread the clips evenly over this many seconds. If omitted, each clip goes out once the previous one settles |
| `child_order_type` | string | required | Must be `market` |
| `reduce_only` | boolean | required | Whether the clips are reduce-only |
| `purpose` | string | optional | `standard` (default) or `position_exit` |
| `position_id` | string | conditional | Required for `position_exit`, which also needs `reduce_only: true`. Not allowed for `standard` |
| `slippage_percent` | decimal string | optional | Max slippage for each clip |
### TWAP
Splits an amount into market orders, called slices, spread over `duration_seconds`. Pacifica plans 2 to 100 slices based on the duration and the market's lot size. See [TWAP](/trading-on-pacifica/order-types/classic/twap).
| Field | Type | Need | Description |
| - | - | - | - |
| `symbol` | string | required | Market |
| `side` | string | required | `bid` or `ask` |
| `amount` | decimal string | required | Total amount |
| `reduce_only` | boolean | required | Whether the slices are reduce-only |
| `duration_seconds` | integer | required | Total running time in seconds. Must be positive |
| `randomize` | boolean | required | Vary slice sizes and gaps |
| `slippage_percent` | decimal string | optional | Max slippage for each slice |
| `price_limit` | decimal string | optional | Pause a buy while the mark is at or above this price, or a sell while it is at or below. Resumes when the price comes back |
```json theme={null}
{
"strategy_type": "twap",
"params": {
"symbol": "BTC",
"side": "ask",
"amount": "1",
"reduce_only": false,
"duration_seconds": 5400,
"randomize": true,
"price_limit": "95000"
}
}
```
# Orders
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/orders
This section covers details for interacting with current and historical orders on Pacifica.
* [Create market order](/api-documentation/api/rest-api/orders/create-market-order): This endpoint allows users to create a new market order with optional take profit and stop loss levels.
* [Create limit order](/api-documentation/api/rest-api/orders/create-limit-order): This endpoint allows users to create a new limit order with optional take profit and stop loss levels.
* [Create stop order](/api-documentation/api/rest-api/orders/create-stop-order): This endpoint allows users to create stop order.
* [Create position TP/SL](/api-documentation/api/rest-api/orders/create-position-tp-sl): This endpoint allows users to set take profit and stop loss levels for an existing position.
* [Cancel order](/api-documentation/api/rest-api/orders/cancel-order): This endpoint allows users to cancel an existing order.
* [Cancel all orders](/api-documentation/api/rest-api/orders/cancel-all-orders): This endpoint allows users to cancel all orders for all/given symbol(s).
* [Cancel stop order](/api-documentation/api/rest-api/orders/cancel-stop-order): This endpoint allows users to cancel a stop order by its (CL)OID.
* [Edit order](/api-documentation/api/rest-api/orders/edit-order): This endpoint allows users to edit an existing limit order by modifying its size and/or price.
* [Batch order](/api-documentation/api/rest-api/orders/batch-order): This endpoint allows users to submit multiple order operations in a single request. Batched orders are executed in the order they are batched in, and will not be split up by other users' orders.
* [Get open orders](/api-documentation/api/rest-api/orders/get-open-orders): This endpoint allows users to get open orders on their account.
* [Get order history](/api-documentation/api/rest-api/orders/get-order-history): This endpoint allows users to get a summarized order history.
* [Get order history by ID](/api-documentation/api/rest-api/orders/get-order-history-by-id): This endpoint allows users to get order history by id.
* [Get order history records](/api-documentation/api/rest-api/orders/get-order-history-records): This endpoint allows users to get order history and finished order strategies in one list.
# Batch Order
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/orders/batch-order
This endpoint allows users to submit multiple order operations in a single request. Batched orders are executed in the order they are batched in, and will not be split up by other users' orders.
The [Pacifica Python SDK](https://github.com/pacifica-fi/python-sdk/blob/f2385d42e9ae5276ba2ba85505d51db2eefd2715/rest/batch_orders.py) provides a comprehensive example on using this endpoint
```http theme={null}
POST /api/v1/orders/batch
```
#### Operation Type (for Signing)
| Header Field | Type | Content |
|---|
| None | - | Batch orders are not signed as a whole, but rather by its individual actions components. |
#### Request Body
| Field | Type | Need | Description | Example |
|---|
| `"actions"` | array | required | List of order actions to perform\
\
Each action has a "type" field and action-specific "data" | See next two rows |
| `"type"` | string | required | Specifies type of action. This is DIFFERENT to the "type" used in signature headers | `"Create"`\
`"CreateMarket"`\
`"Cancel"`\
`"Edit"`\
`"SetPositionTpsl"`\
`"CancelStopOrder"`\
(case sensitive) |
| `"data"` | object | required | Contains signed request payloads of individual actions. Fields are identical to the corresponding standalone endpoints: create limit order, create market order, cancel order, edit order, create position TP/SL, and cancel stop order. | See code block below. Messages and corresponding fields are identical to [create](/api-documentation/api/rest-api/orders/create-limit-order) and [cancel](/api-documentation/api/rest-api/orders/cancel-order) requests. |
```json theme={null}
{
"actions":[
{
"type":"Create",
"data":{
"account":"42trU9A5...",
"signature":"5UpRZ14Q...",
"timestamp":1749190500355,
"expiry_window":5000,
"symbol":"BTC",
"price":"100000",
"reduce_only":false,
"amount":"0.1",
"side":"bid",
"tif":"GTC",
"client_order_id":"57a5efb1-bb96-49a5-8bfd-f25d5f22bc7e"
}
},
{
"type":"CreateMarket",
"data":{
"account":"42trU9A5...",
"signature":"3KxMn7pQ...",
"timestamp":1749190500355,
"expiry_window":5000,
"symbol":"ETH",
"amount":"1.0",
"side":"ask",
"slippage_percent":"0.5",
"reduce_only":false
}
},
{
"type":"Cancel",
"data":{
"account":"42trU9A5...",
"signature":"4NDFHyTG...",
"timestamp":1749190500355,
"expiry_window":5000,
"symbol":"BTC",
"order_id":42069
}
}
]
}
```
#### Response
* Status 200: Batch operations processed successfully
```json theme={null}
{
"success": true,
"data": {
"results": [
{
"success": true,
"order_id": 470506,
"error": null
},
{
"success": true,
"order_id": null,
"error": null
}
]
},
"error": null,
"code": null
}
```
* Status 400: Bad request
```json theme={null}
{
"error": "Invalid batch operation parameters",
"code": 400
}
```
* Status 500: Internal server error
### Notes on Batch Ordering
#### Speed Bump (Latency Protection)
Batch orders are subject to a conditional \~200ms delay to protect liquidity providers from adverse selection:\
\
Speed bump is applied if the batch contains:
* Market orders (CreateMarket)
* Limit orders with TIF = GTC or IOC
Speed bump is NOT applied if the batch only contains:
* Add Liquidity Only orders (TIF = ALO)
* Top of Book orders (TIF = TOB)
* Cancel operations
* Edit operations
* TP/SL operations
When the speed bump applies, it is applied once to the batch as a whole before any action is processed, so exempt actions in the same batch (such as edits and cancels) are delayed along with it.
#### Signature Requirements
* Each action in the batch must be individually signed
* All signatures must be valid for the batch to process
#### Execution Behavior and Limits
* Maximum 10 actions per batch request
* Actions are executed atomically in the order provided
* If one action fails, subsequent actions are still attempted
# Cancel All Orders
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/orders/cancel-all-orders
This endpoint allows users to cancel all orders for all/given symbol(s).
The [Pacifica Python SDK](https://github.com/pacifica-fi/python-sdk/blob/f2385d42e9ae5276ba2ba85505d51db2eefd2715/rest/cancel_all_orders.py) provides a comprehensive example on using this endpoint
```http theme={null}
POST /api/v1/orders/cancel_all
```
#### Operation Type (for Signing)
| Header Field | Type | Content |
| - | - | - |
| `"type"` | string | `"cancel_all_orders"` |
#### Request Body
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | User's wallet address | `42trU9A5...` |
| `"signature"` | string | required | Cryptographic signature | `5j1Vy9Uq...` |
| `"timestamp"` | integer | required | Current timestamp in milliseconds | `1716200000000` |
| `"all_symbols"` | boolean | required | Whether to cancel orders for all symbols | `true` |
| `"exclude_reduce_only"` | boolean | required | Whether to exclude reduce-only orders | `false` |
| `"symbol"` | string | required\
(if all\_symbols is false) | Trading pair symbol | |
| `"agent_wallet"` | string | optional | Agent wallet address | `69trU9A5...` |
| `"expiry_window"` | integer | optional | Signature expiry in milliseconds | `30000` |
```json theme={null}
{
"account": "42trU9A5...",
"signature": "5j1Vy9Uq...",
"timestamp": 1716200000000,
"all_symbols": true,
"exclude_reduce_only": false,
"symbol": "BTC",
"agent_wallet": "69trU9A5...",
"expiry_window": 30000
}
```
#### Response
* Status 200: All orders cancelled successfully
```json theme={null}
{
"cancelled_count": 5
}
```
* Status 400: Bad request
```json theme={null}
{
"error": "Invalid parameters",
"code": 400
}
```
* Status 500: Internal server error
#### Code Example (Python)
```python theme={null}
import requests
payload = {
"account": "42trU9A5...",
"signature": "5j1Vy9Uq...",
"timestamp": 1716200000000,
"all_symbols": True,
"exclude_reduce_only": False
}
response = requests.post(
"/api/v1/orders/cancel_all",
json=payload,
headers={"Content-Type": "application/json"}
)
data = response.json()
```
# Cancel Order
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/orders/cancel-order
This endpoint allows users to cancel an existing order.
The [Pacifica Python SDK](https://github.com/pacifica-fi/python-sdk/blob/f2385d42e9ae5276ba2ba85505d51db2eefd2715/rest/cancel_order.py) provides a comprehensive example on using this endpoint.
```http theme={null}
POST /api/v1/orders/cancel
```
#### Operation Type (for Signing)
| Header Field | Type | Content |
| - | - | - |
| `"type"` | string | `"cancel_order"` |
#### Request Body
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | User's wallet address | `42trU9A5...` |
| `"signature"` | string | required | Cryptographic signature | `5j1Vy9Uq...` |
| `"timestamp"` | integer | required | Current timestamp in milliseconds | `1716200000000` |
| `"symbol"` | string | required | Trading pair symbol | `BTC` |
| `"order_id"` | integer | required (if no CLOID) | Exchange-assigned order ID | `123` |
| `"client_order_id"` | Full UUID string | required (if no OID) | Client-defined order ID | `f47ac10b-58cc-4372-a567-0e02b2c3d479` |
| `"agent_wallet"` | string | optional | Agent wallet address | `69trU9A5...` |
| `"expiry_window"` | integer | optional | Signature expiry in milliseconds | `30000` |
```json theme={null}
{
"account": "42trU9A5...",
"signature": "5j1Vy9Uq...",
"timestamp": 1716200000000,
"symbol": "BTC",
"order_id": 123,
"agent_wallet": "69trU9A5...",
"expiry_window": 30000
}
```
#### Response
* Status 200: Order cancelled successfully
```json theme={null}
{
"success": true
}
```
* Status 400: Bad request
```json theme={null}
{
"error": "Order not found",
"code": 400
}
```
* Status 500: Internal server error
#### Code Example (Python)
```python theme={null}
import requests
payload = {
"account": "42trU9A5...",
"signature": "5j1Vy9Uq...",
"timestamp": 1716200000000,
"symbol": "BTC",
"order_id": 123
}
response = requests.post(
"/api/v1/orders/cancel",
json=payload,
headers={"Content-Type": "application/json"}
)
data = response.json()
```
Cancel requests are not affected by any speedbumps.
# Cancel Stop Order
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/orders/cancel-stop-order
This endpoint allows users to cancel a stop order by its (CL)OID.
```http theme={null}
POST /api/v1/orders/stop/cancel
```
#### Operation Type (for Signing)
| Header Field | Type | Content |
| - | - | - |
| `"type"` | string | `"cancel_stop_order"` |
#### Request Body
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | User's wallet address | `42trU9A5...` |
| `"signature"` | string | required | Cryptographic signature | `5j1Vy9Uq...` |
| `"timestamp"` | integer | required | Current timestamp in milliseconds | `1716200000000` |
| `"symbol"` | string | required | Trading pair symbol | `BTC` |
| `"order_id"` | integer | required (if no CLOID) | Exchange-assigned order ID | `123` |
| `"client_order_id"` | Full UUID string | required (if no OID) | Client-defined order ID | `f47ac10b-58cc-4372-a567-0e02b2c3d479` |
| `"agent_wallet"` | string | optional | Agent wallet address | `69trU9A5...` |
| `"expiry_window"` | integer | optional | Signature expiry in milliseconds | `30000` |
```json theme={null}
{
"account": "42trU9A5...",
"signature": "5j1Vy9Uq...",
"timestamp": 1716200000000,
"symbol": "BTC",
"order_id": 123,
"agent_wallet": "69trU9A5...",
"expiry_window": 30000
}
```
#### Response
* Status 200: Stop order cancelled successfully
```json theme={null}
{
"success": true
}
```
* Status 400: Bad request
```json theme={null}
{
"error": "Stop order not found",
"code": 400
}
```
* Status 500: Internal server error
#### Code Example (Python)
```python theme={null}
import requests
payload = {
"account": "42trU9A5...",
"signature": "5j1Vy9Uq...",
"timestamp": 1716200000000,
"symbol": "BTC",
"order_id": 123
}
response = requests.post(
"/api/v1/orders/stop/cancel",
json=payload,
headers={"Content-Type": "application/json"}
)
data = response.json()
```
# Create Limit Order
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/orders/create-limit-order
This endpoint allows users to create a new limit order with optional take profit and stop loss levels.
The [Pacifica Python SDK](https://github.com/pacifica-fi/python-sdk/blob/f2385d42e9ae5276ba2ba85505d51db2eefd2715/rest/create_order.py) provides a comprehensive example on using this endpoint.
```http theme={null}
POST /api/v1/orders/create
```
#### Operation Type (for Signing)
| Header Field | Type | Content |
| - | - | - |
| `"type"` | string | `"create_order"` |
#### Request Body
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | User's wallet address | `42trU9A5...` |
| `"signature"` | string | required | Cryptographic signature | `5j1Vy9Uq...` |
| `"timestamp"` | integer | required | Current timestamp in milliseconds | `1716200000000` |
| `"symbol"` | string | required | Trading pair symbol | `BTC` |
| `"price"` | string | required | Order price | `50000` |
| `"amount"` | string | required | Order amount | `0.1` |
| `"side"` | string | required | Order side (bid/ask) | `bid` |
| `"tif"` | string | required | Time in force (`GTC`, `IOC`, `ALO`, `TOB`; case-insensitive) | `GTC` |
| `"reduce_only"` | boolean | required | Whether the order is reduce-only | `false` |
| `"client_order_id"` | Full UUID string | optional | Client-defined order ID | `f47ac10b-58cc-4372-a567-0e02b2c3d479` |
| `"order_expiry"` | integer | optional | When the order expires and is cancelled, in milliseconds since epoch. Must be 5 minutes to 30 days from now. Only for TIF `GTC`, `ALO`, and `TOB` | `1716203600000` |
| `"take_profit"` | object | optional | Take profit stop order configuration | See next five rows |
| `"stop_price"` | string | required | Stop trigger price | `55000` |
| `"limit_price"` | string | optional | Limit price for the triggered order | `54950` |
| `"client_order_id"` | Full UUID string | optional | Client-defined order ID for the stop order | `e36ac10b-58cc-4372-a567-0e02b2c3d479` |
| `"trigger_price_type"` | string | optional | Price type used to trigger the stop order. Defaults to `last_trade_price`. Options: `mark_price`, `last_trade_price`, `mid_price` | `mark_price` |
| `"amount"` | string | optional | Order amount for the triggered order. If omitted, the full position size is used | `0.1` |
| `"stop_loss"` | object | optional | Stop loss order configuration | See next five rows |
| `"stop_price"` | string | required | Stop trigger price | `48000` |
| `"limit_price"` | string | optional | Limit price for the triggered order | `47950` |
| `"client_order_id"` | Full UUID string | optional | Client-defined order ID for the stop order | `d25ac10b-58cc-4372-a567-0e02b2c3d479` |
| `"trigger_price_type"` | string | optional | Price type used to trigger the stop order. Defaults to `last_trade_price`. Options: `mark_price`, `last_trade_price`, `mid_price` | `mark_price` |
| `"amount"` | string | optional | Order amount for the triggered order. If omitted, the full position size is used | `0.1` |
| `"agent_wallet"` | string | optional | Agent wallet address | `69trU9A5...` |
| `"expiry_window"` | integer | optional | Signature expiry in milliseconds | `30000` |
| `"builder_code"` | string | optional | Builder program code (3-16 alphanumeric characters) | `MYCODE` |
```json theme={null}
{
"account": "42trU9A5...",
"signature": "5j1Vy9Uq",
"timestamp": 1716200000000,
"symbol": "BTC",
"price": "50000",
"amount": "0.1",
"side": "bid",
"tif": "GTC",
"reduce_only": false,
"client_order_id": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
"take_profit": {
"stop_price": "55000",
"limit_price": "54950",
"client_order_id": "e36ac10b-58cc-4372-a567-0e02b2c3d479",
"trigger_price_type": "mark_price"
},
"stop_loss": {
"stop_price": "48000",
"limit_price": "47950",
"client_order_id": "d25ac10b-58cc-4372-a567-0e02b2c3d479",
"trigger_price_type": "mark_price"
},
"agent_wallet": "69trU9A5...",
"expiry_window": 30000,
"builder_code": "MYCODE"
}
```
#### Response
* Status 200: Order created successfully
```json theme={null}
{
"order_id": 12345
}
```
* Status 400: Bad request
```json theme={null}
{
"error": "Invalid order parameters",
"code": 400
}
```
* Status 500: Internal server error
#### Code Example (Python)
```python theme={null}
import requests
payload = {
"account": "42trU9A5...",
"signature": "5j1Vy9Uq...",
"timestamp": 1716200000000,
"symbol": "BTC",
"price": "50000",
"amount": "0.1",
"side": "bid",
"tif": "GTC",
"reduce_only": False,
"client_order_id": "f47ac10b-58cc-4372-a567-0e02b2c3d479"
}
response = requests.post(
"/api/v1/orders/create",
json=payload,
headers={"Content-Type": "application/json"}
)
data = response.json()
```
Note: In order to protect liquidity providers from adverse selection, all TIF GTC, and TIF IOC orders are subject to a \~200ms delay.
# Create Market Order
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/orders/create-market-order
This endpoint allows users to create a new market order with optional take profit and stop loss levels.
```http theme={null}
POST /api/v1/orders/create_market
```
#### Operation Type (for Signing)
| Header Field | Type | Content |
| - | - | - |
| `"type"` | string | `"create_market_order"` |
#### Request Body
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | User's wallet address | `42trU9A5...` |
| `"signature"` | string | required | Cryptographic signature | `5j1Vy9Uq...` |
| `"timestamp"` | integer | required | Current timestamp in milliseconds | `1716200000000` |
| `"symbol"` | string | required | Trading pair symbol | `BTC` |
| `"amount"` | string | required | Order amount | `0.1` |
| `"side"` | string | required | Order side (bid/ask) | `bid` |
| `"slippage_percent"` | string | required | Maximum slippage tolerance in percentage, e.g. "0.5" means 0.5% max slippage | `0.5` |
| `"reduce_only"` | boolean | required | Whether the order is reduce-only | `false` |
| `"client_order_id"` | Full UUID string | optional | Client-defined order ID | `f47ac10b-58cc-4372-a567-0e02b2c3d479` |
| `"take_profit"` | object | optional | Take profit stop order configuration | See next five rows |
| `"stop_price"` | string | required | Stop trigger price | `55000` |
| `"limit_price"` | string | optional | Limit price for the triggered order | `54950` |
| `"client_order_id"` | Full UUID string | optional | Client-defined order ID for the stop order | `e36ac10b-58cc-4372-a567-0e02b2c3d479` |
| `"trigger_price_type"` | string | optional | Price type used to trigger the stop order. Defaults to `last_trade_price`. Options: `mark_price`, `last_trade_price`, `mid_price` | `mark_price` |
| `"amount"` | string | optional | Order amount for the triggered order. If omitted, the full position size is used | `0.1` |
| `"stop_loss"` | object | optional | Stop loss order configuration | See next five rows |
| `"stop_price"` | string | required | Stop trigger price | `48000` |
| `"limit_price"` | string | optional | Limit price for the triggered order | `47950` |
| `"client_order_id"` | Full UUID string | optional | Client-defined order ID for the stop order | `d25ac10b-58cc-4372-a567-0e02b2c3d479` |
| `"trigger_price_type"` | string | optional | Price type used to trigger the stop order. Defaults to `last_trade_price`. Options: `mark_price`, `last_trade_price`, `mid_price` | `mark_price` |
| `"amount"` | string | optional | Order amount for the triggered order. If omitted, the full position size is used | `0.1` |
| `"agent_wallet"` | string | optional | Agent wallet address | `69trU9A5...` |
| `"expiry_window"` | integer | optional | Signature expiry in milliseconds | `30000` |
| `"builder_code"` | string | optional | Builder program code (3-16 alphanumeric characters) | `MYCODE` |
```json theme={null}
{
"account": "42trU9A5...",
"signature": "5j1Vy9Uq",
"timestamp": 1716200000000,
"symbol": "BTC",
"amount": "0.1",
"side": "bid",
"slippage_percent": "0.5",
"reduce_only": false,
"client_order_id": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
"take_profit": {
"stop_price": "55000",
"limit_price": "54950",
"client_order_id": "e36ac10b-58cc-4372-a567-0e02b2c3d479",
"trigger_price_type": "mark_price"
},
"stop_loss": {
"stop_price": "48000",
"limit_price": "47950",
"client_order_id": "d25ac10b-58cc-4372-a567-0e02b2c3d479",
"trigger_price_type": "mark_price"
},
"agent_wallet": "69trU9A5...",
"expiry_window": 30000,
"builder_code": "MYCODE"
}
```
#### Response
* Status 200: Order created successfully
```json theme={null}
{
"order_id": 12345
}
```
* Status 400: Bad request
```json theme={null}
{
"error": "Invalid order parameters",
"code": 400
}
```
* Status 500: Internal server error
#### Code Example (Python)
```python theme={null}
import requests
payload = {
"account": "42trU9A5...",
"signature": "5j1Vy9Uq...",
"timestamp": 1716200000000,
"symbol": "BTC",
"amount": "0.1",
"side": "bid",
"slippage_percent": 1,
"reduce_only": False,
"client_order_id": "f47ac10b-58cc-4372-a567-0e02b2c3d479"
}
response = requests.post(
"/api/v1/orders/create_market",
json=payload,
headers={"Content-Type": "application/json"}
)
data = response.json()
```
Note: In order to protect liquidity providers from adverse selection, all market orders are subject to a \~200ms delay.
# Create Position TP/SL
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/orders/create-position-tp-sl
This endpoint allows users to set take profit and stop loss levels for an existing position.
```http theme={null}
POST /api/v1/positions/tpsl
```
#### Operation Type (for Signing)
| Header Field | Type | Content |
| - | - | - |
| `"type"` | string | `"set_position_tpsl"` |
#### Request Body
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | User's wallet address | `42trU9A5...` |
| `"signature"` | string | required | Cryptographic signature | `5j1Vy9Uq...` |
| `"timestamp"` | integer | required | Current timestamp in milliseconds | `1716200000000` |
| `"symbol"` | string | required | Trading pair symbol | `BTC` |
| `"side"` | string | required | Order side (bid/ask) | `bid` |
| `"take_profit"` | object | optional (if there is SL) | Take profit stop order configuration | See next five rows |
| `"stop_price"` | string | required | Stop trigger price | `55000` |
| `"limit_price"` | string | optional | Limit price for the triggered order | `54950` |
| `"client_order_id"` | Full UUID string | optional | Client-defined order ID for the stop order | `e36ac10b-58cc-4372-a567-0e02b2c3d479` |
| `"trigger_price_type"` | string | optional | Price type used to trigger the stop order. Defaults to `last_trade_price`. Options: `mark_price`, `last_trade_price`, `mid_price` | `mark_price` |
| `"amount"` | string | optional | Order amount for the triggered order. If omitted, the full position size is used | `0.1` |
| `"stop_loss"` | object | optional (if there is TP) | Stop loss order configuration | See next five rows |
| `"stop_price"` | string | required | Stop trigger price | `48000` |
| `"limit_price"` | string | optional | Limit price for the triggered order | `47950` |
| `"client_order_id"` | Full UUID string | optional | Client-defined order ID for the stop order | `d25ac10b-58cc-4372-a567-0e02b2c3d479` |
| `"trigger_price_type"` | string | optional | Price type used to trigger the stop order. Defaults to `last_trade_price`. Options: `mark_price`, `last_trade_price`, `mid_price` | `mark_price` |
| `"amount"` | string | optional | Order amount for the triggered order. If omitted, the full position size is used | `0.1` |
| `"agent_wallet"` | string | optional | Agent wallet address | `69trU9A5...` |
| `"expiry_window"` | integer | optional | Signature expiry in milliseconds | `30000` |
| `"builder_code"` | string | optional | Builder program code (3-16 alphanumeric characters) | `MYCODE` |
```json theme={null}
{
"account": "42trU9A5...",
"signature": "5j1Vy9Uq...",
"timestamp": 1716200000000,
"symbol": "BTC",
"side": "bid",
"take_profit": {
"stop_price": "55000",
"limit_price": "54950",
"client_order_id": "e36ac10b-58cc-4372-a567-0e02b2c3d479",
"trigger_price_type": "mark_price"
},
"stop_loss": {
"stop_price": "48000",
"limit_price": "47950",
"client_order_id": "d25ac10b-58cc-4372-a567-0e02b2c3d479",
"trigger_price_type": "mark_price"
},
"agent_wallet": "69trU9A5...",
"expiry_window": 30000,
"builder_code": "MYCODE"
}
```
#### Response
* Status 200: Take profit and stop loss set successfully
```json theme={null}
{
"success": true
}
```
* Status 400: Bad request
```json theme={null}
{
"error": "Position not found",
"code": 400
}
```
* Status 500: Internal server error
#### Code Example (Python)
```python theme={null}
import requests
payload = {
"account": "42trU9A5...",
"signature": "5j1Vy9Uq...",
"timestamp": 1716200000000,
"symbol": "BTC",
"side": "bid",
"take_profit": {
"stop_price": "55000",
"limit_price": "54950"
},
"stop_loss": {
"stop_price": "48000",
"limit_price": "47950"
}
}
response = requests.post(
"/api/v1/positions/tpsl",
json=payload,
headers={"Content-Type": "application/json"}
)
data = response.json()
```
# Create Stop Order
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/orders/create-stop-order
This endpoint allows users to create stop order.
```http theme={null}
POST /api/v1/orders/stop/create
```
#### Operation Type (for Signing)
| Header Field | Type | Content |
| - | - | - |
| `"type"` | string | `"create_stop_order"` |
#### Request Body
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | User's wallet address | `42trU9A5...` |
| `"signature"` | string | required | Cryptographic signature | `5j1Vy9Uq...` |
| `"timestamp"` | integer | required | Current timestamp in milliseconds | `1716200000000` |
| `"symbol"` | string | required | Trading pair symbol | `BTC` |
| `"side"` | string | required | Order side (bid/ask) | `bid` |
| `"reduce_only"` | boolean | required | Whether the order is reduce-only | `false` |
| `"stop_order"` | object | required | Stop order configuration | See next five rows |
| `"stop_price"` | string | required | Stop trigger price | `48000` |
| `"limit_price"` | string | optional | Limit price for the triggered order | `47950` |
| `"client_order_id"` | Full UUID string | optional | Client-defined order ID for the stop order | `d25ac10b-58cc-4372-a567-0e02b2c3d479` |
| `"trigger_price_type"` | string | optional | Price type used to trigger the stop order. Defaults to `last_trade_price`. Options: `mark_price`, `last_trade_price`, `mid_price` | `mark_price` |
| `"amount"` | string | optional | Order amount (inside `stop_order`). If omitted, the full position size is used | `0.1` |
| `"agent_wallet"` | string | optional | Agent wallet address | `69trU9A5...` |
| `"expiry_window"` | integer | optional | Signature expiry in milliseconds | `30000` |
| `"builder_code"` | string | optional | Builder program code (3-16 alphanumeric characters) | `MYCODE` |
```json theme={null}
{
"account": "42trU9A5...",
"signature": "5j1Vy9Uq...",
"timestamp": 1716200000000,
"symbol": "BTC",
"side": "bid",
"reduce_only": true,
"stop_order": {
"stop_price": "48000",
"limit_price": "47950",
"client_order_id": "d25ac10b-58cc-4372-a567-0e02b2c3d479",
"trigger_price_type": "mark_price",
"amount": "0.1"
},
"agent_wallet": "69trU9A5...",
"expiry_window": 30000,
"builder_code": "MYCODE"
}
```
#### Response
* Status 200: Stop order created successfully
```json theme={null}
{
"order_id": 12345
}
```
* Status 400: Bad request
```json theme={null}
{
"error": "Invalid stop order parameters",
"code": 400
}
```
* Status 500: Internal server error
#### Code Example (Python)
```python theme={null}
import requests
payload = {
"account": "42trU9A5...",
"signature": "5j1Vy9Uq...",
"timestamp": 1716200000000,
"symbol": "BTC",
"side": "bid",
"reduce_only": True,
"stop_order": {
"stop_price": "48000",
"limit_price": "47950",
"amount": "0.1"
}
}
response = requests.post(
"/api/v1/orders/stop/create",
json=payload,
headers={"Content-Type": "application/json"}
)
data = response.json()
```
# Edit Order
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/orders/edit-order
This endpoint allows users to edit an existing limit order by modifying its size and/or price.
```http theme={null}
POST /api/v1/orders/edit
```
#### Operation Type (for Signing)
| Header Field | Type | Content |
| - | - | - |
| `"type"` | string | `"edit_order"` |
#### Request Body
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | User's wallet address | `42trU9A5...` |
| `"signature"` | string | required | Cryptographic signature | `5j1Vy9Uq...` |
| `"timestamp"` | integer | required | Current timestamp in milliseconds | `1716200000000` |
| `"symbol"` | string | required | Trading pair symbol | `BTC` |
| `"price"` | string | required | Order price | `50000` |
| `"amount"` | string | optional | Order amount. If omitted, the existing order's remaining amount is kept | `0.1` |
| `"order_id"` | integer | required\
(if no CLOID) | Exchange assigned order ID | `123456789` |
| `"client_order_id"` | Full UUID string | required\
(if no OID) | Client-defined order ID | `f47ac10b-58cc-4372-a567-0e02b2c3d479` |
| `"order_expiry"` | integer or null | optional | New expiry in milliseconds since epoch, 5 minutes to 30 days from now. Omit it to keep the current expiry. Send `null` to remove the expiry. The value, including `null`, is part of the signed data | `1716203600000` |
| `"agent_wallet"` | string | optional | Agent wallet address | `69trU9A5...` |
| `"expiry_window"` | integer | optional | Signature expiry in milliseconds | `30000` |
Note: You must provide either `order_id` OR `client_order_id` but not both.
```json theme={null}
{
"account": "42trU9A5...",
"signature": "5j1Vy9Uq...",
"timestamp": 1716200000000,
"symbol": "BTC",
"price": "90000",
"amount": "0.5",
"order_id": 123456789,
"agent_wallet": "69trU9A5...",
"expiry_window": 30000
}
```
#### Response
* Status 200: Order created successfully
```json theme={null}
{
"order_id": 123498765
}
```
* Status 400: Bad request
```json theme={null}
{
"success": false,
"error": "Order not found",
"code": 400
}
```
* Status 500: Internal server error
#### Code Example (Python)
```python theme={null}
import requests
payload = {
"account": "42trU9A5...",
"signature": "5j1Vy9Uq...",
"timestamp": 1716200000000,
"symbol": "BTC",
"price": "90000",
"amount": "0.5",
"order_id": 123456789
}
response = requests.post(
"/api/v1/orders/edit",
json=payload,
headers={"Content-Type": "application/json"}
)
data = response.json()
```
**Notes:** Editing an order cancels the original and creates a new one. The new order maintains the same side, reduce-only status, and client\_order\_id (if provided), is created with TIF = ALO (Post Only), and receives a new system-assigned order\_id.
Edit orders are not subject to the taker speedbump. Because the replacement order is always created with TIF = ALO (Post Only), it can never take liquidity, so no delay is applied.
# Get Open Orders
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/orders/get-open-orders
This endpoint allows users to get open orders on their account.
```http theme={null}
GET /api/v1/orders
```
#### Query Parameters
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | Account address to filter orders | `42trU9A5...` |
```http theme={null}
/api/v1/orders?account=42trU9A5...
```
#### Response
* Status 200: Successfully retrieved open orders
```json theme={null}
{
"success": true,
"data": [
{
"order_id": 315979358,
"client_order_id": "add9a4b5-c7f7-4124-b57f-86982d86d479",
"symbol": "ASTER",
"side": "ask",
"price": "1.836",
"initial_amount": "85.33",
"filled_amount": "0",
"cancelled_amount": "0",
"stop_price": null,
"order_type": "limit",
"stop_parent_order_id": null,
"reduce_only": false,
"created_at": 1759224706737,
"updated_at": 1759224706737,
"li": 1557370337
}
],
"error": null,
"code": null,
"last_order_id": 1557370337
}
```
| Field | Type | Description |
|---|
| `"order_id"` | integer | Order id assigned to order |
| `"client_order_id"` | UUID | CLOID of order if assigned by user |
| `"parent_id"` | UUID or null | ID of the [order strategy](/api-documentation/api/rest-api/order-strategies) that placed the order. `null` for other orders |
| `"symbol"` | string | Trading pair symbol |
| `"side"` | string | Whether the order is a bid or an ask |
| `"price"` | decimal string | Price set by the order |
| `"initial_amount"` | decimal string | Amount (in token denomination) of the order placed |
| `"filled_amount"` | decimal string | Amount (in token denomination) of the order placed that has been filled |
| `"cancelled_amount"` | decimal string | Amount (in token denomination) of the order placed that has been cancelled |
| `"stop_price"` | decimal string | Stop price assigned upon order creation for subsequent position if order is filled if specified by user. |
| `"order_type"` | string | `"limit"`\
`"market"`\
`"stop_limit"`\
`"stop_market"`\
`"take_profit_limit"`\
`"stop_loss_limit"`\
`"take_profit_market"`\
`"stop_loss_market"` |
| `"stop_parent_order_id"` | integer | Order id of stop order attached to original order |
| `"trigger_price_type"` | string | Price type used to trigger stop orders (`mark_price`, `last_trade_price`, `mid_price`); defaults to `last_trade_price` |
| `"reduce_only"` | boolean | If the order is reduce only |
| `"order_expiry"` | integer or null | Time the order expires, in milliseconds. `null` if the order has no expiry |
| `"instrument_type"` | string | Instrument type of the market |
| `"created_at"` | integer | Timestamp in milliseconds when the order was created on Pacifica |
| `"updated_at"` | integer | Timestamp in milliseconds when the order was last modified (by a fill) |
| `"li"` | integer or null | [Last ID](/api-documentation/api/last-id) — sequence number for this order. `null` if the engine has not touched the row yet. |
| `"last_order_id"` | integer | [Last ID](/api-documentation/api/last-id) — sequence number for the account's open-order set. Stays available after the last order is removed. |
* Status 400: Invalid request parameters
* Status 401: Unauthorized access
* Status 500: Internal server error
#### Code Example (Python)
```python theme={null}
import requests
response = requests.get(
"/api/v1/orders?account=42trU9A5...",
headers={"Accept": "*/*"},
)
data = response.json()
```
# Get Order History
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/orders/get-order-history
This endpoint allows users to get a summarized order history.
```http theme={null}
GET /api/v1/orders/history
```
#### Query Parameters
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | Account address to filter orders | `42trU9A5...` |
| `"limit"` | integer | optional | Maximum number of records to return, default to 100 | `100` |
| `"cursor"` | string | optional | Cursor pagination to access records. Default to none | `1115hVka` |
```http theme={null}
/api/v1/orders/history?account=42trU9A5...&limit=100
```
#### Response
* Status 200: Successfully retrieved order history
```json theme={null}
{
"success": true,
"data": [
{
"order_id": 315992721,
"client_order_id": "ade",
"symbol": "XPL",
"side": "ask",
"initial_price": "1.0865",
"average_filled_price": "0",
"amount": "984",
"filled_amount": "0",
"order_status": "open",
"order_type": "limit",
"stop_price": null,
"stop_parent_order_id": null,
"reduce_only": false,
"reason": null,
"created_at": 1759224893638,
"updated_at": 1759224893638
},
...
],
"next_cursor": "1111Hyd74",
"has_more": true
}
```
| Field | Type | Description |
|---|
| `"order_id"` | integer | Order id assigned to order |
| `"client_order_id"` | UUID | CLOID of order if assigned by user |
| `"parent_id"` | UUID or null | ID of the [order strategy](/api-documentation/api/rest-api/order-strategies) that placed the order. `null` for other orders |
| `"symbol"` | string | Trading pair symbol |
| `"side"` | string | Whether the order is a bid or an ask |
| `"initial_price"` | decimal string | Initial (limit) price of the order |
| `"average_filled_price"` | decimal string | VWAP of price at which the order was filled at |
| `"amount"` | decimal string | Amount (in token denomination) of the order placed |
| `"filled_amount"` | decimal string | Amount (in token denomination) of the order placed that was filled |
| `"order_status"` | string | `"open"`\
`"partially_filled"`\
`"filled"`\
`"cancelled"`\
`"rejected"` |
| `"order_type"` | string | `"limit"`\
`"market"`\
`"stop_limit"`\
`"stop_market"`\
`"take_profit_limit"`\
`"stop_loss_limit"`\
`"take_profit_market"`\
`"stop_loss_market"` |
| `"stop_price"` | decimal string | Stop price assigned upon order creation for subsequent position if order is filled if specified by user. |
| `"stop_parent_order_id"` | integer | Order id of stop order attached to original order |
| `"reduce_only"` | boolean | If the order is reduce only |
| `"trigger_price_type"` | string | Price type used to trigger stop orders (`mark_price`, `last_trade_price`, `mid_price`); defaults to `last_trade_price` |
| `"reason"` | string | Provides reason for an order being `"cancelled"` or `"rejected"`:\
`"cancel"`\
`"force_cancel"`\
`"expired"`\
`"post_only_rejected"`\
`"self_trade_prevented"` |
| `"instrument_type"` | string | Instrument type of the market |
| `"created_at"` | integer | Timestamp in milliseconds when the order was created on Pacifica |
| `"updated_at"` | integer | Timestamp in milliseconds when any of the order was last modified |
| `'next_cursor'` | string | Next cursor for pagination |
| `'has_more'` | boolean | True if there exists a `'next_cursor'` |
* Status 400: Invalid request parameters
* Status 401: Unauthorized access
* Status 500: Internal server error
#### Code Example (Python)
```python theme={null}
import requests
response = requests.get(
"/api/v1/orders/history?account=42trU9A5...&limit=100",
headers={"Accept": "*/*"},
)
data = response.json()
```
# Get Order History by ID
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/orders/get-order-history-by-id
This endpoint allows users to get order history by id.
```http theme={null}
GET /api/v1/orders/history_by_id
```
#### Query Parameters
| Field | Type | Need | Description | Example |
|---|
| `"order_id"` | integer | required | Order ID to retrieve history for | `13753364` |
```http theme={null}
/api/v1/orders/history_by_id?order_id=13753364
```
#### Response
* Status 200: Successfully retrieved open orders
```json theme={null}
{
"success": true,
"data": [
{
"history_id": 641452639,
"order_id": 315992721,
"client_order_id": "ade1aa6...",
"symbol": "XPL",
"side": "ask",
"price": "1.0865",
"initial_amount": "984",
"filled_amount": "0",
"cancelled_amount": "984",
"event_type": "cancel",
"order_type": "limit",
"order_status": "cancelled",
"stop_price": null,
"stop_parent_order_id": null,
"reduce_only": false,
"created_at": 1759224895038
},
{
"history_id": 641452513,
"order_id": 315992721,
"client_order_id": "ade1aa6...",
"symbol": "XPL",
"side": "ask",
"price": "1.0865",
"initial_amount": "984",
"filled_amount": "0",
"cancelled_amount": "0",
"event_type": "make",
"order_type": "limit",
"order_status": "open",
"stop_price": null,
"stop_parent_order_id": null,
"reduce_only": false,
"created_at": 1759224893638
}
],
"error": null,
"code": null
}
```
| Field | Type | Description |
|---|
| `"history_id"` | integer | History ID assigned to the order |
| `"order_id"` | integer | Order ID assigned to order |
| `"client_order_id"` | UUID | CLOID of order if assigned by user |
| `"parent_id"` | UUID or null | ID of the [order strategy](/api-documentation/api/rest-api/order-strategies) that placed the order. `null` for other orders |
| `"symbol"` | string | Trading pair symbol |
| `"side"` | string | Whether the order is a bid or an ask |
| `"price"` | decimal string | Execution price of the order event (e.g. order creation limit price, order matching filled price, limit price at cancellation) |
| `"initial_amount"` | decimal string | Amount (in token denomination) of the order placed |
| `"filled_amount"` | decimal string | Amount (in token denomination) of the order placed that was filled |
| `"cancelled_amount"` | decimal string | Amount (in token denomination) of the order placed that was cancelled |
| `"event_type"` | string | `"make"``"stop_created"``"twap_created"``"fulfill_market"``"fulfill_limit"``"adjust"``"stop_parent_order_filled"``"stop_triggered"``"stop_upgrade"``"twap_triggered"``"cancel"``"force_cancel"``"expired"``"post_only_rejected"``"self_trade_prevented"` |
| `"order_type"` | string | `"limit"`\
`"market"`\
`"stop_limit"`\
`"stop_market"`\
`"take_profit_limit"`\
`"stop_loss_limit"`\
`"take_profit_market"`\
`"stop_loss_market"` |
| `"order_status"` | string | `"open"`\
`"partially_filled"`\
`"filled"`\
`"cancelled"`\
`"rejected"` |
| `"stop_price"` | decimal string | Stop price assigned upon order creation for subsequent position if order is filled if specified by user. |
| `"stop_parent_order_id"` | integer | Order id of stop order attached to original order |
| `"reduce_only"` | boolean | If the order is reduce only |
| `"trigger_price_type"` | string | Price type used to trigger stop orders (`mark_price`, `last_trade_price`, `mid_price`); defaults to `last_trade_price` |
| `"instrument_type"` | string | Instrument type of the market |
| `"created_at"` | integer | Timestamp in milliseconds when the order was created on Pacifica |
* Status 400: Invalid request parameters
* Status 401: Unauthorized access
* Status 500: Internal server error
#### Code Example (Python)
```python theme={null}
import requests
response = requests.get(
"/api/v1/orders/history_by_id?order_id=13753364",
headers={"Accept": "*/*"},
)
data = response.json()
```
# Get Order History Records
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/orders/get-order-history-records
This endpoint allows users to get order history and finished order strategies in one list.
```http theme={null}
GET /api/v1/orders/history/records
```
This endpoint returns your orders and your finished [order strategies](/api-documentation/api/rest-api/order-strategies) in one list. It sorts the list by creation time, newest first. Each item has a `kind` and a `record`.
It differs from [Get order history](/api-documentation/api/rest-api/orders/get-order-history) in these ways:
* It includes finished order strategies as `"kind": "strategy"` records. Open strategies are not included.
* It leaves out orders that a strategy placed. A strategy sets `parent_id` on each order that it places. You can find these orders in the strategy record's `owned_orders`.
* It sorts by creation time. Get order history sorts by order ID.
* `has_more` is `true` only when another page exists.
#### Query Parameters
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | Account address | `42trU9A5...` |
| `"limit"` | integer | optional | Maximum number of records to return. Default and maximum are 100. Values outside 1 to 100 are clamped to that range | `100` |
| `"cursor"` | string | optional | The `"next_cursor"` value from the previous page. Leave it out to get the first page | `pxinAJf8...` |
```http theme={null}
/api/v1/orders/history/records?account=42trU9A5...&limit=100
```
#### Response
* Status 200: Successfully retrieved order history records
```json theme={null}
{
"success": true,
"data": [
{
"kind": "strategy",
"record": {
"strategy_id": "0f8e6c2a-5b1d-4c3e-9a7f-2d4b6e8a1c3f",
"revision": 2,
"account": "42trU9A5...",
"strategy_type": "twap",
"definition": {
"strategy_type": "twap",
"params": { ... }
},
"lifecycle": "completed",
"state": { ... },
"applied_trade_history_id": 912800455,
"applied_order_history_id": 1840022917,
"expires_at_ms": null,
"scheduled_start_at_ms": null,
"scheduled_end_at_ms": null,
"created_at_ms": 1759224900000,
"updated_at_ms": 1759225500000,
"owned_orders": [
{
"order_id": 315992800,
"prev_order_id": null,
"is_open": false,
"client_order_id": null,
"take_profit_client_order_id": null,
"stop_loss_client_order_id": null
},
...
]
}
},
{
"kind": "order",
"record": {
"order_id": 315992721,
"client_order_id": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
"parent_id": null,
"symbol": "XPL",
"side": "ask",
"initial_price": "1.0865",
"average_filled_price": "0",
"amount": "984",
"filled_amount": "0",
"order_status": "open",
"order_type": "limit",
"stop_price": null,
"stop_parent_order_id": null,
"reduce_only": false,
"trigger_price_type": null,
"reason": null,
"instrument_type": "perpetual",
"created_at": 1759224893638,
"updated_at": 1759224893638
}
},
...
],
"next_cursor": "pxinAJf8...",
"has_more": true
}
```
| Field | Type | Description |
|---|
| `"kind"` | string | `"order"` or `"strategy"` |
| `"record"` | object | An order record or a strategy record, as set by `"kind"` (see below) |
| `"next_cursor"` | string | Cursor for the next page. Omitted when `"has_more"` is `false` |
| `"has_more"` | boolean | `true` if more records exist after this page |
To get the next page, send the same request with `cursor` set to `next_cursor`. Treat the cursor as an opaque string. It doesn't work with [Get order history](/api-documentation/api/rest-api/orders/get-order-history).
**Order Record Fields** (`"kind": "order"`)
Each order appears once, in its latest state.
| Field | Type | Description |
|---|
| `"order_id"` | integer | Order id assigned to order |
| `"client_order_id"` | UUID | CLOID of order if assigned by user |
| `"parent_id"` | UUID or null | Always `null` in this endpoint |
| `"symbol"` | string | Trading pair symbol |
| `"side"` | string | Whether the order is a bid or an ask |
| `"initial_price"` | decimal string | Initial (limit) price of the order |
| `"average_filled_price"` | decimal string | VWAP of price at which the order was filled. `"0"` if nothing has filled |
| `"amount"` | decimal string | Amount (in token denomination) of the order placed |
| `"filled_amount"` | decimal string | Amount (in token denomination) of the order placed that was filled |
| `"order_status"` | string | `"open"`\
`"partially_filled"`\
`"filled"`\
`"cancelled"`\
`"rejected"` |
| `"order_type"` | string | `"limit"`\
`"market"`\
`"stop_limit"`\
`"stop_market"`\
`"take_profit_limit"`\
`"stop_loss_limit"`\
`"take_profit_market"`\
`"stop_loss_market"` |
| `"stop_price"` | decimal string | Stop price of a stop order |
| `"stop_parent_order_id"` | integer | Parent order id of a stop order |
| `"reduce_only"` | boolean | If the order is reduce only |
| `"trigger_price_type"` | string | Price type used to trigger stop orders (`mark_price`, `last_trade_price`, `mid_price`); defaults to `last_trade_price` |
| `"reason"` | string | Provides reason for an order being `"cancelled"` or `"rejected"`:\
`"cancel"`\
`"force_cancel"`\
`"expired"`\
`"post_only_rejected"`\
`"self_trade_prevented"` |
| `"instrument_type"` | string | `"perpetual"` or `"spot"` |
| `"created_at"` | integer | Timestamp in milliseconds of the first event for this order. The list sorts by this value |
| `"updated_at"` | integer | Timestamp in milliseconds of the latest event for this order |
**Strategy Record Fields** (`"kind": "strategy"`)
A strategy record is a finished order strategy. The main fields are below. See [Order strategies](/api-documentation/api/rest-api/order-strategies) for the full shape, `definition`, and `state`.
| Field | Type | Description |
|---|
| `"strategy_id"` | UUID | Strategy ID |
| `"strategy_type"` | string | Strategy type, for example `"twap"` |
| `"lifecycle"` | string | `"completed"`\
`"cancelled"`\
`"expired"`\
`"failed"` |
| `"terminal_reason"` | string | Why the strategy ended, for example `"user_cancel"` or `"insufficient_balance"`. Omitted when no reason applies |
| `"owned_orders"` | array | Orders that the strategy placed |
| `"created_at_ms"` | integer | Timestamp in milliseconds when the strategy was created. The list sorts by this value |
| `"updated_at_ms"` | integer | Timestamp in milliseconds when the strategy last changed |
* Status 400: Invalid request parameters or invalid cursor
* Status 500: Internal server error
#### Code Example (Python)
```python theme={null}
import requests
response = requests.get(
"/api/v1/orders/history/records?account=42trU9A5...&limit=100",
headers={"Accept": "*/*"},
)
data = response.json()
```
# Print
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/print
This section covers placing Print orders on Pacifica.
* [Create Print order](/api-documentation/api/rest-api/print/create-print-order): This endpoint allows users to place a Print order, with an optional builder code.
# Create Print Order
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/print/create-print-order
This endpoint allows users to place a Print order, with an optional builder code.
```http theme={null}
POST /api/v1/game/deposit
```
Locks your deposit in a new Print order. See [Placing & Managing Orders](/print/placing-and-managing-orders) for how Print orders work.
#### Operation Type (for Signing)
| Header Field | Type | Content |
| - | - | - |
| `"type"` | string | `"deposit_to_game"` |
#### Request Body
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | User's wallet address | `42trU9A5...` |
| `"signature"` | string | required | Cryptographic signature | `5j1Vy9Uq...` |
| `"timestamp"` | integer | required | Current timestamp in milliseconds | `1716200000000` |
| `"game"` | string | required | Print product, set by market and cycle length: `BTC_24H`, `BTC_7D`, `BTC_1M` (30 days), `ETH_24H`, and so on | `BTC_24H` |
| `"deposit_amount"` | string | required | Deposit in USDC, minimum 10 | `1000.00` |
| `"direction"` | integer | required | `0` - long: the order opens a long if the price falls to the target\
`1` - short: the order opens a short if the price rises to the target | `1` |
| `"strike_price"` | string | required | Target price | `95000.00` |
| `"leverage"` | string | required | Leverage, up to the market's maximum | `2.0` |
| `"total_segments"` | integer | optional | Number of cycles the order runs, 1 to 1000. If omitted, the order rolls over until you end it | `7` |
| `"idempotency_key"` | string | optional | Full UUID string. Prevents duplicate orders | `550e8400-e29b-41d4-a716-446655440000` |
| `"agent_wallet"` | string | optional | Agent wallet address | `69trU9A5...` |
| `"expiry_window"` | integer | optional | Signature expiry in milliseconds | `30000` |
| `"builder_code"` | string | optional | Builder program code (3-16 alphanumeric characters). See below | `MYCODE` |
```json theme={null}
{
"account": "42trU9A5...",
"signature": "5j1Vy9Uq...",
"timestamp": 1716200000000,
"game": "BTC_24H",
"deposit_amount": "1000.00",
"direction": 1,
"strike_price": "95000.00",
"leverage": "2.0",
"total_segments": 7,
"idempotency_key": "550e8400-e29b-41d4-a716-446655440000",
"agent_wallet": "69trU9A5...",
"expiry_window": 30000,
"builder_code": "MYCODE"
}
```
#### Builder codes
A builder code on a Print order earns its owner two things:
* **10% of each premium** of the order. The premium is the yield, and it is paid at the start of every cycle, so the reward applies to every roll-over. A later liquidation does not reverse it. The reward comes from Pacifica's revenue, and the user keeps the full premium.
* **The code's builder fee** on the perp position that the order delivers, charged like the fee on an order fill. The user pays this fee from the delivered margin.
Other rules:
* The user must have [approved](/programs/builder-program) the code with a `max_fee_rate` that covers the code's `fee_rate`, as for an order.
* The user's referrer earns nothing for an order that carries a builder code.
* A code that belongs to the user's own account or one of their subaccounts is ignored, and the order is placed without it.
See the [Builder Program](/programs/builder-program) for how to get a code.
#### Response
* Status 200: Order created successfully
```json theme={null}
{
"success": true,
"data": {
"game_account_address": "Cdoykiss4V6kWydv7Q1EQghNqens9Hpte2iB7qjxNxc6"
},
"error": null,
"code": null
}
```
`game_account_address` is the address of the new Print order.
* Status 400: Bad request
```json theme={null}
{
"success": false,
"data": null,
"error": "total_segments must be between 1 and 1000",
"code": 400
}
```
* Status 401: Unauthorized
* Status 409: Duplicate idempotency key
* Status 500: Internal server error
#### Code Example (Python)
```python theme={null}
import requests
payload = {
"account": "42trU9A5...",
"signature": "5j1Vy9Uq...",
"timestamp": 1716200000000,
"game": "BTC_24H",
"deposit_amount": "1000.00",
"direction": 1,
"strike_price": "95000.00",
"leverage": "2.0",
"builder_code": "MYCODE"
}
response = requests.post(
"/api/v1/game/deposit",
json=payload,
headers={"Content-Type": "application/json"}
)
data = response.json()
```
# Spot
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/spot
Endpoints for querying spot asset information and bridge parameters.
# Get Bridge Info
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/spot/get-bridge-info
This endpoint returns bridge parameters for all spot assets, including deposit minimums, withdrawal fees, and on-chain program addresses.
```http theme={null}
GET /api/v1/spot_assets/bridge/info
```
#### Response
* Status 200: Success
```json theme={null}
{
"success": true,
"data": [
{
"symbol": "SOL",
"minimum_deposit": "0.01",
"withdrawal_fee": "0.001",
"bridge_program": "5eykt4UsFv8P8NJdTREpY1vzqKqZKvdpKuc147dw2N9d",
"mint": null,
"decimals": 9
}
],
"error": null,
"code": null
}
```
| Field | Type | Description |
|---|
| `"symbol"` | string | Spot asset symbol |
| `"minimum_deposit"` | decimal string | Minimum deposit amount |
| `"withdrawal_fee"` | decimal string | Fee charged on withdrawals |
| `"bridge_program"` | string | Solana program address for the bridge |
| `"mint"` | string or null | Token mint address (null for native SOL) |
| `"decimals"` | integer | Token decimal precision |
Response is cached for 1 minute.
* Status 500: Internal server error
#### Code Example (Python)
```python theme={null}
import requests
response = requests.get(
"/api/v1/spot_assets/bridge/info",
headers={"Accept": "*/*"},
)
data = response.json()
```
# Get Bridge Parameters
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/spot/get-bridge-parameters
This endpoint returns bridge parameters for a single spot asset by symbol, including deposit minimums, withdrawal fees, and on-chain program addresses.
```http theme={null}
GET /api/v1/spot_assets/bridge/parameters/{symbol}
```
#### Path Parameters
| Parameter | Type | Required | Description |
|---|
| `symbol` | string | Yes | The spot asset symbol (e.g. SOL) |
Example: `/api/v1/spot_assets/bridge/parameters/SOL`
#### Response
* Status 200: Success
```json theme={null}
{
"success": true,
"data": {
"symbol": "SOL",
"minimum_deposit": "0.01",
"withdrawal_fee": "0.001",
"bridge_program": "5eykt4UsFv8P8NJdTREpY1vzqKqZKvdpKuc147dw2N9d",
"mint": null,
"decimals": 9
},
"error": null,
"code": null
}
```
| Field | Type | Description |
|---|
| `"symbol"` | string | Spot asset symbol |
| `"minimum_deposit"` | decimal string | Minimum deposit amount |
| `"withdrawal_fee"` | decimal string | Fee charged on withdrawals |
| `"bridge_program"` | string | Solana program address for the bridge |
| `"mint"` | string or null | Token mint address (null for native SOL) |
| `"decimals"` | integer | Token decimal precision |
* Status 404: Asset not found or no active bridge for the symbol.
* Status 500: Internal server error
#### Code Example (Python)
```python theme={null}
import requests
symbol = "SOL"
response = requests.get(
f"/api/v1/spot_assets/bridge/parameters/{symbol}",
headers={"Accept": "*/*"},
)
data = response.json()
```
# Get Spot Assets
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/spot/get-spot-assets
This endpoint returns a list of all spot assets available on the exchange, including their trading parameters and collateral eligibility.
```http theme={null}
GET /api/v1/spot_assets
```
#### Query Parameters
| Parameter | Type | Required | Description |
|---|
| `"include_inactive"` | boolean | No | Include inactive spot assets. Defaults to false. |
| `"collateral_enabled_only"` | boolean | No | Only return assets enabled as collateral. Defaults to false. |
#### Response
* Status 200: Success
```json theme={null}
{
"success": true,
"data": [
{
"symbol": "SOL",
"tick_size": "0.01",
"lot_size": "0.01",
"active": true,
"collateral_enabled": true,
"ltv_ratio": "0.80",
"created_at": 1716200000000,
"updated_at": 1716200000000
}
],
"error": null,
"code": null
}
```
| Field | Type | Description |
|---|
| `"symbol"` | string | Spot asset symbol |
| `"tick_size"` | decimal string | Minimum price increment |
| `"lot_size"` | decimal string | Minimum quantity increment |
| `"active"` | boolean | Whether the asset is currently active for trading |
| `"collateral_enabled"` | boolean | Whether the asset can be used as unified margin collateral |
| `"ltv_ratio"` | decimal string | Loan-to-value ratio when used as collateral (e.g. "0.80" = 80%) |
| `"created_at"` | integer | Timestamp in milliseconds |
| `"updated_at"` | integer | Timestamp in milliseconds |
Results are sorted alphabetically by symbol.
* Status 500: Internal server error
#### Code Example (Python)
```python theme={null}
import requests
response = requests.get(
"/api/v1/spot_assets",
headers={"Accept": "*/*"},
)
data = response.json()
```
# Subaccounts
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/subaccounts
* [Create subaccount](/api-documentation/api/rest-api/subaccounts/create-subaccount): This endpoint allows regular accounts to create subaccounts with a secure authentication scheme. Both the main account and subaccount must sign to establish the relationship.
* [List subaccounts](/api-documentation/api/rest-api/subaccounts/list-subaccounts): Lists all subaccounts associated with a main (parent) account. Returns address, balance, and other account details for each subaccount.
* [Subaccount fund transfer](/api-documentation/api/rest-api/subaccounts/subaccount-fund-transfer): This endpoint allows transfer of funds between main and subaccounts
* [Subaccount spot transfer](/api-documentation/api/rest-api/subaccounts/subaccount-spot-transfer): This endpoint allows users to transfer spot assets between a main account and its subaccounts
# Create Subaccount
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/subaccounts/create-subaccount
This endpoint allows regular accounts to create subaccounts with a secure authentication scheme. Both the main account and subaccount must sign to establish the relationship.
The subaccount creation process follows the below steps.
1. The main account must authorize the creation of a subaccount under its control
2. The subaccount must consent to being controlled by the main account
3. The API server must verify both signatures to prevent unauthorized subaccount creation\
Valid addresses must be used in order to establish main/subaccount relationships via API:
* Neither account can be a subaccount of another account.
* The subaccount address cannot have any deposit/trade history
Please refer to the [Python SDK](https://github.com/pacifica-fi/python-sdk/blob/f2385d42e9ae5276ba2ba85505d51db2eefd2715/rest/create_subaccount.py) for a comprehensive guide on subaccount creation via API
```http theme={null}
POST /api/v1/account/subaccount/create
```
#### Request Body
| Field | Type | Need | Description | Example |
|---|
| `"main_account"` | string | required | Main account wallet address | `42trU9A5...` |
| `"subaccount"` | string | required | Subaccount wallet address | `69trU9A5...` |
| `"timestamp"` | integer | required | Current timestamp in milliseconds | `1716200000000` |
| `"main_signature"` | string | required | Main account signature | `5j1Vy9Uq...` |
| `"sub_signature"` | string | required | Subaccount signature | `4k2Wx8Zq...` |
| `"expiry_window"` | integer | optional | Signature expiry in milliseconds | `30000` |
```json theme={null}
{
"main_account": "42trU9A5...",
"subaccount": "69trU9A5...",
"main_signature": "5j1Vy9Uq...",
"sub_signature": "4k2Wx8Zq...",
"timestamp": 1716200000000,
"expiry_window": 30000
}
```
#### Response
* Status 200: Subaccount created successfully
```json theme={null}
{
"success": true,
"data": null,
"error": null,
"code": null,
}
```
* Status 400: Bad request
```json theme={null}
{
"success": false,
"data": null,
"error": "Account already exists: CRTxBM...",
"code": 2
}
```
* Status 500: Internal server error
# List Subaccounts
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/subaccounts/list-subaccounts
Lists all subaccounts associated with a main (parent) account. Returns address, balance, and other account details for each subaccount.
```http theme={null}
POST /api/v1/account/subaccount/list
```
#### Request Body
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | Main account wallet address | `42trU9A5...` |
| `"signature"` | string | required | Main account signature | `5j1Vy9Uq...` |
| `"timestamp"` | integer | required | Current timestamp in milliseconds | `1716200000000` |
| `"agent_wallet"` | string | optional | Agent wallet address | `69trU9A5...` |
| `"expiry_window"` | integer | optional | Signature expiry in milliseconds | `30000` |
```json theme={null}
{
"account": "42txU9As...",
"signature": "5j1Vy9Uq...",
"timestamp": 1716200000000,
"expiry_window": 30000
}
```
#### Response
* Status 200: Subaccounts listed successfully
```json theme={null}
{
"success": true,
"data": {
"subaccounts": [
{
"address": "69txU9As...",
"balance": "1000.50",
"pending_balance": "0.00",
"fee_level": 1,
"fee_mode": "auto",
"created_at": 1716200000000,
"nickname": "Trading Bot"
}
]
},
"error": null,
"code": null
}
```
| Field | Type | Description |
| - | - | - |
| `'address'` | string | Current account balance, defined as amount of USD in account before settlement |
| `'balance'` | decimal string | Subaccount balance in USD |
| `'pending_balance'` | decimal string | Amount of subaccount balance in pending status (deposit request is successful, waiting on confirmation) |
| `'fee_level'` | integer | Current fee tier of account, determined by trading volume |
| `'fee_mode'` | string | `"auto"` by default |
| `'created_at'` | integer | Creation timestamp in milliseconds |
| `'nickname'` | string or null | Optional subaccount nickname (omitted when not set) |
* Status 400: Bad request
```json theme={null}
{
"success": false,
"data": null,
"error": "Invalid signature format",
"code": null
}
```
* Status 401: Unauthorized
```json theme={null}
{
"success": false,
"data": null,
"error": "Signature verification failed",
"code": null
}
```
# Subaccount Fund Transfer
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/subaccounts/subaccount-fund-transfer
This endpoint allows transfer of funds between main and subaccounts
Please refer to the [Python SDK](https://github.com/pacifica-fi/python-sdk/blob/main/rest/transfer_subaccount_fund.py) for a comprehensive guide on subaccount fund transfer via API
```http theme={null}
POST /api/v1/account/subaccount/transfer
```
#### Request Body
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | Sender account address | `42trU9A5...` |
| `"signature"` | string | required | Sender account signature | `5j1Vy9Uq...` |
| `"timestamp"` | integer | required | Current timestamp in milliseconds | `1716200000000` |
| `"expiry_window"` | integer | optional | Signature expiry in milliseconds | `30000` |
| `"to_account"` | string | required | Recipient wallet address | `69trU9A5...` |
| `"amount"` | decimal string | required | Transfer amount (in USDC) | `420.69` |
| `"idempotency_key"` | string | optional | Full UUID. Prevents duplicate transfers | `f47ac10b-58cc-4372-a567-0e02b2c3d479` |
| `"agent_wallet"` | string | optional | Agent wallet address | `69trU9A5...` |
```json theme={null}
{
"account": "AwX6321...",
"signature": "65L9qPp...",
"timestamp": 1749228826313,
"expiry_window": 5000,
"to_account": "CRTxBM...",
"amount": "420.69"
}
```
#### Response
* Status 200: Transfer completed successfully
```json theme={null}
Status Code: 200
{
"success": true,
"data": {
"success": true,
"error": null
},
"error": null,
"code": null
}
```
* Status 400: Bad request
```json theme={null}
Status Code: 400
{
"success": false,
"data": null,
"error": "Insufficient balance for AwX6321: 420.69 (account value: 336.9100000000000000000000)",
"code": 5
}
```
* Status 500: Internal server error
# Subaccount Spot Transfer
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/subaccounts/subaccount-spot-transfer
This endpoint allows users to transfer spot assets between a main account and its subaccounts
Please refer to the [Python SDK](https://github.com/pacifica-fi/python-sdk) for a comprehensive guide on subaccount spot transfer via API
```http theme={null}
POST /api/v1/account/subaccount/spot_asset/transfer
```
#### Request Body
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | User's wallet address (sender) | `42trU9A5...` |
| `"signature"` | string | required | Cryptographic signature | `5j1Vy9Uq...` |
| `"timestamp"` | integer | required | Current timestamp in milliseconds | `1716200000000` |
| `"to_account"` | string | required | Destination account address | `69trU9A5...` |
| `"symbol"` | string | required | Spot asset symbol (e.g. SOL) | `SOL` |
| `"amount"` | decimal string | required | Amount to transfer | `1.50000000` |
| `"idempotency_key"` | string | optional | Full UUID. Prevents duplicate transfers | `f47ac10b-58cc-4372-a567-0e02b2c3d479` |
| `"agent_wallet"` | string | optional | Agent wallet address | `69trU9A5...` |
| `"expiry_window"` | integer | optional | Signature expiry in milliseconds | `30000` |
The signature must be generated using the operation type `"transfer_spot_asset"`.
```json theme={null}
{
"account": "42trU9A5...",
"signature": "5j1Vy9Uq...",
"timestamp": 1716200000000,
"to_account": "69trU9A5...",
"symbol": "SOL",
"amount": "1.50000000",
"idempotency_key": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
"agent_wallet": "69trU9A5...",
"expiry_window": 30000
}
```
The destination account must be a subaccount of the sender, or the sender must be a subaccount transferring to its parent.
#### Response
* Status 200: Transfer completed successfully
```json theme={null}
Status Code: 200
{
"success": true,
"data": {
"success": true,
"error": null
},
"error": null,
"code": null
}
```
* Status 409: Duplicate idempotency key
* Status 500: Internal server error
#### Code Example (Python)
```python theme={null}
import requests
payload = {
"account": "42trU9A5...",
"signature": "5j1Vy9Uq...",
"timestamp": 1716200000000,
"to_account": "69trU9A5...",
"symbol": "SOL",
"amount": "1.50000000",
"idempotency_key": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
"agent_wallet": "69trU9A5...",
"expiry_window": 30000,
}
response = requests.post(
"/api/v1/account/subaccount/spot_asset/transfer",
headers={"Accept": "*/*", "Content-Type": "application/json"},
json=payload,
)
data = response.json()
```
# TWAP
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/twap
This section covers creating, cancelling, and tracking TWAP orders on Pacifica.
A TWAP (time-weighted average price) order splits an amount into smaller market orders and sends them over a set duration. For how TWAP works in the app, see [TWAP](/trading-on-pacifica/order-types/classic/twap).
Pacifica runs TWAPs in two ways:
* **TWAP orders.** You create them with [Create TWAP order](/api-documentation/api/rest-api/twap/create-twap-order). The matching engine runs them.
* **TWAP order strategies.** You create them with [Create order strategy](/api-documentation/api/rest-api/order-strategies/create-order-strategy) and `strategy_type` `twap`. They add a price limit and randomized slices. See [Strategy parameters](/api-documentation/api/rest-api/order-strategies/strategy-parameters#twap).
The `/api/v1/orders/twap` endpoints cover TWAP orders only. The `/api/v1/twaps` endpoints list both kinds together.
* [Create TWAP order](/api-documentation/api/rest-api/twap/create-twap-order): This endpoint allows users to create a TWAP order that splits an amount into market orders over a set duration.
* [Cancel TWAP order](/api-documentation/api/rest-api/twap/cancel-twap-order): This endpoint allows users to cancel an open TWAP order.
* [Get open TWAP orders](/api-documentation/api/rest-api/twap/get-open-twap-orders): This endpoint allows users to get the open TWAP orders on their account.
* [Get TWAP order history](/api-documentation/api/rest-api/twap/get-twap-order-history): This endpoint allows users to get a summarized TWAP order history.
* [Get TWAP order history by ID](/api-documentation/api/rest-api/twap/get-twap-order-history-by-id): This endpoint allows users to get every event of one TWAP order.
* [Get TWAP records](/api-documentation/api/rest-api/twap/get-twap-records): This endpoint allows users to list an account's running TWAPs, from both TWAP orders and TWAP order strategies.
* [Get TWAP record history](/api-documentation/api/rest-api/twap/get-twap-record-history): This endpoint allows users to list an account's finished TWAPs, from both TWAP orders and TWAP order strategies.
To stream TWAP orders, subscribe to [Account TWAP orders](/api-documentation/api/websocket/subscriptions/account-twap-orders) and [Account TWAP order updates](/api-documentation/api/websocket/subscriptions/account-twap-order-updates).
# Cancel TWAP Order
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/twap/cancel-twap-order
This endpoint allows users to cancel an open TWAP order.
```http theme={null}
POST /api/v1/orders/twap/cancel
```
Cancelling stops further sub-orders. Fills that already happened stay. The order's status becomes `cancelled`.
[Cancel all orders](/api-documentation/api/rest-api/orders/cancel-all-orders) also cancels TWAP orders in the markets it covers.
This endpoint cancels TWAP orders only. To cancel a TWAP order strategy, use [Cancel order strategy](/api-documentation/api/rest-api/order-strategies/cancel-order-strategy).
#### Operation Type (for Signing)
| Header Field | Type | Content |
| - | - | - |
| `"type"` | string | `"cancel_twap_order"` |
#### Request Body
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | User's wallet address | `42trU9A5...` |
| `"signature"` | string | required | Cryptographic signature | `5j1Vy9Uq...` |
| `"timestamp"` | integer | required | Current timestamp in milliseconds | `1716200000000` |
| `"symbol"` | string | required | Trading pair symbol of the TWAP order | `BTC` |
| `"order_id"` | integer | required (if no CLOID) | TWAP order ID | `13753364` |
| `"client_order_id"` | Full UUID string | required (if no OID) | Client-defined order ID of the TWAP order | `f47ac10b-58cc-4372-a567-0e02b2c3d479` |
| `"agent_wallet"` | string | optional | Agent wallet address | `69trU9A5...` |
| `"expiry_window"` | integer | optional | Signature expiry in milliseconds | `30000` |
If you send both `order_id` and `client_order_id`, Pacifica uses `client_order_id`.
```json theme={null}
{
"account": "42trU9A5...",
"signature": "5j1Vy9Uq...",
"timestamp": 1716200000000,
"symbol": "BTC",
"order_id": 13753364,
"agent_wallet": "69trU9A5...",
"expiry_window": 30000
}
```
#### Response
* Status 200: Request accepted
```json theme={null}
{
"success": true,
"data": null,
"error": null,
"code": null
}
```
The response is the same when no open TWAP order has that `order_id`. To confirm the cancel, check `order_status` in [Get TWAP order history by ID](/api-documentation/api/rest-api/twap/get-twap-order-history-by-id).
* Status 400: Invalid request body
* Status 422: The engine rejected the request, for example because no open TWAP order has that `client_order_id`
```json theme={null}
{
"success": false,
"data": null,
"error": "TwapUnusedClientOrderId(f47ac10b-58cc-4372-a567-0e02b2c3d479)",
"code": 0,
"error_id": "unspecified"
}
```
* Status 500: Internal server error
#### Code Example (Python)
```python theme={null}
import requests
payload = {
"account": "42trU9A5...",
"signature": "5j1Vy9Uq...",
"timestamp": 1716200000000,
"symbol": "BTC",
"order_id": 13753364
}
response = requests.post(
"/api/v1/orders/twap/cancel",
json=payload,
headers={"Content-Type": "application/json"}
)
data = response.json()
```
# Create TWAP Order
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/twap/create-twap-order
This endpoint allows users to create a TWAP order that splits an amount into market orders over a set duration.
```http theme={null}
POST /api/v1/orders/twap/create
```
A TWAP order splits `amount` into smaller market orders, called sub-orders, and sends them over `duration_in_seconds`. Each sub-order uses `slippage_percent` as its maximum slippage.
This endpoint creates a TWAP order that the matching engine runs. It has no price limit and no randomized slices. For those settings, create a TWAP [order strategy](/api-documentation/api/rest-api/order-strategies/strategy-parameters#twap) instead.
#### How a TWAP order runs
* Pacifica plans one sub-order for every 30 seconds of `duration_in_seconds`, plus one. It plans fewer if `amount` holds fewer lots than that, so each sub-order is at least one lot.
* Pacifica sends one sub-order about every 30 seconds.
* Each sub-order is the remaining amount divided by the remaining sub-order count, rounded down to the lot size. It is at most 3 times the planned sub-order amount.
* The order ends as `completed` when the full amount fills.
* The order ends as `expired` if part of the amount is still unfilled after the last planned sub-order, or when its time runs out. Its `expiration` is 30 seconds after the end of `duration_in_seconds`.
* If the engine rejects a sub-order, the order stops and ends as `rejected_due_to_sub_order`.
* You can have up to 4 open TWAP orders per account in each market.
#### Operation Type (for Signing)
| Header Field | Type | Content |
| - | - | - |
| `"type"` | string | `"create_twap_order"` |
#### Request Body
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | User's wallet address | `42trU9A5...` |
| `"signature"` | string | required | Cryptographic signature | `5j1Vy9Uq...` |
| `"timestamp"` | integer | required | Current timestamp in milliseconds | `1716200000000` |
| `"symbol"` | string | required | Trading pair symbol | `BTC` |
| `"amount"` | string | required | Total amount to execute, in token units | `0.121` |
| `"side"` | string | required | Order side (bid/ask) | `bid` |
| `"reduce_only"` | boolean | required | Whether each sub-order is reduce-only | `false` |
| `"slippage_percent"` | string | required | Maximum slippage for each sub-order, in percent. For example, "0.5" means 0.5%. At most 2 decimal places | `0.5` |
| `"duration_in_seconds"` | integer | required | Time to spread the sub-orders over, in seconds. Minimum 30 | `3600` |
| `"client_order_id"` | Full UUID string | optional | Client-defined order ID. Must not match another open TWAP order of yours in the same market | `f47ac10b-58cc-4372-a567-0e02b2c3d479` |
| `"agent_wallet"` | string | optional | Agent wallet address | `69trU9A5...` |
| `"expiry_window"` | integer | optional | Signature expiry in milliseconds | `30000` |
| `"builder_code"` | string | optional | Builder program code (3-16 alphanumeric characters). Not supported on spot markets | `MYCODE` |
```json theme={null}
{
"account": "42trU9A5...",
"signature": "5j1Vy9Uq...",
"timestamp": 1716200000000,
"symbol": "BTC",
"amount": "0.121",
"side": "bid",
"reduce_only": false,
"slippage_percent": "0.5",
"duration_in_seconds": 3600,
"client_order_id": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
"agent_wallet": "69trU9A5...",
"expiry_window": 30000
}
```
For this request, Pacifica plans 121 sub-orders of 0.001 BTC, about 30 seconds apart, if the BTC lot size is 0.001 or smaller.
#### Response
* Status 200: TWAP order created successfully
```json theme={null}
{
"success": true,
"data": {
"order_id": 13753364
},
"error": null,
"code": null
}
```
`order_id` is the TWAP order ID. Use it to cancel the order or to get its history.
* Status 400: Invalid request body, for example an unknown `side` or a `slippage_percent` with more than 2 decimal places
* Status 422: The engine rejected the order
```json theme={null}
{
"success": false,
"data": null,
"error": "The requested duration of twap order 10s is too short. Should be at least 30s",
"code": 0,
"error_id": "unspecified"
}
```
* Status 500: Internal server error
#### Code Example (Python)
```python theme={null}
import requests
payload = {
"account": "42trU9A5...",
"signature": "5j1Vy9Uq...",
"timestamp": 1716200000000,
"symbol": "BTC",
"amount": "0.121",
"side": "bid",
"reduce_only": False,
"slippage_percent": "0.5",
"duration_in_seconds": 3600,
"client_order_id": "f47ac10b-58cc-4372-a567-0e02b2c3d479"
}
response = requests.post(
"/api/v1/orders/twap/create",
json=payload,
headers={"Content-Type": "application/json"}
)
data = response.json()
```
# Get Open TWAP Orders
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/twap/get-open-twap-orders
This endpoint allows users to get the open TWAP orders on their account.
```http theme={null}
GET /api/v1/orders/twap
```
Returns every open TWAP order on the account. A TWAP order leaves this list when it completes, expires, or is cancelled or rejected. This list doesn't include TWAP order strategies. To see both kinds, use [Get TWAP records](/api-documentation/api/rest-api/twap/get-twap-records).
#### Query Parameters
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | Account address to filter TWAP orders | `42trU9A5...` |
```http theme={null}
/api/v1/orders/twap?account=42trU9A5...
```
#### Response
* Status 200: Successfully retrieved open TWAP orders
```json theme={null}
{
"success": true,
"data": [
{
"order_id": 13753364,
"client_order_id": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
"symbol": "BTC",
"side": "bid",
"initial_amount": "0.121",
"filled_amount": "0.04",
"reduce_only": false,
"slippage_percent": "0.500000000000",
"planned_sub_order_amount": "0.001",
"planned_sub_order_count": 121,
"past_sub_order_count": 40,
"total_filled_value": "3496.5",
"expiration": 1716203630000,
"created_at": 1716200000000,
"updated_at": 1716201200000
}
],
"error": null,
"code": null
}
```
| Field | Type | Description |
|---|
| `"order_id"` | integer | TWAP order ID |
| `"client_order_id"` | UUID or null | CLOID of the TWAP order if assigned by user |
| `"symbol"` | string | Trading pair symbol |
| `"side"` | string | Whether the order is a bid or an ask |
| `"initial_amount"` | decimal string | Total amount (in token denomination) of the TWAP order |
| `"filled_amount"` | decimal string | Amount (in token denomination) filled so far |
| `"reduce_only"` | boolean | If each sub-order is reduce only |
| `"slippage_percent"` | decimal string | Maximum slippage for each sub-order, in percent |
| `"planned_sub_order_amount"` | decimal string | Planned amount (in token denomination) of each sub-order, set at creation |
| `"planned_sub_order_count"` | integer | Number of planned sub-orders |
| `"past_sub_order_count"` | integer | Number of planned sub-orders processed so far |
| `"total_filled_value"` | decimal string | Total value (price × amount) filled across all sub-orders. Divide by `filled_amount` to get the average fill price |
| `"expiration"` | integer | Timestamp in milliseconds when the TWAP order's time runs out: 30 seconds after the end of `duration_in_seconds` |
| `"created_at"` | integer | Timestamp in milliseconds when the TWAP order was created on Pacifica |
| `"updated_at"` | integer | Timestamp in milliseconds when the TWAP order was last updated |
* Status 400: Invalid request parameters
* Status 500: Internal server error
#### Code Example (Python)
```python theme={null}
import requests
response = requests.get(
"/api/v1/orders/twap?account=42trU9A5...",
headers={"Accept": "*/*"},
)
data = response.json()
```
# Get TWAP Order History
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/twap/get-twap-order-history
This endpoint allows users to get a summarized TWAP order history.
```http theme={null}
GET /api/v1/orders/twap/history
```
Returns one row per TWAP order, open or finished, with its latest state. Rows are sorted by `order_id`, newest first. This history doesn't include TWAP order strategies. To see both kinds, use [Get TWAP record history](/api-documentation/api/rest-api/twap/get-twap-record-history).
#### Query Parameters
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | Account address to filter TWAP orders | `42trU9A5...` |
| `"limit"` | integer | optional | Maximum number of records to return, default to 100. Values above 4000 are capped at 4000 | `100` |
| `"cursor"` | string | optional | Cursor pagination to access records. Default to none | `1115hVka` |
```http theme={null}
/api/v1/orders/twap/history?account=42trU9A5...&limit=100
```
#### Response
* Status 200: Successfully retrieved TWAP order history
```json theme={null}
{
"success": true,
"data": [
{
"order_id": 13753364,
"client_order_id": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
"symbol": "BTC",
"side": "bid",
"initial_amount": "0.121",
"filled_amount": "0.04",
"average_price_of_last_filled_sub_order": "87420",
"value_of_last_filled_sub_order": "87.42",
"total_filled_value": "3496.5",
"order_status": "in_execution",
"reduce_only": false,
"slippage_percent": "0.500000000000",
"planned_sub_order_amount": "0.001",
"planned_sub_order_count": 121,
"past_sub_order_count": 40,
"expiration": 1716203630000,
"created_at": 1716200000000,
"updated_at": 1716201200000
},
...
],
"next_cursor": "1111Hyd74",
"has_more": true
}
```
| Field | Type | Description |
|---|
| `"order_id"` | integer | TWAP order ID |
| `"client_order_id"` | UUID or null | CLOID of the TWAP order if assigned by user |
| `"symbol"` | string | Trading pair symbol |
| `"side"` | string | Whether the order is a bid or an ask |
| `"initial_amount"` | decimal string | Total amount (in token denomination) of the TWAP order |
| `"filled_amount"` | decimal string | Amount (in token denomination) filled |
| `"average_price_of_last_filled_sub_order"` | decimal string | Average fill price of the latest sub-order that filled |
| `"value_of_last_filled_sub_order"` | decimal string | Filled value (price × amount) of the latest sub-order that filled |
| `"total_filled_value"` | decimal string | Total value (price × amount) filled across all sub-orders. Divide by `filled_amount` to get the average fill price |
| `"order_status"` | string | `"open"`: no sub-order processed yet\
`"in_execution"`: sending sub-orders\
`"completed"`: the full amount filled\
`"cancelled"`: cancelled, for example by a cancel request or a liquidation\
`"expired"`: ended with part of the amount unfilled\
`"rejected_due_to_sub_order"`: stopped because the engine rejected a sub-order |
| `"reduce_only"` | boolean | If each sub-order is reduce only |
| `"slippage_percent"` | decimal string | Maximum slippage for each sub-order, in percent |
| `"planned_sub_order_amount"` | decimal string | Planned amount (in token denomination) of each sub-order, set at creation |
| `"planned_sub_order_count"` | integer | Number of planned sub-orders |
| `"past_sub_order_count"` | integer | Number of planned sub-orders processed |
| `"expiration"` | integer | Timestamp in milliseconds when the TWAP order's time runs out |
| `"created_at"` | integer | Timestamp in milliseconds when the TWAP order was created on Pacifica |
| `"updated_at"` | integer | Timestamp in milliseconds of the TWAP order's latest event |
| `'next_cursor'` | string | Next cursor for pagination. Omitted when `'has_more'` is false |
| `'has_more'` | boolean | True if there exists a `'next_cursor'` |
* Status 400: Invalid request parameters
* Status 500: Internal server error
#### Code Example (Python)
```python theme={null}
import requests
response = requests.get(
"/api/v1/orders/twap/history?account=42trU9A5...&limit=100",
headers={"Accept": "*/*"},
)
data = response.json()
```
# Get TWAP Order History by ID
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/twap/get-twap-order-history-by-id
This endpoint allows users to get every event of one TWAP order.
```http theme={null}
GET /api/v1/orders/twap/history_by_id
```
Returns one row per event of the TWAP order, newest first. Each row shows the order's state after that event.
#### Query Parameters
| Field | Type | Need | Description | Example |
|---|
| `"order_id"` | integer | required | TWAP order ID to retrieve history for | `13753364` |
```http theme={null}
/api/v1/orders/twap/history_by_id?order_id=13753364
```
#### Response
* Status 200: Successfully retrieved TWAP order history
```json theme={null}
{
"success": true,
"data": [
{
"history_id": 26698518,
"order_id": 13753364,
"client_order_id": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
"symbol": "BTC",
"side": "bid",
"initial_amount": "0.121",
"filled_amount": "0.04",
"average_price_of_last_filled_sub_order": "87420",
"value_of_last_filled_sub_order": "87.42",
"event_type": "sub_order_executed",
"order_status": "in_execution",
"reduce_only": false,
"slippage_percent": "0.500000000000",
"planned_sub_order_amount": "0.001",
"planned_sub_order_count": 121,
"past_sub_order_count": 40,
"created_at": 1716201200000
},
{
"history_id": 26690012,
"order_id": 13753364,
"client_order_id": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
"symbol": "BTC",
"side": "bid",
"initial_amount": "0.121",
"filled_amount": "0",
"average_price_of_last_filled_sub_order": "0",
"value_of_last_filled_sub_order": "0",
"event_type": "twap_created",
"order_status": "open",
"reduce_only": false,
"slippage_percent": "0.500000000000",
"planned_sub_order_amount": "0.001",
"planned_sub_order_count": 121,
"past_sub_order_count": 0,
"created_at": 1716200000000
}
],
"error": null,
"code": null
}
```
| Field | Type | Description |
|---|
| `"history_id"` | integer | History ID of the event |
| `"order_id"` | integer | TWAP order ID |
| `"client_order_id"` | UUID or null | CLOID of the TWAP order if assigned by user |
| `"symbol"` | string | Trading pair symbol |
| `"side"` | string | Whether the order is a bid or an ask |
| `"initial_amount"` | decimal string | Total amount (in token denomination) of the TWAP order |
| `"filled_amount"` | decimal string | Amount (in token denomination) filled after this event |
| `"average_price_of_last_filled_sub_order"` | decimal string | Average fill price of the sub-order in this event. `0` if the event has no fill |
| `"value_of_last_filled_sub_order"` | decimal string | Filled value (price × amount) of the sub-order in this event. `0` if the event has no fill |
| `"event_type"` | string | `"twap_created"`: order created\
`"sub_order_executed"`: a sub-order was placed\
`"sub_order_failed"`: the engine rejected a sub-order\
`"cancel"`: order cancelled\
`"reject_sub_order_failure"`: order stopped after a rejected sub-order\
`"expiration"`: order expired with part of the amount unfilled\
`"completion"`: the full amount filled |
| `"order_status"` | string | `"open"`\
`"in_execution"`\
`"completed"`\
`"cancelled"`\
`"expired"`\
`"rejected_due_to_sub_order"`\
See [Get TWAP order history](/api-documentation/api/rest-api/twap/get-twap-order-history) |
| `"reduce_only"` | boolean | If each sub-order is reduce only |
| `"slippage_percent"` | decimal string | Maximum slippage for each sub-order, in percent |
| `"planned_sub_order_amount"` | decimal string | Planned amount (in token denomination) of each sub-order, set at creation |
| `"planned_sub_order_count"` | integer | Number of planned sub-orders |
| `"past_sub_order_count"` | integer | Number of planned sub-orders processed after this event |
| `"created_at"` | integer | Timestamp in milliseconds when the event occurred |
* Status 400: Invalid request parameters
* Status 404: No history for this TWAP order ID
* Status 500: Internal server error
#### Code Example (Python)
```python theme={null}
import requests
response = requests.get(
"/api/v1/orders/twap/history_by_id?order_id=13753364",
headers={"Accept": "*/*"},
)
data = response.json()
```
# Get TWAP Record History
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/twap/get-twap-record-history
This endpoint allows users to list an account's finished TWAPs, from both TWAP orders and TWAP order strategies.
```http theme={null}
GET /api/v1/twaps/history
```
Returns every finished TWAP on the account, as one list of records. Like [Get TWAP records](/api-documentation/api/rest-api/twap/get-twap-records), it merges TWAP orders (`identity.kind` is `order`) and TWAP order strategies (`identity.kind` is `strategy`).
Records are sorted by creation time, newest first. Only TWAP orders created through the API are listed.
#### Query Parameters
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | Account address to filter TWAPs | `42trU9A5...` |
| `"limit"` | integer | optional | Maximum number of records to return, default to 100. Values outside 1 to 500 are clamped to that range | `100` |
| `"cursor"` | string | optional | The `next_cursor` from the previous page. Default to none | `3vQB7B6M...` |
```http theme={null}
/api/v1/twaps/history?account=42trU9A5...&limit=100
```
#### Response
* Status 200: Successfully retrieved TWAP record history
```json theme={null}
{
"success": true,
"data": {
"records": [
{
"identity": {
"kind": "order",
"order_id": 13753364
},
"symbol": "BTC",
"side": "bid",
"initial_amount": "0.121000000000000000",
"filled_amount": "0.121000000000000000",
"average_fill_price": "87398.2",
"reduce_only": false,
"duration_seconds": 3630,
"randomize": false,
"slippage_percent": "0.500000000000",
"price_limit": null,
"number_of_clips": 121,
"placed_clip_count": 121,
"status": "completed",
"terminal_reason": null,
"created_at_ms": 1716200000000,
"updated_at_ms": 1716203600000,
"capabilities": []
},
{
"identity": {
"kind": "strategy",
"strategy_id": "0f8e7c2a-4b1d-4e5f-9a3b-2c1d0e9f8a7b",
"revision": 1
},
"symbol": "ETH",
"side": "ask",
"initial_amount": "2",
"filled_amount": "0.5",
"average_fill_price": "3120.4",
"reduce_only": false,
"duration_seconds": 1800,
"randomize": true,
"slippage_percent": null,
"price_limit": "3000",
"number_of_clips": 61,
"placed_clip_count": 15,
"status": "cancelled",
"terminal_reason": "user_cancel",
"created_at_ms": 1716190000000,
"updated_at_ms": 1716190460000,
"capabilities": ["timeline"]
}
],
"next_cursor": "3vQB7B6M...",
"has_more": true
},
"error": null,
"code": null
}
```
The record fields match [Get TWAP records](/api-documentation/api/rest-api/twap/get-twap-records). These fields differ:
| Field | Type | Description |
|---|
| `"status"` | string | `"completed"`: the TWAP finished. For an order, this means the full amount filled\
`"cancelled"`: cancelled, by you or by Pacifica\
`"expired"`: the TWAP ended early or unfilled. For an order, part of the amount was still unfilled when it ran out of planned sub-orders or time. For a strategy, it reached its expiry or scheduled end\
`"failed"`: the TWAP could not continue. For an order, the engine rejected a sub-order |
| `"terminal_reason"` | string or null | Why the TWAP stopped, when known, for example `"user_cancel"`, `"boundary_cancel"`, `"insufficient_balance"`, or `"rejected"`. For an order, `"user_cancel"` when `"cancelled"`, `"rejected"` when `"failed"`, and `null` otherwise |
| `"capabilities"` | array of strings | `["timeline"]` for a strategy. Empty for an order |
* Status 400: Invalid request parameters or cursor
* Status 500: Internal server error
#### Code Example (Python)
```python theme={null}
import requests
response = requests.get(
"/api/v1/twaps/history?account=42trU9A5...&limit=100",
headers={"Accept": "*/*"},
)
data = response.json()
```
# Get TWAP Records
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/twap/get-twap-records
This endpoint allows users to list an account's running TWAPs, from both TWAP orders and TWAP order strategies.
```http theme={null}
GET /api/v1/twaps
```
Returns every TWAP on the account that hasn't finished, as one list of records. The list merges two sources:
* TWAP orders, from [Create TWAP order](/api-documentation/api/rest-api/twap/create-twap-order). `identity.kind` is `order`.
* TWAP order strategies, from [Create order strategy](/api-documentation/api/rest-api/order-strategies/create-order-strategy) with `strategy_type` `twap`. `identity.kind` is `strategy`.
Records are sorted by creation time, newest first. Only TWAP orders created through the API are listed. A new TWAP order can take a moment to appear. For finished TWAPs, use [Get TWAP record history](/api-documentation/api/rest-api/twap/get-twap-record-history).
#### Query Parameters
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | Account address to filter TWAPs | `42trU9A5...` |
| `"limit"` | integer | optional | Maximum number of records to return, default to 100. Values outside 1 to 500 are clamped to that range | `100` |
| `"cursor"` | string | optional | The `next_cursor` from the previous page. Default to none | `3vQB7B6M...` |
```http theme={null}
/api/v1/twaps?account=42trU9A5...&limit=100
```
#### Response
* Status 200: Successfully retrieved TWAP records
```json theme={null}
{
"success": true,
"data": {
"records": [
{
"identity": {
"kind": "strategy",
"strategy_id": "0f8e7c2a-4b1d-4e5f-9a3b-2c1d0e9f8a7b",
"revision": 1
},
"symbol": "ETH",
"side": "ask",
"initial_amount": "2",
"filled_amount": "0.5",
"average_fill_price": "3120.4",
"reduce_only": false,
"duration_seconds": 1800,
"randomize": true,
"slippage_percent": null,
"price_limit": "3000",
"number_of_clips": 61,
"placed_clip_count": 15,
"status": "running",
"terminal_reason": null,
"created_at_ms": 1716200300000,
"updated_at_ms": 1716200750000,
"capabilities": ["cancel", "timeline"]
},
{
"identity": {
"kind": "order",
"order_id": 13753364
},
"symbol": "BTC",
"side": "bid",
"initial_amount": "0.121000000000000000",
"filled_amount": "0.040000000000000000",
"average_fill_price": "87412.5",
"reduce_only": false,
"duration_seconds": 3630,
"randomize": false,
"slippage_percent": "0.500000000000",
"price_limit": null,
"number_of_clips": 121,
"placed_clip_count": 40,
"status": "running",
"terminal_reason": null,
"created_at_ms": 1716200000000,
"updated_at_ms": 1716201200000,
"capabilities": ["cancel"]
}
],
"next_cursor": null,
"has_more": false
},
"error": null,
"code": null
}
```
| Field | Type | Description |
|---|
| `"identity"` | object | Where the TWAP comes from. `"kind"` is `"order"` or `"strategy"`. An order has `"order_id"` (integer). A strategy has `"strategy_id"` (UUID) and `"revision"` (integer) |
| `"symbol"` | string | Trading pair symbol |
| `"side"` | string | Whether the TWAP is a bid or an ask |
| `"initial_amount"` | decimal string | Total amount (in token denomination) of the TWAP |
| `"filled_amount"` | decimal string | Amount (in token denomination) filled so far |
| `"average_fill_price"` | decimal string or null | Average fill price. `null` if nothing has filled |
| `"reduce_only"` | boolean | If each slice is reduce only |
| `"duration_seconds"` | integer | For a strategy, the duration you set. For an order, the time from creation to `expiration`, which is about 30 seconds longer than `duration_in_seconds` |
| `"randomize"` | boolean | If slice sizes and timing are randomized. Always `false` for an order |
| `"slippage_percent"` | decimal string or null | Maximum slippage for each slice, in percent. `null` for a strategy that uses the default |
| `"price_limit"` | decimal string or null | Price limit of a strategy. Always `null` for an order |
| `"number_of_clips"` | integer | Number of planned slices. For an order, this is `planned_sub_order_count` |
| `"placed_clip_count"` | integer | Number of slices processed so far. For an order, this is `past_sub_order_count` |
| `"status"` | string | `"pending"`: a strategy waiting for its scheduled start\
`"active"`: an order with no slice processed yet, or an armed strategy that isn't placing slices yet\
`"running"`: placing slices\
`"paused"`: a strategy held by its price limit |
| `"terminal_reason"` | string or null | Always `null` here. See [Get TWAP record history](/api-documentation/api/rest-api/twap/get-twap-record-history) |
| `"created_at_ms"` | integer | Timestamp in milliseconds when the TWAP was created |
| `"updated_at_ms"` | integer | Timestamp in milliseconds when the TWAP was last updated |
| `"capabilities"` | array of strings | What you can do with the TWAP now:\
`"cancel"`: cancel an order with [Cancel TWAP order](/api-documentation/api/rest-api/twap/cancel-twap-order), or a strategy with [Cancel order strategy](/api-documentation/api/rest-api/order-strategies/cancel-order-strategy)\
`"edit"`: edit the strategy with [Edit order strategy](/api-documentation/api/rest-api/order-strategies/edit-order-strategy). Only before it starts placing orders, and not while paused\
`"timeline"`: get the strategy's events with [Get order strategy timeline](/api-documentation/api/rest-api/order-strategies/get-order-strategy-timeline) |
| `'next_cursor'` | string or null | Next cursor for pagination |
| `'has_more'` | boolean | True if there exists a `'next_cursor'` |
Amounts and slippage of an order record keep their stored decimal places, for example `0.121000000000000000`.
* Status 400: Invalid request parameters or cursor
* Status 500: Internal server error
#### Code Example (Python)
```python theme={null}
import requests
response = requests.get(
"/api/v1/twaps?account=42trU9A5...&limit=100",
headers={"Accept": "*/*"},
)
data = response.json()
```
# Two-Factor Authentication
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/two-factor
This section covers two-factor authentication (2FA) for withdrawals and factor changes.
Two-factor authentication (2FA) adds a second check to withdrawals. When 2FA is on, every withdrawal and every factor change needs a proof from a second factor, in addition to the request signature. Renaming a factor is the only change that needs no proof.
A factor is one of these:
* An authenticator app (TOTP) that shows a 6-digit code.
* A passkey or a security key (WebAuthn). These work only in the Pacifica app. See [Passkeys and security keys](#passkeys-and-security-keys).
API clients should use an authenticator app.
* [Get two-factor status](/api-documentation/api/rest-api/two-factor/get-two-factor-status): This endpoint allows users to get an account's two-factor status, factors, and remaining recovery keys.
* [Begin TOTP enrollment](/api-documentation/api/rest-api/two-factor/begin-totp-enrollment): This endpoint allows users to start adding an authenticator app (TOTP) factor.
* [Finish TOTP enrollment](/api-documentation/api/rest-api/two-factor/finish-totp-enrollment): This endpoint allows users to confirm an authenticator app (TOTP) factor with a code.
* [Begin WebAuthn registration](/api-documentation/api/rest-api/two-factor/begin-webauthn-registration): This endpoint allows users to start registering a passkey or security key.
* [Finish WebAuthn registration](/api-documentation/api/rest-api/two-factor/finish-webauthn-registration): This endpoint allows users to finish registering a passkey or security key.
* [Begin WebAuthn authentication](/api-documentation/api/rest-api/two-factor/begin-webauthn-authentication): This endpoint allows users to get a challenge for a passkey or security key proof.
* [Disable two-factor authentication](/api-documentation/api/rest-api/two-factor/disable-two-factor): This endpoint allows users to turn off two-factor authentication and delete every factor and recovery key.
* [Remove factor](/api-documentation/api/rest-api/two-factor/remove-factor): This endpoint allows users to remove one factor.
* [Rename factor](/api-documentation/api/rest-api/two-factor/rename-factor): This endpoint allows users to change a factor's label.
* [Regenerate recovery keys](/api-documentation/api/rest-api/two-factor/regenerate-recovery-keys): This endpoint allows users to replace their recovery keys with a new set.
### Turn on 2FA with an authenticator app
1. Call [Begin TOTP enrollment](/api-documentation/api/rest-api/two-factor/begin-totp-enrollment) with a `label`. The response has an `enrollment_id`, a base32 `secret`, and an `otpauth_uri`.
2. Add the secret to an authenticator app. Show `otpauth_uri` as a QR code, or type `secret` in by hand. Codes use SHA-1, 6 digits, and a 30-second period.
3. Within 10 minutes, call [Finish TOTP enrollment](/api-documentation/api/rest-api/two-factor/finish-totp-enrollment) with the `enrollment_id` and the app's current `code`.
4. Save the `recovery_keys` from the response. Pacifica shows them only once.
2FA is now on. [Get two-factor status](/api-documentation/api/rest-api/two-factor/get-two-factor-status) returns `"protected_actions": ["withdrawal"]`.
The code that finishes enrollment is used up. Wait for the next code before you send your first proof.
### Proofs
A proof is a JSON object. Its `type` field selects the factor.
| `type` | Shape | Content |
| - | - | - |
| `"totp"` | `{"type": "totp", "code": "123456"}` | The authenticator app's current code, as a string of exactly 6 digits |
| `"recovery_key"` | `{"type": "recovery_key", "key": "3f9a-1c0b-77de-a4e2-0b19-5c6d-e8f0-2a7b"}` | One of your [recovery keys](#recovery-keys) |
| `"webauthn"` | `{"type": "webauthn", "challenge_id": "45c48cce-...", "credential": {...}}` | A passkey or security key assertion. See [Begin WebAuthn authentication](/api-documentation/api/rest-api/two-factor/begin-webauthn-authentication) |
Put the proof in the request body:
* In `two_factor` on withdrawals, [Begin TOTP enrollment](/api-documentation/api/rest-api/two-factor/begin-totp-enrollment), and [Begin WebAuthn registration](/api-documentation/api/rest-api/two-factor/begin-webauthn-registration).
* In `proof` on [Disable two-factor authentication](/api-documentation/api/rest-api/two-factor/disable-two-factor), [Remove factor](/api-documentation/api/rest-api/two-factor/remove-factor), and [Regenerate recovery keys](/api-documentation/api/rest-api/two-factor/regenerate-recovery-keys).
Do not sign the proof. Sign the request without it, then add the proof to the body.
Each proof works once:
* A TOTP code works once. After a proof passes, wait for the next code.
* A recovery key works once.
* A WebAuthn challenge works once.
Each action accepts these proofs:
| Action | `totp` | `webauthn` | `recovery_key` |
| - | - | - | - |
| Withdrawal | Yes | Yes | No |
| Add a factor while 2FA is on | Yes | Yes | Yes |
| Remove a factor | Yes | Yes | Yes |
| Regenerate recovery keys | Yes | Yes | Yes |
| Disable 2FA | Yes | Yes | Yes |
Renaming a factor needs no proof. A recovery key on a withdrawal returns status `422`.
### Who can sign
| Endpoint | Signer | Account |
| - | - | - |
| [Get two-factor status](/api-documentation/api/rest-api/two-factor/get-two-factor-status) | Account key or [agent wallet](/api-documentation/api/signing/api-agent-keys) | Main account only |
| [Begin WebAuthn authentication](/api-documentation/api/rest-api/two-factor/begin-webauthn-authentication) | Account key or [agent wallet](/api-documentation/api/signing/api-agent-keys) | Account with 2FA on |
| Every other 2FA endpoint | Account key only | Main account only |
An agent wallet cannot add, remove, or rename factors. It cannot regenerate recovery keys or turn 2FA off. A subaccount gets status `403` from the main-account-only endpoints.
These endpoints use the normal [signing scheme](/api-documentation/api/signing/implementation). Each page shows the `data` object to sign. Some request fields are not signed: `code` on Finish TOTP enrollment, `credential` on Finish WebAuthn registration, and every proof. Sign UUID values in lowercase, as the API returns them.
### Limits
* **Proof attempts.** Each signer can make 5 proof attempts per 5 minutes. A proof that passes resets this count. The account key and each agent wallet have separate counts, so an agent wallet that sends wrong proofs locks out only itself.
* **Wrong proofs.** Each signer can send 30 wrong proofs per 24 hours. After that, Pacifica refuses every proof from that signer with status `429` until 24 hours after its first wrong proof. A proof that passes does not reset this count.
* **WebAuthn challenges.** Each signer can request up to 60 challenges per 10 minutes for each action. A WebAuthn proof with an unknown, expired, or used challenge does not count as a proof attempt.
* **Factors.** An account can have up to 8 factors. It can have only one authenticator app. A new authenticator app replaces the old one when you finish its enrollment.
* **Enrollments.** You can start up to 20 enrollments per 10 minutes. An enrollment lasts 10 minutes. A TOTP enrollment allows 5 wrong codes. After that, start again.
* **Retrying a begin call.** While 2FA is on, the begin enrollment calls need a proof. After the proof passes, you can repeat the same begin request, with the same `label` (and `kind` for WebAuthn), for 5 minutes without a new proof. This helps when a user cancels an authenticator prompt.
* **Factor changes.** Adding a factor, removing a factor, regenerating recovery keys, and disabling 2FA end every enrollment in progress and every 5-minute retry window. A finish call then returns status `422` with `two-factor settings changed. Start again.` Renaming a factor does not end them.
Pacifica checks the factor limit, the enrollment limit, and whether a factor can be removed before it checks the proof. A request that fails these checks does not use up your code.
### Recovery keys
* Your first factor comes with 10 recovery keys. Later factors do not add keys. Their finish response has an empty `recovery_keys` list.
* Pacifica shows recovery keys only once. Store them somewhere safe.
* A key is 8 groups of 4 hex characters, for example `3f9a-1c0b-77de-a4e2-0b19-5c6d-e8f0-2a7b`. Case and hyphens do not matter.
* Each key works once. [Get two-factor status](/api-documentation/api/rest-api/two-factor/get-two-factor-status) returns `recovery_keys_remaining`.
* A recovery key authorizes factor changes only. It never authorizes a withdrawal.
* If you lose your authenticator app, send a recovery key as the proof to [Begin TOTP enrollment](/api-documentation/api/rest-api/two-factor/begin-totp-enrollment) or to [Disable two-factor authentication](/api-documentation/api/rest-api/two-factor/disable-two-factor).
* [Regenerate recovery keys](/api-documentation/api/rest-api/two-factor/regenerate-recovery-keys) replaces the whole set. Disabling 2FA deletes it.
### Withdrawals
When 2FA is on, every withdrawal needs a proof, including withdrawals that an agent wallet signs. Send an `idempotency_key`, and send the proof in `two_factor`. For details, see [Request withdrawal](/api-documentation/api/rest-api/account/request-withdrawal) and [Withdraw spot asset](/api-documentation/api/rest-api/account/withdraw-spot-asset).
### Passkeys and security keys
Passkeys and security keys use WebAuthn. Pacifica binds them to its own domain, and it accepts them only from the Pacifica app's origin. Pacifica also rejects an assertion that another site requested through an embedded frame, that is, an assertion with `crossOrigin` or `topOrigin` set in its client data.
So in practice, you can register and use a passkey only in the Pacifica app. A script or bot cannot make a passkey proof. API clients should use an authenticator app.
A WebAuthn proof needs a challenge from [Begin WebAuthn authentication](/api-documentation/api/rest-api/two-factor/begin-webauthn-authentication). The challenge is bound to the exact request that the proof authorizes.
### Errors
2FA errors carry an `error_id`. Match on `error_id`, not on `error`. See [Error codes](/api-documentation/api/error-codes).
| Status | `error_id` | Meaning |
| - | - | - |
| `400` | | Invalid request fields or signature. A withdrawal without `idempotency_key` while 2FA is on |
| `401` | `second_factor_invalid` | The proof is wrong, expired, or already used. Or the WebAuthn challenge is expired, used, or for another request |
| `403` | | The account is a subaccount, or it does not exist |
| `409` | `operation_conflict` | The withdrawal `idempotency_key` belongs to a different request |
| `422` | `second_factor_setup_incomplete` | The request does not fit the account's 2FA setup. `error` says why. See below |
| `428` | `second_factor_required` | 2FA is on, and the request has no proof |
| `429` | `second_factor_rate_limited` | Too many proof attempts, enrollments, or WebAuthn challenges |
| `503` | `second_factor_unavailable` | The two-factor service is unavailable. Retry later |
```json theme={null}
{
"success": false,
"data": null,
"error": "two-factor proof is required",
"code": 428,
"error_id": "second_factor_required"
}
```
`error` values with status `422`:
| `error` | Meaning |
| - | - |
| `set up two-factor authentication before continuing` | The account has never started an enrollment |
| `two-factor is not enabled` | 2FA is off, and the call needs it on |
| `two-factor settings changed. Start again.` | A factor change ended this enrollment. Start a new one |
| `a user can have at most 8 factors` | The account already has 8 factors |
| `the last factor cannot be removed. Disable two-factor instead.` | Remove factor cannot remove the only factor |
| `unknown factor` | No factor on the account has this `factor_id` |
| `a recovery key only authorizes factor changes` | A recovery key was sent for a withdrawal |
| `credential is already registered` | This passkey or security key is already a factor |
| `the authenticator must verify the user with a PIN or biometric` | The authenticator did not verify the user |
| `no matching WebAuthn credential` | The account has no factor of the requested `kind` |
### Code Example (Python)
This example turns on 2FA with an authenticator app, then withdraws with a TOTP proof. The signing steps follow [Signing](/api-documentation/api/signing/implementation).
```python theme={null}
import json
import time
import uuid
import base58
import requests
from solders.keypair import Keypair
API_URL = "https://api.pacifica.fi/api/v1"
keypair = Keypair.from_bytes(base58.b58decode("your_private_key_here"))
account = str(keypair.pubkey())
def sort_json_keys(value):
if isinstance(value, dict):
return {key: sort_json_keys(value[key]) for key in sorted(value)}
if isinstance(value, list):
return [sort_json_keys(item) for item in value]
return value
def signed_post(path, operation_type, data, unsigned=None):
"""Signs `data`, then adds the `unsigned` fields, such as a proof, to the body."""
timestamp = int(time.time() * 1_000)
message = {
"timestamp": timestamp,
"expiry_window": 30_000,
"type": operation_type,
"data": data,
}
compact = json.dumps(sort_json_keys(message), separators=(",", ":"))
signature = keypair.sign_message(compact.encode("utf-8"))
body = {
"account": account,
"signature": base58.b58encode(bytes(signature)).decode("ascii"),
"timestamp": timestamp,
"expiry_window": 30_000,
**data,
**(unsigned or {}),
}
return requests.post(f"{API_URL}{path}", json=body).json()
# 1. Start the enrollment. Add the URI to an authenticator app.
begin = signed_post(
"/account/2fa/totp/begin", "begin_totp_enrollment", {"label": "Authenticator app"}
)
print(begin["data"]["otpauth_uri"])
# 2. Finish with the app's current code. The code is not signed.
finish = signed_post(
"/account/2fa/totp/finish",
"finish_totp_enrollment",
{"enrollment_id": begin["data"]["enrollment_id"]},
unsigned={"code": input("Code: ")},
)
recovery_keys = finish["data"]["recovery_keys"] # Pacifica shows these only once
# 3. Withdraw with a TOTP proof. Use a new code, not the one from step 2.
withdrawal = signed_post(
"/account/withdraw",
"withdraw",
{"amount": "100.50", "idempotency_key": str(uuid.uuid4())},
unsigned={"two_factor": {"type": "totp", "code": input("Next code: ")}},
)
```
# Begin TOTP Enrollment
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/two-factor/begin-totp-enrollment
This endpoint allows users to start adding an authenticator app (TOTP) factor.
```http theme={null}
POST /api/v1/account/2fa/totp/begin
```
Starts adding an authenticator app as a [two-factor](/api-documentation/api/rest-api/two-factor) factor. The response has a new TOTP secret. Add it to an authenticator app, then call [Finish TOTP enrollment](/api-documentation/api/rest-api/two-factor/finish-totp-enrollment) with a code within 10 minutes.
#### Operation Type (for Signing)
| Header Field | Type | Content |
| - | - | - |
| `"type"` | string | `"begin_totp_enrollment"` |
#### Request Body
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | User's wallet address | `42trU9A5...` |
| `"signature"` | string | required | Cryptographic signature | `5j1Vy9Uq...` |
| `"timestamp"` | integer | required | Current timestamp in milliseconds | `1716200000000` |
| `"label"` | string | required | Your name for the factor. 1 to 64 characters, with no control characters and no leading or trailing spaces | `Authenticator app` |
| `"expiry_window"` | integer | optional | Signature expiry in milliseconds | `30000` |
| `"two_factor"` | object | conditional | Proof. Required while 2FA is on. Not part of the signed payload. See [Proofs](/api-documentation/api/rest-api/two-factor#proofs) | `{"type": "totp", "code": "123456"}` |
```json theme={null}
{
"account": "42trU9A5...",
"signature": "5j1Vy9Uq...",
"timestamp": 1716200000000,
"label": "Authenticator app",
"expiry_window": 30000
}
```
Sign this request with the account's own key. Agent wallets cannot sign it. The account must be a main account.
If 2FA is already on, send a proof in `two_factor`. Any proof type works, including a recovery key. After the proof passes, you can send the same request with the same `label` again for 5 minutes without a new proof.
An account has one authenticator app. If it already has one, the new one replaces it when you finish enrollment.
#### Signing
Sign `label` as the `data` object. Do not sign `two_factor`. For the request above, the message to sign is:
```json theme={null}
{"data":{"label":"Authenticator app"},"expiry_window":30000,"timestamp":1716200000000,"type":"begin_totp_enrollment"}
```
#### Response
* Status 200: Enrollment started
```json theme={null}
{
"success": true,
"data": {
"enrollment_id": "8f14e45f-ceea-467a-9575-0b3a8d6c3f1e",
"secret": "JBSWY3DPEHPK3PXPJBSWY3DPEHPK3PXP",
"otpauth_uri": "otpauth://totp/Pacifica:42trU9...xNc6?secret=JBSWY3DPEHPK3PXPJBSWY3DPEHPK3PXP&issuer=Pacifica"
},
"error": null,
"code": null
}
```
| Field | Type | Description |
| - | - | - |
| `'enrollment_id'` | string | Enrollment ID (UUID). Send it to [Finish TOTP enrollment](/api-documentation/api/rest-api/two-factor/finish-totp-enrollment) within 10 minutes |
| `'secret'` | string | TOTP secret in base32. Type it into an authenticator app if you cannot scan a QR code |
| `'otpauth_uri'` | string | `otpauth://` URI with the secret. Show it as a QR code for an authenticator app |
Codes use SHA-1, 6 digits, and a 30-second period. The authenticator app shows the issuer `Pacifica` and a short form of your wallet address.
Keep the secret private. Anyone who has it can make codes.
* Status 400: Invalid request parameters, label, or signature
* Status 401: The proof is wrong, expired, or already used
* Status 403: The account is a subaccount, or it does not exist
* Status 422: The account has no room for another factor (`a user can have at most 8 factors`)
* Status 428: 2FA is on, and the request has no `two_factor`
```json theme={null}
{
"success": false,
"data": null,
"error": "two-factor proof is required",
"code": 428,
"error_id": "second_factor_required"
}
```
* Status 429: Too many proof attempts, or more than 20 enrollments started in 10 minutes
* Status 500: Internal server error
* Status 503: The two-factor service is unavailable. Retry later
#### Code Example (Python)
```python theme={null}
import requests
payload = {
"account": "42trU9A5...",
"signature": "5j1Vy9Uq...",
"timestamp": 1716200000000,
"label": "Authenticator app"
}
response = requests.post(
"/api/v1/account/2fa/totp/begin",
json=payload,
headers={"Content-Type": "application/json"}
)
data = response.json()
```
# Begin WebAuthn Authentication
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/two-factor/begin-webauthn-authentication
This endpoint allows users to get a challenge for a passkey or security key proof.
```http theme={null}
POST /api/v1/account/2fa/webauthn/authenticate/begin
```
Returns a WebAuthn challenge for a passkey or security key [proof](/api-documentation/api/rest-api/two-factor#proofs). The challenge is bound to one request: a withdrawal or a factor change.
Pacifica accepts passkeys only from the Pacifica app. A script or bot cannot make a passkey proof. API clients should use a TOTP proof. See [Passkeys and security keys](/api-documentation/api/rest-api/two-factor#passkeys-and-security-keys).
#### Operation Type (for Signing)
| Header Field | Type | Content |
| - | - | - |
| `"type"` | string | `"begin_webauthn_authentication"` |
#### Request Body
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | User's wallet address | `42trU9A5...` |
| `"signature"` | string | required | Cryptographic signature | `5j1Vy9Uq...` |
| `"timestamp"` | integer | required | Current timestamp in milliseconds | `1716200000000` |
| `"action"` | string | required | What the proof will authorize:\
`"withdrawal"`\
`"factor_management"` | `withdrawal` |
| `"intent_hash"` | string | required | Hash of the request that the proof will authorize. Base64url, no padding, 32 bytes. See below | `q1Xn0bJr8m2p...` |
| `"kind"` | string | required | Factor kind to use:\
`"passkey"`\
`"security_key"` | `passkey` |
| `"agent_wallet"` | string | optional | Agent wallet address | `69trU9A5...` |
| `"expiry_window"` | integer | optional | Signature expiry in milliseconds | `30000` |
```json theme={null}
{
"account": "42trU9A5...",
"signature": "5j1Vy9Uq...",
"timestamp": 1716200000000,
"action": "withdrawal",
"intent_hash": "q1Xn0bJr8m2p...",
"kind": "passkey",
"expiry_window": 30000
}
```
You can sign this request with the account key or with an [agent wallet](/api-documentation/api/signing/api-agent-keys). The account must have 2FA on.
`intent_hash` covers the action, the account, and the signed `type` and `data` of the request that the proof will authorize. It does not cover `timestamp` or `expiry_window`. The Pacifica app computes `intent_hash` for you.
To use the challenge:
1. Pass `options` to `navigator.credentials.get()` in the Pacifica app.
2. Send the request that `intent_hash` describes, with this proof in `two_factor` or `proof`:
```json theme={null}
{
"type": "webauthn",
"challenge_id": "45c48cce-2e2d-4fbd-8f3b-7a1c9e0d5b62",
"credential": {
"id": "pQx3...",
"rawId": "pQx3...",
"type": "public-key",
"response": {
"authenticatorData": "SZYN5YgO...",
"clientDataJSON": "eyJ0eXBl...",
"signature": "MEUCIQDx...",
"userHandle": "rT9b..."
}
}
}
```
`credential` is the assertion from `navigator.credentials.get()` as JSON, with binary values as base64url strings.
A challenge lasts 5 minutes and works once. If the proof arrives with a different request, Pacifica rejects it and the challenge is used up.
#### Signing
Sign `action`, `intent_hash`, and `kind` as the `data` object. For the request above, the message to sign is:
```json theme={null}
{"data":{"action":"withdrawal","intent_hash":"q1Xn0bJr8m2p...","kind":"passkey"},"expiry_window":30000,"timestamp":1716200000000,"type":"begin_webauthn_authentication"}
```
#### Response
* Status 200: Challenge created
```json theme={null}
{
"success": true,
"data": {
"challenge_id": "45c48cce-2e2d-4fbd-8f3b-7a1c9e0d5b62",
"options": {
"publicKey": {
"challenge": "x8Jf2KqLm0pR..."
}
}
},
"error": null,
"code": null
}
```
The `options` above are shortened.
| Field | Type | Description |
| - | - | - |
| `'challenge_id'` | string | Challenge ID (UUID). Send it in the `webauthn` proof within 5 minutes. It works once |
| `'options'` | object | WebAuthn request options for `navigator.credentials.get()`. Binary values are base64url strings |
* Status 400: Invalid request parameters, `intent_hash`, or signature
* Status 403: The account does not exist
* Status 422: The account cannot make this proof. The `error` field says why:
| `error` | Meaning |
| - | - |
| `two-factor is not enabled` | 2FA is off |
| `no matching WebAuthn credential` | The account has no factor of this `kind` |
| `set up two-factor authentication before continuing` | The account has never started an enrollment |
* Status 429: More than 60 challenges in 10 minutes for this action and signer
* Status 500: Internal server error
* Status 503: The two-factor service is unavailable. Retry later
#### Code Example (Python)
```python theme={null}
import requests
payload = {
"account": "42trU9A5...",
"signature": "5j1Vy9Uq...",
"timestamp": 1716200000000,
"action": "withdrawal",
"intent_hash": "q1Xn0bJr8m2p...",
"kind": "passkey"
}
response = requests.post(
"/api/v1/account/2fa/webauthn/authenticate/begin",
json=payload,
headers={"Content-Type": "application/json"}
)
data = response.json()
```
# Begin WebAuthn Registration
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/two-factor/begin-webauthn-registration
This endpoint allows users to start registering a passkey or security key.
```http theme={null}
POST /api/v1/account/2fa/webauthn/register/begin
```
Starts registering a passkey or a security key as a [two-factor](/api-documentation/api/rest-api/two-factor) factor. The response has WebAuthn options for the browser. Pass them to `navigator.credentials.create()`, then call [Finish WebAuthn registration](/api-documentation/api/rest-api/two-factor/finish-webauthn-registration) within 10 minutes.
Pacifica accepts passkeys only from the Pacifica app. A script or bot cannot register one. API clients should use an [authenticator app](/api-documentation/api/rest-api/two-factor/begin-totp-enrollment). See [Passkeys and security keys](/api-documentation/api/rest-api/two-factor#passkeys-and-security-keys).
#### Operation Type (for Signing)
| Header Field | Type | Content |
| - | - | - |
| `"type"` | string | `"begin_webauthn_registration"` |
#### Request Body
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | User's wallet address | `42trU9A5...` |
| `"signature"` | string | required | Cryptographic signature | `5j1Vy9Uq...` |
| `"timestamp"` | integer | required | Current timestamp in milliseconds | `1716200000000` |
| `"kind"` | string | required | Factor kind:\
`"passkey"`\
`"security_key"` | `security_key` |
| `"label"` | string | required | Your name for the factor. 1 to 64 characters, with no control characters and no leading or trailing spaces | `YubiKey 5C` |
| `"expiry_window"` | integer | optional | Signature expiry in milliseconds | `30000` |
| `"two_factor"` | object | conditional | Proof. Required while 2FA is on. Not part of the signed payload. See [Proofs](/api-documentation/api/rest-api/two-factor#proofs) | `{"type": "totp", "code": "123456"}` |
```json theme={null}
{
"account": "42trU9A5...",
"signature": "5j1Vy9Uq...",
"timestamp": 1716200000000,
"kind": "security_key",
"label": "YubiKey 5C",
"expiry_window": 30000,
"two_factor": {
"type": "totp",
"code": "123456"
}
}
```
Sign this request with the account's own key. Agent wallets cannot sign it. The account must be a main account.
If 2FA is already on, send a proof in `two_factor`. Any proof type works, including a recovery key. After the proof passes, you can send the same request with the same `kind` and `label` again for 5 minutes without a new proof. This helps when the user cancels the browser prompt.
A `"passkey"` must verify the user with a PIN or biometric. A `"security_key"` asks the browser for a separate device, such as a USB or NFC key. The device names the new credential with a short form of your wallet address and your `label`.
#### Signing
Sign `kind` and `label` as the `data` object. Do not sign `two_factor`. For the request above, the message to sign is:
```json theme={null}
{"data":{"kind":"security_key","label":"YubiKey 5C"},"expiry_window":30000,"timestamp":1716200000000,"type":"begin_webauthn_registration"}
```
#### Response
* Status 200: Registration started
```json theme={null}
{
"success": true,
"data": {
"challenge_id": "45c48cce-2e2d-4fbd-8f3b-7a1c9e0d5b62",
"options": {
"publicKey": {
"challenge": "x8Jf2KqLm0pR..."
}
}
},
"error": null,
"code": null
}
```
The `options` above are shortened.
| Field | Type | Description |
| - | - | - |
| `'challenge_id'` | string | Challenge ID (UUID). Send it to [Finish WebAuthn registration](/api-documentation/api/rest-api/two-factor/finish-webauthn-registration) within 10 minutes. It works once |
| `'options'` | object | WebAuthn creation options for `navigator.credentials.create()`. Binary values are base64url strings |
* Status 400: Invalid request parameters, label, or signature
* Status 401: The proof is wrong, expired, or already used
* Status 403: The account is a subaccount, or it does not exist
* Status 422: The account has no room for another factor (`a user can have at most 8 factors`)
* Status 428: 2FA is on, and the request has no `two_factor`
* Status 429: Too many proof attempts, or more than 20 enrollments started in 10 minutes
* Status 500: Internal server error
* Status 503: The two-factor service is unavailable. Retry later
#### Code Example (Python)
```python theme={null}
import requests
payload = {
"account": "42trU9A5...",
"signature": "5j1Vy9Uq...",
"timestamp": 1716200000000,
"kind": "security_key",
"label": "YubiKey 5C",
"two_factor": {"type": "totp", "code": "123456"}
}
response = requests.post(
"/api/v1/account/2fa/webauthn/register/begin",
json=payload,
headers={"Content-Type": "application/json"}
)
data = response.json()
```
# Disable Two-Factor Authentication
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/two-factor/disable-two-factor
This endpoint allows users to turn off two-factor authentication and delete every factor and recovery key.
```http theme={null}
POST /api/v1/account/2fa/disable
```
Turns off [two-factor authentication](/api-documentation/api/rest-api/two-factor). Pacifica deletes every factor and every recovery key on the account. After that, withdrawals and factor changes do not need a proof.
#### Operation Type (for Signing)
| Header Field | Type | Content |
| - | - | - |
| `"type"` | string | `"disable_two_factor"` |
#### Request Body
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | User's wallet address | `42trU9A5...` |
| `"signature"` | string | required | Cryptographic signature | `5j1Vy9Uq...` |
| `"timestamp"` | integer | required | Current timestamp in milliseconds | `1716200000000` |
| `"proof"` | object | required | Proof. A recovery key works. Not part of the signed payload. See [Proofs](/api-documentation/api/rest-api/two-factor#proofs) | `{"type": "totp", "code": "123456"}` |
| `"expiry_window"` | integer | optional | Signature expiry in milliseconds | `30000` |
```json theme={null}
{
"account": "42trU9A5...",
"signature": "5j1Vy9Uq...",
"timestamp": 1716200000000,
"proof": {
"type": "totp",
"code": "123456"
},
"expiry_window": 30000
}
```
Sign this request with the account's own key. Agent wallets cannot sign it. The account must be a main account.
This call also ends every enrollment in progress. To turn 2FA on again, enroll a new factor. Your first new factor comes with a new set of recovery keys.
#### Signing
The `data` object is empty. Do not sign `proof`. For the request above, the message to sign is:
```json theme={null}
{"data":{},"expiry_window":30000,"timestamp":1716200000000,"type":"disable_two_factor"}
```
#### Response
* Status 200: Two-factor authentication turned off
```json theme={null}
{
"success": true,
"data": null,
"error": null,
"code": null
}
```
* Status 400: Invalid request parameters or signature
* Status 401: The proof is wrong, expired, or already used
* Status 403: The account is a subaccount, or it does not exist
* Status 422: The account has never started an enrollment (`set up two-factor authentication before continuing`)
* Status 429: Too many proof attempts
* Status 500: Internal server error
* Status 503: The two-factor service is unavailable. Retry later
#### Code Example (Python)
```python theme={null}
import requests
payload = {
"account": "42trU9A5...",
"signature": "5j1Vy9Uq...",
"timestamp": 1716200000000,
"proof": {"type": "totp", "code": "123456"}
}
response = requests.post(
"/api/v1/account/2fa/disable",
json=payload,
headers={"Content-Type": "application/json"}
)
data = response.json()
```
# Finish TOTP Enrollment
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/two-factor/finish-totp-enrollment
This endpoint allows users to confirm an authenticator app (TOTP) factor with a code.
```http theme={null}
POST /api/v1/account/2fa/totp/finish
```
Confirms an authenticator app with its current code. Call it after [Begin TOTP enrollment](/api-documentation/api/rest-api/two-factor/begin-totp-enrollment). When this call succeeds, [two-factor authentication](/api-documentation/api/rest-api/two-factor) is on.
#### Operation Type (for Signing)
| Header Field | Type | Content |
| - | - | - |
| `"type"` | string | `"finish_totp_enrollment"` |
#### Request Body
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | User's wallet address | `42trU9A5...` |
| `"signature"` | string | required | Cryptographic signature | `5j1Vy9Uq...` |
| `"timestamp"` | integer | required | Current timestamp in milliseconds | `1716200000000` |
| `"enrollment_id"` | string | required | Enrollment ID (UUID) from Begin TOTP enrollment | `8f14e45f-ceea-467a-9575-0b3a8d6c3f1e` |
| `"code"` | string | required | The authenticator app's current code. Exactly 6 digits. Not part of the signed payload | `123456` |
| `"expiry_window"` | integer | optional | Signature expiry in milliseconds | `30000` |
```json theme={null}
{
"account": "42trU9A5...",
"signature": "5j1Vy9Uq...",
"timestamp": 1716200000000,
"enrollment_id": "8f14e45f-ceea-467a-9575-0b3a8d6c3f1e",
"code": "123456",
"expiry_window": 30000
}
```
Sign this request with the account's own key. Agent wallets cannot sign it. The account must be a main account.
This call needs no proof. Begin TOTP enrollment already checked it.
* If the code is wrong, the enrollment stays open. Try again.
* After 5 wrong codes, the enrollment ends. Start again.
* After 10 minutes, the enrollment expires. Start again.
The code that you send is used up. Wait for the next code before you send your first proof.
#### Signing
Sign `enrollment_id` as the `data` object. Do not sign `code`. For the request above, the message to sign is:
```json theme={null}
{"data":{"enrollment_id":"8f14e45f-ceea-467a-9575-0b3a8d6c3f1e"},"expiry_window":30000,"timestamp":1716200000000,"type":"finish_totp_enrollment"}
```
#### Response
* Status 200: Authenticator app added
```json theme={null}
{
"success": true,
"data": {
"recovery_keys": [
"3f9a-1c0b-77de-a4e2-0b19-5c6d-e8f0-2a7b",
"9e2d-4b7a-0c61-f385-a7d2-6e19-3b40-c8f5",
"..."
]
},
"error": null,
"code": null
}
```
| Field | Type | Description |
| - | - | - |
| `'recovery_keys'` | array | New [recovery keys](/api-documentation/api/rest-api/two-factor#recovery-keys). 10 keys for your first factor. Empty when 2FA was already on |
Pacifica shows recovery keys only once. Store them somewhere safe.
* Status 400: Invalid request parameters or signature
* Status 401: The code is wrong, or the enrollment is unknown, expired, or ended
```json theme={null}
{
"success": false,
"data": null,
"error": "two-factor proof is invalid or has expired",
"code": 401,
"error_id": "second_factor_invalid"
}
```
* Status 403: The account is a subaccount, or it does not exist
* Status 422: A factor change ended this enrollment (`two-factor settings changed. Start again.`), or the account has no room for another factor
* Status 500: Internal server error
* Status 503: The two-factor service is unavailable. Retry later
#### Code Example (Python)
```python theme={null}
import requests
payload = {
"account": "42trU9A5...",
"signature": "5j1Vy9Uq...",
"timestamp": 1716200000000,
"enrollment_id": "8f14e45f-ceea-467a-9575-0b3a8d6c3f1e",
"code": "123456"
}
response = requests.post(
"/api/v1/account/2fa/totp/finish",
json=payload,
headers={"Content-Type": "application/json"}
)
data = response.json()
```
# Finish WebAuthn Registration
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/two-factor/finish-webauthn-registration
This endpoint allows users to finish registering a passkey or security key.
```http theme={null}
POST /api/v1/account/2fa/webauthn/register/finish
```
Finishes registering a passkey or a security key. Call it after [Begin WebAuthn registration](/api-documentation/api/rest-api/two-factor/begin-webauthn-registration). When this call succeeds, [two-factor authentication](/api-documentation/api/rest-api/two-factor) is on.
Pacifica accepts passkeys only from the Pacifica app. See [Passkeys and security keys](/api-documentation/api/rest-api/two-factor#passkeys-and-security-keys).
#### Operation Type (for Signing)
| Header Field | Type | Content |
| - | - | - |
| `"type"` | string | `"finish_webauthn_registration"` |
#### Request Body
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | User's wallet address | `42trU9A5...` |
| `"signature"` | string | required | Cryptographic signature | `5j1Vy9Uq...` |
| `"timestamp"` | integer | required | Current timestamp in milliseconds | `1716200000000` |
| `"challenge_id"` | string | required | Challenge ID (UUID) from Begin WebAuthn registration | `45c48cce-2e2d-4fbd-8f3b-7a1c9e0d5b62` |
| `"credential"` | object | required | The credential from `navigator.credentials.create()` as JSON, with binary values as base64url strings. Not part of the signed payload | See below |
| `"expiry_window"` | integer | optional | Signature expiry in milliseconds | `30000` |
```json theme={null}
{
"account": "42trU9A5...",
"signature": "5j1Vy9Uq...",
"timestamp": 1716200000000,
"challenge_id": "45c48cce-2e2d-4fbd-8f3b-7a1c9e0d5b62",
"credential": {
"id": "pQx3...",
"rawId": "pQx3...",
"type": "public-key",
"response": {
"attestationObject": "o2NmbXRk...",
"clientDataJSON": "eyJ0eXBl..."
}
},
"expiry_window": 30000
}
```
Sign this request with the account's own key. Agent wallets cannot sign it. The account must be a main account.
This call needs no proof. Begin WebAuthn registration already checked it.
The challenge works once. If this call fails, start again with Begin WebAuthn registration.
#### Signing
Sign `challenge_id` as the `data` object. Do not sign `credential`. For the request above, the message to sign is:
```json theme={null}
{"data":{"challenge_id":"45c48cce-2e2d-4fbd-8f3b-7a1c9e0d5b62"},"expiry_window":30000,"timestamp":1716200000000,"type":"finish_webauthn_registration"}
```
#### Response
* Status 200: Passkey or security key added
```json theme={null}
{
"success": true,
"data": {
"recovery_keys": []
},
"error": null,
"code": null
}
```
| Field | Type | Description |
| - | - | - |
| `'recovery_keys'` | array | New [recovery keys](/api-documentation/api/rest-api/two-factor#recovery-keys). 10 keys for your first factor. Empty when 2FA was already on |
Pacifica shows recovery keys only once. Store them somewhere safe.
* Status 400: Invalid request parameters or signature
* Status 401: The credential is not valid, or the challenge is unknown, expired, or already used
* Status 403: The account is a subaccount, or it does not exist
* Status 422: The registration does not fit the account. The `error` field says why:
| `error` | Meaning |
| - | - |
| `credential is already registered` | This passkey or security key is already a factor |
| `the authenticator must verify the user with a PIN or biometric` | The authenticator did not verify the user |
| `two-factor settings changed. Start again.` | A factor change ended this registration |
| `a user can have at most 8 factors` | The account already has 8 factors |
* Status 500: Internal server error
* Status 503: The two-factor service is unavailable. Retry later
#### Code Example (Python)
```python theme={null}
import requests
payload = {
"account": "42trU9A5...",
"signature": "5j1Vy9Uq...",
"timestamp": 1716200000000,
"challenge_id": "45c48cce-2e2d-4fbd-8f3b-7a1c9e0d5b62",
"credential": credential # from navigator.credentials.create() in the Pacifica app
}
response = requests.post(
"/api/v1/account/2fa/webauthn/register/finish",
json=payload,
headers={"Content-Type": "application/json"}
)
data = response.json()
```
# Get Two-Factor Status
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/two-factor/get-two-factor-status
This endpoint allows users to get an account's two-factor status, factors, and remaining recovery keys.
```http theme={null}
POST /api/v1/account/2fa/status
```
Returns whether [two-factor authentication](/api-documentation/api/rest-api/two-factor) is on, the account's factors, and the number of unused recovery keys.
#### Operation Type (for Signing)
| Header Field | Type | Content |
| - | - | - |
| `"type"` | string | `"two_factor_status"` |
#### Request Body
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | User's wallet address | `42trU9A5...` |
| `"signature"` | string | required | Cryptographic signature | `5j1Vy9Uq...` |
| `"timestamp"` | integer | required | Current timestamp in milliseconds | `1716200000000` |
| `"agent_wallet"` | string | optional | Agent wallet address | `69trU9A5...` |
| `"expiry_window"` | integer | optional | Signature expiry in milliseconds | `30000` |
```json theme={null}
{
"account": "42trU9A5...",
"signature": "5j1Vy9Uq...",
"timestamp": 1716200000000,
"agent_wallet": "69trU9A5...",
"expiry_window": 30000
}
```
You can sign this request with the account key or with an [agent wallet](/api-documentation/api/signing/api-agent-keys). The account must be a main account.
#### Signing
The `data` object is empty. For the request above, the message to sign is:
```json theme={null}
{"data":{},"expiry_window":30000,"timestamp":1716200000000,"type":"two_factor_status"}
```
#### Response
* Status 200: Success
```json theme={null}
{
"success": true,
"data": {
"protected_actions": ["withdrawal"],
"factors": [
{
"id": "c9f0f895-fb98-4b91-a3b5-6e9e7c2f1d4a",
"kind": "totp",
"label": "Authenticator app",
"created_at": "2026-10-10T12:00:00.123456Z",
"last_used_at": "2026-10-12T08:30:15.654321Z"
}
],
"recovery_keys_remaining": 10
},
"error": null,
"code": null
}
```
| Field | Type | Description |
| - | - | - |
| `'protected_actions'` | array | Actions that need a proof. `["withdrawal"]` while 2FA is on. Empty while 2FA is off |
| `'factors'` | array | The account's factors. See below |
| `'recovery_keys_remaining'` | integer | Number of unused recovery keys |
While 2FA is on, factor changes also need a proof. `protected_actions` lists only withdrawals.
Each entry in `factors` has these fields:
| Field | Type | Description |
| - | - | - |
| `'id'` | string | Factor ID (UUID). Send it to [Rename factor](/api-documentation/api/rest-api/two-factor/rename-factor) or [Remove factor](/api-documentation/api/rest-api/two-factor/remove-factor) |
| `'kind'` | string | `"totp"`, `"passkey"`, or `"security_key"` |
| `'label'` | string | Your name for the factor |
| `'created_at'` | string | When the factor was added (RFC 3339) |
| `'last_used_at'` | string or null | When a proof from this factor last passed (RFC 3339). `null` if the factor has not made a proof yet |
An account that never turned on 2FA returns empty lists and `"recovery_keys_remaining": 0`.
* Status 400: Invalid request parameters or signature
* Status 403: The account is a subaccount, or it does not exist
* Status 500: Internal server error
* Status 503: The two-factor service is unavailable. Retry later
#### Code Example (Python)
```python theme={null}
import requests
payload = {
"account": "42trU9A5...",
"signature": "5j1Vy9Uq...",
"timestamp": 1716200000000
}
response = requests.post(
"/api/v1/account/2fa/status",
json=payload,
headers={"Content-Type": "application/json"}
)
data = response.json()
```
# Regenerate Recovery Keys
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/two-factor/regenerate-recovery-keys
This endpoint allows users to replace their recovery keys with a new set.
```http theme={null}
POST /api/v1/account/2fa/recovery-keys/regenerate
```
Replaces your [recovery keys](/api-documentation/api/rest-api/two-factor#recovery-keys) with a new set of 10. Your old keys stop working, including unused ones.
#### Operation Type (for Signing)
| Header Field | Type | Content |
| - | - | - |
| `"type"` | string | `"regenerate_recovery_keys"` |
#### Request Body
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | User's wallet address | `42trU9A5...` |
| `"signature"` | string | required | Cryptographic signature | `5j1Vy9Uq...` |
| `"timestamp"` | integer | required | Current timestamp in milliseconds | `1716200000000` |
| `"proof"` | object | required | Proof. A recovery key works. Not part of the signed payload. See [Proofs](/api-documentation/api/rest-api/two-factor#proofs) | `{"type": "totp", "code": "123456"}` |
| `"expiry_window"` | integer | optional | Signature expiry in milliseconds | `30000` |
```json theme={null}
{
"account": "42trU9A5...",
"signature": "5j1Vy9Uq...",
"timestamp": 1716200000000,
"proof": {
"type": "totp",
"code": "123456"
},
"expiry_window": 30000
}
```
Sign this request with the account's own key. Agent wallets cannot sign it. The account must be a main account.
This call also ends every enrollment in progress.
#### Signing
The `data` object is empty. Do not sign `proof`. For the request above, the message to sign is:
```json theme={null}
{"data":{},"expiry_window":30000,"timestamp":1716200000000,"type":"regenerate_recovery_keys"}
```
#### Response
* Status 200: Recovery keys replaced
```json theme={null}
{
"success": true,
"data": {
"recovery_keys": [
"3f9a-1c0b-77de-a4e2-0b19-5c6d-e8f0-2a7b",
"9e2d-4b7a-0c61-f385-a7d2-6e19-3b40-c8f5",
"..."
]
},
"error": null,
"code": null
}
```
| Field | Type | Description |
| - | - | - |
| `'recovery_keys'` | array | The 10 new recovery keys |
Pacifica shows recovery keys only once. Store them somewhere safe.
* Status 400: Invalid request parameters or signature
* Status 401: The proof is wrong, expired, or already used
* Status 403: The account is a subaccount, or it does not exist
* Status 422: 2FA is off (`two-factor is not enabled`)
* Status 429: Too many proof attempts
* Status 500: Internal server error
* Status 503: The two-factor service is unavailable. Retry later
#### Code Example (Python)
```python theme={null}
import requests
payload = {
"account": "42trU9A5...",
"signature": "5j1Vy9Uq...",
"timestamp": 1716200000000,
"proof": {"type": "totp", "code": "123456"}
}
response = requests.post(
"/api/v1/account/2fa/recovery-keys/regenerate",
json=payload,
headers={"Content-Type": "application/json"}
)
data = response.json()
```
# Remove Factor
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/two-factor/remove-factor
This endpoint allows users to remove one factor.
```http theme={null}
POST /api/v1/account/2fa/factors/remove
```
Removes one [two-factor](/api-documentation/api/rest-api/two-factor) factor. Your other factors and your recovery keys stay. To get factor IDs, call [Get two-factor status](/api-documentation/api/rest-api/two-factor/get-two-factor-status).
You cannot remove the last factor. To remove it, [disable two-factor authentication](/api-documentation/api/rest-api/two-factor/disable-two-factor).
#### Operation Type (for Signing)
| Header Field | Type | Content |
| - | - | - |
| `"type"` | string | `"remove_two_factor_factor"` |
#### Request Body
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | User's wallet address | `42trU9A5...` |
| `"signature"` | string | required | Cryptographic signature | `5j1Vy9Uq...` |
| `"timestamp"` | integer | required | Current timestamp in milliseconds | `1716200000000` |
| `"factor_id"` | string | required | ID (UUID) of the factor to remove | `c9f0f895-fb98-4b91-a3b5-6e9e7c2f1d4a` |
| `"proof"` | object | required | Proof. A recovery key works. Not part of the signed payload. See [Proofs](/api-documentation/api/rest-api/two-factor#proofs) | `{"type": "totp", "code": "123456"}` |
| `"expiry_window"` | integer | optional | Signature expiry in milliseconds | `30000` |
```json theme={null}
{
"account": "42trU9A5...",
"signature": "5j1Vy9Uq...",
"timestamp": 1716200000000,
"factor_id": "c9f0f895-fb98-4b91-a3b5-6e9e7c2f1d4a",
"proof": {
"type": "totp",
"code": "123456"
},
"expiry_window": 30000
}
```
Sign this request with the account's own key. Agent wallets cannot sign it. The account must be a main account.
Pacifica checks that the factor exists and is not the last one before it checks the proof. A request that fails these checks does not use up your proof.
This call also ends every enrollment in progress.
#### Signing
Sign `factor_id` as the `data` object. Do not sign `proof`. For the request above, the message to sign is:
```json theme={null}
{"data":{"factor_id":"c9f0f895-fb98-4b91-a3b5-6e9e7c2f1d4a"},"expiry_window":30000,"timestamp":1716200000000,"type":"remove_two_factor_factor"}
```
#### Response
* Status 200: Factor removed
```json theme={null}
{
"success": true,
"data": null,
"error": null,
"code": null
}
```
* Status 400: Invalid request parameters or signature
* Status 401: The proof is wrong, expired, or already used
* Status 403: The account is a subaccount, or it does not exist
* Status 422: The factor cannot be removed. The `error` field says why:
| `error` | Meaning |
| - | - |
| `the last factor cannot be removed. Disable two-factor instead.` | This is the account's only factor |
| `unknown factor` | No factor on the account has this `factor_id` |
| `two-factor is not enabled` | 2FA is off |
* Status 429: Too many proof attempts
* Status 500: Internal server error
* Status 503: The two-factor service is unavailable. Retry later
#### Code Example (Python)
```python theme={null}
import requests
payload = {
"account": "42trU9A5...",
"signature": "5j1Vy9Uq...",
"timestamp": 1716200000000,
"factor_id": "c9f0f895-fb98-4b91-a3b5-6e9e7c2f1d4a",
"proof": {"type": "totp", "code": "123456"}
}
response = requests.post(
"/api/v1/account/2fa/factors/remove",
json=payload,
headers={"Content-Type": "application/json"}
)
data = response.json()
```
# Rename Factor
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/two-factor/rename-factor
This endpoint allows users to change a factor's label.
```http theme={null}
POST /api/v1/account/2fa/factors/rename
```
Changes the label of one [two-factor](/api-documentation/api/rest-api/two-factor) factor. To get factor IDs, call [Get two-factor status](/api-documentation/api/rest-api/two-factor/get-two-factor-status).
This call needs no proof, because a label grants no access. It does not end enrollments in progress.
#### Operation Type (for Signing)
| Header Field | Type | Content |
| - | - | - |
| `"type"` | string | `"rename_two_factor_factor"` |
#### Request Body
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | User's wallet address | `42trU9A5...` |
| `"signature"` | string | required | Cryptographic signature | `5j1Vy9Uq...` |
| `"timestamp"` | integer | required | Current timestamp in milliseconds | `1716200000000` |
| `"factor_id"` | string | required | ID (UUID) of the factor to rename | `c9f0f895-fb98-4b91-a3b5-6e9e7c2f1d4a` |
| `"label"` | string | required | New name for the factor. 1 to 64 characters, with no control characters and no leading or trailing spaces | `Phone` |
| `"expiry_window"` | integer | optional | Signature expiry in milliseconds | `30000` |
```json theme={null}
{
"account": "42trU9A5...",
"signature": "5j1Vy9Uq...",
"timestamp": 1716200000000,
"factor_id": "c9f0f895-fb98-4b91-a3b5-6e9e7c2f1d4a",
"label": "Phone",
"expiry_window": 30000
}
```
Sign this request with the account's own key. Agent wallets cannot sign it. The account must be a main account.
#### Signing
Sign `factor_id` and `label` as the `data` object. For the request above, the message to sign is:
```json theme={null}
{"data":{"factor_id":"c9f0f895-fb98-4b91-a3b5-6e9e7c2f1d4a","label":"Phone"},"expiry_window":30000,"timestamp":1716200000000,"type":"rename_two_factor_factor"}
```
#### Response
* Status 200: Factor renamed
```json theme={null}
{
"success": true,
"data": null,
"error": null,
"code": null
}
```
* Status 400: Invalid request parameters, label, or signature
* Status 403: The account is a subaccount, or it does not exist
* Status 422: No factor on the account has this `factor_id` (`unknown factor`)
* Status 500: Internal server error
* Status 503: The two-factor service is unavailable. Retry later
#### Code Example (Python)
```python theme={null}
import requests
payload = {
"account": "42trU9A5...",
"signature": "5j1Vy9Uq...",
"timestamp": 1716200000000,
"factor_id": "c9f0f895-fb98-4b91-a3b5-6e9e7c2f1d4a",
"label": "Phone"
}
response = requests.post(
"/api/v1/account/2fa/factors/rename",
json=payload,
headers={"Content-Type": "application/json"}
)
data = response.json()
```
# Vaults
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/vaults
REST API endpoints for creating, funding, configuring, and listing vaults.
Pacifica's user-facing docs call these managed pools **vaults**, while the REST API namespace currently uses `/api/v1/lake/*`.
## Endpoints
* [Create vault](/api-documentation/api/rest-api/vaults/create-vault)
* [Claim vault referral code](/api-documentation/api/rest-api/vaults/claim-vault-referral-code)
* [Deposit to vault](/api-documentation/api/rest-api/vaults/deposit-to-vault)
* [Claim vault manager](/api-documentation/api/rest-api/vaults/claim-vault-manager)
* [Withdraw from vault](/api-documentation/api/rest-api/vaults/withdraw-from-vault)
* [Update vault deposit cap](/api-documentation/api/rest-api/vaults/update-vault-deposit-cap)
* [Add vault whitelist](/api-documentation/api/rest-api/vaults/add-vault-whitelist)
* [Remove vault whitelist](/api-documentation/api/rest-api/vaults/remove-vault-whitelist)
* [Add vault blacklist](/api-documentation/api/rest-api/vaults/add-vault-blacklist)
* [Remove vault blacklist](/api-documentation/api/rest-api/vaults/remove-vault-blacklist)
* [Add vault max leverage](/api-documentation/api/rest-api/vaults/add-vault-max-leverage)
* [Remove vault max leverage](/api-documentation/api/rest-api/vaults/remove-vault-max-leverage)
* [List vaults](/api-documentation/api/rest-api/vaults/list-vaults)
# Add Vault Blacklist
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/vaults/add-vault-blacklist
Add blocked symbols to a vault blacklist.
```http theme={null}
POST /api/v1/lake/add_blacklist
```
The operation type for signing is `"add_lake_blacklist"`.
Only the vault creator can call this endpoint.
#### Request Body
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | Creator wallet address | `42trU9A5...` |
| `"signature"` | string | required | Cryptographic signature | `5J3mBbAH...` |
| `"timestamp"` | integer | required | Current timestamp in milliseconds | `1716200000000` |
| `"lake"` | string | required | Vault address | `AbCdEfGh123456789...` |
| `"symbols"` | string array | required | Symbols to add to the blacklist | `["BTC", "ETH"]` |
| `"agent_wallet"` | string | optional | Agent wallet address | `69trU9A5...` |
| `"expiry_window"` | integer | optional | Signature expiry in milliseconds | `30000` |
```json theme={null}
{
"account": "42trU9A5...",
"signature": "5J3mBbAH...",
"timestamp": 1716200000000,
"lake": "AbCdEfGh123456789...",
"symbols": ["BTC", "ETH"]
}
```
#### Response
* Status 200: Blacklist updated successfully
```json theme={null}
{
"success": true,
"data": {
"success": true
},
"error": null,
"code": null
}
```
* Status 400: Invalid request parameters
* Status 401: Unauthorized access
* Status 403: Caller is not the vault creator
* Status 500: Internal server error
# Add Vault Max Leverage
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/vaults/add-vault-max-leverage
Add per-symbol max leverage limits for a vault.
```http theme={null}
POST /api/v1/lake/add_max_leverage
```
The operation type for signing is `"add_lake_max_leverage"`.
Only the vault creator can call this endpoint.
#### Request Body
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | Creator wallet address | `42trU9A5...` |
| `"signature"` | string | required | Cryptographic signature | `5J3mBbAH...` |
| `"timestamp"` | integer | required | Current timestamp in milliseconds | `1716200000000` |
| `"lake"` | string | required | Vault address | `AbCdEfGh123456789...` |
| `"symbols"` | string array | required | Symbols that should receive the same max leverage cap | `["BTC", "ETH"]` |
| `"max_leverage"` | decimal string | required | Maximum leverage to apply to every listed symbol | `10` |
| `"agent_wallet"` | string | optional | Agent wallet address | `69trU9A5...` |
| `"expiry_window"` | integer | optional | Signature expiry in milliseconds | `30000` |
```json theme={null}
{
"account": "42trU9A5...",
"signature": "5J3mBbAH...",
"timestamp": 1716200000000,
"lake": "AbCdEfGh123456789...",
"symbols": ["BTC", "ETH"],
"max_leverage": "10"
}
```
#### Response
* Status 200: Max leverage updated successfully
```json theme={null}
{
"success": true,
"data": {
"success": true
},
"error": null,
"code": null
}
```
* Status 400: Invalid request parameters
* Status 401: Unauthorized access
* Status 403: Caller is not the vault creator
* Status 500: Internal server error
# Add Vault Whitelist
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/vaults/add-vault-whitelist
Add tradable symbols to a vault whitelist.
```http theme={null}
POST /api/v1/lake/add_whitelist
```
The operation type for signing is `"add_lake_whitelist"`.
Only the vault creator can call this endpoint.
#### Request Body
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | Creator wallet address | `42trU9A5...` |
| `"signature"` | string | required | Cryptographic signature | `5J3mBbAH...` |
| `"timestamp"` | integer | required | Current timestamp in milliseconds | `1716200000000` |
| `"lake"` | string | required | Vault address | `AbCdEfGh123456789...` |
| `"symbols"` | string array | required | Symbols to add to the whitelist | `["BTC", "ETH"]` |
| `"agent_wallet"` | string | optional | Agent wallet address | `69trU9A5...` |
| `"expiry_window"` | integer | optional | Signature expiry in milliseconds | `30000` |
```json theme={null}
{
"account": "42trU9A5...",
"signature": "5J3mBbAH...",
"timestamp": 1716200000000,
"lake": "AbCdEfGh123456789...",
"symbols": ["BTC", "ETH"]
}
```
#### Response
* Status 200: Whitelist updated successfully
```json theme={null}
{
"success": true,
"data": {
"success": true
},
"error": null,
"code": null
}
```
* Status 400: Invalid request parameters
* Status 401: Unauthorized access
* Status 403: Caller is not the vault creator
* Status 500: Internal server error
# Claim Vault Manager
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/vaults/claim-vault-manager
Claim the manager role on a fresh vault.
```http theme={null}
POST /api/v1/lake/claim_manager
```
The operation type for signing is `"claim_lake_manager"`.
This endpoint is only for fresh vaults that were created without a manager.
#### Request Body
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | Claimer wallet address | `42trU9A5...` |
| `"signature"` | string | required | Cryptographic signature | `5J3mBbAH...` |
| `"timestamp"` | integer | required | Current timestamp in milliseconds | `1716200000000` |
| `"lake"` | string | required | Vault address | `AbCdEfGh123456789...` |
| `"deposit_amount"` | decimal string | required | Manager's initial deposit amount | `1000.00` |
| `"agent_wallet"` | string | optional | Agent wallet address | `69trU9A5...` |
| `"expiry_window"` | integer | optional | Signature expiry in milliseconds | `30000` |
```json theme={null}
{
"account": "42trU9A5...",
"signature": "5J3mBbAH...",
"timestamp": 1716200000000,
"lake": "AbCdEfGh123456789...",
"deposit_amount": "1000.00"
}
```
#### Response
* Status 200: Manager claim successful
```json theme={null}
{
"success": true,
"data": {
"shares_minted": "1000.00"
},
"error": null,
"code": null
}
```
| Field | Type | Description |
| - | - | - |
| `'shares_minted'` | decimal string | Number of manager shares minted to the claimer |
* Status 400: Invalid request parameters
* Status 401: Unauthorized access
* Status 500: Internal server error
# Claim Vault Referral Code
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/vaults/claim-vault-referral-code
Claim a referral code for an existing vault.
```http theme={null}
POST /api/v1/lake/claim_referral_code
```
The operation type for signing is `"claim_lake_referral"`.
Only the vault creator can claim a referral code for an existing vault.
#### Request Body
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | Creator wallet address | `42trU9A5...` |
| `"signature"` | string | required | Cryptographic signature | `5J3mBbAH...` |
| `"timestamp"` | integer | required | Current timestamp in milliseconds | `1716200000000` |
| `"lake"` | string | required | Vault address | `AbCdEfGh123456789...` |
| `"code"` | string | required | Referral code to claim | `testcode` |
| `"agent_wallet"` | string | optional | Agent wallet address | `69trU9A5...` |
| `"expiry_window"` | integer | optional | Signature expiry in milliseconds | `30000` |
```json theme={null}
{
"account": "42trU9A5...",
"signature": "5J3mBbAH...",
"timestamp": 1716200000000,
"lake": "AbCdEfGh123456789...",
"code": "testcode"
}
```
#### Response
* Status 200: Referral code claimed successfully
```json theme={null}
{
"success": true,
"data": {
"success": true
},
"error": null,
"code": null
}
```
* Status 400: Invalid request parameters or caller is not the vault creator
* Status 401: Unauthorized access
* Status 500: Internal server error
# Create Vault
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/vaults/create-vault
Create a new vault (lake) and optionally set its initial configuration and seed deposit.
```http theme={null}
POST /api/v1/lake/create
```
The operation type for signing is `"create_lake"`.
This endpoint creates a new vault and returns its generated account address. The API path uses `lake`, but this feature is referred to as `vaults` in user-facing docs.
`manager_loss_share` is currently disabled; omit it or pass `"0"`.
#### Request Body
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | Creator wallet address | `42trU9A5...` |
| `"signature"` | string | required | Signature over the sorted request payload | `5J3mBbAH...` |
| `"timestamp"` | integer | required | Current timestamp in milliseconds | `1716200000000` |
| `"manager"` | string | optional | Manager address. Omit to create a fresh vault with no manager. | `8zFqj1Kp...` |
| `"nickname"` | string | optional | Display name for the vault | `BTC Basis Vault` |
| `"deposit_cap"` | decimal string | optional | Maximum LP balance accepted by the vault | `1000000` |
| `"manager_profit_share"` | decimal string | optional | Performance fee fraction in `[0,1]` | `0.20` |
| `"manager_loss_share"` | decimal string | optional | Temporarily disabled; only `"0"` is accepted | `0` |
| `"deposit_min_duration_ms"` | integer | optional | Minimum deposit lock duration in milliseconds | `86400000` |
| `"manager_min_balance_portion"` | decimal string | optional | Manager balance ratio required to claim or re-enable the vault | `0.10` |
| `"manager_liquidation_balance_portion"` | decimal string | optional | Manager balance ratio that triggers trading halt and liquidation | `0.05` |
| `"initial_deposit"` | decimal string | optional | Seed deposit from the creator in the same request | `1000.00` |
| `"withdraw_window_s"` | integer | optional | Withdrawal cycle period in seconds | `2592000` |
| `"withdraw_duration_s"` | integer | optional | Open withdrawal time per cycle in seconds | `259200` |
| `"referral_code"` | string | optional | Referral code to claim for the new vault | `testcode` |
| `"initial_deposit_address_whitelist"` | string array or null | optional | Initial deposit-address whitelist. Empty or omitted = no restriction (anyone can deposit). | `["42trU9A5..."]` |
| `"agent_wallet"` | string | optional | Agent wallet address | `69trU9A5...` |
| `"expiry_window"` | integer | optional | Signature expiry in milliseconds | `30000` |
```json theme={null}
{
"account": "42trU9A5...",
"signature": "5J3mBbAH...",
"timestamp": 1716200000000,
"nickname": "BTC Basis Vault",
"manager_profit_share": "0.20",
"deposit_cap": "1000000",
"deposit_min_duration_ms": 86400000,
"manager_min_balance_portion": "0.10",
"manager_liquidation_balance_portion": "0.05",
"initial_deposit": "1000.00",
"withdraw_window_s": 2592000,
"withdraw_duration_s": 259200,
"referral_code": "testcode",
"expiry_window": 30000
}
```
#### Response
* Status 200: Vault created successfully
```json theme={null}
{
"success": true,
"data": {
"lake_address": "AbCdEfGh123456789...",
"referral_claimed": true
},
"error": null,
"code": null
}
```
| Field | Type | Description |
| - | - | - |
| `'lake_address'` | string | Generated vault account address |
| `'referral_claimed'` | boolean | Whether the optional referral code was claimed successfully |
* Status 400: Invalid request parameters
* Status 401: Unauthorized access
* Status 500: Internal server error
# Deposit to Vault
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/vaults/deposit-to-vault
Deposit funds into a vault and receive vault shares.
```http theme={null}
POST /api/v1/lake/deposit
```
The operation type for signing is `"deposit_to_lake"`.
Use this endpoint to deposit USDC from an account into a vault. Deposits are idempotent when an `idempotency_key` is supplied.
#### Request Body
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | Depositor wallet address | `42trU9A5...` |
| `"signature"` | string | required | Cryptographic signature | `5J3mBbAH...` |
| `"timestamp"` | integer | required | Current timestamp in milliseconds | `1716200000000` |
| `"lake"` | string | required | Vault address | `AbCdEfGh123456789...` |
| `"amount"` | decimal string | required | Deposit amount in USDC | `1000.00` |
| `"idempotency_key"` | UUID string | optional | Client-generated key to prevent duplicate deposits | `550e8400-e29b-41d4-a716-446655440000` |
| `"agent_wallet"` | string | optional | Agent wallet address | `69trU9A5...` |
| `"expiry_window"` | integer | optional | Signature expiry in milliseconds | `30000` |
```json theme={null}
{
"account": "42trU9A5...",
"signature": "5J3mBbAH...",
"timestamp": 1716200000000,
"lake": "AbCdEfGh123456789...",
"amount": "1000.00",
"idempotency_key": "550e8400-e29b-41d4-a716-446655440000"
}
```
#### Response
* Status 200: Deposit successful
```json theme={null}
{
"success": true,
"data": {
"shares_minted": "1000.00"
},
"error": null,
"code": null
}
```
| Field | Type | Description |
| - | - | - |
| `'shares_minted'` | decimal string | Number of vault shares minted to the depositor |
* Status 400: Invalid request parameters
* Status 401: Unauthorized access
* Status 409: Duplicate idempotency key
* Status 500: Internal server error
# List Vaults
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/vaults/list-vaults
List all vaults and optionally include the querying account's share balance.
```http theme={null}
GET /api/v1/lake/list
```
Returns all vaults ordered by creation time descending. If `account` is provided, the response also includes that account's share balance in each vault as `user_share`.
#### Query Parameters
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | optional | Account address whose share balance should be included | `42trU9A5...` |
```http theme={null}
/api/v1/lake/list?account=42trU9A5...
```
#### Response
* Status 200: List of vaults
```json theme={null}
{
"success": true,
"data": {
"lakes": [
{
"address": "AbCdEfGh123456789...",
"creator": "42trU9A5...",
"manager": "8zFqj1Kp...",
"nickname": "BTC Basis Vault",
"lp_shares": "900000.00",
"manager_shares": "100000.00",
"lp_balance": "910000.00",
"manager_balance": "115000.00",
"last_checked_equity": "1025000.00",
"high_watermark": "1025000.00",
"created_at": 1700000000000,
"referrer": "7xyReferrer...",
"user_share": "500.00",
"config": {
"deposit_cap": "1000000.00",
"manager_profit_share": "0.20",
"manager_loss_share": "0",
"deposit_min_duration_ms": 86400000,
"manager_min_balance_portion": "0.10",
"manager_liquidation_balance_portion": "0.05",
"withdraw_window_s": 2592000,
"withdraw_duration_s": 259200
}
}
]
},
"error": null,
"code": null
}
```
**Lake fields**
| Field | Type | Description |
| - | - | - |
| `'address'` | string | Vault account address |
| `'creator'` | string | Creator address |
| `'manager'` | string or null | Current manager address |
| `'nickname'` | string or null | Optional vault nickname |
| `'lp_shares'` | decimal string | Total LP shares outstanding |
| `'manager_shares'` | decimal string | Total manager shares outstanding |
| `'lp_balance'` | decimal string | Balance attributed to LP shares |
| `'manager_balance'` | decimal string | Balance attributed to manager shares |
| `'last_checked_equity'` | decimal string | Most recent equity snapshot used for vault accounting |
| `'high_watermark'` | decimal string | High-water mark for performance fee accounting |
| `'created_at'` | integer | Vault creation timestamp in milliseconds |
| `'referrer'` | string or null | Referrer address if a referral code was claimed |
| `'user_share'` | decimal string or null | Share balance for the queried account, when `account` is provided |
| `'config'` | object or null | Vault configuration, when present |
**Config fields**
| Field | Type | Description |
| - | - | - |
| `'deposit_cap'` | decimal string or null | LP deposit cap |
| `'manager_profit_share'` | decimal string or null | Performance fee fraction |
| `'manager_loss_share'` | decimal string or null | Manager loss share setting |
| `'deposit_min_duration_ms'` | integer or null | Minimum deposit duration |
| `'manager_min_balance_portion'` | decimal string or null | Required manager balance ratio |
| `'manager_liquidation_balance_portion'` | decimal string or null | Halt/liquidation trigger ratio |
| `'withdraw_window_s'` | integer or null | Withdrawal cycle period |
| `'withdraw_duration_s'` | integer or null | Open withdrawal duration per cycle |
* Status 500: Internal server error
# Remove Vault Blacklist
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/vaults/remove-vault-blacklist
Remove blocked symbols from a vault blacklist.
```http theme={null}
POST /api/v1/lake/remove_blacklist
```
The operation type for signing is `"remove_lake_blacklist"`.
Only the vault creator can call this endpoint.
#### Request Body
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | Creator wallet address | `42trU9A5...` |
| `"signature"` | string | required | Cryptographic signature | `5J3mBbAH...` |
| `"timestamp"` | integer | required | Current timestamp in milliseconds | `1716200000000` |
| `"lake"` | string | required | Vault address | `AbCdEfGh123456789...` |
| `"symbols"` | string array | required | Symbols to remove from the blacklist | `["BTC", "ETH"]` |
| `"agent_wallet"` | string | optional | Agent wallet address | `69trU9A5...` |
| `"expiry_window"` | integer | optional | Signature expiry in milliseconds | `30000` |
```json theme={null}
{
"account": "42trU9A5...",
"signature": "5J3mBbAH...",
"timestamp": 1716200000000,
"lake": "AbCdEfGh123456789...",
"symbols": ["BTC", "ETH"]
}
```
#### Response
* Status 200: Blacklist updated successfully
```json theme={null}
{
"success": true,
"data": {
"success": true
},
"error": null,
"code": null
}
```
* Status 400: Invalid request parameters
* Status 401: Unauthorized access
* Status 403: Caller is not the vault creator
* Status 500: Internal server error
# Remove Vault Max Leverage
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/vaults/remove-vault-max-leverage
Remove per-symbol max leverage limits from a vault.
```http theme={null}
POST /api/v1/lake/remove_max_leverage
```
The operation type for signing is `"remove_lake_max_leverage"`.
Only the vault creator can call this endpoint.
#### Request Body
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | Creator wallet address | `42trU9A5...` |
| `"signature"` | string | required | Cryptographic signature | `5J3mBbAH...` |
| `"timestamp"` | integer | required | Current timestamp in milliseconds | `1716200000000` |
| `"lake"` | string | required | Vault address | `AbCdEfGh123456789...` |
| `"symbols"` | string array | required | Symbols whose custom max leverage should be removed | `["BTC", "ETH"]` |
| `"agent_wallet"` | string | optional | Agent wallet address | `69trU9A5...` |
| `"expiry_window"` | integer | optional | Signature expiry in milliseconds | `30000` |
```json theme={null}
{
"account": "42trU9A5...",
"signature": "5J3mBbAH...",
"timestamp": 1716200000000,
"lake": "AbCdEfGh123456789...",
"symbols": ["BTC", "ETH"]
}
```
#### Response
* Status 200: Max leverage removed successfully
```json theme={null}
{
"success": true,
"data": {
"success": true
},
"error": null,
"code": null
}
```
* Status 400: Invalid request parameters
* Status 401: Unauthorized access
* Status 403: Caller is not the vault creator
* Status 500: Internal server error
# Remove Vault Whitelist
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/vaults/remove-vault-whitelist
Remove tradable symbols from a vault whitelist.
```http theme={null}
POST /api/v1/lake/remove_whitelist
```
The operation type for signing is `"remove_lake_whitelist"`.
Only the vault creator can call this endpoint.
#### Request Body
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | Creator wallet address | `42trU9A5...` |
| `"signature"` | string | required | Cryptographic signature | `5J3mBbAH...` |
| `"timestamp"` | integer | required | Current timestamp in milliseconds | `1716200000000` |
| `"lake"` | string | required | Vault address | `AbCdEfGh123456789...` |
| `"symbols"` | string array | required | Symbols to remove from the whitelist | `["BTC", "ETH"]` |
| `"agent_wallet"` | string | optional | Agent wallet address | `69trU9A5...` |
| `"expiry_window"` | integer | optional | Signature expiry in milliseconds | `30000` |
```json theme={null}
{
"account": "42trU9A5...",
"signature": "5J3mBbAH...",
"timestamp": 1716200000000,
"lake": "AbCdEfGh123456789...",
"symbols": ["BTC", "ETH"]
}
```
#### Response
* Status 200: Whitelist updated successfully
```json theme={null}
{
"success": true,
"data": {
"success": true
},
"error": null,
"code": null
}
```
* Status 400: Invalid request parameters
* Status 401: Unauthorized access
* Status 403: Caller is not the vault creator
* Status 500: Internal server error
# Update Vault Deposit Cap
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/vaults/update-vault-deposit-cap
Update or clear the deposit cap for a vault.
```http theme={null}
POST /api/v1/lake/update_deposit_cap
```
The operation type for signing is `"update_lake_deposit_cap"`.
Only the vault creator can call this endpoint.
#### Request Body
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | Creator wallet address | `42trU9A5...` |
| `"signature"` | string | required | Cryptographic signature | `5J3mBbAH...` |
| `"timestamp"` | integer | required | Current timestamp in milliseconds | `1716200000000` |
| `"lake"` | string | required | Vault address | `AbCdEfGh123456789...` |
| `"deposit_cap"` | decimal string or null | optional | New LP deposit cap. Set to `null` to remove the cap. | `2000000` |
| `"agent_wallet"` | string | optional | Agent wallet address | `69trU9A5...` |
| `"expiry_window"` | integer | optional | Signature expiry in milliseconds | `30000` |
```json theme={null}
{
"account": "42trU9A5...",
"signature": "5J3mBbAH...",
"timestamp": 1716200000000,
"lake": "AbCdEfGh123456789...",
"deposit_cap": "2000000"
}
```
#### Response
* Status 200: Deposit cap updated successfully
```json theme={null}
{
"success": true,
"data": {
"success": true
},
"error": null,
"code": null
}
```
* Status 400: Invalid request parameters
* Status 401: Unauthorized access
* Status 403: Caller is not the vault creator
* Status 500: Internal server error
# Withdraw From Vault
Source: https://docs.pacifica.fi/api-documentation/api/rest-api/vaults/withdraw-from-vault
Redeem vault shares and withdraw funds from a vault.
```http theme={null}
POST /api/v1/lake/withdraw
```
The operation type for signing is `"withdraw_from_lake"`.
Use this endpoint to redeem shares from a vault. Withdrawals are idempotent when an `idempotency_key` is supplied.
#### Request Body
| Field | Type | Need | Description | Example |
|---|
| `"account"` | string | required | Depositor wallet address | `42trU9A5...` |
| `"signature"` | string | required | Cryptographic signature | `5J3mBbAH...` |
| `"timestamp"` | integer | required | Current timestamp in milliseconds | `1716200000000` |
| `"lake"` | string | required | Vault address | `AbCdEfGh123456789...` |
| `"shares"` | decimal string | required | Number of shares to redeem | `50.00` |
| `"idempotency_key"` | UUID string | optional | Client-generated key to prevent duplicate withdrawals | `550e8400-e29b-41d4-a716-446655440000` |
| `"agent_wallet"` | string | optional | Agent wallet address | `69trU9A5...` |
| `"expiry_window"` | integer | optional | Signature expiry in milliseconds | `30000` |
```json theme={null}
{
"account": "42trU9A5...",
"signature": "5J3mBbAH...",
"timestamp": 1716200000000,
"lake": "AbCdEfGh123456789...",
"shares": "50.00",
"idempotency_key": "550e8400-e29b-41d4-a716-446655440000"
}
```
#### Response
* Status 200: Withdrawal successful
```json theme={null}
{
"success": true,
"data": {
"amount_withdrawn": "500.00"
},
"error": null,
"code": null
}
```
| Field | Type | Description |
| - | - | - |
| `'amount_withdrawn'` | decimal string | USDC returned to the depositor |
* Status 400: Invalid request parameters
* Status 401: Unauthorized access
* Status 409: Duplicate idempotency key
* Status 500: Internal server error
# Signing
Source: https://docs.pacifica.fi/api-documentation/api/signing
Pacifica uses deterministic JSON formatting to generate Ed25519 signatures for API authentication.
All POST requests require signing, whereas GET and websocket subscriptions do not.\
\
We *strongly* recommend following the [Pacifica Python SDK](https://github.com/pacifica-fi/python-sdk) to generate signatures and submit trading requests. The following example explains the key steps in constructing valid signatures.
# API Agent Keys
Source: https://docs.pacifica.fi/api-documentation/api/signing/api-agent-keys
The signature verification process in both REST API and Websocket allows user generated API Agent Keys (also called "Agent Wallets") to sign on behalf of the original account. This is similar to the API Keys used for most leading exchanges. This way, API users can trade programmably without exposing the private key of the original wallet to the trading program.
### Generate API Agent Keys
Agent wallets can be generated on the [frontend](https://app.pacifica.fi/apikey), or using this [Python SDK example](https://github.com/pacifica-fi/python-sdk/blob/main/rest/api_agent_keys.py#L31-L79).
### Use API Agent Keys
For all POST requests, follow these steps in request construction
* Still use the original wallet's public key for `account`,
* Use API Agent Private Key to sign the message payload to generate `signature`, and
* Add `agent_wallet: [AGENT_WALLET_PUBLIC_KEY]` to the request header.
As an example, this [Python SDK program](https://github.com/pacifica-fi/python-sdk/blob/main/rest/api_agent_keys.py#L81-L135) uses API Agent Key to place a market order.
# Error Handling
Source: https://docs.pacifica.fi/api-documentation/api/signing/error-handling
An invalid signed message can result in a variety of Status 400 errors. The following illustrate error messages and common causes.
| Error Message | Potential Causes |
|---|
| `"Invalid signature"` | - Invalid signature format (not valid base58)
- Signature bytes don't form a valid Ed25519 signature
- Malformed signature data
|
| `"Invalid message"` | - Message has expired (timestamp + expiry\_window \< current time)
- Message cannot be serialized to JSON
- Message structure is malformed
|
| `"Invalid public key"` | - Account address doesn't represent a valid Ed25519 public key
- Public key bytes are malformed
|
| `"Verification failed"` | - Signature doesn't match the message content
- Wrong private key was used to sign
- Message content was modified after signing
|
While we have provided several different error message types in order to aid debugging, an incorrectly generated signed message is still relatively ambiguous when it comes to troubleshooting the root cause of the issue, making debugging more challenging.\
\
As such, the following guide and/or the [Pacifica Python SDK](https://github.com/pacifica-fi/python-sdk), when followed closely, should make signing relatively straightforward to implement.
# Hardware Wallet
Source: https://docs.pacifica.fi/api-documentation/api/signing/hardware-wallet
Pacifica supports hardware wallet signature authentication via Ed25519 [off-chain message signing](https://github.com/solana-labs/solana/blob/master/docs/src/proposals/off-chain-message-signing.md). To use hardware wallet, after constructing the [message bytes](/api-documentation/api/signing/implementation#7-convert-to-bytes-and-generate-signature), prepend it with the `\xffsolana offchain` header together with message length, version information, etc.
Then, in the [signature to send](/api-documentation/api/signing/implementation#8-build-final-request), use `hardware` as the `type` :
```
...
"signature": {
"type": "hardware",
"value": "2V4Y7Mpk...",
},
...
```
For more details, refer to [this example](https://github.com/pacifica-fi/python-sdk/blob/2b5e629eb15d86c1a229df5d1847f5000f113ec9/rest/transfer_subaccount_fund_hardware.py#L27-L47) in the Python SDK.
# Implementation
Source: https://docs.pacifica.fi/api-documentation/api/signing/implementation
The following guide provides a step-by-step breakdown of Pacifica's signing implementation
### 1. Setup and Initialization
```python theme={null}
import time
import base58
import requests
from solders.keypair import Keypair
PRIVATE_KEY = "your_private_key_here"
# Generate keypair from private key
keypair = Keypair.from_bytes(base58.b58decode(PRIVATE_KEY))
public_key = str(keypair.pubkey())
```
### 2. Choose Endpoint and Define Operation Type
For this example, we use the order creation endpoint. Refer to [Operation Types](/api-documentation/api/signing/operation-types) for a list of all types and corresponding API endpoints.
```python theme={null}
API_URL = "https://api.pacifica.fi/api/v1/orders/create"
operation_type = "create_order"
operation_data = {
"symbol": "BTC",
"price": "100000",
"amount": "0.1",
"side": "bid",
"tif": "GTC",
"reduce_only": False,
"client_order_id": str(uuid.uuid4()),
}
```
### 3. Create Signature Header
Note that all times specified are denoted in milliseconds.\
\
The `"expiry_window"` field is optional, and defaults to 30\_000 (30 seconds) if not specified in the header.
```python theme={null}
# Get current timestamp in milliseconds
timestamp = int(time.time() * 1_000)
signature_header = {
"timestamp": timestamp,
"expiry_window": 5_000,
"type": "create_order",
}
```
### 4. Combine Header and Payload
```python theme={null}
data_to_sign = {
**signature_header,
"data": operation_data,
}
```
In the case of our example, this creates:
```python theme={null}
{
"timestamp": 1748970123456,
"expiry_window": 5000,
"type": "create_order",
"data": {
"symbol": "BTC",
"price": "100000",
"amount": "0.1",
"side": "bid",
"tif": "GTC",
"reduce_only": False,
"client_order_id": "12345678-1234-1234-1234-123456789abc"
}
}
```
Note that data must be in same level as other headers.
### 5. Recursively Sort JSON Keys
```python theme={null}
def sort_json_keys(value):
if isinstance(value, dict):
sorted_dict = {}
for key in sorted(value.keys()):
sorted_dict[key] = sort_json_keys(value[key])
return sorted_dict
elif isinstance(value, list):
return [sort_json_keys(item) for item in value]
else:
return value
sorted_message = sort_json_keys(data_to_sign)
```
In the case of our example, this creates:
```python theme={null}
{
"data": {
"amount": "0.1",
"client_order_id": "12345678-1234-1234-1234-123456789abc",
"price": "100000",
"reduce_only": false,
"side": "bid",
"symbol": "BTC",
"tif": "GTC"
},
"expiry_window": 5000,
"timestamp": 1748970123456,
"type": "create_order"
}
```
Note that the recursive sorting alphabetically sorts \*all\* levels
### 6. Create Compact JSON
Compact JSON string with no whitespace and standardized separators
```python theme={null}
import json
compact_json = json.dumps(sorted_message, separators=(",", ":"))
```
In the case of our example, this creates:
```
{"data":{"amount":"0.1","client_order_id":"12345678-1234-1234-1234-123456789abc","price":"100000","reduce_only":false,"side":"bid","symbol":"BTC","tif":"GTC"},"expiry_window":5000,"timestamp":1748970123456,"type":"create_order"}
```
This ensures that all logically identical messages will always produce \*identical\* signatures
### 7. Convert to Bytes and Generate Signature
Messages are converted to UTF-8 bytes for signing. The signature generated is then converted to Base58 string for transmission.
```python theme={null}
# Convert to UTF-8 bytes
message_bytes = compact_json.encode("utf-8")
# Sign message bytes using your private key
signature = keypair.sign_message(message_bytes)
# Convert signature to Base58 string
signature_b58 = base58.b58encode(bytes(signature)).decode("ascii")
# Expect an output similar to:
# "5j1Vy9UqYUF2jKD9r2Lv5AoMWHJuW5a1mqVzEhC9SJL5GqbPkGEQKpW3UZmKXr4UWrHMJ5xHQFMJkZWE8J5VyA"
```
### 8. Build Final Request
Build the header with generated authentication info and combine with operation data (NOT the "data" wrapper!)
```python theme={null}
request_header = {
"account": public_key,
"agent_wallet": None,
"signature": signature_b58,
"timestamp": signature_header["timestamp"],
"expiry_window": signature_header["expiry_window"],
}
final_request = {
**request_header,
**operation_data, # Use the ORIGINAL create order fields
}
```
In the case of our example, the final request looks like:
```python theme={null}
{
"account": "6ETnufiec2CxVWTS4u5Wiq33Zh5Y3Qm6Pkdpi375fuxP",
"agent_wallet": null,
"signature": "5j1Vy9UqYUF2jKD9r2Lv5AoMWHJuW5a1mqVzEhC9SJL5GqbPkGEQKpW3UZmKXr4UWrHMJ",
"timestamp": 1748970123456,
"expiry_window": 5000,
"symbol": "BTC",
"price": "100000",
"amount": "0.1",
"side": "bid",
"tif": "GTC",
"reduce_only": false,
"client_order_id": "12345678-1234-1234-1234-123456789abc"
}
```
# Operation Types
Source: https://docs.pacifica.fi/api-documentation/api/signing/operation-types
The following table provides the "type"s required by the signature header and their corresponding API endpoints
| Operation Type | API Endpoint |
| - | - |
| `"create_order"` | `/api/v1/orders/create` |
| `"create_stop_order"` | `/api/v1/orders/stop/create` |
| `"cancel_order"` | `/api/v1/orders/cancel` |
| `"cancel_all_orders"` | `/api/v1/orders/cancel_all` |
| `"cancel_stop_order"` | `/api/v1/orders/stop/cancel` |
| `"update_leverage"` | `/api/v1/account/leverage` |
| `"update_margin_mode"` | `/api/v1/account/margin` |
| `"set_position_tpsl"` | `/api/v1/positions/tpsl` |
| `"withdraw"` | `/api/v1/account/withdraw` |
| `"subaccount_initiate"` | `/api/v1/account/subaccount/create` |
| `"subaccount_confirm"` | `/api/v1/account/subaccount/create` |
| `"create_market_order"` | `/api/v1/orders/create_market` |
| `"transfer_funds"` | `/api/v1/account/subaccount/transfer` |
| `"bind_agent_wallet"` | `/api/v1/agent/bind` |
| `"create_api_key"` | `/api/v1/account/api_keys/create` |
| `"revoke_api_key"` | `/api/v1/account/api_keys/revoke` |
| `"list_api_keys"` | `/api/v1/account/api_keys` |
| `"create_lake"` | `/api/v1/lake/create` |
| `"claim_lake_referral"` | `/api/v1/lake/claim_referral_code` |
| `"deposit_to_lake"` | `/api/v1/lake/deposit` |
| `"claim_lake_manager"` | `/api/v1/lake/claim_manager` |
| `"withdraw_from_lake"` | `/api/v1/lake/withdraw` |
| `"update_lake_deposit_cap"` | `/api/v1/lake/update_deposit_cap` |
| `"add_lake_whitelist"` | `/api/v1/lake/add_whitelist` |
| `"remove_lake_whitelist"` | `/api/v1/lake/remove_whitelist` |
| `"add_lake_blacklist"` | `/api/v1/lake/add_blacklist` |
| `"remove_lake_blacklist"` | `/api/v1/lake/remove_blacklist` |
| `"add_lake_max_leverage"` | `/api/v1/lake/add_max_leverage` |
| `"remove_lake_max_leverage"` | `/api/v1/lake/remove_max_leverage` |
| `"deposit_to_game"` | `/api/v1/game/deposit` |
| `"create_order_strategy"` | `/api/v1/order_strategies/create` |
| `"edit_order_strategy"` | `/api/v1/order_strategies/edit` |
| `"cancel_order_strategy"` | `/api/v1/order_strategies/cancel` |
| `"update_account_settings"` | `/api/v1/account/settings` |
| `"create_twap_order"` | `/api/v1/orders/twap/create` |
| `"cancel_twap_order"` | `/api/v1/orders/twap/cancel` |
| `"two_factor_status"` | `/api/v1/account/2fa/status` |
| `"begin_totp_enrollment"` | `/api/v1/account/2fa/totp/begin` |
| `"finish_totp_enrollment"` | `/api/v1/account/2fa/totp/finish` |
| `"begin_webauthn_registration"` | `/api/v1/account/2fa/webauthn/register/begin` |
| `"finish_webauthn_registration"` | `/api/v1/account/2fa/webauthn/register/finish` |
| `"begin_webauthn_authentication"` | `/api/v1/account/2fa/webauthn/authenticate/begin` |
| `"disable_two_factor"` | `/api/v1/account/2fa/disable` |
| `"remove_two_factor_factor"` | `/api/v1/account/2fa/factors/remove` |
| `"rename_two_factor_factor"` | `/api/v1/account/2fa/factors/rename` |
| `"regenerate_recovery_keys"` | `/api/v1/account/2fa/recovery-keys/regenerate` |
| `"register_expo_device"` | `/api/v1/account/notifications/expo/device` |
| `"unregister_expo_device"` | `/api/v1/account/notifications/expo/device/unregister` |
| `"register_web_push_subscription"` | `/api/v1/account/notifications/web_push/subscription` |
| `"get_web_push_subscription"` | `/api/v1/account/notifications/web_push/subscription/status` |
| `"unregister_web_push_subscription"` | `/api/v1/account/notifications/web_push/subscription/unregister` |
| `"list_notification_preferences"` | `/api/v1/account/notifications/preferences/list` |
| `"set_notification_preference"` | `/api/v1/account/notifications/preferences` |
| `"set_notification_master_preference"` | `/api/v1/account/notifications/preferences/master` |
| `"send_test_notification"` | `/api/v1/account/notifications/test` |
| `"get_notification_history"` | `/api/v1/account/notifications/history` |
| `"mark_notifications_seen"` | `/api/v1/account/notifications/seen` |
Note: Pacifica's batch order endpoint does NOT have a corresponding operation type as all individual operations within the batch are signed independently with their own operation types.
# Tick and Lot Size
Source: https://docs.pacifica.fi/api-documentation/api/tick-and-lot-size
The following doc describes how tick and lot size, as well as rounding, are handled at an API level when Pacifica's endpoints receive requests with price and amount fields.
Both `'price'` and `'amount'` fields in order related API operations are subject to rounding, needing to be multiples of tick and lot size.\
\
Generally `tick_size` is determined by the rightmost decimal place of a symbol's current price, and prices generally have five significant figures, with the exception of assets with more than six integer places, where sig.figs = #of integer places.\
\
For example:\
\
If `'price' = 123.45`, expect `'tick_size' = 0.01`\
If `'price' = 123456`, expect `'tick_size' = 1`\
\
Generally, `lot_size*tick_size = 0.0001 or 0.00001`, based on the market.\
\
For the exact implemented `tick_size` and `lot_size` of each market, call the [market info](/api-documentation/api/rest-api/markets/get-market-info) endpoint to verify.
## Rounding
Pacifica accepts requests containing `'price'` and `'amount'` fields only when they are multiples of `tick_size` and `lot_size` respectively. Any requests with incorrectly rounded `'price'` and `'amount'` fields will return `'"Bad Request","code":400'`
For example:\
\
BTC has `"tick_size": "1"`, `"lot_size": "0.00001"`\
\
A request where `"amount": "0.000005"` will return `Status 400: Bad Request`\
A request where `"price": "100_000.5"` will return `Status 400: Bad Request`
A request where `"amount": "0.00002"` will be accepted\
A request where `"price": "100_001"` will be accepted
# Websocket
Source: https://docs.pacifica.fi/api-documentation/api/websocket
Mainnet websocket URL: [wss://ws.pacifica.fi/ws](wss://ws.pacifica.fi/ws)\
Testnet websocket URL: [wss://test-ws.pacifica.fi/ws](wss://test-ws.pacifica.fi/ws)
The API service provides a universal endpoint for websocket streams. The subscribed data will be streamed in the corresponding channel after the connection is established.
### Subscription Message
```
{
"method": "subscribe",
"params": { ... }
}
```
### Unsubscription Message
```
{
"method": "unsubscribe",
"params": { ... }
}
```
### Heartbeat and Timeout
A websocket connection will be closed if no message is sent for the past 60 seconds, or the connection has been alive for 24 hours.
To keep the connection alive without messages in 60 seconds, we can send a heartbeat message
```
{
"method": "ping"
}
```
and an alive connection will respond with
```
{
"channel": "pong"
}
```
### Compression
To reduce bandwidth, open the connection with `?compress=deflate`:
```
wss://ws.pacifica.fi/ws?compress=deflate
```
The server then sends subscription data and snapshots as binary frames of raw DEFLATE data (no zlib header). Each frame holds one complete message. Other messages, such as `pong`, errors, and trading responses, stay as text frames.
The compression state carries across messages, so use one decompressor for the whole connection. This is not the standard `permessage-deflate` extension.
```python theme={null}
import zlib
inflater = zlib.decompressobj(-zlib.MAX_WBITS) # one per connection
def decode(message):
if isinstance(message, bytes):
return inflater.decompress(message).decode()
return message
```
### Slow Clients
For `book` and `bbo`, a client that reads slowly receives only the latest snapshot, not every update in between. If the server cannot write to a connection for 60 seconds, it closes the connection with close code `1011`.
# Subscriptions
Source: https://docs.pacifica.fi/api-documentation/api/websocket/subscriptions
* [Prices](/api-documentation/api/websocket/subscriptions/prices): Streams all symbols' price information on Pacifica as they update
* [Orderbook](/api-documentation/api/websocket/subscriptions/orderbook): Streams book data for given symbol at a set aggregation level as they update
* [Best bid offer (BBO)](/api-documentation/api/websocket/subscriptions/best-bid-offer-bbo): Real-time updates of the best bid and ask prices and amounts for a specific symbol. Updates are sent whenever the top of book changes.
* [Trades](/api-documentation/api/websocket/subscriptions/trades): Streams all trades on the taker side as they occur in a chosen market.
* [Candle](/api-documentation/api/websocket/subscriptions/candle): Streams candle information for given symbol and candle time interval
* [Mark price candle](/api-documentation/api/websocket/subscriptions/mark-price-candle): Streams real-time mark price candlestick data for a specific market.
* [Account margin](/api-documentation/api/websocket/subscriptions/account-margin): Streams all changes made to an account's margin mode in any market.
* [Account leverage](/api-documentation/api/websocket/subscriptions/account-leverage): Streams all changes made to an account's max leverage in any market.
* [Account info](/api-documentation/api/websocket/subscriptions/account-info): Streams all changes made to an account's overall info such as equity, balance, order count, etc.
* [Account positions](/api-documentation/api/websocket/subscriptions/account-positions): Streams all changes made to an account's positions in any market. A position that has been fully closed will be streamed and return empty.
* [Account order updates](/api-documentation/api/websocket/subscriptions/account-order-updates): Streams the amount and nature of changes made to any of an account's open orders in any market.
* [Account order strategy updates](/api-documentation/api/websocket/subscriptions/account-order-strategy-updates): Streams lifecycle changes of an account's order strategies.
* [Account TWAP orders](/api-documentation/api/websocket/subscriptions/account-twap-orders): Streams the full list of an account's open TWAP orders whenever one of them changes.
* [Account TWAP order updates](/api-documentation/api/websocket/subscriptions/account-twap-order-updates): Streams each change to an account's TWAP orders, such as creation, sub-order fills, and cancellation.
* [Account trades](/api-documentation/api/websocket/subscriptions/account-trades): Streams all trades that take place for an account
* [Account transfers](/api-documentation/api/websocket/subscriptions/account-transfers): Streams deposit, withdrawal, and transfer events for an account.
* [Account liquidations](/api-documentation/api/websocket/subscriptions/account-liquidations): Streams each of an account's positions that liquidation or ADL closed. Requires the account's API key.
# Account Info
Source: https://docs.pacifica.fi/api-documentation/api/websocket/subscriptions/account-info
Streams all changes made to an account's overall info such as equity, balance, order count, etc.
Refer to [Websocket](/api-documentation/api/websocket) for establishing the websocket connection.
## Leverage
### Params
```json theme={null}
{
"method": "subscribe",
"params": {
"source": "account_info",
"account": "42trU9A5...",
"full": true // Optional. Defaults to false
}
}
```
Set `full` to `true` to add the `cae`, `poe`, and `tae` equity fields to each update.
### Stream
```json theme={null}
{
"channel": "account_info",
"data": {
"ae": "2000",
"as": "1500",
"aw": "1400",
"b": "2000",
"f": 1,
"mu": "500",
"cm": "400",
"oc": 10,
"pb": "0",
"pc": 2,
"sc": 2,
"sb": [
{
"s": "SOL",
"a": "1.50000000",
"lr": "0.80",
"aw": "1.00000000",
"pb": "0.00",
"dw": "250.000000",
"dd": "50000.000000",
"wd": "250000.000000"
}
],
"t": 1234567890
}
}
```
| Field | Type | Description |
|---|
| `'ae'` | string | Account equity |
| `'as'` | string | Available to spend |
| `'aw'` | string | Available to withdraw |
| `'b'` | string | Account balance |
| `'f'` | integer | Account fee tier |
| `'mu'` | string | Total margin used |
| `'cm'` | string | Maintenance margin required in cross mode |
| `'oc'` | integer | Orders count |
| `'pb'` | string | Pending balance |
| `'pc'` | integer | Positions count |
| `'sc'` | integer | Stop order count |
| `'sb'` | array | Spot asset balances (see below) |
| `'t'` | number | Timestamp in milliseconds |
| `'cae'` | string | Cross account equity. Only with `full` |
| `'poe'` | string | Equity locked in open [Print](/print) orders. Only with `full` |
| `'tae'` | string | Total account equity: `ae` plus `poe`. Only with `full` |
**Spot Balance Fields**
| Field | Type | Description |
| - | - | - |
| `'s'` | string | Spot asset symbol |
| `'a'` | string | Total amount held |
| `'lr'` | string | Loan-to-value ratio |
| `'aw'` | string | Available to withdraw |
| `'pb'` | string | Pending balance |
| `'dw'` | string | Daily withdrawal amount (USD) |
| `'dd'` | string | Effective daily deposit limit (USD) |
| `'wd'` | string | Effective daily withdrawal limit (USD) |
If `full` is `true` and the equity components are not available yet, the channel sends this message instead of an update:
```json theme={null}
{
"channel": "account_info",
"data": {
"code": 503,
"error": "Full account components are unavailable",
"error_id": "full_components_unavailable"
}
}
```
# Account Leverage
Source: https://docs.pacifica.fi/api-documentation/api/websocket/subscriptions/account-leverage
Streams all changes made to an account's max leverage in any market.
Refer to [Websocket](/api-documentation/api/websocket) for establishing the websocket connection.
## Leverage
### Params
```json theme={null}
{
"method": "subscribe",
"params": {
"source": "account_leverage",
"account": "42trU9A5..."
}
}
```
### Stream
```json theme={null}
{
"channel": "account_leverage",
"data": {
"u": "42trU9A5...",
"s": "BTC",
"l": 12,
"t": 1234567890
}
}
```
| Field | Type | Description |
|---|
| `'u'` | string | Account address |
| `'s'` | string | Symbol |
| `'l'` | integer | New leverage |
| `'t'` | number | Timestamp in milliseconds |
# Account Liquidations
Source: https://docs.pacifica.fi/api-documentation/api/websocket/subscriptions/account-liquidations
Streams each of an account's positions that liquidation or ADL closed.
Refer to [Websocket](/api-documentation/api/websocket) for establishing the websocket connection.
This channel requires the account's API key. Open the connection with the `PF-API-KEY` header set to a key that belongs to the subscribed account, as described in [API Config Keys](/api-documentation/api/rate-limits/api-config-keys). Any other subscribe fails with code `403`. There is no exchange-wide liquidation channel.
### Params
```json theme={null}
{
"method": "subscribe",
"params": {
"source": "account_liquidations",
"account": "42trU9A5..."
}
}
```
### Stream
The channel sends no snapshot on subscribe. It sends each event once, as it happens.
```json theme={null}
{
"channel": "account_liquidations",
"data": [
{
"u": "42trU9A5...",
"s": "BTC",
"m": "adl",
"d": "ask",
"a": "0.25",
"p": "64210",
"i": null,
"t": 1760630400000,
"li": 9123
}
]
}
```
| Field | Type | Description |
|---|
| `'u'` | string | Account address |
| `'s'` | string | Symbol |
| `'m'` | string | How the position closed. See below |
| `'d'` | string | Side of the closed position: `'bid'` - long, `'ask'` - short |
| `'a'` | decimal string | Closed amount |
| `'p'` | decimal string | Average fill price for `'market'`, otherwise the transfer or ADL price |
| `'i'` | integer | Liquidation order ID for `'market'`, otherwise `null` |
| `'t'` | number | Timestamp in milliseconds |
| `'li'` | number | [Last ID](/api-documentation/api/last-id) — sequence number of the operation |
#### Mechanism (`'m'`)
| `'m'` | Account was | How the position closed |
| - | - | - |
| `'market'` | Liquidated | An IOC liquidation order filled on the book |
| `'backstop'` | Liquidated | Transferred to the backstop liquidator |
| `'adl_liquidated'` | Liquidated | Closed against ADL counterparties |
| `'adl'` | An ADL counterparty | Auto-deleveraged to cover another account's liquidation |
Every value except `'adl'` means the account was liquidated. `'adl'` names the profitable side that ADL closed.
A chunked market liquidation sends one event for each chunk that fills. The trades that the close produced arrive on [Account Trades](/api-documentation/api/websocket/subscriptions/account-trades) with the same `li`. Join them on `(li, u, s)`.
The channel does not report delisting closes or the backstop liquidator's side of a transfer.
# Account Margin
Source: https://docs.pacifica.fi/api-documentation/api/websocket/subscriptions/account-margin
Streams all changes made to an account's margin mode in any market.
Refer to [Websocket](/api-documentation/api/websocket) for establishing the websocket connection.
## Margin
### Params
```json theme={null}
{
"method": "subscribe",
"params": {
"source": "account_margin",
"account": "42trU9A5..."
}
}
```
### Stream
```json theme={null}
{
"channel": "account_margin",
"data": {
"u": "42trU9A5...",
"s": "ETH",
"i": true,
"t": 1234567890
}
}
```
| Field | Type | Description |
| - | - | - |
| `'u'` | string | Account address |
| `'t'` | number | Timestamp in milliseconds |
| `'s'` | string | Symbol |
| `'i'` | boolean | New margin mode (isolated or not isolated) |
# Account Order Strategy Updates
Source: https://docs.pacifica.fi/api-documentation/api/websocket/subscriptions/account-order-strategy-updates
Streams lifecycle changes of an account's order strategies.
Refer to [Websocket](/api-documentation/api/websocket) for establishing the websocket connection.
Sends one event each time an [order strategy](/api-documentation/api/rest-api/order-strategies) changes its lifecycle or phase. To see the strategy's full state, call [Get order strategy](/api-documentation/api/rest-api/order-strategies/get-order-strategy). Orders and fills from a strategy also arrive on [Account order updates](/api-documentation/api/websocket/subscriptions/account-order-updates) and [Account trades](/api-documentation/api/websocket/subscriptions/account-trades).
### Params
```json theme={null}
{
"method": "subscribe",
"params": {
"source": "account_order_strategy_updates",
"account": "42trU9A5..."
}
}
```
### Stream
The channel sends no snapshot on subscribe.
```json theme={null}
{
"channel": "account_order_strategy_updates",
"data": {
"event_id": 18842,
"account": "42trU9A5...",
"strategy_id": "0f8e7c2a-4b1d-4e5f-9a3b-2c1d0e9f8a7b",
"state": "open",
"phase": "running",
"at_ms": 1716203600000
}
}
```
| Field | Type | Description |
| - | - | - |
| `'event_id'` | integer | Event ID. An event can arrive more than once; drop events with an `event_id` you have already seen |
| `'account'` | string | Account address |
| `'strategy_id'` | string | Strategy ID (UUID) |
| `'state'` | string | `pending`, `open`, `paused`, `completed`, `cancelled`, `expired`, or `failed`. See [Lifecycle](/api-documentation/api/rest-api/order-strategies#lifecycle) |
| `'phase'` | string | Only while `open`: `armed` (waiting for a trigger) or `running` |
| `'at_ms'` | integer | Time of the change in milliseconds |
# Account Order Updates
Source: https://docs.pacifica.fi/api-documentation/api/websocket/subscriptions/account-order-updates
Streams the amount and nature of changes made to any of an account's open orders in any market.
Refer to [Websocket](/api-documentation/api/websocket) for establishing the websocket connection.
### Params
```json theme={null}
{
"method": "subscribe",
"params": {
"source": "account_order_updates",
"account": "42trU9A5..."
}
}
```
### Stream
```json theme={null}
{
"channel": "account_order_updates",
"data": [
{
"i": 1559665358,
"I": null,
"u": "BrZp5bidJ3WUvceSq7X78bhjTfZXeezzGvGEV4hAYKTa",
"s": "BTC",
"d": "bid",
"p": "89501",
"ip": "89501",
"lp": "89501",
"a": "0.00012",
"f": "0.00012",
"oe": "fulfill_limit",
"os": "filled",
"ot": "limit",
"sp": null,
"si": null,
"tp": null,
"r": false,
"ct": 1765017049008,
"ut": 1765017219639,
"li": 1559696133
}
]
}
```
| Field | Type | Description |
|---|
| `'i'` | integer | Order ID |
| `'I'` | Full UUID string | Client order ID |
| `'u'` | base58 encoded address | Account |
| `'s'` | string | Symbol |
| `'d'` | string | Side: \[`bid`, `ask`] |
| `'p'` | decimal string | Average filled price |
| `'ip'` | decimal string | Initial price |
| `'lp'` | decimal string | Last filled price |
| `'a'` | decimal string | Original amount |
| `'f'` | decimal string | Filled amount |
| `'oe'` | string | Order event (see below) |
| `'os'` | string | Order status (see below) |
| `'ot'` | string | Order type (see below) |
| `'sp'` | string | Stop price |
| `'si'` | string | Stop parent order ID |
| `'tp'` | string | Stop trigger price type: `last_trade_price`, `mark_price`, or `mid_price` |
| `'r'` | bool | Reduce only |
| `'ct'` | integer | Created at time (milliseconds) |
| `'ut'` | integer | Updated at time (milliseconds) |
| `'li'` | integer | [Last ID](/api-documentation/api/last-id) — sequence number, monotonically increasing. Reconcile updates by order ID (`i`). |
| Field | Value | Description |
| - | - | - |
| `'oe'` | `make` | Order placed on book |
| | `stop_created` | Stop order created |
| | `fulfill_market` | User filled by market order |
| | `fulfill_limit` | User filled others limit order |
| | `adjust` | Order modified |
| | `stop_parent_order_filled` | Parent order filled |
| | `stop_triggered` | Stop order activated |
| | `stop_upgrade` | Stop order upgraded |
| | `cancel` | User cancelled |
| | `force_cancel` | Cancelled by system |
| | `expired` | Time expired |
| | `post_only_rejected` | Cannot execute ALO |
| | `self_trade_prevented` | Cannot execute self-trade |
| `'os'` | `open` | Active on orderbook |
| | `partially_filled` | Partially filled |
| | `filled` | Completely filled |
| | `cancelled` | Cancelled |
| | `rejected` | Rejected |
| `'ot'` | `limit` | Limit |
| | `market` | Market |
| | `stop_limit` | Stop limit |
| | `stop_market` | Stop market |
| | `take_profit_limit` | Take profit (limit) |
| | `stop_loss_limit` | Stop loss (limit) |
| | `take_profit_market` | Take profit (market) |
| | `stop_loss_market` | Stop loss (market) |
# Account Positions
Source: https://docs.pacifica.fi/api-documentation/api/websocket/subscriptions/account-positions
Streams all changes made to an account's positions in any market. A position that has been fully closed will be streamed and return empty.
Refer to [Websocket](/api-documentation/api/websocket) for establishing the websocket connection.
### Params
```json theme={null}
{
"method": "subscribe",
"params": {
"source": "account_positions",
"account": "42trU9A5..."
}
}
```
### Positions Snapshots
Upon subscription, the `account_positions` websocket immediately returns a snapshot of all current positions, then begins streaming all changes made to an account's positions in a best effort picture of current state.\
\
We recommend using `account_positions` for initialization, and `account_trades`, to construct up-to-date positions state.
Every `account_positions` message is a **complete replacement** — replace your whole local array on each message rather than merging. A closed position is dropped (there is no zero row or deletion marker), and an empty `data: []` array means the account is flat.
Each message carries a [Last ID](/api-documentation/api/last-id) (`li`) on every row and one on the envelope for the whole position set. On (re)subscription, use the initialization snapshot as your baseline, then apply later snapshots with an equal or newer envelope `li` and discard older ones.
### Stream
```json theme={null}
{
"channel": "subscribe",
"data": {
"source": "account_positions",
"account": "BrZp5..."
}
}
// this is the initialization snapshot
{
"channel": "account_positions",
"data": [
{
"s": "BTC",
"d": "bid",
"a": "0.00022",
"p": "87185",
"m": "0",
"f": "-0.00023989",
"i": false,
"l": null,
"t": 1764133203991,
"I": "8f14e45f-ceea-467a-9575-4a1c2b3d4e5f",
"r": "-0.0418",
"li": 1559395580
}
],
"li": 1559395580
}
// this shows the position being increased by an order filling
{
"channel": "account_positions",
"data": [
{
"s": "BTC",
"d": "bid",
"a": "0.00044",
"p": "87285.5",
"m": "0",
"f": "-0.00023989",
"i": false,
"l": "-95166.79231",
"t": 1764133656974,
"I": "8f14e45f-ceea-467a-9575-4a1c2b3d4e5f",
"r": "-0.0837",
"li": 1559412952
}
],
"li": 1559412952
}
// this shows the position being closed
{
"channel": "account_positions",
"data": [],
"li": 1559438203
}
```
| Field | Type | Description |
|---|
| `'s'` | string | Symbol |
| `'d'` | string | Position side (bid, ask) |
| `'a'` | decimal string | Position amount |
| `'p'` | decimal string | Average entry price |
| `'m'` | decimal string | Position margin |
| `'f'` | decimal string | Position funding fee |
| `'i'` | bool | Is position isolated? |
| `'l'` | decimal string | Liquidation price in USD (null if not applicable) |
| `'t'` | number | Timestamp in milliseconds |
| `'I'` | string | Position ID (UUID) |
| `'r'` | decimal string or null | Realized PnL since the position opened: close PnL, minus trading fees, plus funding. `null` for a position opened before 2026-10-04 |
| `'li'` (row) | number or null | [Last ID](/api-documentation/api/last-id) — sequence number for this `(account, symbol)` position. `null` if the engine has not touched the row yet. |
| `'li'` (envelope) | number | [Last ID](/api-documentation/api/last-id) — sequence number for the account's whole position set. Advances on every change, including closes and empty snapshots. |
# Account Trades
Source: https://docs.pacifica.fi/api-documentation/api/websocket/subscriptions/account-trades
Streams all trades that take place for an account
Refer to [Websocket](/api-documentation/api/websocket) for establishing the websocket connection.
### Params
```json theme={null}
{
"method": "subscribe",
"params": {
"source": "account_trades",
"account": "42trU9A5..."
}
}
```
### Stream
```json theme={null}
{
"channel": "account_trades",
"data": [
{
"h": 80063441,
"i": 1559912767,
"I": null,
"u": "BrZp5bidJ3WUvceSq7X78bhjTfZXeezzGvGEV4hAYKTa",
"s": "BTC",
"p": "89477",
"o": "89505",
"a": "0.00036",
"te": "fulfill_taker",
"ts": "close_long",
"tc": "normal",
"f": "0.012885",
"n": "-0.022965",
"t": 1765018588190,
"li": 1559912767,
"it": 0
}
]
}
```
| Field | Type | Description |
|---|
| `'h'` | integer | History ID |
| `'i'` | integer | Order ID |
| `'I'` | Full UUID string | Client order ID |
| `'u'` | sting | Account address |
| `'s'` | string | Symbol |
| `'p'` | decimal string | Price |
| `'o'` | decimal string | Entry price |
| `'a'` | decimal string | Trade amount |
| `'te'` | string | `'fulfill_maker'` - provided liquidity\
`'fulfill_taker'` - took liquidity |
| `'ts'` | string | Trade side |
| `'tc'` | string | `'normal'` - Regular trade\
`'market_liquidation'` - liquidated by market order\
`'backstop_liquidation'` - liquidated by backstop liquidator\
`'settlement'` - ADL/settlement\
`'insolvency_liquidation'` - liquidated due to insolvency\
`'game_settlement'` - game settlement\
`'fulfill_rfq'` - RFQ fill |
| `'f'` | decimal string | Trade fee |
| `'n'` | decimal string | PnL |
| `'t'` | number | Timestamp in milliseconds |
| `'li'` | number | [Last ID](/api-documentation/api/last-id) — sequence number, monotonically increasing. Deduplicate by history ID (`h`). |
| `'it'` | integer | Instrument type |
# Account Transfers
Source: https://docs.pacifica.fi/api-documentation/api/websocket/subscriptions/account-transfers
Streams deposit, withdrawal, and transfer events for an account.
Refer to [Websocket](/api-documentation/api/websocket) for establishing the websocket connection.
## Account Transfers
### Params
```json theme={null}
{
"method": "subscribe",
"params": {
"source": "account_transfers",
"account": "42trU9A5..."
}
}
```
### Stream
```json theme={null}
{
"channel": "account_transfers",
"data": {
"u": "42trU9A5...",
"e": "deposit",
"a": "USDC",
"am": "1000.000000",
"t": 1716200000000,
"tx": "5xGk...",
"bn": 42,
"ra": "1000.000000",
"f": "0.500000"
}
}
```
Note: the optional keys (`tx`, `s`, `r`, `bn`, `ra`, `f`) are **omitted** from the payload when they do not apply — they are not sent as `null`. Only `u`, `e`, `a`, `am`, and `t` are always present.
| Field | Type | Description |
| - | - | - |
| `'u'` | string | Account address |
| `'e'` | string | Transfer event type: `deposit`, `subaccount_transfer`, `withdrawal_pending`, `withdrawal_confirmed` |
| `'a'` | string | Asset symbol |
| `'am'` | string | Transfer amount |
| `'t'` | number | Timestamp in milliseconds |
| `'tx'` | string (optional) | Transaction ID (omitted if not applicable) |
| `'s'` | string (optional) | Source address (omitted if not applicable) |
| `'r'` | string (optional) | Receiver address (omitted if not applicable) |
| `'bn'` | integer (optional) | Batch nonce for withdrawals (omitted if not applicable) |
| `'ra'` | string (optional) | Requested amount before fees (omitted if not applicable) |
| `'f'` | string (optional) | Fee amount (omitted if not applicable) |
#### Code Example (Python)
```python theme={null}
import asyncio
import json
import websockets
async def subscribe_account_transfers(account: str):
uri = "wss://"
async with websockets.connect(uri) as ws:
await ws.send(json.dumps({
"method": "subscribe",
"params": {
"source": "account_transfers",
"account": account,
},
}))
async for message in ws:
data = json.loads(message)
print(data)
asyncio.run(subscribe_account_transfers("42trU9A5..."))
```
# Account TWAP Order Updates
Source: https://docs.pacifica.fi/api-documentation/api/websocket/subscriptions/account-twap-order-updates
Streams each change to an account's TWAP orders, such as creation, sub-order fills, and cancellation.
Refer to [Websocket](/api-documentation/api/websocket) for establishing the websocket connection.
### Params
```json theme={null}
{
"method": "subscribe",
"params": {
"source": "account_twap_order_updates",
"account": "42trU9A5..."
}
}
```
Each message carries one or more TWAP order events. Each row shows the TWAP order's state after its event, like a row of [Get TWAP order history](/api-documentation/api/rest-api/twap/get-twap-order-history). Reconcile rows by TWAP order ID (`i`).
This channel covers TWAP orders from [Create TWAP order](/api-documentation/api/rest-api/twap/create-twap-order). It does not cover TWAP order strategies.
### Stream
```json theme={null}
{
"channel": "account_twap_order_updates",
"data": [
{
"i": 13753364,
"I": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
"u": "42trU9A5...",
"s": "BTC",
"d": "bid",
"ta": "0.121",
"fa": "0.04",
"lp": "87420",
"lv": "87.42",
"tv": "3496.5",
"oe": "sub_order_executed",
"os": "in_execution",
"r": false,
"sp": "0.5",
"psa": "0.001",
"psc": 121,
"pasc": 40,
"et": 1716203630000,
"ct": 1716200000000,
"ut": 1716201200000
}
]
}
```
| Field | Type | Description |
|---|
| `'i'` | integer | TWAP order ID |
| `'I'` | Full UUID string | Client order ID |
| `'u'` | string | Account |
| `'s'` | string | Symbol |
| `'d'` | string | Side: \[`bid`, `ask`] |
| `'ta'` | decimal string | Total amount |
| `'fa'` | decimal string | Filled amount |
| `'lp'` | decimal string | Average fill price of the latest sub-order that filled |
| `'lv'` | decimal string | Filled value (price × amount) of the latest sub-order that filled |
| `'tv'` | decimal string | Total filled value (price × amount) across all sub-orders |
| `'oe'` | string | TWAP order event (see below) |
| `'os'` | string | TWAP order status (see below) |
| `'r'` | bool | Reduce only |
| `'sp'` | decimal string | Maximum slippage for each sub-order, in percent |
| `'psa'` | decimal string | Planned amount of each sub-order |
| `'psc'` | integer | Number of planned sub-orders |
| `'pasc'` | integer | Number of planned sub-orders processed so far |
| `'et'` | integer | Expiration time (milliseconds) |
| `'ct'` | integer | Created at time (milliseconds) |
| `'ut'` | integer | Updated at time (milliseconds) |
| Field | Value | Description |
| - | - | - |
| `'oe'` | `twap_created` | TWAP order created |
| | `sub_order_executed` | Sub-order placed |
| | `sub_order_failed` | Engine rejected a sub-order |
| | `cancel` | TWAP order cancelled |
| | `reject_sub_order_failure` | TWAP order stopped after a failed sub-order |
| | `expiration` | Expired with part of the amount unfilled |
| | `completion` | Full amount filled |
| `'os'` | `open` | No sub-order processed yet |
| | `in_execution` | Sending sub-orders |
| | `completed` | Full amount filled |
| | `cancelled` | Cancelled |
| | `expired` | Ended with part of the amount unfilled |
| | `rejected_due_to_sub_order` | Stopped because a sub-order was rejected |
# Account TWAP Orders
Source: https://docs.pacifica.fi/api-documentation/api/websocket/subscriptions/account-twap-orders
Streams the full list of an account's open TWAP orders whenever one of them changes.
Refer to [Websocket](/api-documentation/api/websocket) for establishing the websocket connection.
### Params
```json theme={null}
{
"method": "subscribe",
"params": {
"source": "account_twap_orders",
"account": "42trU9A5..."
}
}
```
### TWAP Order Snapshots
Pacifica sends a message when any open TWAP order on the account is created, updated, or closed. Each message is a **complete replacement** of the account's open TWAP orders. Replace your whole local list on each message. An empty `data: []` array means the account has no open TWAP orders.
Pacifica does not send a snapshot when you subscribe. To get the starting list, call [Get open TWAP orders](/api-documentation/api/rest-api/twap/get-open-twap-orders).
This channel covers TWAP orders from [Create TWAP order](/api-documentation/api/rest-api/twap/create-twap-order). It does not cover TWAP order strategies. Those stream on [Account order strategy updates](/api-documentation/api/websocket/subscriptions/account-order-strategy-updates).
### Stream
```json theme={null}
{
"channel": "account_twap_orders",
"data": [
{
"i": 13753364,
"I": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
"s": "BTC",
"d": "bid",
"a": "0.121",
"f": "0.04",
"tv": "3496.5",
"ro": false,
"sp": "0.500000000000",
"psa": "0.001",
"psc": 121,
"poc": 40,
"e": 1716203630000,
"t": 1716201200000
}
],
"li": 1559696133
}
```
| Field | Type | Description |
|---|
| `'i'` | integer | TWAP order ID |
| `'I'` | Full UUID string | Client order ID |
| `'s'` | string | Symbol |
| `'d'` | string | Side: \[`bid`, `ask`] |
| `'a'` | decimal string | Total amount |
| `'f'` | decimal string | Filled amount |
| `'tv'` | decimal string | Total filled value (price × amount) across all sub-orders |
| `'ro'` | bool | Reduce only |
| `'sp'` | decimal string | Maximum slippage for each sub-order, in percent |
| `'psa'` | decimal string | Planned amount of each sub-order |
| `'psc'` | integer | Number of planned sub-orders |
| `'poc'` | integer | Number of planned sub-orders processed so far |
| `'e'` | integer | Expiration time (milliseconds) |
| `'t'` | integer | Updated at time (milliseconds) |
| `'li'` (envelope) | integer | The highest order ID in the account's order history when Pacifica built the message. Absent if the account has no order history |
# Best Bid Offer (BBO)
Source: https://docs.pacifica.fi/api-documentation/api/websocket/subscriptions/best-bid-offer-bbo
Real-time updates of the best bid and ask prices and amounts for a specific symbol. Updates are sent whenever the top of book changes.
Refer to [Websocket](/api-documentation/api/websocket) for establishing the websocket connection.
### Params
```json theme={null}
{
"method": "subscribe",
"params": {
"source": "bbo",
"symbol": "BTC"
}
}
```
### Stream
```json theme={null}
{
"channel": "bbo",
"data": {
"s": "BTC",
"i": 1234567890,
"li": 1325476098,
"t": 1764133203991,
"b": "87185",
"B": "1.234",
"a": "87186",
"A": "0.567"
}
}
```
| Field | Type | Description |
| - | - | - |
| `'s'` | string | Symbol |
| `'i'` | integer | Order id |
| `'li'` | integer | [Last ID](/api-documentation/api/last-id) — sequence number for this symbol. Monotonically increasing; use it to order updates and detect gaps. |
| `'t'` | integer | Timestamp in milliseconds |
| `'b'` | decimal string | Best bid price |
| `'B'` | decimal string | Best bid amount (in token amount) |
| `'a'` | decimal string | Best ask price |
| `'A'` | decimal string | Best ask amount (in token amount) |
# Candle
Source: https://docs.pacifica.fi/api-documentation/api/websocket/subscriptions/candle
Streams candle information for given symbol and candle time interval
Refer to [Websocket](/api-documentation/api/websocket) for establishing the websocket connection.
### Params
```json theme={null}
{
"method": "subscribe",
"params": {
"source": "candle",
"symbol": "SOL",
"interval": "1m"
}
}
```
Where `"interval"` can be `1m, 3m, 5m, 15m, 30m, 1h, 2h, 4h, 8h, 12h, 1d, 1w, 1M`
### Stream
```json theme={null}
{
"channel": "candle",
"data": {
"t": 1749052260000,
"T": 1749052320000,
"s": "SOL",
"i": "1m",
"o": "157.3",
"c": "157.32",
"h": "157.32",
"l": "157.3",
"v": "1.22",
"n": 8
}
}
```
| Field | Type | Description |
| - | - | - |
| `'t'` | number | Start time (milliseconds) |
| `'T'` | number | End time (milliseconds) |
| `'s'` | string | Symbol |
| `'i'` | string | Candle interval |
| `'o'` | decimal string | Open price |
| `'c'` | decimal string | Close price |
| `'h'` | decimal string | High price |
| `'l'` | decimal string | Low price |
| `'v'` | decimal string | Volume |
| `'n'` | number | Number of trades in this period |
# Mark Price Candle
Source: https://docs.pacifica.fi/api-documentation/api/websocket/subscriptions/mark-price-candle
Streams real-time mark price candlestick data for a specific market.
Refer to [Websocket](/api-documentation/api/websocket) for establishing the websocket connection.
### Params
```json theme={null}
{
"method": "subscribe",
"params": {
"source": "mark_price_candle",
"symbol": "BTC",
"interval": "1m"
}
}
```
Where `"interval"` can be `1m, 3m, 5m, 15m, 30m, 1h, 2h, 4h, 8h, 12h, 1d, 1w, 1M`
### Stream
```json theme={null}
{
"channel": "mark_price_candle",
"data": {
"t": 1748954160000,
"T": 1748954220000,
"s": "BTC",
"i": "1m",
"o": "105376.500000",
"c": "105380.250000",
"h": "105385.750000",
"l": "105372.000000",
"v": "0",
"n": 0
}
}
```
| Field | Type | Description |
| - | - | - |
| `'t'` | number | Start time (milliseconds) |
| `'T'` | number | End time (milliseconds) |
| `'s'` | string | Symbol |
| `'i'` | string | Candle interval |
| `'o'` | decimal string | Open mark price |
| `'c'` | decimal string | Close mark price |
| `'h'` | decimal string | High mark price |
| `'l'` | decimal string | Low mark price |
| `'v'` | decimal string | Volume (always `"0"`) |
| `'n'` | number | Number of trades in this period |
# Orderbook
Source: https://docs.pacifica.fi/api-documentation/api/websocket/subscriptions/orderbook
Streams book data for given symbol at a set aggregation level as they update
Refer to [Websocket](/api-documentation/api/websocket) for establishing the websocket connection.
### Params
```json theme={null}
{
"method": "subscribe",
"params": {
"source": "book",
"symbol": "SOL",
"agg_level": 1 // Aggregation level
}
}
```
where `agg_level` can be one of `1, 2, 5, 10, 100, 1000`.
### Stream
```json theme={null}
{
"channel": "book",
"data": {
"l": [
[
{
"a": "37.86",
"n": 4,
"p": "157.47"
},
// ... other aggegated bid levels
],
[
{
"a": "12.7",
"n": 2,
"p": "157.49"
},
{
"a": "44.45",
"n": 3,
"p": "157.5"
},
// ... other aggregated ask levels
]
],
"s": "SOL",
"t": 1749051881187,
"li": 1559885104
}
}
```
The `book` websocket stream updates once every 250ms
| Field | Type | Description |
| - | - | - |
| `'l'` | array | \[Bids, Asks] |
| `'a'` | decimal string | Total amount in aggregation level. |
| `'n'` | integer | Number of orders in aggregation level. |
| `'p'` | decimal string | - In bids array, this is highest price in aggregation level.
- In asks array, this is lowest price in aggregation level.
|
| `'s'` | string | Symbol |
| `'t'` | number | Timestamp in milliseconds |
| `'li'` | number | [Last ID](/api-documentation/api/last-id) — sequence number for this symbol. Monotonically increasing; use it to order updates and detect gaps. |
# Prices
Source: https://docs.pacifica.fi/api-documentation/api/websocket/subscriptions/prices
Streams all symbols' price information on Pacifica as they update
Refer to [Websocket](/api-documentation/api/websocket) for establishing the websocket connection.
### Params
```json theme={null}
{
"method": "subscribe",
"params": {
"source": "prices"
}
}
```
### Stream
```json theme={null}
{
"channel": "prices",
"data": [
{
"funding": "0.0000125",
"mark": "105473",
"mid": "105476",
"next_funding": "0.0000125",
"open_interest": "0.00524",
"oracle": "105473",
"symbol": "BTC",
"timestamp": 1749051612681,
"volume_24h": "63265.87522",
"yesterday_price": "955476"
}
// ... other symbol prices
],
}
```
| Field | Type | Description |
| - | - | - |
| `'funding'` | decimal string | Funding rate |
| `'mark'` | decimal string | Mark price |
| `'timestamp'` | number | Timestamp in milliseconds |
| `'mid'` | decimal string | Mid price |
| `'next_funding'` | decimal string | Next funding rate |
| `'open_interest'` | decimal string | Open interest amount |
| `'oracle'` | decimal string | Oracle price |
| `'symbol'` | string | Symbol |
| `'volume_24h'` | decimal string | 24 hour volume in USD |
| `'yesterday_price'` | decimal string | Previous day price |
# Trades
Source: https://docs.pacifica.fi/api-documentation/api/websocket/subscriptions/trades
Streams all trades on the taker side as they occur in a chosen market.
Refer to [Websocket](/api-documentation/api/websocket) for establishing the websocket connection.
### Params
```json theme={null}
{
"method": "subscribe",
"params": {
"source": "trades",
"symbol": "SOL"
}
}
```
### Stream
```json theme={null}
{
"channel": "trades",
"data": [
{
"h": 80062522,
"s": "BTC",
"a": "0.00001",
"p": "89471",
"d": "close_short",
"tc": "normal",
"t": 1765018379085,
"li": 1559885104,
"it": 0
}
]
}
```
| Field | Type | Description |
|---|
| `'h'` | integer | History ID |
| `'s'` | string | Symbol |
| `'a'` | decimal string | Amount |
| `'p'` | decimal string | Price |
| `'d'` | string | Trade side`open_long``open_short``close_long``close_short` |
| `'tc'` | string | Trade cause`normal` `market_liquidation` `backstop_liquidation` `settlement` `insolvency_liquidation` `game_settlement` `fulfill_rfq` |
| `'t'` | number | Timestamp in milliseconds |
| `'li'` | number | [Last ID](/api-documentation/api/last-id) — sequence number for this symbol. Monotonically increasing; use it to order updates and detect gaps. |
| `'it'` | integer | Instrument type |
# Trading Operations
Source: https://docs.pacifica.fi/api-documentation/api/websocket/trading-operations
* [Create market order](/api-documentation/api/websocket/trading-operations/create-market-order): This request type allows users to place market orders through Pacifica's websocket API.
* [Create limit order](/api-documentation/api/websocket/trading-operations/create-limit-order): This request type allows users to place limit orders through Pacifica's websocket API.
* [Edit order](/api-documentation/api/websocket/trading-operations/edit-order): This request type allows users to modify existing orders (price and/or size) through websocket API in one request.
* [Batch order](/api-documentation/api/websocket/trading-operations/batch-order): This endpoint allows users to submit multiple order operations in a single websocket request.
* [Cancel order](/api-documentation/api/websocket/trading-operations/cancel-order): This request type allows users to cancel orders through Pacifica's websocket API.
* [Cancel all orders](/api-documentation/api/websocket/trading-operations/cancel-all-orders): This request type allows users to cancel all orders through Pacifica's websocket API.
# Batch Order
Source: https://docs.pacifica.fi/api-documentation/api/websocket/trading-operations/batch-order
This endpoint allows users to submit multiple order operations in a single websocket request.
The [Pacifica Python SDK](https://github.com/pacifica-fi/python-sdk/blob/f2385d42e9ae5276ba2ba85505d51db2eefd2715/rest/batch_orders.py) provides a comprehensive example on using this endpoint
### Request
```json theme={null}
{
"id": "660065de-8f32-46ad-ba1e-83c93d3e3966",
"params": {
"batch_orders": {
"actions": [
{
"type": "Create",
"data": {
"account": "42trU9A5...",
"signature": "5UpRZ14Q...",
"timestamp": 1749190500355,
"expiry_window": 5000,
"symbol": "BTC",
"price": "100000",
"reduce_only": false,
"amount": "0.1",
"side": "bid",
"tif": "GTC",
"client_order_id": "57a5efb1-bb96-49a5-8bfd-f25d5f22bc7e"
}
},
{
"type": "CreateMarket",
"data": {
"account": "42trU9A5...",
"signature": "3KxMn7pQ...",
"timestamp": 1749190500355,
"expiry_window": 5000,
"symbol": "ETH",
"amount": "1.0",
"side": "ask",
"slippage_percent": "0.5",
"reduce_only": false
}
},
{
"type": "Cancel",
"data": {
"account": "42trU9A5...",
"signature": "4NDFHyTG...",
"timestamp": 1749190500355,
"expiry_window": 5000,
"symbol": "SOL",
"order_id": 42069
}
}
]
}
}
}
```
| Field | Type | Need | Description | Example |
|---|
| `"id"` | Full UUID string | required | Client-defined request ID | 660065de-8f32-46ad-ba1e-83c93d3e3966 |
| `"actions"` | array | required | List of order actions to perform\
\
Each action has a "type" field and action-specific "data" | See next two rows |
| `"type"` | string | required | Specifies type of action. This is DIFFERENT to the "type" used in signature headers | `"Create"`\
`"CreateMarket"`\
`"Cancel"`\
`"Edit"`\
`"SetPositionTpsl"`\
`"CancelStopOrder"`\
(case sensitive) |
| `"data"` | object | required | Contains signed request payloads of individual actions. Fields are identical to the corresponding standalone endpoints: create limit order, create market order, cancel order, edit order, create position TP/SL, and cancel stop order. | See code block below. Messages and corresponding fields are identical to [create](/api-documentation/api/rest-api/orders/create-limit-order) and [cancel](/api-documentation/api/rest-api/orders/cancel-order) requests. |
#### Response
* Status 200: Batch operations processed successfully
```json theme={null}
{
"code": 200,
"data": {
"results": [
{
"success": true,
"order_id": 645953,
"error": null
},
{
"success": false,
"order_id": null,
"error": "Order not found"
}
]
},
"id": "660065de-8f32-46ad-ba1e-83c93d3e3966",
"t": 1749223025962,
"type": "batch_orders",
"rl": {
"r": 9980,
"q": 10000,
"t": 1000
}
}
```
Each entry in `results` corresponds positionally to an action in the request `actions` array, and has the following fields:
| Field | Type | Description |
| - | - | - |
| `'success'` | boolean | Whether the individual action succeeded |
| `'order_id'` | integer or null | Resulting order ID (null for cancels or failed actions) |
| `'error'` | string or null | Error message if the action failed, otherwise null |
The top-level frame also includes the always-present `rl` (rate-limit) object: `r` = credits remaining, `q` = quota, `t` = reset-in (ms).
* Status 400: Bad request
```json theme={null}
{
"error": "Invalid batch operation parameters",
"code": 400
}
```
* Status 500: Internal server error
### Notes on Batch Ordering
#### Speed Bump (Latency Protection)
Batch orders are subject to a conditional randomized \~200ms (190-210ms) delay to protect liquidity providers from adverse selection:\
\
Speed bump is applied if the batch contains:
* Market orders (CreateMarket)
* Limit orders with TIF = GTC or IOC
Speed bump is NOT applied if the batch only contains:
* Add Liquidity Only orders (TIF = ALO)
* Top of Book orders (TIF = TOB)
* Cancel operations
* Edit operations
* TP/SL operations
When the speed bump applies, it is applied once to the batch as a whole before any action is processed, so exempt actions in the same batch (such as edits and cancels) are delayed along with it.
#### Signature Requirements
* Each action in the batch must be individually signed
* All signatures must be valid for the batch to process
#### Execution Behavior and Limits
* Maximum 10 actions per batch request
* Actions are executed atomically in the order provided
* If one action fails, subsequent actions are still attempted
# Cancel All Orders
Source: https://docs.pacifica.fi/api-documentation/api/websocket/trading-operations/cancel-all-orders
This request type allows users to cancel all orders through Pacifica's websocket API.
The [Pacifica Python SDK](https://github.com/pacifica-fi/python-sdk/blob/f2385d42e9ae5276ba2ba85505d51db2eefd2715/ws/cancel_all_orders.py) provides a comprehensive example on using this endpoint.
### Request
```json theme={null}
{
"id": "4e9b4edb-b123-4759-9250-d19db61fabcb",
"params": {
"cancel_all_orders": {
"account": "AwX6f3...",
"signature": "2XP8fz...",
"timestamp": 1749221927343,
"expiry_window": 5000,
"all_symbols": true,
"exclude_reduce_only": false
}
}
}
```
| Field | Type | Need | Description | Example |
|---|
| `"id"` | Full UUID string | required | Client-defined request ID | `1bb2b72f-f545-4938-8a38-c5cda8823675` |
| `"params"` | object | required | Contains action type and action parameters | `"cancel_all_orders"` |
| `"cancel_all_orders"` | object | required | Specifies action type and contains parameters | See examples. |
| `"account"` | string | required | User's wallet address | `42trU9A5...` |
| `"agent_wallet"` | string | optional | Agent wallet address | `69trU9A5...` |
| `"signature"` | string | required | Cryptographic signature | `5j1Vy9Uq...` |
| `"timestamp"` | integer | required | Current timestamp in milliseconds | `1716200000000` |
| `"expiry_window"` | integer | optional | Signature expiry in milliseconds | `30000` |
| `"all_symbols"` | boolean | required | Whether to cancel orders for all symbols | `true` |
| `"exclude_reduce_only"` | boolean | required | Whether to exclude reduce-only orders | `false` |
| `"symbol"` | string | required\
(if `"all_symbols"` is false) | Trading pair symbol | `BTC` |
```json theme={null}
{
"code": 200,
"data": {
"cancelled_count": 10
},
"id": "b86b4f45-49da-4191-84e2-93e141acdeab",
"t": 1749221787291,
"type": "cancel_all_orders",
"rl": {
"r": 9995,
"q": 10000,
"t": 1000
}
}
```
| Field | Type | Description |
| - | - | - |
| `'code'` | integer | Status code |
| `'data'` | object | Contains information about placed order |
| `'cancelled_count'` | integer | Number of orders successfully cancelled |
| `'id'` | string | Same as above request ID |
| `'t'` | integer | Timestamp in milliseconds |
| `'type'` | string | Specifies action type |
| `'rl'` | object or null | Rate-limit info, always present: `r` = credits remaining, `q` = quota, `t` = reset-in (ms) |
On error, the frame omits `data` and instead carries an `err` (string) field describing the failure, alongside the same `id`, `type`, `code`, `t`, and `rl` fields.
# Cancel Order
Source: https://docs.pacifica.fi/api-documentation/api/websocket/trading-operations/cancel-order
This request type allows users to cancel orders through Pacifica's websocket API.
The [Pacifica Python SDK](https://github.com/pacifica-fi/python-sdk/blob/f2385d42e9ae5276ba2ba85505d51db2eefd2715/ws/cancel_order.py) provides a comprehensive example on using this endpoint.
### Request
```json theme={null}
{
"id": "1bb2b72f-f545-4938-8a38-c5cda8823675",
"params": {
"cancel_order": {
"account": "AwX6321...",
"signature": "4RqbgB...",
"timestamp": 1749223343149,
"expiry_window": 5000,
"symbol": "BTC",
"client_order_id": "79f948fd-7556-4066-a128-083f3ea49322"
}
}
}
```
| Field | Type | Need | Description | Example |
|---|
| `"id"` | Full UUID string | required | Client-defined request ID | `1bb2b72f-f545-4938-8a38-c5cda8823675` |
| `"params"` | object | required | Contains action type and action parameters | `"cancel_order"` |
| `"cancel_order"` | object | required | Specifies action type and contains parameters | See examples. |
| `"account"` | string | required | User's wallet address | `42trU9A5...` |
| `"agent_wallet"` | string | optional | Agent wallet address | `69trU9A5...` |
| `"signature"` | string | required | Cryptographic signature | `5j1Vy9Uq...` |
| `"timestamp"` | integer | required | Current timestamp in milliseconds | `1716200000000` |
| `"expiry_window"` | integer | optional | Signature expiry in milliseconds | `30000` |
| `"symbol"` | string | required | Trading pair symbol | `BTC` |
| `"order_id"` | integer | required (if no CLOID) | Exchange-assigned order ID | `123` |
| `"client_order_id"` | Full UUID string | required (if no OID) | Client-defined order ID | `f47ac10b-58cc-4372-a567-0e02b2c3d479` |
### Response
```json theme={null}
{
"code": 200,
"data": {
"I": "79f948fd-7556-4066-a128-083f3ea49322",
"i": null,
"s": "BTC"
},
"id": "1bb2b72f-f545-4938-8a38-c5cda8823675",
"t": 1749223343610,
"type": "cancel_order",
"rl": {
"r": 9995,
"q": 10000,
"t": 1000
}
}
```
| Field | Type | Description |
| - | - | - |
| `'code'` | integer | Status code |
| `'data'` | object | Contains information about placed order |
| `'I'` | string | CLOID (if provided) |
| `'i'` | integer | Order ID |
| `'s'` | string | Symbol |
| `'id'` | string | Same as above request ID |
| `'t'` | integer | Timestamp in milliseconds |
| `'type'` | string | Specifies action type |
| `'rl'` | object or null | Rate-limit info, always present: `r` = credits remaining, `q` = quota, `t` = reset-in (ms) |
On error, the frame omits `data` and instead carries an `err` (string) field describing the failure, alongside the same `id`, `type`, `code`, `t`, and `rl` fields.
Cancels are not subject to any speedbump.
# Create Limit Order
Source: https://docs.pacifica.fi/api-documentation/api/websocket/trading-operations/create-limit-order
This request type allows users to place limit orders through Pacifica's websocket API.
The [Pacifica Python SDK](https://github.com/pacifica-fi/python-sdk/blob/f2385d42e9ae5276ba2ba85505d51db2eefd2715/ws/create_order.py) provides a comprehensive example on using this endpoint.
### Request
```json theme={null}
{
"id": "660065de-8f32-46ad-ba1e-83c93d3e3966",
"params": {
"create_order": {
"account": "AwX6321...",
"signature": "5vnYpt...",
"timestamp": 1749223025396,
"expiry_window": 5000,
"symbol": "BTC",
"price": "100000.00",
"reduce_only": false,
"amount": "0.001",
"side": "bid",
"tif": "GTC",
"client_order_id": "79f948fd-7556-4066-a128-083f3ea49322",
"builder_code": "MYCODE"
}
}
}
```
| Field | Type | Need | Description | Example |
|---|
| `"id"` | Full UUID string | required | Client-defined request ID | `660065de-8f32-46ad-ba1e-83c93d3e3966` |
| `"params"` | object | required | Contains action type and action parameters | `"create_order"` |
| `"create_order"` | object | required | Specifies action type and contains parameters | See examples. |
| `"account"` | string | required | User's wallet address | `42trU9A5...` |
| `"agent_wallet"` | string | optional | Agent wallet address | `69trU9A5...` |
| `"signature"` | string | required | Cryptographic signature | `5j1Vy9Uq...` |
| `"timestamp"` | integer | required | Current timestamp in milliseconds | `1716200000000` |
| `"expiry_window"` | integer | optional | Signature expiry in milliseconds | `30000` |
| `"symbol"` | string | required | Trading pair symbol | `BTC` |
| `"price"` | string | required | Order price | `50000` |
| `"reduce_only"` | boolean | required | Whether the order is reduce-only | `false` |
| `"amount"` | string | required | Order amount | `0.1` |
| `"side"` | string | required | Order side (bid/ask) | `bid` |
| `"tif"` | string | required | Time in force (`GTC`, `IOC`, `ALO`, `TOB`) | `GTC` |
| `"client_order_id"` | Full UUID string | optional | Client-defined order ID | `f47ac10b-58cc-4372-a567-0e02b2c3d479` |
| `"order_expiry"` | integer | optional | When the order expires and is cancelled, in milliseconds since epoch. Must be 5 minutes to 30 days from now. Only for TIF `GTC`, `ALO`, and `TOB` | `1716203600000` |
| `"builder_code"` | string | optional | Builder program code (3-16 alphanumeric) | `MYCODE` |
| `"take_profit"` | object | optional | Take profit stop order configuration | See next three rows |
| `"stop_price"` | string | required (if `"take_profit"` exists) | Stop trigger price | `55000` |
| `"limit_price"` | string | optional | Limit price for the triggered order | `54950` |
| `"client_order_id"` | string | Full UUID string | Client-defined order ID for the stop order | `e36ac10b-58cc-4372-a567-0e02b2c3d479` |
| `"trigger_price_type"` | string | optional | Price type to trigger stop. Options: `mark_price` (default), `last_trade_price`, `mid_price` | `mark_price` |
| `"stop_loss"` | object | optional | Stop loss order configuration | See next three rows |
| `"stop_price"` | string | required (if `"stop_loss"` exists) | Stop trigger price | `48000` |
| `"limit_price"` | string | optional | Limit price for the triggered order | `47950` |
| `"client_order_id"` | string | Full UUID string | Client-defined order ID for the stop order | `d25ac10b-58cc-4372-a567-0e02b2c3d479` |
| `"trigger_price_type"` | string | optional | Price type to trigger stop. Options: `mark_price` (default), `last_trade_price`, `mid_price` | `mark_price` |
### Response
```json theme={null}
{
"code": 200,
"data": {
"I": "79f948fd-7556-4066-a128-083f3ea49322",
"i": 645953,
"s": "BTC"
},
"id": "660065de-8f32-46ad-ba1e-83c93d3e3966",
"t": 1749223025962,
"type": "create_order",
"rl": {
"r": 9990,
"q": 10000,
"t": 1000
}
}
```
| Field | Type | Description |
| - | - | - |
| `'code'` | integer | Status code |
| `'data'` | object | Contains information about placed order |
| `'I'` | string | CLOID (if provided) |
| `'i'` | integer | Order ID |
| `'s'` | string | Symbol |
| `'id'` | string | Client-defined request ID |
| `'t'` | integer | Timestamp in milliseconds |
| `'type'` | string | Specifies action type |
| `'rl'` | object or null | Rate-limit info, always present: `r` = credits remaining, `q` = quota, `t` = reset-in (ms) |
On error, the frame omits `data` and instead carries an `err` (string) field describing the failure, alongside the same `id`, `type`, `code`, `t`, and `rl` fields.
Note: In order to protect liquidity providers from adverse selection, all TIF GTC, and TIF IOC orders are subject to a \~200ms delay.
# Create Market Order
Source: https://docs.pacifica.fi/api-documentation/api/websocket/trading-operations/create-market-order
This request type allows users to place market orders through Pacifica's websocket API.
The [Pacifica Python SDK](https://github.com/pacifica-fi/python-sdk/blob/f2385d42e9ae5276ba2ba85505d51db2eefd2715/ws/create_order.py) provides a comprehensive example on using this endpoint.
### Request
```json theme={null}
{
"id": "660065de-8f32-46ad-ba1e-83c93d3e3966",
"params": {
"create_market_order": {
"account": "AwX6321...",
"signature": "5vnYpt...",
"timestamp": 1749223025396,
"expiry_window": 5000,
"symbol": "BTC",
"reduce_only": false,
"amount": "0.001",
"side": "bid",
"slippage_percent": "0.5",
"client_order_id": "79f948fd-7556-4066-a128-083f3ea49322",
"builder_code": "MYCODE"
}
}
}
```
| Field | Type | Need | Description | Example |
|---|
| `"id"` | Full UUID string | required | Client-defined request ID | `660065de-8f32-46ad-ba1e-83c93d3e3966` |
| `"params"` | object | required | Contains action type and action parameters | `"create_order"` |
| `"create_market_order"` | object | required | Specifies action type and contains parameters | See examples. |
| `"account"` | string | required | User's wallet address | `42trU9A5...` |
| `"agent_wallet"` | string | optional | Agent wallet address | `69trU9A5...` |
| `"signature"` | string | required | Cryptographic signature | `5j1Vy9Uq...` |
| `"timestamp"` | integer | required | Current timestamp in milliseconds | `1716200000000` |
| `"expiry_window"` | integer | optional | Signature expiry in milliseconds | `30000` |
| `"symbol"` | string | required | Trading pair symbol | `BTC` |
| `"reduce_only"` | boolean | required | Whether the order is reduce-only | `false` |
| `"amount"` | string | required | Order amount | `0.1` |
| `"side"` | string | required | Order side (bid/ask) | `bid` |
| `"slippage_percent"` | string | required | Maximum allowed slippage in percentage, e.g. "0.5" means 0.5% max slippage | `0.5` |
| `"client_order_id"` | Full UUID string | optional | Client-defined order ID | `f47ac10b-58cc-4372-a567-0e02b2c3d479` |
| `"builder_code"` | string | optional | Builder program code (3-16 alphanumeric) | `MYCODE` |
| `"take_profit"` | object | optional | Take profit stop order configuration | See next three rows |
| `"stop_price"` | string | required (if `"take_profit"` exists) | Stop trigger price | `55000` |
| `"limit_price"` | string | optional | Limit price for the triggered order | `54950` |
| `"client_order_id"` | Full UUID string | optional | Client-defined order ID for the stop order | `e36ac10b-58cc-4372-a567-0e02b2c3d479` |
| `"trigger_price_type"` | string | optional | Price type to trigger stop. Options: `mark_price` (default), `last_trade_price`, `mid_price` | `mark_price` |
| `"stop_loss"` | object | optional | Stop loss order configuration | See next three rows |
| `"stop_price"` | string | required (if `"stop_loss"` exists) | Stop trigger price | `48000` |
| `"limit_price"` | string | optional | Limit price for the triggered order | `47950` |
| `"client_order_id"` | Full UUID string | optional | Client-defined order ID for the stop order | `d25ac10b-58cc-4372-a567-0e02b2c3d479` |
| `"trigger_price_type"` | string | optional | Price type to trigger stop. Options: `mark_price` (default), `last_trade_price`, `mid_price` | `mark_price` |
### Response
```json theme={null}
{
"code": 200,
"data": {
"I": "79f948fd-7556-4066-a128-083f3ea49322",
"i": 645953,
"s": "BTC"
},
"id": "660065de-8f32-46ad-ba1e-83c93d3e3966",
"t": 1749223025962,
"type": "create_market_order",
"rl": {
"r": 9990,
"q": 10000,
"t": 1000
}
}
```
| Field | Type | Description |
| - | - | - |
| `'code'` | integer | Status code |
| `'data'` | object | Contains information about placed order |
| `'I'` | string | CLOID (if provided) |
| `'i'` | integer | Order ID |
| `'s'` | string | Symbol |
| `'id'` | string | Client-defined request ID |
| `'t'` | integer | Timestamp in milliseconds |
| `'type'` | string | Specifies action type |
| `'rl'` | object or null | Rate-limit info, always present: `r` = credits remaining, `q` = quota, `t` = reset-in (ms) |
On error, the frame omits `data` and instead carries an `err` (string) field describing the failure, alongside the same `id`, `type`, `code`, `t`, and `rl` fields.
Note: In order to protect liquidity providers from adverse selection, all market orders are subject to a \~200ms delay.
# Edit Order
Source: https://docs.pacifica.fi/api-documentation/api/websocket/trading-operations/edit-order
This request type allows users to modify existing orders (price and/or size) through websocket API in one request.
The [Pacifica Python SDK](https://github.com/pacifica-fi/python-sdk/blob/f2385d42e9ae5276ba2ba85505d51db2eefd2715/ws/create_order.py) provides a comprehensive example on using this endpoint.
### Request
```json theme={null}
{
"id": "660065de-8f32-46ad-ba1e-83c93d3e3966",
"params": {
"edit_order": {
"account": "AwX6321...",
"signature": "5vnYpt...",
"timestamp": 1749223025396,
"expiry_window": 5000,
"symbol": "BTC",
"price": "99500",
"amount": "0.002",
"order_id": 645953
}
}
}
```
| Field | Type | Need | Description | Example |
|---|
| `"id"` | Full UUID string | required | Client-defined request ID | `660065de-8f32-46ad-ba1e-83c93d3e3966` |
| `"params"` | object | required | Contains action type and action parameters | `"edit_order"` |
| `"edit_order"` | object | required | Specifies action type and contains parameters | See examples. |
| `"account"` | string | required | User's wallet address | `42trU9A5...` |
| `"agent_wallet"` | string | optional | Agent wallet address | `69trU9A5...` |
| `"signature"` | string | required | Cryptographic signature | `5j1Vy9Uq...` |
| `"timestamp"` | integer | required | Current timestamp in milliseconds | `1716200000000` |
| `"expiry_window"` | integer | optional | Signature expiry in milliseconds | `30000` |
| `"symbol"` | string | required | Trading pair symbol | `BTC` |
| `"price"` | string | required | Order price | `99500` |
| `"amount"` | string | optional | Order amount (if omitted, only the price is changed) | `0.002` |
| `"order_id"` | integer | optional | System-defined order ID (needed if no CLOID provided) | `645953` |
| `"client_order_id"` | Full UUID string | optional | Client-defined order ID (needed if no OID provided) | `f47ac10b-58cc-4372-a567-0e02b2c3d479` |
| `"order_expiry"` | integer or null | optional | New expiry in milliseconds since epoch, 5 minutes to 30 days from now. Omit it to keep the current expiry. Send `null` to remove the expiry. The value, including `null`, is part of the signed data | `1716203600000` |
### Response
```json theme={null}
{
"code": 200,
"data": {
"I": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
"i": 645954,
"s": "BTC"
},
"id": "660065de-8f32-46ad-ba1e-83c93d3e3966",
"t": 1749223026150,
"type": "edit_order",
"rl": {
"r": 9990,
"q": 10000,
"t": 1000
}
}
```
| Field | Type | Description |
| - | - | - |
| `'code'` | integer | Status code |
| `'data'` | object | Contains information about placed order |
| `'I'` | string | CLOID (if original order contained one) |
| `'i'` | integer | New order ID |
| `'s'` | string | Symbol |
| `'id'` | string | Client-defined request ID |
| `'t'` | integer | Timestamp in milliseconds |
| `'type'` | string | Specifies action type |
| `'rl'` | object or null | Rate-limit info, always present: `r` = credits remaining, `q` = quota, `t` = reset-in (ms) |
On error, the frame omits `data` and instead carries an `err` (string) field describing the failure, alongside the same `id`, `type`, `code`, `t`, and `rl` fields.
**Notes:** Editing an order cancels the original and creates a new one. The new order maintains the same side, reduce-only status, and client\_order\_id (if provided), is created with TIF = ALO (Post Only), and receives a new system-assigned order\_id.\
\
Edit orders are not subject to the taker speedbump. Because the replacement order is always created with TIF = ALO (Post Only), it can never take liquidity, so no delay is applied.
# Changelog
Source: https://docs.pacifica.fi/api-documentation/changelog
Changelog for Pacifica's API documentation
### 2026-11-05
**Docs**
* [Error codes](/api-documentation/api/error-codes) \[UPDATE]
* Added business logic error codes 122–158
* Documented the error response format: `error_id`, signature error IDs, and per-field validation `details`
* [TWAP](/api-documentation/api/rest-api/twap) \[NEW]
* Documented the TWAP order endpoints under `/api/v1/orders/twap` and the [Account TWAP orders](/api-documentation/api/websocket/subscriptions/account-twap-orders) and [Account TWAP order updates](/api-documentation/api/websocket/subscriptions/account-twap-order-updates) websocket channels. These have been live since 2025-10-08
* [Operation types](/api-documentation/api/signing/operation-types) \[UPDATE]
* Added the signing types for Print orders, order strategies, account settings, TWAP orders, two-factor authentication, and notifications
### 2026-10-20
**REST API**
* [Create Print order](/api-documentation/api/rest-api/print/create-print-order) \[UPDATE]
* A Print order with a builder code now also pays the code's builder fee on the perp position it delivers, on top of the 10% premium share
* The user's approval `max_fee_rate` must now cover the code's `fee_rate`, as for an order
### 2026-10-17
**REST API**
* [Create Print order](/api-documentation/api/rest-api/print/create-print-order) \[NEW]
* Documented `POST /api/v1/game/deposit` for placing Print orders
* Added `builder_code`: the code's owner earns 10% of each premium of the order
**WebSocket**
* [Account liquidations](/api-documentation/api/websocket/subscriptions/account-liquidations) \[NEW]
* Streams each of an account's positions that liquidation or ADL closed. Requires the account's API config key
### 2026-10-16
**REST API**
* [Web Push notifications](/api-documentation/api/rest-api/notifications#web-push) \[NEW]
* Register a browser's Web Push subscription to get notifications in browsers and installed web apps
### 2026-10-08
**REST API**
* [Two-factor authentication](/api-documentation/api/rest-api/two-factor) \[NEW]
* Endpoints under `/api/v1/account/2fa` to turn on 2FA with an authenticator app or a passkey, manage factors, and regenerate recovery keys
* [Request withdrawal](/api-documentation/api/rest-api/account/request-withdrawal) and [Withdraw spot asset](/api-documentation/api/rest-api/account/withdraw-spot-asset) \[UPDATE]
* Accounts with two-factor authentication on must send a `two_factor` proof and an `idempotency_key`. This applies to agent wallets too
* Retrying with the same `idempotency_key` and the same request now returns the first result. Status `409` means the key was used for a different request
* [Notifications](/api-documentation/api/rest-api/notifications) \[NEW]
* Endpoints under `/api/v1/account/notifications` for mobile push devices, notification preferences, test notifications, and the in-app notification history
### 2026-10-04
**REST API & WS**
* [Get positions](/api-documentation/api/rest-api/account/get-positions) and [Account positions](/api-documentation/api/websocket/subscriptions/account-positions) \[UPDATE]
* Added realized PnL since the position opened: `realized_pnl` (REST) and `r` (WS). `null` for positions opened before this date
### 2026-10-03
**REST API**
* [Update account settings](/api-documentation/api/rest-api/account/update-account-settings) \[NEW]
* `POST /api/v1/account/settings` sets the leaderboard `privacy_mode`: `none`, `anonymous`, or `hidden`
* [Get account settings](/api-documentation/api/rest-api/account/get-account-settings) returns `privacy_mode`
### 2026-09-29
**REST API**
* Input validation \[UPDATE]
* Requests with invalid fields return status `400` with an `error_id` and a `details` list of the bad fields. See [Error codes](/api-documentation/api/error-codes#error-response-format)
### 2026-09-17
**REST API & WS**
* [Last ID](/api-documentation/api/last-id) \[UPDATE]
* `account_positions` and REST [`/api/v1/positions`](/api-documentation/api/rest-api/account/get-positions) / [`/api/v1/orders`](/api-documentation/api/rest-api/orders/get-open-orders) now include a per-row `li` alongside the set-level value
* Documented Last ID as a per-symbol sequence number for ordering and gap detection
### 2026-09-13
**REST API & WS**
* [Order strategies](/api-documentation/api/rest-api/order-strategies) \[NEW]
* Create, edit, cancel, and list server-side order strategies under `/api/v1/order_strategies`: OCO, conditional, trailing stop, chase, swarm, trigger swarm, and TWAP
* [Account order strategy updates](/api-documentation/api/websocket/subscriptions/account-order-strategy-updates) websocket streams lifecycle changes
* Orders and trades that a strategy places carry the strategy ID as `parent_id`
* [Get order history records](/api-documentation/api/rest-api/orders/get-order-history-records) \[NEW]
* Returns orders and finished order strategies in one cursor-paginated list
* [Get TWAP records](/api-documentation/api/rest-api/twap/get-twap-records) and [Get TWAP record history](/api-documentation/api/rest-api/twap/get-twap-record-history) \[NEW]
* `/api/v1/twaps` and `/api/v1/twaps/history` list TWAP orders and TWAP order strategies together
### 2026-09-04
**REST API & WS**
* [Get positions](/api-documentation/api/rest-api/account/get-positions) and [Account positions](/api-documentation/api/websocket/subscriptions/account-positions) \[UPDATE]
* Added a position ID: `id` (REST) and `I` (WS). A new ID starts each time a position opens from flat
**WebSocket**
* [Orderbook](/api-documentation/api/websocket/subscriptions/orderbook) \[UPDATE]
* `agg_level` values are now `1, 2, 5, 10, 100, 1000`. Levels `2` and `5` are new. **Breaking:** `10000` is no longer accepted
* [Compression](/api-documentation/api/websocket#compression) \[NEW]
* Connect with `?compress=deflate` to receive subscription data as raw DEFLATE binary frames
### 2026-08-27
**REST API & WS**
* Order expiry \[NEW]
* Added optional `order_expiry` (milliseconds) to [create limit order](/api-documentation/api/rest-api/orders/create-limit-order) for TIF `GTC`, `ALO`, and `TOB`. The expiry must be 5 minutes to 30 days from now
* [Edit order](/api-documentation/api/rest-api/orders/edit-order) accepts `order_expiry`: omit it to keep the current expiry, or send `null` to remove it
* [Get open orders](/api-documentation/api/rest-api/orders/get-open-orders) returns `order_expiry`
* Batch `Create` and `Edit` actions accept the same field
* [Edit order](/api-documentation/api/rest-api/orders/edit-order) \[UPDATE]
* Edits, including edits in a batch, are no longer subject to the taker speed bump
**WebSocket**
* [WebSocket limits](/api-documentation/api/rate-limits#websocket-limits) \[UPDATE]
* New per-IP connection limits and per-connection limits on subscriptions, distinct accounts, and subscribe messages
### 2026-08-06
**REST API & WS**
* [Get account info](/api-documentation/api/rest-api/account/get-account-info) and [Account info](/api-documentation/api/websocket/subscriptions/account-info) websocket \[NEW]
* Added optional `full` parameter. It adds Print order equity and total account equity (`print_order_equity`, `total_account_equity` on REST; `cae`, `poe`, `tae` on WS)
### 2026-07-28
**REST API & WS**
* Error IDs \[NEW]
* Error responses now include an `error_id`. Signature failures return JSON with an `error_id` such as `signature_expired`, instead of plain text. See [Error codes](/api-documentation/api/error-codes#error-response-format)
### 2026-07-25
**GENERAL API**
* [Open order limits](/api-documentation/api/rate-limits#open-order-limits) \[NEW]
* Accounts on fee tier 1 can hold up to 300 open orders per market. Higher tiers and market makers can hold up to 1,000
### 2026-06-30
**MCP**
* [MCP Server](/api-documentation/api/mcp) \[NEW]
* Added documentation for the Pacifica MCP server (`@pacifica-fi/mcp-server`), which exposes the REST API as Model Context Protocol tools
* Covers the Claude Desktop quickstart, configuration (environment variables, auth modes, security), client setup for Claude Code, OpenAI Codex, Factory, Hermes, and Crush, and the full tool reference
* Documents the on-chain [funding tools](/api-documentation/api/mcp/tools#funding) `mintUsdp` (testnet faucet) and `depositUsdp` (deposit USDC/USDP into your exchange balance), plus the `SOLANA_RPC_URL`, `PACIFICA_PROGRAM_ID`, and `PACIFICA_USDC_MINT` environment variables
### 2026-05-04
**Docs**
* [Vaults](/vaults) \[NEW]
* Added a new vaults section covering overview, depositing, managing a vault, profit and loss, and risk controls
**REST API**
* [Vaults](/api-documentation/api/rest-api/vaults) \[NEW]
* Added REST API docs for vault creation, deposits, withdrawals, manager claims, referral codes, deposit cap updates, whitelist/blacklist updates, max leverage updates, and vault listing under `/api/v1/lake/*`
* [Operation Types](/api-documentation/api/signing/operation-types) \[UPDATE]
* Added signing operation types for all documented vault endpoints
### 2026-04-23
**REST API & WS**
* [Batch order](/api-documentation/api/rest-api/orders/batch-order) \[UPDATE]
* Expanded action types: `CreateMarket`, `Edit`, `SetPositionTpsl`, `CancelStopOrder` now supported alongside `Create` and `Cancel`
* Added `builder_code` parameter to all order creation endpoints \[UPDATE]
* Supports Builder Program fee attribution (3-16 alphanumeric characters)
* Added `trigger_price_type` to all stop order and TP/SL configurations \[UPDATE]
* Options: `mark_price` (default), `last_trade_price`, `mid_price`
**REST API**
* [Get spot assets](/api-documentation/api/rest-api/spot/get-spot-assets) \[NEW]
* List all spot assets with collateral eligibility and LTV ratios
* [Get bridge info](/api-documentation/api/rest-api/spot/get-bridge-info) \[NEW]
* Retrieve bridge parameters for all spot assets (minimum deposit, withdrawal fee, mint address)
* [Get bridge parameters](/api-documentation/api/rest-api/spot/get-bridge-parameters) \[NEW]
* Retrieve bridge parameters for a single spot asset by symbol
* [Withdraw spot asset](/api-documentation/api/rest-api/account/withdraw-spot-asset) \[NEW]
* Withdraw spot assets with idempotency key support
* [Get pending spot withdrawals](/api-documentation/api/rest-api/account/get-pending-spot-withdrawals) \[NEW]
* [Get spot deposit history](/api-documentation/api/rest-api/account/get-spot-deposit-history) \[NEW]
* [Get spot withdrawal history](/api-documentation/api/rest-api/account/get-spot-withdrawal-history) \[NEW]
* [Get spot balance history](/api-documentation/api/rest-api/account/get-spot-balance-history) \[NEW]
* [Subaccount spot transfer](/api-documentation/api/rest-api/subaccounts/subaccount-spot-transfer) \[NEW]
* Transfer spot assets between main account and subaccounts
* [Update spot settings](/api-documentation/api/rest-api/account/update-spot-settings) \[NEW]
* Toggle per-asset `unified_margin_excluded` flag for unified margin collateral
* [Toggle auto-lending](/api-documentation/api/rest-api/account/toggle-auto-lending) \[NEW]
* Enable or disable automatic lending
* [Add isolated margin](/api-documentation/api/rest-api/account/add-isolated-margin) \[NEW]
* Add USDC margin to an isolated position
* [Get fee levels](/api-documentation/api/rest-api/markets/get-fee-levels) \[NEW]
* Retrieve all fee tier levels with maker/taker rates
* [Get loan pool](/api-documentation/api/rest-api/markets/get-loan-pool) \[NEW]
* Retrieve loan pool state including utilization and borrow/lend rates
* [Get account loan info](/api-documentation/api/rest-api/account/get-account-loan-info) \[NEW]
* Retrieve loan and collateral details under unified margin (borrowed amount, collateral utilization, per-asset LTV)
* [Get account info](/api-documentation/api/rest-api/account/get-account-info) \[UPDATE]
* Added `spot_collateral`, `pending_interest`, `spot_balances`, `cross_account_equity`, and `spot_market_value` fields to support unified margin with spot collateral
* [Get account settings](/api-documentation/api/rest-api/account/get-account-settings) \[UPDATE]
* Documented `auto_lend_disabled` and `spot_settings` with `unified_margin_excluded` per asset
* [Get positions](/api-documentation/api/rest-api/account/get-positions) \[UPDATE]
* Added `liquidation_price` and `amount` fields
* [Get loan pool](/api-documentation/api/rest-api/markets/get-loan-pool) \[UPDATE]
* Added `utilization_max` and `auto_lender_entry_threshold` fields
* [Create stop order](/api-documentation/api/rest-api/orders/create-stop-order) \[FIX]
* Fixed `side` parameter examples to use correct values (`bid`/`ask`)
**WebSocket**
* [Account transfers](/api-documentation/api/websocket/subscriptions/account-transfers) \[NEW]
* Real-time deposit, withdrawal, and transfer event stream
* [Account info](/api-documentation/api/websocket/subscriptions/account-info) \[UPDATE]
* Added `sb` (spot\_balances) field with per-asset collateral details
* [Account order updates](/api-documentation/api/websocket/subscriptions/account-order-updates) \[UPDATE]
* Added `tp` (trigger\_price\_type) field
* Added order types: `stop_limit`, `stop_market`, `take_profit_limit`, `stop_loss_limit`, `take_profit_market`, `stop_loss_market`
### 2026-03-11
* [Account settings](/api-documentation/api/rest-api/account/get-account-settings) REST API to include `margin_settings`, `spot_settings` and `auto_lend_disabled`, in order to support spot assets and unified margin \[UPDATE]
### 2026-02-19
* VIP Tier rate-limits increased \[UPDATE]
### 2026-02-05
* Remove `account_orders` websocket endpoint. Note that open orders snapshot can be obtained from REST API `/api/v1/orders` and real time order updates can be obtained from websocket `account_order_updates` \[UPDATE]
* Enforce main+subaccount rate limit [based on fee tier](/api-documentation/api/rate-limits#credit-quotas) for requests with API Config Keys \[NEW]
### 2026-01-24
* Update `agg_level` to `1, 10, 100, 1000, 10000` for `api/v1/book` and websocket `book` \[UPDATE]
### 2026-01-20
* Add `maker_fee` and `taker_fee` to /api/v1/account endpoint \[UPDATE]
### 2026-01-12
* Add `li` (Last ID) to `bbo` websocket stream \[UPDATE]
### 2026-01-01
* Add `li` (Last ID) to `orderbook` websocket stream \[UPDATE]
### 2025-12-16
**WebSocket**
* Initialization added to `account_orders` endpoint \[UPDATE]
* `account_orders` endpoint now sends snapshot of account's open orders upon subscription.
### 2025-12-06
**REST API & WS**
* Last ID added \[NEW]
* Added field in multiple REST and WS endpoints as an exchange-wide identifier to order all exchange events
### 2025-11-19
**REST API**
* Market info endpoint updated \[UPDATE]
* Added `created_at` field to /api/v1/info response showing when each market was listed
**WEBSOCKET**
* Account positions snapshot \[UPDATE]
* account\_positions websocket endpoint now returns immediate snapshot of current positions upon subscription
* Batch orders \[NEW]
* Order batching now supported via websocket
* Best bid offer (BBO) \[NEW]
* bbo endpoint now supported via websocket
* constantly streams top of book for selected symbol
**REST API & WS**
* Edit order type added \[NEW]
* Added endpoint in REST and WS to edit price and/or size of existing orders
* Mark price candle added \[NEW]
* Added endpoint in REST and WS to show mark price candles
* Returns candle data based on mark price instead of traded prices
* Batch order speed bump optimization \[UPDATE]
* Speed bump now applied conditionally based on order types in batch
* Only applied if batch contains market orders or limit orders with TIF GTC/IOC
* Speed bump not applied if batch only contains ALO/TOB orders, cancellations, or TP/SL updates
### 2025-11-12
**GENERAL API**
* Taker latency increased. \[UPDATE]
* All market orders, TIF GTC, and TIF IOC orders are subject to a \~200ms delay
### 2025-11-10
**REST API & WS**
* [Top-of-Book (TOB)](/trading-on-pacifica/order-types) TIF order type added \[NEW]
* Useable in:
* Frontend GUI under Limit, TIF, TOB (Post Only)
* [Create limit order REST API](/api-documentation/api/rest-api/orders/create-limit-order) endpoint
* [Batch order REST API](/api-documentation/api/rest-api/orders/batch-order) endpoint
* [Create limit order websocket](/api-documentation/api/websocket/trading-operations/create-limit-order) endpoint
### 2025-11-09
**GENERAL API**
* Taker latency added. \[NEW]
* All market orders, TIF GTC, and TIF IOC orders are subject to a randomized 50-100ms delay
### 2025-10-30
**REST API**
* Cursor based pagination added for all history endpoints \[UPDATE]
* Offset pagination deprecated
### 2025-10-25
**REST API**
* [List subaccounts](/api-documentation/api/rest-api/subaccounts/list-subaccounts) \[NEW]
* Added a new endpoint to retrieve subaccount information
**WEBSOCKET**
* [Orderbook websocket](/api-documentation/api/websocket/subscriptions/orderbook) \[UPDATE]
* 'book' websocket update interval improved from 500ms to 100ms
# Audits
Source: https://docs.pacifica.fi/other/audits
[BlockSec audit report (PDF)](https://raw.githubusercontent.com/blocksecteam/audit-reports/main/rust/blocksec_pacifica_fi_perp_contracts_signed_20250424.pdf)
# Brand Assets
Source: https://docs.pacifica.fi/other/brand-assets
This section provides guidelines for using Pacifica's brand assets to ensure a consistent and professional presentation across all channels. Whether you are a partner, media outlet, or community member, please follow these guidelines when using our logos, colors, and other visual elements.
*Download high-resolution logos and vector files from our:* [*Brand Assets Repository.*](https://drive.google.com/drive/folders/1cpktvx3Ir4OZVjEiyqY3VcY3Y87_PTnb?usp=sharing)
# Contact Us
Source: https://docs.pacifica.fi/other/contact-us
We're here to help. Whether you have a question about trading, need technical support, or want to share your feedback, feel free to reach out to us through any of the channels below.
#### Community
Join our active community on Discord or Telegram to connect with fellow traders, ask questions, and stay updated on the latest news.
* [Discord](https://discord.gg/dxddmceu4C)
* [Telegram](https://t.me/PacificaTGPortalBot)
* Email: [ops@pacifica.fi](mailto:ops@pacifica.fi)
#### Socials
Follow us for the latest updates, announcements, and market insights.
* [X](https://x.com/pacifica_fi)
***
*We value your input and are committed to ensuring a smooth, secure, and transparent trading experience on Pacifica. Your questions and feedback help us improve!*
# Glossary of Terms
Source: https://docs.pacifica.fi/other/glossary-of-terms
**Auto-Deleveraging (ADL):** A last-resort mechanism that automatically reduces the profitable positions of opposing traders to help cover losses in extreme market conditions.
**Backstop Liquidation:** A process where, if orderbook liquidity is insufficient to liquidate a position via market orders, the position (and remaining collateral) is transferred to a dedicated vault that systematically closes it.\
\
**Candle:** A visual summary of the stock's price action within a period of time, displaying the opening, closing, high, and low prices. Pacifica's candlestick charts are powered by [TradingView](https://www.tradingview.com/symbols/BTCUSD/).
**Collateral:** Funds deposited into your account to secure open positions.
**Cross Margin:** A margin mode that uses your entire account balance to support all open positions, improving capital efficiency.
**Funding Rate:** A periodic fee, updated every hour, exchanged between long and short positions to keep the perpetual contract price aligned with the underlying spot market.
**Impact Price:** The average execution price calculated for a predefined notional amount from the orderbook, used to determine the Premium Index.
**Initial Margin:** The required collateral to open a position, calculated as the position size multiplied by the entry price, divided by the leverage.
**Isolated Margin:** A margin mode where each position is allocated its own specific collateral, limiting risk to that individual position.
**Liquidation:** The forced closure of a position when its margin falls below the required maintenance level.
**Maintenance Margin:** The minimum collateral that must be maintained to keep a position open, typically set at half of the initial margin.
**Maker Order:** An order that adds liquidity to the order book, such as a resting limit order.
**Oracle Price (Mark Price):** An aggregated price calculated from multiple external sources (weighted median from major centralized exchanges or TWAP from decentralized exchanges) used to determine margin requirements, funding fees, and liquidation thresholds.
**Premium Index:** A measure of the deviation between the Impact Price and the Oracle Price, used in funding rate calculations.
**Taker Order:** An order that removes liquidity by executing against existing orders in the order book.
**Time-In-Force (TIF):** The instruction that determines how long an order remains active (e.g., Good-Til-Cancelled, Immediate-or-Cancel, Add-Limit-Only).
**TWAP (Time-Weighted Average Price):** A method to calculate an average price over a specific period to mitigate the impact of market volatility on execution.
**Withdrawal Controls:** Mechanisms that restrict collateral withdrawals during periods of extreme volatility to ensure open positions remain adequately funded.
# Close Beta Guide
Source: https://docs.pacifica.fi/pacifica/close-beta-guide
[https://www.canva.com/design/DAGp110OV-w/sL4OUVxdMA\_5iul99P2c-A/edit](https://www.canva.com/design/DAGp110OV-w/sL4OUVxdMA_5iul99P2c-A/edit)
# About Us
Source: https://docs.pacifica.fi/pacifica/readme
Pacifica is democratizing trading intelligence.
Crypto has revolutionized access to financial markets through open, permissionless infrastructure. Yet the tools and expertise needed to navigate increasingly complex markets remain concentrated in the hands of a select few. We believe the next breakthrough in onchain finance will be defined not by just providing access to markets, but through sharing the capabilities to thrive in them.
Pacifica was founded on this belief. We launched in June 2025 as a high-performance decentralized trading platform, combining institutional-grade execution with self-custody and permissionless access. What began as a perpetuals platform quickly grew into a broader trading ecosystem spanning crypto, real-world assets, and pre-IPO markets.
Market access was our foundation. Empowering traders is our next leap forward. We envision a future where traders focus on ideas, creativity, and strategy while intelligence-powered systems simplify the complexities of research, analysis, and execution. Neptune, our proprietary agentic harness, brings this vision to life by transforming trading ideas into executable strategies and automating sophisticated workflows.
The same philosophy shapes our broader ecosystem. Through simplified exotic instruments (Print), intuitive trading experiences (Swim), and community-driven opportunities (Vaults), we are expanding how people participate in markets. We believe the future of trading lies in making even the most sophisticated financial products easier for all to understand and participate in.
Bringing this vision to life requires expertise across both finance and technology. Our team draws on experience in traditional finance, crypto, high-frequency trading, and AI, with backgrounds spanning Binance, FTX, Coinbase, Jane Street, OpenAI, DeepMind, and MIT. Entirely self-funded since inception, Pacifica retains the independence to pursue this vision for the long term.
Our ambition is to make intelligent trading the new standard, fundamentally redefining how the world trades.
# Testnet Guide
Source: https://docs.pacifica.fi/pacifica/testnet-guide
[https://www.canva.com/design/DAGi6sRFjjo/7Vu9daOHcwah6M0A\_dwJLQ/edit?utm\_content=DAGi6sRFjjo\&utm\_campaign=designshare\&utm\_medium=link2\&utm\_source=sharebutton](https://www.canva.com/design/DAGi6sRFjjo/7Vu9daOHcwah6M0A_dwJLQ/edit?utm_content=DAGi6sRFjjo\&utm_campaign=designshare\&utm_medium=link2\&utm_source=sharebutton)
# Print
Source: https://docs.pacifica.fi/print
Print lets you earn yield while your orders wait to be filled. Instead of a limit order that sits idle until the market reaches it, a Print order pays you for every cycle it waits — and still opens your position at the exact price you chose.
### How Print Works
You set a **target price** and a **direction**:
* **Print Long** — target price *below* the current market ("if BTC drops to X, I'll buy").
* **Print Short** — target price *above* the current market ("if BTC rises to X, I'll sell").
You lock a deposit, pick your leverage, and choose how long each cycle runs — **24 hours** on any market, or **7 days** or **30 days** on BTC. From there you earn a payout every cycle while you wait. Your order isn't filled the moment the market touches your target — it's checked once at the end of each cycle: if the market has reached your target by then, it fills at your target price; if not, it rolls into the next cycle and keeps earning.

Print is available on **BTC, ETH, SOL, HYPE, ZEC, XRP, LIT, NEAR, ENA, and SKHYNIX**. Every listed Print market offers a 24-hour cycle; BTC also offers 7-day and 30-day cycles. See [Specifications](/print/specifications) for current leverage and deposit limits.
### Print vs. Limit Orders
Like a limit order, you pick a side, a target price, and a leverage. What's different is everything about *waiting* and *filling*:
| | Limit order | Print order |
| - | - | - |
| Earn while waiting | No | Yes — a payout every cycle |
| When it can fill | The instant the market touches your price, any time | Only at the **end of each cycle** |
| Fill price | Your limit price | Your target price |
| If the price never reaches it | Rests unchanged until you cancel | Auto-rolls to a new target at the same % distance, and keeps earning |
| Capital while waiting | Reserved, earns nothing | Locked as margin, and earns yield every cycle |
| Cancelling | Removed immediately | Resolves at the end of the current cycle |
The most important difference: a limit order fills the moment price touches it. **A Print order only checks at the end of each cycle.** If the market dips to your target intraday and bounces back, a limit order would have filled — a Print order does not. It only fills if the market has reached or passed your target *at the checkpoint*.
### In This Section
* [Placing & Managing Orders](/print/placing-and-managing-orders) — the inputs you set, and how to cancel or withdraw.
* [The Print Cycle](/print/the-print-cycle) — how fills and roll-overs work, and what cycle length changes.
* [Yield](/print/yield) — how your payout is calculated and what drives it.
* [Margin & Liquidation](/print/margin-and-liquidation) — leverage, liquidation price, and your maximum loss.
* [Examples](/print/examples) — worked scenarios with real numbers.
* [Specifications](/print/specifications) — markets, limits, and parameters at a glance.
* [FAQ](/print/faq) — common questions.
# Examples
Source: https://docs.pacifica.fi/print/examples
**Example 1 — A Print Long that rolls over, then fills.**
BTC is at 70,000. You place a Print Long on the **24-hour cycle** with a **\$100 deposit**, **10× leverage**, and a **target of 69,000** (about 1.43% below market). If it fills, your position size is about **0.0145 BTC** — a \$1,000 notional (`100 × 10 ÷ 69,000`).
* **Day 1.** The order goes live and you're paid the block's yield (the exact amount depends on market conditions). Over the next 24 hours BTC dips to 69,200 intraday but never trades at or below 69,000 *at the checkpoint*. At the 24-hour mark BTC is 70,500 → **no fill**. The order rolls over to a new target the same \~1.43% below 70,500 ≈ **69,500**. The yield you earned stays in the account, and the order runs into the next block.
* **Day 2.** BTC drifts down. At the next 24-hour mark it's 69,300 — at or below your 69,500 target → **fill**. You open a \~0.0144 BTC long at exactly **69,500**, funded by your deposit plus every payout you accrued. From here it's an ordinary 10× long.
The intraday dip on Day 1 didn't fill you, you kept all the yield, and you entered at your target price rather than a random intraday level.
**Example 2 — A Print Short.**
BTC is at 70,000. You place a Print Short on the **24-hour cycle** with a **\$200 deposit**, **5× leverage**, and a **target of 71,500** (about 2.1% above market). Position size if filled: about **0.014 BTC** (`200 × 5 ÷ 71,500`). Each 24-hour block pays you a yield. If BTC is at or above 71,500 at a checkpoint, you open a short at 71,500; otherwise the target rolls to the same \~2.1% above the new market price and you keep earning.
**Example 3 — Leverage changes both your yield and your liquidation price.**
Same Print Long (target 69,000, \$100 deposit), before any yield has accrued:
| Leverage | Position size | Notional | Liquidation price |
| - | - | - | - |
| 2× | 0.0029 BTC | \$200 | \~34,500 |
| 10× | 0.0145 BTC | \$1,000 | \~62,100 |
| 20× | 0.0290 BTC | \$2,000 | \~65,550 |
| 40× | 0.0580 BTC | \$4,000 | \~67,275 |
Higher leverage pays more yield, but the liquidation price climbs toward your 69,000 target — at 20× the market only has to fall about 5% below your target to wipe the position, and at 40× (BTC's maximum) about 2.5%. (Earned yield adds to your margin, so each cycle nudges the liquidation price a little further away.)
**Example 4 — The same conviction, on three different cycles.**
BTC is at 70,000 and you want to buy 3% lower, at 67,900. On BTC you can express that on any of the three cycles, and they behave quite differently:
| Cycle | Checked for a fill | Payout | What you're really saying |
| - | - | - | - |
| 24 hours | Every day | Small, paid daily | "I think BTC touches 67,900 by tomorrow" |
| 7 days | Once a week | Much larger, paid weekly | "I think BTC touches 67,900 some time this week" |
| 30 days | Once a month | Largest, paid monthly | "I think BTC touches 67,900 some time this month" |
A 3% move is unremarkable over a month and a real event over a day, so the monthly cycle pays far more for the same target — it's a much likelier fill. The trade-off is time: the 30-day order is only checked at the end of the month, your deposit stays locked until then even if you cancel, and the price can swing well past 67,900 and back without filling you.
That's also why the wider target ranges only open up on the longer cycles: a 40% target is meaningless over 24 hours, but a real proposition over 30 days.
# FAQ
Source: https://docs.pacifica.fi/print/faq
> [accordion] Which markets can I use Print on?
>
> **BTC, ETH, SOL, HYPE, ZEC, XRP, LIT, NEAR, ENA, and SKHYNIX.** All ten markets offer 24-hour cycles; BTC also offers 7-day and 30-day cycles. See [Specifications](/print/specifications) for leverage and deposit limits.
> [accordion] How long does a Print order run for?
>
> You choose. Every market offers a **24-hour** cycle, and BTC also offers **7-day** and **30-day** cycles. The cycle length is fixed for the life of the order: it sets how often the order is checked for a fill, how much each payout covers, and how far from the market you're allowed to set your target (10% at 24 hours, 20% at 7 days, 40% at 30 days). See [The Print Cycle](/print/the-print-cycle).
> [accordion] Does my order fill the moment the price hits my target?
>
> No. A Print order is only checked at the **end of each cycle**. If the price touches your target in between but isn't past it at the checkpoint, you don't fill — the order rolls over. This is the biggest difference from a normal limit order, which fills the instant the market touches it, and it gets more pronounced the longer the cycle you pick.
> [accordion] What price do I fill at if the market runs past my target?
>
> Always your **target price**, not the market price at the checkpoint. If BTC is below your long target at the checkpoint, you still open at the target price.
> [accordion] Do I keep the yield if my order fills, or if I cancel?
>
> Yes to both. Yield is paid each cycle and is already yours: it funds your position when the order fills, or it comes back with your deposit when you cancel. The only way to lose accrued yield is liquidation.
> [accordion] Can I lose more than my deposit?
>
> No. The most you can lose is your deposit plus the yield it has earned — everything in the Print account, and nothing beyond it.
> [accordion] Why did my APY change after I placed the order?
>
> The rate is recalculated every cycle from current market conditions — how far your target sits from the market and how much the market is moving. Every roll-over re-prices at the new market, so your APY moves over time.
> [accordion] Can I change my target price, leverage, or cycle length after placing an order?
>
> There's no in-place edit. Cancel the order — it resolves at the end of the current cycle — and place a new one with the settings you want.
> [accordion] What happens to my position after it fills?
>
> It becomes an ordinary leveraged position opened at your target price. From then on it follows normal perp rules: you can close it, add margin, or be liquidated like any other position.
> [accordion] Why does my filled position show a higher leverage than my Print order?
>
> Your Print leverage sets your position's **size and margin**. After a fill, the leverage shown in your perps account reflects your **account's leverage setting for that market**. That display does not change the size, entry price, or margin of the position opened by Print.
> [accordion] Can I be liquidated while my order is still waiting to fill?
>
> Liquidation is only evaluated at a checkpoint. If, at that point, the market has run past your liquidation price (which sits beyond your target), the order is liquidated and the margin is lost. Moves that spike and recover before the checkpoint don't liquidate you. On a 7-day or 30-day cycle that check happens only at the end of the week or month, so it's the level at the checkpoint that decides — not where the market travelled in between.
> [accordion] When can I get my money back?
>
> A Print order — and a cancellation — always resolves at the end of the current cycle, not instantly. On a 24-hour order that's at most a day away; on a 30-day order it can be nearly a month. Once it resolves, your funds return to your main trading balance and you can withdraw them.
> [accordion] Is my deposit separate from my trading balance?
>
> Yes. Placing a Print order moves the deposit into that order as locked margin, and each order is its own bucket. It returns to your main balance when the order resolves.
# Margin & Liquidation
Source: https://docs.pacifica.fi/print/margin-and-liquidation
Once a Print order fills, it becomes a normal leveraged position and can be liquidated — so leverage cuts both ways. Concepts like size, margin, and liquidation price work the same as regular perp trading.
The most you can lose is everything in the Print account — **your deposit plus the yield it has earned. You can never lose more than that.**
```
max loss = deposit + yield earned
position size = deposit × leverage / target price
Long liquidation price = target − (deposit + yield) × target / (leverage × deposit)
Short liquidation price = target + (deposit + yield) × target / (leverage × deposit)
```
In practice the liquidation price sits roughly `target ÷ leverage` away from your target, on the losing side. **Higher leverage moves the liquidation price closer to your target — more yield, but more risk.**
Two things that differ from a normal position:
* **Liquidation is only checked at the cycle's checkpoint, not continuously.** If the mark price is beyond your liquidation price at the end of a block, the order is liquidated and the margin is lost. Moves that recover before the checkpoint do not liquidate you — but note that on a 7-day or 30-day cycle, the check that matters is the one at the end of the week or the month, so a large move that has not recovered by then is what settles your order.
* **No maintenance margin while resting.** Before a Print order fills, there's nothing to top up — the deposit is the whole risk.
# Placing & Managing Orders
Source: https://docs.pacifica.fi/print/placing-and-managing-orders
### Placing an Order
You choose:
* **Market** — BTC, ETH, SOL, HYPE, ZEC, XRP, LIT, NEAR, ENA, or SKHYNIX. Each market has its own maximum leverage and each cycle length has its own limit on total open Print deposits (see [Specifications](/print/specifications)).
* **Cycle length** — **24 hours** on any market. BTC also offers **7 days** and **30 days**. This sets how often your order is checked for a fill and how much each payout covers.
* **Direction** — Long or Short.
* **Target price** — at least **0.5%** away from the current mark price, and at most **10%** on a 24-hour cycle, **20%** on 7 days, or **40%** on 30 days.
* **Leverage** — **1×** up to the market's maximum: **40×** on BTC, **25×** on ETH, **20×** on SOL, HYPE, and XRP, and **10×** on ZEC, LIT, NEAR, ENA, and SKHYNIX.
* **Deposit** — your locked margin, minimum **\$10**. This is drawn from your Pacifica trading balance.
Your order's notional is set by your deposit and leverage:
```
notional = deposit × leverage
position size = notional / target price
```
There's no in-place edit once an order is live. To change your target, leverage, or cycle length, cancel the order and place a new one.
### Cancelling & Withdrawing
Cancelling a Print order sends an "end" request, but the order **stays active until the end of the current block.** At that checkpoint it resolves one last time: it either fills (if the market reached your target) or returns your deposit to you. Either way, you still earn that block's payout — cancelling never forfeits yield already in progress.
This is worth weighing before you pick a long cycle: a 30-day order cancelled on day two still resolves at that block's checkpoint, four weeks out.
When an order fills, closes, or is cancelled, your funds — the deposit plus earned yield, or the position it opened — return to your main Pacifica trading balance. Each Print order is its own margin bucket, separate from your other balances until it resolves.
# Specifications
Source: https://docs.pacifica.fi/print/specifications
| Parameter | Value |
| - | - |
| Markets | BTC, ETH, SOL, HYPE, ZEC, XRP, LIT, NEAR, ENA, SKHYNIX |
| Cycle length | 24 hours on every market; BTC also offers 7-day and 30-day |
| Leverage | 1× up to the market's maximum (see below) |
| Target distance from mark | 0.5% (tightest) out to 10%, 20%, or 40% (widest), depending on cycle length |
| Minimum deposit | \$10 |
| Fill price | Your exact target price |
| Settlement | Evaluated once per cycle, at the checkpoint |
| Yield crediting | At the start of each cycle; added to your locked margin |
| Trading fee on yield | None |
### Markets and cycle lengths
Each market and cycle length has its own leverage and deposit limits:
| Market | Cycle | Max Print leverage | Deposit limit |
| - | - | - | - |
| BTC | 24 hours | 40× | \$250,000 |
| BTC | 7 days | 40× | \$100,000 |
| BTC | 30 days | 40× | \$100,000 |
| ETH | 24 hours | 25× | \$200,000 |
| SOL | 24 hours | 20× | \$200,000 |
| HYPE | 24 hours | 20× | \$300,000 |
| ZEC | 24 hours | 10× | \$200,000 |
| XRP | 24 hours | 20× | \$50,000 |
| LIT | 24 hours | 10× | \$50,000 |
| NEAR | 24 hours | 10× | \$50,000 |
| ENA | 24 hours | 10× | \$50,000 |
| SKHYNIX | 24 hours | 10× | \$200,000 |
On top of the per-product limits, Print as a whole holds at most **\$700,000** of open deposits across every market and cycle length combined. Both limits apply: a product can have room under its own cap while the shared pool is full.
### Target distance by cycle length
Your target must fall within the range for your cycle:
| Cycle | Target distance from mark |
| - | - |
| 24 hours | 0.5% – 10% |
| 7 days | 0.5% – 20% |
| 30 days | 0.5% – 40% |
A few notes:
* **Distance is measured from the mark price** at the moment you place, and again from the new mark price at every roll-over.
* **Maximum leverage is per market.** The Print cap is separate from — and can be lower than — the leverage your account can use for regular perp trading in that market.
* **The deposit limit is a cap on locked deposits**, not on any single order. Once a product sits at its limit — or Print as a whole sits at the \$700,000 pool limit — new orders there are rejected until capacity becomes available.
* **Once filled, a Print position follows standard perp rules** — normal margin, mark-price liquidation, and fees apply to the position from that point on.
# The Print Cycle
Source: https://docs.pacifica.fi/print/the-print-cycle
Print orders run in fixed blocks. You pick the block length when you place the order — **24 hours** on any market, or **7 days** and **30 days** on BTC — and it stays the same for the life of the order.
At the end of every block, exactly one of two things happens\*:
* **Fill** — if the mark price has reached or passed your target, your order fills at the **target price** and you now hold a normal leveraged position.
* **Roll over** — if it hasn't, the order automatically renews for another block of the same length at a **new target the same % distance from the new market price**, and keeps earning.
You earn the **full payout for the block no matter which outcome occurs.**
A limit order fills the instant the market touches it; a Print order is only evaluated at these checkpoints. A move to your target that reverses before the checkpoint does **not** fill your order — and the longer the block you choose, the more of those round trips it can sit through.
### Choosing a cycle length
The cycle length changes three things at once:
* **How often you're checked.** A 24-hour order gets a fill-or-roll decision every day; a 30-day order gets one a month.
* **How big each payout is.** Each payout covers the whole block, so a 30-day block pays far more than a 24-hour one — it's a single payment for a month of waiting, not a daily drip.
* **How far out you can aim.** Longer blocks allow targets further from the market: up to 10% at 24 hours, 20% at 7 days, and 40% at 30 days. See [Specifications](/print/specifications).
A longer cycle also means your funds stay locked longer. Cancelling still only takes effect at the next checkpoint, so a 30-day order cancelled on day two resolves at the end of that 30-day block, not immediately.
### Roll-over Example
You open a 24-hour Print Long when BTC is at 70,000 with a target of 69,000 (about 1.43% below). After 24 hours BTC is at 70,500 and your order hasn't filled, so it rolls over. The new target is set to the same \~1.43% distance from 70,500 — roughly **69,500**. The yield you earned stays in the account and carries into the next block.
A 7-day or 30-day order behaves identically; the checkpoint just arrives a week or a month later.\
\
*\*If the order is not liquidated or cancelled.*
# Yield
Source: https://docs.pacifica.fi/print/yield
Your payout is paid at the start of each cycle by the Print liquidity pool and credited straight to your order, where it stays as part of your locked margin rather than being paid out. It is shown as an annualized **APY**.
Each cycle's payout is sized from your **original deposit** and current market conditions — it isn't calculated on the yield you've already banked, so payouts don't snowball. What the banked yield *does* do is add to your margin, which nudges your liquidation price a little further from your target each cycle.
Four things push each payout up:
* **Conviction (target distance).** The closer your target is to the current market price, the higher the yield — you're more likely to fill, so the pool pays you more to wait.
* **Leverage.** More leverage means a larger position, which means a larger payout.
* **Market volatility.** The more the market is moving, the larger the payout.
* **Cycle length.** Each payout covers a whole cycle, so a 7-day or 30-day block pays much more per payout than a 24-hour one — it just arrives once a week or once a month instead of daily.
Because the first three are read fresh at every roll-over, the same order can pay very different amounts from one cycle to the next.
No trading fee is taken out of your yield.
Your APY isn't fixed. It's recalculated every cycle from current market conditions, and every roll-over re-prices at the new market — so expect it to move over time.
# Bug Bounty Program
Source: https://docs.pacifica.fi/programs/bug-bounty-program
Pacifica is committed to maintaining the highest standards of security. We invite security researchers to identify and disclose vulnerabilities in a constructive and responsible manner and help us protect our users, infrastructure, and ecosystem.
## Pacifica Bug Bounty Program Rules
1. Please submit a clear and detailed report with reproducible steps via email to [ops@pacifica.fi](mailto:ops@pacifica.fi) or open a ticket on Pacifica's [Discord](https://discord.gg/pacifica).
2. If we cannot reproduce the issue from your submission, it will not qualify for a reward.
3. Social engineering attacks (e.g., phishing) against Pacifica employees or community members are strictly prohibited.
4. Please make a good faith effort to avoid privacy violations, data loss, service degradation, or interruptions.
5. Actions that negatively impact the availability of Pacifica services (e.g., DoS/DDoS) are not allowed.
6. The bug bounty does not pay-out any attacks that directly disrupt services.
**Testnet Guidelines**
* If you wish to test asset-related features, please do so on the Pacifica testnet at [https://test-app.pacifica.fi/trade/BTC](https://test-app.pacifica.fi/trade/BTC)
* For testnet only vulnerabilities not reproducible on mainnet, bounty level will be lowered
* Not all testnet features are eligible for the program (newly deployed features known by the team to be unstable, for example)
* Reach out to the team at [ops@pacifica.fi](mailto:ops@pacifica.fi) or on [Discord](https://discord.gg/pacifica) for more on using the Pacifica testnet
***
### Bug Bounty Vulnerability Levels
| Level | Bounty |
| :-: | :-: |
| Critical | 10,000-25,000 USDC |
| High | 2,500-10,000 USDC |
| Medium | 500-2,500 USDC |
| Low | 500 USDC |
**How are the various levels of bugs/vulnerabilities defined?**
To ensure consistent triage and fair rewards, vulnerabilities are classified into **Critical, High, Medium, and Low** categories. The following descriptions serve as a guide, and are not exhaustive:
#### Critical Vulnerabilities
Critical issues directly compromise Pacifica's **core systems, infrastructure, or smart contracts** in ways that could result in the safety of user deposits or core systems on Pacifica being compromised.
#### High-Risk Vulnerabilities
High-risk issues compromise system integrity, sensitive data, or critical business logic, but with limited impact relative to Critical Vulnerabilities.
#### Medium-Risk Vulnerabilities
Medium-risk issues impact user accounts, degrade service, or allow targeted exploitation, but do not put the entire system or core contracts at risk.
#### Low-Risk Vulnerabilities
Low-risk issues generally require user interaction, have limited impact, or only reveal non-critical information.
***
### Submission Process
* Consolidate your findings neatly in writing that includes the following:
* A clear description of the bug/issue.
* Step-by-step instructions on reproducing the issue on our end.
* Proof-of-concept (PoC) or exploit script (if applicable).
* Send reports to: [ops@pacifica.fi](mailto:ops@pacifica.fi) (flag any such reports as \[important] or \[urgent]).
* Alternatively, reach out to the team on [Discord](http://discord.gg/pacifica) by opening a ticket.
* Include impact assessment and suggested remediation steps
* Provide screenshots, videos, or other evidence to support your findings if applicable
**Important Guidelines:**
* If the same vulnerability is reported by multiple researchers, the first complete submission will be rewarded
* Submit one vulnerability per report, unless chaining vulnerabilities is necessary to demonstrate real impact.
* Multiple vulnerabilities that stem from a single root cause will be treated as one bounty.
* Rewards are paid in USDC to the submitter's Pacifica account for responsible disclosure of bugs after assessment by the Pacifica team.
* All research must be conducted ethically and responsibly in accordance with the rules of the Pacifica bug bounty program.
***
### Prohibited Activity
**The following activities are strictly prohibited, and will result in a report becoming ineligible for the bug bounty and/or further investigation and legal action.**
* Direct testing on the Pacifica mainnet in a manner that results in/may result in service disruption or data loss. All attempts must be done on Pacifica Testnet.
* Any phishing, social engineering, or physical security attacks.
* Denial-of-Service (DoS) or large-scale DDoS attacks.
* Testing third-party apps (SSO providers, wallets, browser extensions) outside Pacifica's control.
* Violating user privacy or accessing accounts belonging to others without consent.
* Public disclosure of vulnerabilities prior to their resolution without consent or authorization.
* Threats, ransom demands, or publishing sensitive data without consent.
* Exploiting vulnerabilities for personal financial gain beyond bug bounty rewards.
***
### Eligibility
* Reports must be submitted to the Pacifica team directly via email or Discord. Others are not accepted.
* You must comply with KYC verification to be eligible for any bug bounty rewards and to be able to receive USDC payouts on Pacifica.
* You must maintain strict confidentiality about discovered vulnerabilities until authorized disclosure.
#### The Following Are NOT Eligible for the Bug Bounty Program
* UI/UX bugs without security implications.
* Reports without sufficient detail, reproducible steps, or PoC.
* Vulnerabilities requiring highly improbable user actions, unrealistic market conditions or social engineering.
* Issues in outdated browsers, plugins, or operating systems not supported by Pacifica.
* Vulnerabilities requiring physical access to user devices.
* Bugs in third-party libraries or services that don't create direct risk to Pacifica users.
* Non-security related bugs such as cosmetic issues or minor functional problems.
* Theoretical vulnerabilities without demonstrable security impact.
***
All submissions must meet program requirements to be eligible for rewards. Pacifica reserves full discretion in classifying reported issues and determining payout amounts. By submitting a report, you acknowledge that it becomes the property of Pacifica, and we may use, modify, or disclose the information as necessary to improve the security of our platform.
In return, Pacifica is committed to treating researchers with respect and fairness. We will investigate all valid reports promptly, provide clear reasoning behind our classifications, and reward based on the severity of the issue. Most importantly, we will pursue legal action against those who do not conduct research in good faith.
# Builder Program
Source: https://docs.pacifica.fi/programs/builder-program
Pacifica's builder program allows third-party developers ("builders") to earn fees for orders they send on behalf of the users. These must be **approved by the user** before they can be used on any order. Once approved, the builder may include the code in any supported order creation request. Users can revoke access at any time.
Builder codes affect only Pacifica's order fee logic and are fully verified by the API according to user approval, fee limits, and builder configuration.
### Step 1: Request User Authorization
Request the user to authorize placing orders with your builder code by prompting them to sign an approval request containing your builder code as `builder_code` and the additional fee rate you want to charge as `max_fee_rate`.
**Important:** The user's `max_fee_rate` must be greater than or equal to your builder's `fee_rate`. If they set a lower value, orders will be rejected.
**Data to be Signed**
To approve a builder code, the user signs:
```json theme={null}
{
"timestamp": ,
"expiry_window": 5000,
"type": "approve_builder_code",
"data": {
"builder_code": "YOUR_CODE",
"max_fee_rate": "0.001"
}
}
```
After following the [signing implementation](/api-documentation/api/signing/implementation), compact and sort this payload recursively to generate the signature.
**Complete Payload (After Signing)**
```
{
"account": "6ETn....",
"agent_wallet": null,
"signature": "5j1Vy9UqYUF2jKD9r2Lv5AoMWHJuW5a1mqVzEhC9SJL5GqbPkGEQKpW3UZmKXr4UWrHMJ5xHQFMJkZWE8J5VyA",
"timestamp": 1748970123456,
"expiry_window": 5000,
"builder_code": "YOUR_CODE",
"max_fee_rate": "0.001"
}
```
**Endpoint:** `POST https://api.pacifica.fi/api/v1/account/builder_codes/approve`
**Check User Approvals (Optional)**
You can query which builder codes a user has approved:
**Endpoint:** `GET https://api.pacifica.fi/api/v1/account/builder_codes/approvals?account=6ETn....`
**Response:**
```
[
{
"builder_code": "YOUR_CODE",
"description": "Test Builder Integration",
"max_fee_rate": "0.001",
"updated_at": 1748970123456
}
]
```
**Revoke Builder Code Authorization (Optional)**
Users can revoke authorization at any time:
**Data to be Signed**
```
{
"timestamp": 1748970123456,
"expiry_window": 5000,
"type": "revoke_builder_code",
"data": {
"builder_code": "YOUR_CODE"
}
}
```
**Complete Payload (After Signing)**
```
{
"account": "6ETnufiec2CxVWTS4u5Wiq33Zh5Y3Qm6Pkdpi375fuxP",
"agent_wallet": null,
"signature": "5j1Vy9UqYUF2jKD9r2Lv5AoMWHJuW5a1mqVzEhC9SJL5GqbPkGEQKpW3UZmKXr4UWrHMJ5xHQFMJkZWE8J5VyA",
"timestamp": 1748970123456,
"expiry_window": 5000,
"builder_code": "YOUR_CODE"
}
```
**Endpoint:** `POST https://api.pacifica.fi/api/v1/account/builder_codes/revoke`\
### **Step 2: Include Builder Code in Order Creation Requests**
All order creation requests may now include your builder code in the `builder_code` parameter. Update the following endpoints:
**REST API:**
* `POST /api/v1/orders/create_market`
* `POST /api/v1/orders/create`
* `POST /api/v1/orders/stop/create`
* `POST /api/v1/positions/tpsl`
**WebSocket:**
* `create_market_order`
* `create_limit_order`
* `create_stop_order`
* `set_position_tpsl`
**Example: Create Market Order with Builder Code**
**Data to be Signed**
```
{
"timestamp": 1716200000000,
"expiry_window": 30000,
"type": "create_market_order",
"data": {
"symbol": "BTC",
"amount": "0.1",
"side": "bid",
"slippage_percent": "0.5",
"reduce_only": false,
"client_order_id": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
"builder_code": "YOUR_CODE"
}
}
```
**Complete Payload (After Signing)**
```
{
"account": "6ETnufiec2CxVWTS4u5Wiq33Zh5Y3Qm6Pkdpi375fuxP",
"agent_wallet": null,
"signature": "5j1Vy9UqYUF2jKD9r2Lv5AoMWHJuW5a1mqVzEhC9SJL5GqbPkGEQKpW3UZmKXr4UWrHMJ5xHQFMJkZWE8J5VyA",
"timestamp": 1716200000000,
"expiry_window": 30000,
"symbol": "BTC",
"amount": "0.1",
"side": "bid",
"slippage_percent": "0.5",
"reduce_only": false,
"client_order_id": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
"builder_code": "YOUR_CODE"
}
```
**Endpoint:** `POST https://api.pacifica.fi/api/v1/orders/create_market`
**Example: Create Limit Order with Builder Code**
**Data to be Signed**
```
{
"timestamp": 1716200000000,
"expiry_window": 30000,
"type": "create_order",
"data": {
"symbol": "BTC",
"amount": "0.1",
"side": "bid",
"tick_level": 1000,
"tif": "gtc",
"reduce_only": false,
"client_order_id": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
"builder_code": "YOUR_CODE"
}
}
```
**Endpoint:** `POST https://api.pacifica.fi/api/v1/orders/create`
**Example: Set Position TP/SL with Builder Code**
**Data to be Signed**
```
{
"timestamp": 1716200000000,
"expiry_window": 30000,
"type": "set_position_tpsl",
"data": {
"symbol": "BTC",
"side": "bid",
"take_profit": {
"stop_price": "55000",
"limit_price": "54950",
"client_order_id": "e36ac10b-58cc-4372-a567-0e02b2c3d479"
},
"stop_loss": {
"stop_price": "48000",
"limit_price": "47950",
"client_order_id": "d25ac10b-58cc-4372-a567-0e02b2c3d479"
},
"builder_code": "YOUR_CODE"
}
}
```
**Complete Payload (After Signing)**
```
{
"account": "6ETnufiec2CxVWTS4u5Wiq33Zh5Y3Qm6Pkdpi375fuxP",
"agent_wallet": null,
"signature": "5j1Vy9UqYUF2jKD9r2Lv5AoMWHJuW5a1mqVzEhC9SJL5GqbPkGEQKpW3UZmKXr4UWrHMJ5xHQFMJkZWE8J5VyA",
"timestamp": 1716200000000,
"expiry_window": 30000,
"symbol": "BTC",
"side": "bid",
"take_profit": {
"stop_price": "55000",
"limit_price": "54950",
"client_order_id": "e36ac10b-58cc-4372-a567-0e02b2c3d479"
},
"stop_loss": {
"stop_price": "48000",
"limit_price": "47950",
"client_order_id": "d25ac10b-58cc-4372-a567-0e02b2c3d479"
},
"builder_code": "YOUR_CODE"
}
```
**Endpoint:** `POST https://api.pacifica.fi/api/v1/positions/tpsl`
**Note:** `builder_code` is provided only at the top level for TP/SL creation, not within individual `take_profit` or `stop_loss` objects.\
### Print Orders
[Print orders](/print) accept a builder code too, through the `builder_code` field of [Create Print Order](/api-documentation/api/rest-api/print/create-print-order). The code's owner earns **10% of each premium** of the order, paid at the start of every cycle from Pacifica's revenue. The code's builder fee also applies to the perp position that the order delivers, as it does to an order fill. The approval's `max_fee_rate` must cover the code's `fee_rate`, as for an order. A Print order that uses a code from the user's own account or subaccounts is placed without it.
**Endpoint:** `POST https://api.pacifica.fi/api/v1/game/deposit`
### Implementation Notes
* **Signature Generation:** Follow the standard [signing implementation](/api-documentation/api/signing/implementation) for all requests
* **Builder Code Placement:** The `builder_code` must be included in the `data` object when creating the payload to be signed
* **Recursive Sorting:** All JSON keys must be recursively sorted alphabetically before creating the compact JSON string
* **Timestamps:** All times are in milliseconds
* **Expiry Window:** Defaults to 30 seconds (30,000 ms) if not specified
* **Backwards Compatibility:** The `builder_code` field is optional on all order creation endpoints
* **Validation:** Orders with builder codes will be rejected if:
* The builder code doesn't exist
* The user hasn't approved the builder code
* The user's `max_fee_rate` is less than the builder's `fee_rate`
### Update Builder Code Fee Rate
Update the fee rate for your builder code. This endpoint is for builder account owners to change the fee they charge on orders sent with their builder code.\
\
**Request User Authorization (Sign & Send)**\
Builder account owner to sign an update containing the builder code and the new fee rate.\
**Data to be Signed**
```
{
"timestamp": ,
"expiry_window": 5000,
"type": "update_builder_code_fee_rate",
"data": {
"builder_code": "YOUR_CODE",
"fee_rate": "0.05"
}
}
```
**Complete Payload (After Signing)**
```
{
"account": "6ETn....",
"agent_wallet": null,
"signature": "5j1V.....",
"timestamp": 1748970123456,
"expiry_window": 5000,
"builder_code": "YOUR_CODE",
"fee_rate": "0.05"
}
```
**Endpoints:** `POST https://api.pacifica.fi/api/v1/builder/update_fee_rate`
### Referral Code Claim
Users can claim a referral code to establish a referral relationship with the code's owner.
#### How It Works
**Step 1: Request User Authorization**
Request the user to authorize claiming a referral code by prompting them to sign an approval request containing the referral code.
**Data to be Signed**
```
{
"timestamp": ,
"expiry_window": 5000,
"type": "claim_referral_code",
"data": {
"code": "YOUR_CODE"
}
}
```
After following the signing implementation, compact and sort this payload recursively to generate the signature.
**Complete Payload (After Signing)**
```
{
"account": "6ETn....",
"agent_wallet": null,
"signature": "5jHM.....",
"timestamp": 1748970123456,
"expiry_window": 5000,
"code": "YOUR_CODE"
}
```
**Endpoint:** `POST https://api.pacifica.fi/api/v1/referral/user/code/claim`
### **Useful Endpoints**
* User trade history via specific builder code: `https://api.pacifica.fi/api/v1/trades/history?account=[WALLET_ADDRESS]&builder_code=[BUILDER_CODE]`
* Builder Code Specifications: `https://api.pacifica.fi/api/v1/builder/overview?account=[WALLET_ADDRESS]`
* Builder Trade History: `https://api.pacifica.fi/api/v1/builder/trades?builder_code=[BUILDER_CODE]`
* Builder Code User Leaderboard: `https://api.pacifica.fi/api/v1/leaderboard/builder_code?builder_code=[BUILDER_CODE]`
### Error Handling
**Common Error Codes:**
* `403 Unauthorized`: User hasn't approved the builder code or `max_fee_rate` is too low
* `404 Not Found`: Builder code doesn't exist
* `400 Bad Request`: Invalid builder code format (must be alphanumeric, max 16 characters)
### Full Details and Onboarding
For more Pacifica Builder Program specs and details, as well as to onboard to the program, please reach out to us at [ops@pacifica.fi](mailto:ops@pacifica.fi), open a support ticket on our [Discord](http://discord.gg/pacifica) or text @PacificaTGPortalBot on Telegram.
# Educators Program
Source: https://docs.pacifica.fi/programs/educators-program
The **Educators Program** has been **discontinued** until further notice. We will review all submissions up to date and will share more details regarding winning submissions soon.
Thanks to everyone who has participated!\
\
Winning submissions will be announced on our Discord: [discord.gg/pacifica](https://t.co/mJbPQx0UY7)\
# Market Maker Program
Source: https://docs.pacifica.fi/programs/market-maker-program
### Program Overview
The Pacifica Market Making program exists to ensure a healthy marketplace, benefitting traders with tight spreads and deep liquidity.
The program aims to foster a fair and open competitive environment, where Liquidity Providers are able to earn rewards proportional to their relative contributions to these goals.
In order to assist in liquidity provisioning, MM program participants enjoy the following:
* Zero fees on maker fills
* Greatly increased rate-limits
* Increased deposit caps
### Eligibility
All users of Pacifica Exchange are eligible to participate in the Market Making program. Opt-in is required in order to set up reporting channels and apply for zero-maker-fee grace periods while ramping up.
To qualify for rewards beyond the initial program launch assessment period, an eligible Market Maker must meet the minimum requirement of X% of the Total MakerScore for the relevant period\
\
This amount will be determined soon, and is subject to change over time based on liquidity conditions on Pacifica.
### Scoring
Participants in the Pacifica Market Making program are scored and rewarded based on the following criteria. For full details, please reach out to Pacifica Institutional (see below):
* Maker Volume
* Pairs Traded
* Quote spread and depth
* Quote uptime
### Rewards
After the Market Maker's score is calculated for each assessment period, trading rewards for the period can be received in the form of points OR cash, and makers can choose a combination of the two.
The USD pool available to be distributed each period is calculated as:\
12% of total trading fees collected from all market maker counterparties.
The Points pool to be distributed each period is 2,000,000 points (1,000,000/week)
### Additional Specs
* MM accounts earn points as per the regular points program for all non-maker activity
* MM accounts pay regular taker fees based on total trading volume.
* MM accounts and subaccounts are ineligible for participation in exchange-wide trading competitions unless otherwise specified.
* Weekly reports will be sent summarizing maker performance.
* Maker rewards will be sent during points distributions every 14 days.
### Full Details and Application
For full Pacifica Market Making Program specs and details, as well as to apply to be part of the program, please reach out to us at [ops@pacifica.fi](mailto:ops@pacifica.fi) or open a ticket at [discord.gg/pacifica](https://discord.gg/pacifica)
Note: Pacifica monitors all trading activities closely. We do not tolerate market manipulation or abusive trading activities of any kind. If we suspect a participant to be in violation, we reserve the right to modify or deny their rewards entirely. Pacifica reserves the right to modify aspects of the Market Maker Program based on changing market and liquidity conditions.
# Points Program
Source: https://docs.pacifica.fi/programs/points-program
The Pacifica Points program launched on Thursday, September 4th at 00:00 UTC. Each week:
* Snapshots are taken every Thursday at 00:00 UTC
* Distributions occur within 24 hours of each snapshot
* Weekly allocation: 10,000,000 points distributed weekly among eligible Pacifica users
Earn points by engaging in organic trading activities on Pacifica via GUI or API. Self-trading, sybil or any other manipulative activities will not earn points.\

### FAQ
#### What Is the Pacifica Points Formula?
The formula is dynamic and opaque by design, updated weekly as usage evolves.
#### What Activities Earn Points?
Many activities are tracked by our points program, and attribution for different activities may happen immediately or be applied over-time over several distributions.
#### Who Knows the Details of the Points Program?
Very few Pacifica team members. Only Pacifica's community members are eligible to earn points in order to ensure fairness and prevent abuse.
#### Do People With Multiple Accounts Have an Advantage Over Me?
No. Discrete or costless actions do not yield rewards in isolation. Having 100 accounts provides no advantage over one.
#### Do Early Users Have an Advantage?
Pacifica's points program is structured to balance both early supporters and long-term contributors fairly.
#### Can I Buy Points?
No. There was no prior allocation and there is no way to purchase points. They can only be earned by trading, providing feedback, and spreading the word.
#### Can I Trade Points on Secondary Markets?
While Pacifica cannot/will not actively police this, we do not condone any such activity and strongly discourage this for security reasons.
# Referral and Affiliate Program
Source: https://docs.pacifica.fi/programs/referral-and-affiliate-program
### Referrals
Once you have generated \$10,000 in volume, you will be able to generate a referral link on [app.pacifica.fi/referral](https://app.pacifica.fi/referral), and share it with others to use in order to sign into Pacifica as your referee.

Referrers receive 10% of the points generated by their referred users.
* Referees will receive a 5% point bonus
* Fee and point rewards are automatically credited to the referrer account alongside the weekly points distribution, based on the referred users' trading activity.
* There is no application process required. Every user can generate their unique referral link directly from their account dashboard after reaching the \$10,000 volume threshold.
NOTES: Pacifica's referral portal updates once every 15 minutes. If you have recently reached the \$10,000 threshold or have recently referred friends, please wait up to 15 minutes before they appear in your portal.\
\
**How do I use a referral code?**
After creating a new wallet and joining Pacifica, navigate to the top-right corner and open the referral section. There, you'll be prompted to enter a referral code. By using a referral code during signup, your account will be linked as a referee to the user who generated that code.
**How do I create a referral link?**\
\
At the top part of the referral page ([app.pacifica.fi/referral](https://app.pacifica.fi/referral)), you will see the "Generate Referral Link" button. Once you click it, you will be prompted to enter your preferred referral name. Once you have done that, you will be able to copy and paste the link. This will allow people to join Pacifica as your referral by just clicking it.

**How do I use a referral link?**\
\
When joining Pacifica on a fresh wallet, through a referral link you will be prompted to connect your wallet, and then claim the referral code as shown below. Using a referral link to sign up to Pacifica will attach your account as a referee to the generator of the referral link. The referral will directly use up the amount of codes you have available. In order to claim a referral code you must deposit.

### Affiliates
Pacifica Affiliates can earn rewards from both **trading activity** and **Print** activity generated by their referees. The reward structure differs between the two.
#### Trading Fee Share
For eligible trading activity across **perps and spot**, Pacifica Affiliates receive fee share **incentives of up to 40%** from their referees.
The fee share an affiliate earns scales with the total trading volume generated by their referred users, allowing affiliates to unlock higher percentages as they bring more value to the platform.
#### Print
For Print, Pacifica Affiliates receive an additional reward equal to **10% of the realised Print yield earned by their direct referees**.
Unlike trading fee share, the Print affiliate rate is fixed and does not scale with referral volume.
#### Swim
For Swim, Pacifica Affiliates receive an additional reward equal to **10% of the realised Swim wins earned by their direct referees**.
Swim affiliate rate is fixed and does not scale with referral volume.
#### Joining the Pacifica Affiliate Program
Spots in the Pacifica Affiliate program are limited, and participation is a selective process based on the Pacifica team's discretion.
If you believe that you have a large trading community that is interested in trading on Pacifica, please open a ticket at [discord.gg/pacifica](https://discord.gg/pacifica) for additional information.
#### Exceptions to Referrals and Affiliate Rewards
Referee accounts that become part of Pacifica's market maker program will no longer provide cash reward to their referrers.
# VIP Program
Source: https://docs.pacifica.fi/programs/vip-program
Want to carry over your trading tier from other exchanges?
If you've traded on other exchanges, you can verify your past 30 day trading volume and receive the equivalent VIP fee tier on Pacifica for 30 days.
How to get started:
1. Open a support ticket on our [Discord](http://discord.gg/pacifica) or text @PacificaTGPortalBot on Telegram; let us know you want to verify your volume and join the VIP Program.
2. Our team will guide you through a verification process to prove ownership.
3. Once verified, your external trading volume will be mapped to the appropriate Pacifica VIP tier, and your VIP fee tier will be active for the following 30 days.
Notes:
* Each Pacifica account can link only one external wallet for this VIP tier match.
Enjoy your VIP benefits on Pacifica and thank you for trading with us!
# Deposit/Withdrawal
Source: https://docs.pacifica.fi/support/deposit-withdrawal
### Deposits
**Supported asset:**
* Please deposit USDC on **Solana** only
Deposits sent via any other network or token (e.g., Ethereum, Arbitrum, USDT, SOL) will not be credited.
**Minimum deposit:**
* 10 USDC
Deposits below 10 USDC will not be automatically credited. You may send additional USDC to the same address to reach the minimum.
Deposits are usually credited within minutes, but may be delayed due to:
* Solana network congestion
* RPC instability
* Temporary infrastructure load
Always verify the transaction on a Solana block explorer before contacting support.
***
### Withdrawals
Withdrawals are processed via **USDC on Solana** only.
Your Solana wallet must:
* Have a valid USDC token account
If you encounter an error, ensure there is a **non-zero amount of USDC** already in your wallet to initialize the token account, then retry.
Withdrawal delays may occur during periods of Solana network congestion.
***
### Important
We highly recommend depositing and withdrawing directly through the Pacifica front-end to avoid errors.
Before sending funds:
* Double-check the network (Solana)
* Confirm the token is USDC
* Consider sending a small test transaction for large transfers
If issues persist, contact support with your transaction signature (TXID) and relevant details.
# Mobile App Account Deletion
Source: https://docs.pacifica.fi/support/mobile-app-account-deletion
To request deletion of your Pacifica Mobile account, join the [Pacifica Discord](https://discord.com/invite/dxddmceu4C) and open a support ticket.
In your ticket, please include the wallet address associated with your account so the team can identify the correct account. Do not include private keys, seed phrases, passwords, or other sensitive wallet credentials.
After your request is reviewed, Pacifica will delete or de-identify account and personal data that is no longer needed to provide the service. Some records may be retained where required for legal, security, anti-fraud, accounting, compliance, dispute-resolution, or regulatory purposes.
On-chain wallet activity is public blockchain data and cannot be deleted by Pacifica.
For privacy, compliance, or mobile app support questions, open a support ticket in the [Pacifica Discord](https://discord.com/invite/dxddmceu4C).
# Recover Assets After Reown to Privy Migration
Source: https://docs.pacifica.fi/support/recover-assets-after-reown-to-privy-migration
Pacifica has migrated its embedded/social login flow from Reown to Privy.
If you originally used **Reown social login** to access Pacifica, your assets are still controlled by the same on-chain wallet. To regain direct control of that wallet, you need to export the wallet's private key from Reown and import it into a wallet you control.
This guide is only for **legacy Reown social login users**. If you originally connected a self-custody wallet such as Phantom, Solflare, Backpack, or Ledger, you do not need this recovery flow.
> **Important:** Never share your private key with anyone, including Pacifica support. Only export it from Reown's official site, and store it securely offline.
## Official Reown Recovery Page
Use Reown's official secure recovery page: [https://secure.reown.com/](https://secure.reown.com/)
## Video Walkthrough
[https://www.youtube.com/watch?v=sdaX-H1bgv4](https://www.youtube.com/watch?v=sdaX-H1bgv4)
## What This Process Does
The walkthrough shows how to:
1. Sign back into Reown using the same social login you used previously.
2. Export the private key for the wallet created under the old Reown flow.
3. Import that private key into a self-custodial Solana wallet.
4. Use that wallet to access, manage, or withdraw the same assets.
## Step-by-Step Summary
1. Go to Reown's secure recovery page at [https://secure.reown.com/](https://secure.reown.com/) and sign in with the same social account you previously used on Pacifica.
2. Open the wallet management flow and export the wallet's private key.
3. Store the private key securely before leaving the page.
4. Import that private key into a supported self-custodial Solana wallet.
5. Use the imported wallet to access the same on-chain assets and reconnect to Pacifica if needed.
## Need Help?
If you run into issues during this process, contact support and include:
* The social login method you originally used
* Whether you can still access that same social account
* A screenshot of any error or blocked step
# Trade Outcomes
Source: https://docs.pacifica.fi/support/trade-outcomes
Common questions about how positions are closed on Pacifica.
* [Why was I Liquidated?](/support/trade-outcomes/why-was-i-liquidated)
* [My TP/SL did not execute properly](/support/trade-outcomes/my-tp-sl-did-not-execute-properly)
# My TP/SL Did Not Execute Properly
Source: https://docs.pacifica.fi/support/trade-outcomes/my-tp-sl-did-not-execute-properly
There are several common cases of TP/SL execution that may be frequently misunderstood. Expand a question below for details.
> [accordion] My TP/SL didn't close my position at the exact price I set
>
> This is normal behavior. A stop loss works very differently from a limit order.
>
> A limit order executes only at the specified price or better.
>
> A stop order, on the other hand, is triggered when the mark or last traded price reaches the user's specified trigger level (this can be customized on Pacifica).
>
> During periods of volatility, orderbook prices can move past the trigger level before triggering the stop order. This is especially true when mark price is used.
>
> This, along with natural orderbook slippage - which can be higher during periods of volatility - causes discrepancies between TP/SL prices and actual execution.
>
> This is expected behavior across all exchanges, and it's extremely rare for a TP/SL order to execute exactly at the trigger price due to normal market movement and liquidity dynamics.
> [accordion] My TP/SL did not close my position as the price kept moving in a single direction
>
> A stop-limit order works in two stages:
>
> When the trigger price is reached, it places a limit order at the specified limit price.
>
> That limit order will then attempt to execute at that price or better.
>
> However, if the market falls through your limit price and doesn't recover, the limit order may remain unfilled, creating the impression that the stop-limit didn't work. In reality, it worked as intended - it just couldn't execute because the market moved past your limit.
>
> To guarantee that your position closes once the trigger is hit, consider using a stop-market order instead of a stop-limit order. Stop-market orders prioritize execution, while stop-limits prioritize price.
>
> Especially if using stops to prevent liquidation, we highly recommend using stop market orders to guarantee execution.
> [accordion] My TP/SL was not triggered despite crossing the price level on the chart
>
> This is likely because of the mark price being used to trigger stops. Using mark price to trigger stops has the advantage of having exchange-isolated 'wicks' not trigger a user's orders.
>
> If you would like to have TP/SL be triggered using last traded orderbook price, you can change the trigger condition of your stop orders when placing a stop order to "Last traded".
>
> 
> [accordion] How do TP/SL limit orders work?
>
> Stop-Loss and Take-Profit orders are triggered by the **mark/last/mid price**. Once triggered, a limit order is placed to try to close off your position.
>
> **Long Positions - Stop-Loss (SL)**
>
> If you are long and set a **trigger price of \$25** and a **limit price of \$25**, when the mark price falls below \$25 a **limit sell order at \$25** will be placed. If the market drops quickly from \$26 to \$23, your order may rest at \$25 without filling.
>
> If instead you set a **limit price of \$22**, the order has a higher probability of filling somewhere between \$23 and \$22 during a sharp move. Lower limit prices increase fill probability but may result in worse execution.
>
> **Long Positions - Take-Profit (TP)**
>
> If you are long and set a **trigger price of \$32** and a **limit price of \$31.50**, when the mark price rises above \$32 a **limit sell order at \$31.50** will be placed. This protects you from selling below \$31.50 if the price quickly retraces after triggering.
>
> **Short Positions - Stop-Loss (SL)**
>
> If you are short and set a **trigger price of \$30** and a **limit price of \$30**, when the mark price rises above \$30 a **limit buy order at \$30** will be placed. If the market spikes rapidly from \$29 to \$33, your order may not fill.
>
> If instead you set a **limit price of \$34**, the order has a higher probability of filling somewhere between \$33 and \$34 during fast upward moves. Higher limit prices improve fill probability but may result in worse execution.
>
> **Short Positions - Take-Profit (TP)**
>
> If you are short and set a **trigger price of \$20** and a **limit price of \$20.50**, when the mark price falls below \$20 a **limit buy order at \$20.50** will be placed. This ensures the order will not fill at a worse price (above \$20.50) if the market rebounds after triggering.
# Why Was I Liquidated?
Source: https://docs.pacifica.fi/support/trade-outcomes/why-was-i-liquidated
A liquidation occurs when your position moves against you and your account equity falls below the required **maintenance margin**. Expand a question below for details.
> [accordion] What happens during a liquidation?
>
> When this happens:
>
> * Your position is automatically closed by the system
> * You will see **"Market Liquidation"** in your Trade History
> * The position size will be reduced to zero (or partially reduced if partial liquidation applies)
> * Your available balance and margin will update accordingly
>
> Liquidations are triggered based on mark price and maintenance margin requirements, not just last traded price.
>
> You can read more about how liquidations work on Pacifica in [Liquidations](/trading-on-pacifica/liquidations).
> [accordion] Why was I liquidated at a different price to what was previously shown?
>
> This is most likely a result of cross margining.
>
> 1. When you are using cross margin, all your open positions share the same margin pool.
> 2. The displayed liquidation price is conditional: it typically assumes your other positions don't change materially.
> 3. When multiple positions move against you at the same time: losses are accumulated across multiple positions simultaneously.
> 4. This means shared margin was consumed faster: your total account equity drops quicker than a single-position estimate.
> 5. Liquidation thresholds adjusted upward in real time: as equity falls, the effective liquidation prices for each position increase.
> 6. Liquidation triggered at the account level: once total margin fell below requirements, liquidation occurred even if one market hadn't reached the originally displayed price.
>
> How to prevent this:
>
> 1. Use isolated margin if you want more stable, predictable liquidation prices per position.
> 2. Avoid holding multiple correlated positions at high leverage on cross margin.
# Swim
Source: https://docs.pacifica.fi/swim/swim-2
Swim is Pacifica's live prediction game. Watch a market price chart, tap the zones you think the price will move into, and get paid out when you're right. More pairs are coming soon.
### How Swim Works
The chart sits on top of a live grid of boxes. Each box covers a fixed price range vertically and a fixed time window horizontally, so every cell represents a specific price zone at a specific moment ahead.
Tap a box and you're predicting that price will pass through it. If it does, you collect your bet multiplied by that box's payout.
### Trading
* Pick a bet size
* Tap zones on the grid as the chart moves
* Collect `bet × multiplier` any time price enters a zone you tapped
### How Multipliers Work
Zone multipliers ladder based on distance in time and price from the current price. The further the zone, the higher the band. These numbers shift constantly as the chart moves. Nothing is locked in until the price actually reaches it. Once you tap a zone, the multiplier shown at that moment is locked in for your bet, regardless of how the grid shifts afterward.
### **Golden Boxes**
Golden boxes are special boxes that contain a share of the golden prize pool. They are highlighted with a combination of visual effects, making them easy to distinguish from regular boxes.
Golden boxes work just like every other box:
* Tap a golden box to place your prediction
* Win when the market price enters it
* The same timing, multiplier, and settlement rules apply
The golden prize pool accumulates over time as a progressive pot. Each day, the available prize is divided among the golden boxes appearing that day.\
\
Golden boxes appear daily between **2:00 PM and 3:00 PM UTC**.
### Balance
Swim trades draw directly from your Pacifica trading balance, the same one you use for spot and perps. No separate deposit needed, no extra steps.
### Oracle
Swim reads live orderbook prices from leading centralized and decentralized venues, and then aggregates their short term EWMA through a venue-weighted mean.
# Contract Specifications
Source: https://docs.pacifica.fi/trading-on-pacifica/contract-specifications
Pacifica's perpetual contracts let you seamlessly trade cryptocurrency assets with leverage, without the need for an expiration date. Understanding the specifications of these contracts is crucial for effective trading, risk management, and maximizing your trading potential.
Below is a summary of Pacifica's key contract details. You can explore deeper into each specification through dedicated subpages linked below.
### Pacifica Contract Specifications
| Specification | Description | Details |
| - | - | - |
| Contract | Type of perpetual contract | Linear perpetual |
| Contract Size | Size per contract | 1 unit of underlying spot asset |
| IMM (Initial Maintenance Margin) | Margin required to open a position | 1 / (user-selected leverage), dynamically increased when Open Interest sharply rises relative to liquidity |
| MM | Maintenance Margin | 50% of initial margin fraction |
| Dynamic Margin Adjustment | Margin requirement adjustments | Yes (triggered by sharp increase in open interest vs. exchange liquidity, super-linear scaling of initial margin) |
| Oracle Price | Price used for liquidation & PnL | Oracle-based (see Oracle Price) |
| Delivery / Expiration | Contract expiry | None (continuous with hourly funding payments) |
| Position Limit | Maximum allowed position size | No explicit limit per user (position size managed by dynamic margining) |
| Account Type | Margin management style | Per-wallet cross or isolated margin |
| Funding Impact Notional | Notional size impacting funding rates | 20,000 USDC (BTC, ETH); 6,000 USDC (other assets) |
| Maximum Market Order Value | Largest allowed market order | \$4M (leverage >=50), \$1M (leverage 20-50), \$500k (leverage 10-20), otherwise \$250k |
| Maximum Limit Order Value | Largest allowed limit order | 10x- maximum market order value |
### Detailed Contract Information
Explore further details for each area:
* [Market Specifications](/trading-on-pacifica/contract-specifications/market-specifications): View per-market parameters for all available markets.
* [Oracle Price](/trading-on-pacifica/contract-specifications/oracle-price-and-mark-price): Understand how Pacifica calculates the oracle-based Mark Price.
***
Use this overview as your quick-reference guide, and dive deeper into each subpage for full explanations.
# Market Specifications
Source: https://docs.pacifica.fi/trading-on-pacifica/contract-specifications/market-specifications
Per-market trading parameters for every Pacifica market
Every Pacifica market shares the same contract framework (see [Contract Specifications](/trading-on-pacifica/contract-specifications)): linear perpetuals, USDC-margined, funding paid hourly, initial margin = 1 / selected leverage, maintenance margin = 50% of initial. The parameters below are what differ per market.
**How to read this table**
* **Tick Size** — minimum price increment for orders.
* **Order Increment** — minimum quantity step, in units of the base asset.
* **Max Leverage** — highest selectable leverage; your initial margin fraction is 1 / leverage.
* **Oracle Composition** — the markets in the oracle index and their weights, labeled spot or futures. A stale venue drops out and remaining weights renormalize; composition changes as venues list or delist an asset. This column shows the oracle index only — the mark price additionally references perpetual mark prices from Binance, OKX, Bybit and Hyperliquid (crypto) or the RWA venues (equities, FX, commodities). See [Oracle Price & Mark Price](/trading-on-pacifica/contract-specifications/oracle-price-and-mark-price).
* **Listed** — date the market launched on mainnet.
> [!NOTE]
>
> **Denomination.** Binance, OKX, Bybit and Bitget source markets are quoted in **USDT** (the Binance futures index is itself a composite of USDT spot markets); Hyperliquid, trade.xyz, Lighter and Backpack markets are quoted in **USDC/USD**. Source prices enter the oracle as-is — no USDT↔USD conversion is applied.
> [!NOTE]
>
> Parameters can change as liquidity and risk conditions evolve. Live values are always available from the public API: `GET /api/v1/info`. This page is regenerated from that endpoint — last generated 2026-07-16.
### Crypto perpetuals
Standard crypto perpetuals. Oracle prices are a weighted composite of major centralized-exchange markets, refreshed every 3 seconds. kPEPE and kBONK reference 1,000× the underlying token price.
| Market | Tick Size | Order Increment | Max Leverage | Oracle Composition | Listed |
| - | - | - | - | - | - |
| BTC | 1 | 0.00001 | 50x | Binance spot 40% · Binance fut. index 20% · OKX spot 20% · Bybit spot 20% | 2025-06-02 |
| ETH | 0.1 | 0.0001 | 50x | Binance spot 40% · Binance fut. index 20% · OKX spot 20% · Bybit spot 20% | 2025-06-02 |
| BNB | 0.01 | 0.001 | 20x | Binance spot 40% · Binance fut. index 20% · OKX spot 20% · Bybit spot 20% | 2025-07-30 |
| DOGE | 0.00001 | 1 | 20x | Binance spot 40% · Binance fut. index 20% · OKX spot 20% · Bybit spot 20% | 2025-07-23 |
| HYPE | 0.001 | 0.01 | 20x | Binance fut. index 33% · OKX spot 33% · Bybit spot 33% | 2025-07-19 |
| SOL | 0.01 | 0.01 | 20x | Binance spot 40% · Binance fut. index 20% · OKX spot 20% · Bybit spot 20% | 2025-06-02 |
| XRP | 0.0001 | 0.01 | 20x | Binance spot 40% · Binance fut. index 20% · OKX spot 20% · Bybit spot 20% | 2025-07-19 |
| AAVE | 0.01 | 0.01 | 10x | Binance spot 40% · Binance fut. index 20% · OKX spot 20% · Bybit spot 20% | 2025-08-06 |
| ADA | 0.00001 | 0.1 | 10x | Binance spot 40% · Binance fut. index 20% · OKX spot 20% · Bybit spot 20% | 2025-12-10 |
| ARB | 0.00001 | 0.1 | 10x | Binance spot 40% · Binance fut. index 20% · OKX spot 20% · Bybit spot 20% | 2025-12-10 |
| ASTER | 0.00001 | 0.01 | 10x | Binance spot 40% · Binance fut. index 20% · OKX spot 20% · Bybit spot 20% | 2025-09-20 |
| AVAX | 0.001 | 0.01 | 10x | Binance spot 40% · Binance fut. index 20% · OKX spot 20% · Bybit spot 20% | 2025-09-18 |
| BCH | 0.01 | 0.01 | 10x | Binance spot 40% · Binance fut. index 20% · OKX spot 20% · Bybit spot 20% | 2025-12-03 |
| CRV | 0.0001 | 0.1 | 10x | Binance spot 40% · Binance fut. index 20% · OKX spot 20% · Bybit spot 20% | 2025-08-15 |
| ENA | 0.00001 | 1 | 10x | Binance spot 40% · Binance fut. index 20% · OKX spot 20% · Bybit spot 20% | 2025-07-27 |
| FARTCOIN | 0.0001 | 0.1 | 10x | Binance fut. index 100% | 2025-07-25 |
| JUP | 0.0001 | 1 | 10x | Binance spot 40% · Binance fut. index 20% · OKX spot 20% · Bybit spot 20% | 2026-01-05 |
| LDO | 0.0001 | 0.1 | 10x | Binance spot 40% · Binance fut. index 20% · OKX spot 20% · Bybit spot 20% | 2025-08-14 |
| LINK | 0.001 | 0.1 | 10x | Binance spot 40% · Binance fut. index 20% · OKX spot 20% · Bybit spot 20% | 2025-08-08 |
| LIT | 0.0001 | 0.1 | 10x | Binance fut. index 33% · OKX spot 33% · Bybit spot 33% | 2025-12-20 |
| LTC | 0.01 | 0.01 | 10x | Binance spot 40% · Binance fut. index 20% · OKX spot 20% · Bybit spot 20% | 2025-08-13 |
| NEAR | 0.0001 | 0.1 | 10x | Binance spot 40% · Binance fut. index 20% · OKX spot 20% · Bybit spot 20% | 2025-11-12 |
| PAXG | 0.1 | 0.001 | 10x | Binance spot 50% · Binance fut. index 25% · OKX spot 25% | 2025-10-21 |
| PUMP | 0.000001 | 1 | 10x | Binance spot 40% · Binance fut. index 20% · OKX spot 20% · Bybit spot 20% | 2025-07-14 |
| SUI | 0.0001 | 0.1 | 10x | Binance spot 40% · Binance fut. index 20% · OKX spot 20% · Bybit spot 20% | 2025-07-30 |
| TAO | 0.01 | 0.01 | 10x | Binance spot 50% · Binance fut. index 25% · OKX spot 25% | 2025-11-01 |
| TRUMP | 0.0001 | 0.1 | 10x | Binance spot 40% · Binance fut. index 20% · OKX spot 20% · Bybit spot 20% | 2025-11-12 |
| UNI | 0.001 | 0.1 | 10x | Binance spot 40% · Binance fut. index 20% · OKX spot 20% · Bybit spot 20% | 2025-08-15 |
| XMR | 0.01 | 0.01 | 10x | Binance fut. index 100% | 2025-12-03 |
| XPL | 0.0001 | 1 | 10x | Binance spot 40% · Binance fut. index 20% · OKX spot 20% · Bybit spot 20% | 2025-09-25 |
| ZEC | 0.01 | 0.01 | 10x | Binance spot 50% · Binance fut. index 25% · OKX spot 25% | 2025-10-27 |
| kBONK | 0.000001 | 1 | 10x | Binance spot 40% · Binance fut. index 20% · OKX spot 20% · Bybit spot 20% | 2025-08-01 |
| kPEPE | 0.000001 | 1 | 10x | Binance spot 40% · Binance fut. index 20% · OKX spot 20% · Bybit spot 20% | 2025-08-11 |
| ICP | 0.0001 | 0.1 | 5x | Binance spot 40% · Binance fut. index 20% · OKX spot 20% · Bybit spot 20% | 2025-11-12 |
| PENGU | 0.000001 | 1 | 5x | Binance spot 40% · Binance fut. index 20% · OKX spot 20% · Bybit spot 20% | 2025-08-01 |
| STRK | 0.0001 | 1 | 5x | Binance spot 40% · Binance fut. index 20% · OKX spot 20% · Bybit spot 20% | 2025-11-11 |
| VIRTUAL | 0.0001 | 0.1 | 5x | Binance spot 40% · Binance fut. index 20% · OKX spot 20% · Bybit spot 20% | 2025-10-30 |
| WIF | 0.00001 | 1 | 5x | Binance spot 40% · Binance fut. index 20% · OKX spot 20% · Bybit spot 20% | 2026-01-05 |
| WLD | 0.0001 | 0.1 | 5x | Binance spot 40% · Binance fut. index 20% · OKX spot 20% · Bybit spot 20% | 2025-12-31 |
| WLFI | 0.0001 | 1 | 5x | Binance spot 40% · Binance fut. index 20% · OKX spot 20% · Bybit spot 20% | 2025-08-24 |
| ZK | 0.00001 | 1 | 5x | Binance spot 40% · Binance fut. index 20% · OKX spot 20% · Bybit spot 20% | 2025-11-02 |
| ZRO | 0.0001 | 0.1 | 5x | Binance spot 40% · Binance fut. index 20% · OKX spot 20% · Bybit spot 20% | 2026-02-11 |
| 2Z | 0.0001 | 1 | 3x | Binance spot 40% · Binance fut. index 20% · OKX spot 20% · Bybit spot 20% | 2025-10-02 |
| CHIP | 0.0001 | 0.1 | 3x | Binance spot 40% · Binance fut. index 20% · OKX spot 20% · Bybit spot 20% | 2026-04-23 |
| MEGA | 0.00001 | 1 | 3x | Binance spot 40% · Binance fut. index 20% · OKX spot 20% · Bybit spot 20% | 2026-01-21 |
| MON | 0.00001 | 1 | 3x | Binance fut. index 50% · OKX spot 50% | 2025-10-28 |
| PIPPIN | 0.00001 | 1 | 3x | Binance fut. index 100% | 2026-01-05 |
### Special crypto pairs
**SOL-USDC** is a spot market (1x, no funding) priced off the SOL composite oracle. **BP** tracks Backpack's USDC spot market and carries reduced leverage while external liquidity develops.
| Market | Tick Size | Order Increment | Max Leverage | Oracle Composition | Listed |
| - | - | - | - | - | - |
| SOL-USDC | 0.01 | 0.001 | 1x | Binance spot 40% · Binance fut. index 20% · OKX spot 20% · Bybit spot 20% | 2026-04-19 |
| BP | 0.0001 | 0.1 | 3x | Backpack spot 100% | 2026-02-11 |
### Equity, FX & commodity perpetuals
Real-world-asset perpetuals trade 24/7 on Pacifica, including when the underlying market is closed. Oracle prices composite trade.xyz, Lighter and Bitget RWA markets — plus Binance where it lists the equivalent contract; funding continues to accrue hourly through weekends and market closures.
| Market | Class | Tick Size | Order Increment | Max Leverage | Oracle Composition | Listed |
| - | - | - | - | - | - | - |
| CRCL | Equity | 0.01 | 0.001 | 10x | trade.xyz index 71% · Lighter index 14% · Bitget index 14% | 2026-03-19 |
| GOOGL | Equity | 0.01 | 0.001 | 10x | trade.xyz index 71% · Lighter index 14% · Bitget index 14% | 2026-02-11 |
| HOOD | Equity | 0.001 | 0.01 | 10x | trade.xyz index 71% · Lighter index 14% · Bitget index 14% | 2026-03-13 |
| MSTR | Equity | 0.001 | 0.01 | 10x | Binance fut. index 42% · trade.xyz index 42% · Lighter index 8% · Bitget index 8% | 2026-06-26 |
| NVDA | Equity | 0.01 | 0.001 | 10x | trade.xyz index 71% · Lighter index 14% · Bitget index 14% | 2025-12-28 |
| PLTR | Equity | 0.01 | 0.001 | 10x | trade.xyz index 71% · Lighter index 14% · Bitget index 14% | 2026-02-25 |
| SAMSUNG | Equity | 0.01 | 0.001 | 10x | Binance fut. index 42% · trade.xyz index 42% · Lighter index 8% · Bitget index 8% | 2026-06-03 |
| SKHYNIX | Equity | 0.1 | 0.0001 | 10x | Binance fut. index 42% · trade.xyz index 42% · Lighter index 8% · Bitget index 8% | 2026-06-03 |
| SPCX | Equity | 0.01 | 0.01 | 10x | trade.xyz index 83% · Lighter index 17% | 2026-05-20 |
| TSLA | Equity | 0.01 | 0.001 | 10x | trade.xyz index 71% · Lighter index 14% · Bitget index 14% | 2026-01-15 |
| SP500 | Index | 0.1 | 0.0001 | 20x | trade.xyz index 83% · Bitget index 17% | 2026-03-19 |
| URNM | ETF | 0.001 | 0.01 | 10x | Binance fut. index 50% · trade.xyz index 50% | 2026-02-25 |
| EURUSD | FX | 0.0001 | 0.1 | 50x | trade.xyz index 83% · Lighter index 17% | 2026-02-11 |
| USDJPY | FX | 0.01 | 0.001 | 50x | trade.xyz index 83% · Lighter index 17% | 2026-01-15 |
| CL | Commodity | 0.001 | 0.01 | 10x | trade.xyz index 71% · Lighter index 14% · Bitget index 14% | 2026-01-11 |
| COPPER | Commodity | 0.0001 | 0.01 | 10x | Binance fut. index 45% · trade.xyz index 45% · Bitget index 9% | 2026-02-11 |
| NATGAS | Commodity | 0.0001 | 0.1 | 10x | Binance fut. index 42% · trade.xyz index 42% · Lighter index 8% · Bitget index 8% | 2026-02-25 |
| PLATINUM | Commodity | 0.1 | 0.0001 | 10x | trade.xyz index 100% | 2026-03-19 |
| XAG | Commodity | 0.001 | 0.01 | 10x | trade.xyz index 71% · Lighter index 14% · Bitget index 14% | 2025-12-30 |
| XAU | Commodity | 0.1 | 0.0001 | 10x | trade.xyz index 71% · Lighter index 14% · Bitget index 14% | 2026-02-11 |
***
Funding accrues hourly on all perpetual markets. For how prices are formed, see [Oracle Price & Mark Price](/trading-on-pacifica/contract-specifications/oracle-price-and-mark-price); for margin mechanics, see [Margin and Leverage](/trading-on-pacifica/margin-and-leverage).
# Oracle Price & Mark Price
Source: https://docs.pacifica.fi/trading-on-pacifica/contract-specifications/oracle-price-and-mark-price
Pacifica's perpetual contracts use a decentralized Oracle Price to accurately value positions and determine funding rate and is a component of Mark Price. This Oracle Price protects traders by reducing manipulation risks and ensuring market stability. Mark Price is used for liquidations, margin requirements and Unrealized PnL.
### Oracle Price Calculation
The oracle price is updated every 3 seconds and calculated as a weighted average of USDT denominated prices from major exchanges.
| CEX | Weights |
| :-: | :-: |
| Binance | 2 |
| OKX | 1 |
| Bybit | 1 |
| Hyperliquid | 1 |
### Uses of Oracle Price on Pacifica
The Oracle Price is crucial for several Pacifica exchange operations:
* Funding Rates: Calculations rely on the Oracle Price to maintain alignment with spot markets.
* Mark Price Calculation: Oracle price serves as a component of Mark Price to prevent market manipulation and ensure the accuracy of settlements.
### Uses of Mark Price on Pacifica
The Mark Price is the median value of:\
1\. Oracle (spot) price\
2\. The median of best bid, best ask, and last trade on Pacifica\
3\. Perpetual price from major exchanges
The Mark Price is used for:
* Liquidation Calculations: By using the median value of the 3 Mark Price components, Pacifica ensures fair and accurate liquidations.
* Margin Requirements: Both initial and maintenance margins are determined using the Mark Price.
* Unrealized PnL: Open positions are marked-to-market using the Mark Price.
### Transparency & Reliability
Pacifica provides transparent and verifiable Oracle Prices available directly through our trading interface or via API endpoints, ensuring trust and accountability.
***
For further details or technical questions, refer to our [API documentation](/api-documentation/api) or contact our support via [Contact Us](/other/contact-us).
# Pre-Markets
Source: https://docs.pacifica.fi/trading-on-pacifica/contract-specifications/pre-markets
When Pacifica lists pre-markets that are not on other major exchanges, the oracle references Pacifica's mark price instead of external sources.\
\
An EMA is also applied to prevent oracle manipulation. This, combined with Pacifica's price band mechanic (+-30% of mark price) prevents extreme manipulation of pre-market perps.\
\
Once other major venues begin listing the same market, their pricing will be added to Pacifica's oracle reference in order to further strengthen its robustness.\
\
Additionally, Pacifica exercises strict open interest caps in pre-market pairs to prevent abnormal trading activity and market manipulation.
# Deposits & Withdrawals
Source: https://docs.pacifica.fi/trading-on-pacifica/deposits-and-withdrawals
Before trading, a user connects a Solana-compatible wallet to Pacifica and funds the account with USDC. Pacifica supports Phantom, Solflare, Backpack, Ledger (via browser extension), and other WalletConnect-compatible wallets.
## USDC Deposits
Pacifica currently limits deposits to a maximum of \$500,000 account equity during Closed Beta. Additional deposits are gated on the frontend, and API deposits exceeding these amounts are held in pending.
Minimum deposit: \$10.
Fees: network gas only.
### USDC Withdrawals
Pacifica currently limits single-account withdrawals to a maximum of \$500,000 every 24 hours during Closed Beta. Additional withdrawals are gated on the frontend, and API withdrawals exceeding the limit are held in pending.
Unrealized PnL may be withdrawn from an isolated position or a cross-margin account subject to the 10% initial-margin floor. See [Margin & Leverage](/trading-on-pacifica/margin-and-leverage).
An exchange-wide withdrawal cap applies across all assets as a risk-mitigation mechanism. It is unlikely to affect normal withdrawals.
Under unified margin, USDC withdrawal is bounded by `available_to_withdraw`, which deducts any outstanding money-market borrow. An account with a negative USDC balance cannot withdraw USDC until the debt is repaid or sufficient spot is sold.
Minimum withdrawal: \$1.
Fees: \$1 per withdrawal (gas).
## Spot Asset Deposits
Spot assets are credited to the account after on-chain confirmation. Once credited, the balance is tradeable on the corresponding spot market and contributes cross-margin collateral per the asset's LTV and per-user cap. See [Spot Collateral](/trading-on-pacifica/spot-collateral).
Each supported spot asset has a per-user daily USD-notional deposit cap of \$50,000.
Minimum deposit: approximately \$10 worth of the deposited asset.
Fees: network gas only.
## Spot Asset Withdrawals
The maximum withdrawable amount for a given spot asset is:
```
available_spot_to_withdraw =
min(spot_balance,
(cross_equity_without_spot + spot_collateral_value - required_borrow
- 0.1 * total_position_value)
/ (price * ltv_ratio))
```
The constraint ensures remaining collateral covers both outstanding perpetual margin and any money-market debt after withdrawal. The 10% floor on `total_position_value` matches the constraint applied to USDC withdrawals.
Each asset has a per-user daily USD-notional withdrawal cap of \$500,000. Requests above the cap are queued for the next reset.
A time-based, exchange-wide withdrawal cap applies across USDC and spot combined.
Fees: network gas, plus a withdrawal fee of approximately \$1 worth of the withdrawn asset.
## Subaccount Spot Transfers
Spot assets can be moved between a master account and any of its direct subaccounts without an on-chain transaction. Transfers are instant and fee-free. Asset movements are subject to margin requirements.
USDC transfers between subaccounts continue to follow the existing [Subaccount Fund Transfer](/api-documentation/api/rest-api/subaccounts/subaccount-fund-transfer) rules.
# Fund Security
Source: https://docs.pacifica.fi/trading-on-pacifica/fund-security
In the high-stakes world of decentralized finance, security is the foundation upon which everything else is built. At Pacifica, our mission has always been to build the most powerful and secure perpetual DEX, one that rivals the performance of centralized exchanges without sacrificing the self-custodial ethos that makes DeFi revolutionary.
Since our mainnet launch we have processed significant volume, earning the trust of a rapidly growing community of active traders. This trust is our most valuable asset. In order to keep up with the continuously rising stakes of growth, Pacifica is transitioning to a sophisticated hot-cold hybrid security architecture with multi-signature governance.
## The Inherent Tension: Power vs. Protection
The core challenge for any high-performance perpetual DEX is managing the "withdrawal authority", the logic within a smart contract that permits the movement of user funds. To facilitate instant withdrawals, this authority must be readily accessible to the matching engine. However, concentrating this access in a single, always-online endpoint creates systemic risk.
Most perpetual DEXs operate with a unified smart contract architecture where all user funds reside in a single upgradeable contract. In these systems, the proxy contract holds user funds and delegates calls to a logic contract. If administrators can upgrade this logic, they possess the ability to modify withdrawal permissions. The contract logic is flexible, but ultimate control rests with whoever holds the admin keys. If the withdrawal authority is compromised, all funds are exposed. Subsequent effects of this are then: if the smart contract has a vulnerability, all funds are at risk, and if admin keys are stolen, the contract logic itself can be upgraded to drain user capital. There's no segmentation, no firebreak, no defense in depth.
## The Pacifica Protocol: Layered, Proactive Security
We aim to think beyond this single-point-of-failure paradigm entirely. Our new design creates a multi-layered defense system that is both resilient and non-custodial. This is the culmination of best practices implemented in a transparent, verifiable manner.
### The Hot Wallet: The Engine of Commerce
This is the operational treasury and represents only a fraction of total funds.
The hot wallet is managed by the matching engine, which can execute withdrawals up to the programmatic spending limit without additional approvals. This ensures legitimate user withdrawals remain instantaneous. If compromised through an engine key breach, smart contract exploit, or social engineering attack, an attacker can only access the limited funds in the hot wallet.
### The Cold Vault: The Fortress of Funds
The bulk of user capital resides in the cold vault, secured by a multi-signature smart contract governed by a decentralized council that is geo-distributed across multiple continents. This vault has one primary function: to replenish the hot wallet through programmatic spending limits.
We've partnered with Squads Protocol, the leading multi-signature infrastructure securing over \$10 billion in assets on Solana. Squads is the first formally verified program on Solana, meaning its code has undergone mathematical proofs of correctness beyond traditional auditing. The multi-signature requirement means multiple independent parties must approve any transaction before it executes, eliminating the single point of failure inherent in traditional single-key wallets.
Squads enables time-locked upgrade mechanisms that introduce mandatory delays between proposal and execution, giving users visibility and the ability to exit if they disagree. Role-based access control defines who can propose, approve, and execute transactions. Emergency pause functionality requires multi-party consensus. The cold vault cannot send funds to arbitrary addresses. Its logic is constrained by design, making it technically impossible for any party to redirect funds elsewhere.
### The Unbreakable Chain of Custody
The true innovation lies in the interaction between these two layers, creating a security model that provides both operational efficiency and ironclad protection.
When a user requests a withdrawal, the matching engine processes it instantly from the hot wallet. If the hot wallet balance dips below a predefined threshold, a replenishment process is automatically initiated, which requires a consensus-approved transaction from the decentralized multi-sig governing the cold vault. Multiple independent signers must review and approve the transfer, ensuring that no single party can unilaterally move funds from cold storage.
The cold vault then sends only the necessary amount to replenish the hot wallet up to its operational limit, never exceeding the predetermined cap. This creates a security guarantee: even in a worst-case scenario where our operational systems are fully compromised, where an attacker gains control of the matching engine, the AWS infrastructure, or even internal access credentials, they can only access the limited funds in the hot wallet. The majority of funds remain safe.
Using Squads' programmatic spending limit feature, we can allocate specific withdrawal budgets to the hot wallet without requiring full multi-signature approval for every routine operation. For example, the hot wallet might have a daily limit of \$5 million USDC for user withdrawals. Any attempt to exceed this limit automatically triggers multi-signature requirements. The system is self-enforcing; the blockchain itself prevents unauthorized fund movements.
### Signer-Level Separation: The Technical Advantage
Our architecture implements security at the signer level, creating distinct roles with different permissions and capabilities. The hot signer, controlled by the engine operator, can withdraw up to the Squads wallet's spending limit in a specified time duration. The cold signers, a distributed group of multi-sig members, control reserve funds and have the authority to adjust spending limits through consensus. The upgrade authority is distributed across multi-sig participants, not held by any individual or single organization.
This means any single party attempting to compromise the exchange, whether external attacker or rogue insider, can only access the limited funds in the hot wallet. The spending limit acts as a firebreak, containing potential damage and preventing catastrophic loss.
Let's examine potential attack scenarios:
| Attack Vector | Single Contract | Pacifica Hot/Cold Hybrid |
|---|
| Engine compromise | All funds exposed | Only hot wallet funds exposed |
| Smart contract exploit | All funds at risk | Only hot wallet funds at risk |
| Admin key compromise | Can upgrade to drain all funds | Requires multi-sig;spending limits enforced |
| Social engineering | Single point of failure | Multiple parties must be compromised |
| Inside threat | Unilateral access possible | Impossible without multi-party collusion |
### Uncompromising Decentralization
By vesting control of the cold vault in a decentralized multi-sig, we eliminate any single point of failure's ability to bring down the entire system. The distributed governance model ensures that even if several parties are compromised, the threshold mechanism prevents unauthorized access to the majority of funds.
### Verifiable Security Over Blind Trust
Our model allows the community to audit the key facts: the spending limit of the hot wallet and the immutable logic of the cold vault. You don't have to trust us; you can verify the security model on-chain. Every parameter, every threshold, every authorization is recorded on the blockchain and can be independently verified by anyone.
Any proposed change to withdrawal authorities or spending limits requires not only multi-signature approval but also a time-locked execution period, giving users visibility into governance decisions and the ability to withdraw their funds if they disagree.
Pacifica's bridge and cold vaults, along with all component logic can be found in the following addresses:
* USDC deposit/withdraw bridge: `72R843XwZxqWhsJceARQQTTbYtWy6Zw9et2YV4FpRHTa`
* SOL deposit/withdraw bridge: `9sSr35zwnFTuv2kZ86i55sR9dqQLTG663homexrLYgYu`
* USDC cold-vault: `5kwCMKjE3Krvs7cHfcQ9kBkGyPQphd3oJ4KnsXcpMoVc`
* SOL cold-vault: `8nFeyzTFhUXp11raJkSSvZWn9GXDjcrGq8LuzP9aKtg8`
### Built for Scale
This architecture is designed to grow with us. As our TVL expands into the hundreds of millions and even billions, the risk profile remains constant. Whether we're securing \$100 million or \$10 billion in user funds, the fundamental security guarantees remain unchanged: the hot wallet cap limits exposure, the multi-sig prevents unauthorized cold storage access, and the spending limits act as an automatic circuit breaker.
## Conclusion: Security as a First Principle
The transition to hot-cold hybrid architecture with multi-signature governance and programmatic spending limits represents more than a technical upgrade. It's a statement that we prioritize long-term security over short-term convenience, and that decentralized finance can meet the highest security standards while exceeding centralized platforms in transparency and verifiability.
As we continue scaling toward becoming the leading perpetual DEX, security architecture that protects billions in user funds lays an ironclad foundation. We build for the future.
# Funding Rates
Source: https://docs.pacifica.fi/trading-on-pacifica/funding-rates
Funding fees ensure perpetual contract prices closely track the underlying spot market. Depending on the prevailing funding rate, traders with open positions periodically pay or receive these fees:
* Positive Funding Rate: Traders holding long positions pay traders holding short positions.
* Negative Funding Rate: Traders holding short positions pay traders holding long positions.
Funding rates are updated every hour, calculated based on market conditions from the previous hour.
### Funding Rate Calculation
Pacifica calculates the funding rate using two components: the Premium Index and a fixed 8-hour Interest Rate (0.01%):
```
funding_rate = (premium_index + clamp(interest_rate - premium_index, -0.05%, 0.05%))/8
```
**Where:**
* **Premium Index** measures the deviation between the Impact Price and the Oracle Price:
```
premium_index = impact_price / oracle_price - 1
```
* **Impact Price** is determined by the average execution price for a defined Impact Notional from Pacifica's orderbook:
```
impact_price = max(impact_bid_price - oracle_price, 0)
- max(oracle_price - impact_ask_price, 0)
```
The **Impact Notional** values are:
| Asset | Impact Notional (USD) |
| :-: | :-: |
| BTC | \$20,000 |
| Other | \$6,000 |
* **Clamp** of +-0.05% keeps funding static for small fluctuations in premium, allowing for a steady funding rate during relatively steady market conditions
Pacifica samples and updates the funding rate every **5 seconds** and displays a TWAP of the estimated next 1h funding rate. At the end of each **1-hour interval**, the average funding rate is taken and then applied to open positions, and the funding rate TWAP is reset.
Funding fees per hour are capped at ±4%.\
\
**Funding payments:**
* Long positions:
* Positive funding rate: Account Balance reduced (pay fee)
* Negative funding rate: Account Balance increased (receive fee)
* Short positions:
* Positive funding rate: Account Balance reduced (receive fee)
* Negative funding rate: Account Balance increased (pay fee)
### Effect on Isolated Positions and Liquidations
For isolated margin positions, funding payments are deducted from the isolated margin balance and will therefore affect the position's liquidation price. After each funding payout, Pacifica recalculates liquidation prices to reflect the adjusted margin.
# Liquidations
Source: https://docs.pacifica.fi/trading-on-pacifica/liquidations
Pacifica employs a three-tiered liquidation process to manage positions that fall below the required maintenance margin. The multi-step approach minimizes market disruption while ensuring that a trader's collateral is used effectively to cover losses.
### Liquidation Price Formula
Liquidation occurs when a user's account equity falls below the maintenance margin of open positions.
Maintenance margin is ½ the initial margin requirement on all markets, defined by `1 / max_leverage` of the market.
```
liquidation_price = [price - (side * position_margin) / position_size]
/ (1 - side / max_leverage / 2)
```
`side = 1` for long, `-1` for short. `position_margin` is `account_equity` for cross-margin positions; `price` should be the current `mark_price` if `account_equity` already reflects unrealized PnL.
### Three-Tiered Liquidation Process
1. **Market Liquidation.** When a user's account equity first falls below maintenance margin but remains above the backstop liquidation threshold (⅔ of maintenance margin), all open orders - including ones that would otherwise reduce exposure - are cancelled, and the positions are liquidated by sending market orders into the orderbook.
During a market liquidation, positions are broken into smaller chunks, each placed as an IOC order as close to backstop liquidation price as possible (to prevent immediate backstop liquidation). The chunking strategy is dynamic and based on market leverage:
```
Small positions (< $2,000 * max_leverage): 1 chunk (immediate)
Large positions (>= $2,000 * max_leverage): 5 chunks
```
`max(0.75%, maintenance_margin_ratio * 0.4)` of the value of positions liquidated in this manner is deducted by the liquidation engine. Large positions are sent with a small interval between chunks (average under 1 second). If enough of the position is closed to restore maintenance margin levels, the remainder stays with the trader as a partial liquidation.
2. **Backstop Liquidation.** If account equity falls below ⅔ of the maintenance margin, all open positions and remaining collateral are transferred to a Pacifica backstop liquidator. This prevents orderbook disruption during large market movements.
3. **Auto-Deleveraging.** If account equity falls below zero while maintaining an open position - caused by prior tiers having insufficient liquidity - Pacifica closes opposing profitable traders' positions based on risk priority to maintain overall market health.
Due to their experimental or volatile nature, the backstop liquidator does not take positions from the following markets: `URNM, GOLD, SILVER, PAXG, CL, COPPER, NATGAS, EURUSD, USDJPY, NVDA, TSLA, PLTR, SP500, GOOGL, CRCL, HOOD, MEGA, BP`.
### Spot Insolvency Deleveraging
Unified margin accounts can hold negative USDC balances backed by spot collateral. A separate deleveraging path unwinds spot positions if an account's debt exceeds its collateral or if the money market is under stress. This is separate from perpetual liquidations.
Spot deleveraging runs in two modes:
1. **Account-level.** Triggered when an individual borrower's spot collateral value is no longer sufficient to support the USDC debt and/or any perpetual initial-margin requirement.
2. **Pool-level.** Triggered when money-market `utilization >= 95%`. Deleveraging proceeds from the largest borrowers first and aims to bring utilization back down to 90%.
In both modes, the system begins liquidating spot assets on the account's behalf into the spot orderbook to repay USDC loans.
# Margin & Leverage
Source: https://docs.pacifica.fi/trading-on-pacifica/margin-and-leverage
Pacifica supports cross margin and isolated margin. Margin mode is selected per trading pair. Cross margin is the default.
Margin mode cannot be changed for a symbol with an open position. Leverage can be increased on a symbol with an open position but cannot be decreased until the position is closed.
### Cross Margin
Cross margin pools the account's USDC balance, unrealized PnL from cross perpetual positions, and LTV-adjusted spot collateral into a single equity figure that supports all cross positions.
```
account_value = usdc_balance + unrealized_pnl - pending_interest + spot_collateral_value
```
Unrealized PnL updates continuously. Isolated positions and their assigned margin are excluded. `pending_interest` is unsettled interest on any outstanding money-market borrow and is deducted from equity as soon as it accrues.
Spot holdings contribute to `account_value` according to per-asset LTV, a per-user collateral cap, and an optional hedging bonus. See [Spot Collateral](/trading-on-pacifica/spot-collateral) for the full formula.
### Isolated Margin
Isolated margin assigns a dedicated margin amount to each position. Isolated positions receive no collateral from spot holdings and are not affected by the unified margin model. Their liquidation is determined solely by the assigned isolated margin and the position's notional.
### Initial Margin
Placing an order reserves initial margin based on entry price, position size, and selected leverage.
```
initial_margin = position_size * entry_price / leverage
```
### Unrealized PnL and Withdrawable Balance
Unrealized PnL can be withdrawn from an isolated position or a cross-margin account, subject to the 10% initial-margin floor. Open spot buy orders also deduct their locked USDC from withdrawable balance:
```
withdrawable_balance = usdc_balance + unrealized_pnl - pending_interest + spot_collateral_value
- max(initial_margin_required, 0.1 * total_position_value)
- spot_buy_order_locked_usdc
```
# Money Market
Source: https://docs.pacifica.fi/trading-on-pacifica/money-market
Pacifica operates a single USDC money market shared across all cross-margin accounts
Lending and borrowing are implicit on Pacifica. Positions can be opened against spot collateral and pay no interest until negative PnL triggers a borrow.
Accounts with idle USDC above a threshold supply the pool and earn interest. Accounts who 1) hold spot collateral 2) have cross margin equity that falls below zero automatically borrow from the pool and pay interest. Only USDC is lent or borrowed; spot assets serve as collateral and are never rehypothecated.
### Lenders and Borrowers
An account is eligible to lend when all of the following hold:
* Its USDC balance is at least the minimum lender threshold (1,000 USDC).
* Its lendable capacity - USDC balance net of the 10% initial-margin floor, pending interest, and any USDC locked by spot buy orders - is also at least 1,000 USDC.
* `auto_lend_disabled` is false.
An account is a borrower when:
```
equity_without_spot = usdc_balance + unrealized_pnl_from_cross_perps - pending_interest
required_borrow = max(0, -equity_without_spot)
```
and `required_borrow > 0`. Borrowing is only permitted while spot collateral is sufficient to cover the shortfall. An account without adequate spot collateral is flagged for insolvency deleveraging. See [Liquidations](/trading-on-pacifica/liquidations#spot-insolvency-deleveraging).
### Pool Aggregates
```
total_borrowable = sum over eligible lenders of their lendable capacity
total_borrowed = sum over borrowers of required_borrow
utilization = total_borrowed / total_borrowable
```
Pool state is published via `GET /api/v1/loan_pool`.
### Utilization Thresholds
| Threshold | Utilization | Behavior |
| - | - | - |
| Optimal | 80% | Borrow APR equals the kink rate. |
| Order admission limit | > 90% | Borrowing accounts cannot place new non-reduce-only perpetual orders. |
| Pool deleveraging | ≥ 95% | Pool-level insolvency deleveraging begins. |
| Pool deleveraging target | 90% | Utilization target after pool-level deleveraging. |
### Borrow APR
Borrow APR is a piecewise function of utilization:
```
u <= 0.8: apr = MIN_BORROW_APR + (LINEAR_KINK_APR - MIN_BORROW_APR) * (u / 0.8)
u > 0.8: apr = LINEAR_KINK_APR * (EXPONENTIAL_TARGET_APR / LINEAR_KINK_APR) ^ ((u - 0.8) / 0.2)
```
Current defaults: `MIN_BORROW_APR = 1%`, `LINEAR_KINK_APR = 10.95%`, `EXPONENTIAL_TARGET_APR = 50%`. At `u = 1`, the curve reaches exactly `EXPONENTIAL_TARGET_APR`.
Lender APR is derived pro-rata from utilization:
```
lend_apr = borrow_apr * utilization
```
APR values are compounded per-second, so `APY ≈ e^APR - 1`.
### Interest Accrual and Payout
Every 60 seconds, each borrower's `pending_interest` grows by:
```
pending_interest += required_borrow * borrow_rate_per_second * 60
```
Every hour, accumulated `pending_interest` is charged to the borrower's USDC balance and distributed pro-rata across lenders' USDC balances.
### Order Admission Under Stress
When pool `utilization > 90%`, accounts carrying a borrow (`equity_without_spot < 0`) cannot place new perpetual orders unless the order is reduce-only. Spot orders are not subject to this check. Non-borrowing accounts are unaffected.
### Opt-Outs
* **Stop lending.** Set `auto_lend_disabled = true`. USDC balance remains usable for trading but is excluded from `total_borrowable` and earns no yield.
* **Exclude a spot asset from unified margin.** Set `unified_margin_excluded = true` on a (user, asset) pair. The asset remains in the account and tradeable but contributes no collateral and cannot back a borrow.
Borrowing itself cannot be disabled. An account whose `equity_without_spot` drops below zero with sufficient spot collateral will automatically open a loan.
# Order Types
Source: https://docs.pacifica.fi/trading-on-pacifica/order-types
Choose from classic order types and strategies based on how you want to trade.
Select an order type from the dropdown at the top of the order form. Explore the two groups below to find its settings and examples.
## At a glance
| Order type | What it does | Typical use |
| - | - | - |
| [Market](/trading-on-pacifica/order-types/classic/market) | Executes at available prices within your slippage limit | Enter or exit promptly |
| [Limit](/trading-on-pacifica/order-types/classic/limit) | Buys at your limit price or lower, or sells at your limit price or higher | Control execution price |
| [Stop Market](/trading-on-pacifica/order-types/classic/stop-market) | Places a market order when a trigger price is reached | Stop loss or breakout entry |
| [Stop Limit](/trading-on-pacifica/order-types/classic/stop-limit) | Places a limit order when a trigger price is reached | Combine a trigger with a limit price |
| [RFQ](/trading-on-pacifica/order-types/classic/rfq) | Requests liquidity before you submit a market order | Review an estimate before trading |
| [TWAP](/trading-on-pacifica/order-types/classic/twap) | Splits an order into smaller market orders over time | Spread execution over time |
| [Scale](/trading-on-pacifica/order-types/classic/scale) | Places a ladder of limit orders across a price range | Build or reduce a position at several prices |
| [Chase](/trading-on-pacifica/order-types/strategies/chase) | Reprices a post-only limit order as the best bid or ask changes | Seek a maker fill |
| [Conditional Market](/trading-on-pacifica/order-types/strategies/conditional-market) | Places a market order when a chosen market meets a price condition | Trigger a market order on another market or price source |
| [Conditional Limit](/trading-on-pacifica/order-types/strategies/conditional-limit) | Places a limit order when a chosen market meets a price condition | Combine a price condition with a limit price |
| [OCO](/trading-on-pacifica/order-types/strategies/oco) | Places the first of two stop legs to trigger and cancels the other | Set two alternative orders |
| [Trailing Stop](/trading-on-pacifica/order-types/strategies/trailing-stop) | Tracks the market at a fixed distance and triggers on a reversal | Adjust a stop as the market moves |
| [Swarm](/trading-on-pacifica/order-types/strategies/swarm) | Places small market orders in quick succession | Split a fast execution into smaller orders |
| [Trigger Swarm](/trading-on-pacifica/order-types/strategies/trigger-swarm) | Waits for a price trigger, then places market orders one at a time | Combine a trigger with split execution |
| [Atomic](/trading-on-pacifica/order-types/strategies/atomic) | Submits market orders across several markets together | Pair trades and baskets |
> [card] [Classic](/trading-on-pacifica/order-types/classic)
>
> Market, Limit, Stop Market, Stop Limit, RFQ, TWAP and Scale.
> [card] [Strategies](/trading-on-pacifica/order-types/strategies)
>
> Chase, Conditional Market and Limit, OCO, Trailing Stop, Swarm, Trigger Swarm and Atomic.
# Classic
Source: https://docs.pacifica.fi/trading-on-pacifica/order-types/classic
Choose a market, limit, stop, RFQ, TWAP or Scale order to control price and timing.
Classic order types cover immediate execution, price limits, stop triggers and orders spread across time or a price range. Choose a type below for its settings and examples.
## At a glance
| Order type | What it does | Typical use |
| - | - | - |
| [Market](/trading-on-pacifica/order-types/classic/market) | Executes at available prices within your slippage limit | Enter or exit promptly |
| [Limit](/trading-on-pacifica/order-types/classic/limit) | Buys at your limit price or lower, or sells at your limit price or higher | Control execution price |
| [Stop Market](/trading-on-pacifica/order-types/classic/stop-market) | Places a market order when a trigger price is reached | Stop loss or breakout entry |
| [Stop Limit](/trading-on-pacifica/order-types/classic/stop-limit) | Places a limit order when a trigger price is reached | Combine a trigger with a limit price |
| [RFQ](/trading-on-pacifica/order-types/classic/rfq) | Requests liquidity before you submit a market order | Review an estimate before trading |
| [TWAP](/trading-on-pacifica/order-types/classic/twap) | Splits an order into smaller market orders over time | Spread execution over time |
| [Scale](/trading-on-pacifica/order-types/classic/scale) | Places a ladder of limit orders across a price range | Build or reduce a position at several prices |
> [card] [Market](/trading-on-pacifica/order-types/classic/market)
>
> Execute at available market prices within your slippage limit.
> [card] [Limit](/trading-on-pacifica/order-types/classic/limit)
>
> Set your price and choose how unfilled orders are handled.
> [card] [Stop Market](/trading-on-pacifica/order-types/classic/stop-market)
>
> Place a market order when a trigger price is reached.
> [card] [Stop Limit](/trading-on-pacifica/order-types/classic/stop-limit)
>
> Place a limit order when a trigger price is reached.
> [card] [RFQ](/trading-on-pacifica/order-types/classic/rfq)
>
> Request liquidity and review an estimate before submitting a market order.
> [card] [TWAP](/trading-on-pacifica/order-types/classic/twap)
>
> Spread an order over time with smaller market orders.
> [card] [Scale](/trading-on-pacifica/order-types/classic/scale)
>
> Place a ladder of limit orders across a price range.
# Limit
Source: https://docs.pacifica.fi/trading-on-pacifica/order-types/classic/limit
Set the price you are willing to trade at and choose how unfilled orders are handled.
A limit order buys at your limit price or lower, or sells at your limit price or higher. It can fill immediately if that price matches an existing order. Its time-in-force determines what happens to any unfilled amount. Use a limit order when the execution price matters more than being filled immediately.

BTC limit order form. The TIF dropdown sits next to Reduce Only.
## Time-in-force (TIF)
Every limit order on Pacifica uses one of the following TIF options.
* **Good-Til-Cancelled (GTC):** The order remains active on the order book until it is either filled or cancelled.
* **Immediate-or-Cancel (IOC):** The order attempts to match immediately at the specified price (or better). Any portion that is not filled immediately is cancelled.
* **Add-Liquidity-Only (ALO):** Also known as **"Post Only"**. The order is added to the order book only if it does not immediately match against an existing order. If it would cross, it is cancelled.
* **Top-of-Book (TOB):** An ALO order that would cross the book is placed at the best possible maker price instead of being cancelled. For a buy, that is the lowest ask minus one tick. For a sell, it is the highest bid plus one tick.
# Market
Source: https://docs.pacifica.fi/trading-on-pacifica/order-types/classic/market
Execute at available market prices when you want to enter or exit promptly.
A market order executes immediately at the best available prices. It is filled against the order book up to your **Max Slippage** setting (the default is 3%). Any part of the order that cannot be filled within that slippage is cancelled. You can also add take profit and stop loss orders with **TP/SL**.

BTC market order form.
# RFQ
Source: https://docs.pacifica.fi/trading-on-pacifica/order-types/classic/rfq
Request liquidity and review an estimate before submitting a market order.
RFQ (Request for Quote) lets you request liquidity for your order size before trading. It is available on supported markets.
## How it works
1. Select **RFQ** from the order-type dropdown, choose **Buy / Long** or **Sell / Short**, and enter your size.
2. Pacifica requests liquidity automatically. The request refreshes when you edit the order.
3. When the form shows **Ready to execute**, review the estimate and submit your order.
4. Your order executes as a market order, subject to your **Max Slippage** setting.
> [!NOTE]
>
> The displayed price is an estimate from the public order book, not a locked quote or a guaranteed fill price.
## Settings
| Setting | What it does |
| - | - |
| **Size** | The amount you want to buy or sell. |
| **Max Slippage** | Limits how far the execution price can move against you. |
| **Reduce Only** | Restricts the order to reducing an existing position. |
## Good to know
* Requesting liquidity does not place a trade. You still need to submit the order.
* If liquidity is unavailable, the form cannot proceed until a fresh request is ready.
* An order can fill partially. Any amount that cannot fill within your slippage limit is cancelled.
# Scale
Source: https://docs.pacifica.fi/trading-on-pacifica/order-types/classic/scale
Place up to 100 limit orders across a price range from one form, with control over how prices and sizes are distributed.
A Scale order lays a ladder of limit orders across a price range. Instead of picking one price, you set a **Min Price** and **Max Price**, choose how many orders to place, and Pacifica spreads your total size across them. Use it to build a position gradually into a dip, or to scale out of a position as the price rises.

BTC Scale form with price range, order count and distribution settings. The form shows the ladder's average price.
## How it works
1. Enter the total **Amount** you want to trade and the price range.
2. Choose the **Order Count** (2 to 100). Your amount is split into that many limit orders.
3. Optionally skew the ladder with the two distribution sliders (see below).
4. Click **Long / Buy** or **Short / Sell**. Pacifica submits the ladder as **GTC** limit orders. Orders that match available prices can fill immediately; the remainder rests on the book.
Once placed, the orders are independent. They show up in **Open Orders**, fill on their own as the market trades through them, and can be cancelled individually or all at once.
## Settings
| Setting | Range | What it does |
| - | - | - |
| **Min Price / Max Price** | Max must be above Min | The lowest and highest limit price in the ladder. Prices are rounded to the market's tick size. |
| **Order Count** | 2 to 100 | How many limit orders to place. Every order must still meet the market's minimum order size, so very small amounts limit the count. |
| **Price Distribution** | -100% to +100% | Where the prices cluster. **Even** (0%) spaces them uniformly. **Lower** bunches more orders toward Min Price. **Higher** bunches them toward Max Price. The further from 0%, the stronger the skew. |
| **Amount Distribution** | -100% to +100% | How size is allocated. **Even** (0%) gives every order the same size. **Lower** puts more size on the lower-priced orders. **Higher** puts more size on the higher-priced orders. |
| **Reduce Only** | On / Off | Makes every order in the ladder reduce-only. Requires an open position on the opposite side. |
The form shows an **Avg Price** estimate. Review the prices and amounts before submitting the ladder.
## Example
You want to buy 0.5 BTC if the price pulls back from \$100,000 into the \$95,000 to \$99,500 range, and you want more size the lower it goes:
* **Min Price** \$95,000, **Max Price** \$99,500, **Order Count** 10.
* **Price Distribution** 0% (even spacing, one order every \$500).
* **Amount Distribution** -50% (Lower), so the order at \$95,000 is about six times the size of the order at \$99,500: roughly 0.0857 BTC and 0.0143 BTC, before lot-size rounding.
If the price only dips to \$98,000, only the higher-priced orders are likely to fill. The lower orders remain open until filled or cancelled.
## Good to know
* Prices and amounts are rounded to the market's tick and lot sizes. A narrow range can produce multiple orders at the same price.
* A Scale ladder is a set of ordinary limit orders, so it appears in **Open Orders**, not in the **Strategies** tab.
* Limit orders pay maker fees when they rest and fill. A buy at or above the best ask, or a sell at or below the best bid, can fill immediately and pay taker fees.
* Orders are accepted individually. Check **Open Orders** and **Trade History** to confirm the ladder, especially if any order is rejected.
# Stop Limit
Source: https://docs.pacifica.fi/trading-on-pacifica/order-types/classic/stop-limit
Combine a price trigger with a limit price for the order placed when it triggers.
A stop limit order places a limit order when a trigger price is reached. Set the **Price** (the limit price of the order that will be placed), the **Stop Price** (the trigger) and the **Trigger Condition** price source. Because the resulting order is a limit order, it may not fill if the market moves through your limit price after the trigger.

BTC stop limit order form with separate limit and stop prices.
# Stop Market
Source: https://docs.pacifica.fi/trading-on-pacifica/order-types/classic/stop-market
Place a market order when a trigger price is reached, for a stop loss, take profit or entry.
A stop market order sends a market order when a trigger price is reached. Set the **Stop Price** and pick the **Trigger Condition** price source: **Last** (last trade price, the default), **Mark** or **Mid**. Once triggered, it places a market order. Stop Market uses an 8% slippage limit, rather than the **Max Slippage** setting for a manually placed market order. Use it to take profit, limit losses or enter on a price move.

BTC stop market order form.
# TWAP
Source: https://docs.pacifica.fi/trading-on-pacifica/order-types/classic/twap
Spread an order over 1 minute to 24 hours using smaller market orders placed over time.
A TWAP (time-weighted average price) order splits your amount into smaller market orders, called slices. Use it to spread execution over time. Your average fill price depends on the prices and liquidity available when each slice executes.

BTC TWAP form with running time and max slippage per slice.
## How it works
1. Enter the total **Amount** and the **Running Time**, from 1 minute to 24 hours.
2. Choose your **Max Slippage**. It applies to each market order individually.
3. Submit the TWAP. Pacifica places slices over the running time, subject to the schedule and settings below.
4. Check the filled amount and status. A TWAP can finish with part of the amount unfilled.
## Slice schedule
TWAPs plan between 2 and 100 slices across the running time, subject to lot-size and minimum-order requirements. The slices are scheduled from the start to the end of the window. Longer TWAPs therefore have wider gaps between slices. Slice sizes are fixed when you submit, so an unfilled amount is not redistributed to later slices. The running time sets the planned spacing; it is not an automatic cancellation deadline.
## Settings
| Setting | What it does |
| - | - |
| **Running Time** | Sets the planned execution time, from 1 minute to 24 hours. |
| **Price Limit** | Pauses a buy while the mark price is at or above the limit, or a sell while it is at or below the limit. Execution can resume when the price returns inside the boundary. |
| **Randomize Slices** | Varies slice sizes and intervals. Sizes are roughly 50% to 150% of the average, subject to lot-size and minimum-order requirements. Gaps range from 0.5× to 1.5× the base interval. |
| **Reduce Only** | Restricts each slice to reducing an existing position. |
| **Max Slippage** | Limits slippage on each market order. It does not set a fixed execution price for the whole TWAP. |
## Example
You want to sell 1 BTC over 90 minutes:
* Set **Amount** to 1 BTC and **Running Time** to 1 hour 30 minutes.
* With **Randomize Slices** off, the schedule plans 100 slices of 0.01 BTC about 54.5 seconds apart. These planned amounts do not increase to make up for partial fills.
## Good to know
* Market-order fills pay taker fees and appear in **Trade History**.
* Manage TWAPs in **Strategies**, under **TWAP**. The shared limit of 100 open strategies per account applies.
* Cancelling stops further execution. Trades already filled remain in your account.
* Pauses and randomized timing can change the actual duration. If you need execution to stop, cancel the strategy and check its status.
# Strategies
Source: https://docs.pacifica.fi/trading-on-pacifica/order-types/strategies
Use price tracking, conditional triggers, sequential execution or baskets to manage more complex orders.
Strategies give you more control over how an order follows the market, when it starts, and how it trades across one or more markets. Choose a type below for its settings and examples.
## At a glance
| Order type | What it does | Typical use |
| - | - | - |
| [Chase](/trading-on-pacifica/order-types/strategies/chase) | Reprices a post-only limit order as the best bid or ask changes | Seek a maker fill |
| [Conditional Market](/trading-on-pacifica/order-types/strategies/conditional-market) | Places a market order when a chosen market meets a price condition | Trigger a market order on another market or price source |
| [Conditional Limit](/trading-on-pacifica/order-types/strategies/conditional-limit) | Places a limit order when a chosen market meets a price condition | Combine a price condition with a limit price |
| [OCO](/trading-on-pacifica/order-types/strategies/oco) | Places the first of two stop legs to trigger and cancels the other | Set two alternative orders |
| [Trailing Stop](/trading-on-pacifica/order-types/strategies/trailing-stop) | Tracks the market at a fixed distance and triggers on a reversal | Adjust a stop as the market moves |
| [Swarm](/trading-on-pacifica/order-types/strategies/swarm) | Places small market orders in quick succession | Split a fast execution into smaller orders |
| [Trigger Swarm](/trading-on-pacifica/order-types/strategies/trigger-swarm) | Waits for a price trigger, then places market orders one at a time | Combine a trigger with split execution |
| [Atomic](/trading-on-pacifica/order-types/strategies/atomic) | Submits market orders across several markets together | Pair trades and baskets |
> [card] [Chase](/trading-on-pacifica/order-types/strategies/chase)
>
> Follow the best bid or ask with a post-only limit order.
> [card] [Conditional Market](/trading-on-pacifica/order-types/strategies/conditional-market)
>
> Place a market order when a chosen market meets a price condition.
> [card] [Conditional Limit](/trading-on-pacifica/order-types/strategies/conditional-limit)
>
> Place a limit order when a chosen market meets a price condition.
> [card] [OCO](/trading-on-pacifica/order-types/strategies/oco)
>
> Set two alternative stop orders; the first to trigger cancels the other.
> [card] [Trailing Stop](/trading-on-pacifica/order-types/strategies/trailing-stop)
>
> Track the market with a stop that adjusts as the price moves in your favor.
> [card] [Swarm](/trading-on-pacifica/order-types/strategies/swarm)
>
> Place small market orders in quick succession.
> [card] [Trigger Swarm](/trading-on-pacifica/order-types/strategies/trigger-swarm)
>
> Wait for a price condition, then place market orders one at a time.
> [card] [Atomic](/trading-on-pacifica/order-types/strategies/atomic)
>
> Submit a basket of market orders across several markets together.
## Managing strategies
Chase, conditional orders, OCO, Trailing Stop, Swarm and Trigger Swarm manage execution for you. [TWAP](/trading-on-pacifica/order-types/classic/twap) also uses the **Strategies** tab. Atomic submits ordinary market orders, with each leg shown in **Positions** and **Trade History**.
* **Where to find them.** Open strategies appear in the **Strategies** tab, grouped by type. Resting orders appear in **Open Orders**, and fills appear in **Trade History**.
* **Status.** The table shows whether a strategy is waiting, running, paused or finished. Check its status and filled amount to see what has executed.
* **Cancelling.** Cancel an open strategy from the **Strategies** tab. Cancellation also cancels its resting orders. Trades already filled remain in your account.
* **Slippage.** Market orders placed by these strategies use your **Max Slippage** setting. A trigger or a completed schedule does not guarantee that the full amount fills.
* **Limits.** Each account can have at most 100 open strategies at a time.
* **Reduce Only.** Restricts fills to reducing an existing position. You cannot combine it with an attached **TP/SL**.

The Strategies tab groups open strategies by type.
# Atomic
Source: https://docs.pacifica.fi/trading-on-pacifica/order-types/strategies/atomic
Submit a weighted basket of market orders together for a pair trade or a position across several markets.
An Atomic order submits several market orders across different markets together. You build a basket of **long** legs and **short** legs, give each leg a weight, and enter one **Total size** in USD. Pacifica splits the total across the legs by weight, converts each leg to a token amount at its mark price, and submits every leg together in one batch.

Atomic form with a BTC long and an ETH short. The form shows each leg's size, leverage and the total margin required.
> [!NOTE]
>
> Atomic does not guarantee an all-or-nothing fill. One leg can fill even if another is rejected or only partially filled.
## How it works
1. The market you are viewing is added as the first long leg. Use **Add long** and **Add short** to add more legs, up to 5 on each side, and click a leg's symbol to swap it for another market.
2. Set each leg's **weight**. Weights are relative, so they do not have to add up to 100. The form shows each leg's effective share, USD notional, token amount, leverage and estimated liquidation price.
3. Enter the **Total size** in USD, or use the slider and percentage buttons. 100% sizes the basket to the largest notional your idle margin allows across all legs. **Rebalance** resets every leg to an equal weight.
4. Click **Execute Atomic Order**. Each leg is signed as a market order with your **Max Slippage**, and all legs are sent to the exchange in a single batch request. Each leg can fill or fail independently.
## Settings
| Setting | What it does |
| - | - |
| **Long / Short legs** | Up to 5 markets per side. A market can appear only once in the basket. |
| **Weight** | Each leg's share of the total size, relative to the sum of all weights. |
| **Total size** | The USD notional of the whole basket. |
| **Reduce Only** | Every leg is reduce-only, so the basket only closes existing positions. |
| **Max Slippage** | Applies to every leg individually. |
The **Margin** row shows the total initial margin the basket needs: each leg's notional divided by that market's leverage, summed.
## Example
You want a basket with \$1,000 of total notional, split equally between a BTC long and an ETH short:
* Set the long leg to **BTC** with weight 50, the short leg to **ETH** with weight 50 and **Total size** to \$1,000.
* The form shows \$500 of BTC and \$500 of ETH, with the token amounts calculated from their current mark prices.
* On **Execute Atomic Order**, both market orders are submitted together.
## Good to know
* Each leg is an ordinary market order on its own market. Fills are shown per market in **Trade History**, and the positions appear separately in **Positions**.
* Legs are validated independently by the engine. If one leg is rejected (for example, it is below that market's minimum order size or you lack margin), other legs may still execute. Check **Trade History** and **Positions** after submitting a basket.
* Each leg's slippage protection applies to that leg alone, so a thin market in the basket can be partially filled while the others fill completely.
* Atomic orders are not strategies. They do not appear in the **Strategies** tab.
# Chase
Source: https://docs.pacifica.fi/trading-on-pacifica/order-types/strategies/chase
Automatically reprice a post-only limit order to follow the best bid or ask while seeking a maker fill.
A Chase order follows the best bid for a buy or the best ask for a sell. Pacifica reprices the unfilled amount as that price changes. Orders are post-only, so fills pay maker fees. A fill is not guaranteed.

BTC Chase form with a price boundary and a choice to pause or cancel when it is crossed.
## How it works
1. When you place the order, Pacifica places a post-only (ALO) limit order at the current best bid (for a buy) or best ask (for a sell).
2. When the best bid or ask changes, Pacifica reprices your order. Only the unfilled remainder is moved, so partial fills are kept.
3. The order finishes when the whole amount has filled, when you cancel it, or when a price boundary cancels it. A boundary can also pause repricing.
Because the order is always post-only, it never takes liquidity. It can only be filled by someone else crossing the spread into it.
## Settings
| Setting | Options | What it does |
| - | - | - |
| **Chase until** | **To Price** or **Till Fill** | **To Price** stops chasing at a limit you set. **Till Fill** keeps chasing until the order is fully filled or you cancel it, with no price boundary. |
| **Chase To Price** | Positive price | The furthest price you are willing to chase to. For a buy it is a ceiling, for a sell it is a floor. The form pre-fills this at 0.5% away from the current price. Reaching the price exactly is still allowed. Only moving past it triggers the breach action. |
| **If price moves above / below Chase To Price** | **Pause** or **Cancel** | What happens when the best bid or ask moves past your boundary. **Pause** stops repricing but leaves the resting order able to fill. Repricing resumes when the price returns inside the boundary. **Cancel** ends the strategy and cancels the resting order. |
| **Reduce Only** | On / Off | Only reduces an existing position. Cannot be combined with **TP/SL**. |
| **TP/SL** | Optional | A take profit and/or stop loss attached to the position the chase opens. They stay attached when the order is repriced. |
## Example
BTC has a best bid of \$100,000 and a best ask of \$100,010. You want to buy 0.1 BTC without crossing the spread:
* Place a **Chase** buy for 0.1 BTC, with **To Price** set to \$100,500 and breach action **Cancel**.
* Your order rests at \$100,000. If the bid ticks up to \$100,001, your order follows to \$100,001.
* If sellers hit your bid, you fill as a maker. If the best bid goes above \$100,500, the chase is cancelled and you can decide what to do next.
## Good to know
* Each reprice replaces the resting order, so your order joins the back of the queue at the new price level.
* A Chase can partially fill many times on its way to completion. Every fill shows up in **Trade History** and counts toward the total.
* Chase orders can also be created from the **Positions** panel to reduce a position with a post-only order.
* Chase orders appear under the **Strategies** tab (**Auto Chase** sub-tab) while they are working.
# Conditional Limit
Source: https://docs.pacifica.fi/trading-on-pacifica/order-types/strategies/conditional-limit
Place a limit order when a chosen market meets a price condition, with control over the limit price and time-in-force.
A Conditional Limit order waits for a price condition, then places a limit order at the **Price** and **TIF** you choose. Select **Cond. Limit** in the order form.
Unlike a [Stop Limit](/trading-on-pacifica/order-types/classic/stop-limit) order, the trigger can watch a **different market** from the one you trade. It can also use the **best bid** or **best ask**, and the resulting order can use any time-in-force.

BTC Conditional Limit form with separate trigger and limit prices.
## How it works
1. Pick the **Trigger Symbol**. It defaults to the market you are trading, but you can watch another market on Pacifica.
2. Choose **≥ Above** or **≤ Below**, then enter the **Trigger Price**.
3. Choose the **Trigger Condition** price source: **Mid**, **Mark**, **Last**, **Best Bid** or **Best Ask**.
4. Enter the **Amount**, limit **Price** and **TIF**, then choose your side.
5. When the chosen price meets the condition, Pacifica submits the limit order. Its time-in-force determines what happens to any unfilled amount.
If the condition is already true when you submit, the form warns you and the order can trigger as soon as the condition is evaluated. The strategy submits one order and does not trigger again.
## Settings
| Setting | Options | What it does |
| - | - | - |
| **Trigger Symbol** | Any market | The market whose price is watched. Can differ from the market you trade. |
| **≥ Above / ≤ Below** | Above / Below | Trigger when the watched price is at or above, or at or below, the trigger price. |
| **Trigger Price** | Positive price | The level to watch. |
| **Trigger Condition** | **Mid**, **Mark**, **Last**, **Best Bid**, **Best Ask** | The price source compared against the trigger price. |
| **Price** | Positive price | The limit price of the order placed after the trigger. |
| **TIF** | **GTC**, **IOC**, **ALO**, **TOB** | How the limit order is handled. See [Time-in-force](/trading-on-pacifica/order-types/classic/limit#time-in-force-tif). |
| **Reduce Only** | On / Off | Only reduces an existing position. Cannot be combined with **TP/SL**. |
| **TP/SL** | Optional | Take profit and stop loss attached to the resulting order. Its trigger source can be **Mark**, **Last** or **Mid**. |
## Example
You expect BTC to bounce after a dip and want to place a limit buy when its mid price reaches \$95,000:
* Select **Cond. Limit**, with **Trigger Symbol** set to BTC, **≤ Below** \$95,000 and **Trigger Condition** set to **Mid**.
* Set **Price** to \$94,900, **TIF** to **GTC** and **Amount** to 0.1 BTC.
* When mid reaches \$95,000 or lower, a GTC limit buy at \$94,900 is placed. Any unfilled amount rests until it fills or you cancel it.
## Good to know
* Reaching the trigger does not guarantee a fill. The market may move away from your limit price.
* Use **ALO** for a post-only order or **TOB** for a top-of-book order. See [Time-in-force](/trading-on-pacifica/order-types/classic/limit#time-in-force-tif).
* Open conditional orders appear in **Strategies**, under **Conditional Orders**. A resting limit order appears in **Open Orders** after the trigger.
* To place a market order when the condition is met, use [Conditional Market](/trading-on-pacifica/order-types/strategies/conditional-market).
# Conditional Market
Source: https://docs.pacifica.fi/trading-on-pacifica/order-types/strategies/conditional-market
Place a market order when a chosen market meets a price condition, including a trigger on a different market.
A Conditional Market order waits for a price condition, then places a market order using your **Max Slippage** setting. Select **Cond. Market** in the order form.
Unlike a [Stop Market](/trading-on-pacifica/order-types/classic/stop-market) order, the trigger can watch a **different market** from the one you trade. It can also use the **best bid** or **best ask**, as well as mid, mark and last trade prices.

BTC Conditional Market form with a trigger symbol, price and condition.
## How it works
1. Pick the **Trigger Symbol**. It defaults to the market you are trading, but you can watch another market on Pacifica.
2. Choose **≥ Above** or **≤ Below**, then enter the **Trigger Price**.
3. Choose the **Trigger Condition** price source: **Mid**, **Mark**, **Last**, **Best Bid** or **Best Ask**.
4. Enter the **Amount** and choose your side.
5. When the chosen price meets the condition, Pacifica submits the market order.
If the condition is already true when you submit, the form warns you and the order can trigger as soon as the condition is evaluated. The strategy submits one order and does not trigger again.
## Settings
| Setting | Options | What it does |
| - | - | - |
| **Trigger Symbol** | Any market | The market whose price is watched. Can differ from the market you trade. |
| **≥ Above / ≤ Below** | Above / Below | Trigger when the watched price is at or above, or at or below, the trigger price. |
| **Trigger Price** | Positive price | The level to watch. |
| **Trigger Condition** | **Mid**, **Mark**, **Last**, **Best Bid**, **Best Ask** | The price source compared against the trigger price. |
| **Reduce Only** | On / Off | Only reduces an existing position. Cannot be combined with **TP/SL**. |
| **TP/SL** | Optional | Take profit and stop loss attached to the resulting order. Its trigger source can be **Mark**, **Last** or **Mid**. |
## Example
You want to buy 0.1 BTC if its mid price falls to \$95,000:
* Select **Cond. Market**, with **Trigger Symbol** set to BTC.
* Choose **≤ Below**, set **Trigger Price** to \$95,000 and **Trigger Condition** to **Mid**.
* Set **Amount** to 0.1 BTC and choose **Buy**.
* When the mid price reaches \$95,000 or lower, Pacifica places a market buy. The fill price depends on available liquidity and your **Max Slippage**.
## Good to know
* The trigger price determines when the order is placed. It is not a guaranteed fill price.
* Any amount that cannot fill within your slippage limit is cancelled.
* Open conditional orders appear in **Strategies**, under **Conditional Orders**.
* To set a limit price for the resulting order, use [Conditional Limit](/trading-on-pacifica/order-types/strategies/conditional-limit).
# OCO (One-Cancels-the-Other)
Source: https://docs.pacifica.fi/trading-on-pacifica/order-types/strategies/oco
Set two alternative stop orders so that the first to trigger cancels the other.
An OCO order lets you set two stop orders at the same time on the same market. Each leg has its own stop price, side and order type. The first leg whose trigger is crossed is placed as an order, and the other leg is cancelled. You can use it to trade a breakout in either direction, to buy below or sell above the current price, or to bracket an open position with a take profit and a stop loss.

BTC OCO form with two alternative stop orders. The first to trigger cancels the other.
## How it works
1. Pick a preset or configure the two legs by hand.
2. For each leg choose **Stop Market** or **Stop Limit**, **Buy** or **Sell**, and a **Stop Price** (plus a **Limit Price** for stop limit legs).
3. Choose the **Trigger Condition** price source shared by both legs: **Mid** or **Mark**.
4. Enter the **Amount**. Both legs use the same size.
5. Pacifica watches the market. When one leg's stop price is crossed, Pacifica submits that leg and cancels the other. A stop market leg places a market order using your **Max Slippage**. A stop limit leg places a **GTC** limit order at its limit price.
If both conditions are met in the same evaluation, **Leg 1** takes priority.
> [!NOTE]
>
> The other leg is cancelled when the first leg triggers, before a fill is confirmed. If the triggered order is rejected or does not fill, the cancelled leg does not become active again.
## Presets
The three buttons fill in both legs 5% away from the current mark price. Edit any field afterwards.
| Preset | Leg 1 | Leg 2 | Use |
| - | - | - | - |
| **Breakout** | Stop Market **Buy** above the market | Stop Market **Sell** below the market | Enter in the direction of the break. |
| **Retracement** | Stop Limit **Buy** below the market | Stop Limit **Sell** above the market | Buy below or sell above the current price. |
| **Bracket exit** | Stop Limit **Sell** above the market (take profit) | Stop Market **Sell** below the market (stop loss) | Exit a long position either way. Turns on **Reduce Only**. Flip both legs to Buy for a short. |
## Settings
| Setting | Options | What it does |
| - | - | - |
| **Leg type** | Stop Market, Stop Limit | Whether the leg places a market order or a resting limit order. |
| **Side** | Buy, Sell | Per leg. The two legs can be on the same side (bracket) or opposite sides (breakout, retracement). |
| **Stop Price** | Positive price | The trigger for that leg. The form shows whether it is above or below the current mark. |
| **Limit Price** | Positive price | Stop limit legs only. The price of the limit order placed after the trigger. |
| **Trigger Condition** | **Mid**, **Mark** | Shared by both legs. |
| **Reduce Only** | On / Off | Applies to both legs. |
## Example
You are long 0.1 BTC at \$100,000. You want to take profit at \$105,000 and stop out at \$95,000:
* Choose **Bracket exit**, then set **Leg 1** to Stop Limit **Sell** with **Stop Price** and **Limit Price** both at \$105,000. Set **Leg 2** to Stop Market **Sell** with **Stop Price** at \$95,000.
* Set **Amount** to 0.1 BTC, **Trigger Condition** to **Mid** and **Reduce Only** on.
* If mid reaches \$105,000 first, a limit sell at \$105,000 is placed and the stop loss is cancelled. If mid falls to \$95,000 first, a market sell is placed and the take profit is cancelled. Either order may fill partially.
## Good to know
* Only the triggered leg becomes an order. Until then an OCO holds no place in the order book queue.
* A stop limit leg rests as a GTC limit order after it triggers. If the market moves through the limit price, it may not fill.
* Open OCOs appear under the **Strategies** tab (**OCO** sub-tab). After a leg triggers, the resulting order appears in **Open Orders** or **Trade History**.
* OCO stop legs use Mid or Mark as the trigger source. Last trade price is not available for OCO.
# Swarm
Source: https://docs.pacifica.fi/trading-on-pacifica/order-types/strategies/swarm
Split an order into small market orders placed in quick succession, with optional randomization and a price boundary.
A Swarm splits an amount into smaller market orders, called clips. You choose how many clips to place and how quickly to place them, from 1 to 10 clips per second. Each clip has slippage protection. Execution price still depends on the liquidity available when each clip reaches the market.

BTC Swarm form with clip count, placement speed and an estimated duration.
## How it works
1. Enter the total **Amount**, the **Number Of Clips** (2 to 100) and the **Placement Speed** (1 to 10 clips per second).
2. Pacifica divides your amount into clips. Without randomization, the clips are evenly sized, subject to lot-size rounding, and scheduled at regular intervals.
3. Each clip is placed as a market order using your **Max Slippage**. Actual placement can be slower than the selected speed while earlier orders are being processed.
4. The Swarm completes when the cumulative fills reach the target amount.
## Settings
| Setting | Range | What it does |
| - | - | - |
| **Number Of Clips** | 2 to 100 | How many market orders the amount is split into. Every clip must be at least one lot and meet the market's minimum order size. |
| **Placement Speed** | 1 to 10 clips / sec | The target rate for placing clips. The form estimates about 3 seconds for 25 clips at 10 per second. |
| **Randomize Clips** | On / Off | Varies both the clip sizes and the gaps between them instead of using a fixed pattern. Sizes vary between roughly 50% and 150% of the average clip, and each gap between 0.5× and 1.5× the base interval. Lot-size rounding and minimum order sizes can limit the variation. |
| **Mark Price Boundary** | Positive price, optional | A limit on how far the mark price may move against you. For a buy it is a ceiling, for a sell it is a floor. Touching the boundary counts as crossing it. |
| **When the boundary is crossed** | **Pause** or **Cancel** | **Pause** holds the remaining clips while the mark is beyond the boundary and resumes when it comes back. **Cancel** ends the Swarm, keeping the fills so far. |
| **Reduce Only** | On / Off | Every clip is reduce-only. Cannot be combined with **TP/SL**. |
| **TP/SL** | Optional | Take profit and stop loss for the position the Swarm builds. |
The form shows the **Avg Clip Size**, the **Est. Duration** and an **Est. Slippage** comparison against a single market order of the same size.
## Example
You want to buy 1 BTC quickly in smaller orders:
* Select **Swarm**, with **Amount** 1 BTC, **Number Of Clips** 25, **Placement Speed** 10 clips per second and **Randomize Clips** on.
* Set **Mark Price Boundary** to \$101,000 and action **Pause**.
* The average clip is 0.04 BTC and the target interval is 0.1 seconds; randomization varies both. If the mark price rises to \$101,000 during execution, the remaining clips wait until it drops back below, then continue.
## Good to know
* Each clip is an independent market order. Every fill appears in **Trade History**, and a clip can be partially filled if the book is thin within your slippage.
* Temporary order rejections can delay execution. Repeated rejections or insufficient balance can end the strategy before the full amount fills. Check its status and filled amount.
* Swarms are listed in the **Strategies** tab under **Swarm**, showing clips placed, filled amount and average fill price.
* For execution over minutes or hours, use [TWAP](/trading-on-pacifica/order-types/classic/twap). To start after a price condition is met, use [Trigger Swarm](/trading-on-pacifica/order-types/strategies/trigger-swarm).
# Trailing Stop
Source: https://docs.pacifica.fi/trading-on-pacifica/order-types/strategies/trailing-stop
Track a market with a stop at a fixed percentage or dollar distance, then place a market order when the price reverses.
A trailing stop moves with the market. For a **sell** (protecting a long), the stop tracks the highest price seen and sits a fixed distance below it. As the price rises, the stop rises with it. When the price falls back by the trail distance, the stop triggers. For a **buy**, the stop tracks the lowest price and sits a fixed distance above it. The stop only ever moves in your favor. It never loosens.

BTC Trailing Stop form with trail distance and an optional activation price.
## How it works
1. Set the **Trail Amount**, as a percentage or a dollar amount, and the **Trigger Condition** price source (**Mid** or **Mark**).
2. Optionally set an **Activation Price**. Until the market reaches it, the trailing stop is dormant. A sell activates once the price rises to the activation price, and a buy once the price falls to it. With no activation price, tracking starts immediately.
3. Once active, Pacifica records the extreme price (the peak for a sell, the trough for a buy) and derives the stop level from it: peak minus trail for a sell, trough plus trail for a buy. The stop is updated on every new extreme.
4. When the price retraces to the stop level, a **market order** is placed for the full amount, using your **Max Slippage**. The order may fill only partially.
A trailing stop triggers once. It does not become active again after submitting the market order.
## Settings
| Setting | Options | What it does |
| - | - | - |
| **Trail Amount** | USD or % | The distance between the extreme price and the stop. Enter a positive dollar amount, or a percentage from 0.01% to 99.99% in increments of 0.01%. |
| **Activation Price** | Optional | The price that must be reached before tracking begins. |
| **Trigger Condition** | **Mid**, **Mark** | The price source used both to track the extreme and to detect the retracement. |
| **Reduce Only** | On / Off | **On** makes it a trailing exit: it can only close an existing position. **Off** makes it a trailing entry that opens a position on the retracement. |
The form describes the resulting behavior in words. For example, you can set a sell to activate at a mid price of \$110,000, then trail 2% below the peak.
## Trailing exit from the Positions panel
You can also attach a trailing stop directly to an open position from the **Positions** table (**Trailing Stop** tab of the **TP/SL** dialog). A position trailing stop submits a reduce-only market order for the **full position size at trigger time**. A full fill is still subject to available liquidity and slippage.
## Example
You are long 0.1 BTC at \$100,000 and want a stop that stays 2% below the highest price reached:
* Select **Trailing Stop**, side **Sell**, **Trail Amount** 2%, **Trigger Condition** **Mid**, **Reduce Only** on and **Amount** 0.1 BTC.
* BTC rallies to \$110,000. The stop is now \$107,800. BTC keeps going to \$120,000. The stop is now \$117,600.
* BTC pulls back to \$117,600. A reduce-only market sell for 0.1 BTC is placed. Its fill price may differ from \$117,600, and it may fill only partially.
## Good to know
* The stop places a market order, so the fill can be worse than the stop level in a fast market, up to your **Max Slippage**.
* Trailing stops are listed in the **Strategies** tab under **Trailing Stop**. There you can see the current extreme and the current stop level.
* Trailing stops use Mid or Mark as the price source. Last trade price is not available.
# Trigger Swarm
Source: https://docs.pacifica.fi/trading-on-pacifica/order-types/strategies/trigger-swarm
Wait for a price condition, then place an amount as a sequence of small market orders, one at a time.
A Trigger Swarm combines a [conditional trigger](/trading-on-pacifica/order-types/strategies/conditional-market) with clip-by-clip market execution. Execution starts when the watched price meets your condition. Then Pacifica works the order in a series of market clips, sending the next clip only after the previous one has settled. Use it to split an order into smaller trades after a price trigger.

BTC Trigger Swarm form with a price condition and clip count.
## How it works
1. Set the trigger exactly as for a conditional order: **Trigger Symbol** (any market), **≥ Above** or **≤ Below**, **Trigger Price**, and the **Trigger Condition** price source (**Mid**, **Mark**, **Last**, **Best Bid** or **Best Ask**).
2. Set the total **Amount** and the **Clip Count** (2 to 100).
3. When the condition is met, the strategy starts placing clips. A condition that is already met can trigger immediately.
4. Clips are placed sequentially. Each clip is a market order with your **Max Slippage** for the remaining amount divided by the remaining clips. The next clip is sent as soon as the previous one has settled. If a clip only partially fills, the shortfall rolls into the remaining clips.
5. The strategy completes when the target amount has filled.
## Settings
| Setting | Options | What it does |
| - | - | - |
| **Trigger Symbol** | Any market | The market whose price is watched. Can differ from the market you trade. |
| **≥ Above / ≤ Below** | Above / Below | Direction of the trigger. |
| **Trigger Price** | Positive price | The level to watch. |
| **Trigger Condition** | **Mid**, **Mark**, **Last**, **Best Bid**, **Best Ask** | The price source for the trigger. |
| **Clip Count** | 2 to 100 | How many market clips the amount is split into. Every clip must be at least one lot. |
| **Reduce Only** | On / Off | Every clip is reduce-only. Use it to close an existing position. Leave it off to open or add to a position. |
## Trigger Swarm as a position exit
From the **Positions** table you can attach a Trigger Swarm to an open position (**Trigger Swarm** tab of the **TP/SL** dialog). In that mode, its target is the **full position size at trigger time**. It is cancelled if the position is gone or has changed side before the trigger. A full exit still depends on the clips filling.
## Example
You are long 1 BTC and want to exit if the market breaks down, but want to split the exit into smaller market orders:
* Select **Trigger Swarm**, side **Sell**, **Trigger Symbol** BTC, **≤ Below** \$95,000, **Trigger Condition** **Mark**, **Clip Count** 10, **Amount** 1 BTC and **Reduce Only** on.
* When the mark price reaches \$95,000 or lower, a 0.1 BTC market sell is placed. If each clip fills in full, the next clips are also 0.1 BTC. Partial fills change the size of later clips.
## Good to know
* Until the condition is met, a Trigger Swarm holds nothing on the book and shows as *Active* in the **Strategies** tab (**Trigger Swarm** sub-tab).
* Temporary rejections can be retried. If execution ends before any clip is accepted or filled, the status is **Trigger failed**. If a clip was accepted or filled, it ends as **Cancelled**. Check the filled amount for any remaining position.
* Unlike a plain [Swarm](/trading-on-pacifica/order-types/strategies/swarm), a Trigger Swarm has no placement-speed setting. Its pace is set by how quickly each clip settles.
# Overview
Source: https://docs.pacifica.fi/trading-on-pacifica/overview
Pacifica supports perpetual and spot trading. Over thirty-five perpetual markets are currently listed, alongside a growing set of spot markets quoted in USDC.
* **Instrument types:** Perpetuals and spot (base asset vs. USDC).
* **Margin modes:** Cross margin (default; unified with spot collateral) and isolated margin. Spot is cross-only.
* **Leverage:** 3x to 50x on perpetuals, depending on market. Spot is 1x.
Detailed pages:
* [Contract Specifications](/trading-on-pacifica/contract-specifications) - perpetual contract specs and supported pairs.
* [Oracle Price & Mark Price](/trading-on-pacifica/contract-specifications/oracle-price-and-mark-price)
* [Order Types](/trading-on-pacifica/order-types)
* [Margin & Leverage](/trading-on-pacifica/margin-and-leverage)
* [Unified Margin](/trading-on-pacifica/unified-margin)
* [Spot Collateral](/trading-on-pacifica/spot-collateral)
* [Spot Trading](/trading-on-pacifica/spot-trading)
* [Money Market](/trading-on-pacifica/money-market)
* [Funding Rates](/trading-on-pacifica/funding-rates)
* [Trading Fees](/trading-on-pacifica/trading-fees)
* [Deposits & Withdrawals](/trading-on-pacifica/deposits-and-withdrawals)
* [Liquidations](/trading-on-pacifica/liquidations)
*Access to Trading on Pacifica is strictly prohibited for individuals or entities residing in, incorporated in, or operating from, but not limited to, the United States of America, Cuba, the Crimean Peninsula (including Sevastopol), Iran, Afghanistan, Syria, and North Korea (collectively, the "Restricted Jurisdictions"). Access to trading functionality from IP addresses from any Restricted Jurisdiction is programmatically restricted.*
# Self-Trade Prevention
Source: https://docs.pacifica.fi/trading-on-pacifica/self-trade-prevention
When a new order attempts to match with a resting order placed by the same account, the existing order is cancelled, and the new order proceeds as per normal.\
\
This makes sure that no trades will happen between orders from the same account.\
\
The removed order will be labelled as "Rejected" under the "Status" column in order history.
# Spot Collateral
Source: https://docs.pacifica.fi/trading-on-pacifica/spot-collateral
Each eligible spot asset contributes collateral to a cross-margin account according to four per-asset parameters. The contribution is bounded by a per-user USD cap on market value and may be boosted for the portion of the balance hedged by an opposing cross-margin short.
### Parameters
| Parameter | Description |
| - | - |
| `collateral_enabled` | If false, the asset contributes zero collateral regardless of balance or settings. |
| `ltv_ratio` | Loan-to-value ratio, between 0 and 1. Typical values: 0.90 (BTC, ETH), 0.80 (majors). |
| `spread_divisor` | Hedging bonus multiplier applied to the hedged portion of a balance. Optional. Bonus applies only when `spread_divisor > 1`. |
| `collateral_value_limit_usd` | Per-(user, asset) cap on the asset's gross market value that is eligible for collateral. Default 10,000 USD. |
Parameter values are published via `GET /api/v1/spot_assets`. The per-user cap can be raised by admin override.
### Collateral Curve
For spot balance `B`, oracle price `P`, and hedged size `H` (the portion of `B` offset by a cross-margin short perpetual in the same underlying; isolated shorts do not count):
```
base_rate = ltv_ratio * P
bonus_rate = P * (1 - ltv_ratio) * (1 - 1 / spread_divisor) (when spread_divisor > 1, else 0)
hedged_rate = base_rate + bonus_rate
capped_units = collateral_value_limit_usd / P
hedged_units = min(H, B, capped_units)
base_units = min(B, capped_units) - hedged_units
spot_collateral_value = hedged_rate * hedged_units + base_rate * base_units
```
Units beyond `capped_units` contribute no additional collateral; they remain in the account and are fully tradeable. Because `capped_units` is defined in terms of market value, the maximum collateral a single (user, asset) pair can contribute to cross margin is `ltv_ratio * collateral_value_limit_usd` (e.g. 9,000 USD at `ltv_ratio = 0.9` and the 10,000 USD default cap).
### Hedging Bonus Example
SOL with `ltv_ratio = 0.80`, `spread_divisor = 1.05`, `P = 150`. Account holds 100 SOL spot and a 50 SOL cross-margin short perpetual. Assume the balance is below the per-user cap.
```
base_rate = 0.80 * 150 = 120
bonus_rate = 150 * (1 - 0.80) * (1 - 1/1.05) ≈ 1.4286
hedged_rate = 120 + 1.4286 ≈ 121.4286
hedged_units = 50
base_units = 50
spot_collateral_value ≈ 121.4286 * 50 + 120 * 50 ≈ 12,071.4
```
Without the hedge, the same 100 SOL would contribute `120 * 100 = 12,000`. The hedge adds roughly 71.4 USD of additional collateral.
### Spot Sell Orders
Placing a spot sell order locks the base asset against the order. Locked units are excluded from `spot_collateral_value` until the order fills or is cancelled. See [Spot Trading](/trading-on-pacifica/spot-trading#balance-locks).
### Excluding an Asset From Unified Margin
Setting `unified_margin_excluded = true` on a (user, asset) pair removes its collateral contribution. The balance remains in the account and can be bought, sold, withdrawn, or transferred normally.
# Spot Trading
Source: https://docs.pacifica.fi/trading-on-pacifica/spot-trading
Spot markets trade a base asset against USDC on Pacifica's performant orderbooks.
### Order Types
Spot markets accept Market, Limit, Stop Market, and Stop Limit orders with TIF settings GTC, IOC, ALO, and TOB. See [Order Types](/trading-on-pacifica/order-types) for more. Orders flagged `reduce_only` on a spot market are rejected.
### Fees
Spot fees are deducted from the received asset at the end of a trade.
```
buy: received_base = (usdc_spent / price) * (1 - fee_rate)
sell: received_usdc = (base_sold * price) * (1 - fee_rate)
```
Fee tiers follow the perpetual fee schedule. See [Trading Fees](/trading-on-pacifica/trading-fees).
### Balance Locks
Placing a spot order locks the relevant balance until the order fills or is cancelled.
| Side | Locked balance | Effect on cross margin |
| - | - | - |
| Buy | `size * price` in USDC | Reduces `available_to_spend` and `available_to_withdraw` by the locked USDC. |
| Sell | `size` in base asset | Reduces `spot_collateral_value` by the locked units' LTV-adjusted value. |
# Trading Fees
Source: https://docs.pacifica.fi/trading-on-pacifica/trading-fees
Your trading volume on Pacifica determines your fee tier.\
\
Fee tiers update daily based on an account's volume over the past 30 days.\
\
All subaccounts share the same fee tier as the master account.\
Subaccount volumes count toward the master account total for fee calculations.
| Tier | 30-day Rolling Volume | Maker Fee | Taker Fee |
| - | - | - | - |
| 1 | 0 | 0.015% | 0.040% |
| 2 | > \$5,000,000 | 0.012% | 0.038% |
| 3 | > \$10,000,000 | 0.009% | 0.036% |
| 4 | > \$25,000,000 | 0.006% | 0.034% |
| 5 | > \$50,000,000 | 0.003% | 0.032% |
| VIP 1 | > \$100,000,000 | 0.000% | 0.030% |
| VIP 2 | > \$250,000,000 | 0.000% | 0.029% |
| VIP 3 | > \$500,000,000 | 0.000% | 0.028% |
Note:
* All volume thresholds refer to your total executed trading volume in USD equivalent.
* Fees are settled automatically for each trade upon execution.
# Unified Margin
Source: https://docs.pacifica.fi/trading-on-pacifica/unified-margin
Unified margin is a generalization of cross margin across spot and perp assets. Pacifica users' account's USDC balance, unrealized PnL, and spot holdings are margined together in a unified account.
### Account Equity
```
equity_without_spot = usdc_balance + unrealized_pnl_from_cross_perps - pending_interest
account_equity = equity_without_spot + spot_collateral_value
```
`pending_interest` is interest that has accrued on outstanding borrows but has not yet been settled against the USDC balance. It is deducted from equity the moment it accrues. See [Money Market](/trading-on-pacifica/money-market).
Spot collateral value is computed per asset using a piecewise curve based on LTV ratio, a per-user collateral cap, and an optional hedging bonus for delta-neutral positions. See [Spot Collateral](/trading-on-pacifica/spot-collateral).
### Implicit Borrowing
Pacifica's implicit borrowing mechanism allows for greater capital efficiency when spot assets are used as margin for perpetual positions. Perp positions can be opened against spot margin with no initial borrow.
The exception to this is isolated perp positions, where the entire margin required is borrowed upfront upon the position being opened.
An account is treated as a borrower whenever `equity_without_spot < 0`. The shortfall `required_borrow = max(0, -equity_without_spot)` is covered implicitly by the money market. This can happen because the USDC balance goes negative, cross perp losses exceed USDC, or accrued interest pushes equity below zero. Interest accrues on the outstanding amount from that point. No user action is required, and no explicit borrow transaction is submitted.
Implicit borrowing only proceeds if the account holds enough spot collateral to cover the borrow under effective LTV. An account without adequate spot collateral is flagged for deleveraging. See [Liquidations](/trading-on-pacifica/liquidations#spot-insolvency-deleveraging).
### Carry and Hedged Positions
Because spot and perpetual PnL are netted in a single equity figure, a long spot position paired with a short perpetual on the same underlying functions as a carry trade without requiring the user to collateralize each leg separately. The matched portion of the hedge also receives an elevated LTV rate. See [Spot Collateral](/trading-on-pacifica/spot-collateral).
### Exceptions to Unified Margin
* A spot asset can be excluded from unified margin at the account level by setting `unified_margin_excluded` (this can be done on the portfolio page). The balance remains usable for spot trading but contributes zero collateral for perpetual margining.
* Assets with `collateral_enabled = false` never contribute collateral regardless of account settings. (currently all spot assets contribute collateral)
### Subaccounts
Subaccounts are margined independently. Spot collateral and USDC held in a subaccount back only that subaccount's positions. Assets can be moved between a master account and its direct subaccounts via [subaccount spot transfers](/trading-on-pacifica/deposits-and-withdrawals#subaccount-spot-transfers).
# Vaults
Source: https://docs.pacifica.fi/vaults
A vault is a managed trading pool deployed by a Pacifica user. Depositors contribute USDC; a designated manager (vault manager) trades the pooled balance on Pacifica. Profits and losses are distributed to depositors according to the vault's configuration.
A vault is a real Pacifica trading account, and is subject to the same Margin, leverage, mark-price, and trading rules by default.
The vault's balance, however, is collectively owned by its depositors via shares. The trading actions the manager can take are additionally bounded by configurable trading constraints set at vault creation.
### Roles
| Role | Description |
| - | - |
| **Creator** | The address that calls `create_lake` and pays the creation fee. The creator chooses the vault's configuration and can later update a small set of post-creation-mutable parameters. |
| **Manager** | The address authorized to place orders for the vault. Set at creation, or claimed afterward via `claim_lake_manager` on a manager-less vault. The manager also deposits capital and holds Manager Shares. |
| **LP / Depositor** | Any address that deposits into the vault. Receives LP Shares proportional to the vault's NAV at deposit time. |
The creator and manager may be the same address, different addresses, or - for a fresh vault - the manager seat may be left open for a third party to claim later.
### Share Classes
A vault tracks two independent share classes against the same pool of capital:
* **Manager Shares** are minted when the manager deposits and burned when the manager withdraws. They give the manager a claim on the manager-side balance and route their share of profits/losses through the manager's economics (including the performance fee on profits above the high-water mark).
* **LP Shares** are minted to any other depositor and follow the LP-side balance.
Each share class has its own `balance` and `share count`, but both classes own a single underlying account balance and a single set of positions. PnL is split between the two classes pro-rata before any per-class economics apply. See [Profit & Loss](/vaults/profit-and-loss).
### Lifecycle
1. **Create.** Creator pays the creation fee and chooses a configuration. The vault is assigned a fresh address and starts empty.
2. **Seed.** The creator may seed the vault in the same call, or the manager (if different) may deposit later. A vault with `manager_min_balance_portion` set must satisfy that floor before LP capital is accepted by the deposit cap.
3. **Operate.** The manager places orders for the vault subject to its symbol whitelist, blacklist, and per-symbol leverage caps. LPs deposit and withdraw within the configured cooldowns and withdrawal windows.
4. **Halt or wind-down.** If the manager's balance share falls below the configured liquidation portion, the engine halts trading and liquidates open positions. The manager can lift the halt by depositing back to the minimum balance portion. A vault with no remaining capital can be left dormant indefinitely.
### Per-Page Guide
* [Depositing](/vaults/depositing) - for users putting USDC into a vault. Covers share accounting, withdrawals, and what to evaluate before depositing.
* [Managing a Vault](/vaults/managing-a-vault) - for vault creators and managers. Covers configuration, mutability, and operating constraints.
* [Profit & Loss](/vaults/profit-and-loss) - how PnL is distributed between LP and Manager Shares, the performance fee, and the high-water mark.
* [Risk Controls](/vaults/risk-controls) - symbol whitelists, leverage caps, manager balance requirements, trading halt, and vault liquidation.
# Depositing Into a Vault
Source: https://docs.pacifica.fi/vaults/depositing
This page covers what a depositor (LP) needs to know before, during, and after depositing into a vault. Vault concepts and roles are described in the [Vaults overview](/vaults).
### Before Depositing
A vault is a discretionary trading pool. Depositors take on the trading risk taken by the manager, capped at their deposited capital. Pacifica does not vet, audit, or insure third-party vault managers. Treat depositing into a vault the same way you would treat sending capital to any external trader.
Before depositing, review:
* The manager address, the creator address, and any nickname. The creator can change a small set of trading parameters after creation (see [Managing a Vault → Mutability](/vaults/managing-a-vault#mutability)).
* The current symbol whitelist, blacklist, and per-symbol leverage caps. These define what the manager is permitted to trade.
* `manager_profit_share` and `deposit_min_duration_ms`. These determine your fees and your minimum lock-up.
* `withdraw_window_s` and `withdraw_duration_s` if set. These determine when withdrawals are open.
* The current balance, the current LP share count, and the current open positions. These define the NAV at which your shares will be priced.
### How Shares Are Priced on Deposit
A deposit is converted into LP shares against the vault's net asset value at the moment of deposit. The vault's NAV is the lake account's equity (USDC balance plus unrealized PnL on all open positions, marked to mark price), with the period's PnL first attributed to existing shareholders.
```
NAV_per_share_before_deposit = lp_balance / lp_shares (after accumulated PnL is credited)
shares_minted = amount / NAV_per_share_before_deposit
= amount * lp_shares / lp_balance
```
If the vault is empty for the LP class (`lp_shares == 0`), shares are minted 1:1 (1 share per 1 USDC).
The first step of a deposit is always a "ledger sync" that credits the period's profit or loss to the existing share classes. New shares are then minted at the post-sync NAV, so depositors do not capture or share in PnL that accrued before their deposit. See [Profit & Loss → Profit Attribution](/vaults/profit-and-loss#profit-attribution) for the formula.
### Deposit Constraints
| Constraint | Source | Effect |
| - | - | - |
| Minimum deposit | Constant 10 USDC. | Smaller amounts are rejected. |
| Deposit cap | Vault config `deposit_cap`. | Total LP balance after the deposit cannot exceed the cap. The manager's own deposits are not counted against the cap. |
| Available balance | Standard cross-margin check. | The depositor must have sufficient `available_to_withdraw` to cover the deposit, exactly as for any other USDC outflow. |
### Withdrawing
Withdrawals are denominated in shares. The amount returned is your proportional claim on the LP-side balance after the period's PnL has been credited.
```
NAV_per_share_at_withdraw = lp_balance / lp_shares (after ledger sync)
amount_withdrawn = shares_redeemed * NAV_per_share_at_withdraw
= shares_redeemed * lp_balance / lp_shares
```
A withdrawal is permitted only if all of the following hold:
* The depositor holds at least the requested number of shares.
* If `deposit_min_duration_ms > 0` is configured, at least that many milliseconds have elapsed since the depositor's most recent deposit. Each new deposit resets the timer for the depositor's entire share balance, not just the new shares.
* If `withdraw_window_s` and `withdraw_duration_s` are configured, the current time falls within an open window. The window check is `current_unix_time_s mod withdraw_window_s < withdraw_duration_s`, which means windows are anchored to the Unix epoch (1970-01-01 00:00:00 UTC), not to the vault's creation time. For example, with `withdraw_window_s = 86400` (1 day) and `withdraw_duration_s = 3600` (1 hour), withdrawals are open from 00:00 to 01:00 UTC every day.
* The vault has sufficient `available_to_withdraw`. This is the lake account's free balance after subtracting margin reserved for open positions and orders. If the manager has the vault fully deployed in positions, withdrawals may be partially unfilled until the manager closes or de-risks.
The redeemed amount is paid in USDC into the depositor's account immediately. The vault's high-water mark is reduced by the same dollar amount paid out, so future performance fees are charged on profit relative to the post-withdrawal balance rather than the pre-withdrawal peak. See [Profit & Loss → High-water mark](/vaults/profit-and-loss#high-water-mark) for the exact behavior under deposits and withdrawals.
### Risks
A depositor in a vault can lose up to their entire deposit. There is no Pacifica-funded backstop for vault losses beyond the standard exchange liquidation engine that protects the broader orderbook.
Specific exposures to be aware of:
* **Trading risk.** The manager's positions can lose money. Losses are taken from the LP balance pro-rata with the manager's balance. Cross-margin liquidations reduce the vault's USDC and may force a withdrawal queue if the lake account's `available_to_withdraw` drops to zero.
* **Manager risk.** The manager has discretion within the configured constraints. The creator may also widen those constraints over time (e.g., adding symbols to the whitelist). See [Managing a Vault → Mutability](/vaults/managing-a-vault#mutability).
* **Liquidity risk.** Withdrawals require the vault to have free balance. Large drawdowns or fully-deployed positions can delay withdrawals until the manager closes positions or until liquidations run.
* **Window risk.** A vault with a withdrawal window restriction is not redeemable outside the window. Plan around the configured cycle.
* **Counterparty risk.** A vault deployed by a third party is not Pacifica-operated and is not insured by Pacifica. Treat it accordingly.
### Where to Find Vault State
Vault metadata, configuration, current balances, and share counts are exposed through the standard account and vault endpoints (documented separately under API Documentation). The vault's address is a normal Pacifica account address and can also be inspected on the trading interface like any other account.
# Managing a Vault
Source: https://docs.pacifica.fi/vaults/managing-a-vault
This page covers the manager and creator side of a vault: deploying it, choosing its parameters, and operating it day-to-day. Depositor mechanics are described in [Depositing](/vaults/depositing).
### Creating a Vault
Vault creation is a single signed call. The creator provides:
* An optional `manager` address. If omitted, the vault is created as a "fresh vault" with no manager - any address can later [claim the manager seat](#claiming-a-fresh-vault).
* An optional `nickname`, for display on the vaults page. Nicknames are unique across all vaults.
* An optional [configuration](#configuration) object. If omitted, the default configuration applies (no caps, no fees, no cooldowns, no symbol restrictions).
* An optional seed deposit. If provided, the same call also performs a `deposit_to_lake` from the creator into the new vault.
A creation fee of 10 USDC is charged to the creator at vault creation. The vault is assigned a freshly-generated address and starts with zero balance, zero shares, and zero positions.
A vault may itself be designated as the manager of another vault (a "subvault"). Subvaults are limited to one level of nesting.
### Claiming a Fresh Vault
A fresh vault (created without a manager) can have its manager seat claimed by any address via a signed `claim_lake_manager` call. Claiming requires:
* An initial deposit of at least 10 USDC.
* If the vault was created with `manager_min_balance_portion` set, the post-claim manager balance ratio must satisfy `manager_balance / (manager_balance + lp_balance) >= manager_min_balance_portion`.
Once claimed, the manager seat is permanent for the lifetime of the vault.
### Configuration
A vault's behavior is governed by a `LakeConfig`. Some fields are fixed at creation; others can be updated by the creator. All fields are optional. Where a field is `None` the vault behaves as if no constraint of that kind exists.
| Field | Mutable? | Description |
| - | - | - |
| `deposit_cap` | Yes (creator) | Maximum total LP balance accepted by the vault. The manager's own deposits do not count against the cap. `None` = uncapped. |
| `whitelist` | Yes (creator) | Symbols the manager is permitted to trade. `None` = all listed symbols allowed. |
| `blacklist` | Yes (creator) | Symbols the manager is blocked from trading, applied after the whitelist. A symbol in both lists is blocked. `None` = no blocked symbols. |
| `max_leverages` | Yes (creator) | Per-symbol leverage caps for orders placed by the vault. `None` = the symbol's exchange-default max leverage applies. |
| `manager_profit_share` | No | Fraction of profits above the high-water mark routed to the manager as a performance fee, in `[0, 1]`. `None` = no fee. See [Profit & Loss](/vaults/profit-and-loss). |
| `deposit_min_duration_ms` | No | Minimum time (in milliseconds) a depositor's funds must remain in the vault before they can be withdrawn. Reset on every new deposit by the same depositor. |
| `manager_min_balance_portion` | No | Minimum manager-balance ratio required to claim the manager seat and to lift a trading halt. In `[0, 1]`. |
| `manager_liquidation_balance_portion` | No | Manager-balance ratio at which the engine halts the vault and liquidates open positions. In `[0, 1]`. Must be strictly less than `manager_min_balance_portion` if both are set. |
| `withdraw_window_s` | No | Period of the withdrawal-window cycle in seconds. Must be in `[1 hour, 90 days]`. Set together with `withdraw_duration_s`. |
| `withdraw_duration_s` | No | How many seconds out of each `withdraw_window_s` period are open for withdrawals. Must be in `[1 hour, 30 days]` and strictly less than `withdraw_window_s`. |
#### Mutability
Only the creator can update mutable fields. Updates take effect immediately on the next operation.
The non-mutable fields are deliberately fixed at creation: they govern the vault's economics, withdrawal cadence, and risk thresholds.
### Operating the Vault
The vault is a real Pacifica account. The manager places orders for it through the Pacifica frontend or by using the standard order endpoints, signed by the manager's wallet or by an [agent key](/api-documentation/api/signing/api-agent-keys) bound to the manager's address.
All Pacifica trading rules apply unchanged: order types, margin model, mark price, funding, liquidation. See [Trading on Pacifica](/trading-on-pacifica/overview).
The manager is also subject to the standard exchange-wide constraints such as rate limits and individual deposit requirements for the vault account itself.
### Manager Economics
Manager Shares and LP Shares are separate share classes against the same underlying balance and positions.
* The manager's deposits and withdrawals follow the same minimum amount and the same `available_to_withdraw` constraints, and the same period-PnL ledger sync as LP deposits and withdrawals.
* `deposit_min_duration_ms` and `withdraw_window_s/duration_s` apply to manager withdrawals as well.
* When a vault is configured with `manager_min_balance_portion`, the manager must satisfy the threshold to claim the seat and to lift a trading halt. See [Risk Controls → Manager Balance Portion](/vaults/risk-controls#manager-balance-portion).
The manager's earnings come from two sources:
1. The pro-rata return on Manager Shares, identical in form to an LP's return.
2. The performance fee on profits above the high-water mark, set by `manager_profit_share`. The fee is credited to `manager_balance` and accrues to Manager Shares automatically. See [Profit & Loss → Performance fee](/vaults/profit-and-loss#performance-fee).
# Profit & Loss
Source: https://docs.pacifica.fi/vaults/profit-and-loss
A vault holds a single account balance and a single set of positions. Realized and unrealized PnL accrue to that one account, and the vault then attributes the change to its two share classes (LP and Manager) before any deposit or withdrawal touches the share count.
### Profit Attribution
If PnL over a period is positive, the manager first takes a performance fee on profits above the vault's high-water mark. The remainder is split pro-rata between LP and Manager balances by their share of the previous period's total balance.
```
fee_eligible_profit = max(current_equity - high_watermark, 0)
performance_fee = fee_eligible_profit * manager_profit_share
remaining_pnl = period_pnl - performance_fee
lp_ratio = lp_balance / (lp_balance + manager_balance)
mgr_ratio = manager_balance / (lp_balance + manager_balance)
lp_delta = remaining_pnl * lp_ratio
mgr_delta = remaining_pnl * mgr_ratio + performance_fee
high_watermark = max(high_watermark, current_equity)
```
If `manager_profit_share` is unset it defaults to zero and no performance fee is taken.
#### Performance Fee
The performance fee is charged only on equity above the previous all-time high (the "high-water mark", or HWM). If the vault has been at a loss since its last peak, no performance fee accrues until the prior peak has been recovered.
#### High-Water Mark
The HWM moves monotonically upward through trading PnL. It also tracks deposits and withdrawals so that they do not artificially trigger or skip the performance fee:
* On a deposit, the HWM increases by the deposit amount. New capital does not retroactively earn or pay performance fees on the prior peak.
* On a withdrawal, the HWM is reduced by the gross dollar amount paid out. The profit/loss of the vault is accounted for upon withdrawal with regard to calculating the HWM.
The HWM never moves down through trading. Drawdowns must be recovered before the manager earns another performance fee.
### Loss Attribution
If PnL over a period is negative, the loss is split pro-rata between LP and Manager balances.
```
loss = -period_pnl
lp_ratio = lp_balance / (lp_balance + manager_balance)
mgr_ratio = manager_balance / (lp_balance + manager_balance)
lp_delta = -loss * lp_ratio
mgr_delta = -loss * mgr_ratio
high_watermark unchanged
```
### Worked Example: Profit Period
A vault with `manager_profit_share = 0.20` starts a period at:
```
lp_balance = 800
manager_balance = 200
lp_shares = 800
manager_shares = 200
high_watermark = 1000
last_checked = 1000
```
The vault trades to a new equity of `1100`. An LP deposits.
```
period_pnl = 1100 - 1000 = +100
fee_eligible_profit = max(1100 - 1000, 0) = 100
performance_fee = 100 * 0.20 = 20
remaining_pnl = 100 - 20 = 80
lp_ratio = 0.8, mgr_ratio = 0.2
lp_delta = 80 * 0.8 = 64
mgr_delta = 80 * 0.2 + 20 = 36
lp_balance -> 864 (unchanged share count: 800)
manager_balance -> 236 (unchanged share count: 200)
high_watermark -> 1100
last_checked -> 1100
```
NAV per LP share rises from 1.00 to 1.08; NAV per Manager Share rises from 1.00 to 1.18 (the manager captured both their pro-rata profit and the 20 USDC performance fee).
### Worked Example: Loss Period
A vault starts a period at:
```
lp_balance = 800
manager_balance = 200
high_watermark = 1000
last_checked = 1000
```
The vault trades to a new equity of `900`.
```
loss = 100
lp_ratio = 0.8, mgr_ratio = 0.2
lp_delta = -80
mgr_delta = -20
lp_balance -> 720
manager_balance -> 180
high_watermark -> 1000 (unchanged)
last_checked -> 900
```
The HWM is unchanged, so the manager will not earn a performance fee until equity recovers above 1000.
# Risk Controls
Source: https://docs.pacifica.fi/vaults/risk-controls
A vault is a real Pacifica account and is subject to the same liquidation engine as any other account ([Liquidations](/trading-on-pacifica/liquidations)). On top of that, vault-specific controls bound what the manager can do, when the engine forcibly halts trading, and how the manager is required to remain aligned with depositors.
This page collects those controls in one place. The economic split during PnL events is described separately in [Profit & Loss](/vaults/profit-and-loss).
### Trading Constraints on the Manager
Every order placed on a vault is checked against the vault's trading configuration in addition to the standard exchange checks.
| Constraint | Behavior |
| - | - |
| `whitelist` | If set, the order's symbol must be in the whitelist. If unset, all listed symbols are permitted. |
| `blacklist` | If set, the order's symbol must not be in the blacklist. The blacklist is applied after the whitelist; a symbol in both lists is blocked. |
| `max_leverages[symbol]` | If set, the order's selected leverage on that symbol must not exceed this cap. If unset, the symbol's exchange-default max leverage applies. |
| `trading_halt` | If true, all order submissions on the vault are rejected. Set automatically by the liquidation worker; cleared by manager top-up (see below). |
Constraint violations are returned as errors at order submission time and do not consume any state. They are checked uniformly for both manual orders and orders placed via an [agent key](/api-documentation/api/signing/api-agent-keys).
`whitelist`, `blacklist`, and `max_leverages` can be updated by the creator at any time. Updates take effect on the next order. There is no notice period for depositors. See [Managing a Vault → Mutability](/vaults/managing-a-vault#mutability).
### Manager Balance Portion
The manager's balance portion is the manager's share of the vault's total non-position USDC equity:
```
manager_balance_portion = manager_balance / (manager_balance + lp_balance)
```
Two thresholds in the vault config govern how this ratio is enforced:
| Threshold | Configured by | Used at |
| - | - | - |
| `manager_min_balance_portion` | Creator (immutable) | Required when claiming the manager seat on a fresh vault. Required to lift a trading halt after liquidation. |
| `manager_liquidation_balance_portion` | Creator (immutable) | When the live ratio falls below this threshold, the engine halts trading and liquidates open positions. |
`manager_liquidation_balance_portion` must be strictly less than `manager_min_balance_portion` if both are set. The gap between the two acts as a buffer: the manager has room to operate without being one bad tick away from a halt, but is required to top up past the higher threshold to resume trading.
If neither portion is configured, the engine does not auto-halt the vault on manager-balance grounds, and the LP is exposed to a manager who can in principle hold zero capital in the vault.