@floorlaunchpad/sdk 0.3.2 → 0.4.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.
Files changed (62) hide show
  1. package/CHANGELOG.md +66 -0
  2. package/README.md +14 -0
  3. package/dist/abi/evm.gen.js +1 -1
  4. package/dist/abi/solana.gen.js +1 -1
  5. package/dist/client/evm/index.js +16 -2
  6. package/dist/client/solana/index.js +19 -7
  7. package/dist/config/generated.js +26864 -402
  8. package/dist/config/registry.gen.js +33 -2
  9. package/dist/evm/chains.js +9 -1
  10. package/dist/evm/floor/abi.gen.js +1 -1
  11. package/dist/evm/floor/events.js +9 -1
  12. package/dist/evm/floor/legacy-events.js +25 -0
  13. package/dist/indexer/bodies.js +91 -17
  14. package/dist/indexer/client.js +34 -14
  15. package/dist/indexer/contract.js +132 -28
  16. package/dist/indexer/partners.js +3 -2
  17. package/dist/indexer/paths.js +61 -29
  18. package/dist/indexer/read.js +27 -15
  19. package/dist/indexer/search.js +130 -0
  20. package/dist/indexer/stack-edge.js +35 -0
  21. package/dist/indexer/stream.js +70 -23
  22. package/dist/math/v2/split.js +11 -3
  23. package/dist/solana/floor/events.js +1 -1
  24. package/dist/solana/floor/genesis.js +9 -3
  25. package/dist/solana/floor/instructions.js +14 -5
  26. package/dist/solana/floor/registry.js +4 -0
  27. package/dist/v2/solana.js +17 -2
  28. package/dist/v2/tx/solana.js +1 -1
  29. package/docs/bot.md +36 -1
  30. package/docs/cursor-pages.md +56 -0
  31. package/docs/floor-line.md +9 -4
  32. package/examples/floor-line.html +6 -6
  33. package/package.json +1 -1
  34. package/src/abi/evm.gen.ts +1 -1
  35. package/src/abi/solana.gen.ts +1 -1
  36. package/src/client/evm/index.ts +16 -2
  37. package/src/client/solana/index.ts +19 -7
  38. package/src/client/types.ts +1 -1
  39. package/src/config/generated.ts +26864 -402
  40. package/src/config/index.ts +9 -2
  41. package/src/config/registry.gen.ts +33 -2
  42. package/src/events/types.gen.ts +2 -1
  43. package/src/evm/chains.ts +9 -1
  44. package/src/evm/floor/abi.gen.ts +1 -1
  45. package/src/evm/floor/events.ts +11 -1
  46. package/src/evm/floor/legacy-events.ts +27 -0
  47. package/src/indexer/bodies.ts +99 -17
  48. package/src/indexer/client.ts +52 -30
  49. package/src/indexer/contract.ts +151 -29
  50. package/src/indexer/partners.ts +3 -2
  51. package/src/indexer/paths.ts +84 -29
  52. package/src/indexer/read.ts +33 -17
  53. package/src/indexer/search.ts +138 -0
  54. package/src/indexer/stack-edge.ts +46 -0
  55. package/src/indexer/stream.ts +78 -24
  56. package/src/math/v2/split.ts +11 -3
  57. package/src/solana/floor/events.ts +1 -1
  58. package/src/solana/floor/genesis.ts +8 -2
  59. package/src/solana/floor/instructions.ts +13 -5
  60. package/src/solana/floor/registry.ts +4 -0
  61. package/src/v2/solana.ts +20 -3
  62. package/src/v2/tx/solana.ts +1 -1
@@ -110,9 +110,40 @@ export const CHAIN_REGISTRY = [
110
110
  },
111
111
  "finality": "finalized",
112
112
  "reorgWindow": 65
113
+ },
114
+ {
115
+ "slug": "elysium",
116
+ "label": "Elysium",
117
+ "family": "evm",
118
+ "v2DayOne": false,
119
+ "chainId": 99901,
120
+ "soakChainId": 99801,
121
+ "native": {
122
+ "name": "Hype",
123
+ "symbol": "HYPE"
124
+ },
125
+ "finality": "safe",
126
+ "reorgWindow": 3400
127
+ },
128
+ {
129
+ "slug": "ton",
130
+ "label": "TON",
131
+ "family": "ton",
132
+ "v2DayOne": false,
133
+ "network": "mainnet",
134
+ "globalId": -239,
135
+ "soakNetwork": "testnet",
136
+ "soakGlobalId": -3,
137
+ "native": {
138
+ "name": "Gram",
139
+ "symbol": "GRAM",
140
+ "decimals": 9
141
+ }
113
142
  }
