Skip to content

Latest commit

 

History

History
77 lines (56 loc) · 2.22 KB

README.md

File metadata and controls

77 lines (56 loc) · 2.22 KB

Reverse Mirage GitHub Actions npm version

Building blocks for Ethereum app development. Built using Viem.

Features

  • ✅ 10x-100x faster, 11.6x smaller than @uniswap/sdk-core
  • ✅ Abstactions for most commonly used token standards
  • ✅ Supports permit
  • ✅ Extensible to build apps and libraries
  • ✅ Seamless extension to Viem
  • ✅ TypeScript ready
  • ✅ Test suite running against local Ethereum network

Example

import { createPublicClient, http } from 'viem'
import { mainnet } from 'viem/chains'
import { publicActionReverseMirage, amountToNumber } from 'reverse-mirage'

export const publicClient = createPublicClient({
  chain: mainnet,
  transport: http()
}).extend(publicActionsReverseMirage)

// read token metadata
const usdc = await publicClient.getERC20({
  address: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', // usdc
  id: mainnet.id
})

console.log(usdc.decimals) // 6
console.log(usdc.name) // USD Coin

// read a balance
const vitalikBalance = await publicClient.getERC20Balance({
  erc20: usdc,
  address: '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045' // vitalik
})

console.log(vitalikBalance.amount) // 420690000n
console.log(amountToNumber(vitalikBalance)) // 420.69

Installation

$ npm i reverse-mirage

Benchmarks

Benchmarks are done with mitata. To reproduce:

$ cd packages/core/
$ bun run src/amount/utils.bench.ts

Results

  • amount add: reverse mirage 8.31x faster than @uniswap/sdk-core
  • amount equal to: reverse-mirage 18.9x faster than @uniswap/sdk-core
  • amount to number: reverse-mirage 313x faster than @uniswap/sdk-core
  • amount to significant: reverse-mirage 27.1x faster than @uniswap/sdk-core

Bundle Size

reverse-mirage: 4.61 kB

@uniswap/sdk-core: 53.4 kB