@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
@@ -38,17 +38,24 @@ export interface ChainRow {
38
38
  name: ChainName;
39
39
 
40
40
  label: string;
41
- family: "solana" | "evm";
41
+ family: "solana" | "evm" | "ton";
42
42
  v2DayOne: boolean;
43
43
  chainId?: number;
44
44
  cluster?: string;
45
+
46
+ network?: string;
47
+ globalId?: number;
48
+
49
+ nativeDecimals?: number;
45
50
  native: string;
46
51
 
47
52
  nativeName: string;
48
53
 
49
54
  floorAmmAddress?: string | null;
55
+
56
+ tonFactoryAddress?: string | null;
50
57
  rpcEnv: string;
51
- soak: { name?: string; chainId?: number; cluster?: string; rpcEnv: string };
58
+ soak: { name?: string; chainId?: number; cluster?: string; network?: string; globalId?: number; rpcEnv: string };
52
59
  explorer: ExplorerRow;
53
60
  quotes: readonly QuoteRow[];
54
61
  }
@@ -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
  ] as const;
115
144
 
116
- export const CHAIN_SLUGS = ["solana","ethereum","base","bsc","arbitrum","arc","robinhood","hyperevm"] as const;
145
+ export const CHAIN_SLUGS = ["solana","ethereum","base","bsc","arbitrum","arc","robinhood","hyperevm","elysium","ton"] as const;
146
+
147
+ export const EVM_CHAIN_SLUGS = ["ethereum","base","bsc","arbitrum","arc","robinhood","hyperevm","elysium"] as const;
117
148
 
118
- export const EVM_CHAIN_SLUGS = ["ethereum","base","bsc","arbitrum","arc","robinhood","hyperevm"] as const;
149
+ export const TON_CHAIN_SLUGS = ["ton"] as const;
@@ -24,11 +24,12 @@ export interface SolLaunchCreatedFields {
24
24
  }
25
25
  export interface SolGraduatedFields {
26
26
  launch: string;
27
- priceX64: bigint;
27
+ windowPriceX64: bigint;
28
28
  windowRaised: bigint;
29
29
  windowTokens: bigint;
30
30
  slot: bigint;
31
31
  ts: bigint;
32
+ priceX64: bigint;
32
33
  }
33
34
  export interface SolPotsSweptFields {
34
35
  launch: string;
package/src/evm/chains.ts CHANGED
@@ -109,6 +109,14 @@ const ROUTES: Record<ChainKey, Omit<EvmChain, "key" | "chainId" | "name" | "nati
109
109
  "⚠ 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.",
110
110
  ],
111
111
  },
112
+ elysium: {
113
+ wrappedNative: null,
114
+ zapRouters: [],
115
+ notes: [
116
+ "⚠ Arbitrum Orbit on HyperEVM: in a contract block.number is HyperEVM's block; the receipt's block is Elysium's.",
117
+ "⚠ No zap routers yet (no DEX read back on chain) and no wrapped HYPE address published: the native coin and listed quotes only.",
118
+ ],
119
+ },
112
120
  };
113
121
 
114
122
  export const EVM_CHAINS: Record<ChainKey, EvmChain> = Object.fromEntries(
@@ -133,7 +141,7 @@ export const FLOOR_SALTS = {
133
141
  export const FLOOR_AMM_ADDRESS: string | null = "0xF10000bd05c2C01793C6d55F027346469683d225";
134
142
 
135
143
  export const FLOOR_AMM_FROM_BLOCK: Readonly<Record<ChainKey, number | null>> = {
136
- ethereum: 26327910, base: 53421827, bsc: 131270813, arbitrum: 520655168, arc: 29205598, robinhood: 104455459, hyperevm: null,
144
+ ethereum: 26327910, base: 53421827, bsc: 131270813, arbitrum: 520655168, arc: 29205598, robinhood: 104455459, hyperevm: 50398055, elysium: 6058368,
137
145
  };
138
146
 
139
147
  const cat = (...h: string[]): string => "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.ts";
4
4
  import { decodeEventLog, itemTopic } from "../items.ts";
5
5
  import type { EventArgsOf, EventName, Log } from "../items.ts";
6
+ import { LEGACY_CLAIMED_TOPIC, LEGACY_EVENTS, normalizeLegacyClaimed } from "./legacy-events.ts";
6
7
  import { FLOOR_AMM_ABI, FLOOR_AMM_UNFROZEN_EVENTS, FLOOR_ZAP_ABI } from "./iface.ts";
7
8
 
8
9
  export type FloorEventName = EventName<typeof FLOOR_AMM_ABI> | EventName<typeof FLOOR_ZAP_ABI>;
@@ -15,6 +16,8 @@ export interface FloorEvmEvent {
15
16
  address?: string;
16
17
 
17
18
  unfrozen?: true;
19
+
20
+ legacy?: true;
18
21
  }
19
22
 
20
23
  const ALL = [...FLOOR_AMM_ABI, ...FLOOR_ZAP_ABI, ...FLOOR_AMM_UNFROZEN_EVENTS];
@@ -38,10 +41,17 @@ for (const i of ALL.filter((i) => i.type === "event").reverse()) {
38
41
  });
39
42
  }
