@floorlaunchpad/sdk 0.3.1 → 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 (64) hide show
  1. package/CHANGELOG.md +97 -0
  2. package/README.md +20 -5
  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 +106 -16
  14. package/dist/indexer/client.js +35 -12
  15. package/dist/indexer/contract.js +138 -28
  16. package/dist/indexer/partners.js +3 -2
  17. package/dist/indexer/paths.js +63 -25
  18. package/dist/indexer/read.js +38 -13
  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/devbuy.js +15 -0
  28. package/dist/v2/solana.js +17 -2
  29. package/dist/v2/tx/solana.js +1 -1
  30. package/docs/bot.md +36 -1
  31. package/docs/cursor-pages.md +56 -0
  32. package/docs/floor-line.md +208 -34
  33. package/examples/floor-line.html +373 -76
  34. package/package.json +1 -1
  35. package/src/abi/evm.gen.ts +1 -1
  36. package/src/abi/solana.gen.ts +1 -1
  37. package/src/client/evm/index.ts +16 -2
  38. package/src/client/solana/index.ts +19 -7
  39. package/src/client/types.ts +1 -1
  40. package/src/config/generated.ts +26864 -402
  41. package/src/config/index.ts +9 -2
  42. package/src/config/registry.gen.ts +33 -2
  43. package/src/events/types.gen.ts +2 -1
  44. package/src/evm/chains.ts +9 -1
  45. package/src/evm/floor/abi.gen.ts +1 -1
  46. package/src/evm/floor/events.ts +11 -1
  47. package/src/evm/floor/legacy-events.ts +27 -0
  48. package/src/indexer/bodies.ts +117 -16
  49. package/src/indexer/client.ts +54 -26
  50. package/src/indexer/contract.ts +158 -30
  51. package/src/indexer/partners.ts +3 -2
  52. package/src/indexer/paths.ts +86 -25
  53. package/src/indexer/read.ts +44 -15
  54. package/src/indexer/search.ts +138 -0
  55. package/src/indexer/stack-edge.ts +46 -0
  56. package/src/indexer/stream.ts +78 -24
  57. package/src/math/v2/split.ts +11 -3
  58. package/src/solana/floor/events.ts +1 -1
  59. package/src/solana/floor/genesis.ts +8 -2
  60. package/src/solana/floor/instructions.ts +13 -5
  61. package/src/solana/floor/registry.ts +4 -0
  62. package/src/v2/devbuy.ts +33 -0
  63. package/src/v2/solana.ts +20 -3
  64. 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: null,
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,16 +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
- });
122
131
 
123
- export const LIVE_LAUNCH = object({ ...LAUNCH_FIELDS, volume24hGross: nullable(big), holders: int });
132
+ trendingScore: nullable(big),
133
+
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)) });
124
139
 
125
140
  const TRADE_FIELDS = {
126
141
  launch: str,
@@ -204,6 +219,8 @@ export const FLOOR_ROUTED = object({
204
219
  indexed,
205
220
  launches: array(object({ launch: str, quote: str, floorFee: big, floorMilestone: big })),
206
221
  pending: array(object({ quote: str, amount: big })),
222
+
223
+ next: optional(nullable(str)),
207
224
  });
208
225
 
209
226
  export const EVENTS = object({
@@ -225,9 +242,22 @@ export const EVENTS = object({
225
242
  })),
226
243
  });
227
244
 
228
- export const LAUNCHES_ALL = object({ indexed, launches: array(LISTED_LAUNCH) });
245
+ const nextCursor = (v, p) => (v === undefined || v === null ? null : str(v, p));
229
246
 
230
- 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 });
231
261
 
232
262
  export const LAUNCH_ONE = object({ indexed, launch: LISTED_LAUNCH });
233
263
 
@@ -239,11 +269,17 @@ export const HOLDERS = object({ indexed, source: oneOf("positions", "trades"), t
239
269
 
240
270
  export const TRADES = object({ indexed, trades: array(PAGED_TRADE), next: nullable(str) });
241
271
 
242
- 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) });
273
+
274
+ export const LAUNCH_CLAIMS = object({ indexed, claims: array(LAUNCH_CLAIM), next: optional(nullable(str)) });
275
+
276
+ export const DEV_BUYS = object({ indexed, teamBuyUnlocked: bool, teamBuyUnlockedTs: nullable(int), devBuys: array(DEV_BUY), next: optional(nullable(str)) });
243
277
 
244
- export const LAUNCH_CLAIMS = object({ indexed, claims: array(LAUNCH_CLAIM) });
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 });
245
279
 
246
- export const DEV_BUYS = object({ indexed, teamBuyUnlocked: bool, teamBuyUnlockedTs: nullable(int), devBuys: array(DEV_BUY) });
280
+ export const MEMBER_SOLD = object({ indexed, memberSold: array(MEMBER_SOLD_ROW), next: optional(nullable(str)) });
281
+
282
+ export const LAUNCH_ACCOUNT = object({ indexed, launch: str, mint: str, slot: int, data: str });
247
283
 
248
284
  export const CANDLE_INTERVALS = ["1s", "5s", "1m", "5m", "15m", "1h", "4h", "1d"] ;
249
285
 
@@ -274,6 +310,8 @@ export const CANDLE = object({
274
310
  volumeSellQuoteRaw: big,
275
311
  buys: int,
276
312
  sells: int,
313
+
314
+ floorX64: optional(nullable(big)),
277
315
  });
278
316
 
279
317
  const USD_RATE = object({ centsX64: nullable(big), source: nullable(str), ageS: nullable(int) });
@@ -320,7 +358,7 @@ export const QUOTE_CHAIN = object({ indexed, launch: str, chain: array(object({
320
358
 
321
359
  export const DEV_TRADES = object({ indexed, launch: str, creator: str, trades: array(TRADE) });
322
360
 
323
- 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)) });
324
362
 
325
363
  const LOCK_HOLDER = object({ wallet: str, place: nullable(int) });
326
364
 
@@ -341,6 +379,9 @@ export const PRICE = object({
341
379
  priceX64: big,
342
380
  livePriceX64: big,
343
381
  floorX64: big,
382
+
383
+ maxLossPpm: optional(nullable(int)),
384
+
344
385
  backedPpm: int,
345
386
  bidTopX64: nullable(big),
346
387
  lastTrade: nullable(object({ priceAfterX64: big, timestamp: int, block: int })),
@@ -352,15 +393,43 @@ export const PRICE = object({
352
393
 
353
394
  export const WALLET_TRADES = object({ indexed, wallet: str, trades: array(PAGED_TRADE), next: nullable(str) });
354
395
 
355
- 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)) });
356
423
 
357
424
  export const WALLET_LOCKS = object({
358
425
  indexed,
359
426
  wallet: str,
360
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)),
361
430
  });
362
431
 
363
- const AT = { timestamp: int, block: int };
432
+ const AT = { timestamp: int, block: int, id: optional(str) };
364
433
 
365
434
  export const INBOX_CLAIMED = object({ ...AT, kind: oneOf("claimed"), launch: str, quote: str, types: int, amount: big, holder: big, txnId: nullable(str) });
366
435
 
@@ -368,7 +437,7 @@ export const INBOX_GRADUATED = object({ ...AT, kind: oneOf("graduated"), launch:
368
437
 
369
438
  export const INBOX_SLOT = object({ ...AT, kind: oneOf("slot"), launch: str, place: int });
370
439
 
371
- 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 });
372
441
 
373
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) });
374
443
 
@@ -386,14 +455,14 @@ export function inboxItem(v , p ) {
386
455
  return d(v, p) ;
387
456
  }
388
457
 
389
- 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)) });
390
459
 
391
460
  export const CLAIM_ROW = object({
392
461
  block: int,
393
462
  timestamp: int,
394
463
  txnId: nullable(str),
395
464
  sender: str,
396
- launch: str,
465
+ launch: nullable(str),
397
466
  quote: str,
398
467
  types: int,
399
468
  creator: big,
@@ -406,7 +475,7 @@ export const CLAIM_ROW = object({
406
475
  teamBuy: big,
407
476
  });
408
477
 
409
- 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)) });
410
479
 
411
480
  const QUOTE_TOTAL = object({ quote: str, total: big, types: int });
412
481
 
@@ -428,6 +497,8 @@ export const CLAIM_VIEW = object({
428
497
  refOwed: optional(array(object({ account: str, quoteMint: str, owed: big }))),
429
498
  pendingRollUp: optional(array(object({ traderRef: str, quoteMint: str, amount: big }))),
430
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)),
431
502
  }),
432
503
  });
433
504
 
@@ -442,6 +513,8 @@ export const PEOPLE = object({
442
513
  indexed,
443
514
  wallet: str,
444
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)),
445
518
  });
446
519
 
447
520
  export const ROLES = object({
@@ -455,9 +528,21 @@ export const ROLES = object({
455
528
  creatorOf: array(str),
456
529
  creatorRefOf: array(object({ launch: str, tier: int })),
457
530
  teamSlotOf: array(object({ launch: str, place: int })),
531
+
532
+ handleSlotOf: array(object({ launch: str, place: int, handle: str })),
458
533
  holdings: array(object({ launch: str, token: str, amount: big })),
459
534
  }),
460
535
  claimed: record(big),
536
+
537
+ next: optional(nullable(str)),
538
+ });
539
+
540
+ export const HANDLE_PLACES = object({
541
+ indexed,
542
+ handle: str,
543
+ places: array(object({ launch: str, place: int })),
544
+
545
+ next: optional(nullable(str)),
461
546
  });
462
547
 
463
548
  export const TRADER_BOARD = object({
@@ -471,3 +556,8 @@ export const LAUNCHER_BOARD = object({
471
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 })) })),
472
557
  });
473
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,20 +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
+ devBuys: ({ launch, ...q }) => indexerPath.devBuys(launch, q),
32
+ memberSold: ({ launch, ...q }) => indexerPath.memberSold(launch, q),
33
+ launchAccount: (a) => indexerPath.launchAccount(a.launch),
31
34
  traders: ({ launch, ...q }) => indexerPath.traders(launch, q),
32
35
  quoteChain: (a) => indexerPath.quoteChain(a.launch),
33
36
  devTrades: ({ launch, ...q }) => indexerPath.devTrades(launch, q),
34
- burns: (a) => indexerPath.burns(a.launch),
37
+ burns: ({ launch, ...q }) => indexerPath.burns(launch, q),
35
38
  launchLocks: (a) => indexerPath.launchLocks(a.launch),
36
39
  marks: ({ launch, ...q }) => indexerPath.marks(launch, q),
37
40
  price: (a) => indexerPath.price(a.launch),
@@ -39,15 +42,18 @@ export const routePath = {
39
42
  candles: (a) => indexerPath.candles(a),
40
43
  candleBundle: ({ launch, ...q }) => indexerPath.candleBundle(launch, q),
41
44
  walletTrades: ({ wallet, ...q }) => indexerPath.walletTrades(wallet, q),
42
- 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),
43
48
  inbox: ({ wallet, ...q }) => indexerPath.inbox(wallet, q),
44
- walletLocks: (a) => indexerPath.walletLocks(a.wallet),
45
- claimHistory: (a) => indexerPath.claimHistory(a.wallet),
49
+ walletLocks: ({ wallet, ...q }) => indexerPath.walletLocks(wallet, q),
50
+ claimHistory: ({ wallet, ...q }) => indexerPath.claimHistory(wallet, q),
46
51
  firsts: (a) => indexerPath.firsts(a.wallet),
47
52
  firstsMany: (a) => indexerPath.firstsMany(a.wallets),
48
- claimView: (a) => indexerPath.claimView(a.wallet),
49
- people: (a) => indexerPath.people(a.wallet),
50
- roles: (a) => indexerPath.roles(a.wallet),
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),
51
57
  traderBoard: (a) => indexerPath.traderBoard(a ?? {}),
52
58
  launcherBoard: (a) => indexerPath.launcherBoard(a ?? {}),
53
59
  tokenHolders: (a) => `/floor-amm/holders/${encodeURIComponent(need(a.token, "token"))}${query({ limit: a.limit, offset: a.offset })}`,
@@ -56,7 +62,7 @@ export const routePath = {
56
62
  dexPair: (a) => `/v2/dex/pair${query({ id: need(a.id, "id") })}`,
57
63
  cgPairs: () => "/v2/coingecko/pairs",
58
64
  cgTickers: () => "/v2/coingecko/tickers",
59
- 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 })}`,
60
66
  llamaTvl: () => "/v2/defillama/tvl",
61
67
  llamaFees: (a) => {
62
68
  if (a && a.to < a.from) throw new RangeError("from > to");
@@ -65,11 +71,13 @@ export const routePath = {
65
71
  health: () => "/health",
66
72
  };
67
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
+
68
76
  export function createIndexerClient(opts ) {
69
77
 
70
78
  const clamp = (name , a ) => {
71
79
  if (typeof a !== "object" || a === null || !("limit" in a) || typeof (a ).limit !== "number") return a;
72
- return { ...a, limit: clampLimit(name, (a ).limit) };
80
+ return { ...a, limit: clampLimit(name, (a ).limit, pageAsked(name, a )) };
73
81
  };
74
82
  const path = (name , a ) => (routePath[name] )(clamp(name, a));
75
83
  const read = async (name , a ) => {
@@ -85,12 +93,27 @@ export function createIndexerClient(opts ) {
85
93
  const max = o.maxPages ?? 100;
86
94
  const lim = routeLimit(name) ;
87
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 };
88
99
  for (let i = 0; i < max; i++) {
89
100
  const body = (await read(name, args)) ;
90
101
  yield body;
91
102
  if (page.kind === "cursor") {
92
103
  if (body.next === null || body.next === undefined) return;
93
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 };
94
117
  } else if (page.kind === "offset") {
95
118
  const step = clampLimit(name, (args.limit ) ?? lim.default);
96
119
  const offset = ((args.offset ) ?? 0) + step;