Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion workspace/data-proxy/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@seda-protocol/data-proxy",
"main": "./src/index.ts",
"version": "6.0.2",
"version": "6.1.0",
"devDependencies": {
"@types/big.js": "^6.2.2",
"@types/ws": "^8.18.1",
Expand Down
91 changes: 21 additions & 70 deletions workspace/data-proxy/src/config/lighter-module-config.ts
Original file line number Diff line number Diff line change
@@ -1,85 +1,36 @@
import { Duration, Effect, Option } from "effect";
import * as v from "valibot";
import { RouteSchema } from "./route-config";
import {
keepaliveIntervalField,
tickerModuleBaseFields,
tickerModuleRouteSchema,
validateTickerModuleRoute,
} from "./ticker-module-config";

export const LIGHTER_STREAM_TYPES = ["ticker", "order_book", "trade"] as const;

export type LighterStreamType = (typeof LIGHTER_STREAM_TYPES)[number];

export const LighterModuleConfigSchema = v.strictObject({
name: v.string(),
type: v.literal("lighter"),
wsUrl: v.optional(v.string(), "wss://mainnet.zklighter.elliot.ai/stream"),
// Lighter numeric market ids (e.g. 1 for BTC) to subscribe at startup.
subscriptionMarketIds: v.optional(v.array(v.number()), []),
maxMarketsPerRequest: v.optional(v.number(), 100),
// Lighter allows 200 client WS messages per minute.
maxMessagesPerMinute: v.optional(
v.pipe(
v.number(),
v.minValue(1, "maxMessagesPerMinute must be at least 1"),
),
180,
),
...tickerModuleBaseFields({
// ?readonly=true avoids geo-restriction on the public stream.
wsUrl: "wss://mainnet.zklighter.elliot.ai/stream?readonly=true",
// Lighter allows 200 client WS messages per minute.
maxMessages: 180,
maxMessagesWindow: "1 minute",
}),
// Lighter closes a connection with no client frames for 2 minutes;
// ping on a shorter cadence.
keepaliveInterval: v.pipe(
v.optional(v.union([v.number(), v.string()]), "60 seconds"),
v.transform((value) =>
Option.getOrThrowWith(
Duration.decodeUnknown(value),
() => new Error("Invalid keepaliveInterval duration"),
),
),
),
reconnectMaxBackoff: v.pipe(
v.optional(v.union([v.number(), v.string()]), "30 seconds"),
v.transform((value) =>
Option.getOrThrowWith(
Duration.decodeUnknown(value),
() => new Error("Invalid reconnectMaxBackoff duration"),
),
),
),
reconnectStableThreshold: v.pipe(
v.optional(v.union([v.number(), v.string()]), "30 seconds"),
v.transform((value) =>
Option.getOrThrowWith(
Duration.decodeUnknown(value),
() => new Error("Invalid reconnectStableThreshold duration"),
),
),
),
marketsCleanupTtl: v.pipe(
v.optional(v.union([v.number(), v.string()]), "1 hour"),
v.transform((ttl) =>
Option.getOrThrowWith(
Duration.decodeUnknown(ttl),
() => new Error("Invalid markets cleanup TTL"),
),
),
),
marketsCleanupInterval: v.pipe(
v.optional(v.union([v.number(), v.string()]), "30 seconds"),
v.transform((interval) =>
Option.getOrThrowWith(
Duration.decodeUnknown(interval),
() => new Error("Invalid markets cleanup interval"),
),
),
),
keepaliveInterval: keepaliveIntervalField("60 seconds"),
streamType: v.optional(v.picklist(LIGHTER_STREAM_TYPES), "ticker"),
});

export type LighterModuleConfig = v.InferOutput<
typeof LighterModuleConfigSchema
>;

export const LighterModuleRouteSchema = v.strictObject({
...RouteSchema.entries,
moduleName: v.string(),
fetchFromModule: v.string(),
type: v.literal("lighter"),
});
export const LighterModuleRouteSchema = tickerModuleRouteSchema("lighter");

export type LighterModuleRoute = v.InferOutput<typeof LighterModuleRouteSchema>;

export const validateLighterModuleRoute = (_route: LighterModuleRoute) =>
Effect.gen(function* () {
return yield* Effect.void;
});
export const validateLighterModuleRoute = validateTickerModuleRoute;
2 changes: 1 addition & 1 deletion workspace/data-proxy/src/config/ticker-module-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const durationField = (defaultValue: string, invalidMessage: string) =>
),
);

/** Shared fields for string-keyed public ticker modules. */
/** Shared fields for public ticker modules. */
export const tickerModuleBaseFields = (defaults: {
wsUrl: string;
maxMessages: number;
Expand Down
7 changes: 0 additions & 7 deletions workspace/data-proxy/src/modules/lighter/errors.ts

This file was deleted.

161 changes: 0 additions & 161 deletions workspace/data-proxy/src/modules/lighter/lighter.ts

This file was deleted.

Loading
Loading