40
43
 
44
+ export const FLOOR_LEGACY_EVENT_TOPICS: Record<string, string> = { Claimed: LEGACY_CLAIMED_TOPIC };
45
+
41
46
  export function decodeFloorLog(log: Log, from?: readonly string[]): FloorEvmEvent | null {
42
47
  if (from && (!log.address || !from.some((a) => a.toLowerCase() === log.address!.toLowerCase()))) return null;
43
48
  const d: FloorEvmEvent | null = decodeEventLog(ALL, log);
44
- if (!d) return null;
49
+ if (!d) {
50
+ const old = decodeEventLog(LEGACY_EVENTS, log);
51
+ if (!old) return null;
52
+ const e: FloorEvmEvent = { ...old, args: normalizeLegacyClaimed(old.args), legacy: true };
53
+ return log.address ? { ...e, address: checksumAddress(log.address) } : e;
54
+ }
45
55
  if (UNFROZEN().has((log.topics[0] ?? "").toLowerCase())) d.unfrozen = true;
46
56
  return log.address ? { ...d, address: checksumAddress(log.address) } : d;
47
57
  }
@@ -0,0 +1,27 @@
1
+
2
+
3
+ import type { AbiItem } from "../items.ts";
4
+
5
+ export const LEGACY_CLAIMED_SIGNATURE =
6
+ "Claimed(address,address,address,uint8,uint256,uint256,uint256,uint256,uint256,uint256,uint256)";
7
+ export const LEGACY_CLAIMED_TOPIC = "0x586c69c7198e9e5c48c058d0267bd1388a73f9a8878aeb9d72d25331acc39aeb";
8
+
9
+ export const LEGACY_EVENTS: readonly AbiItem[] = [
10
+ {
11
+ type: "event", name: "Claimed", anonymous: false, inputs: [
12
+ { name: "wallet", type: "address", indexed: true }, { name: "sender", type: "address", indexed: true },
13
+ { name: "quote", type: "address", indexed: true }, { name: "types", type: "uint8", indexed: false },
14
+ { name: "creator", type: "uint256", indexed: false }, { name: "creatorRef", type: "uint256", indexed: false },
15
+ { name: "teamSlot", type: "uint256", indexed: false }, { name: "traderRef", type: "uint256", indexed: false },
16
+ { name: "holder", type: "uint256", indexed: false }, { name: "extra", type: "uint256", indexed: false },
17
+ { name: "amount", type: "uint256", indexed: false },
18
+ ],
19
+ },
20
+ ];
21
+
22
+ export const CLAIM_HOLDER_BIT = 512n;
23
+
24
+ export function normalizeLegacyClaimed(args: Record<string, any>): Record<string, any> {
25
+ const types = BigInt(args.types);
26
+ return { ...args, types: BigInt(args.holder) > 0n ? types | CLAIM_HOLDER_BIT : types };
27
+ }
@@ -1,6 +1,6 @@
1
1
 
2
2
 
3
- import { array, big, bool, decimal, int, nullable, object, oneOf, optional, record, str } from "./decode.ts";
3
+ import { ShapeError, array, big, bool, decimal, int, nullable, object, oneOf, optional, record, str } from "./decode.ts";
4
4
  import type { Decoder, Infer } from "./decode.ts";
5
5
  import type { DevBuy, DevBuyRole } from "../v2/devbuy.ts";
6
6
 
@@ -30,6 +30,7 @@ export const DEV_BUY = object({
30
30
  block: int,
31
31
  timestamp: int,
32
32
  tx: str,
33
+ id: str,
33
34
  });
34
35
 
35
36
  export type DevBuyItem = Infer<typeof DEV_BUY>;
