xud
Version:
Exchange Union Daemon
31 lines (30 loc) • 1.16 kB
TypeScript
declare class UnitConverter {
/** Number of smallest units per currency. */
private UNITS_PER_CURRENCY;
/**
* Calculates the incoming and outgoing currencies and amounts of subunits/satoshis for an order if it is swapped.
* @param quantity The quantity of the order
* @param price The price of the order
* @param isBuy Whether the order is a buy
* @returns An object with the calculated incoming and outgoing values. The quote currency
* amount is returned as zero if the price is 0 or infinity, indicating a market order.
*/
static calculateInboundOutboundAmounts: (quantity: number, price: number, isBuy: boolean, pairId: string) => {
inboundCurrency: string;
inboundAmount: number;
inboundUnits: number;
outboundCurrency: string;
outboundAmount: number;
outboundUnits: number;
};
init: () => void;
amountToUnits: ({ currency, amount }: {
currency: string;
amount: number;
}) => number;
unitsToAmount: ({ currency, units }: {
currency: string;
units: number;
}) => number;
}
export { UnitConverter };