Execute your swap or call
We allow you to execute any on-chain or cross-chain swap and bridging process and a combination of both.
Executing a route requires a signer to be set up. How to set up a signer.

executeRoute

Type: ExecuteRoute
const tx = await squid.executeRoute({ signer, route, executionSettings })
executionSettings is optional
This function handles approval logic, and will return the executed route once approval and the swap has been completed. ( Returns ethers.providers.TransactionResponse )

Example code snippet

const signer = new ethers.Wallet(privateKey, provider)
const params = {
recipientAddress: signer.address,
sourceChainId: 3, // Ropsten Ethereum
sourceTokenAddress: "0xc778417E063141139Fce010982780140Aa0cD5Ab", // WETH on Ropsten
sourceAmount: "20000000000000000", // 0.02 WETH
destinationChainId: 1287, // Moonbase Alpha
destinationTokenAddress: "0xd1633f7fb3d716643125d6415d4177bc36b7186b", axlUSDC on Moonbeam
slippage: 1
}
const { route } = await squidSdk.getRoute(params)
const tx = await squidSdk.executeRoute({
signer,
route
})
const txReceipt = await tx.wait()
console.log(txReceipt)

executionSettings

In addition to the first two parameters, executeRoute takes an optional executionSettings object as a third parameter.
This can contain an infiniteApproval boolean which allows you to choose whether Squid will approve an infinite amount of tokens to be swapped via Squid in future, or only the amount necessary for this trade. infiniteApproval is defaults to true if not set by the user.
Copy link
On this page
executeRoute
Example code snippet
executionSettings