@@ -103,6 +104,12 @@ const LAUNCH_FIELDS = {
103
104
  unlisted: bool,
104
105
  quoteDecimals: nullable(int),
105
106
  teamSlotRateBps: nullable(int),
107
+
108
+ nextBuyPriceX64: optional(nullable(big)),
109
+ stackEndX64: optional(nullable(big)),
110
+ stackLeft: optional(nullable(big)),
111
+ stackSold: optional(nullable(big)),
112
+ stackSoldBps: optional(nullable(int)),
106
113
  bidTopX64: nullable(big),
107
114
  teamBuyUnlockAt: nullable(int),
108
115
  teamBuyUnlocked: bool,
@@ -123,17 +130,25 @@ const LAUNCH_FIELDS = {
123
130
  export const LAUNCH = object(LAUNCH_FIELDS);
124
131
  export type Launch = Infer<typeof LAUNCH>;
125
132
 
126
- export const LISTED_LAUNCH = object({
133
+ const LISTED_FIELDS = {
127
134
  ...LAUNCH_FIELDS,
128
135
  volume24hGross: nullable(big),
129
136
  holders: int,
137
+
138
+ maxLossPpm: optional(nullable(int)),
139
+
130
140
  backedPpm: nullable(int),
131
141
  volume24hUsd: nullable(decimal),
132
142
  marketCapUsd: nullable(decimal),
133
- });
143
+
144
+ trendingScore: nullable(big),
145
+
146
+ change24hBps: optional(nullable(int)),
147
+ };
148
+ export const LISTED_LAUNCH = object(LISTED_FIELDS);
134
149
  export type ListedLaunch = Infer<typeof LISTED_LAUNCH>;
135
150
 
136
- export const LIVE_LAUNCH = object({ ...LAUNCH_FIELDS, volume24hGross: nullable(big), holders: int });
151
+ export const LIVE_LAUNCH = object({ ...LAUNCH_FIELDS, volume24hGross: nullable(big), holders: int, change24hBps: optional(nullable(int)) });
137
152
  export type LiveLaunch = Infer<typeof LIVE_LAUNCH>;
138
153
 
139
154
  const TRADE_FIELDS = {
@@ -224,6 +239,8 @@ export const FLOOR_ROUTED = object({
224
239
  indexed,
225
240
  launches: array(object({ launch: str, quote: str, floorFee: big, floorMilestone: big })),
226
241
  pending: array(object({ quote: str, amount: big })),
242
+
243
+ next: optional(nullable(str)),
227
244
  });
228
245
  export type FloorRouted = Infer<typeof FLOOR_ROUTED>;
229
246
 
@@ -247,11 +264,25 @@ export const EVENTS = object({
247
264
  });
248
265
  export type Events = Infer<typeof EVENTS>;
249
266
 
250
- export const LAUNCHES_ALL = object({ indexed, launches: array(LISTED_LAUNCH) });
267
+ const nextCursor: Decoder<string | null> = (v, p) => (v === undefined || v === null ? null : str(v, p));
251
268
 
252
- export const LAUNCHES = object({ indexed, total: int, offset: int, launches: array(LISTED_LAUNCH), missing: array(str) });
269
+ const perRow = <T>(d: Decoder<T>): Decoder<T[]> => (v, p) => (v === undefined ? [] : array(d)(v, p));
270
+
271
+ export const LAUNCHES = object({
272
+ indexed, total: int, offset: int, launches: array(LISTED_LAUNCH), missing: array(str),
273
+ cursors: perRow(str), keys: perRow(nullable(str)), next: optional(nullable(str)),
274
+ });
253
275
  export type Launches = Infer<typeof LAUNCHES>;
254
276
 
277
+ const SEARCH_SERVED_TIER: Decoder<0 | 1 | 2 | 3 | 4> = (v, p) => {
278
+ const n = int(v, p);
279
+ if (n < 0 || n > 4) throw new ShapeError(p, "a tier 0..4", v);
280
+ return n as 0 | 1 | 2 | 3 | 4;
281
+ };
282
+
283
+ export const LAUNCH_SEARCH = object({ indexed, q: str, launches: array(object({ ...LISTED_FIELDS, tier: SEARCH_SERVED_TIER })), next: nextCursor });
284
+ export type LaunchSearch = Infer<typeof LAUNCH_SEARCH>;
285
+
255
286
  export const LAUNCH_ONE = object({ indexed, launch: LISTED_LAUNCH });
256
287
 
257
288
  export const LAUNCH_STATE = object({ launch: str, mint: str, block: nullable(int), ts: nullable(int), seq: int, state: LIVE_LAUNCH });
@@ -266,13 +297,22 @@ export type Holders = Infer<typeof HOLDERS>;
266
297
  export const TRADES = object({ indexed, trades: array(PAGED_TRADE), next: nullable(str) });
267
298
  export type Trades = Infer<typeof TRADES>;
268
299
 
269
- 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 });
300
+ 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) });
270
301
  export type LaunchClaim = Infer<typeof LAUNCH_CLAIM>;
271
- export const LAUNCH_CLAIMS = object({ indexed, claims: array(LAUNCH_CLAIM) });
302
+ export const LAUNCH_CLAIMS = object({ indexed, claims: array(LAUNCH_CLAIM), next: optional(nullable(str)) });
303
+ export type LaunchClaims = Infer<typeof LAUNCH_CLAIMS>;
272
304
 
