Skip to main content
AppKit supports on-chain token swaps through pluggable swap providers. Supported swap kinds are Toncoin to jetton and jetton to jetton. The swap flow has two steps: get a quote for the desired trade, then build and send the swap transaction.

Available providers

AppKit supports two swap providers:
  • OmnistonSwapProvider integrates the STON.fi DEX aggregator through the Omniston SDK: @ston-fi/omniston-sdk. Requires the @ston-fi/omniston-sdk package.
  • DeDustSwapProvider integrates the DeDust Router v2 aggregator. Has no additional dependencies.
Register one or more providers during AppKit initialization. AppKit uses the first registered swap provider by default. Pass providerId when requesting a quote to target a specific provider.

Get a swap quote

A swap quote estimates how many tokens are received for a given input amount. The quote requires the source token, destination token, and the amount to swap.

Build and send the swap transaction

Building a swap transaction requires a quote and the sender wallet address. Some parameters are optional:
  • slippageBps overrides the provider default slippage for a single swap.
  • destinationAddress sets a different recipient for the output tokens.
  • deadline sets a UNIX timestamp after which the transaction becomes invalid.

Create a custom swap provider

Custom providers can be added to integrate other DEXes or aggregators. A swap provider implements the SwapProvider interface — two methods for quoting and transaction building: getQuote() and buildSwapTransaction(). The following example assumes DEX APIs that return SwapQuote and TransactionRequest in the exact shapes AppKit expects. In practice, the contents of response.json() require additional mapping and processing before the results can be safely produced from the getQuote() and buildSwapTransaction() functions, respectively.
TypeScript

Register the provider

Register the custom provider during AppKit initialization or dynamically at runtime:

Specify the provider

Once registered, the provider is available through getSwapQuote and buildSwapTransaction. Target it by passing providerId: 'custom-dex' when fetching quotes. AppKit uses the first registered swap provider by default. To change the default later, call kit.swapManager.setDefaultProvider('custom-dex'). Inspect registered provider IDs with kit.swapManager.getRegisteredProviders(). Check whether an ID is already in use with kit.swapManager.hasProvider('custom-dex') before registering a new provider.

See also