@pump-fun/shared-contracts
Version:
Shared contracts for Pump.fun microservices.
137 lines (125 loc) • 4.24 kB
text/typescript
// ============================================
// Trade Event Subjects
// ============================================
/**
* Unified Trade Event subjects (actual subjects used in production)
*/
export const UNIFIED_TRADE_SUBJECTS = {
/** All unified trade events (raw/real-time) */
ALL: "unifiedTradeEvent",
/** All unified trade events (both raw and processed) */
ALL_EVENTS: "unifiedTradeEvent.>",
/** All processed unified trade events (enriched/validated) */
PROCESSED: "unifiedTradeEvent.processed",
/** Token-specific unified trade events - use with token address: unifiedTradeEvent.{mintAddress} */
TOKEN_PATTERN: "unifiedTradeEvent.*",
/** Token-specific processed trade events - use with token address: unifiedTradeEvent.processed.{mintAddress} */
TOKEN_PROCESSED_PATTERN: "unifiedTradeEvent.processed.*",
} as const;
/**
* Livestream event subjects
*/
export const LIVESTREAM_SUBJECTS = {
/** All livestream events */
ALL: "livestream.>",
/** Livestream created event */
CREATED: "livestream.created",
} as const;
/**
* CMS article event subjects
*/
export const CMS_SUBJECTS = {
/** All CMS events */
ALL: "cms.>",
/** Article published event */
ARTICLE_PUBLISHED: "cms.article.published",
} as const;
// ============================================
// Watcher Service Subjects
// ============================================
/**
* Trending aggregator service subjects
*/
export const TRENDING_SUBJECTS = {
/** Trending events (volume spikes, percentage increases) */
EVENT: "trending.event",
/** Request trending data */
REQUEST: "trending.request",
/** Trending data response */
RESPONSE: "trending.response",
} as const;
/**
* Watchlist watcher service subjects
*/
export const WATCHLIST_SUBJECTS = {
/** Get user's watchlist */
GET: "watchlist.get",
/** Watchlist price movement alert (X% since added) */
PRICE_MOVEMENT: "watchlist.price.movement",
/** Watchlist price threshold alert (hit market cap/price threshold) */
PRICE_THRESHOLD: "watchlist.price.threshold",
/** Remove item from watchlist */
REMOVE: "watchlist.remove",
/** Watchlist time-based movement alert (X% in 10m, 1h, 6h, 24h) */
TIME_MOVEMENT: "watchlist.time.movement",
/** Update watchlist thresholds */
UPDATE: "watchlist.price.update",
} as const;
/**
* Portfolio watcher service subjects
*/
export const PORTFOLIO_SUBJECTS = {
/** Order execution notification */
ORDER_EXECUTED: "portfolio.order.executed",
/** Portfolio P&L update */
PNL_UPDATE: "portfolio.pnl.update",
/** Portfolio time-based movement alert (X% in 10m, 1h, 6h, 24h) */
TIME_MOVEMENT: "portfolio.time.movement",
} as const;
/**
* Large trade/whale alert subjects
*/
export const WHALE_SUBJECTS = {
/** All whale alerts */
ALL: "whale.>",
/** Large buy transaction alert (Someone just bought $X worth of coin) */
LARGE_BUY: "whale.large.buy",
/** Large sell transaction alert */
LARGE_SELL: "whale.large.sell",
} as const;
/**
* Milestone monitor service subjects
*/
export const MILESTONE_SUBJECTS = {
/** All-time high milestone */
ATH: "milestone.ath",
/** Market cap milestone (100M, 250M, 500M, 1B, 2B) */
MARKET_CAP: "milestone.market-cap",
/** Price threshold milestone */
PRICE: "milestone.price",
} as const;
/**
* All NATS subjects grouped by service
*/
export const NATS_SUBJECTS = {
CMS: CMS_SUBJECTS,
LIVESTREAM: LIVESTREAM_SUBJECTS,
MILESTONE: MILESTONE_SUBJECTS,
PORTFOLIO: PORTFOLIO_SUBJECTS,
TRENDING: TRENDING_SUBJECTS,
UNIFIED_TRADE: UNIFIED_TRADE_SUBJECTS,
WATCHLIST: WATCHLIST_SUBJECTS,
WHALE: WHALE_SUBJECTS,
} as const;
/**
* Type for all possible NATS subjects
*/
export type NatsSubject =
| (typeof UNIFIED_TRADE_SUBJECTS)[keyof typeof UNIFIED_TRADE_SUBJECTS]
| (typeof LIVESTREAM_SUBJECTS)[keyof typeof LIVESTREAM_SUBJECTS]
| (typeof CMS_SUBJECTS)[keyof typeof CMS_SUBJECTS]
| (typeof TRENDING_SUBJECTS)[keyof typeof TRENDING_SUBJECTS]
| (typeof WATCHLIST_SUBJECTS)[keyof typeof WATCHLIST_SUBJECTS]
| (typeof PORTFOLIO_SUBJECTS)[keyof typeof PORTFOLIO_SUBJECTS]
| (typeof MILESTONE_SUBJECTS)[keyof typeof MILESTONE_SUBJECTS]
| (typeof WHALE_SUBJECTS)[keyof typeof WHALE_SUBJECTS];