273
- export const DEV_BUYS = object({ indexed, teamBuyUnlocked: bool, teamBuyUnlockedTs: nullable(int), devBuys: array(DEV_BUY) });
305
+ export const DEV_BUYS = object({ indexed, teamBuyUnlocked: bool, teamBuyUnlockedTs: nullable(int), devBuys: array(DEV_BUY), next: optional(nullable(str)) });
274
306
  export type DevBuys = Infer<typeof DEV_BUYS>;
275
307
 
308
+ export const MEMBER_SOLD_ROW = object({ launch: str, member: str, place: int, amount: big, quoteOut: big, block: int, timestamp: int, tx: str, id: str });
309
+ export type MemberSoldRow = Infer<typeof MEMBER_SOLD_ROW>;
310
+ export const MEMBER_SOLD = object({ indexed, memberSold: array(MEMBER_SOLD_ROW), next: optional(nullable(str)) });
311
+ export type MemberSoldBody = Infer<typeof MEMBER_SOLD>;
312
+
313
+ export const LAUNCH_ACCOUNT = object({ indexed, launch: str, mint: str, slot: int, data: str });
314
+ export type LaunchAccountBody = Infer<typeof LAUNCH_ACCOUNT>;
315
+
276
316
  export const CANDLE_INTERVALS = ["1s", "5s", "1m", "5m", "15m", "1h", "4h", "1d"] as const;
277
317
  export type CandleInterval = (typeof CANDLE_INTERVALS)[number];
278
318
 
@@ -303,6 +343,8 @@ export const CANDLE = object({
303
343
  volumeSellQuoteRaw: big,
304
344
  buys: int,
305
345
  sells: int,
346
+
347
+ floorX64: optional(nullable(big)),
306
348
  });
307
349
  export type Candle = Infer<typeof CANDLE>;
308
350
 
@@ -358,7 +400,7 @@ export type QuoteChain = Infer<typeof QUOTE_CHAIN>;
358
400
  export const DEV_TRADES = object({ indexed, launch: str, creator: str, trades: array(TRADE) });
359
401
  export type DevTrades = Infer<typeof DEV_TRADES>;
360
402
 
361
- export const BURNS = object({ indexed, launch: str, burns: array(object({ amount: big, block: int, timestamp: int })), program: array(BURN), wallet: array(BURN) });
403
+ 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)) });
362
404
  export type Burns = Infer<typeof BURNS>;
363
405
 
364
406
  const LOCK_HOLDER = object({ wallet: str, place: nullable(int) });
@@ -384,6 +426,9 @@ export const PRICE = object({
384
426
  priceX64: big,
385
427
  livePriceX64: big,
386
428
  floorX64: big,
429
+
430
+ maxLossPpm: optional(nullable(int)),
431
+
387
432
  backedPpm: int,
388
433
  bidTopX64: nullable(big),
389
434
  lastTrade: nullable(object({ priceAfterX64: big, timestamp: int, block: int })),
@@ -397,17 +442,50 @@ export type Price = Infer<typeof PRICE>;
397
442
  export const WALLET_TRADES = object({ indexed, wallet: str, trades: array(PAGED_TRADE), next: nullable(str) });
398
443
  export type WalletTrades = Infer<typeof WALLET_TRADES>;
399
444
 
400
- export const POSITIONS = object({ indexed, wallet: str, positions: array(object({ launch: str, token: str, quote: str, tokens: big })) });
445
+ export const TON_ACTIVITY_KINDS = ["buy", "sell", "claim", "team_slot_add", "team_share_buy", "burn", "withdraw", "create", "unlock_team_buy", "backing", "refused", "aborted"] as const;
446
+
447
+ export const TON_FILL = object({ tokensIn: nullable(big), tokensOut: nullable(big), quoteIn: nullable(big), quoteOut: nullable(big), refund: nullable(big) });
448
+ export type TonFill = Infer<typeof TON_FILL>;
449
+
450
+ export const TON_REASON = object({ code: oneOf("aborted", "refused"), op: nullable(int), class: nullable(int), refunded: nullable(big) });
451
+ export type TonReason = Infer<typeof TON_REASON>;
452
+
453
+ export const TON_ACTIVITY_ROW = object({
454
+ id: str,
455
+ txnId: str,
456
+ block: int,
457
+ timestamp: int,
458
+ kind: oneOf(...TON_ACTIVITY_KINDS),
459
+ status: oneOf("landed", "failed"),
460
+ final: bool,
461
+ launch: nullable(str),
462
+ quote: nullable(str),
463
+ queryId: nullable(str),
464
+ types: nullable(int),
465
+ fill: TON_FILL,
466
+ reason: nullable(TON_REASON),
467
+ });
468
+ export type TonActivityRow = Infer<typeof TON_ACTIVITY_ROW>;
469
+
470
+ export const TON_ACTIVITY = object({ indexed, wallet: str, activity: array(TON_ACTIVITY_ROW), next: nullable(str) });
471
+ export type TonActivity = Infer<typeof TON_ACTIVITY>;
472
+
473
+ export const TON_OUTCOME = object({ indexed, wallet: str, queryId: str, outcome: oneOf("pending", "landed", "failed"), seen: bool, row: nullable(TON_ACTIVITY_ROW) });
474
+ export type TonOutcome = Infer<typeof TON_OUTCOME>;
475
+
476
+ export const POSITIONS = object({ indexed, wallet: str, positions: array(object({ launch: str, token: str, quote: str, tokens: big })), next: optional(nullable(str)) });
401
477
  export type Positions = Infer<typeof POSITIONS>;
402
478
 
403
479
  export const WALLET_LOCKS = object({
404
480
  indexed,
405
481
  wallet: str,
406
482
  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) })),
