Configuration
Configuration options and settings for @tetherto/wdk-protocol-swap-stonfi-ton
Swap Service Configuration
The StonFiProtocolTon accepts a configuration object that sets how the swap service works:
import StonFiProtocolTon from '@tetherto/wdk-protocol-swap-stonfi-ton'
import { WalletAccountTon } from '@tetherto/wdk-wallet-ton'
// Create wallet account first
const account = new WalletAccountTon(seedPhrase, {
tonApiKey: 'YOUR_TON_API_KEY',
tonApiEndpoint: 'YOUR_TON_API_ENDPOINT'
})
// Create swap service with configuration
const swapProtocol = new StonFiProtocolTon(account, {
swapMaxFee: 1000000000n // Optional: Max swap fee in nanotons
})Account Configuration
The swap service uses the wallet account's configuration for TON access:
Configuration Options
Swap Max Fee
The swapMaxFee option sets a top limit for total swap costs to prevent very high fees.
Type: bigint (optional)
Unit: Nanotons (1 TON = 1000000000 nanotons)
Examples:
TON API Configuration
The TON API options come from the wallet account configuration and tell how to connect to TON:
TON API Key: string - Your TON API access key
TON API Endpoint: string - TON API server URL
TON Center Key: string - TON Center access key (optional)
TON Center Endpoint: string - TON Center server URL (optional)
Examples:
Gasless Configuration
When using gasless accounts, you can change configuration options during swap operations:
Paymaster Token
The paymasterToken option says which token to use for paying fees in gasless accounts.
Type: string (optional)
Format: Token name or address
Example:
Note: Gasless swaps only work with jetton-to-jetton pairs. TON-to-jetton and jetton-to-TON swaps need standard (non-gasless) accounts.
Network Support
The swap service works with TON network. Change the API settings in the wallet account configuration:
Swap Options
When calling the swap method, you need to give swap options:
Token In
The tokenIn option says which token to sell.
Type: string
Format: Use 'ton' for native TON or jetton token address
Token Out
The tokenOut option says which token to buy.
Type: string
Format: Use 'ton' for native TON or jetton token address
Token In Amount
The tokenInAmount option says how many tokens to sell.
Type: bigint
Unit: Base units of the token (for TON: 1 TON = 1000000000n nanotons)
Token Out Amount
The tokenOutAmount option says how many tokens to buy (exact output).
Type: bigint
Unit: Base units of the token
Note: Use either tokenInAmount OR tokenOutAmount, not both.
Slippage Tolerance
The slippageTolerance option sets how much price change you accept.
Type: number (optional)
Format: Decimal number (0.01 = 1%)
Default: 0.0001 (0.01%)
Examples:
Recipient Address
The to option says where to send the bought tokens.
Type: string (optional)
Format: Valid TON address
Default: Your own address
Example:
Error Handling
The swap service will throw errors for bad configurations:

