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.Documentation Index
Fetch the complete documentation index at: https://docs.ton.org/llms.txt
Use this file to discover all available pages before exploring further.
Available providers
AppKit supports two swap providers:OmnistonSwapProviderintegrates the STON.fi DEX aggregator through the Omniston SDK:@ston-fi/omniston-sdk. Requires the@ston-fi/omniston-sdkpackage.DeDustSwapProviderintegrates the DeDust Router v2 aggregator. Has no additional dependencies.
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:slippageBpsoverrides the provider default slippage for a single swap.destinationAddresssets a different recipient for the output tokens.deadlinesets 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 theSwapProvider 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 throughgetSwapQuote 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.