114
143
  ] ;
115
144
 
116
- export const CHAIN_SLUGS = ["solana","ethereum","base","bsc","arbitrum","arc","robinhood","hyperevm"] ;
145
+ export const CHAIN_SLUGS = ["solana","ethereum","base","bsc","arbitrum","arc","robinhood","hyperevm","elysium","ton"] ;
146
+
147
+ export const EVM_CHAIN_SLUGS = ["ethereum","base","bsc","arbitrum","arc","robinhood","hyperevm","elysium"] ;
117
148
 
118
- export const EVM_CHAIN_SLUGS = ["ethereum","base","bsc","arbitrum","arc","robinhood","hyperevm"] ;
149
+ export const TON_CHAIN_SLUGS = ["ton"] ;
@@ -86,6 +86,14 @@ const ROUTES
86
86
  "⚠ No WETH9: WRAP_ETH does not apply; only v4 pools in address(0) take the native coin. The zap is for third-token quotes only.",
87
87
  ],
88
88
  },
89
+ elysium: {
90
+ wrappedNative: null,
91
+ zapRouters: [],
92
+ notes: [
93
+ "⚠ Arbitrum Orbit on HyperEVM: in a contract block.number is HyperEVM's block; the receipt's block is Elysium's.",
94
+ "⚠ No zap routers yet (no DEX read back on chain) and no wrapped HYPE address published: the native coin and listed quotes only.",
95
+ ],
96
+ },
89
97
  };
90
98
 
