Web3 APIs & Dev Tools: Squid SDK

Tutorials/Guides
Kagemni Karimu
Nov 13, 2023

Intro

As part of an ongoing effort to assist developers in web3, Lava conducts regular reviews of the best web3 APIs & dev tools. Our last article in this series covered fRPC-Substrate - and we’ve taken a look at Fallback Falooda as well. Please follow along as we uncover the most cutting edge technologies for dapp devs in web3!

Application: Squid SDK by Squid Router Team

Squid SDK emerges as one of the Axelar ecosystem’s major front-runners with an amazing cross-chain use case. As a self-described “liquidity and messaging router”, Squid enables swift token swaps between various cryptocurrencies. If you’re looking to make fast, easy, and secure token swaps, pay special attention: Squid has routed over $500 million of volume+, is used by Pancake Swap, Metamask, Vela Exchange, and allows swaps between USDT, USDC, ETH, ARB, AXL, SUSHI and literally dozens more.

Squid SDK was created by the Squid Router team as one of three related offerings. Squid Router also offers a neat widget and an easy to use API. The SDK is exceptionally simple to use:


// $ npm install --save @0xsquid/sdk@2.8.0-beta.0 

import { Squid } from "@0xsquid/sdk";
import { ethers } from "ethers"
require("dotenv").config();

const userAddress = ""
const integratorId = ""
const privateKey = process.env.PRIVATE_KEY
const rpcUrl = "https://g.w.lavanet.xyz:443/gateway/avax/rpc-http/201723ef5923285f02afb7897fc71cb2"

(async () => {
  // instantiate the SDK with config
   const squid = new Squid({
    baseUrl: "https://v2.api.squidrouter.com",
    integratorId: integratorId
  });

  // init the SDK
  await squid.init();

	const { route } = await squid.getRoute({
	  fromChain: "43114", // Avalanche
	  fromAmount: "10000000000000000", // 0.1 AVAX
	  fromToken: "0xEEeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
	  toChain: "9001", // Evmos
	  toToken: "0xEEeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
	  fromAddress: userAddress,
	  toAddress: userAddress,
	  slippageConfig: {
	    autoMode: 1
	  }
	});

	const provider = new ethers.JsonRpcProvider(rpcUrl);
	const signer = new ethers.Wallet(privateKey, provider);

	const result = await squid.executeRoute({
	  route,
	  signer
	});

	console.log(result);
})();


Main Features:

  • Simple Cross-chain Token Swaps: Squid allows seamless lightweight cross-chain swaps and messaging. The list of supported chains/tokens is great and evergrowing, and includes many favorites such as Evmos and Axelar.
  • Configurable RPC: You can use Squid with ethers.js, viem and perhaps other popular libraries with relative ease. Squid is plug-n-play in most environments and requires very little prep and/or staging.
  • Widget/SDK/API:  React/iframe widgets are available for those unwanting of the Javascript SDK - a raw API is available for those who want to get outside of Javascript but still use Squid. Whether you want the fullblown widget, SDK that’s featured in the snippet above, or the API, it’s got great offerings.
  • Ease of Use: Squid is easy to use with great documentation. There are so many ways it can be used even though its implementation is lightweight and minimalistic.

Considerations

🟢 Squid shows the capabilities of Axelar and is one of the realest projects on Web3 demonstrating cross-chain capabilities. It is a great proof-of-concept for Axelar’s General Message Parsing (GMP) interoperability as it can be used with both EVM signers and Cosmos-based signers easily. With four different security audits, and prioritized security, Squid is a great selection for use in any project.

🔴 Squid Router supports a limited (although quite large & growing) set of token swaps. Also, although interfaces exist for it - tracking in progress token swaps and diagnosing any difficulties or challenges could be difficult.

Why we LAV Squid SDK

❤️ There’s a lot to love here! As an open source project the availability of both a widget, an SDK, and an API means that regardless of the architecture of your application or project, you can use Squid. Squid also doesn’t function as a bridge and takes a no man-in-the-middle approach (i.e. no fees, no holding value, no taking margin on gas).

What we’d like to see!

We’d love to see Lava on the back-end for Squid API and Widgets. Lava is a big supporter of Axelar; we want to be the default RPC for colorful and important applications like Squid.

Outro

Squid SDK stands out as an innovative solution for cross-chain interactions, reflecting the dynamic nature of the web3 ecosystem. The ability to integrate cross-chain token swaps directly into decentralized applications opens up new horizons for developers and users alike.

With a robust set of tools encompassing an easy-to-integrate SDK, a versatile widget, and a comprehensive API, Squid is a testament to Axelar's vision of a deeply interconnected blockchain environment. The promising features and the substantial volume it has routed thus far demonstrate Squid's potential to be a staple in the toolbox of dapp developers. Using Squid and need RPC for Axelar? Try out our RPC Gateway or our own SDK!