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

# Fees

> LP, host, and integrator fee types, accrual, and withdrawal

Trading fees are distributed to liquidity providers and optionally to registered hosts and integrators. This page explains fee types, how they accrue, and how to withdraw them via the SDK.

## Fee Types

* **LP Fee**: Paid by traders to liquidity providers in the asset being swapped **in**.
* **Host Fee**: Optional fee paid in **Asset B** when a pool is created with a `hostNamespace`.
* **Integrator Fee**: Optional fee charged at swap time by integrators, paid in **Asset B**.

<Note>
  All fees for hosts and integrators are assessed and accrued strictly in Asset B of the pool. LP fees are accrued in the asset that the trader provides for the swap. Withdrawals for hosts and integrators are also only in Asset B.
</Note>

## Configuration

* **LP Fee**: Set per pool via `lpFeeRateBps`.
* **Host Fee**: Set per pool via `totalHostFeeRateBps` when using a `hostNamespace`.
  * Hosts register a `minFeeBps`; pools using that namespace must set `totalHostFeeRateBps >= minFeeBps`.
  * Default split of host fees: Flashnet 60%, Host 40%.
* **Integrator Fee**: Set per swap via `integratorFeeRateBps` and optional `integratorPublicKey`.
  * Sharing rule: if `integratorFeeRateBps` ≤ 30 BPS, 0% is shared with Flashnet; above 30 BPS, 30% of the integrator fee is shared with Flashnet.

## Accrual

* **Per Trade**: Fees are computed and accrued on each swap.
* **Asset B Only**: Fees accrue only in Asset B.
* **Real-Time Updates**: Accruals update immediately with executions.

### Querying Accrued Fees

```typescript theme={null}
// Host fees for a specific pool
async function getPoolHostFees(hostNamespace: string, poolId: string) {
  const fees = await client.getPoolHostFees(hostNamespace, poolId);
  console.log('Pool host fees (Asset B):', fees);
}

// Host fees across all pools
async function getHostFees(hostNamespace: string) {
  const fees = await client.getHostFees(hostNamespace);
  console.log('Aggregate host fees (Asset B):', fees);
}

// Integrator fees across all pools
async function getIntegratorFees() {
  const fees = await client.getIntegratorFees();
  console.log('Integrator fees (Asset B):', fees);
}
```

## Withdrawing Fees (Asset B Only)

### Hosts

```typescript theme={null}
// Withdraw all available host fees (Asset B) from a pool
async function withdrawAllHostFees(poolId: string) {
  const res = await client.withdrawHostFees({
    lpIdentityPublicKey: poolId,
  });
  console.log('Host withdrawal:', res);
}

// Withdraw a specific amount of Asset B host fees
async function withdrawPartialHostFees(poolId: string) {
  const res = await client.withdrawHostFees({
    lpIdentityPublicKey: poolId,
    assetBAmount: '500000', // example amount in Asset B units
  });
  console.log('Partial host withdrawal:', res);
}
```

### Integrators

```typescript theme={null}
// Withdraw all available integrator fees (Asset B) from a pool
async function withdrawAllIntegratorFees(poolId: string) {
  const res = await client.withdrawIntegratorFees({
    lpIdentityPublicKey: poolId,
  });
  console.log('Integrator withdrawal:', res);
}

// Withdraw a specific amount of Asset B integrator fees
async function withdrawPartialIntegratorFees(poolId: string) {
  const res = await client.withdrawIntegratorFees({
    lpIdentityPublicKey: poolId,
    assetBAmount: '250000',
  });
  console.log('Partial integrator withdrawal:', res);
}
```

## Best Practices

1. **Surface net amounts** in your UI: amounts shown in simulations and executions are already post‑fee.
2. **Host compliance**: Ensure `totalHostFeeRateBps` meets the host’s `minFeeBps` when using a namespace.
3. **Integrator fee disclosure**: Display `integratorFeeRateBps` transparently to users.

## Related

* [Hosts](/products/flashnet-amm/hosts)
* [Swaps](/products/flashnet-amm/swaps)
* [Liquidity](/products/flashnet-amm/liquidity)
