Skip to content

SDK

Please use @mimoprotocol/swap-sdk to build on top of mimo v2.

Installation

bash
yarn add @mimoprotocol/swap-sdk

Usage

Mimo uses Uniswap V2 standard, you can refer to Uniswap's SDK documentation for more details: https://uniswap.org/docs/v2/SDK/getting-started/

Router Address

The router address for Mimo is:

0x147CdAe2BF7e809b9789aD0765899c06B361C5cE

on IoTeX Chain.

Example

typescript
import { ChainId, Token, WETH, Fetcher, Route, Trade } from '@mimoprotocol/swap-sdk';

// Define tokens
const tokenA = new Token(ChainId.IOTEX, '0x...', 18, 'TOKENA', 'Token A');
const tokenB = new Token(ChainId.IOTEX, '0x...', 18, 'TOKENB', 'Token B');

// Fetch pair
const pair = await Fetcher.fetchPairData(tokenA, tokenB);

// Create route
const route = new Route([pair], tokenA);

// Create trade
const trade = new Trade(route, new TokenAmount(tokenA, '1000000000000000000'), TradeType.EXACT_INPUT);

console.log(trade.executionPrice.toSignificant(6));
console.log(trade.priceImpact.toSignificant(2));

Setting up Endpoint

Please refer to IoTeX documentation for setting up the RPC endpoint.

Additional Resources

Released under the MIT License.