@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.
Files changed (75) hide show
  1. package/CHANGELOG.md +94 -0
  2. package/README.md +16 -0
  3. package/dist/abi/evm.gen.js +6 -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 +31 -14
  7. package/dist/config/generated.js +26864 -402
  8. package/dist/config/registry.gen.js +33 -2
  9. package/dist/evm/chains.js +85 -16
  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/evm/router.js +25 -1
  14. package/dist/evm/squid.js +9 -9
  15. package/dist/evm/zap.js +148 -35
  16. package/dist/indexer/bodies.js +96 -17
  17. package/dist/indexer/client.js +36 -14
  18. package/dist/indexer/contract.js +178 -28
  19. package/dist/indexer/partners.js +3 -2
  20. package/dist/indexer/paths.js +87 -29
  21. package/dist/indexer/read.js +30 -15
  22. package/dist/indexer/search.js +130 -0
  23. package/dist/indexer/stack-edge.js +35 -0
  24. package/dist/indexer/stream.js +70 -23
  25. package/dist/math/v2/split.js +11 -3
  26. package/dist/solana/floor/events.js +1 -1
  27. package/dist/solana/floor/genesis.js +9 -3
  28. package/dist/solana/floor/instructions.js +14 -5
  29. package/dist/solana/floor/registry.js +4 -0
  30. package/dist/v2/devbuy.js +6 -4
  31. package/dist/v2/presetRowEvm.js +21 -2
  32. package/dist/v2/solana.js +17 -2
  33. package/dist/v2/tx/solana.js +1 -1
  34. package/docs/aggregator.md +22 -0
  35. package/docs/bot.md +44 -1
  36. package/docs/cursor-pages.md +58 -0
  37. package/docs/floor-line.md +9 -4
  38. package/docs/frontend.md +2 -0
  39. package/docs/wallet.md +2 -0
  40. package/examples/floor-line.html +6 -6
  41. package/package.json +1 -1
  42. package/src/abi/evm.gen.ts +6 -1
  43. package/src/abi/solana.gen.ts +1 -1
  44. package/src/client/evm/index.ts +16 -2
  45. package/src/client/solana/index.ts +31 -14
  46. package/src/client/types.ts +1 -1
  47. package/src/config/generated.ts +26864 -402
  48. package/src/config/index.ts +9 -2
  49. package/src/config/registry.gen.ts +33 -2
  50. package/src/events/types.gen.ts +2 -1
  51. package/src/evm/chains.ts +94 -15
  52. package/src/evm/floor/abi.gen.ts +1 -1
  53. package/src/evm/floor/events.ts +11 -1
  54. package/src/evm/floor/legacy-events.ts +27 -0
  55. package/src/evm/router.ts +26 -1
  56. package/src/evm/squid.ts +9 -9
  57. package/src/evm/zap.ts +185 -36
  58. package/src/indexer/bodies.ts +106 -17
  59. package/src/indexer/client.ts +56 -30
  60. package/src/indexer/contract.ts +197 -29
  61. package/src/indexer/partners.ts +3 -2
  62. package/src/indexer/paths.ts +131 -29
  63. package/src/indexer/read.ts +36 -17
  64. package/src/indexer/search.ts +138 -0
  65. package/src/indexer/stack-edge.ts +46 -0
  66. package/src/indexer/stream.ts +78 -24
  67. package/src/math/v2/split.ts +11 -3
  68. package/src/solana/floor/events.ts +1 -1
  69. package/src/solana/floor/genesis.ts +8 -2
  70. package/src/solana/floor/instructions.ts +13 -5
  71. package/src/solana/floor/registry.ts +4 -0
  72. package/src/v2/devbuy.ts +6 -4
  73. package/src/v2/presetRowEvm.ts +21 -2
  74. package/src/v2/solana.ts +20 -3
  75. package/src/v2/tx/solana.ts +1 -1
