# Orders

### Fetch Post Order Details

Use this endpoint to preview the outcome of a potential order. It provides critical information such as:

* Estimated liquidation price (post-order)
* AMM fees
* Expected fill price
* Margin impact, price impact and other execution metrics

`POST`  `https://perps-api-mainnet.polynomial.finance/post-trade-details?chainId=<chain_id>`

#### Query&#x20;

| Name      | Value                                                                                                  |
| --------- | ------------------------------------------------------------------------------------------------------ |
| chain\_id | 8008 (mainnet) [addresses](https://docs.polynomial.fi/developer-documentation/api/addresses "mention") |

#### Headers&#x20;

| Name         | Value                                                                                                                   |
| ------------ | ----------------------------------------------------------------------------------------------------------------------- |
| Content-Type | application/json                                                                                                        |
| Accept       | application/json                                                                                                        |
| x-api-key    | [#backend-api-key](https://docs.polynomial.fi/developer-documentation/introduction#backend-api-key "mention")(optional) |

#### Request body

| Name      | Type   | Description                                                                                                          |
| --------- | ------ | -------------------------------------------------------------------------------------------------------------------- |
| accountId | string | Perp Account Id. Returned by accounts api \<ADD\_LINK>                                                               |
| marketId  | string | From `markets` [api](https://docs.polynomial.fi/developer-documentation/markets#retrieve-all-markets-info) response. |
| sizeDelta | string | With 18 decimals precision. Ex `-1000000000000000000` for shorting -1 size                                           |

#### Response

```json
{
    "totalFees": "113173321557870967",
    "fillPrice": "2735468306793171306346",
    "newHealthFactor": 2.6465412772448293,
    "settlementReward": "112673318234506925",
    "ammFees": "500003323364042",
    "nonVipAmmFees": "500003323364042",
    "priceImpact": "669242470939254",
    "newMarginUsage": 37.78516543830542,
    "feasible": true,
    "isPriceImpactProfitable": false,
    "liquidationPrice": "0",
    "errorMsg": null
}
```

### Retrieve All Orders

Use this endpoint to fetch the full list of orders associated with the account.

`GET`  `https://perps-api-mainnet.polynomial.finance/orders/v2?owner=<wallet_addr>&ownershipType=SuperOwner&statuses=<status>`<br>

#### Query

| Name         | Value                                                                                                                                 |
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------- |
| wallet\_addr | 8008 (mainnet) [addresses](https://docs.polynomial.fi/developer-documentation/api/addresses "mention")                                |
| statuses     | <p>Support : \[<code>Created,Committed,Expired,LimitSubmitted,LimitExecuted]</code><br>Eg: <code>statuses=Commited,Expired</code></p> |

#### Headers&#x20;

| Name         | Value                                                                                                                   |
| ------------ | ----------------------------------------------------------------------------------------------------------------------- |
| Content-Type | application/json                                                                                                        |
| Accept       | application/json                                                                                                        |
| x-api-key    | [#backend-api-key](https://docs.polynomial.fi/developer-documentation/introduction#backend-api-key "mention")(optional) |

#### Response

```json
{
  "owner": "0x3000001daCFD0d259fadC5124a7C14f4F544F2DC",
  "orders": [
    {
      "orderType": "Limit",
      "user": "0xc000007EE5FA8d10eEe31Cf06ba5B2E6f0487436",
      "accountId": "100000183460469231731687303715884105732",
      "marketId": "100",
      "chainId": 8008,
      "size": "401328244675427",
      "signature": null,
      "expiry": 1780774691910,
      "priceRange": {
        "priceA": "1",
        "priceB": "4000000000000000000",
        "acceptablePrice": "4200000000000000000",
        "priceANum": 1e-18,
        "priceBNum": 4,
        "acceptablePriceNum": 4.2
      },
      "tpPriceRange": {
        "priceA": "0",
        "priceB": "0",
        "acceptablePrice": "0",
        "priceANum": 0,
        "priceBNum": 0,
        "acceptablePriceNum": 0
      },
      "slPriceRange": {
        "priceA": "0",
        "priceB": "0",
        "acceptablePrice": "0",
        "priceANum": 0,
        "priceBNum": 0,
        "acceptablePriceNum": 0
      },
      "status": "LimitSubmitted",
      "orderId": 28180,
      "onchain": true,
      "hasLimitOrder": true,
      "hasTpSlOrder": false,
      "tpSlExecutionType": null,
      "limitOrderExecutionDetails": null,
      "tpslOrderExecutionDetails": null,
      "submissionTxDetails": {
        "chainId": 8008,
        "blockNumber": 15600261,
        "blockHash": "0xdf081b8f06c62f8e8ed56c6778e433fb50980a306efe199ac5863db40a053409",
        "txHash": "0x319168e6578bbf4c54f71996146978012d762cf0f0d1a2686880dbf435d45916",
        "logIndex": 1,
        "timestamp": 1749238697
      },
      "updateTxDetails": null,
      "timestamp": 1749238698182
    }
    ...
  ],
  "totalCount": 3
}

```