483
+
484
+ next: optional(nullable(str)),
407
485
  });
408
486
  export type WalletLocks = Infer<typeof WALLET_LOCKS>;
409
487
 
410
- const AT = { timestamp: int, block: int };
488
+ const AT = { timestamp: int, block: int, id: optional(str) };
411
489
 
412
490
  export const INBOX_CLAIMED = object({ ...AT, kind: oneOf("claimed"), launch: str, quote: str, types: int, amount: big, holder: big, txnId: nullable(str) });
413
491
 
@@ -415,7 +493,7 @@ export const INBOX_GRADUATED = object({ ...AT, kind: oneOf("graduated"), launch:
415
493
 
416
494
  export const INBOX_SLOT = object({ ...AT, kind: oneOf("slot"), launch: str, place: int });
417
495
 
418
- export const INBOX_DEV_BURN = object({ ...BURN_FIELDS, kind: oneOf("devBurn"), launch: str });
496
+ export const INBOX_DEV_BURN = object({ ...BURN_FIELDS, id: optional(str), kind: oneOf("devBurn"), launch: str });
419
497
 
420
498
  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) });
421
499
 
@@ -434,7 +512,7 @@ export function inboxItem(v: unknown, p: string): InboxItem | null {
434
512
  return d(v, p) as InboxItem;
435
513
  }
436
514
 
437
- export const INBOX = object({ indexed, wallet: str, items: (v: unknown, p: string) => array(inboxItem)(v, p).filter((x): x is InboxItem => x !== null) });
515
+ export const INBOX = object({ indexed, wallet: str, items: (v: unknown, p: string) => array(inboxItem)(v, p).filter((x): x is InboxItem => x !== null), next: optional(nullable(str)) });
438
516
  export type Inbox = Infer<typeof INBOX>;
439
517
 
440
518
  export const CLAIM_ROW = object({
@@ -442,7 +520,7 @@ export const CLAIM_ROW = object({
442
520
  timestamp: int,
443
521
  txnId: nullable(str),
444
522
  sender: str,
445
- launch: str,
523
+ launch: nullable(str),
446
524
  quote: str,
447
525
  types: int,
448
526
  creator: big,
@@ -456,7 +534,7 @@ export const CLAIM_ROW = object({
456
534
  });
457
535
  export type ClaimRow = Infer<typeof CLAIM_ROW>;
458
536
 
459
- export const CLAIM_HISTORY = object({ indexed, wallet: str, claims: array(CLAIM_ROW) });
537
+ export const CLAIM_HISTORY = object({ indexed, wallet: str, claims: array(CLAIM_ROW), next: optional(nullable(str)) });
460
538
  export type ClaimHistory = Infer<typeof CLAIM_HISTORY>;
461
539
 
462
540
  const QUOTE_TOTAL = object({ quote: str, total: big, types: int });
@@ -479,6 +557,8 @@ export const CLAIM_VIEW = object({
479
557
  refOwed: optional(array(object({ account: str, quoteMint: str, owed: big }))),
480
558
  pendingRollUp: optional(array(object({ traderRef: str, quoteMint: str, amount: big }))),
481
559
  owed: optional(array(object({ quote: str, creator: big, creatorRef: big, teamSlot: big, traderRef: big, holder: big, teamBuy: big }))),
560
+
561
+ next: optional(nullable(str)),
482
562
  }),
483
563
  });
484
564
  export type ClaimView = Infer<typeof CLAIM_VIEW>;
@@ -494,6 +574,8 @@ export const PEOPLE = object({
494
574
  indexed,
495
575
  wallet: str,
496
576
  people: array(object({ wallet: str, chain: str, roles: array(object({ kind: oneOf("trader", "creator"), tier: int })), earned: PER_QUOTE, teamMilestone: PER_QUOTE })),
577
+
578
+ next: optional(nullable(str)),
497
579
  });
498
580
  export type People = Infer<typeof PEOPLE>;
499
581
 
@@ -508,12 +590,25 @@ export const ROLES = object({
508
590
  creatorOf: array(str),
509
591
  creatorRefOf: array(object({ launch: str, tier: int })),
510
592
  teamSlotOf: array(object({ launch: str, place: int })),
593
+
594
+ handleSlotOf: array(object({ launch: str, place: int, handle: str })),
511
595
  holdings: array(object({ launch: str, token: str, amount: big })),
512
596
  }),
513
597
  claimed: record(big),
598
+
599
+ next: optional(nullable(str)),
514
600
  });
