For the complete documentation index, see llms.txt. This page is also available as Markdown.

Fees

Configure integrator fees and distinguish gross output from recipient output.

Custom fees are output-side integrator fees bound into the signed ExecutionPlan. Set customFeeBps and customFeeReceiver directly on swapAllowance() or swapPermit2().

Configure fees

One basis point is 0.01%; 20 bps is 0.2%. Omit the fee or use zero to request no custom fee. Use params for trade inputs (from, target, amount, real executor and optional route controls), and fee = { feeAccount: receiverAddress, feeBps: 20 } in this example.

const prepared = await client.swapAllowance({
  ...params,
  customFeeBps: fee.feeBps, customFeeReceiver: fee.feeAccount,
  slippageBps: params.slippageBps ?? 50, // Explicit default: 0.5%
  deadlineSecs: params.deadlineSecs ?? 300,
});

Use the returned net output and minimum for confirmation, then follow Quickstart for submission. In Permit2, set fees during preparation; signing and build preserve that plan.

Fee limits

Layer
v0.5.0 behavior

Preparation helpers

Integer customFeeBps in [0, 10000]; positive fees require a nonzero receiver; violations throw ExecutionRouterValidationError

Deployed service and contracts

Can enforce additional rules or lower live limits

The preparation range is a local input bound, not a promise that a 100% fee is executable. Apply the live service and contract cap.

getRouterConfig(routerAddress) reads the underlying PeachRouter's maxCustomFeeBps, pause state and protocol split. This is the underlying router address, not the Execution Router. A prepared Direct result exposes it as legacyRouterAddress. getProtocolFeeConfig(routerAddress) reads the receiver and protocol share. These mutable values are display/configuration snapshots; they do not override the signed plan.

Output amounts and fees

Value
Meaning

prepared.amountOut

Gross prepared output

prepared.expectAmountOut

Expected prepared recipient output after custom fee

ready.execution.plan.minAmountOut

Signed minimum; Direct prepared results are already ready

simulation.userAmountOut

Simulated actual recipient output

For a built Delegated result, the gross and expected prepared amounts remain in ready.prepared.amountOut and ready.prepared.expectAmountOut; the signed expected amount is ready.execution.plan.expectedAmountOut. A built result does not expose top-level amountOut or expectAmountOut.

Display projection uses integer arithmetic: fee = gross * feeBps / 10000, then net = gross - fee. protocolCutBps is a share of the custom fee, not of the whole swap output. Direct response fee metadata is available in prepared.raw; the SDK checks the total and split sums against the response.

See Slippage for minimum received and positive-slippage settlement.

Legacy quote fees

For getQuote(), pass options.customFee = { feeAccount, feeBps }. A supplied fee requires integer bps in [1, 500] and a nonzero receiver; invalid values throw CustomFeeError. quote.amountOut is net, quote.route.totalAmountOut is gross, and quote.customFee.feeAmount is the projected total fee before protocol split. See Migration Guide when replacing this display-only API.

Last updated

Was this helpful?