Get token exchange rate from Klayswap V2 or V3 LP Contract
npm i exratecalc
const exratecalc = require("exratecalc");
const calculator = new exratecalc("RPC Endpoint");
.v2(v2_LP_Contract_Address, token_symbol){}
returns amount of token per a token with given symbol
.v3(v3_LP_Contract_Address, token_Symbol){}
returns amount of token per a token with given symbol
const exratecalc = require("exratecalc");
const calculator = new exratecalc("RPC Endpoint");
// amount of oUSDT per 1KSP
calculator
.v2("0xe75a6a3a800a2c5123e67e3bde911ba761fe0705", "ksp")
.then(console.log); // 0.4710626833673169
// amount of oUSDT per 1KSP
calculator
.v3("0x21ecdfb99772b10fb913a6f4658a9f97185c82be", "ksp")
.then(console.log); // 0.4706124510348447