@orca-so/wavebreak
Version:
The wavebreak JS client for interacting with the wavebreak program.
144 lines (135 loc) • 7.48 kB
TypeScript
/* tslint:disable */
/* eslint-disable */
export function exactInBuyQuote(price_curve_facade: PriceCurveFacade, requested_amount_in: bigint, swap_fee_bps: number, current_quote_amount: bigint, graduation_target: bigint, max_buy_amount: bigint): Quote;
export function exactOutBuyQuote(price_curve_facade: PriceCurveFacade, requested_amount_out: bigint, swap_fee_bps: number, current_quote_amount: bigint, graduation_target: bigint, max_buy_amount: bigint): Quote;
export function exactInSellQuote(price_curve_facade: PriceCurveFacade, requested_amount_in: bigint, swap_fee_bps: number, current_quote_amount: bigint, graduation_target: bigint, max_sell_amount: bigint): Quote;
export function exactOutSellQuote(price_curve_facade: PriceCurveFacade, requested_amount_out: bigint, swap_fee_bps: number, current_quote_amount: bigint, graduation_target: bigint, max_sell_amount: bigint): Quote;
export function graduateQuote(price_curve: PriceCurveFacade, split_bps: number, quote_amount: bigint, creator_reward: bigint, graduation_reward: bigint, quote_protocol_fee_bps: number): GraduateQuote;
/**
* This function is used to calculate the quote for the closing of the bonding curve
* it only works after all graduation methods have been called.
*/
export function closeQuote(price_curve: PriceCurveFacade, base_amount: bigint, graduation_target: bigint, creator_reward: bigint, graduation_reward: bigint, quote_protocol_fee_bps: number, base_protocol_fee_bps: number, base_allocation_bps: number): CloseQuote;
export function _NUM_BINS(): number;
export function _MIN_GRADUATION_TARGET(): bigint;
export function _MIN_SQRT_PRICE(): bigint;
export function _MAX_SQRT_PRICE(): bigint;
export function flat(sqrt_price: bigint): PriceCurveFacade;
/**
* Creates a curve where the **sqrt_price** moves linearly from start_price to end_price
*/
export function linear(start_price: bigint, end_price: bigint): PriceCurveFacade;
/**
* Creates a curve where the **sqrt_price** moves exponentially from start_price to end_price
*/
export function exponential(start_price: bigint, end_price: bigint, rate: number): PriceCurveFacade;
/**
* Creates a curve where the **sqrt_price** moves sigmoidally from start_price to end_price
*/
export function sigmoid(start_price: bigint, end_price: bigint, rate: number): PriceCurveFacade;
export function curve(curve: PriceCurveFacade): Bins;
export function _BPS_DENOMINATOR(): number;
/**
* Get the current fully diluted mcap of the base token expressed in the quote token.
*/
export function tokenCurrentFdv(price_curve: PriceCurveFacade, quote_amount: bigint, graduation_target: bigint, creator_reward: bigint, graduation_reward: bigint, quote_protocol_fee_bps: number, base_protocol_fee_bps: number, base_allocation_bps: number): bigint;
/**
* Get the estimated fully diluted mcap of the base token at token graduation expressed in the quote token.
*/
export function tokenGraduationFdv(price_curve: PriceCurveFacade, graduation_target: bigint, creator_reward: bigint, graduation_reward: bigint, quote_protocol_fee_bps: number, base_protocol_fee_bps: number, base_allocation_bps: number): bigint;
/**
* Get the price of the base token expressed in the quote token. This is the spot price
* and not a quote for a specific amount.
*/
export function tokenPrice(price_curve: PriceCurveFacade, quote_amount: bigint, graduation_target: bigint): bigint;
/**
* Convert a price into a sqrt priceX64
* IMPORTANT: floating point operations can reduce the precision of the result.
* Make sure to do these operations last and not to use the result for further calculations.
*
* # Parameters
* * `price` - The price to convert
* * `decimals_a` - The number of decimals of the base token
* * `decimals_b` - The number of decimals of the quote token
*
* # Returns
* * `u128` - The sqrt priceX64
*/
export function priceToSqrtPrice(price: number, decimals_a: number, decimals_b: number): bigint;
/**
* Convert a sqrt priceX64 into a tick index
* IMPORTANT: floating point operations can reduce the precision of the result.
* Make sure to do these operations last and not to use the result for further calculations.
*
* # Parameters
* * `sqrt_price` - The sqrt priceX64 to convert
* * `decimals_a` - The number of decimals of the base token
* * `decimals_b` - The number of decimals of the quote token
*
* # Returns
* * `f64` - The decimal price
*/
export function sqrtPriceToPrice(sqrt_price: bigint, decimals_a: number, decimals_b: number): number;
export function quoteToBaseAmount(sqrt_price: bigint, quote_amount: bigint, round_up: boolean): bigint;
/**
* Given a current spot price and a base amount, return the quote amount that would be
* bought or sold for the base amount.
*/
export function baseToQuoteAmount(sqrt_price: bigint, base_amount: bigint, round_up: boolean): bigint;
export function slippageThreshold(quote: Quote, slippage_tolerance_bps: number): PriceThreshold;
export function slippageThresholdExceeded(quote: Quote, price_threshold: PriceThreshold): boolean;
export function bitmapAdd(bitmap: Buffer, value: number): Buffer;
export function bitmapRemove(bitmap: Buffer, value: number): Buffer;
export function bitmapHas(bitmap: Buffer, value: number): boolean;
export function _DEFAULT_TOKEN_DECIMALS(): number;
/**
* Get the current circulating supply of the token.
*/
export function circulatingSupply(price_curve: PriceCurveFacade, quote_amount: bigint, graduation_target: bigint): bigint;
/**
* Calculates the amount of quote tokens that can be used for the graudation methods.
*/
export function quoteGraduationAmount(quote_amount: bigint, quote_protocol_fee_bps: number, creator_reward: bigint, graduation_reward: bigint): bigint;
/**
* Calculates the amount of base tokens that can be used for the graudation methods.
*/
export function baseGraduationAmount(final_price: bigint, quote_amount: bigint, quote_protocol_fee_bps: number, creator_reward: bigint, graduation_reward: bigint): bigint;
/**
* Get the estimated total supply of the token (at graduation).
*/
export function totalSupply(price_curve: PriceCurveFacade, graduation_target: bigint, creator_reward: bigint, graduation_reward: bigint, quote_protocol_fee_bps: number, base_protocol_fee_bps: number, base_allocation_bps: number): bigint;
export function amountToUiAmount(amount: bigint, decimals: number): number;
export function uiAmountToAmount(amount: number, decimals: number): bigint;
export function _ARITHMETIC_OVERFLOW(): string;
export function _AMOUNT_EXCEEDS_MAX_U64(): string;
export function _AMOUNT_EXCEEDS_MAX_U128(): string;
export function _BPS_EXCEEDS_MAX_U16(): string;
export function _BEYOND_GRADUATION_TARGET(): string;
export function _INVALID_PRICE_CURVE(): string;
export interface CloseQuote {
totalSupply: bigint;
baseProtocolFee: bigint;
remainingBaseAmount: bigint;
}
export interface GraduateQuote {
quoteAmount: bigint;
baseAmount: bigint;
}
export interface Quote {
quoteType: QuoteType;
amountIn: bigint;
amountOut: bigint;
feeAmount: bigint;
}
export type QuoteType = { __kind: "BuyExactIn" } | { __kind: "BuyExactOut" } | { __kind: "SellExactIn" } | { __kind: "SellExactOut" };
export type Bins = Bin[];
export interface Bin {
x: number;
y: number;
}
export interface PriceCurveFacade {
startPrice: bigint;
endPrice: bigint;
controlPoints: [number, number, number, number];
}
export type PriceThreshold = [bigint, bigint];