Squid Documentation
Search…
Integrate our smart contracts directly
Squidswap integration example.
We are currently in early development of an SDK package to allow for easy integration with our Squid contract. Until the SDK is published, it is still possible to integrate directly with the Squid contracts using the following guidance.
Please use these instruction with caution since they may be outdated/update frequently. Squid has 4 different integration modes.

Definitions

sourceChain (srcChain) - connected network which originates the transfer. destinationChain (destChain) - network target for transfer. sourceTrade - token exchange on sourceChain. destinationTrade - token exchange after transfer to destinationChain

TradeSend

executes a sourceTrade (swap) before the assets are sent to destChain
function tradeSend(
string memory destinationChain,
string memory destinationAddress,
string memory symbol,
bytes memory tradeData
) external payable

Arguments

destinationChain - network name "ethereum", "moonbeam", "avalanche" destinationAddress - Squid contract on destinationChain symbol - Axelar cross chain token symbol (aUSDC) Testnet tradeData - UniswapV2 encoded calldata to execute the swap

SendTrade

executes a destinationTrade (swap) after assets are send to destination chain.
function sendTrade(
string memory destinationChain,
string memory symbol,
uint256 amount,
bytes memory tradeData,
bytes32 traceId,
address fallbackRecipient,
uint16 inputPos
) external payable

Arguments

destinationChain - network name "ethereum", "moonbeam", "avalanche" symbol - Axelar chross chain token symbol (aUSDC) Testnet amount - aUSDC amount to bridge tradeData - UniswapV2 encoded calldata to execute the swap on destination chain traceID - uuid used for protocol internal tracking/correlation of transactions fallbackRecipient - user address in case the swap on destination chain fails (refund of aUSDC to user) inputPos - constant number indicating the amount input position in calldata (196 for uniswap calldata)

TradeSendTrade

executes a source chain trade (swap) then bridge assets followed by the destination chain trade (swap).
function tradeSendTrade(
string memory destinationChain,
string memory symbol,
bytes memory tradeData1,
bytes memory tradeData2,
bytes32 traceId,
address fallbackRecipient,
uint16 inputPos
) external payable

Arguments

destinationChain - network name "ethereum", "moonbeam", "avalanche" symbol - Axelar chross chain token symbol (aUSDC) Testnet amount - aUSDC amount to bridge tradeData1 - encoded calldata to execute the swap on source chain tradeData2 - encoded calldata to execute the swap on destination chain traceID - uuid used for protocol internal tracking/correlation of transactions fallbackRecipient - user address in case the swap on destination chain fails (refund of aUSDC to user) inputPos - constant number indicating the amount input position in calldata (196 for uniswap calldata)

Calldata example

// javascript example to encode calldata
// swapPath - asset route [fromToken, toToken]
// amount - expected output amount
// routerAddress - swap router (uniswapv2, uniswapv3, curve etc.)
// swapPayload - router specific call data encoding
ethers.utils.defaultAbiCoder.encode(
["address", "uint256", "address", "bytes"],
[swapPath[0], amount, routerAddress, swapPayload]
);
Please also see reference example repo below:
GitHub - 0xsquid/squidswap-abi-example: squidswap abi integration example
GitHub
Copy link
On this page
Definitions
TradeSend
SendTrade
TradeSendTrade
Calldata example