# Endpoints

🔐 — requires authentication\
🪙 — cost of calling in request tokens (see [Rate Limits](https://docs.variational.io/archive/archived-api/rate-limits))

## Companies

### **GET /v1/companies**

🔐 🪙 1

Fetches all companies registered on the platform.

**Parameters:**

* `id`: Uuid (optional) — filters output by company ID
* `limit`: int (optional, max=10,000) — used for pagination
* `offset`: int (optional) — used for pagination

**Output type**: ApiPage\[Company]

<details>

<summary>Example output</summary>

```json
{
  "result": [
    {
      "created_at": "2024-01-01T18:44:33.846999Z",
      "id": "bdd68c99-65fe-4500-baae-5bc09b4af183",
      "is_lp": true,
      "legal_name": "Example company",
      "short_name": "EXMPL"
    },
    {
      "created_at": "2024-02-01 18:44:51.817012Z",
      "id": "af13119d-4ed1-4718-aea3-fecee4764837",
      "is_lp": false,
      "legal_name": "Another company",
      "short_name": "ANTHR"
    }
  ],
  "pagination": {
    "next_page": null
  }
}
```

</details>

**Python SDK:**

```python
def get_companies(self, id: Optional[str] = None,
                  page: Optional[Dict] = None) -> ApiPage[Company]
```

<details>

<summary>SDK examples</summary>

```python
f# iterate over companies
for company in paginate(client.get_companies):
    ...

# load all companies into a list (eagerly request all pages)
companies = list(paginate(client.get_companies))

# fetch company metadata by id
company_id = "bdd68c99-65fe-4500-baae-5bc09b4af183"
company = client.get_companies(id=company_id).result[0]
```

</details>

## Portfolio

### **GET /v1/portfolio/assets**

🔐 🪙 1

Fetches current asset balances for the authenticated user.

**Parameters:**

* `pool`: Uuid (optional) — filters output by settlement pool; if not specified, a summary across all settlement pools is returned
* `limit`: int (optional, max=10,000) — used for pagination
* `offset`: int (optional) — used for pagination

**Output type**: ApiPage\[Asset]

<details>

<summary>Example output</summary>

```json
{
  "result": [
    {
      "asset": "USDC",
      "company": "bdd68c99-65fe-4500-baae-5bc09b4af183",
      "pool_location": "cdfbea44-7e75-4688-a3ea-e8d097ae7ede",
      "qty": "2103.191818"
    }
  ]
  "pagination": {
    "next_page": null
  }
}
```

</details>

**Python SDK:**

```python
def get_portfolio_assets(self, pool: Optional[str] = None,
                         page: Optional[Dict] = None) -> ApiPage[Asset]
```

<details>

<summary>SDK examples</summary>

```python
# iterate over all assets
for assets in paginate(client.get_portfolio_assets):
    ...

# load all assets in a specific pool into a list (eagerly request all pages)
pool_id = "cdfbea44-7e75-4688-a3ea-e8d097ae7ede"
assets = list(paginate(client.get_portfolio_assets, pool=pool_id))
```

</details>

### **GET /v1/portfolio/positions**

🔐 🪙 1

Fetches current position balances for the authenticated user.

**Parameters:**

* `pool`: Uuid (optional) — filters output by settlement pool; if not specified, a summary across all settlement pools is returned
* `limit`: int (optional, max=10,000) — used for pagination
* `offset`: int (optional) — used for pagination

**Output type**: ApiPage\[Position]

<details>

<summary>Example output</summary>

```json
{
  "result": [
    {
      "avg_entry_price": "65215.000000000000",
      "company": "af13119d-4ed1-4718-aea3-fecee4764837",
      "instrument": {
        "expiry": "2024-04-05T08:00:00Z",
        "instrument_type": "dated_future",
        "settlement_asset": "USDC",
        "underlying": "BTC"
      },
      "pool_location": "cdfbea44-7e75-4688-a3ea-e8d097ae7ede",
      "qty": "1",
      "taker_qty": "0",
      "updated_at": "2024-04-02T23:16:52.344386Z"
    }
  ],
  "pagination": {
    "next_page": null
  }
}
```

</details>

**Python SDK:**

```python
def get_portfolio_positions(self, pool: Optional[str] = None,
                            page: Optional[Dict] = None) -> ApiPage[Position]
```

<details>

<summary>SDK examples</summary>

```python
# iterate over positions in a specific settlement pool
pool_id = "cdfbea44-7e75-4688-a3ea-e8d097ae7ede"
for positions in paginate(client.get_portfolio_positions, pool=pool_id):
    ...

# load all your positions into a list (eagerly request all pages)
positions = list(paginate(client.get_portfolio_positions))
```

</details>

### **GET /v1/portfolio/positions/aggregated**

🔐 🪙 10

Fetches aggregated positions for the authenticated user.

**Parameters:**

* `limit`: int (optional, max=10,000) — used for pagination
* `offset`: int (optional) — used for pagination

**Output type**: ApiPage\[AggregatedPosition]

<details>

<summary>Example output</summary>

```json
{
  "result": [
    {
      "iv": "0",
      "notional": "65833.1739032583",
      "position_info": {
        "avg_entry_price": "65215",
        "company": "af13119d-4ed1-4718-aea3-fecee4764837",
        "instrument": {
          "expiry": "2024-04-05T08:00:00Z",
          "instrument_type": "dated_future",
          "settlement_asset": "USDC",
          "underlying": "BTC"
        },
        "pool_location": "00000000-0000-0000-0000-000000000000",
        "qty": "1",
        "taker_qty": "0",
        "updated_at": "2024-04-02T23:16:52.344386Z"
      },
      "price": "65896.65104296",
      "sum_delta": "1",
      "sum_gamma": "0",
      "sum_rho": "0",
      "sum_theta": "0",
      "sum_vega": "0",
      "underlying_price": "65833.1739032583",
      "upnl": "681.65104296"
    }
  ],
  "pagination": {
    "next_page": null
  },
}
```

</details>

**Python SDK:**

```python
def get_portfolio_aggregated_positions(self, page: Optional[Dict] = None) \
    -> ApiPage[AggregatedPosition]
```

<details>

<summary>SDK examples</summary>

```python
# iterate over your company's aggregated positions
for positions in paginate(client.get_portfolio_aggregated_positions):
    ...

# load all your aggregated positions into a list (eagerly request all pages)
positions = list(paginate(client.get_portfolio_aggregated_positions))
```

</details>

### **GET /v1/portfolio/trades**

🔐 🪙 1

Fetches trades for the authenticated user.

**Parameters:**

* `pool`: Uuid (optional) — filters output by settlement pool
* `id`: Uuid (optional) — filters output by trade ID
* `limit`: int (optional, max=10,000) — used for pagination
* `offset`: int (optional) — used for pagination

**Output type**: ApiPage\[Trade]

<details>

<summary>Example output</summary>

```json
{
  "result": [
    {
      "company": "af13119d-4ed1-4718-aea3-fecee4764837",
      "created_at": "2024-04-02T23:16:52.344386Z",
      "id": "01efd105-07d7-43d9-9f51-886af0aa8b25",
      "instrument": {
        "expiry": "2024-04-05T08:00:00Z",
        "instrument_type": "dated_future",
        "settlement_asset": "USDC",
        "underlying": "BTC"
      },
      "pool_location": "cdfbea44-7e75-4688-a3ea-e8d097ae7ede",
      "price": "65215",
      "qty": "1",
      "role": "maker",
      "side": "buy",
      "source_quote": "adb18efb-aee3-4c0f-9e96-082c2849601d",
      "source_rfq": "564eeecb-7466-4af4-b833-907835d6e83b",
      "source_rfq_leg_id": "635976ac-d5ea-4f44-b25a-2de18cc0cade",
      "trade_type": "trade"
    }
  ],
  "pagination": {
    "next_page": null
  }
}
```

</details>

**Python SDK:**

```python
def get_portfolio_trades(self, pool: Optional[str] = None, id: Optional[str] = None,
                         page: Optional[Dict] = None) -> ApiPage[Trade]
```

<details>

<summary>SDK examples</summary>

```python
# iterate over trades in a specific settlement pool
pool_id = "cdfbea44-7e75-4688-a3ea-e8d097ae7ede"
for trade in paginate(client.get_portfolio_trades, pool=pool_id):
    ...

# fetch a trade by id
trade_id = "01efd105-07d7-43d9-9f51-886af0aa8b25"
trade = client.get_portfolio_trades(id=trade_id).result[0]
```

</details>

### **GET /v1/portfolio/summary**

🔐 🪙 10

Fetches the aggregated summary of the authenticated user's positions: balance, uPNL and the Greeks (risk).

**Parameters:** None.

**Output type**: ApiSingle\[PortfolioSummary]

<details>

<summary>Example output</summary>

```json
{
  "result": {
    "sum_balance": "1169.5439289533",
    "sum_delta": "1",
    "sum_dollar_delta": "65660.2180115883",
    "sum_dollar_gamma": "0",
    "sum_gamma": "0",
    "sum_notional": "65660.2180115883",
    "sum_rho": "0",
    "sum_theta": "0",
    "sum_upnl": "529.6761819533",
    "sum_vega": "0"
  }
}
```

</details>

**Python SDK:**

```python
def get_portfolio_summary(self) -> ApiSingle[PortfolioSummary]
```

<details>

<summary>SDK examples</summary>

```python
summary = client.get_portfolio_summary().result
```

</details>

## Quotes

### **GET /v1/quotes, GET /v1/quotes/sent and GET /v1/quotes/received**

🔐 🪙 1

Fetches quotes sent or received by the authenticated user.

**Parameters:**

* `id`: Uuid (optional) — filters output by quote ID
* `limit`: int (optional, max=1,000) — used for pagination
* `offset`: int (optional) — used for pagination

**Output type**: ApiPage\[Quote]

<details>

<summary>Example output</summary>

```json
{
  "result": [
    {
      "aggregated_ask": null,
      "aggregated_bid": "65215",
      "clearing_events": [
        {
          "created_at": "2024-04-02T22:52:46.609140Z",
          "parent_quote_id": "5368f58e-f385-44cc-a9e5-2e8ea51913bb",
          "rfq_id": "564eeecb-7466-4af4-b833-907835d6e83b",
          "status": "pending_pool_creation",
          "taker_side": "sell"
        },
        {
          "created_at": "2024-04-02T22:55:34.122263Z",
          "parent_quote_id": "5368f58e-f385-44cc-a9e5-2e8ea51913bb",
          "rfq_id": "564eeecb-7466-4af4-b833-907835d6e83b",
          "status": "pending_taker_deposit_approval",
          "taker_side": null
        }
      ],
      "clearing_status": "pending_taker_deposit_approval",
      "client_quote_id": "my quote 2",
      "creator_params": {
        "margin_mode": "simple",
        "params": {
          "asset_params": {},
          "auto_liquidation": true,
          "default_asset_param": {
            "futures_initial_margin": "0.02",
            "futures_leverage": "20000",
            "futures_maintenance_margin": "0.01",
            "option_initial_margin": "0.15",
            "option_initial_margin_min": "0.1",
            "option_maintenance_margin": "0.075"
          },
          "liquidation_penalty": "0.1"
        }
      },
      "expires_at": "2024-04-03T10:49:20.685499Z",
      "maker_company": "af13119d-4ed1-4718-aea3-fecee4764837",
      "new_pool_name": "API test pool",
      "other_params": {
        "margin_mode": "simple",
        "params": {
          "asset_params": {},
          "auto_liquidation": true,
          "default_asset_param": {
            "futures_initial_margin": "0.02",
            "futures_leverage": "20000",
            "futures_maintenance_margin": "0.01",
            "option_initial_margin": "0.15",
            "option_initial_margin_min": "0.1",
            "option_maintenance_margin": "0.075"
          },
          "liquidation_penalty": "0.1"
        }
      },
      "parent_quote_id": "5368f58e-f385-44cc-a9e5-2e8ea51913bb",
      "per_leg_quotes": [
        {
          "ask": null,
          "bid": "65215",
          "target_rfq_leg_id": "635976ac-d5ea-4f44-b25a-2de18cc0cade"
        }
      ],
      "pool_location": "cdfbea44-7e75-4688-a3ea-e8d097ae7ede",
      "target_rfq_id": "564eeecb-7466-4af4-b833-907835d6e83b"
    }
  ],
  "pagination": {
    "next_page": null
  }
}
```

</details>

**Python SDK:**

```python
def get_quotes(self, id: Optional[str] = None,
               page: Optional[Dict] = None) -> ApiPage[Quote]

def get_quotes_sent(self, id: Optional[str] = None,
                    page: Optional[Dict] = None) -> ApiPage[Quote]
    
def get_quotes_received(self, id: Optional[str] = None,
                        page: Optional[Dict] = None) -> ApiPage[Quote]
```

<details>

<summary>SDK examples</summary>

```python
# iterate over all of your company's sent quotes
for quote in paginate(client.get_quotes_sent):
    ...

# fetch a received quote by id
quote_id = "5368f58e-f385-44cc-a9e5-2e8ea51913bb"
quote = client.get_quotes_received(id=quote_id).result[0]
```

</details>

### **POST /v1/quotes/new**

🔐 🪙 20

Used to submit a quote in response to a particular RFQ as a maker.

**JSON payload keys:**

* `rfq_id`: Uuid — ID of the target RFQ
* `expires_at`: DateTimeRFC3339 — expiration time
* `leg_quotes`: List\[LegQuote] — quotes for individual RFQ legs
* `pool_strategy`: PoolStrategy — reuse an existing pool or create a new one
* `client_quote_id`: str (optional, max length: 50 characters) — arbitrary string for your internal reference

<details>

<summary>Example input</summary>

```json
{
  "rfq_id": "564eeecb-7466-4af4-b833-907835d6e83b",
  "expires_at": "2024-04-03T10:45:24.967356Z",
  "leg_quotes": [
    {
      "target_rfq_leg_id": "635976ac-d5ea-4f44-b25a-2de18cc0cade",
      "bid": "65220"
    }
  ],
  "pool_strategy": {
    "strategy": "create_new",
    "name": "API test pool",
    "creator_params": {
      "margin_mode": "simple",
      "params": {
        "liquidation_penalty": "0.1",
        "auto_liquidation": true,
        "asset_params": {},
        "default_asset_param": {
          "futures_initial_margin": "0.02",
          "futures_maintenance_margin": "0.01",
          "futures_leverage": "20000",
          "option_initial_margin": "0.15",
          "option_initial_margin_min": "0.1",
          "option_maintenance_margin": "0.075"
        }
      }
    },
    "other_params": {
      "margin_mode": "simple",
      "params": {
        "liquidation_penalty": "0.1",
        "auto_liquidation": true,
        "asset_params": {},
        "default_asset_param": {
          "futures_initial_margin": "0.02",
          "futures_maintenance_margin": "0.01",
          "futures_leverage": "20000",
          "option_initial_margin": "0.15",
          "option_initial_margin_min": "0.1",
          "option_maintenance_margin": "0.075"
        }
      }
    }
  },
  "client_quote_id": "my quote"
}
```

</details>

**Output type:** ApiSingle\[Quote]

<details>

<summary>Example output</summary>

```json
{
  "result": {
    "aggregated_ask": null,
    "aggregated_bid": "65220",
    "clearing_events": [],
    "clearing_status": null,
    "client_quote_id": "my quote",
    "creator_params": {
      "margin_mode": "simple",
      "params": {
        "asset_params": {},
        "auto_liquidation": true,
        "default_asset_param": {
          "futures_initial_margin": "0.02",
          "futures_leverage": "20000",
          "futures_maintenance_margin": "0.01",
          "option_initial_margin": "0.15",
          "option_initial_margin_min": "0.1",
          "option_maintenance_margin": "0.075"
        },
        "liquidation_penalty": "0.1"
      }
    },
    "expires_at": "2024-04-03T10:45:24.967356Z",
    "maker_company": "af13119d-4ed1-4718-aea3-fecee4764837",
    "new_pool_name": "API test pool",
    "other_params": {
      "margin_mode": "simple",
      "params": {
        "asset_params": {},
        "auto_liquidation": true,
        "default_asset_param": {
          "futures_initial_margin": "0.02",
          "futures_leverage": "20000",
          "futures_maintenance_margin": "0.01",
          "option_initial_margin": "0.15",
          "option_initial_margin_min": "0.1",
          "option_maintenance_margin": "0.075"
        },
        "liquidation_penalty": "0.1"
      }
    },
    "parent_quote_id": "37dac6e5-8f91-4cef-9e1e-53042e30991a",
    "per_leg_quotes": [
      {
        "ask": null,
        "bid": "65220",
        "target_rfq_leg_id": "635976ac-d5ea-4f44-b25a-2de18cc0cade"
      }
    ],
    "pool_location": null,
    "target_rfq_id": "564eeecb-7466-4af4-b833-907835d6e83b"
  }
}
```

</details>

**Python SDK:**

```python
def create_quote(self, rfq_id: UUIDv4, expires_at: DateTimeRFC3339,
                 leg_quotes: List[LegQuote], pool_strategy: PoolStrategy,
                 client_quote_id: Optional[str] = None) -> ApiSingle[Quote]
```

<details>

<summary>SDK examples</summary>

```python
margin_params = {
    "margin_mode": MarginMode.SIMPLE,
    "params": {
        "liquidation_penalty": "0.1",
        "auto_liquidation": True,
        "asset_params": {},
        "default_asset_param": {
            "futures_initial_margin": "0.02",
            "futures_maintenance_margin": "0.01",
            "futures_leverage": "20000",
            "option_initial_margin": "0.15",
            "option_initial_margin_min": "0.1",
            "option_maintenance_margin": "0.075",
        },
    }
}
new_quote = maker_client.create_quote(
    rfq_id="564eeecb-7466-4af4-b833-907835d6e83b",
    expires_at="2024-04-03T10:45:24.967356Z",
    client_quote_id="my quote",
    leg_quotes=[
        {
            "target_rfq_leg_id": "635976ac-d5ea-4f44-b25a-2de18cc0cade",
            "bid": "65220"
        }
    ],
    pool_strategy={
        "strategy": PoolStrategyType.CREATE_NEW,
        "name": "API test pool",
        "creator_params": margin_params,
        "other_params": margin_params
    }
).result
```

</details>

### **POST /v1/quotes/cancel**

🔐 🪙 20

Cancels a previously created quote.

JSON payload keys:

* `id`: Uuid — ID of the quote to cancel

<details>

<summary>Example input</summary>

```json
{
  "id": "37dac6e5-8f91-4cef-9e1e-53042e30991a"
}
```

</details>

**Output type:** ApiSingle\[bool]

<details>

<summary>Example output</summary>

```json
{
  "result": true
}
```

</details>

**Python SDK:**

```python
def cancel_quote(self, id: UUIDv4) -> ApiSingle[bool]
```

<details>

<summary>SDK example</summary>

```python
client.cancel_quote(id="3025fca3-114e-4476-a993-93286a7dd43f")
```

</details>

### **POST /v1/quotes/cancel\_all**

🔐 🪙 20

Cancels all of the authenticated user's outstanding quotes.

**Output type:** ApiSingle\[bool]

<details>

<summary>Example output</summary>

```json
{
  "result": true
}
```

</details>

Python SDK:

```python
def cancel_all_quotes(self) -> ApiSingle[bool]
```

<details>

<summary>SDK examples</summary>

```python
client.cancel_all_quotes()
```

</details>

### **POST /v1/quotes/replace**

🔐 🪙 20

Used to cancel an existing quote and submit a new one for the same particular RFQ.

**JSON payload keys:**

* `parent_quote_id`: Uuid — ID of the existing quote to cancel
* `rfq_id`: Uuid — ID of the target RFQ
* `expires_at`: DateTimeRFC3339 — expiration time
* `leg_quotes`: List\[LegQuote] — quotes for individual RFQ legs
* `pool_strategy`: PoolStrategy — reuse an existing pool or create a new one
* `client_quote_id`: str (optional) — arbitrary string for your internal reference

<details>

<summary>Example input</summary>

```json
{
  "parent_quote_id": "37dac6e5-8f91-4cef-9e1e-53042e30991a",
  "rfq_id": "564eeecb-7466-4af4-b833-907835d6e83b",
  "expires_at": "2024-04-03T10:49:20.685499Z",
  "leg_quotes": [
    {
      "target_rfq_leg_id": "635976ac-d5ea-4f44-b25a-2de18cc0cade",
      "bid": "65215"
    }
  ],
  "pool_strategy": {
    "strategy": "create_new",
    "name": "API test pool",
    "creator_params": {
      "margin_mode": "simple",
      "params": {
        "liquidation_penalty": "0.1",
        "auto_liquidation": true,
        "asset_params": {},
        "default_asset_param": {
          "futures_initial_margin": "0.02",
          "futures_maintenance_margin": "0.01",
          "futures_leverage": "20000",
          "option_initial_margin": "0.15",
          "option_initial_margin_min": "0.1",
          "option_maintenance_margin": "0.075"
        }
      }
    },
    "other_params": {
      "margin_mode": "simple",
      "params": {
        "liquidation_penalty": "0.1",
        "auto_liquidation": true,
        "asset_params": {},
        "default_asset_param": {
          "futures_initial_margin": "0.02",
          "futures_maintenance_margin": "0.01",
          "futures_leverage": "20000",
          "option_initial_margin": "0.15",
          "option_initial_margin_min": "0.1",
          "option_maintenance_margin": "0.075"
        }
      }
    }
  },
  "client_quote_id": "my quote 2"
}
```

</details>

**Output type:** ApiSingle\[Quote]

<details>

<summary>Example output</summary>

```json
{
  "result": {
    "aggregated_ask": null,
    "aggregated_bid": "65215",
    "clearing_events": [],
    "clearing_status": null,
    "client_quote_id": "my quote 2",
    "creator_params": {
      "margin_mode": "simple",
      "params": {
        "asset_params": {},
        "auto_liquidation": true,
        "default_asset_param": {
          "futures_initial_margin": "0.02",
          "futures_leverage": "20000",
          "futures_maintenance_margin": "0.01",
          "option_initial_margin": "0.15",
          "option_initial_margin_min": "0.1",
          "option_maintenance_margin": "0.075"
        },
        "liquidation_penalty": "0.1"
      }
    },
    "expires_at": "2024-04-03T10:49:20.685499Z",
    "maker_company": "af13119d-4ed1-4718-aea3-fecee4764837",
    "new_pool_name": "API test pool",
    "other_params": {
      "margin_mode": "simple",
      "params": {
        "asset_params": {},
        "auto_liquidation": true,
        "default_asset_param": {
          "futures_initial_margin": "0.02",
          "futures_leverage": "20000",
          "futures_maintenance_margin": "0.01",
          "option_initial_margin": "0.15",
          "option_initial_margin_min": "0.1",
          "option_maintenance_margin": "0.075"
        },
        "liquidation_penalty": "0.1"
      }
    },
    "parent_quote_id": "5368f58e-f385-44cc-a9e5-2e8ea51913bb",
    "per_leg_quotes": [
      {
        "ask": null,
        "bid": "65215",
        "target_rfq_leg_id": "635976ac-d5ea-4f44-b25a-2de18cc0cade"
      }
    ],
    "pool_location": null,
    "target_rfq_id": "564eeecb-7466-4af4-b833-907835d6e83b"
  }
}
```

</details>

**Python SDK:**

```python
def replace_quote(self, parent_quote_id: UUIDv4, rfq_id: UUIDv4,
                  expires_at: DateTimeRFC3339, leg_quotes: List[LegQuote],
                  pool_strategy: PoolStrategy,
                  client_quote_id: Optional[str] = None) -> ApiSingle[Quote]
```

<details>

<summary>SDK examples</summary>

```python
margin_params = {
    "margin_mode": MarginMode.SIMPLE,
    "params": {
        "liquidation_penalty": "0.1",
        "auto_liquidation": True,
        "asset_params": {},
        "default_asset_param": {
            "futures_initial_margin": "0.02",
            "futures_maintenance_margin": "0.01",
            "futures_leverage": "20000",
            "option_initial_margin": "0.15",
            "option_initial_margin_min": "0.1",
            "option_maintenance_margin": "0.075",
        },
    }
}
new_quote = maker_client.replace_quote(
    parent_quote_id="37dac6e5-8f91-4cef-9e1e-53042e30991a",
    rfq_id="564eeecb-7466-4af4-b833-907835d6e83b",
    expires_at="2024-04-03T10:49:20.685499Z",
    client_quote_id="my quote 2",
    leg_quotes=[
        {
            "target_rfq_leg_id": "635976ac-d5ea-4f44-b25a-2de18cc0cade",
            "bid": "65215"
        }
    ],
    pool_strategy={
        "strategy": PoolStrategyType.CREATE_NEW,
        "name": "API test pool",
        "creator_params": margin_params,
        "other_params": margin_params
    }
).result
```

</details>

### POST /v1/quotes/accept

🔐 🪙 20

Used to accept a quote and create a trade as a taker.

**JSON payload keys:**

* `parent_quote_id`: Uuid — ID of the quote to accept
* `rfq_id`: Uuid — ID of the target RFQ
* `side`: TradeSide — "buy" or "sell"

<details>

<summary>Example input</summary>

```json
{
  "parent_quote_id": "5368f58e-f385-44cc-a9e5-2e8ea51913bb",
  "rfq_id": "564eeecb-7466-4af4-b833-907835d6e83b",
  "side": "sell"
}
```

</details>

**Output type:** ApiSingle\[QuoteAcceptResponse]

<details>

<summary>Example output</summary>

```json
{
  "result": {
    "new_clearing_status": "pending_pool_creation",
    "pending_deposits_sum_qty": "2103.191818",
    "pending_settlement_pool": {
      "id": "cdfbea44-7e75-4688-a3ea-e8d097ae7ede",
      "created_at": "2024-04-03T10:40:11.194670Z",
      "company_creator": "bdd68c99-65fe-4500-baae-5bc09b4af183",
      "status": "pending",
      "address": null,
      "confirmed_by_transaction_id": null
    }
  }
}
```

</details>

Python SDK:

```python
def accept_quote(self, rfq_id: UUIDv4, parent_quote_id: UUIDv4,
                 side: TradeSide) -> ApiSingle[QuoteAcceptResponse]
```

<details>

<summary>SDK examples</summary>

```python
accepted = taker_client.accept_quote(
    rfq_id="564eeecb-7466-4af4-b833-907835d6e83b",
    parent_quote_id="5368f58e-f385-44cc-a9e5-2e8ea51913bb",
    side=TradeSide.SELL,
).result
```

</details>

#### Notes On Clearing Status:

Depending on the quote parameters and prior on-chain calls, the trade can be created in one of three distinct clearing states:

* `pending_pool_creation`: a new settlement pool needs to be created on-chain; this will progress automatically to one of the following statuses
* `pending_taker_deposit_approval`: taker must use the [Permit](#post-v1-transfers-permit) endpoint to allow spending of the amount equal to or greater than `pending_deposits_sum_qty` by the settlement pool address
* `pending_maker_last_look`: the maker is responsible for progressing the trade further by submitting a final "last look" approval

### POST /v1/quotes/maker\_last\_look

🔐 🪙 20

Used by the maker to finalize a trade or cancel it, in response to taker acceptance. The trade must be in `pending_maker_last_look` clearing status.

**JSON payload keys:**

* `parent_quote_id`: Uuid — ID of the quote
* `rfq_id`: Uuid — ID of the RFQ
* `action`: RequestAction — "accept" or "reject"

<details>

<summary>Example input</summary>

```json
{
  "parent_quote_id": "5368f58e-f385-44cc-a9e5-2e8ea51913bb",
  "rfq_id": "564eeecb-7466-4af4-b833-907835d6e83b",
  "action": "accept"
}
```

</details>

**Output Type:** ApiSingle\[MakerLastLookResponse]

<details>

<summary>Example output</summary>

```json
{
  "result": {
    "atomic_deposit_details": {
      "creator_address": "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266",
      "creator_transfer_amount": "2103.191818",
      "other_address": "0xa0ee7a142d267c1f36714e4a8f75612f20a79720",
      "other_transfer_amount": "639.867747",
      "parent_quote_id": "5368f58e-f385-44cc-a9e5-2e8ea51913bb",
      "pool_address": "0x5e5137b6a596a5d7508756c14d07f83ce8535944",
      "rfq_id": "564eeecb-7466-4af4-b833-907835d6e83b"
    },
    "new_clearing_status": "pending_maker_deposit_approval",
    "pending_deposits_sum_qty": "639.867747"
  }
}
```

</details>

**Python SDK:**

```python
def maker_last_look(self, rfq_id: UUIDv4, parent_quote_id: UUIDv4,
                    action: RequestAction) -> ApiSingle[MakerLastLookResponse]
```

<details>

<summary>SDK examples</summary>

```python
last_look = maker_client.maker_last_look(
    rfq_id="564eeecb-7466-4af4-b833-907835d6e83b",
    parent_quote_id="5368f58e-f385-44cc-a9e5-2e8ea51913bb",
    action=RequestAction.ACCEPT,
).result
```

</details>

#### Notes On Clearing Status:

Depending on the current settlement pool margin usage and prior on-chain calls, the trade can end up in one of three distinct clearing states:

* `pending_maker_deposit_approval`: taker must use the [Permit](#post-v1-transfers-permit) endpoint to allow spending of the amount equal to or greater than `pending_deposits_sum_qty` by the settlement pool address
* `pending_atomic_deposit`: this will progress automatically to the following status
* `success_trades_booked_into_pool`: no additional deposits were necessary for initial margin and the trade has successfully cleared

## RFQs

### **GET /v1/rfqs/sent and GET /v1/rfqs/received**

🔐 🪙 10

Fetches RFQs sent or received by the authenticated user.

**Parameters:**

* `id`: Uuid (optional) — filters output by quote ID
* `limit`: int (optional, max=1,000) — used for pagination
* `offset`: int (optional) — used for pagination

**Output type**: ApiPage\[RFQ]

<details>

<summary>Example output</summary>

```json
{
  "result": [
    {
      "asks": [],
      "bids": [
        {
          "additional_margin_requirements": null,
          "margin_requirements": null,
          "parent_quote_id": "5368f58e-f385-44cc-a9e5-2e8ea51913bb",
          "quote_price": "65215"
        }
      ],
      "created_at": "2024-04-02T22:42:19.816573Z",
      "qty": "1",
      "quotes_common_metadata": {
        "5368f58e-f385-44cc-a9e5-2e8ea51913bb": {
          "clearing_events": [
            {
              "created_at": "2024-04-02T22:52:46.609140Z",
              "parent_quote_id": "5368f58e-f385-44cc-a9e5-2e8ea51913bb",
              "rfq_id": "564eeecb-7466-4af4-b833-907835d6e83b",
              "status": "pending_pool_creation",
              "taker_side": "sell"
            },
            {
              "created_at": "2024-04-02T22:55:34.122263Z",
              "parent_quote_id": "5368f58e-f385-44cc-a9e5-2e8ea51913bb",
              "rfq_id": "564eeecb-7466-4af4-b833-907835d6e83b",
              "status": "pending_taker_deposit_approval",
              "taker_side": null
            }
          ],
          "clearing_status": "pending_taker_deposit_approval",
          "creator_params": {
            "margin_mode": "simple",
            "params": {
              "asset_params": {},
              "auto_liquidation": true,
              "default_asset_param": {
                "futures_initial_margin": "0.02",
                "futures_leverage": "20000",
                "futures_maintenance_margin": "0.01",
                "option_initial_margin": "0.15",
                "option_initial_margin_min": "0.1",
                "option_maintenance_margin": "0.075"
              },
              "liquidation_penalty": "0.1"
            }
          },
          "expires_at": "2024-04-03T10:49:20.685499Z",
          "maker_company": "af13119d-4ed1-4718-aea3-fecee4764837",
          "new_pool_name": "API test pool",
          "other_params": {
            "margin_mode": "simple",
            "params": {
              "asset_params": {},
              "auto_liquidation": true,
              "default_asset_param": {
                "futures_initial_margin": "0.02",
                "futures_leverage": "20000",
                "futures_maintenance_margin": "0.01",
                "option_initial_margin": "0.15",
                "option_initial_margin_min": "0.1",
                "option_maintenance_margin": "0.075"
              },
              "liquidation_penalty": "0.1"
            }
          },
          "parent_quote_id": "5368f58e-f385-44cc-a9e5-2e8ea51913bb",
          "pool_creator_company": "bdd68c99-65fe-4500-baae-5bc09b4af183",
          "pool_creator_params": {
            "margin_mode": "simple",
            "params": {
              "asset_params": {},
              "auto_liquidation": true,
              "default_asset_param": {
                "futures_initial_margin": "0.02",
                "futures_leverage": "20000",
                "futures_maintenance_margin": "0.01",
                "option_initial_margin": "0.15",
                "option_initial_margin_min": "0.1",
                "option_maintenance_margin": "0.075"
              },
              "liquidation_penalty": "0.1"
            }
          },
          "pool_location": "cdfbea44-7e75-4688-a3ea-e8d097ae7ede",
          "pool_other_company": "af13119d-4ed1-4718-aea3-fecee4764837",
          "pool_other_params": {
            "margin_mode": "simple",
            "params": {
              "asset_params": {},
              "auto_liquidation": true,
              "default_asset_param": {
                "futures_initial_margin": "0.02",
                "futures_leverage": "20000",
                "futures_maintenance_margin": "0.01",
                "option_initial_margin": "0.15",
                "option_initial_margin_min": "0.1",
                "option_maintenance_margin": "0.075"
              },
              "liquidation_penalty": "0.1"
            }
          }
        }
      },
      "rfq_expires_at": "2024-04-03T10:42:19.795911Z",
      "rfq_id": "564eeecb-7466-4af4-b833-907835d6e83b",
      "rfq_legs": [
        {
          "instrument": {
            "expiry": "2024-04-05T08:00:00Z",
            "instrument_type": "dated_future",
            "settlement_asset": "USDC",
            "underlying": "BTC"
          },
          "qty": "1",
          "rfq_id": "564eeecb-7466-4af4-b833-907835d6e83b",
          "rfq_leg_id": "635976ac-d5ea-4f44-b25a-2de18cc0cade",
          "side": "buy"
        }
      ],
      "rfq_status": "closed",
      "structure": {
        "legs": [
          {
            "instrument": {
              "expiry": "2024-04-05T08:00:00Z",
              "instrument_type": "dated_future",
              "settlement_asset": "USDC",
              "underlying": "BTC"
            },
            "ratio": 1,
            "side": "buy"
          }
        ]
      },
      "structure_price": null,
      "taker_company": "bdd68c99-65fe-4500-baae-5bc09b4af183"
    }
  ],
  "pagination": {
    "next_page": null
  }
}
```

</details>

**Python SDK:**

```python
def get_rfqs_sent(self, id: Optional[str] = None,
                  page: Optional[Dict] = None) -> ApiPage[RFQ]

def get_rfqs_received(self, id: Optional[str] = None,
                      page: Optional[Dict] = None) -> ApiPage[RFQ]
```

<details>

<summary>SDK examples</summary>

```python
# iterate over all of your company's sent RFQs
for quote in paginate(client.get_rfqs_sent):
    ...

# fetch a received RFQ by id
rfq_id = "27581879-bc89-4134-87e9-7d9b1bfec396"
quote = client.get_rfqs_received(id=rfq_id).result[0]
```

</details>

### POST /v1/rfqs/new

🔐 🪙 20

Used to create a new RFQ as a taker.

**JSON payload keys:**

* `structure`: Structure — what is being traded
* `qty`: DecimalStr — quantity in units of the structure (multiplied by ratio per leg)
* `expires_at`: DateTimeRFC3339 — expiration time
* `target_companies`: List of Uuid — specific companies that will see the request

<details>

<summary>Example input</summary>

```json
{
  "structure": {
    "legs": [
      {
        "instrument": {
          "instrument_type": "dated_future",
          "underlying": "BTC",
          "settlement_asset": "USDC",
          "expiry": "2024-04-05T08:00:00Z"
        },
        "ratio": 1,
        "side": "buy"
      }
    ]
  },
  "qty": "1",
  "expires_at": "2024-04-03T10:42:19.795911Z",
  "target_companies": [
    "af13119d-4ed1-4718-aea3-fecee4764837"
  ]
}
```

</details>

**Output type:** ApiSingle\[RFQ]

<details>

<summary>Example output</summary>

```json
{
  "result": {
    "asks": [],
    "bids": [],
    "created_at": "2024-04-02T22:42:19.816573Z",
    "qty": "1",
    "quotes_common_metadata": {},
    "rfq_expires_at": "2024-04-03T10:42:19.795911Z",
    "rfq_id": "564eeecb-7466-4af4-b833-907835d6e83b",
    "rfq_legs": [
      {
        "instrument": {
          "expiry": "2024-04-05T08:00:00Z",
          "instrument_type": "dated_future",
          "settlement_asset": "USDC",
          "underlying": "BTC"
        },
        "qty": "1",
        "rfq_id": "564eeecb-7466-4af4-b833-907835d6e83b",
        "rfq_leg_id": "635976ac-d5ea-4f44-b25a-2de18cc0cade",
        "side": "buy"
      }
    ],
    "rfq_status": "open",
    "structure": {
      "legs": [
        {
          "instrument": {
            "expiry": "2024-04-05T08:00:00Z",
            "instrument_type": "dated_future",
            "settlement_asset": "USDC",
            "underlying": "BTC"
          },
          "ratio": 1,
          "side": "buy"
        }
      ]
    },
    "structure_price": {
      "delta": "1",
      "gamma": "0",
      "native_price": "1",
      "price": "65806.226554946",
      "rho": "0",
      "theta": "0",
      "timestamp": "2024-04-02T22:42:19.836190673Z",
      "vega": "0"
    },
    "taker_company": "bdd68c99-65fe-4500-baae-5bc09b4af183"
  }
}
```

</details>

**Python SDK:**

```python
def create_rfq(self, structure: Structure, qty: StrDecimal,
               expires_at: DateTimeRFC3339,
               target_companies: List[UUIDv4]) -> ApiSingle[RFQ]
```

<details>

<summary><strong>SDK examples</strong></summary>

```python
structure = {"legs": [
    {
        "instrument": {
            "instrument_type": InstrumentType.DATED_FUTURE,
            "underlying": "BTC",
            "settlement_asset": "USDC",
            "expiry": "2024-04-05T08:00:00Z"
        },
        "ratio": 1,
        "side": TradeSide.BUY
    }
]}

# send to one company
target_companies = ["af13119d-4ed1-4718-aea3-fecee4764837"]
new_rfq = client.create_rfq(
    structure=structure,
    qty="1",
    expires_at="2024-04-03T10:42:19.795911Z",
    target_companies=target_companies
).result

# send to all companies
my_company_id = client.get_status().result["auth"]["company_id"]
target_companies = [c["id"] for c in paginate(client.get_companies)
                    if c["id"] != my_company_id]
new_rfq = client.create_rfq(
    structure=structure,
    qty="1",
    expires_at="2024-04-03T10:42:19.795911Z",
    target_companies=target_companies
).result
```

</details>

### POST /v1/rfqs/cancel

🔐 🪙 20

Cancels a previously created RFQ.

**JSON payload keys:**

* `id`: Uuid — ID of the RFQ to cancel

<details>

<summary>Example input</summary>

```python
{
  "id": "564eeecb-7466-4af4-b833-907835d6e83b"
}
```

</details>

**Output type:** ApiSingle\[bool]

<details>

<summary>Example output</summary>

```python
{
  "result": true
}
```

</details>

**Python SDK:**

```python
def cancel_rfq(self, id: UUIDv4) -> ApiSingle[bool]
```

<details>

<summary>SDK examples</summary>

```python
client.cancel_rfq(id="3025fca3-114e-4476-a993-93286a7dd43f")
```

</details>

## Settlement Pools

### **GET /v1/settlement\_pools**

🔐 🪙 10

Fetches settlement pools related to the currently authenticated user.

**Parameters:**

* `id`: Uuid (optional) — filters output by settlement pool ID
* `limit`: int (optional, max=1,000) — used for pagination
* `offset`: int (optional) — used for pagination

**Output type**: ApiPage\[SettlementPool]

<details>

<summary>Example output</summary>

```json
{
  "result": [
    {
      "company_id": "bdd68c99-65fe-4500-baae-5bc09b4af183",
      "data": {
        "address": "0x5e5137b6a596a5d7508756c14d07f83ce8535944",
        "name": "API test pool",
        "created_at": "2024-04-03T10:40:11.194670Z",
        "company_creator": "bdd68c99-65fe-4500-baae-5bc09b4af183",
        "positions": [],
        "parties": [
          {
            "company": "bdd68c99-65fe-4500-baae-5bc09b4af183",
            "created_at": "2024-04-03T10:40:11.194670Z",
            "address": "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266",
            "margin_usage": {
              "balance": "0",
              "margin_params": {
                "margin_mode": "simple",
                "params": {
                  "asset_params": {},
                  "auto_liquidation": true,
                  "default_asset_param": {
                    "futures_initial_margin": "0.02",
                    "futures_leverage": "20000",
                    "futures_maintenance_margin": "0.01",
                    "option_initial_margin": "0.15",
                    "option_initial_margin_min": "0.1",
                    "option_maintenance_margin": "0.075"
                  },
                  "liquidation_penalty": "0.1"
                }
              },
              "margin_usage": {
                "initial_margin": "0",
                "maintenance_margin": "0"
              },
              "max_withdrawable_amount": "0"
            },
            "status": "confirmed",
            "confirmed_by_transaction_id": "0x49fcd19e0d6e2ac154c2476ee0e2e4563bb6f4d224dd67f2abdd0d07ff3341c3"
          },
          {
            "company": "af13119d-4ed1-4718-aea3-fecee4764837",
            "created_at": "2024-04-03T10:40:11.194670Z",
            "address": "0xa0ee7a142d267c1f36714e4a8f75612f20a79720",
            "margin_usage": {
              "balance": "0",
              "margin_params": {
                "margin_mode": "simple",
                "params": {
                  "asset_params": {},
                  "auto_liquidation": true,
                  "default_asset_param": {
                    "futures_initial_margin": "0.02",
                    "futures_leverage": "20000",
                    "futures_maintenance_margin": "0.01",
                    "option_initial_margin": "0.15",
                    "option_initial_margin_min": "0.1",
                    "option_maintenance_margin": "0.075"
                  },
                  "liquidation_penalty": "0.1"
                }
              },
              "margin_usage": {
                "initial_margin": "0",
                "maintenance_margin": "0"
              },
              "max_withdrawable_amount": "0"
            },
            "status": "confirmed",
            "confirmed_by_transaction_id": "0x49fcd19e0d6e2ac154c2476ee0e2e4563bb6f4d224dd67f2abdd0d07ff3341c3"
          }
        ],
        "status": "open",
        "confirmed_by_transaction_id": "0x49fcd19e0d6e2ac154c2476ee0e2e4563bb6f4d224dd67f2abdd0d07ff3341c3"
      },
      "pool_id": "cdfbea44-7e75-4688-a3ea-e8d097ae7ede"
    }
  ],
  "pagination": {
    "next_page": null
  }
}
```

</details>

**Python SDK:**

```python
def get_settlement_pools(self, id: Optional[str] = None,
                         page: Optional[Dict] = None) -> ApiPage[SettlementPool]
```

<details>

<summary>SDK examples</summary>

```python
# iterate over settlement pools
for pool in paginate(client.get_settlement_pools):
    ...

# load all settlement pools into a list (eagerly request all pages)
pools = list(paginate(client.get_settlement_pools))

# fetch company metadata by id
company_id = "60c84784-5516-478d-a320-ee82d7303581"
pool = client.get_settlement_pools(id=company_id).result[0]
```

</details>

### POST /v1/**settlement\_pools/new**

🔐 🪙 20

Creates a new settlement pool between the authenticated user and a specific counterparty.

**JSON payload keys:**

* `pool_name`: str (max length: 50 characters) — name for the new settlement pool
* `company_other`: Uuid — counterparty company ID
* `creator_params`: MarginParams — margin parameters for your company
* `other_params`: MarginParams — margin parameters for the counterparty

<details>

<summary>Example input</summary>

```json
{
  "pool_name": "Test pool",
  "company_other": "af13119d-4ed1-4718-aea3-fecee4764837",
  "creator_params": {
    "margin_mode": "simple",
    "params": {
      "liquidation_penalty": "0.1",
      "auto_liquidation": true,
      "asset_params": {},
      "default_asset_param": {
        "futures_initial_margin": "0.02",
        "futures_maintenance_margin": "0.01",
        "futures_leverage": "20000",
        "option_initial_margin": "0.15",
        "option_initial_margin_min": "0.1",
        "option_maintenance_margin": "0.075"
      }
    }
  },
  "other_params": {
    "margin_mode": "simple",
    "params": {
      "liquidation_penalty": "0.1",
      "auto_liquidation": true,
      "asset_params": {},
      "default_asset_param": {
        "futures_initial_margin": "0.02",
        "futures_maintenance_margin": "0.01",
        "futures_leverage": "20000",
        "option_initial_margin": "0.15",
        "option_initial_margin_min": "0.1",
        "option_maintenance_margin": "0.075"
      }
    }
  }
}
```

</details>

**Output type:** ApiSingle\[SettlementPool]

<details>

<summary>Example output</summary>

```json
{
  "result": {
    "company_id": "bdd68c99-65fe-4500-baae-5bc09b4af183",
    "data": {
      "address": null,
      "name": "Test pool",
      "created_at": "2024-04-03T10:40:11.194670Z",
      "company_creator": "bdd68c99-65fe-4500-baae-5bc09b4af183",
      "positions": [],
      "parties": [
        {
          "company": "bdd68c99-65fe-4500-baae-5bc09b4af183",
          "created_at": "2024-04-03T10:40:11.194670Z",
          "address": "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266",
          "margin_usage": {
            "balance": "0",
            "margin_params": {
              "margin_mode": "simple",
              "params": {
                "asset_params": {},
                "auto_liquidation": true,
                "default_asset_param": {
                  "futures_initial_margin": "0.02",
                  "futures_leverage": "20000",
                  "futures_maintenance_margin": "0.01",
                  "option_initial_margin": "0.15",
                  "option_initial_margin_min": "0.1",
                  "option_maintenance_margin": "0.075"
                },
                "liquidation_penalty": "0.1"
              }
            },
            "margin_usage": {
              "initial_margin": "0",
              "maintenance_margin": "0"
            },
            "max_withdrawable_amount": "0"
          },
          "status": "pending",
          "confirmed_by_transaction_id": null
        },
        {
          "company": "af13119d-4ed1-4718-aea3-fecee4764837",
          "created_at": "2024-04-03T10:40:11.194670Z",
          "address": "0xa0ee7a142d267c1f36714e4a8f75612f20a79720",
          "margin_usage": {
            "balance": "0",
            "margin_params": {
              "margin_mode": "simple",
              "params": {
                "asset_params": {},
                "auto_liquidation": true,
                "default_asset_param": {
                  "futures_initial_margin": "0.02",
                  "futures_leverage": "20000",
                  "futures_maintenance_margin": "0.01",
                  "option_initial_margin": "0.15",
                  "option_initial_margin_min": "0.1",
                  "option_maintenance_margin": "0.075"
                },
                "liquidation_penalty": "0.1"
              }
            },
            "margin_usage": {
              "initial_margin": "0",
              "maintenance_margin": "0"
            },
            "max_withdrawable_amount": "0"
          },
          "status": "pending",
          "confirmed_by_transaction_id": null
        }
      ],
      "status": "pending",
      "confirmed_by_transaction_id": null
   },
    "pool_id": "06783112-1acf-4aee-b14b-1b742091a8ab"
  }
}
```

</details>

**Python SDK:**

```python
def create_settlement_pool(self, pool_name: str, company_other: UUIDv4,
                           creator_params: MarginParams,
                           other_params: MarginParams) -> ApiSingle[SettlementPool]
```

<details>

<summary>SDK examples</summary>

```python
margin_params = {
    "margin_mode": MarginMode.SIMPLE,
    "params": {
        "liquidation_penalty": "0.1",
        "auto_liquidation": True,
        "asset_params": {},
        "default_asset_param": {
            "futures_initial_margin": "0.02",
            "futures_maintenance_margin": "0.01",
            "futures_leverage": "20000",
            "option_initial_margin": "0.15",
            "option_initial_margin_min": "0.1",
            "option_maintenance_margin": "0.075",
        },
    }
}
client.create_settlement_pool(
    pool_name="Test pool",
    company_other="af13119d-4ed1-4718-aea3-fecee4764837",
    creator_params=margin_params,
    other_params=margin_params,
)
```

</details>

## Transfers

### **GET /v1/transfers**

🔐 🪙 1

Fetches transfers for the authenticated user.

**Parameters:**

* `pool`: Uuid (optional) — filters output by settlement pool
* `id`: Uuid (optional) — filters output by transfer ID
* `limit`: int (optional, max=10,000) — used for pagination
* `offset`: int (optional) — used for pagination

**Output type**: ApiPage\[Transfer]

<details>

<summary>Example output</summary>

```json
{
  "result": [
    {
      "asset": "USDC",
      "company": "af13119d-4ed1-4718-aea3-fecee4764837",
      "created_at": "2024-04-02T23:16:52.344386Z",
      "id": "1b9eeb56-1c61-4512-aad4-424736826714",
      "oracle_request_id": null,
      "parent_quote_id": "5368f58e-f385-44cc-a9e5-2e8ea51913bb",
      "qty": "0.00000000082679",
      "reference_instrument": null,
      "rfq_id": "564eeecb-7466-4af4-b833-907835d6e83b",
      "status": "confirmed",
      "target_pool_location": "cdfbea44-7e75-4688-a3ea-e8d097ae7ede",
      "transfer_type": "deposit"
    },
    {
      "asset": "USDC",
      "company": "af13119d-4ed1-4718-aea3-fecee4764837",
      "created_at": "2024-04-02T23:02:21.418980Z",
      "id": "0ab57115-bbac-4e1b-9e9e-685dfd44dd89",
      "oracle_request_id": null,
      "parent_quote_id": "5368f58e-f385-44cc-a9e5-2e8ea51913bb",
      "qty": "639.86774699917321",
      "reference_instrument": null,
      "rfq_id": "564eeecb-7466-4af4-b833-907835d6e83b",
      "status": "confirmed",
      "target_pool_location": "cdfbea44-7e75-4688-a3ea-e8d097ae7ede",
      "transfer_type": "deposit"
    }
  ],
  "pagination": {
    "next_page": null
  }
}
```

</details>

**Python SDK:**

```python
def get_transfers(self, pool: Optional[str] = None, id: Optional[str] = None,
                            page: Optional[Dict] = None) -> ApiPage[Transfer]
```

<details>

<summary>SDK examples</summary>

```python
# iterate over all of your company's transfers
for transfer in paginate(client.get_transfers):
    ...

# fetch a transfer by id
transfer_id = "0ab57115-bbac-4e1b-9e9e-685dfd44dd89"
transfer = client.get_transfers(id=transfer_id).result[0]
```

</details>

### POST /v1/transfers/new

🔐 🪙 20

Initiates a new deposit or withdrawal.

**JSON payload keys:**

* **asset**: str — asset to transfer (must be USDC)
* **qty**: StrDecimal — transfer amount
* **target\_pool\_location**: Uuid — settlement pool ID
* **counterparty**: Uuid — company ID of another company in the pool
* **transfer\_type**: TransferType — `deposit` or `withdrawal`

<details>

<summary>Example input</summary>

```json
{
  "asset": "USDC",
  "qty": "10000",
  "target_pool_location": "49dc28fd-c1b1-494b-908c-4eecfa0a3934",
  "counterparty": "af13119d-4ed1-4718-aea3-fecee4764837",
  "transfer_type": "deposit"
}
```

</details>

**Output type:** ApiSingle\[Transfer]

<details>

<summary>Example output</summary>

```json
{
  "result": {
    "asset": "USDC",
    "company": "f58b3d2f-b5a6-488d-b8a9-dc2b1f782be8",
    "created_at": "2024-04-18T06:45:44.391006Z",
    "id": "f5e972eb-1197-4594-a3cd-94304fb5a978",
    "oracle_request_id": null,
    "parent_quote_id": null,
    "qty": "10000",
    "reference_instrument": null,
    "rfq_id": null,
    "status": "pending",
    "target_pool_location": "49dc28fd-c1b1-494b-908c-4eecfa0a3934",
    "transfer_type": "deposit"
  }
}
```

</details>

**Python SDK:**

```python
def create_transfer(self, asset: AssetToken, qty: StrDecimal,
                        target_pool_location: UUIDv4,
                        transfer_type: TransferType) -> ApiSingle[Transfer]
```

<details>

<summary>SDK examples</summary>

```python
transfer = client.create_transfer(
    asset="USDC",
    qty="10000",
    target_pool_location=pool['pool_id'],
    transfer_type=TransferType.DEPOSIT,
).result

from variational import PollingHelper
poller = PollingHelper(api_client)
transfer = poller.wait_for_transfer(transfer['id'])
```

</details>

### POST /v1/transfers/permit/template

🔐 🪙 1

Generates a [ERC-2612](https://eips.ethereum.org/EIPS/eip-2612) spending permit message. To take effect, it needs to be signed by the company wallet's private key and submitted via [POST /v1/transfers/permit](#post-v1-transfers-permit).

**JSON payload keys:**

* **pool\_address**: H160 — address of the settlement pool
* **allowance**: Allowance — unit and value of the spending allowance
* **seconds\_until\_expiry**: int (default: 60) — for how long the permit will be effective

<details>

<summary>Example input</summary>

```json
{
  "pool_address": "0xb1be60448b947528298a2200f27a8abc3964097b",
  "allowance": {
    "type": "decimal",
    "value": "10000"
  },
  "seconds_until_expiry": 3600
}
```

</details>

**Output type**: ApiSingle\[dict]

<details>

<summary>Example output</summary>

```json
{
  "result": {
    "domain": {
      "chainId": "0xa4b1",
      "name": "TestUSDC",
      "verifyingContract": "0xd985d4707ee37295652545513822835b28a9189c",
      "version": "1"
    },
    "message": {
      "deadline": 1713459016,
      "nonce": 0,
      "owner": "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266",
      "spender": "0xb1be60448b947528298a2200f27a8abc3964097b",
      "value": 10000000000
    },
    "primaryType": "Permit",
    "types": {
      "EIP712Domain": [
        {
          "name": "name",
          "type": "string"
        },
        {
          "name": "version",
          "type": "string"
        },
        {
          "name": "chainId",
          "type": "uint256"
        },
        {
          "name": "verifyingContract",
          "type": "address"
        }
      ],
      "Permit": [
        {
          "name": "owner",
          "type": "address"
        },
        {
          "name": "spender",
          "type": "address"
        },
        {
          "name": "value",
          "type": "uint256"
        },
        {
          "name": "nonce",
          "type": "uint256"
        },
        {
          "name": "deadline",
          "type": "uint256"
        }
      ]
    }
  }
}
```

</details>

Python SDK:

```python
def generate_transfer_permit(self, pool_address: H160, allowance: Allowance,
                             seconds_until_expiry: Optional[int] = None) \
                             -> ApiSingle[dict]
```

<details>

<summary>SDK examples</summary>

```python
msg = self.client.generate_transfer_permit(
    pool_address="0xb1be60448b947528298a2200f27a8abc3964097b",
    allowance={
        "type": AllowanceType.DECIMAL,
        "value": "10000"
    },
    seconds_until_expiry=3600
).result

# or use the helper to generate, sign and submit the permit
from variational import TransferPermitHelper

permits = TransferPermitHelper(client=client, private_key=WALLET_PK)
permits.sign_and_submit_decimal(
    pool_address="0xb1be60448b947528298a2200f27a8abc3964097b",
    allowance=str(10000)
)
```

</details>

### POST /v1/transfers/permit

🔐 🪙 20

Submits a signed [ERC-2612](https://eips.ethereum.org/EIPS/eip-2612) spending permit on-chain, allowing transfer of the signer's funds into the settlement pool.

**JSON payload keys:**

* **message**: dict — permit in EIP-712 format generated by [/v1/transfers/permit/template](#post-v1-transfers-permit-template)
* **signature**: str — produced using message and the company wallet's private key

<details>

<summary>Example input</summary>

```json
{
  "message": {
    "domain": {
      "chainId": 42161,
      "name": "TestUSDC",
      "verifyingContract": "0xd985d4707ee37295652545513822835b28a9189c",
      "version": "1"
    },
    "message": {
      "deadline": 1713459016,
      "nonce": 0,
      "owner": "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266",
      "spender": "0xb1be60448b947528298a2200f27a8abc3964097b",
      "value": 10000000000
    },
    "primaryType": "Permit",
    "types": {
      "EIP712Domain": [
        {
          "name": "name",
          "type": "string"
        },
        {
          "name": "version",
          "type": "string"
        },
        {
          "name": "chainId",
          "type": "uint256"
        },
        {
          "name": "verifyingContract",
          "type": "address"
        }
      ],
      "Permit": [
        {
          "name": "owner",
          "type": "address"
        },
        {
          "name": "spender",
          "type": "address"
        },
        {
          "name": "value",
          "type": "uint256"
        },
        {
          "name": "nonce",
          "type": "uint256"
        },
        {
          "name": "deadline",
          "type": "uint256"
        }
      ]
    }
  },
  "signature": "ada7c1b898baf4880c9978ccc1ee38aab685c87b66fd8feff5caf5fc1c07e41106ec04e064e001e6a3064e50b1a9a49f375da04745e347be4d93036b076a099e1c"
}
```

</details>

**Output type:** ApiSingle\[bool]

<details>

<summary>Example output</summary>

```json
true
```

</details>

**Python SDK:**

```python
def submit_transfer_permit(self, message: dict, signature: str) -> ApiSingle[bool]
```

<details>

<summary>SDK examples</summary>

```python
msg = self.client.generate_transfer_permit(
    pool_address="0xb1be60448b947528298a2200f27a8abc3964097b",
    allowance={
        "type": AllowanceType.DECIMAL,
        "value": "10000"
    },
    seconds_until_expiry=3600
).result
# produce_signature() is not provided
signature = produce_signature(msg, WALLET_PK)
client.submit_transfer_permit(message=msg, signature=signature)

# or use the helper to generate, sign and submit the permit
from variational import TransferPermitHelper

permits = TransferPermitHelper(client=client, private_key=WALLET_PK)
permits.sign_and_submit_decimal(
    pool_address="0xb1be60448b947528298a2200f27a8abc3964097b",
    allowance=str(10000)
)
```

</details>

## Utility

### **GET /v1/status**

Returns current authentication information and server time in milliseconds. This endpoint can be used to check connectivity liveness and measure latency.

**Output type**: ApiSingle\[Status]

<details>

<summary>Example output</summary>

```json
{
  "result": {
    "auth": null,
    "server_timestamp_ms": 1707156691716
  }
}
```

</details>

**Python SDK:**

<pre class="language-python"><code class="lang-python"><strong>def get_status(self) -> ApiSingle[Status]
</strong></code></pre>

<details>

<summary>SDK examples</summary>

```python
status = client.get_status().result
```

</details>

### **GET /v1/metadata/supported\_assets**

Returns tokens supported by the platform, their metadata, and funding rate parameters.

**Parameters:**

* `verified`: boolean (optional) — ensures only verified assets are returned

**Output type**: ApiSingle\[Dict\[AssetToken, List\[SupportedAssetDetails]]]

<details>

<summary>Example output</summary>

```json
{
  "result":
  {
    "BTC":
    [
      {
        "asset": "BTC",
        "asset_name": "BTC",
        "is_dex": false,
        "last_updated_at": "2024-03-07T00:03:20.836Z",
        "precision": 8,
        "variational_funding_rate_params":
        {
          "extreme_slope": "0.0000001",
          "extreme_threshold": "0.9",
          "high_slope": "0.00000003",
          "high_threshold": "0.7",
          "min_imbalance_dollars": "10000",
          "normal_slope": "0.00000001",
          "normal_threshold": "0.5"
        }
      }
    ],
    "ETH":
    [
      {
        "asset": "ETH",
        "asset_name": "ETH",
        "is_dex": false,
        "last_updated_at": "2024-03-07T00:03:20.831Z",
        "precision": 8,
        "variational_funding_rate_params":
        {
          "extreme_slope": "0.0000001",
          "extreme_threshold": "0.9",
          "high_slope": "0.00000003",
          "high_threshold": "0.7",
          "min_imbalance_dollars": "10000",
          "normal_slope": "0.00000001",
          "normal_threshold": "0.5"
        }
      }
    ]
  }
}
```

</details>

**Python SDK:**

```python
def get_supported_assets(self, verified: Optional[bool] = False,
                         page: Optional[Dict] = None) \
                            -> ApiSingle[Dict[AssetToken, List[SupportedAssetDetails]]]
```

<details>

<summary>SDK examples</summary>

```python
all_supported_assets = client.get_supported_assets().result
verified_supported_assets = client.get_supported_assets(verified=True).result
```

</details>
