Coder Social home page Coder Social logo

uv3pe-js's Introduction

uv3pe-js

This package lets you retrieve the price of a token in an Uniswap V3 token pair. For example, you can get the price of one WBTC in the WBTC/USDT pool.

How does it work ?

It instantiates the UniswapV3Pool of the two tokens, located at a provided address on the Ethereum blockchain.

Then, it retrieves the price from the smart contract storage and perform weird computation so that you can use the decimal price in your project !

Getting started !

Installation

You just have to run the following command:

yarn add uv3pe-js

Quickstart

You must have a running web3 instance. Then provide the pool address and the number of decimals of both tokens, that you can retrieve here.

const poolAddress = '0x9db9e0e53058c89e5b94e29621a205198648425b';
const numberOfDecimalsToken1 = 8;
const numberOfDecimalsToken2 = 6;

const WBTCPrice = await GetUniswapV3Price({
    web3,
    poolAddress,
    numberOfDecimalsToken1,
    numberOfDecimalsToken2,
});

Output:

console.log(WBTCPrice); // ---> 39300

Author

Made with ❤️ by 🤖 Luca Georges François 🤖

uv3pe-js's People

Contributors

0xpanoramix avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.