@pompafly/sdk 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +187 -0
- package/dist/index.d.mts +382 -0
- package/dist/index.d.ts +382 -0
- package/dist/index.js +641 -0
- package/dist/index.mjs +609 -0
- package/package.json +35 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
import * as _solana_web3_js from '@solana/web3.js';
|
|
2
|
+
import { PublicKey, Keypair, Connection } from '@solana/web3.js';
|
|
3
|
+
|
|
4
|
+
interface PompaflyConfig {
|
|
5
|
+
/** Solana RPC endpoint URL */
|
|
6
|
+
rpcUrl: string;
|
|
7
|
+
/** Pompafly program ID */
|
|
8
|
+
programId: string;
|
|
9
|
+
/** Backend API base URL */
|
|
10
|
+
apiUrl: string;
|
|
11
|
+
/** WebSocket URL for real-time feeds */
|
|
12
|
+
wsUrl: string;
|
|
13
|
+
}
|
|
14
|
+
declare const DEVNET_CONFIG: PompaflyConfig;
|
|
15
|
+
declare const MAINNET_CONFIG: PompaflyConfig;
|
|
16
|
+
/** Compatible with @solana/wallet-adapter AnchorWallet interface */
|
|
17
|
+
interface WalletAdapter {
|
|
18
|
+
publicKey: PublicKey;
|
|
19
|
+
signTransaction: <T extends _solana_web3_js.Transaction | _solana_web3_js.VersionedTransaction>(tx: T) => Promise<T>;
|
|
20
|
+
signAllTransactions: <T extends _solana_web3_js.Transaction | _solana_web3_js.VersionedTransaction>(txs: T[]) => Promise<T[]>;
|
|
21
|
+
}
|
|
22
|
+
interface Pool {
|
|
23
|
+
mint: string;
|
|
24
|
+
poolAddress: string;
|
|
25
|
+
creator: string;
|
|
26
|
+
creatorXHandle: string;
|
|
27
|
+
name: string;
|
|
28
|
+
symbol: string;
|
|
29
|
+
uri: string;
|
|
30
|
+
status: "active" | "graduating" | "graduated";
|
|
31
|
+
totalSupply: string;
|
|
32
|
+
supplySold: string;
|
|
33
|
+
solBalance: string;
|
|
34
|
+
currentPrice: string;
|
|
35
|
+
marketCap: string;
|
|
36
|
+
progressPercent: number;
|
|
37
|
+
priorityWindowEnd: string;
|
|
38
|
+
graduatedAt: string | null;
|
|
39
|
+
totalTrades: number;
|
|
40
|
+
totalVolumeSol: string;
|
|
41
|
+
holderCount: number;
|
|
42
|
+
createdAt: string;
|
|
43
|
+
}
|
|
44
|
+
interface PoolPrice {
|
|
45
|
+
currentPrice: string;
|
|
46
|
+
marketCap: string;
|
|
47
|
+
solBalance: string;
|
|
48
|
+
supplySold: string;
|
|
49
|
+
progressPercent: number;
|
|
50
|
+
graduationThreshold: string;
|
|
51
|
+
isPriorityWindow: boolean;
|
|
52
|
+
status: string;
|
|
53
|
+
}
|
|
54
|
+
interface PoolListParams {
|
|
55
|
+
page?: number;
|
|
56
|
+
limit?: number;
|
|
57
|
+
status?: "active" | "graduating" | "graduated";
|
|
58
|
+
sort?: "newest" | "oldest" | "volume" | "marketcap" | "graduating";
|
|
59
|
+
search?: string;
|
|
60
|
+
creator?: string;
|
|
61
|
+
}
|
|
62
|
+
interface Trade {
|
|
63
|
+
pool: string;
|
|
64
|
+
mint: string;
|
|
65
|
+
trader: string;
|
|
66
|
+
type: "buy" | "sell";
|
|
67
|
+
tokenAmount: string;
|
|
68
|
+
solAmount: string;
|
|
69
|
+
fee: string;
|
|
70
|
+
price: string;
|
|
71
|
+
txSignature: string;
|
|
72
|
+
timestamp: string;
|
|
73
|
+
}
|
|
74
|
+
interface TradeListParams {
|
|
75
|
+
page?: number;
|
|
76
|
+
limit?: number;
|
|
77
|
+
type?: "buy" | "sell";
|
|
78
|
+
trader?: string;
|
|
79
|
+
}
|
|
80
|
+
interface Candle {
|
|
81
|
+
timestamp: number;
|
|
82
|
+
open: number;
|
|
83
|
+
high: number;
|
|
84
|
+
low: number;
|
|
85
|
+
close: number;
|
|
86
|
+
volume: number;
|
|
87
|
+
tradeCount: number;
|
|
88
|
+
}
|
|
89
|
+
type CandleInterval = "1m" | "5m" | "15m" | "1h" | "4h" | "1d";
|
|
90
|
+
interface CandleParams {
|
|
91
|
+
interval: CandleInterval;
|
|
92
|
+
from?: number;
|
|
93
|
+
to?: number;
|
|
94
|
+
limit?: number;
|
|
95
|
+
}
|
|
96
|
+
interface User {
|
|
97
|
+
wallet: string;
|
|
98
|
+
xHandle: string;
|
|
99
|
+
xVerified: boolean;
|
|
100
|
+
isCreator: boolean;
|
|
101
|
+
totalTrades: number;
|
|
102
|
+
totalVolumeSol: string;
|
|
103
|
+
createdAt: string;
|
|
104
|
+
}
|
|
105
|
+
interface PlatformStats {
|
|
106
|
+
totalPoolsCreated: number;
|
|
107
|
+
totalPoolsGraduated: number;
|
|
108
|
+
graduationRate: string;
|
|
109
|
+
activePoolsCount: number;
|
|
110
|
+
totalUsers: number;
|
|
111
|
+
totalTrades: number;
|
|
112
|
+
totalVolumeSol: string;
|
|
113
|
+
totalFeesCollected: string;
|
|
114
|
+
}
|
|
115
|
+
interface TrendingPool {
|
|
116
|
+
mint: string;
|
|
117
|
+
name: string;
|
|
118
|
+
symbol: string;
|
|
119
|
+
creatorXHandle: string;
|
|
120
|
+
status: string;
|
|
121
|
+
volume24h: string;
|
|
122
|
+
trades24h: number;
|
|
123
|
+
currentPrice: string;
|
|
124
|
+
marketCap: string;
|
|
125
|
+
progressPercent: number;
|
|
126
|
+
}
|
|
127
|
+
interface TxResult {
|
|
128
|
+
signature: string;
|
|
129
|
+
slot?: number;
|
|
130
|
+
}
|
|
131
|
+
interface BuyResult extends TxResult {
|
|
132
|
+
tokenAmount: string;
|
|
133
|
+
solCost: string;
|
|
134
|
+
}
|
|
135
|
+
interface SellResult extends TxResult {
|
|
136
|
+
tokenAmount: string;
|
|
137
|
+
solReceived: string;
|
|
138
|
+
}
|
|
139
|
+
interface CreatePoolResult extends TxResult {
|
|
140
|
+
mint: string;
|
|
141
|
+
pool: string;
|
|
142
|
+
}
|
|
143
|
+
interface ApiResponse<T> {
|
|
144
|
+
success: boolean;
|
|
145
|
+
data: T;
|
|
146
|
+
error?: string;
|
|
147
|
+
code?: string;
|
|
148
|
+
}
|
|
149
|
+
interface PaginatedResponse<T> extends ApiResponse<T[]> {
|
|
150
|
+
pagination: {
|
|
151
|
+
total: number;
|
|
152
|
+
page: number;
|
|
153
|
+
limit: number;
|
|
154
|
+
pages: number;
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
interface PriceEvent {
|
|
158
|
+
type: "price";
|
|
159
|
+
mint: string;
|
|
160
|
+
data: PoolPrice;
|
|
161
|
+
}
|
|
162
|
+
interface TradeEvent {
|
|
163
|
+
type: "trade";
|
|
164
|
+
mint: string;
|
|
165
|
+
data: Trade;
|
|
166
|
+
}
|
|
167
|
+
interface StatusEvent {
|
|
168
|
+
type: "status";
|
|
169
|
+
mint: string;
|
|
170
|
+
data: {
|
|
171
|
+
oldStatus: string;
|
|
172
|
+
newStatus: string;
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
type StreamEvent = PriceEvent | TradeEvent | StatusEvent;
|
|
176
|
+
type StreamEventHandler = (event: StreamEvent) => void;
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* ─────────────────────────────────────────────────────────────
|
|
180
|
+
* PompaflyClient — on-chain transaction builder
|
|
181
|
+
*
|
|
182
|
+
* Builds and sends Solana transactions for the Pompafly program.
|
|
183
|
+
* No dependency on anchor.Program — uses raw instruction encoding.
|
|
184
|
+
*
|
|
185
|
+
* Usage with wallet adapter (frontend):
|
|
186
|
+
* const client = new PompaflyClient({ wallet });
|
|
187
|
+
*
|
|
188
|
+
* Usage with keypair (backend/scripts):
|
|
189
|
+
* const client = new PompaflyClient({ keypair });
|
|
190
|
+
* ─────────────────────────────────────────────────────────────
|
|
191
|
+
*/
|
|
192
|
+
interface ClientOptions {
|
|
193
|
+
wallet?: WalletAdapter;
|
|
194
|
+
keypair?: Keypair;
|
|
195
|
+
config?: PompaflyConfig;
|
|
196
|
+
connection?: Connection;
|
|
197
|
+
}
|
|
198
|
+
declare class PompaflyClient {
|
|
199
|
+
readonly connection: Connection;
|
|
200
|
+
readonly programId: PublicKey;
|
|
201
|
+
readonly config: PompaflyConfig;
|
|
202
|
+
private wallet;
|
|
203
|
+
private globalConfigPda;
|
|
204
|
+
constructor(options: ClientOptions);
|
|
205
|
+
get publicKey(): PublicKey;
|
|
206
|
+
private sendTx;
|
|
207
|
+
createPool(name: string, symbol: string, uri: string, creatorXHandle: string, authoritySigner: Keypair): Promise<CreatePoolResult>;
|
|
208
|
+
buy(mint: string | PublicKey, tokenAmount: number, maxSlippageSol: number, prioritySigner?: Keypair): Promise<BuyResult>;
|
|
209
|
+
sell(mint: string | PublicKey, tokenAmount: number, minReturnSol?: number): Promise<SellResult>;
|
|
210
|
+
collectFees(mint: string | PublicKey, validatorWallet: string | PublicKey, communityWallet: string | PublicKey, platformWallet: string | PublicKey): Promise<TxResult>;
|
|
211
|
+
graduate(mint: string | PublicKey): Promise<TxResult>;
|
|
212
|
+
/**
|
|
213
|
+
* Get raw account data for a pool PDA.
|
|
214
|
+
* Returns the raw bytes — use with the Anchor IDL for full deserialization,
|
|
215
|
+
* or parse manually if you know the layout.
|
|
216
|
+
*/
|
|
217
|
+
getPoolAccountInfo(mint: string | PublicKey): Promise<_solana_web3_js.AccountInfo<Buffer<ArrayBufferLike>> | null>;
|
|
218
|
+
/** Get the pool PDA address for a given mint */
|
|
219
|
+
getPoolAddress(mint: string | PublicKey): Promise<string>;
|
|
220
|
+
/** Get the token vault ATA address for a pool */
|
|
221
|
+
getPoolTokenVault(mint: string | PublicKey): Promise<string>;
|
|
222
|
+
/** Get the global config PDA address */
|
|
223
|
+
getGlobalConfigAddress(): string;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* ─────────────────────────────────────────────────────────────
|
|
228
|
+
* PompaflyAPI — REST API client
|
|
229
|
+
*
|
|
230
|
+
* Wraps all backend endpoints with typed responses.
|
|
231
|
+
* Handles JWT auth automatically after login.
|
|
232
|
+
*
|
|
233
|
+
* Usage:
|
|
234
|
+
* const api = new PompaflyAPI();
|
|
235
|
+
* const pools = await api.getPools({ sort: "trending" });
|
|
236
|
+
* await api.login(wallet, signature);
|
|
237
|
+
* const me = await api.getMe();
|
|
238
|
+
* ─────────────────────────────────────────────────────────────
|
|
239
|
+
*/
|
|
240
|
+
declare class PompaflyAPI {
|
|
241
|
+
private baseUrl;
|
|
242
|
+
private token;
|
|
243
|
+
constructor(config?: PompaflyConfig);
|
|
244
|
+
/** Set JWT token for authenticated requests */
|
|
245
|
+
setToken(token: string): void;
|
|
246
|
+
/** Clear authentication */
|
|
247
|
+
clearToken(): void;
|
|
248
|
+
private fetch;
|
|
249
|
+
/** Request a login nonce for wallet signature */
|
|
250
|
+
getNonce(wallet: string): Promise<ApiResponse<{
|
|
251
|
+
nonce: string;
|
|
252
|
+
message: string;
|
|
253
|
+
}>>;
|
|
254
|
+
/** Verify wallet signature and get JWT */
|
|
255
|
+
verifyWallet(wallet: string, signature: string): Promise<ApiResponse<{
|
|
256
|
+
token: string;
|
|
257
|
+
user: User;
|
|
258
|
+
}>>;
|
|
259
|
+
/** Get X OAuth login URL (must be authenticated first) */
|
|
260
|
+
getXLoginUrl(): string;
|
|
261
|
+
/** Get current user profile */
|
|
262
|
+
getMe(): Promise<ApiResponse<User>>;
|
|
263
|
+
/** List pools with filters and sorting */
|
|
264
|
+
getPools(params?: PoolListParams): Promise<PaginatedResponse<Pool>>;
|
|
265
|
+
/** Get pool details by mint */
|
|
266
|
+
getPool(mint: string): Promise<ApiResponse<Pool>>;
|
|
267
|
+
/** Get current price and curve position */
|
|
268
|
+
getPoolPrice(mint: string): Promise<ApiResponse<PoolPrice>>;
|
|
269
|
+
/** Get top holders for a pool */
|
|
270
|
+
getHolders(mint: string, limit?: number): Promise<ApiResponse<{
|
|
271
|
+
holders: any[];
|
|
272
|
+
totalHolders: number;
|
|
273
|
+
}>>;
|
|
274
|
+
/** Get trade history for a pool */
|
|
275
|
+
getTrades(mint: string, params?: TradeListParams): Promise<PaginatedResponse<Trade>>;
|
|
276
|
+
/** Get OHLCV candle data for charts */
|
|
277
|
+
getCandles(mint: string, params: CandleParams): Promise<ApiResponse<Candle[]>>;
|
|
278
|
+
/** Get trade history for a specific wallet */
|
|
279
|
+
getUserTrades(wallet: string, params?: {
|
|
280
|
+
page?: number;
|
|
281
|
+
limit?: number;
|
|
282
|
+
}): Promise<PaginatedResponse<Trade>>;
|
|
283
|
+
/** Get a priority buy authorization (requires X verification) */
|
|
284
|
+
getPriorityAuth(mint: string): Promise<ApiResponse<{
|
|
285
|
+
signature: string;
|
|
286
|
+
pool: string;
|
|
287
|
+
wallet: string;
|
|
288
|
+
expiresAt: number;
|
|
289
|
+
}>>;
|
|
290
|
+
/** Check priority window status */
|
|
291
|
+
getPriorityStatus(mint: string): Promise<ApiResponse<{
|
|
292
|
+
isActive: boolean;
|
|
293
|
+
endsAt: string;
|
|
294
|
+
remainingSeconds: number;
|
|
295
|
+
}>>;
|
|
296
|
+
/** Get platform-wide statistics */
|
|
297
|
+
getStats(): Promise<ApiResponse<PlatformStats>>;
|
|
298
|
+
/** Get trending pools (24h volume) */
|
|
299
|
+
getTrending(limit?: number): Promise<ApiResponse<TrendingPool[]>>;
|
|
300
|
+
/** Get trader leaderboard */
|
|
301
|
+
getLeaderboard(params?: {
|
|
302
|
+
limit?: number;
|
|
303
|
+
period?: string;
|
|
304
|
+
}): Promise<ApiResponse<any[]>>;
|
|
305
|
+
/** Get fee distribution breakdown */
|
|
306
|
+
getFeeStats(): Promise<ApiResponse<any>>;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
declare class PompaflyStream {
|
|
310
|
+
private wsUrl;
|
|
311
|
+
private ws;
|
|
312
|
+
private listeners;
|
|
313
|
+
private subscriptions;
|
|
314
|
+
private reconnectAttempts;
|
|
315
|
+
private maxReconnectAttempts;
|
|
316
|
+
private reconnectDelay;
|
|
317
|
+
private autoReconnect;
|
|
318
|
+
private isConnected;
|
|
319
|
+
constructor(config?: PompaflyConfig);
|
|
320
|
+
/** Connect to the WebSocket server */
|
|
321
|
+
connect(): void;
|
|
322
|
+
/** Disconnect from the WebSocket server */
|
|
323
|
+
disconnect(): void;
|
|
324
|
+
/** Subscribe to real-time updates for specific token mints */
|
|
325
|
+
subscribe(mints: string[]): void;
|
|
326
|
+
/** Unsubscribe from specific token mints */
|
|
327
|
+
unsubscribe(mints: string[]): void;
|
|
328
|
+
/** Listen for price update events */
|
|
329
|
+
onPrice(handler: (event: PriceEvent) => void): () => void;
|
|
330
|
+
/** Listen for new trade events */
|
|
331
|
+
onTrade(handler: (event: TradeEvent) => void): () => void;
|
|
332
|
+
/** Listen for pool status change events */
|
|
333
|
+
onStatus(handler: (event: StatusEvent) => void): () => void;
|
|
334
|
+
/** Listen for all events */
|
|
335
|
+
onAny(handler: StreamEventHandler): () => void;
|
|
336
|
+
/** Check if connected */
|
|
337
|
+
get connected(): boolean;
|
|
338
|
+
/** Get currently subscribed mints */
|
|
339
|
+
get subscribedMints(): string[];
|
|
340
|
+
private addListener;
|
|
341
|
+
private handleMessage;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* Derive all PDAs for a given mint and program ID.
|
|
346
|
+
* Call once per pool, cache the result.
|
|
347
|
+
*/
|
|
348
|
+
declare function derivePoolAddresses(mint: PublicKey, programId: PublicKey): Promise<{
|
|
349
|
+
pool: PublicKey;
|
|
350
|
+
poolBump: number;
|
|
351
|
+
poolTokenVault: PublicKey;
|
|
352
|
+
}>;
|
|
353
|
+
/**
|
|
354
|
+
* Derive the global config PDA.
|
|
355
|
+
*/
|
|
356
|
+
declare function deriveGlobalConfig(programId: PublicKey): [PublicKey, number];
|
|
357
|
+
/**
|
|
358
|
+
* Convert SOL to lamports.
|
|
359
|
+
*/
|
|
360
|
+
declare function solToLamports(sol: number): number;
|
|
361
|
+
/**
|
|
362
|
+
* Convert lamports to SOL.
|
|
363
|
+
*/
|
|
364
|
+
declare function lamportsToSol(lamports: number | string): number;
|
|
365
|
+
/**
|
|
366
|
+
* Convert token amount to base units (6 decimals).
|
|
367
|
+
*/
|
|
368
|
+
declare function tokensToBase(tokens: number): number;
|
|
369
|
+
/**
|
|
370
|
+
* Convert base units to token amount (6 decimals).
|
|
371
|
+
*/
|
|
372
|
+
declare function baseToTokens(base: number | string): number;
|
|
373
|
+
/** Re-export program constants */
|
|
374
|
+
declare const PROGRAM_CONSTANTS: {
|
|
375
|
+
readonly TOKEN_DECIMALS: 6;
|
|
376
|
+
readonly TOTAL_SUPPLY: "1000000000000000";
|
|
377
|
+
readonly GRADUATION_THRESHOLD_SOL: 150;
|
|
378
|
+
readonly FEE_BPS: 100;
|
|
379
|
+
readonly PRIORITY_WINDOW_SECONDS: 120;
|
|
380
|
+
};
|
|
381
|
+
|
|
382
|
+
export { type ApiResponse, type BuyResult, type Candle, type CandleInterval, type CandleParams, type ClientOptions, type CreatePoolResult, DEVNET_CONFIG, MAINNET_CONFIG, PROGRAM_CONSTANTS, type PaginatedResponse, type PlatformStats, PompaflyAPI, PompaflyClient, type PompaflyConfig, PompaflyStream, type Pool, type PoolListParams, type PoolPrice, type PriceEvent, type SellResult, type StatusEvent, type StreamEvent, type StreamEventHandler, type Trade, type TradeEvent, type TradeListParams, type TrendingPool, type TxResult, type User, type WalletAdapter, baseToTokens, deriveGlobalConfig, derivePoolAddresses, lamportsToSol, solToLamports, tokensToBase };
|