exratecalc
Version:
Get token exchange rate from Klayswap V2 or V3 LP Contract
54 lines (34 loc) • 1.17 kB
Markdown
Get token exchange rate from Klayswap V2 or V3 LP Contract
```tsx
npm i exratecalc
```
```jsx
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
```jsx
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
```
[](https://github.com/natreeum/exratecalc/graphs/contributors)
- [natreeum](https://github.com/natreeum)
---
[](https://www.creder.biz)