@ickb/order
Version:
UDT Limit Order utilities built on top of CCC
133 lines • 4.09 kB
TypeScript
import { ccc, mol } from "@ckb-ccc/core";
import { type ExchangeRatio } from "@ickb/utils";
declare const Ratio_base: (abstract new () => {
toBytes(): ccc.Bytes;
clone(): Ratio;
eq(other: ExchangeRatio): boolean;
hash(): ccc.Hex;
}) & {
byteLength?: number;
encode(_: ExchangeRatio): ccc.Bytes;
decode(_: ccc.BytesLike): Ratio;
fromBytes(_bytes: ccc.BytesLike): Ratio;
from(_: ExchangeRatio): Ratio;
};
export declare class Ratio extends Ratio_base {
ckbScale: ccc.Num;
udtScale: ccc.Num;
constructor(ckbScale: ccc.Num, udtScale: ccc.Num);
static from(ratio: ExchangeRatio): Ratio;
validate(): void;
isValid(): boolean;
isEmpty(): boolean;
isPopulated(): boolean;
static empty(): Ratio;
compare(other: Ratio): number;
applyFee(isCkb2Udt: boolean, fee: ccc.Num, feeBase: ccc.Num): Ratio;
convert(isCkb2Udt: boolean, amount: ccc.FixedPoint, mustCeil: boolean): ccc.FixedPoint;
}
export interface InfoLike {
ckbToUdt: ExchangeRatio;
udtToCkb: ExchangeRatio;
ckbMinMatchLog: ccc.FixedPointLike;
}
declare const Info_base: (abstract new () => {
toBytes(): ccc.Bytes;
clone(): Info;
eq(other: InfoLike): boolean;
hash(): ccc.Hex;
}) & {
byteLength?: number;
encode(_: InfoLike): ccc.Bytes;
decode(_: ccc.BytesLike): Info;
fromBytes(_bytes: ccc.BytesLike): Info;
from(_: InfoLike): Info;
};
export declare class Info extends Info_base {
ckbToUdt: Ratio;
udtToCkb: Ratio;
ckbMinMatchLog: number;
constructor(ckbToUdt: Ratio, udtToCkb: Ratio, ckbMinMatchLog: number);
static from(info: InfoLike): Info;
static create(isCkb2Udt: boolean, ratioLike: ExchangeRatio, ckbMinMatchLog?: number): Info;
validate(): void;
isValid(): boolean;
getCkbMinMatch(): ccc.FixedPoint;
isCkb2Udt(): boolean;
isUdt2Ckb(): boolean;
isDualRatio(): boolean;
ckb2UdtCompare(other: Info): number;
udt2CkbCompare(other: Info): number;
static ckbMinMatchLogDefault(): number;
}
export interface RelativeLike {
padding: ccc.BytesLike;
distance: ccc.NumLike;
}
declare const Relative_base: (abstract new () => {
toBytes(): ccc.Bytes;
clone(): Relative;
eq(other: RelativeLike): boolean;
hash(): ccc.Hex;
}) & {
byteLength?: number;
encode(_: RelativeLike): ccc.Bytes;
decode(_: ccc.BytesLike): Relative;
fromBytes(_bytes: ccc.BytesLike): Relative;
from(_: RelativeLike): Relative;
};
export declare class Relative extends Relative_base {
padding: ccc.Bytes;
distance: ccc.Num;
constructor(padding: ccc.Bytes, distance: ccc.Num);
static from(relative: RelativeLike): Relative;
static create(distance: ccc.Num): Relative;
static padding(): ccc.Bytes;
validate(): void;
isValid(): boolean;
}
export declare const MasterCodec: mol.Codec<{
type: "relative";
value: RelativeLike;
} | {
type: "absolute";
value: ccc.OutPointLike;
}, {
type: "relative";
value: Relative;
} | {
type: "absolute";
value: ccc.OutPoint;
}>;
export type MasterLike = mol.EncodableType<typeof MasterCodec>;
export type Master = mol.DecodedType<typeof MasterCodec>;
export interface OrderDataLike {
udtValue: ccc.FixedPointLike;
master: MasterLike;
info: InfoLike;
}
declare const OrderData_base: (abstract new () => {
toBytes(): ccc.Bytes;
clone(): OrderData;
eq(other: OrderDataLike): boolean;
hash(): ccc.Hex;
}) & {
byteLength?: number;
encode(_: OrderDataLike): ccc.Bytes;
decode(_: ccc.BytesLike): OrderData;
fromBytes(_bytes: ccc.BytesLike): OrderData;
from(_: OrderDataLike): OrderData;
};
export declare class OrderData extends OrderData_base {
udtValue: ccc.FixedPoint;
master: Master;
info: Info;
constructor(udtValue: ccc.FixedPoint, master: Master, info: Info);
static from(data: OrderDataLike): OrderData;
validate(): void;
isValid(): boolean;
isMint(): boolean;
getMaster(current: ccc.OutPoint): ccc.OutPoint;
}
export {};
//# sourceMappingURL=entities.d.ts.map