515
601
  export type Roles = Infer<typeof ROLES>;
516
602
 
603
+ export const HANDLE_PLACES = object({
604
+ indexed,
605
+ handle: str,
606
+ places: array(object({ launch: str, place: int })),
607
+
608
+ next: optional(nullable(str)),
609
+ });
610
+ export type HandlePlaces = Infer<typeof HANDLE_PLACES>;
611
+
517
612
  export const TRADER_BOARD = object({
518
613
  indexed,
519
614
  window: oneOf(...TRADER_WINDOWS),
@@ -526,3 +621,9 @@ export const LAUNCHER_BOARD = object({
526
621
  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 })) })),
527
622
  });
528
623
  export type LauncherBoard = Infer<typeof LAUNCHER_BOARD>;
624
+
625
+ export function maxLossPct(b: { maxLossPpm?: number | null; backedPpm?: number | null; graduated?: boolean }): number | null {
626
+ if (b.maxLossPpm != null) return b.maxLossPpm / 10_000;
627
+ if (b.maxLossPpm === undefined && b.graduated === true && b.backedPpm != null) return Math.max(0, 1_000_000 - b.backedPpm) / 10_000;
628
+ return null;
629
+ }
@@ -1,10 +1,10 @@
1
1
 
2
2
 
3
3
  import { decode } from "./decode.ts";
4
- import { INDEXER_CONTRACT, clampLimit, routeLimit } from "./contract.ts";
4
+ import { INDEXER_CONTRACT, clampLimit, pageAsked, routeLimit } from "./contract.ts";
5
5
  import type { RouteBody, RouteName } from "./contract.ts";
6
6
  import { indexerPath, query } from "./paths.ts";
7
- import type { CandlesQuery, LaunchesQuery, Page, StreamQuery, TradesQuery, WalletTradesQuery } from "./paths.ts";
7
+ import type { CandlesQuery, LaunchSearchQuery, LaunchesQuery, Page, StreamQuery, TradesQuery, WalletPage, WalletTradesQuery } from "./paths.ts";
8
8
  import { IndexerError } from "./read.ts";
9
9
  import type { Get } from "./read.ts";
10
10
  import type { TraderWindow } from "./bodies.ts";
