Swap
This guide demonstrates how to fetch token data, quote, and execute token swaps using the Holdstation SDK.
Installation
Setup
Overall Flow
Call
tokenProvider.details(...)
to fetch token metadata if needed.(Optional) Call
quoter.simple()
orquoter.smart()
to preview routes.Call
swapHelper.quote(params)
withSwapParams["quoteInput"]
to get a live quote for swapping.Call
swapHelper.swap(...)
withSwapParams["input"]
using the result from quote.(Optional) Ensure
feeReceiver
is whitelisted on the contract if you are charging a fee.
Token Metadata
Get Token Info
Get Multiple Token Details
Quoter
Simple Quote
Smart Quote (Slippage + Deadline)
π Parameters β SwapParams["quoteInput"]
SwapParams["quoteInput"]
tokenIn
string
β Yes
Input token address
tokenOut
string
β Yes
Output token address
amountIn
string
β Yes
Input amount (human-readable format)
slippage
string
β Yes
Slippage percentage (e.g., "0.3"
for 0.3%)
fee
string
β Yes
Fee percentage (e.g., "0.2"
for 0.2%)
π Usage Example β Estimate Quote
Execute Swap
π Parameters β SwapParams["input"]
SwapParams["input"]
tokenIn
string
β Yes
Input token address
tokenOut
string
β Yes
Output token address
amountIn
string
β Yes
Input token amount
tx
object
β Yes
Transaction data returned from quote()
fee
string
β Yes
Fee percentage
feeAmountOut
string
β Optional
Fee amount to take from output token
feeReceiver
string
β Yes
Address to receive fee (use AddressZero
if none)
π Usage Example β Execute Swap
π Full Example on GitHub
Check the full swap flow example:
Last updated