UNPKG

@hikaru-fi/swap-router

Version:

Package for calculating optimal path for executing swaps

41 lines (34 loc) 698 B
const { WeightedPool } = require("../poolMath/weightedPool/weightedPool"); /** * @typedef {Record<String, WeightedPool>} PoolDictionary * */ /** * @type {PoolDictionary} */ let pools = {}; /** * @returns {PoolDictionary} */ function getPools() { return pools; } /** * @param {PoolDictionary} updatedPools */ function setPools(updatedPools) { pools = updatedPools; } /** * * @param {String[]} poolsToUpdate * @param {BN[][]} newPoolBalances */ function updatePoolBalances(poolsToUpdate, newPoolBalances) { poolsToUpdate.map((val, index) => pools[val].setBalances(newPoolBalances[index])); } module.exports = { getPools, setPools, updatePoolBalances }