UNPKG

@alcorexchange/alcor-swap-sdk

Version:

​​ **npm** ``` npm i @alcorexchange/alcor-swap-sdk ``` **yarn** ``` yarn add @alcorexchange/alcor-swap-sdk ``` ## Usage ### Import:

14 lines (13 loc) 511 B
import { sqrt } from "./sqrt"; /** * Returns the sqrt ratio as a Q64.64 corresponding to a given ratio of amountB and amountA * @param amountB The numerator amount i.e., the amount of tokenB * @param amountA The denominator amount i.e., the amount of tokenA * @returns The sqrt ratio */ export function encodeSqrtRatioX64(amountB, amountA) { const numerator = BigInt(amountB) << BigInt(128); const denominator = BigInt(amountA); const ratioX128 = numerator / denominator; return sqrt(ratioX128); }