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 (asset in).
  • Host Fee: Optional fee when a pool is created with a hostNamespace.
  • Integrator Fee: Optional fee charged at swap time by integrators via integratorFeeRateBps.
All fees are assessed and accrued strictly in Asset B of the pool. Withdrawals are also only in Asset B.

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

// 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

// 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

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