@hikaru-fi/sc-calculators
Version:
Package for pool calculations
55 lines (49 loc) • 1.2 kB
JavaScript
export const PoolTypes = {
WeightedPool: 'WeightedPool',
StablePool: 'StablePool',
All: 'All'
}
export const SwapTypes = {
// main swap types
Sell: 'SellTokens',
Buy: 'BuyTokens',
None: 'None',
// helper swap types
SingleSwap: 'SingleSwap',
MultipleSwaps: 'MultipleSwaps'
}
/**
*
* @param {String} swapType
* @returns {Number}
*/
export function getSwapType(swapType) {
if (swapType == SwapTypes.Sell) return 0;
if (swapType == SwapTypes.Buy) return 1;
}
/**
*
* @param {import("../poolMath/weightedPool/weightedPool.mjs").RouteInfo} swap
* @returns {String}
*/
export function getSwapName(swap) {
if (swap.swapType == 0) return SwapTypes.Sell;
if (swap.swapType == 1) return SwapTypes.Buy;
return undefined;
}
/**
*
* @param {import("../poolMath/weightedPool/weightedPool.mjs").RouteInfo} swap
* @returns {Boolean}
*/
export function isSell(swap) {
return swap.swapType == 0;
}
/**
*
* @param {import("../poolMath/weightedPool/weightedPool.mjs").RouteInfo} swap
* @returns {Boolean}
*/
export function isBuy(swap) {
return swap.swapType == 1;
}