91
99
  export const EVM_CHAINS = Object.fromEntries(
@@ -110,7 +118,7 @@ export const FLOOR_SALTS = {
110
118
  export const FLOOR_AMM_ADDRESS = "0xF10000bd05c2C01793C6d55F027346469683d225";
111
119
 
112
120
  export const FLOOR_AMM_FROM_BLOCK = {
113
- ethereum: 26327910, base: 53421827, bsc: 131270813, arbitrum: 520655168, arc: 29205598, robinhood: 104455459, hyperevm: 50398055,
121
+ ethereum: 26327910, base: 53421827, bsc: 131270813, arbitrum: 520655168, arc: 29205598, robinhood: 104455459, hyperevm: 50398055, elysium: 6058368,
114
122
  };
115
123
 
116
124
  const cat = (...h ) => "0x" + h.map((x) => bytesToHex(hexToBytes(x)).slice(2)).join("");
@@ -51,7 +51,7 @@ export const FLOOR_AMM_ABI = [
51
51
  {"type":"error","name":"UnknownClaimType","inputs":[]},
52
52
  {"type":"error","name":"UnknownLaunch","inputs":[]},
53
53
  {"type":"event","name":"ClaimSkipped","inputs":[{"name":"wallet","type":"address","indexed":true},{"name":"quote","type":"address","indexed":true},{"name":"amount","type":"uint256","indexed":false}],"anonymous":false},
54
- {"type":"event","name":"Claimed","inputs":[{"name":"wallet","type":"address","indexed":true},{"name":"sender","type":"address","indexed":true},{"name":"quote","type":"address","indexed":true},{"name":"types","type":"uint8","indexed":false},{"name":"creator","type":"uint256","indexed":false},{"name":"creatorRef","type":"uint256","indexed":false},{"name":"teamSlot","type":"uint256","indexed":false},{"name":"traderRef","type":"uint256","indexed":false},{"name":"holder","type":"uint256","indexed":false},{"name":"extra","type":"uint256","indexed":false},{"name":"amount","type":"uint256","indexed":false}],"anonymous":false},
54
+ {"type":"event","name":"Claimed","inputs":[{"name":"wallet","type":"address","indexed":true},{"name":"sender","type":"address","indexed":true},{"name":"quote","type":"address","indexed":true},{"name":"types","type":"uint16","indexed":false},{"name":"creator","type":"uint256","indexed":false},{"name":"creatorRef","type":"uint256","indexed":false},{"name":"teamSlot","type":"uint256","indexed":false},{"name":"traderRef","type":"uint256","indexed":false},{"name":"holder","type":"uint256","indexed":false},{"name":"extra","type":"uint256","indexed":false},{"name":"amount","type":"uint256","indexed":false}],"anonymous":false},
55
55
  {"type":"event","name":"ConfigWritten","inputs":[{"name":"authority","type":"address","indexed":false},{"name":"pendingAuthority","type":"address","indexed":false},{"name":"timelock","type":"address","indexed":false},{"name":"referralAuthority","type":"address","indexed":false},{"name":"createPaused","type":"bool","indexed":false},{"name":"holderDest","type":"address","indexed":false}],"anonymous":false},
56
56
  {"type":"event","name":"CreatorBuyUnlocked","inputs":[{"name":"launchId","type":"uint256","indexed":true},{"name":"creator","type":"address","indexed":true},{"name":"tokens","type":"uint256","indexed":false},{"name":"members","type":"uint256[10]","indexed":false},{"name":"paid","type":"uint256","indexed":false}],"anonymous":false},
57
57
  {"type":"event","name":"Graduated","inputs":[{"name":"launchId","type":"uint256","indexed":true},{"name":"windowPriceX64","type":"uint256","indexed":false},{"name":"priceX64","type":"uint256","indexed":false},{"name":"windowRaised","type":"uint256","indexed":false},{"name":"windowTokens","type":"uint256","indexed":false}],"anonymous":false},
@@ -3,6 +3,7 @@
3
3
  import { checksumAddress } from "../abi.js";
4
4
  import { decodeEventLog, itemTopic } from "../items.js";
5
5
 
6
+ import { LEGACY_CLAIMED_TOPIC, LEGACY_EVENTS, normalizeLegacyClaimed } from "./legacy-events.js";
6
7
  import { FLOOR_AMM_ABI, FLOOR_AMM_UNFROZEN_EVENTS, FLOOR_ZAP_ABI } from "./iface.js";
7
8
 
8
9
   
@@ -28,10 +29,17 @@ for (const i of ALL.filter((i) => i.type === "event").reverse()) {
28
29
  });
29
30
  }
30
31
 
32
+ export const FLOOR_LEGACY_EVENT_TOPICS = { Claimed: LEGACY_CLAIMED_TOPIC };
33
+
31
34
  export function decodeFloorLog(log , from ) {
32
35
  if (from && (!log.address || !from.some((a) => a.toLowerCase() === log.address .toLowerCase()))) return null;
33
36
  const d = decodeEventLog(ALL, log);
34
- if (!d) return null;
37
+ if (!d) {
38
+ const old = decodeEventLog(LEGACY_EVENTS, log);
39
+ if (!old) return null;
40
+ const e = { ...old, args: normalizeLegacyClaimed(old.args), legacy: true };
41
+ return log.address ? { ...e, address: checksumAddress(log.address) } : e;
42
+ }
35
43
  if (UNFROZEN().has((log.topics[0] ?? "").toLowerCase())) d.unfrozen = true;
36
44
  return log.address ? { ...d, address: checksumAddress(log.address) } : d;
37
45
  }
@@ -0,0 +1,25 @@
1
+
2
+
3
+ export const LEGACY_CLAIMED_SIGNATURE =
4
+ "Claimed(address,address,address,uint8,uint256,uint256,uint256,uint256,uint256,uint256,uint256)";
5
+ export const LEGACY_CLAIMED_TOPIC = "0x586c69c7198e9e5c48c058d0267bd1388a73f9a8878aeb9d72d25331acc39aeb";
6
+
7
+ export const LEGACY_EVENTS = [
8
+ {
9
+ type: "event", name: "Claimed", anonymous: false, inputs: [
10
+ { name: "wallet", type: "address", indexed: true }, { name: "sender", type: "address", indexed: true },
11
+ { name: "quote", type: "address", indexed: true }, { name: "types", type: "uint8", indexed: false },
12
+ { name: "creator", type: "uint256", indexed: false }, { name: "creatorRef", type: "uint256", indexed: false },
13
+ { name: "teamSlot", type: "uint256", indexed: false }, { name: "traderRef", type: "uint256", indexed: false },
14
+ { name: "holder", type: "uint256", indexed: false }, { name: "extra", type: "uint256", indexed: false },
15
+ { name: "amount", type: "uint256", indexed: false },
16
+ ],
17
+ },
18
+ ];
19
+
20
+ export const CLAIM_HOLDER_BIT = 512n;
21
+
22
+ export function normalizeLegacyClaimed(args ) {
23
+ const types = BigInt(args.types);
24
+ return { ...args, types: BigInt(args.holder) > 0n ? types | CLAIM_HOLDER_BIT : types };
25
+ }
@@ -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
- export const LISTED_LAUNCH = object({
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
- export const LIVE_LAUNCH = object({ ...LAUNCH_FIELDS, volume24hGross: nullable(big), holders: int });
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,22 @@ export const EVENTS = object({
227
242
  })),
228
243
  });
