> ## Documentation Index
> Fetch the complete documentation index at: https://developers.paxoslabs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Calculate Withdrawal Fee

> Compute the withdrawal fee a user would be charged for a given offer amount and want asset

`GET /v2/amplify/calculateWithdrawalFee` returns the fee a user would be charged for redeeming a specific `offerAmount` of shares for a given `wantAsset`.

Use this endpoint to preview fees in a withdrawal confirmation UI before submitting the order via `GET /v2/amplify/withdraw`.

<Info>
  The withdrawal endpoint already accounts for fees — you do **not** need to call `calculateWithdrawalFee` before preparing withdrawal calldata. It exists purely for display.
</Info>

## Parameters

| Parameter      | Type     | Required | Description                                                          |
| -------------- | -------- | -------- | -------------------------------------------------------------------- |
| `offerAmount`  | `string` | Yes      | Share amount to withdraw in base units (decimal string, 18 decimals) |
| `wantAsset`    | `string` | Yes      | ERC-20 token address the user wants to receive                       |
| `vaultAddress` | `string` | Yes      | BoringVault contract address (`0x` + 40 hex chars)                   |
| `chainId`      | `number` | Yes      | EVM chain ID                                                         |

## Example

<Tabs>
  <Tab title="curl">
    ```bash theme={null}
    curl "https://api.paxoslabs.com/v2/amplify/calculateWithdrawalFee?\
    offerAmount=1000000000000000000&\
    wantAsset=0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48&\
    vaultAddress=0xbbbb000000000000000000000000000000000001&\
    chainId=1" \
      -H "x-api-key: pxl_your_key"
    ```
  </Tab>

  <Tab title="Node.js">
    ```ts theme={null}
    const url = new URL(
      "https://api.paxoslabs.com/v2/amplify/calculateWithdrawalFee"
    );
    url.searchParams.set("offerAmount", "1000000000000000000");
    url.searchParams.set("wantAsset", "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48");
    url.searchParams.set("vaultAddress", "0xbbbb000000000000000000000000000000000001");
    url.searchParams.set("chainId", "1");

    const resp = await fetch(url, {
      headers: { "x-api-key": process.env.AMPLIFY_API_KEY! },
    });
    const data = await resp.json();
    console.log(
      `Fee: ${data.feeAmount} (${data.offerFeePercentage.percentage}%), flat: ${data.flatFee}`
    );
    ```
  </Tab>

  <Tab title="Python">
    ```python theme={null}
    import requests

    resp = requests.get(
        "https://api.paxoslabs.com/v2/amplify/calculateWithdrawalFee",
        headers={"x-api-key": "pxl_your_key"},
        params={
            "offerAmount": "1000000000000000000",
            "wantAsset": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
            "vaultAddress": "0xbbbb000000000000000000000000000000000001",
            "chainId": 1,
        },
    )
    data = resp.json()
    print(
        f"Fee: {data['feeAmount']} "
        f"({data['offerFeePercentage']['percentage']}%), "
        f"flat: {data['flatFee']}"
    )
    ```
  </Tab>

  <Tab title="Go">
    ```go theme={null}
    params := url.Values{
        "offerAmount":  {"1000000000000000000"},
        "wantAsset":    {"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"},
        "vaultAddress": {"0xbbbb000000000000000000000000000000000001"},
        "chainId":      {"1"},
    }
    req, _ := http.NewRequest("GET",
        "https://api.paxoslabs.com/v2/amplify/calculateWithdrawalFee?"+params.Encode(),
        nil)
    req.Header.Set("x-api-key", os.Getenv("AMPLIFY_API_KEY"))
    resp, _ := http.DefaultClient.Do(req)
    defer resp.Body.Close()
    ```
  </Tab>

  <Tab title="Java">
    ```java theme={null}
    String feeUrl = String.format(
        "https://api.paxoslabs.com/v2/amplify/calculateWithdrawalFee?" +
        "offerAmount=%s&wantAsset=%s&vaultAddress=%s&chainId=%d",
        "1000000000000000000",
        "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
        "0xbbbb000000000000000000000000000000000001",
        1);
    HttpRequest req = HttpRequest.newBuilder()
        .uri(URI.create(feeUrl))
        .header("x-api-key", System.getenv("AMPLIFY_API_KEY"))
        .GET().build();
    HttpResponse<String> resp = httpClient.send(req, HttpResponse.BodyHandlers.ofString());
    JsonObject data = JsonParser.parseString(resp.body()).getAsJsonObject();
    ```
  </Tab>
</Tabs>

## Response

```json theme={null}
{
  "feeAmount": "0.05",
  "offerFeePercentage": { "bps": 25, "percentage": "0.2500" },
  "flatFee": "1.05"
}
```

| Field                           | Type               | Description                                                                                        |
| ------------------------------- | ------------------ | -------------------------------------------------------------------------------------------------- |
| `feeAmount`                     | `string` (decimal) | Total fee for this `offerAmount` + `wantAsset`, human-readable (scaled by the want-asset decimals) |
| `offerFeePercentage.bps`        | `number`           | Fee percentage in basis points (`25` = 0.25%)                                                      |
| `offerFeePercentage.percentage` | `string`           | Human-readable percentage with 4 decimals (e.g. `"0.2500"`)                                        |
| `flatFee`                       | `string` (decimal) | Flat per-withdrawal fee, denominated in the want asset (human-readable units)                      |

## Error Responses

| Status | Meaning                                                                  |
| ------ | ------------------------------------------------------------------------ |
| 400    | Invalid parameters (bad address, non-numeric `offerAmount`, etc.)        |
| 404    | No fee module configured for the given `vaultAddress` + `wantAsset` pair |
| 503    | Upstream service unavailable                                             |
