Squid Router icon

Squid Router

Squid Router action

Overview

The "Squid Router" node integrates with the Squid Router API to facilitate cross-chain token swaps. Specifically, the Build Swap Route operation constructs a swap route between two blockchain networks, specifying source and target tokens, chains, and addresses involved. This node is useful for users who want to programmatically determine the best path for swapping tokens across different blockchains, including slippage tolerance.

Practical examples:

  • A DeFi application that needs to find optimal routes for token swaps between Ethereum and Binance Smart Chain.
  • Automated workflows that prepare swap transactions by fetching routing data before execution.
  • Cross-chain payment systems that require dynamic routing of assets from sender to recipient on different chains.

Properties

Name Meaning
Sender Address The blockchain address initiating the swap (source wallet).
Recipient Address The blockchain address receiving the swapped tokens (destination wallet).
Source Chain ID Identifier of the blockchain network where the source tokens reside.
Target Chain ID Identifier of the blockchain network where the target tokens will be received.
Source Token Address The contract address of the token to swap from on the source chain.
Target Token Address The contract address of the token to receive on the target chain.
Amount The amount of source tokens to swap, specified as a number with up to 8 decimal places.
Slippage Optional slippage tolerance percentage allowed during the swap, with up to 2 decimal places.

Output

The output JSON contains the swap route details returned by the Squid Router API. This includes information such as:

  • The steps or legs of the swap route.
  • Estimated amounts and fees.
  • Tokens and chains involved.
  • Any additional metadata required to execute the swap.

The exact structure depends on the API response but generally provides all necessary data to understand and perform the cross-chain swap.

This node does not output binary data.

Dependencies

  • Requires an API key credential for the Squid Router service.
  • Uses the @0xsquid/sdk package to interact with the Squid Router API.
  • Network access to https://v2.api.squidrouter.com.
  • The node initializes the SDK client and waits briefly (1 second) after initialization before making requests.

Troubleshooting

  • Common issues:

    • Invalid or missing API credentials will cause authentication failures.
    • Incorrect chain or token addresses may result in errors or empty routes.
    • Network connectivity problems can prevent API calls.
    • Providing zero or negative amounts will likely cause errors.
  • Error messages:

    • Errors from the underlying HTTP client are caught and rethrown with meaningful messages extracted from the API response.
    • If the node is configured to continue on failure, it will append error details to the output instead of stopping execution.
    • Unsupported operations will throw an explicit error indicating the action is not supported.
  • Resolution tips:

    • Verify API credentials and permissions.
    • Double-check all input addresses and IDs for correctness.
    • Ensure the amount is positive and properly formatted.
    • Check network connectivity and Squid Router service status.

Links and References

Discussion