229
244
 
230
- export const LAUNCHES_ALL = object({ indexed, launches: array(LISTED_LAUNCH) });
245
+ const nextCursor = (v, p) => (v === undefined || v === null ? null : str(v, p));
231
246
 
232
- export const LAUNCHES = object({ indexed, total: int, offset: int, launches: array(LISTED_LAUNCH), missing: array(str) });
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
+ const SEARCH_SERVED_TIER = (v, p) => {
255
+ const n = int(v, p);
256
+ if (n < 0 || n > 4) throw new ShapeError(p, "a tier 0..4", v);
257
+ return n ;
258
+ };
259
+
260
+ export const LAUNCH_SEARCH = object({ indexed, q: str, launches: array(object({ ...LISTED_FIELDS, tier: SEARCH_SERVED_TIER })), next: nextCursor });
233
261
 
234
262
  export const LAUNCH_ONE = object({ indexed, launch: LISTED_LAUNCH });
235
263
 
@@ -241,15 +269,15 @@ export const HOLDERS = object({ indexed, source: oneOf("positions", "trades"), t
241
269
 
242
270
  export const TRADES = object({ indexed, trades: array(PAGED_TRADE), next: nullable(str) });
243
271
 
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 });
272
+ 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
273
 
246
- export const LAUNCH_CLAIMS = object({ indexed, claims: array(LAUNCH_CLAIM) });
274
+ export const LAUNCH_CLAIMS = object({ indexed, claims: array(LAUNCH_CLAIM), next: optional(nullable(str)) });
247
275
 
248
- export const DEV_BUYS = object({ indexed, teamBuyUnlocked: bool, teamBuyUnlockedTs: nullable(int), devBuys: array(DEV_BUY) });
276
+ export const DEV_BUYS = object({ indexed, teamBuyUnlocked: bool, teamBuyUnlockedTs: nullable(int), devBuys: array(DEV_BUY), next: optional(nullable(str)) });
249
277
 
250
278
  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
279
 
252
- export const MEMBER_SOLD = object({ indexed, memberSold: array(MEMBER_SOLD_ROW) });
280
+ export const MEMBER_SOLD = object({ indexed, memberSold: array(MEMBER_SOLD_ROW), next: optional(nullable(str)) });
253
281
 
254
282
  export const LAUNCH_ACCOUNT = object({ indexed, launch: str, mint: str, slot: int, data: str });
255
283
 
@@ -282,6 +310,8 @@ export const CANDLE = object({
282
310
  volumeSellQuoteRaw: big,
283
311
  buys: int,
284
312
  sells: int,
313
+
314
+ floorX64: optional(nullable(big)),
285
315
  });
286
316
 
287
317
  const USD_RATE = object({ centsX64: nullable(big), source: nullable(str), ageS: nullable(int) });