@@ -11,52 +11,79 @@ export const INDEXER_ROUTES = {
11
11
  stream: { pattern: "/floor-amm/stream", keys: ["launch", "state", "lastEventId"] },
12
12
  quotes: { pattern: "/floor-amm/quotes", keys: [] },
13
13
  summary: { pattern: "/floor-amm/summary", keys: [] },
14
- floorRouted: { pattern: "/floor-amm/floor-routed", keys: [] },
14
+ floorRouted: { pattern: "/floor-amm/floor-routed", keys: ["limit", "cursor"] },
15
15
  events: { pattern: "/floor-amm/events", keys: ["fromBlock", "toBlock"] },
16
- launches: { pattern: "/floor-amm/launches", keys: ["sort", "order", "q", "ids", "quote", "creator", "rankable", "graduated", "limit", "offset"] },
16
+ launches: { pattern: "/floor-amm/launches", keys: ["sort", "order", "q", "ids", "quote", "creator", "rankable", "graduated", "preset", "limit", "cursor", "offset"] },
17
+ launchLists: { pattern: "/floor-amm/launch-lists", keys: ["quotes", "cursors", "sort", "order", "creator", "rankable", "graduated", "preset", "limit"] },
18
+ search: { pattern: "/floor-amm/search", keys: ["q", "limit", "cursor", "rankable", "graduated", "quote", "preset"] },
17
19
  launch: { pattern: "/floor-amm/launches/<launch>", keys: [] },
18
20
  launchState: { pattern: "/floor-amm/launches/<launch>/state", keys: [] },
19
21
  milestones: { pattern: "/floor-amm/launches/<launch>/milestones", keys: [] },
20
22
  holders: { pattern: "/floor-amm/launches/<launch>/holders", keys: ["limit"] },
21
23
  trades: { pattern: "/floor-amm/launches/<launch>/trades", keys: ["limit", "before", "traders"] },
22
- launchClaims: { pattern: "/floor-amm/launches/<launch>/claims", keys: ["claimer"] },
23
- devBuys: { pattern: "/floor-amm/launches/<launch>/dev-buys", keys: [] },
24
- memberSold: { pattern: "/floor-amm/launches/<launch>/member-sold", keys: [] },
24
+ launchClaims: { pattern: "/floor-amm/launches/<launch>/claims", keys: ["limit", "before", "claimer"] },
25
+ devBuys: { pattern: "/floor-amm/launches/<launch>/dev-buys", keys: ["limit", "before"] },
26
+ memberSold: { pattern: "/floor-amm/launches/<launch>/member-sold", keys: ["limit", "before"] },
25
27
  launchAccount: { pattern: "/floor-amm/launches/<launch>/account", keys: [] },
26
28
  traders: { pattern: "/floor-amm/launches/<launch>/traders", keys: ["window", "limit"] },
27
29
  quoteChain: { pattern: "/floor-amm/launches/<launch>/chain", keys: [] },
28
30
  devTrades: { pattern: "/floor-amm/launches/<launch>/dev", keys: ["limit"] },
29
- burns: { pattern: "/floor-amm/launches/<launch>/burns", keys: [] },
31
+ burns: { pattern: "/floor-amm/launches/<launch>/burns", keys: ["limit", "before"] },
30
32
  launchLocks: { pattern: "/floor-amm/launches/<launch>/locks", keys: [] },
31
33
  marks: { pattern: "/floor-amm/launches/<launch>/marks", keys: ["limit", "before"] },
32
34
  price: { pattern: "/floor-amm/launches/<launch>/price", keys: [] },
33
35
  highs: { pattern: "/floor-amm/launches/<launch>/highs", keys: ["atLeast", "limit"] },
34
36
  candleBundle: { pattern: "/floor-amm/launches/<launch>/candle-bundle", keys: ["intervals", "limit"] },
35
37
  candles: { pattern: "/floor-amm/candles", keys: ["launch", "interval", "from", "to", "before", "limit"] },
38
+ candlesMany: { pattern: "/floor-amm/candles/many", keys: ["ids", "interval", "before", "limit"] },
36
39
  walletTrades: { pattern: "/floor-amm/wallets/<wallet>/trades", keys: ["limit", "before", "launch"] },
37
- positions: { pattern: "/floor-amm/wallets/<wallet>/positions", keys: [] },
38
- inbox: { pattern: "/floor-amm/wallets/<wallet>/inbox", keys: ["limit"] },
39
- walletLocks: { pattern: "/floor-amm/wallets/<wallet>/locks", keys: [] },
40
- claimHistory: { pattern: "/floor-amm/wallets/<wallet>/claims", keys: [] },
40
+ tonActivity: { pattern: "/floor-amm/wallets/<wallet>/ton-activity", keys: ["limit", "before"] },
41
+ tonOutcome: { pattern: "/floor-amm/wallets/<wallet>/ton-outcome", keys: ["queryId"] },
42
+ positions: { pattern: "/floor-amm/wallets/<wallet>/positions", keys: ["limit", "cursor"] },
43
+ inbox: { pattern: "/floor-amm/wallets/<wallet>/inbox", keys: ["limit", "before"] },
44
+ walletLocks: { pattern: "/floor-amm/wallets/<wallet>/locks", keys: ["limit", "cursor"] },
45
+ claimHistory: { pattern: "/floor-amm/wallets/<wallet>/claims", keys: ["limit", "cursor"] },
41
46
  firsts: { pattern: "/floor-amm/wallets/<wallet>/firsts", keys: [] },
42
47
  firstsMany: { pattern: "/floor-amm/wallets/firsts", keys: ["wallets"] },
43
- claimView: { pattern: "/floor-amm/claims/<wallet>", keys: [] },
44
- people: { pattern: "/floor-amm/referrals/<wallet>/people", keys: [] },
45
- roles: { pattern: "/floor-amm/roles/<wallet>", keys: [] },
46
- handlePlaces: { pattern: "/floor-amm/handles/<handle>/places", keys: [] },
48
+ claimView: { pattern: "/floor-amm/claims/<wallet>", keys: ["limit", "cursor"] },
49
+ people: { pattern: "/floor-amm/referrals/<wallet>/people", keys: ["limit", "cursor"] },
50
+ roles: { pattern: "/floor-amm/roles/<wallet>", keys: ["limit", "cursor"] },
51
+ handlePlaces: { pattern: "/floor-amm/handles/<handle>/places", keys: ["limit", "cursor"] },
47
52
  traderBoard: { pattern: "/floor-amm/leaderboards/traders", keys: ["window", "limit"] },
48
53
  launcherBoard: { pattern: "/floor-amm/leaderboards/launchers", keys: ["limit"] },
49
54
  } as const satisfies Record<string, IndexerRoute>;
50
55
 
51
56
  export type IndexerRouteName = keyof typeof INDEXER_ROUTES;
52
57
 
53
- export const LAUNCH_SORTS = ["created", "newest", "volume1h", "volume24h", "volume7d", "volume", "marketCap", "liquidity", "backed", "trades24h", "holders", "change1h", "change24h", "lastTrade", "nearFloor", "trending", "newHolders24h"] as const;
58
+ export const LAUNCH_SORTS = ["created", "newest", "volume1h", "volume24h", "volume7d", "volume", "marketCap", "liquidity", "backed", "trades24h", "holders", "change1h", "change24h", "lastTrade", "nearFloor", "trending", "newHolders24h", "standingVolume", "standingMarketCap", "standingBacked", "maxloss"] as const;
54
59
  export type LaunchSort = (typeof LAUNCH_SORTS)[number];
55
60
 
56
61
  export const IDS_MAX = 100;
57
62
 
58
63
  export const LAUNCHES_PAGE_MAX = 1_000;
59
64
 
65
+ export const LAUNCHES_PAGE_DEFAULT = 100;
66
+
67
+ export const LAUNCH_LISTS_QUOTES_MAX = 16;
68
+ export const LAUNCH_LISTS_ROWS_MAX = 1_000;
69
+
70
+ export const LAUNCH_LISTS_FIRST = "-";
71
+
72
+ export const CANDLES_MANY_IDS_MAX = 40;
73
+ export const CANDLES_MANY_LIMIT_DEFAULT = 1_000;
74
+ export const CANDLES_MANY_ROWS_MAX = 40_000;
75
+
76
+ export const LAUNCH_CURSOR_MAX = 512;
77
+
78
+ export const WALLET_PAGE_DEFAULT = 100;
79
+ export const WALLET_PAGE_MAX = 500;
80
+
81
+ export const WALLET_CURSOR_MAX = 256;
82
+ export const INBOX_PAGE_DEFAULT = 100;
83
+ export const INBOX_PAGE_MAX = 500;
84
+
85
+ export const PRESET_FILTER_MAX = 16;
86
+
60
87
  export const FIRSTS_MAX = 100;
