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

# Withdrawal Fees

> Calculate withdrawal fees via the FeeModule contract

Equivalent to SDK's [`getWithdrawalFee()`](/v0.5.2/intro/products/earn/developers/api/display/getWithdrawalFee). Reads from the WithdrawQueue's FeeModule on-chain.

## Contract Methods

Reading withdrawal fees requires two calls — first to get the FeeModule address, then to calculate the fee.

### Step 1: `WithdrawQueue.feeModule()`

Returns the address of the FeeModule contract.

**Returns**: `address` — FeeModule contract address

### Step 2: `FeeModule.calculateOfferFees(amount, offerAsset, wantAsset, receiver)`

Calculates the fee that will be deducted from a withdrawal order.

| Parameter    | Type      | Description                                         |
| ------------ | --------- | --------------------------------------------------- |
| `amount`     | `uint256` | Account shares to offer                             |
| `offerAsset` | `address` | BoringVault address (the share token being offered) |
| `wantAsset`  | `address` | Token the user wants to receive (e.g., USDC)        |
| `receiver`   | `address` | Address that will receive the want asset            |

**Returns**: `uint256 feeAmount` — fee in account shares (18 decimals)

### `FeeModule.offerFeePercentage()`

Returns the fee percentage applied to withdrawal orders.

**Returns**: `uint256` — fee percentage with 18-decimal precision (e.g., `5000000000000000` = 0.5%)

## ABI

### WithdrawQueue (fee module lookup)

```json theme={null}
[
  {
    "inputs": [],
    "name": "feeModule",
    "outputs": [{ "name": "", "type": "address" }],
    "stateMutability": "view",
    "type": "function"
  }
]
```

### FeeModule

```json theme={null}
[
  {
    "inputs": [
      { "name": "amount", "type": "uint256" },
      { "name": "offerAsset", "type": "address" },
      { "name": "wantAsset", "type": "address" },
      { "name": "receiver", "type": "address" }
    ],
    "name": "calculateOfferFees",
    "outputs": [{ "name": "feeAmount", "type": "uint256" }],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "offerFeePercentage",
    "outputs": [{ "name": "", "type": "uint256" }],
    "stateMutability": "view",
    "type": "function"
  }
]
```

## Usage

Call `feeModule()` on the **WithdrawQueue** contract (`vault.withdrawQueueModuleId` from [Account Discovery](/v0.5.2/intro/products/earn/developers/guides/direct-contract/vault-queries/vault-discovery)), then call `calculateOfferFees()` on the returned FeeModule address.

```
feeModuleAddress = WithdrawQueue.feeModule()
feeAmount        = FeeModule.calculateOfferFees(shareAmount, boringVaultAddress, wantAssetAddress, receiverAddress)
feePercentage    = FeeModule.offerFeePercentage()
```

<Warning>
  The fee is subtracted from the account shares you offer. If you offer 100 shares
  and the fee is 0.5 shares, only 99.5 shares worth of the want asset will be
  sent to the receiver. Account for this when displaying withdrawal amounts to
  users.
</Warning>
