IntegrationsQuick StartV2

Swap with V2

Be sure to respect all the necessary requirements present in .

Be sure to respect all the necessary requirements present in .

Swapping Tokens

Use the provided swapTokens function to swap ETH for USDC:

  1. Open the index.js file in your editor.

  2. Replace the placeholder values in the main() function:

      const signer = new ethers.Wallet(privateKey, provider);
      const provider = new ethers.providers.JsonRpcProvider("https://api.hyperliquid-testnet.xyz/evm");
      const amountOutMin = ethers.utils.parseUnits("100", 6);
      const to = walletAddress; // Replace with your wallet address
      const ethAmount = "0.1"; // Amount of ETH to swap
      await swapETHForUSDC(provider, signer, amountOutMin, to, ethAmount);
  1. Run the script:
node index.js

On this page