UNPKG

@node-dlc/messaging

Version:
130 lines (129 loc) 4.52 kB
/// <reference types="node" /> import { MessageType, PayoutCurvePieceType } from '../MessageType'; import { F64 } from '../serialize/F64'; import { IDlcMessage } from './DlcMessage'; export declare abstract class PayoutCurvePiece { static deserialize(buf: Buffer): PolynomialPayoutCurvePiece | HyperbolaPayoutCurvePiece; /** * Creates a PayoutCurvePiece from JSON data * @param json JSON object representing a payout curve piece */ static fromJSON(json: any): PayoutCurvePiece; abstract payoutCurvePieceType: PayoutCurvePieceType; abstract type: number; abstract toJSON(): PolynomialPayoutCurvePieceJSON | HyperbolaPayoutCurvePieceJSON; abstract serialize(): Buffer; } /** * PolynomialPayoutCurvePiece defines a polynomial curve piece for payout functions. * This corresponds to type 0 in the sibling sub-type format. */ export declare class PolynomialPayoutCurvePiece extends PayoutCurvePiece implements IDlcMessage { static payoutCurvePieceType: PayoutCurvePieceType; /** * Creates a PolynomialPayoutCurvePiece from JSON data * @param json JSON object representing a polynomial payout curve piece */ static fromJSON(json: any): PolynomialPayoutCurvePiece; /** * Deserializes a polynomial_payout_curve_piece message * @param buf */ static deserialize(buf: Buffer): PolynomialPayoutCurvePiece; /** * The type for polynomial_payout_curve_piece message - Note: this is a sub-component, not a standalone wire message */ type: MessageType; /** * The payout curve piece type for new format */ payoutCurvePieceType: PayoutCurvePieceType; points: IPoint[]; /** * Converts polynomial_payout_curve_piece to JSON */ toJSON(): PolynomialPayoutCurvePieceJSON; /** * Serializes the polynomial_payout_curve_piece message into a Buffer */ serialize(): Buffer; } /** * HyperbolaPayoutCurvePiece defines a hyperbola curve piece for payout functions. * This corresponds to type 1 in the sibling sub-type format. * Updated to use F64 for precise f64 parameter handling. */ export declare class HyperbolaPayoutCurvePiece extends PayoutCurvePiece implements IDlcMessage { static payoutCurvePieceType: PayoutCurvePieceType; /** * Helper function to safely parse F64 values from JSON * Handles both number and string inputs for maximum precision */ private static parseF64Value; /** * Creates a HyperbolaPayoutCurvePiece from JSON data * @param json JSON object representing a hyperbola payout curve piece */ static fromJSON(json: any): HyperbolaPayoutCurvePiece | null; /** * Deserializes a hyperbola_payout_curve_piece message * @param buf */ static deserialize(buf: Buffer): HyperbolaPayoutCurvePiece; /** * The type for hyperbola_payout_curve_piece message - Note: this is a sub-component, not a standalone wire message */ type: MessageType; payoutCurvePieceType: PayoutCurvePieceType; leftEndPoint: IPayoutPoint; rightEndPoint: IPayoutPoint; usePositivePiece: boolean; translateOutcome: F64; translatePayout: F64; a: F64; b: F64; c: F64; d: F64; constructor(usePositivePiece?: boolean, translateOutcome?: string | F64, translatePayout?: string | F64, a?: string | F64, b?: string | F64, c?: string | F64, d?: string | F64); /** * Converts hyperbola_payout_curve_piece to JSON * Uses F64.toJSONValue() which preserves precision by using strings for very large numbers */ toJSON(): HyperbolaPayoutCurvePieceJSON; /** * Serializes the hyperbola_payout_curve_piece message into a Buffer */ serialize(): Buffer; } interface IPoint { eventOutcome: bigint; outcomePayout: bigint; extraPrecision: number; } interface IPointJSON { eventOutcome: number; outcomePayout: number; extraPrecision: number; } interface IPayoutPoint { eventOutcome: bigint; outcomePayout: bigint; extraPrecision: number; } export interface PolynomialPayoutCurvePieceJSON { polynomialPayoutCurvePiece: { payoutPoints: IPointJSON[]; }; } export interface HyperbolaPayoutCurvePieceJSON { hyperbolaPayoutCurvePiece: { usePositivePiece: boolean; translateOutcome: number | string; translatePayout: number | string; a: number | string; b: number | string; c: number | string; d: number | string; }; } export {};