@bancor/carbon-sdk
Version:
The SDK is a READ-ONLY tool, intended to facilitate working with Carbon contracts. It's a convenient wrapper around our matching algorithm, allowing programs and users get a ready to use transaction data that will allow them to manage strategies and fulfi
80 lines • 4.82 kB
TypeScript
import { BigNumber, BigNumberish, Decimal } from '../utils/numerics';
import { DecodedOrder, DecodedStrategy, EncodedStrategy, Strategy } from '../common/types';
import { Decimals } from '../utils/decimals';
export declare function normalizeRate(amount: BigNumberish, amountTokenDecimals: number, otherTokenDecimals: number): string;
export declare function normalizeInvertedRate(amount: BigNumberish, amountTokenDecimals: number, otherTokenDecimals: number): string;
export declare const encodeStrategy: (strategy: DecodedStrategy) => Omit<EncodedStrategy, "id">;
export declare const decodeStrategy: (strategy: EncodedStrategy) => DecodedStrategy & {
id: BigNumber;
encoded: EncodedStrategy;
};
/**
* Converts a DecodedStrategy object to a Strategy object.
*
* @param {DecodedStrategy} strategy - The DecodedStrategy object to convert.
* @returns {Promise<Strategy>} - A promise that resolves to the Strategy object.
* @throws {Error} If an error occurs while fetching the decimals for the tokens.
*/
export declare function parseStrategy(strategy: DecodedStrategy & {
id: BigNumber;
encoded: EncodedStrategy;
}, decimals: Decimals): Promise<Strategy>;
export declare function buildStrategyObject(baseToken: string, quoteToken: string, baseDecimals: number, quoteDecimals: number, buyPriceLow: string, // in quote tkn per 1 base tkn
buyPriceMarginal: string, // in quote tkn per 1 base tkn
buyPriceHigh: string, // in quote tkn per 1 base tkn
buyBudget: string, // in quote tkn
sellPriceLow: string, // in quote tkn per 1 base tkn
sellPriceMarginal: string, // in quote tkn per 1 base tkn
sellPriceHigh: string, // in quote tkn per 1 base tkn
sellBudget: string): DecodedStrategy;
export declare function createFromBuyOrder(baseTokenDecimals: number, quoteTokenDecimals: number, buyPriceLow: string, buyPriceMarginal: string, buyPriceHigh: string, buyBudget: string): DecodedOrder;
export declare function createFromSellOrder(baseTokenDecimals: number, quoteTokenDecimals: number, sellPriceLow: string, sellPriceMarginal: string, sellPriceHigh: string, sellBudget: string): DecodedOrder;
export declare function createOrders(baseTokenDecimals: number, quoteTokenDecimals: number, buyPriceLow: string, buyPriceMarginal: string, buyPriceHigh: string, buyBudget: string, sellPriceLow: string, sellPriceMarginal: string, sellPriceHigh: string, sellBudget: string): {
order0: DecodedOrder;
order1: DecodedOrder;
};
export declare const PPM_RESOLUTION = 1000000;
export declare function addFee(amount: BigNumberish, tradingFeePPM: number): Decimal;
export declare function subtractFee(amount: BigNumberish, tradingFeePPM: number): Decimal;
export declare function enforcePriceRange(minPrice: Decimal, maxPrice: Decimal, marginalPrice: Decimal): import("decimal.js").Decimal;
export declare function getMinMaxPricesByDecimals(baseTokenDecimals: number, quoteTokenDecimals: number): {
minBuyPrice: string;
maxSellPrice: string;
};
/**
* Calculate the overlapping strategy prices. Returns it with correct decimals
*
* @param {string} buyPriceLow - The minimum buy price for the strategy, in in `quoteToken` per 1 `baseToken`, as a string.
* @param {string} sellPriceHigh - The maximum sell price for the strategy, in `quoteToken` per 1 `baseToken`, as a string.
* @param {string} marketPrice - The market price, in `quoteToken` per 1 `baseToken`, as a string.
* @param {string} spreadPercentage - The spread percentage, e.g. for 10%, enter `10`.
* @return {{
* buyPriceLow: string;
* buyPriceHigh: string;
* buyPriceMarginal: string;
* sellPriceLow: string;
* sellPriceHigh: string;
* sellPriceMarginal: string;
* marketPrice: string;
* }} The calculated overlapping strategy prices.
*/
export declare function calculateOverlappingPrices(buyPriceLow: string, sellPriceHigh: string, marketPrice: string, spreadPercentage: string): {
buyPriceLow: string;
buyPriceHigh: string;
buyPriceMarginal: string;
sellPriceLow: string;
sellPriceHigh: string;
sellPriceMarginal: string;
marketPrice: string;
};
export declare function calculateOverlappingSellBudget(baseTokenDecimals: number, quoteTokenDecimals: number, buyPriceLow: string, // in quote tkn per 1 base tkn
sellPriceHigh: string, // in quote tkn per 1 base tkn
marketPrice: string, // in quote tkn per 1 base tkn
spreadPercentage: string, // e.g. for 0.1% pass '0.1'
buyBudget: string): string;
export declare function calculateOverlappingBuyBudget(baseTokenDecimals: number, quoteTokenDecimals: number, buyPriceLow: string, // in quote tkn per 1 base tkn
sellPriceHigh: string, // in quote tkn per 1 base tkn
marketPrice: string, // in quote tkn per 1 base tkn
spreadPercentage: string, // e.g. for 0.1% pass '0.1'
sellBudget: string): string;
//# sourceMappingURL=utils.d.ts.map