@d8x/perpetuals-sdk
Version:
Node TypeScript SDK for D8X Perpetual Futures
232 lines (231 loc) • 10.8 kB
TypeScript
import type { BaseContract, BigNumberish, BytesLike, FunctionFragment, Result, Interface, EventFragment, ContractRunner, ContractMethod, Listener } from "ethers";
import type { TypedContractEvent, TypedDeferredTopicFilter, TypedEventLog, TypedLogDescription, TypedListener, TypedContractMethod } from "./common";
export declare namespace PythStructs {
type PriceStruct = {
price: BigNumberish;
conf: BigNumberish;
expo: BigNumberish;
publishTime: BigNumberish;
};
type PriceStructOutput = [
price: bigint,
conf: bigint,
expo: bigint,
publishTime: bigint
] & {
price: bigint;
conf: bigint;
expo: bigint;
publishTime: bigint;
};
type PriceFeedStruct = {
id: BytesLike;
price: PythStructs.PriceStruct;
emaPrice: PythStructs.PriceStruct;
};
type PriceFeedStructOutput = [
id: string,
price: PythStructs.PriceStructOutput,
emaPrice: PythStructs.PriceStructOutput
] & {
id: string;
price: PythStructs.PriceStructOutput;
emaPrice: PythStructs.PriceStructOutput;
};
}
export interface IPythInterface extends Interface {
getFunction(nameOrSignature: "getEmaPrice" | "getEmaPriceNoOlderThan" | "getEmaPriceUnsafe" | "getPrice" | "getPriceNoOlderThan" | "getPriceUnsafe" | "getUpdateFee" | "getValidTimePeriod" | "parsePriceFeedUpdates" | "updatePriceFeeds" | "updatePriceFeedsIfNecessary"): FunctionFragment;
getEvent(nameOrSignatureOrTopic: "BatchPriceFeedUpdate" | "PriceFeedUpdate"): EventFragment;
encodeFunctionData(functionFragment: "getEmaPrice", values: [BytesLike]): string;
encodeFunctionData(functionFragment: "getEmaPriceNoOlderThan", values: [BytesLike, BigNumberish]): string;
encodeFunctionData(functionFragment: "getEmaPriceUnsafe", values: [BytesLike]): string;
encodeFunctionData(functionFragment: "getPrice", values: [BytesLike]): string;
encodeFunctionData(functionFragment: "getPriceNoOlderThan", values: [BytesLike, BigNumberish]): string;
encodeFunctionData(functionFragment: "getPriceUnsafe", values: [BytesLike]): string;
encodeFunctionData(functionFragment: "getUpdateFee", values: [BytesLike[]]): string;
encodeFunctionData(functionFragment: "getValidTimePeriod", values?: undefined): string;
encodeFunctionData(functionFragment: "parsePriceFeedUpdates", values: [BytesLike[], BytesLike[], BigNumberish, BigNumberish]): string;
encodeFunctionData(functionFragment: "updatePriceFeeds", values: [BytesLike[]]): string;
encodeFunctionData(functionFragment: "updatePriceFeedsIfNecessary", values: [BytesLike[], BytesLike[], BigNumberish[]]): string;
decodeFunctionResult(functionFragment: "getEmaPrice", data: BytesLike): Result;
decodeFunctionResult(functionFragment: "getEmaPriceNoOlderThan", data: BytesLike): Result;
decodeFunctionResult(functionFragment: "getEmaPriceUnsafe", data: BytesLike): Result;
decodeFunctionResult(functionFragment: "getPrice", data: BytesLike): Result;
decodeFunctionResult(functionFragment: "getPriceNoOlderThan", data: BytesLike): Result;
decodeFunctionResult(functionFragment: "getPriceUnsafe", data: BytesLike): Result;
decodeFunctionResult(functionFragment: "getUpdateFee", data: BytesLike): Result;
decodeFunctionResult(functionFragment: "getValidTimePeriod", data: BytesLike): Result;
decodeFunctionResult(functionFragment: "parsePriceFeedUpdates", data: BytesLike): Result;
decodeFunctionResult(functionFragment: "updatePriceFeeds", data: BytesLike): Result;
decodeFunctionResult(functionFragment: "updatePriceFeedsIfNecessary", data: BytesLike): Result;
}
export declare namespace BatchPriceFeedUpdateEvent {
type InputTuple = [
chainId: BigNumberish,
sequenceNumber: BigNumberish
];
type OutputTuple = [chainId: bigint, sequenceNumber: bigint];
interface OutputObject {
chainId: bigint;
sequenceNumber: bigint;
}
type Event = TypedContractEvent<InputTuple, OutputTuple, OutputObject>;
type Filter = TypedDeferredTopicFilter<Event>;
type Log = TypedEventLog<Event>;
type LogDescription = TypedLogDescription<Event>;
}
export declare namespace PriceFeedUpdateEvent {
type InputTuple = [
id: BytesLike,
publishTime: BigNumberish,
price: BigNumberish,
conf: BigNumberish
];
type OutputTuple = [
id: string,
publishTime: bigint,
price: bigint,
conf: bigint
];
interface OutputObject {
id: string;
publishTime: bigint;
price: bigint;
conf: bigint;
}
type Event = TypedContractEvent<InputTuple, OutputTuple, OutputObject>;
type Filter = TypedDeferredTopicFilter<Event>;
type Log = TypedEventLog<Event>;
type LogDescription = TypedLogDescription<Event>;
}
export interface IPyth extends BaseContract {
connect(runner?: ContractRunner | null): IPyth;
waitForDeployment(): Promise<this>;
interface: IPythInterface;
queryFilter<TCEvent extends TypedContractEvent>(event: TCEvent, fromBlockOrBlockhash?: string | number | undefined, toBlock?: string | number | undefined): Promise<Array<TypedEventLog<TCEvent>>>;
queryFilter<TCEvent extends TypedContractEvent>(filter: TypedDeferredTopicFilter<TCEvent>, fromBlockOrBlockhash?: string | number | undefined, toBlock?: string | number | undefined): Promise<Array<TypedEventLog<TCEvent>>>;
on<TCEvent extends TypedContractEvent>(event: TCEvent, listener: TypedListener<TCEvent>): Promise<this>;
on<TCEvent extends TypedContractEvent>(filter: TypedDeferredTopicFilter<TCEvent>, listener: TypedListener<TCEvent>): Promise<this>;
once<TCEvent extends TypedContractEvent>(event: TCEvent, listener: TypedListener<TCEvent>): Promise<this>;
once<TCEvent extends TypedContractEvent>(filter: TypedDeferredTopicFilter<TCEvent>, listener: TypedListener<TCEvent>): Promise<this>;
listeners<TCEvent extends TypedContractEvent>(event: TCEvent): Promise<Array<TypedListener<TCEvent>>>;
listeners(eventName?: string): Promise<Array<Listener>>;
removeAllListeners<TCEvent extends TypedContractEvent>(event?: TCEvent): Promise<this>;
getEmaPrice: TypedContractMethod<[
id: BytesLike
], [
PythStructs.PriceStructOutput
], "view">;
getEmaPriceNoOlderThan: TypedContractMethod<[
id: BytesLike,
age: BigNumberish
], [
PythStructs.PriceStructOutput
], "view">;
getEmaPriceUnsafe: TypedContractMethod<[
id: BytesLike
], [
PythStructs.PriceStructOutput
], "view">;
getPrice: TypedContractMethod<[
id: BytesLike
], [
PythStructs.PriceStructOutput
], "view">;
getPriceNoOlderThan: TypedContractMethod<[
id: BytesLike,
age: BigNumberish
], [
PythStructs.PriceStructOutput
], "view">;
getPriceUnsafe: TypedContractMethod<[
id: BytesLike
], [
PythStructs.PriceStructOutput
], "view">;
getUpdateFee: TypedContractMethod<[
updateData: BytesLike[]
], [
bigint
], "view">;
getValidTimePeriod: TypedContractMethod<[], [bigint], "view">;
parsePriceFeedUpdates: TypedContractMethod<[
updateData: BytesLike[],
priceIds: BytesLike[],
minPublishTime: BigNumberish,
maxPublishTime: BigNumberish
], [
PythStructs.PriceFeedStructOutput[]
], "payable">;
updatePriceFeeds: TypedContractMethod<[
updateData: BytesLike[]
], [
void
], "payable">;
updatePriceFeedsIfNecessary: TypedContractMethod<[
updateData: BytesLike[],
priceIds: BytesLike[],
publishTimes: BigNumberish[]
], [
void
], "payable">;
getFunction<T extends ContractMethod = ContractMethod>(key: string | FunctionFragment): T;
getFunction(nameOrSignature: "getEmaPrice"): TypedContractMethod<[
id: BytesLike
], [
PythStructs.PriceStructOutput
], "view">;
getFunction(nameOrSignature: "getEmaPriceNoOlderThan"): TypedContractMethod<[
id: BytesLike,
age: BigNumberish
], [
PythStructs.PriceStructOutput
], "view">;
getFunction(nameOrSignature: "getEmaPriceUnsafe"): TypedContractMethod<[
id: BytesLike
], [
PythStructs.PriceStructOutput
], "view">;
getFunction(nameOrSignature: "getPrice"): TypedContractMethod<[
id: BytesLike
], [
PythStructs.PriceStructOutput
], "view">;
getFunction(nameOrSignature: "getPriceNoOlderThan"): TypedContractMethod<[
id: BytesLike,
age: BigNumberish
], [
PythStructs.PriceStructOutput
], "view">;
getFunction(nameOrSignature: "getPriceUnsafe"): TypedContractMethod<[
id: BytesLike
], [
PythStructs.PriceStructOutput
], "view">;
getFunction(nameOrSignature: "getUpdateFee"): TypedContractMethod<[updateData: BytesLike[]], [bigint], "view">;
getFunction(nameOrSignature: "getValidTimePeriod"): TypedContractMethod<[], [bigint], "view">;
getFunction(nameOrSignature: "parsePriceFeedUpdates"): TypedContractMethod<[
updateData: BytesLike[],
priceIds: BytesLike[],
minPublishTime: BigNumberish,
maxPublishTime: BigNumberish
], [
PythStructs.PriceFeedStructOutput[]
], "payable">;
getFunction(nameOrSignature: "updatePriceFeeds"): TypedContractMethod<[updateData: BytesLike[]], [void], "payable">;
getFunction(nameOrSignature: "updatePriceFeedsIfNecessary"): TypedContractMethod<[
updateData: BytesLike[],
priceIds: BytesLike[],
publishTimes: BigNumberish[]
], [
void
], "payable">;
getEvent(key: "BatchPriceFeedUpdate"): TypedContractEvent<BatchPriceFeedUpdateEvent.InputTuple, BatchPriceFeedUpdateEvent.OutputTuple, BatchPriceFeedUpdateEvent.OutputObject>;
getEvent(key: "PriceFeedUpdate"): TypedContractEvent<PriceFeedUpdateEvent.InputTuple, PriceFeedUpdateEvent.OutputTuple, PriceFeedUpdateEvent.OutputObject>;
filters: {
"BatchPriceFeedUpdate(uint16,uint64)": TypedContractEvent<BatchPriceFeedUpdateEvent.InputTuple, BatchPriceFeedUpdateEvent.OutputTuple, BatchPriceFeedUpdateEvent.OutputObject>;
BatchPriceFeedUpdate: TypedContractEvent<BatchPriceFeedUpdateEvent.InputTuple, BatchPriceFeedUpdateEvent.OutputTuple, BatchPriceFeedUpdateEvent.OutputObject>;
"PriceFeedUpdate(bytes32,uint64,int64,uint64)": TypedContractEvent<PriceFeedUpdateEvent.InputTuple, PriceFeedUpdateEvent.OutputTuple, PriceFeedUpdateEvent.OutputObject>;
PriceFeedUpdate: TypedContractEvent<PriceFeedUpdateEvent.InputTuple, PriceFeedUpdateEvent.OutputTuple, PriceFeedUpdateEvent.OutputObject>;
};
}