UNPKG

@alcorexchange/alcor-swap-sdk

Version:

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

20 lines (18 loc) 644 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.encodeSqrtRatioX64 = encodeSqrtRatioX64; var _sqrt = require("./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 */ function encodeSqrtRatioX64(amountB, amountA) { const numerator = BigInt(amountB) << BigInt(128); const denominator = BigInt(amountA); const ratioX128 = numerator / denominator; return (0, _sqrt.sqrt)(ratioX128); }