@swaptoshi/dex-module
Version:
Klayr decentralized exchange (dex) on-chain module
66 lines (65 loc) • 3.77 kB
TypeScript
import { Modules } from 'klayr-framework';
import { Slot0, DEXPoolData, DexModuleConfig, ImmutableSwapContext, MutableSwapContext, TickInfo, TokenMethod } from '../../types';
import { Uint128String, Int24String, Uint32String, Int56String, Uint160String, Int256String, Uint256String, Uint24String, Uint16String, Int16String } from '../library/int';
export declare class DEXPool implements DEXPoolData {
constructor(pool: DEXPoolData, stores: Modules.NamedRegistry, events: Modules.NamedRegistry, config: DexModuleConfig, moduleName: string, simulation?: boolean);
createEmulator(): DEXPool;
setSender(senderAddress: Buffer): void;
setConfig(config: DexModuleConfig): void;
addImmutableDependencies(context: ImmutableSwapContext, tokenMethod: TokenMethod): void;
addMutableDependencies(context: MutableSwapContext, tokenMethod: TokenMethod): void;
snapshotCumulativesInside(tickLower: Int24String, tickUpper: Int24String): Promise<[tickCumulativeInside: Int56String, secondsPerLiquidityInsideX128: Uint160String, secondsInside: Uint32String]>;
observe(secondsAgos: Uint32String[]): Promise<{
tickCumulatives: string[];
secondsPerLiquidityCumulativeX128s: string[];
}>;
increaseObservationCardinalityNext(observationCardinalityNext: Uint16String): Promise<void>;
initialize(sqrtPriceX96: Uint160String): Promise<void>;
mint(recipient: Buffer, tickLower: Int24String, tickUpper: Int24String, amount: Uint128String, data: string, callback: (amount0: string, amount1: string, data: string, pool?: DEXPoolData) => Promise<void>): Promise<[amount0: string, amount1: string]>;
collect(recipient: Buffer, tickLower: Int24String, tickUpper: Int24String, amount0Requested: Uint128String, amount1Requested: Uint128String): Promise<[amount0: string, amount1: string]>;
burn(tickLower: Int24String, tickUpper: Int24String, amount: Uint128String): Promise<[amount0: string, amount1: string]>;
swap(recipient: Buffer, zeroForOne: boolean, amountSpecified: Int256String, sqrtPriceLimitX96: Uint160String, data: string, callback: (amount0: string, amount1: string, data: string, pool?: DEXPoolData) => Promise<void>): Promise<[amount0: string, amount1: string]>;
flash(recipient: Buffer, amount0: Uint256String, amount1: Uint256String, data: string, callback: (fee0: string, fee1: string, data: string, pool?: DEXPoolData) => Promise<void>): Promise<void>;
getTick(tick: Int24String): Promise<TickInfo>;
getTickBitmap(index: Int16String): Promise<string>;
toJSON(): DEXPoolData;
private _getBalance0;
private _getBalance1;
private _saveStore;
private _checkMutableDependencies;
private _checkImmutableDependencies;
private _checkFeeProtocol;
private _checkTicks;
private _modifyPosition;
private _updatePosition;
private _validateFeeProtocol;
readonly address: Buffer;
readonly klayr32: string;
readonly collectionId: Buffer;
token0: Buffer;
token1: Buffer;
fee: Uint24String;
tickSpacing: Int24String;
maxLiquidityPerTick: Uint128String;
slot0: Slot0;
feeGrowthGlobal0X128: Uint256String;
feeGrowthGlobal1X128: Uint256String;
liquidity: Uint128String;
private readonly moduleName;
private readonly poolStore;
private readonly tickInfoStore;
private readonly positionInfoStore;
private readonly observationStore;
private readonly tickBitmapStore;
private readonly events;
private readonly stores;
private readonly config;
private readonly simulation;
private feeProtocol;
private feeProtocolPool;
private immutableContext;
private mutableContext;
private tokenMethod;
private mutableDependencyReady;
private immutableDependencyReady;
}