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

Claiming & swapping accumulated fees

Claim the fees your integration has accumulated, or convert them into one target asset.

Your fee accumulates on the collector as plain token balances — the fee comes out of each swap's output token, so a collector serving many pairs holds many tokens. Claims are per token, only the collector's operator can call them, and every claim pays out to the fee_destination fixed at deploy time.

This page uses the official SDKs (0.5.0 or later). The contract-level flow below covers other languages.

Read what has accrued

Reads need no signer. balance returns 0 for a token the collector has never held:

from aquarius import AquariusClient, Asset, XLM

AQUA = Asset.classic("AQUA", "GBNZILSTVQZ4R7IKQDGHYGY2QXL5QOFJYQMXPKWRRM5PAV7Y4M67AQUA")

aqua = AquariusClient(network="mainnet")
collector = aqua.fee_collector("C...")   # your deployed collector

print(collector.fee_destination())       # where claims pay out
print(collector.balance(AQUA))           # accrued fees in AQUA, base units
import { AquariusClient, Asset, XLM } from "@aquariusdefi/sdk";

const AQUA = Asset.classic("AQUA", "GBNZILSTVQZ4R7IKQDGHYGY2QXL5QOFJYQMXPKWRRM5PAV7Y4M67AQUA");

const aqua = new AquariusClient({ network: "mainnet" });
const collector = aqua.feeCollector("C...");   // your deployed collector

console.log(await collector.feeDestination()); // where claims pay out
console.log(await collector.balance(AQUA));    // accrued fees in AQUA, base units

Claim and convert into one asset

claim_and_swap claims a token's entire accrued balance, swaps it through the router along a fresh quoted route, and sends the output token to the fee destination. The minimum-out guard comes from the quote, so a moving market fails the claim instead of underdelivering. The signer must be the operator:

from stellar_sdk import Keypair

USDC = Asset.classic("USDC", "GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN")

aqua = AquariusClient(network="mainnet", signer=Keypair.from_secret("S..."))
collector = aqua.fee_collector("C...")

claimed = collector.claim_and_swap(AQUA, USDC, slippage=0.01)
print(f"claimed {claimed.amount_in} AQUA -> {claimed.amount_out} USDC")
print(f"transaction: {claimed.tx_hash}")
import { Keypair } from "@stellar/stellar-sdk";

const USDC = Asset.classic("USDC", "GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN");

const aqua = new AquariusClient({ network: "mainnet", signer: Keypair.fromSecret("S...") });
const collector = aqua.feeCollector("C...");

const claimed = await collector.claimAndSwap(AQUA, USDC, { slippage: 0.01 });
console.log(`claimed ${claimed.amountIn} AQUA -> ${claimed.amountOut} USDC`);
console.log(`transaction: ${claimed.txHash}`);

Claim raw

claim sweeps one token's balance to the fee destination without conversion. For classic assets the destination needs a trustline for that token:

Contract-level flow (any language)

The collector functions behind claim_and_swap and claim, called directly:

Claim and immediately swap

  • Function: claim_fees_and_swap(e, operator: Address, swaps_chain: Vec<…>, token: Address, out_min: u128) -> u128

  • Effect:

    1. Claims all of token.

    2. Swaps via your router along swaps_chain.

    3. Sends resulting tokens to fee_destination.

  • Returns: Final output amount in the target asset.

Claim raw fees

  • Function: claim_fees(e, operator: Address, token: Address) -> u128

  • Effect: Transfers entire token balance from the contract to fee_destination.

Last updated