Skip to content

Instantly share code, notes, and snippets.

@AhmetEnesKCC
Created October 28, 2025 07:21
Show Gist options
  • Select an option

  • Save AhmetEnesKCC/df8d91779b85cecb07fd2400c3718a09 to your computer and use it in GitHub Desktop.

Select an option

Save AhmetEnesKCC/df8d91779b85cecb07fd2400c3718a09 to your computer and use it in GitHub Desktop.
export interface TradingData {
Trading: {
Tokens: TokenData[];
};
}
export interface TokenData {
Block: BlockInfo;
Interval: IntervalInfo;
Price: PriceInfo;
Token: TokenDetails;
Volume: VolumeInfo;
}
export interface BlockInfo {
Date: string;
Time: string;
Timestamp: string;
}
export interface IntervalInfo {
Time: {
Duration: number;
End: string;
Start: string;
};
}
export interface PriceInfo {
Average: AveragePrices;
IsQuotedInUsd: boolean;
Ohlc: OhlcPrices;
}
export interface AveragePrices {
ExponentialMoving: number;
Mean: number;
SimpleMoving: number;
WeightedSimpleMoving: number;
}
export interface OhlcPrices {
Close: number;
High: number;
Low: number;
Open: number;
}
export interface TokenDetails {
Address: string;
Id: string;
IsNative: boolean;
Name: string;
Network: string;
Symbol: string;
TokenId: string;
}
export interface VolumeInfo {
Base: number;
Quote: number;
Usd: number;
}
export type ServiceKeys =
| 'getCurrencyId'
| 'getTokenPrice'
| 'getTokenPriceStream'
| 'getPriceChange'
| 'getPriceChangeStream';
export type data = Record<string, any>;
export type WsConnectionServiceParams<T extends data> = {
autoCloseMs?: number;
onData: (data: T) => void;
onError: (error: any) => void;
};
export type TokenParameter = string;
export type BaseEndpoint = <T extends data>(
apiKey: string,
tokenAddress: string,
) => Promise<T>;
export type WsEndpoint = <T extends data>(
apiKey: string,
tokenAddress: string,
params?: WsConnectionServiceParams<T>,
) => Promise<T> & WsResponse;
export type Endpoint<T extends 'Ws' | 'Base'> = T extends 'Ws'
? WsEndpoint
: BaseEndpoint;
export type WsResponse = { close: () => void };
export type Services = Record<ServiceKeys, WsEndpoint | BaseEndpoint>;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment