UNPKG

@firefly-exchange/library-sui

Version:

Sui library housing helper methods, classes to interact with Bluefin protocol(s) deployed on Sui

35 lines (34 loc) 1.38 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.filterReserves = exports.filterPositionByPool = exports.filterPositionByID = void 0; /** * Tries to find the provided position in the vector of positions and return it * @param positions Array containing positions * @param id The id of the position to be searched * @returns Position or undefined */ function filterPositionByID(positions, id) { return positions.filter(p => p.position_id == id)[0]; } exports.filterPositionByID = filterPositionByID; /** * Returns the positions matching the pool id provided * @param positions Array containing positions * @param id The id of the position to be searched * @returns Array of positions containing positions of provided pool */ function filterPositionByPool(positions, pool) { return positions.filter(p => p.pool_id == pool); } exports.filterPositionByPool = filterPositionByPool; /** * Filters provided list of reserves to find the coin reserves asked for * @param reserves Array of coin reserves * @param coinType The coin type of reserves to look for * @returns Reserves of provided coin */ function filterReserves(reserves, coinType) { coinType = coinType.startsWith("0x") ? coinType.substring(2) : coinType; return reserves.filter(r => r.coinType == coinType)[0]; } exports.filterReserves = filterReserves;