Skip to content

🦄 Get swap estimates and execute trades on Uniswap programmatically

License

Notifications You must be signed in to change notification settings

mathieuartu/uniswap-quoteswapper

Repository files navigation

🦄 UniswapQuoteSwapper

Unit tests Lint Build npm version npm bundle size (scoped version)

A simple class to get swap estimates and execute trades on UniSwap programmaticaly

Installation

npm i uniswap-quoteswapper

Usage

import UniswapQuoteSwapper from 'uniswap-quoteswapper'

const uqs = new UniswapQuoteSwapper({
    rpcEndpointUrl: 'RPC_ENDPOINT_URL',
    wallet: {
        address: 'YOUR_PUBLIC_ADDRESS',
        privateKey: 'YOUR_PRIVATE_KEY',
    },
})(async () => {
    const quote = await uqs.getQuote({
        from: '0x6B175474E89094C44Da98b954EedeAC495271d0F',
        to: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
        amount: 100,
        slippage: 0.01,
    })
    // quote = { amountOutReadable: 0.0023, ... }
    const approveTxHash = await uqs.approveTokenSpending({ tokenAddress: '0x6B175474E89094C44Da98b954EedeAC495271d0F' })
    const swapTxHash = await uqs.swapQuote(quote)
})()

UniswapQuoteSwapper needs two things to work :

  • Public or private JSON-RPC url
  • Your public and private key in order to sign the transactions

About

🦄 Get swap estimates and execute trades on Uniswap programmatically

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published