@ickb/order
Version:
UDT Limit Order utilities built on top of CCC
66 lines • 3.05 kB
TypeScript
import { ccc } from "@ckb-ccc/core";
import { type ExchangeRatio, type ScriptDeps, type SmartTransaction, type UdtHandler, type ValueComponents } from "@ickb/utils";
import { Info, type InfoLike } from "./entities.js";
import { OrderCell, OrderGroup } from "./cells.js";
export declare class OrderManager implements ScriptDeps {
readonly script: ccc.Script;
readonly cellDeps: ccc.CellDep[];
readonly udtHandler: UdtHandler;
constructor(script: ccc.Script, cellDeps: ccc.CellDep[], udtHandler: UdtHandler);
isOrder(cell: ccc.Cell): boolean;
isMaster(cell: ccc.Cell): boolean;
static convert(isCkb2Udt: boolean, midpoint: ExchangeRatio, amounts: ValueComponents, options?: {
fee?: ccc.Num;
feeBase?: ccc.Num;
ckbMinMatchLog?: number;
}): {
convertedAmount: ccc.FixedPoint;
ckbFee: ccc.FixedPoint;
info: Info;
};
mint(tx: SmartTransaction, lock: ccc.Script, info: InfoLike, amounts: ValueComponents): void;
addMatch(tx: SmartTransaction, match: Match): void;
match(order: OrderCell, isCkb2Udt: boolean, allowance: ccc.FixedPoint): Match;
static bestMatch(orderPool: OrderCell[], allowance: ValueComponents, exchangeRate: ExchangeRatio, options?: {
feeRate?: ccc.Num;
ckbAllowanceStep?: ccc.FixedPoint;
}): Match;
static sequentialMatcher(orderPool: OrderCell[], isCkb2Udt: boolean, allowanceStep: ccc.FixedPoint, ckbMiningFee: ccc.FixedPoint): Generator<Match, void, void>;
melt(tx: SmartTransaction, groups: OrderGroup[], options?: {
isFulfilledOnly?: boolean;
}): void;
findOrders(client: ccc.Client, options?: {
limit?: number;
}): AsyncGenerator<OrderGroup>;
private findSimpleOrders;
private findAllMasters;
private findOrigin;
}
export interface Match {
ckbDelta: bigint;
udtDelta: bigint;
partials: {
order: OrderCell;
ckbOut: ccc.FixedPoint;
udtOut: ccc.FixedPoint;
}[];
}
export declare class OrderMatcher {
readonly order: OrderCell;
readonly isCkb2Udt: boolean;
readonly aScale: ccc.Num;
readonly bScale: ccc.Num;
readonly aIn: ccc.FixedPoint;
readonly bIn: ccc.FixedPoint;
readonly aMin: ccc.FixedPoint;
readonly bMinMatch: ccc.FixedPoint;
readonly bMaxMatch: ccc.FixedPoint;
readonly bMaxOut: ccc.FixedPoint;
readonly realRatio: number;
constructor(order: OrderCell, isCkb2Udt: boolean, aScale: ccc.Num, bScale: ccc.Num, aIn: ccc.FixedPoint, bIn: ccc.FixedPoint, aMin: ccc.FixedPoint, bMinMatch: ccc.FixedPoint, bMaxMatch: ccc.FixedPoint, bMaxOut: ccc.FixedPoint, realRatio: number);
static from(order: OrderCell, isCkb2Udt: boolean, ckbMiningFee: ccc.FixedPoint): OrderMatcher | undefined;
match(bAllowance: ccc.FixedPoint): Match;
create(aOut: ccc.FixedPoint, bOut: ccc.FixedPoint): Match;
static nonDecreasing(aScale: ccc.Num, bScale: ccc.Num, aIn: ccc.FixedPoint, bIn: ccc.FixedPoint, aOut: ccc.FixedPoint): ccc.FixedPoint;
}
//# sourceMappingURL=order.d.ts.map