@@ -328,7 +358,7 @@ export const QUOTE_CHAIN = object({ indexed, launch: str, chain: array(object({
328
358
 
329
359
  export const DEV_TRADES = object({ indexed, launch: str, creator: str, trades: array(TRADE) });
330
360
 
331
- export const BURNS = object({ indexed, launch: str, burns: array(object({ amount: big, block: int, timestamp: int })), program: array(BURN), wallet: array(BURN) });
361
+ 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
362
 
333
363
  const LOCK_HOLDER = object({ wallet: str, place: nullable(int) });
334
364
 
@@ -349,6 +379,9 @@ export const PRICE = object({
349
379
  priceX64: big,
350
380
  livePriceX64: big,
351
381
  floorX64: big,
382
+
383
+ maxLossPpm: optional(nullable(int)),
384
+
352
385
  backedPpm: int,
353
386
  bidTopX64: nullable(big),
354
387
  lastTrade: nullable(object({ priceAfterX64: big, timestamp: int, block: int })),
@@ -360,15 +393,43 @@ export const PRICE = object({
360
393
 
361
394
  export const WALLET_TRADES = object({ indexed, wallet: str, trades: array(PAGED_TRADE), next: nullable(str) });
362
395
 
363
- export const POSITIONS = object({ indexed, wallet: str, positions: array(object({ launch: str, token: str, quote: str, tokens: big })) });
396
+ export const TON_ACTIVITY_KINDS = ["buy", "sell", "claim", "team_slot_add", "team_share_buy", "burn", "withdraw", "create", "unlock_team_buy", "backing", "refused", "aborted"] ;
397
+
398
+ export const TON_FILL = object({ tokensIn: nullable(big), tokensOut: nullable(big), quoteIn: nullable(big), quoteOut: nullable(big), refund: nullable(big) });
399
+
400
+ export const TON_REASON = object({ code: oneOf("aborted", "refused"), op: nullable(int), class: nullable(int), refunded: nullable(big) });
401
+
402
+ export const TON_ACTIVITY_ROW = object({
403
+ id: str,
404
+ txnId: str,
405
+ block: int,
406
+ timestamp: int,
407
+ kind: oneOf(...TON_ACTIVITY_KINDS),
408
+ status: oneOf("landed", "failed"),
409
+ final: bool,
410
+ launch: nullable(str),
411
+ quote: nullable(str),
412
+ queryId: nullable(str),
413
+ types: nullable(int),
414
+ fill: TON_FILL,
415
+ reason: nullable(TON_REASON),
416
+ });
417
+
418
+ export const TON_ACTIVITY = object({ indexed, wallet: str, activity: array(TON_ACTIVITY_ROW), next: nullable(str) });
419
+
420
+ export const TON_OUTCOME = object({ indexed, wallet: str, queryId: str, outcome: oneOf("pending", "landed", "failed"), seen: bool, row: nullable(TON_ACTIVITY_ROW) });
421
+
422
+ export const POSITIONS = object({ indexed, wallet: str, positions: array(object({ launch: str, token: str, quote: str, tokens: big })), next: optional(nullable(str)) });
364
423
 
365
424
  export const WALLET_LOCKS = object({
366
425
  indexed,
367
426
  wallet: str,
368
427
  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) })),
428
+
429
+ next: optional(nullable(str)),
369
430
  });
370
431
 
371
- const AT = { timestamp: int, block: int };
432
+ const AT = { timestamp: int, block: int, id: optional(str) };
372
433
 
373
434
  export const INBOX_CLAIMED = object({ ...AT, kind: oneOf("claimed"), launch: str, quote: str, types: int, amount: big, holder: big, txnId: nullable(str) });
374
435
 
@@ -376,7 +437,7 @@ export const INBOX_GRADUATED = object({ ...AT, kind: oneOf("graduated"), launch:
376
437
 
377
438
  export const INBOX_SLOT = object({ ...AT, kind: oneOf("slot"), launch: str, place: int });
378
439
 
379
- export const INBOX_DEV_BURN = object({ ...BURN_FIELDS, kind: oneOf("devBurn"), launch: str });
440
+ export const INBOX_DEV_BURN = object({ ...BURN_FIELDS, id: optional(str), kind: oneOf("devBurn"), launch: str });
380
441
 
381
442
  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
443
 
@@ -394,14 +455,14 @@ export function inboxItem(v , p ) {
394
455
  return d(v, p) ;
395
456
  }
396
457
 
397
- export const INBOX = object({ indexed, wallet: str, items: (v , p ) => array(inboxItem)(v, p).filter((x) => x !== null) });
458
+ export const INBOX = object({ indexed, wallet: str, items: (v , p ) => array(inboxItem)(v, p).filter((x) => x !== null), next: optional(nullable(str)) });
398
459
 
399
460
  export const CLAIM_ROW = object({
400
461
  block: int,
401
462
  timestamp: int,
402
463
  txnId: nullable(str),
403
464
  sender: str,
404
- launch: str,
465
+ launch: nullable(str),
405
466
  quote: str,
406
467
  types: int,
407
468
  creator: big,
@@ -414,7 +475,7 @@ export const CLAIM_ROW = object({
414
475
  teamBuy: big,
415
476
  });
416
477
 
417
- export const CLAIM_HISTORY = object({ indexed, wallet: str, claims: array(CLAIM_ROW) });
478
+ export const CLAIM_HISTORY = object({ indexed, wallet: str, claims: array(CLAIM_ROW), next: optional(nullable(str)) });
418
479
 
419
480
  const QUOTE_TOTAL = object({ quote: str, total: big, types: int });
420
481
 
@@ -436,6 +497,8 @@ export const CLAIM_VIEW = object({
436
497
  refOwed: optional(array(object({ account: str, quoteMint: str, owed: big }))),
437
498
  pendingRollUp: optional(array(object({ traderRef: str, quoteMint: str, amount: big }))),
438
499
  owed: optional(array(object({ quote: str, creator: big, creatorRef: big, teamSlot: big, traderRef: big, holder: big, teamBuy: big }))),
500
+
501
+ next: optional(nullable(str)),
439
502
  }),
440
503
  });
441
504
 
@@ -450,6 +513,8 @@ export const PEOPLE = object({
450
513
  indexed,
451
514
  wallet: str,
452
515
  people: array(object({ wallet: str, chain: str, roles: array(object({ kind: oneOf("trader", "creator"), tier: int })), earned: PER_QUOTE, teamMilestone: PER_QUOTE })),
516
+
517
+ next: optional(nullable(str)),
453
518
  });
454
519
 
455
520
  export const ROLES = object({
@@ -468,12 +533,16 @@ export const ROLES = object({
468
533
  holdings: array(object({ launch: str, token: str, amount: big })),
469
534
  }),
470
535
  claimed: record(big),
536
+
537
+ next: optional(nullable(str)),
471
538
  });
472
539
 
473
540
  export const HANDLE_PLACES = object({
474
541
  indexed,
475
542
  handle: str,
476
543
  places: array(object({ launch: str, place: int })),
544
+
545
+ next: optional(nullable(str)),
477
546
  });
478
547
 
479
548
  export const TRADER_BOARD = object({
@@ -487,3 +556,8 @@ export const LAUNCHER_BOARD = object({
487
556
  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
557
  });
489
558
 
559
+ export function maxLossPct(b ) {
560
+ if (b.maxLossPpm != null) return b.maxLossPpm / 10_000;
561
+ if (b.maxLossPpm === undefined && b.graduated === true && b.backedPpm != null) return Math.max(0, 1_000_000 - b.backedPpm) / 10_000;
562
+ return null;
563
+ }
@@ -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,22 +18,23 @@ 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
+ search: (a) => indexerPath.search(a),
24
25
  launch: (a) => indexerPath.launch(a.launch),
25
26
  launchState: (a) => indexerPath.launchState(a.launch),
26
27
  milestones: (a) => indexerPath.milestones(a.launch),
27
28
  holders: ({ launch, ...q }) => indexerPath.holders(launch, q),
28
29
  trades: ({ launch, ...q }) => indexerPath.trades(launch, q),
29
30
  launchClaims: ({ launch, ...q }) => indexerPath.launchClaims(launch, q),
30
- devBuys: (a) => indexerPath.devBuys(a.launch),
31
- memberSold: (a) => indexerPath.memberSold(a.launch),
31
+ devBuys: ({ launch, ...q }) => indexerPath.devBuys(launch, q),
32
+ memberSold: ({ launch, ...q }) => indexerPath.memberSold(launch, q),
32
33
  launchAccount: (a) => indexerPath.launchAccount(a.launch),
33
34
  traders: ({ launch, ...q }) => indexerPath.traders(launch, q),
34
35
  quoteChain: (a) => indexerPath.quoteChain(a.launch),
35
36
  devTrades: ({ launch, ...q }) => indexerPath.devTrades(launch, q),
36
- burns: (a) => indexerPath.burns(a.launch),
37
+ burns: ({ launch, ...q }) => indexerPath.burns(launch, q),
37
38
  launchLocks: (a) => indexerPath.launchLocks(a.launch),
38
39
  marks: ({ launch, ...q }) => indexerPath.marks(launch, q),
39
40
  price: (a) => indexerPath.price(a.launch),
@@ -41,16 +42,18 @@ export const routePath = {
41
42
  candles: (a) => indexerPath.candles(a),
42
43
  candleBundle: ({ launch, ...q }) => indexerPath.candleBundle(launch, q),
43
44
  walletTrades: ({ wallet, ...q }) => indexerPath.walletTrades(wallet, q),
44
- positions: (a) => indexerPath.positions(a.wallet),
45
+ tonActivity: ({ wallet, ...q }) => indexerPath.tonActivity(wallet, q),
46
+ tonOutcome: (a) => indexerPath.tonOutcome(a.wallet, a.queryId),
47
+ positions: ({ wallet, ...q }) => indexerPath.positions(wallet, q),
45
48
  inbox: ({ wallet, ...q }) => indexerPath.inbox(wallet, q),
46
- walletLocks: (a) => indexerPath.walletLocks(a.wallet),
47
- claimHistory: (a) => indexerPath.claimHistory(a.wallet),
49
+ walletLocks: ({ wallet, ...q }) => indexerPath.walletLocks(wallet, q),
50
+ claimHistory: ({ wallet, ...q }) => indexerPath.claimHistory(wallet, q),
48
51
  firsts: (a) => indexerPath.firsts(a.wallet),
49
52
  firstsMany: (a) => indexerPath.firstsMany(a.wallets),
50
- claimView: (a) => indexerPath.claimView(a.wallet),
51
- people: (a) => indexerPath.people(a.wallet),
52
- roles: (a) => indexerPath.roles(a.wallet),
53
- handlePlaces: (a) => indexerPath.handlePlaces(a.handle),
53
+ claimView: ({ wallet, ...q }) => indexerPath.claimView(wallet, q),
54
+ people: ({ wallet, ...q }) => indexerPath.people(wallet, q),
55
+ roles: ({ wallet, ...q }) => indexerPath.roles(wallet, q),
56
+ handlePlaces: ({ handle, ...q }) => indexerPath.handlePlaces(handle, q),
54
57
  traderBoard: (a) => indexerPath.traderBoard(a ?? {}),
55
58
  launcherBoard: (a) => indexerPath.launcherBoard(a ?? {}),
56
59
  tokenHolders: (a) => `/floor-amm/holders/${encodeURIComponent(need(a.token, "token"))}${query({ limit: a.limit, offset: a.offset })}`,
@@ -59,7 +62,7 @@ export const routePath = {
59
62
  dexPair: (a) => `/v2/dex/pair${query({ id: need(a.id, "id") })}`,
60
63
  cgPairs: () => "/v2/coingecko/pairs",
61
64
  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 })}`,
65
+ 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
66
  llamaTvl: () => "/v2/defillama/tvl",
64
67
  llamaFees: (a) => {
65
68
  if (a && a.to < a.from) throw new RangeError("from > to");
@@ -68,11 +71,13 @@ export const routePath = {
68
71
  health: () => "/health",
69
72
  };
70
73
 
74
+ 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"] ;
75
+
71
76
  export function createIndexerClient(opts ) {
72
77
 
73
78
  const clamp = (name , a ) => {
74
79
  if (typeof a !== "object" || a === null || !("limit" in a) || typeof (a ).limit !== "number") return a;
75
- return { ...a, limit: clampLimit(name, (a ).limit) };
80
+ return { ...a, limit: clampLimit(name, (a ).limit, pageAsked(name, a )) };
76
81
  };
77
82
  const path = (name , a ) => (routePath[name] )(clamp(name, a));
78
83
  const read = async (name , a ) => {
@@ -88,12 +93,27 @@ export function createIndexerClient(opts ) {
88
93
  const max = o.maxPages ?? 100;
89
94
  const lim = routeLimit(name) ;
90
95
  let args = { ...a };
96
+
97
+ if (page.kind === "cursor" && page.optIn !== undefined && args.before === undefined) args = { ...args, before: "" };
98
+ if (page.kind === "keyset" && page.optIn === true && args.limit === undefined && args.cursor === undefined) args = { ...args, limit: lim.default };
91
99
  for (let i = 0; i < max; i++) {
92
100
  const body = (await read(name, args)) ;
93
101
  yield body;
94
102
  if (page.kind === "cursor") {
95
103
  if (body.next === null || body.next === undefined) return;
96
104
  args = { ...args, before: body.next };
105
+ } else if (page.kind === "keyset") {
106
+
107
+ if (args.ids !== undefined) return;
108
+ if (args.offset !== undefined) {
109
+ const step = clampLimit(name, (args.limit ) ?? lim.default);
110
+ const offset = (args.offset ) + step;
111
+ if (offset >= (body.total ?? 0)) return;
112
+ args = { ...args, offset };
113
+ continue;
114
+ }
115
+ if (body.next === null || body.next === undefined) return;
116
+ args = { ...args, cursor: body.next };
97
117
  } else if (page.kind === "offset") {
98
118
  const step = clampLimit(name, (args.limit ) ?? lim.default);
99
119
  const offset = ((args.offset ) ?? 0) + step;