Learn how to build on the decentralized web
Account Abstraction Wallet
SDK Functions
Swap

Swap functions

const bestTrade = (await smartwallet.swap.getBestTrade({
  smartWalletAddress: storedWallet.smartWalletAddress,
  tradeInput: {
    tradeType: TradeType.EXACT_INPUT,
    tokenAmountFromBeforeWeiConversion,
  },
  fromTokenAddress,
  toTokenAddress,
}))!;
const swap = await smartwallet.swap.swap({
  dumbWallet: storedWallet.dumbWallet,
  smartWalletAddress: storedWallet.smartWalletAddress,
  tradeInfo: bestTrade,
});
const { transactionFee } = await swap.estimateFree();
const swapTX = await swap.sendFree();
await smartwallet.transactions.getTransactionConfirmation(swapTX);