@fleupold/dex-contracts
Version:
Contracts for dFusion multi-token batch auction exchange
35 lines (34 loc) • 1.83 kB
TypeScript
import BN from "bn.js";
import { Fraction } from "./fraction";
declare type SellAmount = BN;
declare type BuyAmount = BN;
/**
* Modifies the price to work with ERC20 units
* @param price - Amount of buy token in exchange for one sell token
* @param sellTokenDecimals - Number of decimals of the sell token
* @param buyTokenDecimals - Number of decimals of the buy token
* Returns Fraction representing the number of buy tokens in exchange for one unit of sell token
*/
export declare function getUnitPrice(price: number, sellTokenDecimals: number, buyTokenDecimals: number): Fraction;
/**
* Computes the amount of output token units from their price and the amount of input token units
* Note that the price is expressed in terms of tokens, while the amounts are in terms of token units
* @param price - Amount of buy token in exchange for one sell token
* @param sellAmount - Amount of sell token units that are exchanged at price
* @param sellTokenDecimals - Number of decimals of the sell token
* @param buyTokenDecimals - Number of decimals of the buy token
* Returns amount of output token units obtained
*/
export declare function getBuyAmountFromPrice(price: number, sellAmount: SellAmount, sellTokenDecimals: number, buyTokenDecimals: number): BuyAmount;
/**
* Computes the buy and sell token amounts required for an unlimited order in the exchange
* @param price - Price of the buyToken relative to one sell token
* @param sellTokenDecimals - Number of decimals of the sell token
* @param buyTokenDecimals - Number of decimals of the buy token
* Returns amounts of sell-buy token for an unlimited order at the input price
*/
export declare function getUnlimitedOrderAmounts(price: number, sellTokenDecimals: number, buyTokenDecimals: number): {
base: SellAmount;
quote: BuyAmount;
};
export {};