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

Claim integrator fees

Discover DEX v2 fee Vaults and build withdrawals for the owner wallet.

Use this guide to claim accrued DEX v2 Vault fees. DEX v1 pays directly and has no matching Vault withdrawal. Supply the actual owner wallet and router metadata; see DEX fees and Setup and environments.

Mainnet workflow

  1. Discover the vaults owed to the operator (e.g., via stonApiClient.getWalletVaultsFee).

  2. Fetch router metadata for each vault using getRouter(routerAddress).

  3. Build the router contracts dynamically with routerFactory and request the vault instance.

  4. Generate the withdrawal transaction parameters.

import { Client, routerFactory } from "@ston-fi/sdk";
import { StonApiClient } from "@ston-fi/api";

const tonClient = new Client({
  endpoint: "https://toncenter.com/api/v2/jsonRPC",
  apiKey: process.env.TON_API_KEY,
});

const apiClient = new StonApiClient();

const userWalletAddress = "<your wallet address>";

// Retrieve pending vault fees for the wallet
const vaults = await apiClient.getWalletVaultsFee({
  walletAddress: userWalletAddress,
});

const txParams = await Promise.all(
  vaults.map(async ({ routerAddress, assetAddress }) => {
    const routerMetadata = await apiClient.getRouter(routerAddress);
    const router = tonClient.open(routerFactory(routerMetadata));

    if (!("getVault" in router)) {
      throw new Error(
        `Vault contract is not supported on router version ${routerMetadata.majorVersion}.${routerMetadata.minorVersion}`,
      );
    }

    const tokenMinter =
      assetAddress === "EQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAM9c"
        ? routerMetadata.ptonMasterAddress
        : assetAddress;

    const vault = tonClient.open(
      await router.getVault({
        tokenMinter,
        user: userWalletAddress,
      }),
    );

    return vault.getWithdrawFeeTxParams({
      queryId: 12345,
    });
  }),
);

Pass the resulting txParams array to your preferred wallet sender (see the transaction sending guide). These are SDK parameters; the sender performs the wallet-specific conversion.

TON fees: TON does not have a jetton minter address. When assetAddress equals the canonical TON address (EQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAM9c), pass routerMetadata.ptonMasterAddress as the tokenMinter so the SDK resolves the correct proxy contract.

Testnet withdrawal (manual setup)

To withdraw fees on TON testnet, configure testnet contracts and use a wallet with accrued Vault fees. The api.ston.fi endpoint serves mainnet data.

This manual approach is strictly for testing. Switch back to the API-driven workflow for mainnet deployments. For the payout model, see DEX fees.

Check the result

Select Vaults with a positive balance. After each withdrawal is processed, inspect the Vault balance and token transfer. Keep batches within the connected wallet’s message capacity. DEX v1 fees are paid directly; these Vault datasets cover DEX v2.

Use the REST transaction action tree to inspect the submitted operation.

Last updated