Skip to content

Commit f12601b

Browse files
authored
Merge pull request #228 from pendle-finance/longhv/working1403
docs: Boros API & WebSocket — v2 pagination, collateral, new endpoints
2 parents 6193e2d + 2819cb2 commit f12601b

1 file changed

Lines changed: 69 additions & 4 deletions

File tree

docs/boros-dev-docs/Backend/3. api.mdx

Lines changed: 69 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ Once your agent is approved, this is the typical order placement flow:
9090
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.
9191
:::
9292

93+
9394
### 3. Closing a Position
9495

9596
```text
@@ -176,10 +177,10 @@ Query and manage user account state.
176177

177178
| Endpoint | Description |
178179
|----------|-------------|
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). |
180181
| `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). |
183184
| `GET /accounts/limit-orders` | Active/inactive limit orders. _(Deprecated — use v2)_ |
184185
| `GET /accounts/transactions` | Trade history. _(Deprecated — use v2)_ |
185186
| `GET /accounts/settlements` | Funding rate settlement history |
@@ -189,9 +190,70 @@ Query and manage user account state.
189190
| `GET /accounts/settings` | User account settings |
190191
| `POST /accounts/settings` | Update settings (agent-signed) |
191192

193+
#### Market Acc Infos
194+
195+
`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) |
224+
| `side` | Side | `0` = Long, `1` = Short |
225+
| `cumulativePnl` | string | Bigint string of all-time cumulative trade PnL |
226+
| `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%) |
249+
| `cumulativeSettlementPnl` | string | All-time cumulative settlement PnL |
250+
| `sinceOpenSettlementPnl` | string | Cumulative settlement PnL since position was opened |
251+
252+
Response includes `syncStatus` (`blockNumber` + `timestamp`).
253+
192254
#### V2 Accounts (Cursor-Based Pagination)
193255

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.
195257

196258
**How it works:**
197259
1. Make the initial request with `limit` (no `resumeToken`)
@@ -235,8 +297,10 @@ Generate transaction calldata for on-chain operations.
235297
| Endpoint | Description |
236298
|----------|-------------|
237299
| `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) |
238301
| `GET /calldata/cancel-order` | Cancel orders |
239302
| `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`. |
240304
| `GET /calldata/enter-exit-markets` | Enter or exit markets |
241305
| `GET /calldata/pay-treasury` | Pay accrued treasury fees |
242306
| `GET /calldata/add-liquidity-single-cash-to-amm` | Add AMM liquidity |
@@ -254,6 +318,7 @@ Preview operations before executing them. All simulation endpoints return the pr
254318
| `GET /simulations/close-active-position` | Preview closing a position |
255319
| `GET /simulations/add-liquidity-single-cash` | Preview adding AMM liquidity |
256320
| `GET /simulations/remove-liquidity-single-cash` | Preview removing AMM liquidity |
321+
| `GET /simulations/cash-swap` | Preview collateral swap between token types. Returns `fromAccState` and `toAccState` with pre/post simulation. Requires `userAddress`, `accountId`, `fromTokenId`, `fromMarketId`, `toTokenId`, `toMarketId`, `unscaledSpent`, `estimatedReceived`. |
257322

258323
### Funding Rate
259324
Access funding rate data and settlement history.

0 commit comments

Comments
 (0)