@@ -18,20 +18,23 @@ export interface RouteArgs {
18
18
  stream: StreamQuery;
19
19
  quotes: void;
20
20
  summary: void;
21
- floorRouted: void;
21
+ floorRouted: { limit?: number; cursor?: string } | void;
22
22
  events: { fromBlock: number; toBlock: number };
23
23
  launches: LaunchesQuery | void;
24
+ search: LaunchSearchQuery;
24
25
  launch: L;
25
26
  launchState: L;
26
27
  milestones: L;
27
28
  holders: L & { limit?: number };
28
29
  trades: L & TradesQuery;
29
- launchClaims: L & { claimer?: string };
30
- devBuys: L;
30
+ launchClaims: L & Page & { claimer?: string };
31
+ devBuys: L & Page;
32
+ memberSold: L & Page;
33
+ launchAccount: L;
31
34
  traders: L & { window?: TraderWindow; limit?: number };
32
35
  quoteChain: L;
33
36
  devTrades: L & { limit?: number };
34
- burns: L;
37
+ burns: L & Page;
35
38
  launchLocks: L;
36
39
  marks: L & Page;
37
40
  price: L;
@@ -39,15 +42,18 @@ export interface RouteArgs {
39
42
  candles: CandlesQuery;
40
43
  candleBundle: L & { intervals?: readonly string[]; limit?: number };
41
44
  walletTrades: W & WalletTradesQuery;
42
- positions: W;
43
- inbox: W & { limit?: number };
44
- walletLocks: W;
45
- claimHistory: W;
45
+ tonActivity: W & Page;
46
+ tonOutcome: W & { queryId: bigint | string };
47
+ positions: W & WalletPage;
48
+ inbox: W & { limit?: number; before?: string };
49
+ walletLocks: W & WalletPage;
50
+ claimHistory: W & WalletPage;
46
51
  firsts: W;
47
52
  firstsMany: { wallets: readonly string[] };
48
- claimView: W;
49
- people: W;
50
- roles: W;
53
+ claimView: W & WalletPage;
54
+ people: W & WalletPage;
55
+ roles: W & WalletPage;
56
+ handlePlaces: { handle: string } & WalletPage;
51
57
  traderBoard: { window?: TraderWindow; limit?: number } | void;
52
58
  launcherBoard: { limit?: number } | void;
53
59
  tokenHolders: { token: string; limit?: number; offset?: number };
@@ -56,7 +62,7 @@ export interface RouteArgs {
56
62
  dexPair: { id: string };
57
63
  cgPairs: void;
58
64
  cgTickers: void;
59
- cgHistoricalTrades: { ticker_id: string; type?: "buy" | "sell"; limit?: number; start_time?: number; end_time?: number };
65
+ cgHistoricalTrades: { ticker_id: string; type?: "buy" | "sell"; limit?: number; before?: string; start_time?: number; end_time?: number };
60
66
  llamaTvl: void;
61
67
  llamaFees: { from: number; to: number } | void;
62
68
  health: void;
@@ -73,20 +79,23 @@ export const routePath: { [N in RouteName]: (a: RouteArgs[N]) => string } = {
73
79
  stream: (a) => indexerPath.stream(a),
74
80
  quotes: () => indexerPath.quotes(),
75
81
  summary: () => indexerPath.summary(),
76
- floorRouted: () => indexerPath.floorRouted(),
82
+ floorRouted: (a) => indexerPath.floorRouted(a ?? {}),
77
83
  events: (a) => indexerPath.events(a.fromBlock, a.toBlock),
78
84
  launches: (a) => indexerPath.launches(a ?? {}),
85
+ search: (a) => indexerPath.search(a),
79
86
  launch: (a) => indexerPath.launch(a.launch),
80
87
  launchState: (a) => indexerPath.launchState(a.launch),
81
88
  milestones: (a) => indexerPath.milestones(a.launch),
82
89
  holders: ({ launch, ...q }) => indexerPath.holders(launch, q),
83
90
  trades: ({ launch, ...q }) => indexerPath.trades(launch, q),
84
91
  launchClaims: ({ launch, ...q }) => indexerPath.launchClaims(launch, q),
85
- devBuys: (a) => indexerPath.devBuys(a.launch),
92
+ devBuys: ({ launch, ...q }) => indexerPath.devBuys(launch, q),
93
+ memberSold: ({ launch, ...q }) => indexerPath.memberSold(launch, q),
94
+ launchAccount: (a) => indexerPath.launchAccount(a.launch),
86
95
  traders: ({ launch, ...q }) => indexerPath.traders(launch, q),
87
96
  quoteChain: (a) => indexerPath.quoteChain(a.launch),
88
97
  devTrades: ({ launch, ...q }) => indexerPath.devTrades(launch, q),
89
- burns: (a) => indexerPath.burns(a.launch),
98
+ burns: ({ launch, ...q }) => indexerPath.burns(launch, q),
90
99
  launchLocks: (a) => indexerPath.launchLocks(a.launch),
91
100
  marks: ({ launch, ...q }) => indexerPath.marks(launch, q),
92
101
  price: (a) => indexerPath.price(a.launch),
@@ -94,15 +103,18 @@ export const routePath: { [N in RouteName]: (a: RouteArgs[N]) => string } = {
94
103
  candles: (a) => indexerPath.candles(a),
95
104
  candleBundle: ({ launch, ...q }) => indexerPath.candleBundle(launch, q),
96
105
  walletTrades: ({ wallet, ...q }) => indexerPath.walletTrades(wallet, q),
97
- positions: (a) => indexerPath.positions(a.wallet),
106
+ tonActivity: ({ wallet, ...q }) => indexerPath.tonActivity(wallet, q),
107
+ tonOutcome: (a) => indexerPath.tonOutcome(a.wallet, a.queryId),
108
+ positions: ({ wallet, ...q }) => indexerPath.positions(wallet, q),
98
109
  inbox: ({ wallet, ...q }) => indexerPath.inbox(wallet, q),
99
- walletLocks: (a) => indexerPath.walletLocks(a.wallet),
100
- claimHistory: (a) => indexerPath.claimHistory(a.wallet),
110
+ walletLocks: ({ wallet, ...q }) => indexerPath.walletLocks(wallet, q),
111
+ claimHistory: ({ wallet, ...q }) => indexerPath.claimHistory(wallet, q),
101
112
  firsts: (a) => indexerPath.firsts(a.wallet),
102
113
  firstsMany: (a) => indexerPath.firstsMany(a.wallets),
103
- claimView: (a) => indexerPath.claimView(a.wallet),
104
- people: (a) => indexerPath.people(a.wallet),
105
- roles: (a) => indexerPath.roles(a.wallet),
114
+ claimView: ({ wallet, ...q }) => indexerPath.claimView(wallet, q),
115
+ people: ({ wallet, ...q }) => indexerPath.people(wallet, q),
116
+ roles: ({ wallet, ...q }) => indexerPath.roles(wallet, q),
117
+ handlePlaces: ({ handle, ...q }) => indexerPath.handlePlaces(handle, q),
106
118
  traderBoard: (a) => indexerPath.traderBoard(a ?? {}),
107
119
  launcherBoard: (a) => indexerPath.launcherBoard(a ?? {}),
108
120
  tokenHolders: (a) => `/floor-amm/holders/${encodeURIComponent(need(a.token, "token"))}${query({ limit: a.limit, offset: a.offset })}`,
@@ -111,7 +123,7 @@ export const routePath: { [N in RouteName]: (a: RouteArgs[N]) => string } = {
111
123
  dexPair: (a) => `/v2/dex/pair${query({ id: need(a.id, "id") })}`,
112
124
  cgPairs: () => "/v2/coingecko/pairs",
113
125
  cgTickers: () => "/v2/coingecko/tickers",
114
- 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 })}`,
126
+ 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 })}`,
115
127
  llamaTvl: () => "/v2/defillama/tvl",
116
128
  llamaFees: (a) => {
117
129
  if (a && a.to < a.from) throw new RangeError("from > to");
@@ -120,7 +132,8 @@ export const routePath: { [N in RouteName]: (a: RouteArgs[N]) => string } = {
120
132
  health: () => "/health",
121
133
  };
122
134
 
123
- export type DrainName = "trades" | "walletTrades" | "launches" | "marks";
135
+ 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"] as const;
136
+ export type DrainName = (typeof DRAIN_NAMES)[number];
124
137
 
125
138
  export type ReadName = Exclude<RouteName, "stream">;
126
139
 
@@ -144,7 +157,7 @@ export function createIndexerClient(opts: IndexerClientOptions): IndexerClient {
144
157
 
145
158
  const clamp = (name: RouteName, a: unknown): unknown => {
146
159
  if (typeof a !== "object" || a === null || !("limit" in a) || typeof (a as { limit: unknown }).limit !== "number") return a;
147
- return { ...a, limit: clampLimit(name, (a as { limit: number }).limit) };
160
+ return { ...a, limit: clampLimit(name, (a as { limit: number }).limit, pageAsked(name, a as Record<string, unknown>)) };
148
161
  };
149
162
  const path = (name: RouteName, a?: unknown): string => (routePath[name] as (x: unknown) => string)(clamp(name, a));
150
163
  const read = async (name: ReadName, a?: unknown): Promise<unknown> => {
@@ -160,12 +173,27 @@ export function createIndexerClient(opts: IndexerClientOptions): IndexerClient {
160
173
  const max = o.maxPages ?? 100;
161
174
  const lim = routeLimit(name)!;
162
175
  let args: Record<string, unknown> = { ...a };
176
+
177
+ if (page.kind === "cursor" && page.optIn !== undefined && args.before === undefined) args = { ...args, before: "" };
178
+ if (page.kind === "keyset" && page.optIn === true && args.limit === undefined && args.cursor === undefined) args = { ...args, limit: lim.default };
163
179
  for (let i = 0; i < max; i++) {
164
180
  const body = (await read(name, args)) as { next?: string | null; total?: number };
165
181
  yield body;
166
182
  if (page.kind === "cursor") {
167
183
  if (body.next === null || body.next === undefined) return;
168
184
  args = { ...args, before: body.next };
185
+ } else if (page.kind === "keyset") {
186
+
187
+ if (args.ids !== undefined) return;
188
+ if (args.offset !== undefined) {
189
+ const step = clampLimit(name, (args.limit as number | undefined) ?? lim.default);
190
+ const offset = (args.offset as number) + step;
191
+ if (offset >= (body.total ?? 0)) return;
192
+ args = { ...args, offset };
193
+ continue;
194
+ }
195
+ if (body.next === null || body.next === undefined) return;
196
+ args = { ...args, cursor: body.next };
169
197
  } else if (page.kind === "offset") {
170
198
  const step = clampLimit(name, (args.limit as number | undefined) ?? lim.default);
171
199
  const offset = ((args.offset as number | undefined) ?? 0) + step;