@ajna-finance/sdk
Version:
A typescript SDK that can be used to create Dapps in Ajna ecosystem.
22 lines (21 loc) • 1.05 kB
TypeScript
import { BigNumber } from 'ethers';
/**
* @notice Calculates the price for a given Fenwick index
* @dev Throws if index exceeds maximum constant
* @dev Fenwick index is converted to bucket index
* @dev Fenwick index to bucket index conversion
* 1.00 : bucket index 0, fenwick index 4146: 7388-4156-3232=0
* MAX_PRICE : bucket index 4156, fenwick index 0: 7388-0-3232=4156.
* MIN_PRICE : bucket index -3232, fenwick index 7388: 7388-7388-3232=-3232.
* @dev V3 (final): x^y = 2^(y*log_2(x))
*/
export declare const indexToPrice: (index: number) => BigNumber;
/**
* @notice Calculates the Fenwick index for a given price
* @param price bucket price, in WAD scale (1e18)
* @dev Throws if price exceeds maximum constant
* @dev Price expected to be inputted as a 18 decimal WAD
* @dev V3 (final): bucket index = log_2(price) / log_2(FLOAT_STEP)
* @dev Fenwick index = 7388 - bucket index + 3232
*/
export declare const priceToIndex: (price: BigNumber) => number;