Deploying a new fee collector
Deploy your own fee collector contract and configure its fee parameters.
To receive fees from swaps, deploy your own fee collector instance through the Provider Swap Fee Factory. With the SDK it is one call — the signer becomes the collector's operator:
from stellar_sdk import Keypair
from aquarius import AquariusClient
aqua = AquariusClient(network="mainnet", signer=Keypair.from_secret("S..."))
collector = aqua.deploy_fee_collector(
max_fee_fraction=100, # per-swap fee_fraction cap: 100 / 10_000 -> up to 1%
fee_denominator=10_000, # basis points; raise for finer fee resolution
fee_destination="G...", # optional — defaults to the operator (the signer)
)
print(f"collector deployed: {collector.address}")import { Keypair } from "@stellar/stellar-sdk";
import { AquariusClient } from "@aquariusdefi/sdk";
const aqua = new AquariusClient({ network: "mainnet", signer: Keypair.fromSecret("S...") });
const collector = await aqua.deployFeeCollector({
maxFeeFraction: 100, // per-swap feeFraction cap: 100 / 10000 -> up to 1%
feeDenominator: 10_000, // basis points; raise for finer fee resolution
feeDestination: "G...", // optional — defaults to the operator (the signer)
});
console.log(`collector deployed: ${collector.address}`);Parameters, fixed at deploy time:
operator
The signer. The only address that can claim fees.
fee_destination
Where every claim pays out. Cannot be changed later — not even by the operator.
max_fee_fraction
Upper bound for the per-swap fee_fraction this collector accepts. At most 20% of fee_denominator (2,000 with a denominator of 10,000); a higher value fails the deployment with FeeFractionTooHigh.
fee_denominator
The fraction's denominator. 10,000 (basis points) works well; record it — the contract has no getter, and every ProviderFeeConfig must match it.
A collector is never upgraded: it keeps the methods it was deployed with, so support for output recipients depends on when you deployed it.
The operator and the fee destination can be the same address; separate addresses are safer. The destination needs trustlines for any asset the operator claims raw — or convert claims into one asset with claim_and_swap.
Verify the deployment with the collector's read methods:
Charge fees on swaps with collector.fee_config(fee_fraction) — see Executing swaps with provider fees.
Complete code examples
This code deploys a fee collector on the Stellar mainnet that accepts fees of up to 1% with the denominator 10,000, then reads its configuration back from the new contract.
To execute the code, provide the secret key of the account that becomes the operator and pays for the deployment, and the address that receives the claimed fees. Save the JavaScript version as a .mjs file: it uses top-level await.
Contract-level flow (any language)
The factory function behind deploy_fee_collector:
Function:
deploy_swap_fee_contract(operator: Address, fee_destination: Address, max_swap_fee_fraction: u32, swap_fee_fraction_denominator: u32) -> AddressReturns: Address of the newly deployed ProviderSwapFeeCollector.
The parameters are described in Provider fee contracts. The call needs the operator's authorization for the root call only, as listed in Contract authorization.
Last updated