Skip to content

This repository serves as an example of the implementation and integration of Hyperswap v3

License

Notifications You must be signed in to change notification settings

HyperSwapX/how-tos-v3

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hyperswap V3 SDK Template

This repository provides a ready-to-use SDK for interacting with Hyperswap V3, including swap functionalities.

Features

  • Swap ERC-20 tokens (e.g., USDC ↔ ETH).

Getting Started

  1. Clone the repository:
    git clone https://github.com/HyperSwapX/how-tos-v3.git
    cd hyperswap-sdk
    
  2. Install dependencies:
    npm install
    
  3. Set up the .env file:
    • Copy the .env.example file to .env:
    cp .env.example .env
    
  • Edit the .env file with your details.

Scripts

  1. Swap tokenIn for tokenOut

To swap WETH for USDC, run:

  node index.js

Edit the index.js file to adjust the parameters like amountIn, amountOutMin. Edit the .env file to adjust the tokenIn and tokenOut (must be ERC20).

Project Structure • index.js: The main entry point to run swap functions. • v3_swap_functions.js: Contains functions for swapping tokens on Hyperswap V3. • abi/: Contains the ABI file for the V3 router contract.

Environment Variables

The project relies on a .env file for sensitive information. Here’s an example:

PRIVATE_KEY=0xYourPrivateKey
RPC_URL=https://api.hyperliquid-testnet.xyz/evm
ROUTER_V3_ADDRESS=0xD81F56576B1FF2f3Ef18e9Cc71Adaa42516fD990
WETH_ADDRESS=0xADcb2f358Eae6492F61A5F87eb8893d09391d160
USDC_ADDRESS=0x24ac48bf01fd6CB1C3836D08b3EdC70a9C4380cA

*Note that you can replace WETH and USDC by any ERC20 token available on Hyperswap V3

Troubleshooting

• If you encounter gas estimation errors (UNPREDICTABLE_GAS_LIMIT), ensure:

	  1.	Your wallet has sufficient funds.
	  2.	The contract addresses are correct.

• Check the logs for specific error messages. The most common issues are related to incorrect amounts, insufficient balances, or invalid contract interaction.

About

This repository serves as an example of the implementation and integration of Hyperswap v3

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published