61
88
 
62
89
  export const STREAM_STATE_MAX = 16;
@@ -79,6 +106,8 @@ const need = (s: string): string => {
79
106
  };
80
107
  const seg = (s: string): string => encodeURIComponent(need(s));
81
108
 
109
+ const presets = (p: readonly number[] | undefined): readonly string[] | undefined => (p === undefined || p.length === 0 ? undefined : p.map(String));
110
+
82
111
  const launchPath = (id: string, tail = ""): string => `/floor-amm/launches/${seg(id)}${tail}`;
83
112
  const walletPath = (w: string, tail: string): string => `/floor-amm/wallets/${seg(w)}${tail}`;
84
113
 
@@ -94,10 +123,58 @@ export interface LaunchesQuery {
94
123
 
95
124
  rankable?: boolean;
96
125
  graduated?: boolean;
126
+
127
+ preset?: readonly number[];
128
+
97
129
  limit?: number;
130
+
131
+ cursor?: string;
98
132
  offset?: number;
99
133
  }
100
134
 
135
+ export interface LaunchListsQuery {
136
+
137
+ quotes: readonly string[];
138
+
139
+ cursors?: readonly (string | null)[];
140
+ sort?: LaunchSort;
141
+ order?: "asc" | "desc";
142
+ creator?: string;
143
+ rankable?: boolean;
144
+ graduated?: boolean;
145
+ preset?: readonly number[];
146
+
147
+ limit?: number;
148
+ }
149
+
150
+ export interface CandlesManyQuery {
151
+
152
+ ids: readonly string[];
153
+ interval?: string;
154
+
155
+ before?: number;
156
+
157
+ limit?: number;
158
+ }
159
+
160
+ export interface LaunchSearchQuery {
161
+
162
+ q: string;
163
+
164
+ limit?: number;
165
+
166
+ cursor?: string;
167
+ rankable?: boolean;
168
+ graduated?: boolean;
169
+ quote?: string;
170
+ preset?: readonly number[];
171
+ }
172
+
173
+ export interface WalletPage {
174
+ limit?: number;
175
+ cursor?: string;
176
+ }
177
+
101
178
  export interface Page {
102
179
  limit?: number;
103
180
 
@@ -144,27 +221,40 @@ export const indexerPath = {
144
221
  },
145
222
  quotes: (): string => "/floor-amm/quotes",
146
223
  summary: (): string => "/floor-amm/summary",
147
- floorRouted: (): string => "/floor-amm/floor-routed",
224
+ floorRouted: (q: { limit?: number; cursor?: string } = {}): string => `/floor-amm/floor-routed${query({ limit: q.limit, cursor: q.cursor })}`,
148
225
  events: (fromBlock: number, toBlock: number): string => `/floor-amm/events${query({ fromBlock, toBlock })}`,
149
226
 
150
227
  launches: (q: LaunchesQuery = {}): string => {
151
228
  if (q.ids !== undefined && q.ids.length > IDS_MAX) throw new RangeError(`at most ${IDS_MAX} ids`);
152
229
  const sort = q.sort ?? (q.ids === undefined ? "created" : undefined);
153
- return `/floor-amm/launches${query({ sort, order: q.order, q: q.q, ids: q.ids, quote: q.quote, creator: q.creator, rankable: q.rankable, graduated: q.graduated, limit: q.limit, offset: q.offset })}`;
230
+ if (q.preset !== undefined && q.preset.length > PRESET_FILTER_MAX) throw new RangeError(`at most ${PRESET_FILTER_MAX} presets`);
231
+ return `/floor-amm/launches${query({ sort, order: q.order, q: q.q, ids: q.ids, quote: q.quote, creator: q.creator, rankable: q.rankable, graduated: q.graduated, preset: presets(q.preset), limit: q.limit, cursor: q.cursor, offset: q.offset })}`;
232
+ },
233
+ search: (q: LaunchSearchQuery): string => {
234
+ if (q.q.trim() === "") throw new RangeError("an empty search");
235
+ if (q.preset !== undefined && q.preset.length > PRESET_FILTER_MAX) throw new RangeError(`at most ${PRESET_FILTER_MAX} presets`);
236
+ return `/floor-amm/search${query({ q: q.q, limit: q.limit, cursor: q.cursor, rankable: q.rankable, graduated: q.graduated, quote: q.quote, preset: presets(q.preset) })}`;
237
+ },
238
+ launchLists: (q: LaunchListsQuery): string => {
239
+ if (q.quotes.length < 1 || q.quotes.length > LAUNCH_LISTS_QUOTES_MAX) throw new RangeError(`1..${LAUNCH_LISTS_QUOTES_MAX} quotes`);
240
+ if (q.cursors !== undefined && q.cursors.length !== q.quotes.length) throw new RangeError("one cursor per quote");
241
+ if (q.preset !== undefined && q.preset.length > PRESET_FILTER_MAX) throw new RangeError(`at most ${PRESET_FILTER_MAX} presets`);
242
+ const cursors = q.cursors?.some((c) => c !== null && c !== "") ? q.cursors.map((c) => (c === null || c === "" ? LAUNCH_LISTS_FIRST : c)) : undefined;
243
+ return `/floor-amm/launch-lists${query({ quotes: q.quotes, cursors, sort: q.sort, order: q.order, creator: q.creator, rankable: q.rankable, graduated: q.graduated, preset: presets(q.preset), limit: q.limit })}`;
154
244
  },
155
245
  launch: (id: string): string => launchPath(id),
156
246
  launchState: (id: string): string => launchPath(id, "/state"),
157
247
  milestones: (id: string): string => launchPath(id, "/milestones"),
158
248
  holders: (id: string, q: { limit?: number } = {}): string => launchPath(id, `/holders${query({ limit: q.limit })}`),
159
249
  trades: (id: string, q: TradesQuery = {}): string => launchPath(id, `/trades${query({ limit: q.limit, before: q.before, traders: q.traders?.length ? q.traders : undefined })}`),
160
- launchClaims: (id: string, q: { claimer?: string } = {}): string => launchPath(id, `/claims${query({ claimer: q.claimer })}`),
161
- devBuys: (id: string): string => launchPath(id, "/dev-buys"),
162
- memberSold: (id: string): string => launchPath(id, "/member-sold"),
250
+ launchClaims: (id: string, q: Page & { claimer?: string } = {}): string => launchPath(id, `/claims${query({ limit: q.limit, before: q.before, claimer: q.claimer })}`),
251
+ devBuys: (id: string, q: Page = {}): string => launchPath(id, `/dev-buys${query({ limit: q.limit, before: q.before })}`),
252
+ memberSold: (id: string, q: Page = {}): string => launchPath(id, `/member-sold${query({ limit: q.limit, before: q.before })}`),
163
253
  launchAccount: (id: string): string => launchPath(id, "/account"),
164
254
  traders: (id: string, q: { window?: "1h" | "24h" | "7d" | "all"; limit?: number } = {}): string => launchPath(id, `/traders${query({ window: q.window, limit: q.limit })}`),
165
255
  quoteChain: (id: string): string => launchPath(id, "/chain"),
166
256
  devTrades: (id: string, q: { limit?: number } = {}): string => launchPath(id, `/dev${query({ limit: q.limit })}`),
167
- burns: (id: string): string => launchPath(id, "/burns"),
257
+ burns: (id: string, q: Page = {}): string => launchPath(id, `/burns${query({ limit: q.limit, before: q.before })}`),
168
258
  launchLocks: (id: string): string => launchPath(id, "/locks"),
169
259
  marks: (id: string, q: Page = {}): string => launchPath(id, `/marks${query({ limit: q.limit, before: q.before })}`),
170
260
  price: (id: string): string => launchPath(id, "/price"),
@@ -177,20 +267,32 @@ export const indexerPath = {
177
267
  if (q.limit !== undefined && q.before === undefined) throw new RangeError("limit is read only with before");
178
268
  return `/floor-amm/candles${query({ launch: need(q.launch), interval: q.interval, from: q.from, to: q.to, before: q.before, limit: q.limit })}`;
179
269
  },
270
+ candlesMany: (q: CandlesManyQuery): string => {
271
+ if (q.ids.length < 1 || q.ids.length > CANDLES_MANY_IDS_MAX) throw new RangeError(`1..${CANDLES_MANY_IDS_MAX} ids`);
272
+ return `/floor-amm/candles/many${query({ ids: q.ids, interval: q.interval, before: q.before, limit: q.limit })}`;
273
+ },
180
274
  walletTrades: (w: string, q: WalletTradesQuery = {}): string => walletPath(w, `/trades${query({ limit: q.limit, before: q.before, launch: q.launch })}`),
181
- positions: (w: string): string => walletPath(w, "/positions"),
182
- inbox: (w: string, q: { limit?: number } = {}): string => walletPath(w, `/inbox${query({ limit: q.limit })}`),
183
- walletLocks: (w: string): string => walletPath(w, "/locks"),
184
- claimHistory: (w: string): string => walletPath(w, "/claims"),
275
+
276
+ tonActivity: (w: string, q: Page = {}): string => walletPath(w, `/ton-activity${query({ limit: q.limit, before: q.before })}`),
277
+ tonOutcome: (w: string, queryId: bigint | string): string => walletPath(w, `/ton-outcome${query({ queryId: String(queryId) })}`),
278
+
279
+ positions: (w: string, q: WalletPage = {}): string => walletPath(w, `/positions${query({ limit: q.limit, cursor: q.cursor })}`),
280
+
281
+ inbox: (w: string, q: { limit?: number; before?: string } = {}): string => walletPath(w, `/inbox${query({ limit: q.limit, before: q.before })}`),
282
+ walletLocks: (w: string, q: WalletPage = {}): string => walletPath(w, `/locks${query({ limit: q.limit, cursor: q.cursor })}`),
283
+
284
+ claimHistory: (w: string, q: WalletPage = {}): string => walletPath(w, `/claims${query({ limit: q.limit, cursor: q.cursor })}`),
185
285
  firsts: (w: string): string => walletPath(w, "/firsts"),
186
286
  firstsMany: (wallets: readonly string[]): string => {
187
287
  if (wallets.length === 0 || wallets.length > FIRSTS_MAX) throw new RangeError(`1..${FIRSTS_MAX} wallets`);
188
288
  return `/floor-amm/wallets/firsts${query({ wallets })}`;
189
289
  },
190
- claimView: (w: string): string => `/floor-amm/claims/${seg(w)}`,
191
- people: (w: string): string => `/floor-amm/referrals/${seg(w)}/people`,
192
- roles: (w: string): string => `/floor-amm/roles/${seg(w)}`,
193
- handlePlaces: (handle: string): string => `/floor-amm/handles/${seg(handle)}/places`,
290
+ claimView: (w: string, q: WalletPage = {}): string => `/floor-amm/claims/${seg(w)}${query({ limit: q.limit, cursor: q.cursor })}`,
291
+
292
+ people: (w: string, q: WalletPage = {}): string => `/floor-amm/referrals/${seg(w)}/people${query({ limit: q.limit, cursor: q.cursor })}`,
293
+
294
+ roles: (w: string, q: WalletPage = {}): string => `/floor-amm/roles/${seg(w)}${query({ limit: q.limit, cursor: q.cursor })}`,
295
+ handlePlaces: (handle: string, q: WalletPage = {}): string => `/floor-amm/handles/${seg(handle)}/places${query({ limit: q.limit, cursor: q.cursor })}`,
194
296
  traderBoard: (q: { window?: "1h" | "24h" | "7d" | "all"; limit?: number } = {}): string => `/floor-amm/leaderboards/traders${query({ window: q.window, limit: q.limit })}`,
195
297
  launcherBoard: (q: { limit?: number } = {}): string => `/floor-amm/leaderboards/launchers${query({ limit: q.limit })}`,
196
298
  } as const satisfies Record<IndexerRouteName, (...a: never[]) => string>;
@@ -6,18 +6,21 @@ import * as B from "./bodies.ts";
6
6
  import { indexerPath } from "./paths.ts";
7
7
  import { errorCode } from "./contract.ts";
8
8
  import type { IndexerErrorCode } from "./contract.ts";
9
- import type { CandlesQuery, LaunchesQuery, Page, TradesQuery, WalletTradesQuery } from "./paths.ts";
9
+ import type { CandlesManyQuery, CandlesQuery, LaunchListsQuery, LaunchSearchQuery, LaunchesQuery, Page, TradesQuery, WalletPage, WalletTradesQuery } from "./paths.ts";
10
10
 
11
11
  export * from "./bodies.ts";
12
12
  export { ShapeError, decode } from "./decode.ts";
13
13
  export type { Decoder, Infer } from "./decode.ts";
14
- export { FIRSTS_MAX, IDS_MAX, INDEXER_ROUTES, LAUNCHES_PAGE_MAX, LAUNCH_SORTS, STREAM_STATE_MAX, indexerPath, query } from "./paths.ts";
14
+ export { FIRSTS_MAX, IDS_MAX, INDEXER_ROUTES, LAUNCHES_PAGE_DEFAULT, LAUNCHES_PAGE_MAX, LAUNCH_CURSOR_MAX, LAUNCH_SORTS, PRESET_FILTER_MAX, STREAM_STATE_MAX, INBOX_PAGE_DEFAULT, INBOX_PAGE_MAX, WALLET_CURSOR_MAX, WALLET_PAGE_DEFAULT, WALLET_PAGE_MAX, indexerPath, query } from "./paths.ts";
15
+ export { ADDRESS_PREFIX_MIN, SEARCH_PAGE_DEFAULT, SEARCH_PAGE_MAX, SEARCH_PARITY_CORPUS, SEARCH_Q_MAX, SEARCH_SUBSTRING_MIN, searchFold, searchNeedle, searchNeedles, searchServed, searchServedTier, searchTier, searchTierFolded } from "./search.ts";
16
+ export type { SearchSubject, SearchTier } from "./search.ts";
15
17
  export * from "./partners.ts";
16
- export { INDEXER_CONTRACT, INDEXER_ERROR_CODES, LIMITS, OPEN_ROUTES, ROUTE_NAMES, UNITS, clampLimit, errorCode, matchRoute, queryArg, queryBool, queryLimit, queryRefusal, routeLimit, spanRefusal } from "./contract.ts";
18
+ export * from "./stack-edge.ts";
19
+ export { INDEXER_CONTRACT, INDEXER_ERROR_CODES, LIMITS, OPEN_ROUTES, ROUTE_NAMES, UNITS, clampLimit, errorCode, matchRoute, pageAsked, pageLimit, queryArg, queryBool, queryLimit, queryRefusal, routeLimit, spanRefusal } from "./contract.ts";
17
20
  export type { IndexerErrorCode, Pagination, PathParam, QueryKey, RouteBody, RouteContract, RouteName, Served, ServedBody, ServedKeys, Units } from "./contract.ts";
18
- export { createIndexerClient, routePath } from "./client.ts";
21
+ export { DRAIN_NAMES, createIndexerClient, routePath } from "./client.ts";
19
22
  export type { DrainName, IndexerClient, IndexerClientOptions, ReadName, RouteArgs } from "./client.ts";
20
- export type { CandlesQuery, IndexerRoute, IndexerRouteName, LaunchSort, LaunchesQuery, Page, StreamQuery, TradesQuery, WalletTradesQuery } from "./paths.ts";
23
+ export type { CandlesManyQuery, CandlesQuery, LaunchListsQuery, IndexerRoute, IndexerRouteName, LaunchSearchQuery, LaunchSort, LaunchesQuery, Page, StreamQuery, TradesQuery, WalletPage, WalletTradesQuery } from "./paths.ts";
21
24
 
22
25
  export type LaunchId = string;
23
26
 
@@ -63,8 +66,11 @@ export const readFloorRouted = (get: Get): Promise<B.FloorRouted> => readRoute(g
63
66
 
64
67
  export const readEvents = (get: Get, fromBlock: number, toBlock: number): Promise<B.Events> => readRoute(get, indexerPath.events(fromBlock, toBlock), B.EVENTS);
65
68
 
69
+ export const readLaunchLists = (get: Get, q: LaunchListsQuery): Promise<B.LaunchLists> => readRoute(get, indexerPath.launchLists(q), B.LAUNCH_LISTS);
66
70
  export const readLaunches = (get: Get, q: LaunchesQuery = {}): Promise<B.Launches> => readRoute(get, indexerPath.launches(q), B.LAUNCHES);
67
71
 
72
+ export const readLaunchSearch = (get: Get, q: LaunchSearchQuery): Promise<B.LaunchSearch> => readRoute(get, indexerPath.search(q), B.LAUNCH_SEARCH);
73
+
68
74
  export const readLaunch = (get: Get, id: LaunchId): Promise<At & { launch: B.ListedLaunch }> => readRoute(get, indexerPath.launch(id), B.LAUNCH_ONE);
69
75
 
70
76
  export const readLaunchState = (get: Get, id: LaunchId): Promise<B.LaunchState> => readRoute(get, indexerPath.launchState(id), B.LAUNCH_STATE);
@@ -73,10 +79,10 @@ export const readMilestones = (get: Get, id: LaunchId): Promise<B.LaunchMileston
73
79
  export const readHolders = (get: Get, id: LaunchId, q: { limit?: number } = {}): Promise<B.Holders> => readRoute(get, indexerPath.holders(id, q), B.HOLDERS);
74
80
 
75
81
  export const readTrades = (get: Get, id: LaunchId, q: TradesQuery = {}): Promise<B.Trades> => readRoute(get, indexerPath.trades(id, q), B.TRADES);
76
- export const readLaunchClaims = (get: Get, id: LaunchId, q: { claimer?: string } = {}): Promise<At & { claims: B.LaunchClaim[] }> => readRoute(get, indexerPath.launchClaims(id, q), B.LAUNCH_CLAIMS);
77
- export const readDevBuys = (get: Get, id: LaunchId): Promise<B.DevBuys> => readRoute(get, indexerPath.devBuys(id), B.DEV_BUYS);
82
+ export const readLaunchClaims = (get: Get, id: LaunchId, q: Page & { claimer?: string } = {}): Promise<B.LaunchClaims> => readRoute(get, indexerPath.launchClaims(id, q), B.LAUNCH_CLAIMS);
83
+ export const readDevBuys = (get: Get, id: LaunchId, q: Page = {}): Promise<B.DevBuys> => readRoute(get, indexerPath.devBuys(id, q), B.DEV_BUYS);
78
84
 
79
- export const readMemberSold = (get: Get, id: LaunchId): Promise<B.MemberSoldBody> => readRoute(get, indexerPath.memberSold(id), B.MEMBER_SOLD);
85
+ export const readMemberSold = (get: Get, id: LaunchId, q: Page = {}): Promise<B.MemberSoldBody> => readRoute(get, indexerPath.memberSold(id, q), B.MEMBER_SOLD);
80
86
 
81
87
  export const readLaunchAccount = (get: Get, id: LaunchId): Promise<B.LaunchAccountBody> => readRoute(get, indexerPath.launchAccount(id), B.LAUNCH_ACCOUNT);
82
88
 
@@ -91,31 +97,35 @@ export const readTraders = (get: Get, id: LaunchId, q: { window?: B.TraderWindow
91
97
  export const readQuoteChain = (get: Get, id: LaunchId): Promise<B.QuoteChain> => readRoute(get, indexerPath.quoteChain(id), B.QUOTE_CHAIN);
92
98
 
93
99
  export const readDevTrades = (get: Get, id: LaunchId, q: { limit?: number } = {}): Promise<B.DevTrades> => readRoute(get, indexerPath.devTrades(id, q), B.DEV_TRADES);
94
- export const readBurns = (get: Get, id: LaunchId): Promise<B.Burns> => readRoute(get, indexerPath.burns(id), B.BURNS);
100
+ export const readBurns = (get: Get, id: LaunchId, q: Page = {}): Promise<B.Burns> => readRoute(get, indexerPath.burns(id, q), B.BURNS);
95
101
  export const readLaunchLocks = (get: Get, id: LaunchId): Promise<B.LaunchLocks> => readRoute(get, indexerPath.launchLocks(id), B.LAUNCH_LOCKS);
96
102
 
97
103
  export const readMarks = (get: Get, id: LaunchId, q: Page = {}): Promise<B.Marks> => readRoute(get, indexerPath.marks(id, q), B.MARKS);
98
104
  export const readPrice = (get: Get, id: LaunchId): Promise<B.Price> => readRoute(get, indexerPath.price(id), B.PRICE);
99
105
 
100
106
  export const readCandles = (get: Get, q: CandlesQuery): Promise<B.Candles> => readRoute(get, indexerPath.candles(q), B.CANDLES);
107
+
108
+ export const readCandlesMany = (get: Get, q: CandlesManyQuery): Promise<B.CandlesMany> => readRoute(get, indexerPath.candlesMany(q), B.CANDLES_MANY);
101
109
  export const readCandleBundle = (get: Get, id: LaunchId, q: { intervals?: readonly string[]; limit?: number } = {}): Promise<B.CandleBundle> => readRoute(get, indexerPath.candleBundle(id, q), B.CANDLE_BUNDLE);
102
110
  export const readHighs = (get: Get, id: LaunchId, q: { atLeast?: bigint | string; limit?: number } = {}): Promise<B.Highs> => readRoute(get, indexerPath.highs(id, q), B.HIGHS);
103
111
 
104
112
  export const readWalletTrades = (get: Get, wallet: string, q: WalletTradesQuery = {}): Promise<B.WalletTrades> => readRoute(get, indexerPath.walletTrades(wallet, q), B.WALLET_TRADES);
105
- export const readPositions = (get: Get, wallet: string): Promise<B.Positions> => readRoute(get, indexerPath.positions(wallet), B.POSITIONS);
113
+ export const readTonActivity = (get: Get, wallet: string, q: Page = {}): Promise<B.TonActivity> => readRoute(get, indexerPath.tonActivity(wallet, q), B.TON_ACTIVITY);
114
+ export const readTonOutcome = (get: Get, wallet: string, queryId: bigint | string): Promise<B.TonOutcome> => readRoute(get, indexerPath.tonOutcome(wallet, queryId), B.TON_OUTCOME);
115
+ export const readPositions = (get: Get, wallet: string, q: WalletPage = {}): Promise<B.Positions> => readRoute(get, indexerPath.positions(wallet, q), B.POSITIONS);
106
116
 
107
- export const readInbox = (get: Get, wallet: string, q: { limit?: number } = {}): Promise<B.Inbox> => readRoute(get, indexerPath.inbox(wallet, q), B.INBOX);
108
- export const readWalletLocks = (get: Get, wallet: string): Promise<B.WalletLocks> => readRoute(get, indexerPath.walletLocks(wallet), B.WALLET_LOCKS);
109
- export const readClaimHistory = (get: Get, wallet: string): Promise<B.ClaimHistory> => readRoute(get, indexerPath.claimHistory(wallet), B.CLAIM_HISTORY);
117
+ export const readInbox = (get: Get, wallet: string, q: { limit?: number; before?: string } = {}): Promise<B.Inbox> => readRoute(get, indexerPath.inbox(wallet, q), B.INBOX);
118
+ export const readWalletLocks = (get: Get, wallet: string, q: WalletPage = {}): Promise<B.WalletLocks> => readRoute(get, indexerPath.walletLocks(wallet, q), B.WALLET_LOCKS);
119
+ export const readClaimHistory = (get: Get, wallet: string, q: WalletPage = {}): Promise<B.ClaimHistory> => readRoute(get, indexerPath.claimHistory(wallet, q), B.CLAIM_HISTORY);
110
120
 
111
- export const readClaimView = (get: Get, wallet: string): Promise<B.ClaimView> => readRoute(get, indexerPath.claimView(wallet), B.CLAIM_VIEW);
121
+ export const readClaimView = (get: Get, wallet: string, q: WalletPage = {}): Promise<B.ClaimView> => readRoute(get, indexerPath.claimView(wallet, q), B.CLAIM_VIEW);
112
122
  export const readFirsts = (get: Get, wallet: string): Promise<At & { wallet: string } & B.Firsts> => readRoute(get, indexerPath.firsts(wallet), B.FIRSTS);
113
123
 
114
124
  export const readFirstsMany = (get: Get, wallets: readonly string[]): Promise<At & { wallets: Record<string, B.Firsts> }> => readRoute(get, indexerPath.firstsMany(wallets), B.FIRSTS_MANY);
115
- export const readPeople = (get: Get, wallet: string): Promise<B.People> => readRoute(get, indexerPath.people(wallet), B.PEOPLE);
116
- export const readRoles = (get: Get, wallet: string): Promise<B.Roles> => readRoute(get, indexerPath.roles(wallet), B.ROLES);
125
+ export const readPeople = (get: Get, wallet: string, q: WalletPage = {}): Promise<B.People> => readRoute(get, indexerPath.people(wallet, q), B.PEOPLE);
126
+ export const readRoles = (get: Get, wallet: string, q: WalletPage = {}): Promise<B.Roles> => readRoute(get, indexerPath.roles(wallet, q), B.ROLES);
117
127
 
118
- export const readHandlePlaces = (get: Get, handle: string): Promise<B.HandlePlaces> => readRoute(get, indexerPath.handlePlaces(handle), B.HANDLE_PLACES);
128
+ export const readHandlePlaces = (get: Get, handle: string, q: WalletPage = {}): Promise<B.HandlePlaces> => readRoute(get, indexerPath.handlePlaces(handle, q), B.HANDLE_PLACES);
119
129
 
120
130
  export const readTraderBoard = (get: Get, q: { window?: B.TraderWindow; limit?: number } = {}): Promise<B.TraderBoard> => readRoute(get, indexerPath.traderBoard(q), B.TRADER_BOARD);
121
131
  export const readLauncherBoard = (get: Get, q: { limit?: number } = {}): Promise<B.LauncherBoard> => readRoute(get, indexerPath.launcherBoard(q), B.LAUNCHER_BOARD);
@@ -130,3 +140,12 @@ export function offPriceBps(price: Pick<B.Price, "livePriceX64">, quotedX64: big
130
140
  if (p === 0n) return null;
131
141
  return Number(((quotedX64 - p) * 10_000n) / p);
132
142
  }
143
+
144
+ export interface CursorPage<T> {
145
+ rows: readonly T[];
146
+ next: string | null;
147
+ }
148
+ export function cursorPage<K extends string, T>(body: { readonly [k in K]: readonly T[] } & { next?: string | null }, rows: K): CursorPage<T> {
149
+ if (body.next === undefined) throw new Error(`not a page: the body has no next (rows ${rows})`);
150
+ return { rows: body[rows], next: body.next };
151
+ }
@@ -0,0 +1,138 @@
1
+
2
+
3
+ export const SEARCH_Q_MAX = 64;
4
+
5
+ export const SEARCH_PAGE_DEFAULT = 12;
6
+
7
+ export const SEARCH_PAGE_MAX = 100;
8
+
9
+ export const ADDRESS_PREFIX_MIN = 4;
10
+
11
+ export const SEARCH_SUBSTRING_MIN = 3;
12
+
13
+ export type SearchTier = 0 | 1 | 2 | 3 | 4 | 5;
14
+
15
+ export interface SearchSubject {
16
+ name: string | null;
17
+ symbol: string | null;
18
+ token: string;
19
+ }
20
+
21
+ export function searchFold(s: string): string {
22
+ return s.normalize("NFKC").toLowerCase().replace(/\s+/g, " ").trim();
23
+ }
24
+
25
+ export function searchNeedles(q: string): string[] {
26
+ const f = searchFold(q);
27
+ if (!f.startsWith("$")) return f === "" ? [] : [f];
28
+ const bare = f.slice(1).trim();
29
+ return bare === "" ? [f] : [bare, f];
30
+ }
31
+
32
+ export function searchNeedle(q: string): string {
33
+ return searchNeedles(q)[0] ?? "";
34
+ }
35
+
36
+ export function searchTierFolded(name: string, symbol: string, token: string, n: string): SearchTier | null {
37
+ if (n === "") return null;
38
+ if (symbol === n || name === n || token === n) return 0;
39
+ if (symbol.startsWith(n)) return 1;
40
+ if (name.startsWith(n) || name.includes(` ${n}`)) return 2;
41
+ if (symbol.includes(n) || name.includes(n)) return 3;
42
+ if (token.startsWith(n)) return 4;
43
+ if ((name + symbol + token).includes(n)) return 5;
44
+ return null;
45
+ }
46
+
47
+ export function searchServed(tier: SearchTier, needle: string): boolean {
48
+ const n = [...needle].length;
49
+ if (tier <= 2) return true;
50
+ if (tier === 3) return n >= SEARCH_SUBSTRING_MIN;
51
+ if (tier === 4) return n >= ADDRESS_PREFIX_MIN;
52
+ return false;
53
+ }
54
+
55
+ export function searchTier(l: SearchSubject, q: string): SearchTier | null {
56
+ const name = searchFold(l.name ?? ""), symbol = searchFold(l.symbol ?? ""), token = searchFold(l.token);
57
+ let best: SearchTier | null = null;
58
+ for (const n of searchNeedles(q)) {
59
+ const t = searchTierFolded(name, symbol, token, n);
60
+ if (t !== null && (best === null || t < best)) best = t;
61
+ }
62
+ return best;
63
+ }
64
+
65
+ export function searchServedTier(l: SearchSubject, q: string): SearchTier | null {
66
+ const name = searchFold(l.name ?? ""), symbol = searchFold(l.symbol ?? ""), token = searchFold(l.token);
67
+ let best: SearchTier | null = null;
68
+ for (const n of searchNeedles(q)) {
69
+ const t = searchTierFolded(name, symbol, token, n);
70
+ if (t !== null && searchServed(t, n) && (best === null || t < best)) best = t;
71
+ }
72
+ return best;
73
+ }
74
+
75
+ const SOL = "So11111111111111111111111111111111111111112";
76
+ const EVM = "0xabCDeF0123456789AbcdEf0123456789aBCDEF01";
77
+
78
+ export const SEARCH_PARITY_CORPUS: readonly (readonly [string | null, string | null, string, string, SearchTier | null])[] = [
79
+
80
+ ["Doge Wif Hat", "WIF", SOL, "wif", 0],
81
+ ["Doge Wif Hat", "WIF", SOL, "WIF", 0],
82
+ ["Doge Wif Hat", "WIF", SOL, "$wif", 0],
83
+ ["Doge Wif Hat", "WIF", SOL, " doge wif hat ", 0],
84
+ ["Doge Wif Hat", "WIF", SOL, SOL, 0],
85
+ ["Doge Wif Hat", "WIF", EVM, EVM.toLowerCase(), 0],
86
+ ["Doge Wif Hat", "WIF", EVM, EVM.toUpperCase().replace("0X", "0x"), 0],
87
+ ["FLOOR", "FLR", SOL, "flr", 0],
88
+ ["Café", "CAFE", SOL, "café", 0],
89
+ ["Café", "CF", SOL, "café", 0],
90
+ ["Ⅻ Club", "XII", SOL, "xii", 0],
91
+ ["Dog", "DOG", SOL, "$dog", 0],
92
+
93
+ ["Moon Rocket", "MOONR", SOL, "moo", 1],
94
+ ["Moon Rocket", "MOONR", SOL, "$MOO", 1],
95
+ ["Moon Rocket", "MOONR", SOL, "moo", 1],
96
+
97
+ ["Moon Rocket", "MR", SOL, "moon", 2],
98
+ ["Moon Rocket", "MR", SOL, "rock", 2],
99
+ ["Moon Rocket", "MR", SOL, "moon rock", 2],
100
+ ["Moon\tRocket", "MR", SOL, "moon r", 2],
101
+ ["The Big Dog", "TBD", SOL, "big d", 2],
102
+
103
+ ["Moon Rocket", "MR", SOL, "ocke", 3],
104
+ ["Moon Rocket", "XMOONX", SOL, "oon", 3],
105
+ ["Pepe", "PEPE", SOL, "ep", 3],
106
+ ["Pepe Coin", "PC", SOL, "pe c", 3],
107
+
108
+ ["Moon Rocket", "MR", SOL, "so1", 4],
109
+ ["Moon Rocket", "MR", SOL, "so11", 4],
110
+ ["Moon Rocket", "MR", EVM, "0xab", 4],
111
+ ["Moon Rocket", "MR", EVM, "0xA", 4],
112
+
113
+ ["Moon Rocket", "MR", SOL, "1111", 5],
114
+ ["Moon Rocket", "MR", EVM, "cdef01", 5],
115
+ ["Moon Rocket", "MR", SOL, "rocketmr", 5],
116
+ ["Moon Rocket", "MR", SOL, "mrso", 5],
117
+
118
+ [null, "ZED", SOL, "zed", 0],
119
+ [null, null, SOL, "zed", null],
120
+ ["Zed", null, SOL, "ze", 2],
121
+ [null, null, SOL, "so11", 4],
122
+
123
+ ["Moon Rocket", "MR", SOL, "venus", null],
124
+ ["Moon Rocket", "MR", SOL, "", null],
125
+ ["Moon Rocket", "MR", SOL, " ", null],
126
+ ["Moon Rocket", "MR", SOL, "$", null],
127
+
128
+ ["$$ Bills", "BILL", SOL, "$$", 2],
129
+ ["Bills", "$BILL", SOL, "$$bill", 0],
130
+
131
+ ["Big Money", "BM", SOL, "$ money", 2],
132
+
133
+ ["$WIF Coin", "$WIF", SOL, "$wif", 0],
134
+ ["Doge Wif Hat", "WIF", SOL, "$wif", 0],
135
+ ["$1 Coin", "ONE", SOL, "$1", 2],
136
+ ["Cash $ Money", "CASH", SOL, "$", 2],
137
+ ["Cash $ Money", "CASH", SOL, " $ ", 2],
138
+ ];
@@ -0,0 +1,46 @@
1
+
2
+
3
+ export interface StackEdgeBar {
4
+ time: number;
5
+ high: number;
6
+ close: number;
7
+ }
8
+
9
+ export interface StackEdgePoint {
10
+ i: number;
11
+ edge: number;
12
+ }
13
+
14
+ function startBar(bars: readonly StackEdgeBar[], graduatedAt: number): number {
15
+ let start = 0;
16
+ for (let j = 0; j < bars.length; j++) {
17
+ if (bars[j]!.time <= graduatedAt) start = j;
18
+ else break;
19
+ }
20
+ return start;
21
+ }
22
+
23
+ export function stackEdgeWalk(bars: readonly StackEdgeBar[], graduatedAt: number, endPrice: number | null): StackEdgePoint[] {
24
+ const out: StackEdgePoint[] = [];
25
+ let m = 0;
26
+ for (let j = startBar(bars, graduatedAt); j < bars.length; j++) {
27
+ const b = bars[j]!;
28
+ if (!(b.close > 0) || !(b.high > 0)) continue;
29
+ m = Math.max(m, b.high);
30
+ if (endPrice !== null && endPrice > 0 && m >= endPrice) break;
31
+ out.push({ i: j, edge: m });
32
+ }
33
+ return out;
34
+ }
35
+
36
+ export function stackEdgeEnd(bars: readonly StackEdgeBar[], graduatedAt: number, endPrice: number | null): number | null {
37
+ if (endPrice === null || !(endPrice > 0)) return null;
38
+ let m = 0;
39
+ for (let j = startBar(bars, graduatedAt); j < bars.length; j++) {
40
+ const b = bars[j]!;
41
+ if (!(b.close > 0) || !(b.high > 0)) continue;
42
+ m = Math.max(m, b.high);
43
+ if (m >= endPrice) return j;
44
+ }
45
+ return null;
46
+ }