Getting Started

Get started with Moromoro SDK in minutes! This guide will walk you through making your first swap on HyperEVM.

Basic Setup

1

Install Dependencies

npm install @moromoro/moro-sdk ethers
2

Import the SDK

const { MoroBestRate } = require('@moromoro/moro-sdk')
const { ethers } = require('ethers')

For TypeScript/ES6:

import { MoroBestRate } from '@moromoro/moro-sdk'
import { ethers } from 'ethers'
3

Initialize Provider and Client

// Connect to HyperEVM
const provider = new ethers.providers.JsonRpcProvider('https://rpc.hyperliquid.xyz/evm')

// Create Moromoro client
const moroClient = new MoroBestRate(provider, 'hyperevm')

Getting a Quote

Simple Quote Example

// Token addresses
const HYPE = '0x5555555555555555555555555555555555555555' // Native token
const USDT = '0xb8ce59fc3717ada4c02eadf9682a9e934f625ebb' // USDT0

// Swap parameters
const amountIn = ethers.utils.parseUnits('10', 18) // 10 HYPE
const gasFee = ethers.BigNumber.from('5000000000') // 5 gwei

// Get best rate quote
const quote = await moroClient.getQuote(
    HYPE,           // source token
    USDT,           // destination token
    amountIn,       // amount to swap
    gasFee,         // gas price for calculation
    { enableSplit: false } // options
)

console.log('Quote:', quote)
console.log('Amount Out:', ethers.utils.formatUnits(quote.amountOut, 6))

Quote Response

The quote object contains:

Executing a Swap

Method 2: Direct Contract Interaction

Swapping ERC20 Tokens

When swapping ERC20 tokens (non-native), you need to approve the router first:

Enable Split Trading

For potentially better rates, enable split trading:

Supported Networks

Initialize the SDK with different networks:

Complete Example

Here's a complete example with error handling:

Next Steps

Common Issues

Insufficient Balance

Solution: Ensure your wallet has enough native tokens for the swap amount + gas fees.

Slippage Exceeded

Solution: Increase slippage tolerance:

Token Not Approved

Solution: Approve the token before swapping:

Getting Help

  • https://github.com/moromoro/moro-sdk/issues

  • https://discord.gg/moromoro