@floorlaunchpad/sdk 0.3.2 → 0.4.1
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/CHANGELOG.md +94 -0
- package/README.md +16 -0
- package/dist/abi/evm.gen.js +6 -1
- package/dist/abi/solana.gen.js +1 -1
- package/dist/client/evm/index.js +16 -2
- package/dist/client/solana/index.js +31 -14
- package/dist/config/generated.js +26864 -402
- package/dist/config/registry.gen.js +33 -2
- package/dist/evm/chains.js +85 -16
- package/dist/evm/floor/abi.gen.js +1 -1
- package/dist/evm/floor/events.js +9 -1
- package/dist/evm/floor/legacy-events.js +25 -0
- package/dist/evm/router.js +25 -1
- package/dist/evm/squid.js +9 -9
- package/dist/evm/zap.js +148 -35
- package/dist/indexer/bodies.js +96 -17
- package/dist/indexer/client.js +36 -14
- package/dist/indexer/contract.js +178 -28
- package/dist/indexer/partners.js +3 -2
- package/dist/indexer/paths.js +87 -29
- package/dist/indexer/read.js +30 -15
- package/dist/indexer/search.js +130 -0
- package/dist/indexer/stack-edge.js +35 -0
- package/dist/indexer/stream.js +70 -23
- package/dist/math/v2/split.js +11 -3
- package/dist/solana/floor/events.js +1 -1
- package/dist/solana/floor/genesis.js +9 -3
- package/dist/solana/floor/instructions.js +14 -5
- package/dist/solana/floor/registry.js +4 -0
- package/dist/v2/devbuy.js +6 -4
- package/dist/v2/presetRowEvm.js +21 -2
- package/dist/v2/solana.js +17 -2
- package/dist/v2/tx/solana.js +1 -1
- package/docs/aggregator.md +22 -0
- package/docs/bot.md +44 -1
- package/docs/cursor-pages.md +58 -0
- package/docs/floor-line.md +9 -4
- package/docs/frontend.md +2 -0
- package/docs/wallet.md +2 -0
- package/examples/floor-line.html +6 -6
- package/package.json +1 -1
- package/src/abi/evm.gen.ts +6 -1
- package/src/abi/solana.gen.ts +1 -1
- package/src/client/evm/index.ts +16 -2
- package/src/client/solana/index.ts +31 -14
- package/src/client/types.ts +1 -1
- package/src/config/generated.ts +26864 -402
- package/src/config/index.ts +9 -2
- package/src/config/registry.gen.ts +33 -2
- package/src/events/types.gen.ts +2 -1
- package/src/evm/chains.ts +94 -15
- package/src/evm/floor/abi.gen.ts +1 -1
- package/src/evm/floor/events.ts +11 -1
- package/src/evm/floor/legacy-events.ts +27 -0
- package/src/evm/router.ts +26 -1
- package/src/evm/squid.ts +9 -9
- package/src/evm/zap.ts +185 -36
- package/src/indexer/bodies.ts +106 -17
- package/src/indexer/client.ts +56 -30
- package/src/indexer/contract.ts +197 -29
- package/src/indexer/partners.ts +3 -2
- package/src/indexer/paths.ts +131 -29
- package/src/indexer/read.ts +36 -17
- package/src/indexer/search.ts +138 -0
- package/src/indexer/stack-edge.ts +46 -0
- package/src/indexer/stream.ts +78 -24
- package/src/math/v2/split.ts +11 -3
- package/src/solana/floor/events.ts +1 -1
- package/src/solana/floor/genesis.ts +8 -2
- package/src/solana/floor/instructions.ts +13 -5
- package/src/solana/floor/registry.ts +4 -0
- package/src/v2/devbuy.ts +6 -4
- package/src/v2/presetRowEvm.ts +21 -2
- package/src/v2/solana.ts +20 -3
- package/src/v2/tx/solana.ts +1 -1
package/dist/indexer/bodies.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
import { array, big, bool, decimal, int, nullable, object, oneOf, optional, record, str } from "./decode.js";
|
|
3
|
+
import { ShapeError, array, big, bool, decimal, int, nullable, object, oneOf, optional, record, str } from "./decode.js";
|
|
4
4
|
|
|
5
5
|
export const INDEXED = object({ block: int, timestamp: int });
|
|
6
6
|
|
|
@@ -26,6 +26,7 @@ export const DEV_BUY = object({
|
|
|
26
26
|
block: int,
|
|
27
27
|
timestamp: int,
|
|
28
28
|
tx: str,
|
|
29
|
+
id: str,
|
|
29
30
|
});
|
|
30
31
|
|
|
31
32
|
export const BONDING = object({ tokens: big, sold: big, left: big, priceX64: big });
|
|
@@ -92,6 +93,12 @@ const LAUNCH_FIELDS = {
|
|
|
92
93
|
unlisted: bool,
|
|
93
94
|
quoteDecimals: nullable(int),
|
|
94
95
|
teamSlotRateBps: nullable(int),
|
|
96
|
+
|
|
97
|
+
nextBuyPriceX64: optional(nullable(big)),
|
|
98
|
+
stackEndX64: optional(nullable(big)),
|
|
99
|
+
stackLeft: optional(nullable(big)),
|
|
100
|
+
stackSold: optional(nullable(big)),
|
|
101
|
+
stackSoldBps: optional(nullable(int)),
|
|
95
102
|
bidTopX64: nullable(big),
|
|
96
103
|
teamBuyUnlockAt: nullable(int),
|
|
97
104
|
teamBuyUnlocked: bool,
|
|
@@ -111,18 +118,24 @@ const LAUNCH_FIELDS = {
|
|
|
111
118
|
};
|
|
112
119
|
export const LAUNCH = object(LAUNCH_FIELDS);
|
|
113
120
|
|
|
114
|
-
|
|
121
|
+
const LISTED_FIELDS = {
|
|
115
122
|
...LAUNCH_FIELDS,
|
|
116
123
|
volume24hGross: nullable(big),
|
|
117
124
|
holders: int,
|
|
125
|
+
|
|
126
|
+
maxLossPpm: optional(nullable(int)),
|
|
127
|
+
|
|
118
128
|
backedPpm: nullable(int),
|
|
119
129
|
volume24hUsd: nullable(decimal),
|
|
120
130
|
marketCapUsd: nullable(decimal),
|
|
121
131
|
|
|
122
132
|
trendingScore: nullable(big),
|
|
123
|
-
});
|
|
124
133
|
|
|
125
|
-
|
|
134
|
+
change24hBps: optional(nullable(int)),
|
|
135
|
+
};
|
|
136
|
+
export const LISTED_LAUNCH = object(LISTED_FIELDS);
|
|
137
|
+
|
|
138
|
+
export const LIVE_LAUNCH = object({ ...LAUNCH_FIELDS, volume24hGross: nullable(big), holders: int, change24hBps: optional(nullable(int)) });
|
|
126
139
|
|
|
127
140
|
const TRADE_FIELDS = {
|
|
128
141
|
launch: str,
|
|
@@ -206,6 +219,8 @@ export const FLOOR_ROUTED = object({
|
|
|
206
219
|
indexed,
|
|
207
220
|
launches: array(object({ launch: str, quote: str, floorFee: big, floorMilestone: big })),
|
|
208
221
|
pending: array(object({ quote: str, amount: big })),
|
|
222
|
+
|
|
223
|
+
next: optional(nullable(str)),
|
|
209
224
|
});
|
|
210
225
|
|
|
211
226
|
export const EVENTS = object({
|
|
@@ -227,9 +242,25 @@ export const EVENTS = object({
|
|
|
227
242
|
})),
|
|
228
243
|
});
|
|
229
244
|
|
|
230
|
-
|
|
245
|
+
const nextCursor = (v, p) => (v === undefined || v === null ? null : str(v, p));
|
|
246
|
+
|
|
247
|
+
const perRow = (d ) => (v, p) => (v === undefined ? [] : array(d)(v, p));
|
|
248
|
+
|
|
249
|
+
export const LAUNCHES = object({
|
|
250
|
+
indexed, total: int, offset: int, launches: array(LISTED_LAUNCH), missing: array(str),
|
|
251
|
+
cursors: perRow(str), keys: perRow(nullable(str)), next: optional(nullable(str)),
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
export const LAUNCH_LIST = object({ quote: str, total: int, launches: array(LISTED_LAUNCH), cursors: array(str), keys: array(nullable(str)), next: nullable(str) });
|
|
255
|
+
export const LAUNCH_LISTS = object({ indexed, lists: array(LAUNCH_LIST) });
|
|
256
|
+
|
|
257
|
+
const SEARCH_SERVED_TIER = (v, p) => {
|
|
258
|
+
const n = int(v, p);
|
|
259
|
+
if (n < 0 || n > 4) throw new ShapeError(p, "a tier 0..4", v);
|
|
260
|
+
return n ;
|
|
261
|
+
};
|
|
231
262
|
|
|
232
|
-
export const
|
|
263
|
+
export const LAUNCH_SEARCH = object({ indexed, q: str, launches: array(object({ ...LISTED_FIELDS, tier: SEARCH_SERVED_TIER })), next: nextCursor });
|
|
233
264
|
|
|
234
265
|
export const LAUNCH_ONE = object({ indexed, launch: LISTED_LAUNCH });
|
|
235
266
|
|
|
@@ -241,15 +272,15 @@ export const HOLDERS = object({ indexed, source: oneOf("positions", "trades"), t
|
|
|
241
272
|
|
|
242
273
|
export const TRADES = object({ indexed, trades: array(PAGED_TRADE), next: nullable(str) });
|
|
243
274
|
|
|
244
|
-
export const LAUNCH_CLAIM = object({ launch: str, claimer: str, types: int, quote: str, amount: big, holder: big, teamBuy: optional(big), block: int, ts: int, tx: str });
|
|
275
|
+
export const LAUNCH_CLAIM = object({ launch: str, claimer: str, types: int, quote: str, amount: big, holder: big, teamBuy: optional(big), block: int, ts: int, tx: str, id: optional(str) });
|
|
245
276
|
|
|
246
|
-
export const LAUNCH_CLAIMS = object({ indexed, claims: array(LAUNCH_CLAIM) });
|
|
277
|
+
export const LAUNCH_CLAIMS = object({ indexed, claims: array(LAUNCH_CLAIM), next: optional(nullable(str)) });
|
|
247
278
|
|
|
248
|
-
export const DEV_BUYS = object({ indexed, teamBuyUnlocked: bool, teamBuyUnlockedTs: nullable(int), devBuys: array(DEV_BUY) });
|
|
279
|
+
export const DEV_BUYS = object({ indexed, teamBuyUnlocked: bool, teamBuyUnlockedTs: nullable(int), devBuys: array(DEV_BUY), next: optional(nullable(str)) });
|
|
249
280
|
|
|
250
281
|
export const MEMBER_SOLD_ROW = object({ launch: str, member: str, place: int, amount: big, quoteOut: big, block: int, timestamp: int, tx: str, id: str });
|
|
251
282
|
|
|
252
|
-
export const MEMBER_SOLD = object({ indexed, memberSold: array(MEMBER_SOLD_ROW) });
|
|
283
|
+
export const MEMBER_SOLD = object({ indexed, memberSold: array(MEMBER_SOLD_ROW), next: optional(nullable(str)) });
|
|
253
284
|
|
|
254
285
|
export const LAUNCH_ACCOUNT = object({ indexed, launch: str, mint: str, slot: int, data: str });
|
|
255
286
|
|
|
@@ -282,6 +313,8 @@ export const CANDLE = object({
|
|
|
282
313
|
volumeSellQuoteRaw: big,
|
|
283
314
|
buys: int,
|
|
284
315
|
sells: int,
|
|
316
|
+
|
|
317
|
+
floorX64: optional(nullable(big)),
|
|
285
318
|
});
|
|
286
319
|
|
|
287
320
|
const USD_RATE = object({ centsX64: nullable(big), source: nullable(str), ageS: nullable(int) });
|
|
@@ -300,6 +333,8 @@ export const CANDLES = object({
|
|
|
300
333
|
candles: array(CANDLE),
|
|
301
334
|
});
|
|
302
335
|
|
|
336
|
+
export const CANDLES_MANY = object({ indexed, interval: str, series: array(CANDLES), missing: array(str) });
|
|
337
|
+
|
|
303
338
|
export const CANDLE_BUNDLE = object({
|
|
304
339
|
indexed,
|
|
305
340
|
launch: str,
|
|
@@ -328,7 +363,7 @@ export const QUOTE_CHAIN = object({ indexed, launch: str, chain: array(object({
|
|
|
328
363
|
|
|
329
364
|
export const DEV_TRADES = object({ indexed, launch: str, creator: str, trades: array(TRADE) });
|
|
330
365
|
|
|
331
|
-
export const BURNS = object({ indexed, launch: str, burns: array(object({ amount: big, block: int, timestamp: int })), program: array(
|
|
366
|
+
export const BURNS = object({ indexed, launch: str, burns: array(object({ id: optional(str), amount: big, block: int, timestamp: int })), program: array(object({ ...BURN_FIELDS, id: optional(str) })), wallet: array(object({ ...BURN_FIELDS, id: optional(str) })), next: optional(nullable(str)) });
|
|
332
367
|
|
|
333
368
|
const LOCK_HOLDER = object({ wallet: str, place: nullable(int) });
|
|
334
369
|
|
|
@@ -349,6 +384,9 @@ export const PRICE = object({
|
|
|
349
384
|
priceX64: big,
|
|
350
385
|
livePriceX64: big,
|
|
351
386
|
floorX64: big,
|
|
387
|
+
|
|
388
|
+
maxLossPpm: optional(nullable(int)),
|
|
389
|
+
|
|
352
390
|
backedPpm: int,
|
|
353
391
|
bidTopX64: nullable(big),
|
|
354
392
|
lastTrade: nullable(object({ priceAfterX64: big, timestamp: int, block: int })),
|
|
@@ -360,15 +398,43 @@ export const PRICE = object({
|
|
|
360
398
|
|
|
361
399
|
export const WALLET_TRADES = object({ indexed, wallet: str, trades: array(PAGED_TRADE), next: nullable(str) });
|
|
362
400
|
|
|
363
|
-
export const
|
|
401
|
+
export const TON_ACTIVITY_KINDS = ["buy", "sell", "claim", "team_slot_add", "team_share_buy", "burn", "withdraw", "create", "unlock_team_buy", "backing", "refused", "aborted"] ;
|
|
402
|
+
|
|
403
|
+
export const TON_FILL = object({ tokensIn: nullable(big), tokensOut: nullable(big), quoteIn: nullable(big), quoteOut: nullable(big), refund: nullable(big) });
|
|
404
|
+
|
|
405
|
+
export const TON_REASON = object({ code: oneOf("aborted", "refused"), op: nullable(int), class: nullable(int), refunded: nullable(big) });
|
|
406
|
+
|
|
407
|
+
export const TON_ACTIVITY_ROW = object({
|
|
408
|
+
id: str,
|
|
409
|
+
txnId: str,
|
|
410
|
+
block: int,
|
|
411
|
+
timestamp: int,
|
|
412
|
+
kind: oneOf(...TON_ACTIVITY_KINDS),
|
|
413
|
+
status: oneOf("landed", "failed"),
|
|
414
|
+
final: bool,
|
|
415
|
+
launch: nullable(str),
|
|
416
|
+
quote: nullable(str),
|
|
417
|
+
queryId: nullable(str),
|
|
418
|
+
types: nullable(int),
|
|
419
|
+
fill: TON_FILL,
|
|
420
|
+
reason: nullable(TON_REASON),
|
|
421
|
+
});
|
|
422
|
+
|
|
423
|
+
export const TON_ACTIVITY = object({ indexed, wallet: str, activity: array(TON_ACTIVITY_ROW), next: nullable(str) });
|
|
424
|
+
|
|
425
|
+
export const TON_OUTCOME = object({ indexed, wallet: str, queryId: str, outcome: oneOf("pending", "landed", "failed"), seen: bool, row: nullable(TON_ACTIVITY_ROW) });
|
|
426
|
+
|
|
427
|
+
export const POSITIONS = object({ indexed, wallet: str, positions: array(object({ launch: str, token: str, quote: str, tokens: big })), next: optional(nullable(str)) });
|
|
364
428
|
|
|
365
429
|
export const WALLET_LOCKS = object({
|
|
366
430
|
indexed,
|
|
367
431
|
wallet: str,
|
|
368
432
|
locks: array(object({ launch: str, token: str, kind: oneOf("teamBuy"), direction: oneOf("incoming", "outgoing"), tokens: big, place: nullable(int), createdAt: int, unlocked: bool, unlockedAt: nullable(int), unlockAt: nullable(int), locked: big, claimed: big, holders: array(LOCK_HOLDER) })),
|
|
433
|
+
|
|
434
|
+
next: optional(nullable(str)),
|
|
369
435
|
});
|
|
370
436
|
|
|
371
|
-
const AT = { timestamp: int, block: int };
|
|
437
|
+
const AT = { timestamp: int, block: int, id: optional(str) };
|
|
372
438
|
|
|
373
439
|
export const INBOX_CLAIMED = object({ ...AT, kind: oneOf("claimed"), launch: str, quote: str, types: int, amount: big, holder: big, txnId: nullable(str) });
|
|
374
440
|
|
|
@@ -376,7 +442,7 @@ export const INBOX_GRADUATED = object({ ...AT, kind: oneOf("graduated"), launch:
|
|
|
376
442
|
|
|
377
443
|
export const INBOX_SLOT = object({ ...AT, kind: oneOf("slot"), launch: str, place: int });
|
|
378
444
|
|
|
379
|
-
export const INBOX_DEV_BURN = object({ ...BURN_FIELDS, kind: oneOf("devBurn"), launch: str });
|
|
445
|
+
export const INBOX_DEV_BURN = object({ ...BURN_FIELDS, id: optional(str), kind: oneOf("devBurn"), launch: str });
|
|
380
446
|
|
|
381
447
|
export const INBOX_DEV_BUY = object({ ...AT, kind: oneOf("devBuy"), launch: str, wallet: str, role: DEV_BUY_ROLE, count: int, quoteIn: big, tokens: big, txnId: nullable(str) });
|
|
382
448
|
|
|
@@ -394,14 +460,14 @@ export function inboxItem(v , p ) {
|
|
|
394
460
|
return d(v, p) ;
|
|
395
461
|
}
|
|
396
462
|
|
|
397
|
-
export const INBOX = object({ indexed, wallet: str, items: (v , p ) => array(inboxItem)(v, p).filter((x) => x !== null) });
|
|
463
|
+
export const INBOX = object({ indexed, wallet: str, items: (v , p ) => array(inboxItem)(v, p).filter((x) => x !== null), next: optional(nullable(str)) });
|
|
398
464
|
|
|
399
465
|
export const CLAIM_ROW = object({
|
|
400
466
|
block: int,
|
|
401
467
|
timestamp: int,
|
|
402
468
|
txnId: nullable(str),
|
|
403
469
|
sender: str,
|
|
404
|
-
launch: str,
|
|
470
|
+
launch: nullable(str),
|
|
405
471
|
quote: str,
|
|
406
472
|
types: int,
|
|
407
473
|
creator: big,
|
|
@@ -414,7 +480,7 @@ export const CLAIM_ROW = object({
|
|
|
414
480
|
teamBuy: big,
|
|
415
481
|
});
|
|
416
482
|
|
|
417
|
-
export const CLAIM_HISTORY = object({ indexed, wallet: str, claims: array(CLAIM_ROW) });
|
|
483
|
+
export const CLAIM_HISTORY = object({ indexed, wallet: str, claims: array(CLAIM_ROW), next: optional(nullable(str)) });
|
|
418
484
|
|
|
419
485
|
const QUOTE_TOTAL = object({ quote: str, total: big, types: int });
|
|
420
486
|
|
|
@@ -436,6 +502,8 @@ export const CLAIM_VIEW = object({
|
|
|
436
502
|
refOwed: optional(array(object({ account: str, quoteMint: str, owed: big }))),
|
|
437
503
|
pendingRollUp: optional(array(object({ traderRef: str, quoteMint: str, amount: big }))),
|
|
438
504
|
owed: optional(array(object({ quote: str, creator: big, creatorRef: big, teamSlot: big, traderRef: big, holder: big, teamBuy: big }))),
|
|
505
|
+
|
|
506
|
+
next: optional(nullable(str)),
|
|
439
507
|
}),
|
|
440
508
|
});
|
|
441
509
|
|
|
@@ -450,6 +518,8 @@ export const PEOPLE = object({
|
|
|
450
518
|
indexed,
|
|
451
519
|
wallet: str,
|
|
452
520
|
people: array(object({ wallet: str, chain: str, roles: array(object({ kind: oneOf("trader", "creator"), tier: int })), earned: PER_QUOTE, teamMilestone: PER_QUOTE })),
|
|
521
|
+
|
|
522
|
+
next: optional(nullable(str)),
|
|
453
523
|
});
|
|
454
524
|
|
|
455
525
|
export const ROLES = object({
|
|
@@ -468,12 +538,16 @@ export const ROLES = object({
|
|
|
468
538
|
holdings: array(object({ launch: str, token: str, amount: big })),
|
|
469
539
|
}),
|
|
470
540
|
claimed: record(big),
|
|
541
|
+
|
|
542
|
+
next: optional(nullable(str)),
|
|
471
543
|
});
|
|
472
544
|
|
|
473
545
|
export const HANDLE_PLACES = object({
|
|
474
546
|
indexed,
|
|
475
547
|
handle: str,
|
|
476
548
|
places: array(object({ launch: str, place: int })),
|
|
549
|
+
|
|
550
|
+
next: optional(nullable(str)),
|
|
477
551
|
});
|
|
478
552
|
|
|
479
553
|
export const TRADER_BOARD = object({
|
|
@@ -487,3 +561,8 @@ export const LAUNCHER_BOARD = object({
|
|
|
487
561
|
launchers: array(object({ creator: str, launches: int, graduated: int, volumeUsd: decimal, liquidityUsd: decimal, bestLaunch: nullable(str), byQuote: record(object({ volume: big, liquidity: big, launches: int })) })),
|
|
488
562
|
});
|
|
489
563
|
|
|
564
|
+
export function maxLossPct(b ) {
|
|
565
|
+
if (b.maxLossPpm != null) return b.maxLossPpm / 10_000;
|
|
566
|
+
if (b.maxLossPpm === undefined && b.graduated === true && b.backedPpm != null) return Math.max(0, 1_000_000 - b.backedPpm) / 10_000;
|
|
567
|
+
return null;
|
|
568
|
+
}
|
package/dist/indexer/client.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
3
|
import { decode } from "./decode.js";
|
|
4
|
-
import { INDEXER_CONTRACT, clampLimit, routeLimit } from "./contract.js";
|
|
4
|
+
import { INDEXER_CONTRACT, clampLimit, pageAsked, routeLimit } from "./contract.js";
|
|
5
5
|
|
|
6
6
|
import { indexerPath, query } from "./paths.js";
|
|
7
7
|
|
|
@@ -18,39 +18,44 @@ export const routePath = {
|
|
|
18
18
|
stream: (a) => indexerPath.stream(a),
|
|
19
19
|
quotes: () => indexerPath.quotes(),
|
|
20
20
|
summary: () => indexerPath.summary(),
|
|
21
|
-
floorRouted: () => indexerPath.floorRouted(),
|
|
21
|
+
floorRouted: (a) => indexerPath.floorRouted(a ?? {}),
|
|
22
22
|
events: (a) => indexerPath.events(a.fromBlock, a.toBlock),
|
|
23
23
|
launches: (a) => indexerPath.launches(a ?? {}),
|
|
24
|
+
launchLists: (a) => indexerPath.launchLists(a),
|
|
25
|
+
search: (a) => indexerPath.search(a),
|
|
24
26
|
launch: (a) => indexerPath.launch(a.launch),
|
|
25
27
|
launchState: (a) => indexerPath.launchState(a.launch),
|
|
26
28
|
milestones: (a) => indexerPath.milestones(a.launch),
|
|
27
29
|
holders: ({ launch, ...q }) => indexerPath.holders(launch, q),
|
|
28
30
|
trades: ({ launch, ...q }) => indexerPath.trades(launch, q),
|
|
29
31
|
launchClaims: ({ launch, ...q }) => indexerPath.launchClaims(launch, q),
|
|
30
|
-
devBuys: (
|
|
31
|
-
memberSold: (
|
|
32
|
+
devBuys: ({ launch, ...q }) => indexerPath.devBuys(launch, q),
|
|
33
|
+
memberSold: ({ launch, ...q }) => indexerPath.memberSold(launch, q),
|
|
32
34
|
launchAccount: (a) => indexerPath.launchAccount(a.launch),
|
|
33
35
|
traders: ({ launch, ...q }) => indexerPath.traders(launch, q),
|
|
34
36
|
quoteChain: (a) => indexerPath.quoteChain(a.launch),
|
|
35
37
|
devTrades: ({ launch, ...q }) => indexerPath.devTrades(launch, q),
|
|
36
|
-
burns: (
|
|
38
|
+
burns: ({ launch, ...q }) => indexerPath.burns(launch, q),
|
|
37
39
|
launchLocks: (a) => indexerPath.launchLocks(a.launch),
|
|
38
40
|
marks: ({ launch, ...q }) => indexerPath.marks(launch, q),
|
|
39
41
|
price: (a) => indexerPath.price(a.launch),
|
|
40
42
|
highs: ({ launch, ...q }) => indexerPath.highs(launch, q),
|
|
41
43
|
candles: (a) => indexerPath.candles(a),
|
|
44
|
+
candlesMany: (a) => indexerPath.candlesMany(a),
|
|
42
45
|
candleBundle: ({ launch, ...q }) => indexerPath.candleBundle(launch, q),
|
|
43
46
|
walletTrades: ({ wallet, ...q }) => indexerPath.walletTrades(wallet, q),
|
|
44
|
-
|
|
47
|
+
tonActivity: ({ wallet, ...q }) => indexerPath.tonActivity(wallet, q),
|
|
48
|
+
tonOutcome: (a) => indexerPath.tonOutcome(a.wallet, a.queryId),
|
|
49
|
+
positions: ({ wallet, ...q }) => indexerPath.positions(wallet, q),
|
|
45
50
|
inbox: ({ wallet, ...q }) => indexerPath.inbox(wallet, q),
|
|
46
|
-
walletLocks: (
|
|
47
|
-
claimHistory: (
|
|
51
|
+
walletLocks: ({ wallet, ...q }) => indexerPath.walletLocks(wallet, q),
|
|
52
|
+
claimHistory: ({ wallet, ...q }) => indexerPath.claimHistory(wallet, q),
|
|
48
53
|
firsts: (a) => indexerPath.firsts(a.wallet),
|
|
49
54
|
firstsMany: (a) => indexerPath.firstsMany(a.wallets),
|
|
50
|
-
claimView: (
|
|
51
|
-
people: (
|
|
52
|
-
roles: (
|
|
53
|
-
handlePlaces: (
|
|
55
|
+
claimView: ({ wallet, ...q }) => indexerPath.claimView(wallet, q),
|
|
56
|
+
people: ({ wallet, ...q }) => indexerPath.people(wallet, q),
|
|
57
|
+
roles: ({ wallet, ...q }) => indexerPath.roles(wallet, q),
|
|
58
|
+
handlePlaces: ({ handle, ...q }) => indexerPath.handlePlaces(handle, q),
|
|
54
59
|
traderBoard: (a) => indexerPath.traderBoard(a ?? {}),
|
|
55
60
|
launcherBoard: (a) => indexerPath.launcherBoard(a ?? {}),
|
|
56
61
|
tokenHolders: (a) => `/floor-amm/holders/${encodeURIComponent(need(a.token, "token"))}${query({ limit: a.limit, offset: a.offset })}`,
|
|
@@ -59,7 +64,7 @@ export const routePath = {
|
|
|
59
64
|
dexPair: (a) => `/v2/dex/pair${query({ id: need(a.id, "id") })}`,
|
|
60
65
|
cgPairs: () => "/v2/coingecko/pairs",
|
|
61
66
|
cgTickers: () => "/v2/coingecko/tickers",
|
|
62
|
-
cgHistoricalTrades: (a) => `/v2/coingecko/historical_trades${query({ ticker_id: need(a.ticker_id, "ticker_id"), type: a.type, limit: a.limit, start_time: a.start_time, end_time: a.end_time })}`,
|
|
67
|
+
cgHistoricalTrades: (a) => `/v2/coingecko/historical_trades${query({ ticker_id: need(a.ticker_id, "ticker_id"), type: a.type, limit: a.limit, before: a.before, start_time: a.start_time, end_time: a.end_time })}`,
|
|
63
68
|
llamaTvl: () => "/v2/defillama/tvl",
|
|
64
69
|
llamaFees: (a) => {
|
|
65
70
|
if (a && a.to < a.from) throw new RangeError("from > to");
|
|
@@ -68,11 +73,13 @@ export const routePath = {
|
|
|
68
73
|
health: () => "/health",
|
|
69
74
|
};
|
|
70
75
|
|
|
76
|
+
export const DRAIN_NAMES = ["trades", "launchClaims", "memberSold", "burns", "walletTrades", "launches", "search", "marks", "inbox", "positions", "walletLocks", "claimHistory", "people", "roles", "tokenHolders", "tonActivity", "cgHistoricalTrades", "floorRouted", "devBuys", "claimView", "handlePlaces"] ;
|
|
77
|
+
|
|
71
78
|
export function createIndexerClient(opts ) {
|
|
72
79
|
|
|
73
80
|
const clamp = (name , a ) => {
|
|
74
81
|
if (typeof a !== "object" || a === null || !("limit" in a) || typeof (a ).limit !== "number") return a;
|
|
75
|
-
return { ...a, limit: clampLimit(name, (a ).limit) };
|
|
82
|
+
return { ...a, limit: clampLimit(name, (a ).limit, pageAsked(name, a )) };
|
|
76
83
|
};
|
|
77
84
|
const path = (name , a ) => (routePath[name] )(clamp(name, a));
|
|
78
85
|
const read = async (name , a ) => {
|
|
@@ -88,12 +95,27 @@ export function createIndexerClient(opts ) {
|
|
|
88
95
|
const max = o.maxPages ?? 100;
|
|
89
96
|
const lim = routeLimit(name) ;
|
|
90
97
|
let args = { ...a };
|
|
98
|
+
|
|
99
|
+
if (page.kind === "cursor" && page.optIn !== undefined && args.before === undefined) args = { ...args, before: "" };
|
|
100
|
+
if (page.kind === "keyset" && page.optIn === true && args.limit === undefined && args.cursor === undefined) args = { ...args, limit: lim.default };
|
|
91
101
|
for (let i = 0; i < max; i++) {
|
|
92
102
|
const body = (await read(name, args)) ;
|
|
93
103
|
yield body;
|
|
94
104
|
if (page.kind === "cursor") {
|
|
95
105
|
if (body.next === null || body.next === undefined) return;
|
|
96
106
|
args = { ...args, before: body.next };
|
|
107
|
+
} else if (page.kind === "keyset") {
|
|
108
|
+
|
|
109
|
+
if (args.ids !== undefined) return;
|
|
110
|
+
if (args.offset !== undefined) {
|
|
111
|
+
const step = clampLimit(name, (args.limit ) ?? lim.default);
|
|
112
|
+
const offset = (args.offset ) + step;
|
|
113
|
+
if (offset >= (body.total ?? 0)) return;
|
|
114
|
+
args = { ...args, offset };
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
if (body.next === null || body.next === undefined) return;
|
|
118
|
+
args = { ...args, cursor: body.next };
|
|
97
119
|
} else if (page.kind === "offset") {
|
|
98
120
|
const step = clampLimit(name, (args.limit ) ?? lim.default);
|
|
99
121
|
const offset = ((args.offset ) ?? 0) + step;
|