You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/boros-dev-docs/Backend/3. api.mdx
+69-4Lines changed: 69 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -90,6 +90,7 @@ Once your agent is approved, this is the typical order placement flow:
90
90
When submitting via the Send Txs Bot, you can set `skipReceipt=true` to get the `txHash` returned immediately without waiting for block inclusion. With `skipReceipt=false` (default), the bot waits for the transaction to be included in a block and returns the full `status` and any `error` message. Use `skipReceipt=true` for lower latency when you can track the transaction status yourself.
91
91
:::
92
92
93
+
93
94
### 3. Closing a Position
94
95
95
96
```text
@@ -176,10 +177,10 @@ Query and manage user account state.
176
177
177
178
| Endpoint | Description |
178
179
|----------|-------------|
179
-
|`POST /accounts/market-acc-infos`| Positions, margins, balances for market accounts |
180
+
|`POST /accounts/market-acc-infos`| Positions, margins, balances for market accounts. See [details below](#market-acc-infos).|
180
181
|`GET /accounts/entered-markets`| Markets entered by a cross-margin account |
181
-
|`GET /accounts/active-positions`| All active positions for a user |
182
-
|`GET /accounts/latest-settlements`| Latest settlement info per position |
182
+
|`GET /accounts/active-positions`| All active positions for a user. See [details below](#active-positions).|
183
+
|`GET /accounts/latest-settlements`| Latest settlement per market position. See [details below](#latest-settlements).|
183
184
|`GET /accounts/limit-orders`| Active/inactive limit orders. _(Deprecated — use v2)_|
184
185
|`GET /accounts/transactions`| Trade history. _(Deprecated — use v2)_|
185
186
|`GET /accounts/settlements`| Funding rate settlement history |
@@ -189,9 +190,70 @@ Query and manage user account state.
189
190
|`GET /accounts/settings`| User account settings |
`POST /accounts/market-acc-infos` — Returns detailed account information for one or more market accounts. Accepts an array of up to **100**`marketAccs` in the request body.
196
+
197
+
**Response fields (per market account):**
198
+
199
+
| Field | Type | Description |
200
+
|-------|------|-------------|
201
+
|`totalCash`| string | Total cash balance (bigint string in settlement token) |
202
+
|`netBalance`| string | Equity = totalCash + sum of all position values |
203
+
|`positions`| array | List of active positions (size, rate, entry block, etc.) |
204
+
|`initialMargin`| string | Raw initial margin without leverage |
205
+
|`initialMarginWithLeverage`| string | Initial margin with leverage applied |
206
+
|`availableInitialMargin`| string | Remaining margin available for new positions |
207
+
|`availableMaintMargin`| string | Remaining margin before liquidation (health ratio = 1.0 when zero) |
208
+
209
+
Response includes `syncStatus` (`blockNumber` + `timestamp`).
210
+
211
+
#### Active Positions
212
+
213
+
`GET /accounts/active-positions` — Returns all active (non-zero size) positions for a user's account. Query params: `userAddress`, `accountId`.
214
+
215
+
**Response fields (per position):**
216
+
217
+
| Field | Type | Description |
218
+
|-------|------|-------------|
219
+
|`marketId`| number | Market identifier |
220
+
|`marketAcc`| MarketAcc | Packed account position identifier |
221
+
|`isCross`| boolean | Whether the position uses cross-margin mode |
222
+
|`fixedApr`| number | The fixed APR of the position (e.g. `0.05` = 5%) |
223
+
|`signedSize`| string | Bigint string of signed position size (negative = short) |
|`isMatured`| boolean | Whether the market has reached its maturity date |
227
+
228
+
Response includes `syncStatus` (`blockNumber` + `timestamp`).
229
+
230
+
#### Latest Settlements
231
+
232
+
`GET /accounts/latest-settlements` — Returns the most recent settlement for each market that a user's account has participated in. Query params: `userAddress`, `accountId`.
233
+
234
+
**Response fields (per settlement):**
235
+
236
+
| Field | Type | Description |
237
+
|-------|------|-------------|
238
+
|`marketId`| number | Market identifier |
239
+
|`marketAcc`| MarketAcc | Packed account position identifier |
240
+
|`isCross`| boolean | Whether the position uses cross-margin mode |
241
+
|`isMatured`| boolean | Whether the market has reached maturity |
242
+
|`timestamp`| number | Timestamp of the latest settlement |
243
+
|`side`| Side | Position side at time of settlement (`0` = Long, `1` = Short) |
244
+
|`positionSize`| string | Bigint string of position size at settlement |
245
+
|`yieldPaid`| string | Bigint string of yield paid in the latest settlement period |
246
+
|`yieldReceived`| string | Bigint string of yield received in the latest settlement period |
247
+
|`settlement`| string | Net settlement = yieldReceived − yieldPaid |
248
+
|`settlementRate`| number | Annualized settlement rate of the latest period (e.g. `0.05` = 5%) |
|`sinceOpenSettlementPnl`| string | Cumulative settlement PnL since position was opened |
251
+
252
+
Response includes `syncStatus` (`blockNumber` + `timestamp`).
253
+
192
254
#### V2 Accounts (Cursor-Based Pagination)
193
255
194
-
The v2 endpoints replace the v1 offset-based pagination (`skip`/`limit`/`total`) with **cursor-based pagination** using a `resumeToken`. This is significantly more efficient for large datasets — no `countDocuments()` overhead and no performance degradation on later pages.
256
+
The v2 endpoints replace the v1 offset-based pagination (`skip`/`limit`/`total`) with **cursor-based pagination** using a `resumeToken`. This is significantly more efficient for large datasets.
195
257
196
258
**How it works:**
197
259
1. Make the initial request with `limit` (no `resumeToken`)
@@ -235,8 +297,10 @@ Generate transaction calldata for on-chain operations.
235
297
| Endpoint | Description |
236
298
|----------|-------------|
237
299
|`POST /calldata/place-orders`| Place one or more limit orders |
300
+
|`POST /calldata/place-orders-with-rate`| Place orders with an explicit desired rate (instead of slippage) |
238
301
|`GET /calldata/cancel-order`| Cancel orders |
239
302
|`GET /calldata/cash-transfer`| Transfer between cross and isolated accounts |
303
+
|`POST /send-txs-bot/v1/agent/cash-swap`| Swap collateral between different token types (agent-signed, EIP-712). Requires `fromTokenId`, `fromMarketId`, `toTokenId`, `toMarketId`, `unscaledSpent`, `minUnscaledReceived`, and `nonce`. |
240
304
|`GET /calldata/enter-exit-markets`| Enter or exit markets |
0 commit comments