@floorlaunchpad/sdk 0.1.0 → 0.3.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 (292) hide show
  1. package/CHANGELOG.md +84 -0
  2. package/LICENSE +201 -60
  3. package/README.md +45 -24
  4. package/dist/abi/evm-event-names.js +12 -0
  5. package/dist/abi/evm.gen.js +130 -0
  6. package/dist/abi/functions.gen.js +144 -0
  7. package/dist/abi/index.js +17 -0
  8. package/dist/abi/solana.gen.js +128 -0
  9. package/dist/burn.js +21 -0
  10. package/dist/client/evm/index.js +191 -0
  11. package/dist/client/index.js +19 -0
  12. package/dist/client/solana/index.js +259 -0
  13. package/dist/client/types.js +5 -0
  14. package/dist/codec.js +77 -0
  15. package/dist/config/codeHash.js +9 -0
  16. package/dist/config/generated.js +746 -0
  17. package/dist/config/index.js +49 -0
  18. package/dist/config/registry.gen.js +118 -0
  19. package/dist/config/solana-genesis.js +7 -0
  20. package/dist/ed25519.js +31 -0
  21. package/dist/errors.js +249 -0
  22. package/dist/events/index.js +40 -0
  23. package/dist/events/types.gen.js +3 -0
  24. package/dist/evm/abi.js +283 -0
  25. package/dist/evm/balances.js +26 -0
  26. package/dist/evm/chains.js +144 -0
  27. package/dist/evm/floor/abi.gen.js +195 -0
  28. package/dist/evm/floor/calls.js +230 -0
  29. package/dist/evm/floor/create.js +49 -0
  30. package/dist/evm/floor/events.js +41 -0
  31. package/dist/evm/floor/iface.js +44 -0
  32. package/dist/evm/items.js +209 -0
  33. package/dist/evm/keccak.js +118 -0
  34. package/dist/evm/multicall.js +30 -0
  35. package/dist/evm/router.js +184 -0
  36. package/dist/evm/zap.js +128 -0
  37. package/dist/fixtures.js +53 -0
  38. package/dist/generated/index.js +28 -0
  39. package/dist/generated/interface.gen.js +146 -0
  40. package/dist/handle.js +22 -0
  41. package/dist/index.js +91 -7
  42. package/dist/indexer/bodies.js +473 -0
  43. package/dist/indexer/client.js +104 -0
  44. package/dist/indexer/contract.js +349 -0
  45. package/dist/indexer/decode.js +97 -0
  46. package/dist/indexer/partners.js +100 -0
  47. package/dist/indexer/paths.js +127 -0
  48. package/dist/indexer/read.js +109 -0
  49. package/dist/indexer/stream.js +71 -0
  50. package/dist/lock.js +16 -0
  51. package/dist/math/fixed.js +154 -0
  52. package/dist/math/genesis.js +39 -0
  53. package/dist/math/index.js +20 -0
  54. package/dist/math/u256.js +49 -0
  55. package/dist/math/v2/ask.js +162 -0
  56. package/dist/math/v2/book.js +607 -0
  57. package/dist/math/v2/circulating.js +62 -0
  58. package/dist/math/v2/create.js +122 -0
  59. package/dist/math/v2/display.js +208 -0
  60. package/dist/math/v2/error.js +17 -0
  61. package/dist/math/v2/feasibility.js +174 -0
  62. package/dist/math/v2/fees.js +121 -0
  63. package/dist/math/v2/holders.js +105 -0
  64. package/dist/math/v2/milestones.js +40 -0
  65. package/dist/math/v2/pow.js +69 -0
  66. package/dist/math/v2/preset.js +151 -0
  67. package/dist/math/v2/receipt.js +108 -0
  68. package/dist/math/v2/relay.js +217 -0
  69. package/dist/math/v2/rows.js +365 -0
  70. package/dist/math/v2/split.js +111 -0
  71. package/dist/math/v2/sqrt.js +84 -0
  72. package/dist/math/v2/supply.js +21 -0
  73. package/dist/math/v2/team.js +75 -0
  74. package/dist/math/v2/trade.js +126 -0
  75. package/dist/math/v2/wide.js +51 -0
  76. package/dist/quote.js +6 -0
  77. package/dist/registryPrice.js +23 -0
  78. package/dist/route/edge-jupiter.js +42 -0
  79. package/dist/route/edge.js +11 -0
  80. package/dist/route/graph.js +51 -0
  81. package/dist/route/path.js +75 -0
  82. package/dist/route/quote.js +15 -0
  83. package/dist/route-jupiter.js +35 -0
  84. package/dist/route.js +8 -0
  85. package/dist/sha256.js +61 -0
  86. package/dist/solana/alt.js +18 -0
  87. package/dist/solana/floor/accounts.js +390 -0
  88. package/dist/solana/floor/borsh.js +66 -0
  89. package/dist/solana/floor/create.js +65 -0
  90. package/dist/solana/floor/events.js +140 -0
  91. package/dist/solana/floor/genesis.js +91 -0
  92. package/dist/solana/floor/genesisList.js +68 -0
  93. package/dist/solana/floor/instructions.js +435 -0
  94. package/dist/solana/floor/metadata.js +198 -0
  95. package/dist/solana/floor/mint.js +206 -0
  96. package/dist/solana/floor/program.js +64 -0
  97. package/dist/solana/floor/registry.js +83 -0
  98. package/dist/solana/instruction.js +49 -0
  99. package/dist/solana/pda.js +88 -0
  100. package/dist/solana/tx.js +138 -0
  101. package/dist/v2/burnPreview.js +35 -0
  102. package/dist/v2/circulating.js +11 -0
  103. package/dist/v2/claimAllEvm.js +70 -0
  104. package/dist/v2/claims-evm.js +120 -0
  105. package/dist/v2/claims.js +218 -0
  106. package/dist/v2/dead.js +21 -0
  107. package/dist/v2/devbuy.js +37 -0
  108. package/dist/v2/events.js +115 -0
  109. package/dist/v2/evm.js +299 -0
  110. package/dist/v2/evmReads.js +76 -0
  111. package/dist/v2/genesis.js +76 -0
  112. package/dist/v2/layouts.js +217 -0
  113. package/dist/v2/market-evm.js +74 -0
  114. package/dist/v2/presetRowEvm.js +45 -0
  115. package/dist/v2/press.js +106 -0
  116. package/dist/v2/quoteMint.js +52 -0
  117. package/dist/v2/receipt-tx.js +149 -0
  118. package/dist/v2/route-alt.js +114 -0
  119. package/dist/v2/route.js +389 -0
  120. package/dist/v2/solana.js +391 -0
  121. package/dist/v2/solanaSettle.js +97 -0
  122. package/dist/v2/tx/evm.js +126 -0
  123. package/dist/v2/tx/genesis.js +47 -0
  124. package/dist/v2/tx/index.js +5 -0
  125. package/dist/v2/tx/solana.js +118 -0
  126. package/dist/v2/types.js +13 -0
  127. package/docs/aggregator.md +61 -0
  128. package/docs/bot.md +50 -0
  129. package/docs/frontend.md +29 -0
  130. package/docs/wallet.md +54 -0
  131. package/package.json +428 -32
  132. package/src/abi/evm-event-names.ts +12 -0
  133. package/src/abi/evm.gen.ts +139 -0
  134. package/src/abi/functions.gen.ts +154 -0
  135. package/src/abi/index.ts +30 -0
  136. package/src/abi/solana.gen.ts +138 -0
  137. package/src/burn.ts +37 -0
  138. package/src/client/evm/index.ts +199 -0
  139. package/src/client/index.ts +23 -0
  140. package/src/client/solana/index.ts +260 -0
  141. package/src/client/types.ts +162 -0
  142. package/src/codec.ts +77 -0
  143. package/src/config/codeHash.ts +9 -0
  144. package/src/config/generated.ts +746 -0
  145. package/src/config/index.ts +91 -0
  146. package/src/config/registry.gen.ts +118 -0
  147. package/src/config/solana-genesis.ts +7 -0
  148. package/src/ed25519.ts +31 -0
  149. package/src/errors.ts +270 -0
  150. package/src/events/index.ts +44 -0
  151. package/src/events/types.gen.ts +831 -0
  152. package/src/evm/abi.ts +292 -0
  153. package/src/evm/balances.ts +26 -0
  154. package/src/evm/chains.ts +167 -0
  155. package/src/evm/floor/abi.gen.ts +195 -0
  156. package/src/evm/floor/calls.ts +247 -0
  157. package/src/evm/floor/create.ts +68 -0
  158. package/src/evm/floor/events.ts +51 -0
  159. package/src/evm/floor/iface.ts +45 -0
  160. package/src/evm/items.ts +252 -0
  161. package/src/evm/keccak.ts +118 -0
  162. package/src/evm/multicall.ts +43 -0
  163. package/src/evm/router.ts +209 -0
  164. package/src/evm/zap.ts +152 -0
  165. package/src/fixtures.ts +53 -0
  166. package/src/generated/index.ts +29 -0
  167. package/src/generated/interface.gen.ts +153 -0
  168. package/src/handle.ts +22 -0
  169. package/src/index.ts +91 -6
  170. package/src/indexer/bodies.ts +528 -0
  171. package/src/indexer/client.ts +178 -0
  172. package/src/indexer/contract.ts +410 -0
  173. package/src/indexer/decode.ts +109 -0
  174. package/src/indexer/partners.ts +109 -0
  175. package/src/indexer/paths.ts +190 -0
  176. package/src/indexer/read.ts +119 -0
  177. package/src/indexer/stream.ts +83 -0
  178. package/src/lock.ts +16 -0
  179. package/src/math/fixed.ts +154 -0
  180. package/src/math/genesis.ts +39 -0
  181. package/src/math/index.ts +24 -0
  182. package/src/math/u256.ts +49 -0
  183. package/src/math/v2/ask.ts +218 -0
  184. package/src/math/v2/book.ts +660 -0
  185. package/src/math/v2/circulating.ts +69 -0
  186. package/src/math/v2/create.ts +139 -0
  187. package/src/math/v2/display.ts +250 -0
  188. package/src/math/v2/error.ts +19 -0
  189. package/src/math/v2/feasibility.ts +200 -0
  190. package/src/math/v2/fees.ts +121 -0
  191. package/src/math/v2/holders.ts +124 -0
  192. package/src/math/v2/milestones.ts +51 -0
  193. package/src/math/v2/pow.ts +71 -0
  194. package/src/math/v2/preset.ts +189 -0
  195. package/src/math/v2/receipt.ts +162 -0
  196. package/src/math/v2/relay.ts +235 -0
  197. package/src/math/v2/rows.ts +412 -0
  198. package/src/math/v2/split.ts +160 -0
  199. package/src/math/v2/sqrt.ts +86 -0
  200. package/src/math/v2/supply.ts +27 -0
  201. package/src/math/v2/team.ts +75 -0
  202. package/src/math/v2/trade.ts +145 -0
  203. package/src/math/v2/wide.ts +52 -0
  204. package/src/quote.ts +6 -0
  205. package/src/registryPrice.ts +28 -0
  206. package/src/route/edge-jupiter.ts +71 -0
  207. package/src/route/edge.ts +22 -0
  208. package/src/route/graph.ts +77 -0
  209. package/src/route/path.ts +84 -0
  210. package/src/route/quote.ts +46 -0
  211. package/src/route-jupiter.ts +36 -0
  212. package/src/route.ts +8 -0
  213. package/src/sha256.ts +61 -0
  214. package/src/solana/alt.ts +25 -0
  215. package/src/solana/floor/accounts.ts +393 -0
  216. package/src/solana/floor/borsh.ts +66 -0
  217. package/src/solana/floor/create.ts +89 -0
  218. package/src/solana/floor/events.ts +147 -0
  219. package/src/solana/floor/genesis.ts +111 -0
  220. package/src/solana/floor/genesisList.ts +75 -0
  221. package/src/solana/floor/instructions.ts +491 -0
  222. package/src/solana/floor/metadata.ts +246 -0
  223. package/src/solana/floor/mint.ts +242 -0
  224. package/src/solana/floor/program.ts +64 -0
  225. package/src/solana/floor/registry.ts +96 -0
  226. package/src/solana/instruction.ts +61 -0
  227. package/src/solana/pda.ts +91 -0
  228. package/src/solana/tx.ts +143 -0
  229. package/src/v2/burnPreview.ts +52 -0
  230. package/src/v2/circulating.ts +22 -0
  231. package/src/v2/claimAllEvm.ts +97 -0
  232. package/src/v2/claims-evm.ts +179 -0
  233. package/src/v2/claims.ts +288 -0
  234. package/src/v2/dead.ts +21 -0
  235. package/src/v2/devbuy.ts +55 -0
  236. package/src/v2/events.ts +131 -0
  237. package/src/v2/evm.ts +349 -0
  238. package/src/v2/evmReads.ts +121 -0
  239. package/src/v2/genesis.ts +80 -0
  240. package/src/v2/layouts.ts +219 -0
  241. package/src/v2/market-evm.ts +95 -0
  242. package/src/v2/presetRowEvm.ts +54 -0
  243. package/src/v2/press.ts +124 -0
  244. package/src/v2/quoteMint.ts +63 -0
  245. package/src/v2/receipt-tx.ts +251 -0
  246. package/src/v2/route-alt.ts +114 -0
  247. package/src/v2/route.ts +494 -0
  248. package/src/v2/solana.ts +439 -0
  249. package/src/v2/solanaSettle.ts +117 -0
  250. package/src/v2/tx/evm.ts +152 -0
  251. package/src/v2/tx/genesis.ts +66 -0
  252. package/src/v2/tx/index.ts +5 -0
  253. package/src/v2/tx/solana.ts +140 -0
  254. package/src/v2/types.ts +284 -0
  255. package/dist/adapter.d.ts +0 -28
  256. package/dist/adapter.d.ts.map +0 -1
  257. package/dist/adapter.js +0 -2
  258. package/dist/adapter.js.map +0 -1
  259. package/dist/chain.d.ts +0 -23
  260. package/dist/chain.d.ts.map +0 -1
  261. package/dist/chain.js +0 -25
  262. package/dist/chain.js.map +0 -1
  263. package/dist/client.d.ts +0 -26
  264. package/dist/client.d.ts.map +0 -1
  265. package/dist/client.js +0 -43
  266. package/dist/client.js.map +0 -1
  267. package/dist/dex-adapter.d.ts +0 -228
  268. package/dist/dex-adapter.d.ts.map +0 -1
  269. package/dist/dex-adapter.js +0 -407
  270. package/dist/dex-adapter.js.map +0 -1
  271. package/dist/index.d.ts +0 -7
  272. package/dist/index.d.ts.map +0 -1
  273. package/dist/index.js.map +0 -1
  274. package/dist/quotes.d.ts +0 -12
  275. package/dist/quotes.d.ts.map +0 -1
  276. package/dist/quotes.gen.d.ts +0 -8
  277. package/dist/quotes.gen.d.ts.map +0 -1
  278. package/dist/quotes.gen.js +0 -2170
  279. package/dist/quotes.gen.js.map +0 -1
  280. package/dist/quotes.js +0 -24
  281. package/dist/quotes.js.map +0 -1
  282. package/dist/types.d.ts +0 -111
  283. package/dist/types.d.ts.map +0 -1
  284. package/dist/types.js +0 -2
  285. package/dist/types.js.map +0 -1
  286. package/src/adapter.ts +0 -20
  287. package/src/chain.ts +0 -39
  288. package/src/client.ts +0 -41
  289. package/src/dex-adapter.ts +0 -477
  290. package/src/quotes.gen.ts +0 -2170
  291. package/src/quotes.ts +0 -29
  292. package/src/types.ts +0 -115
@@ -0,0 +1,473 @@
1
+
2
+
3
+ import { array, big, bool, decimal, int, nullable, object, oneOf, optional, record, str } from "./decode.js";
4
+
5
+ export const INDEXED = object({ block: int, timestamp: int });
6
+
7
+ const indexed = nullable(INDEXED);
8
+
9
+ export const FEES = object({ backing: big, team: big, platform: big, floorFee: big, holder: big });
10
+
11
+ export const MILESTONE_CLASSES = ["team", "holder", "platform", "floor"] ;
12
+ export const MILESTONES = object({ team: big, holder: big, platform: big, floor: big });
13
+
14
+ export const DEV_BUY_ROLE = oneOf("creator", "team_member", "team_share_buy", "team_buy");
15
+
16
+ export const DEV_BUY = object({
17
+ role: DEV_BUY_ROLE,
18
+ trader: str,
19
+ quoteIn: big,
20
+ tokens: big,
21
+ priceBeforeX64: big,
22
+ priceAfterX64: big,
23
+ impactBps: big,
24
+ priceNowX64: big,
25
+ changeSinceBps: big,
26
+ block: int,
27
+ timestamp: int,
28
+ tx: str,
29
+ });
30
+
31
+ export const BONDING = object({ tokens: big, sold: big, left: big, priceX64: big });
32
+
33
+ const BURN_FIELDS = {
34
+ timestamp: int,
35
+ block: int,
36
+ txnId: nullable(str),
37
+ source: oneOf("program", "dead", "wallet"),
38
+ wallet: nullable(str),
39
+ role: nullable(int),
40
+ place: nullable(int),
41
+ burned: big,
42
+ fromTeamBuy: nullable(big),
43
+ fromShareBought: nullable(big),
44
+ fromWallet: nullable(big),
45
+ balanceBefore: nullable(big),
46
+ pctBps: nullable(int),
47
+ supplyAfter: nullable(big),
48
+ sOutAfter: nullable(big),
49
+ floorAfterX64: nullable(big),
50
+ sOutBefore: nullable(big),
51
+ floorBeforeX64: nullable(big),
52
+ scene: bool,
53
+
54
+ floorRiseBps: nullable(int),
55
+ };
56
+ export const BURN = object(BURN_FIELDS);
57
+
58
+ const LAUNCH_FIELDS = {
59
+ id: str,
60
+
61
+ pair: str,
62
+ chain: str,
63
+ token: str,
64
+ quote: str,
65
+ creator: str,
66
+ name: nullable(str),
67
+ symbol: nullable(str),
68
+ tokenDecimals: nullable(int),
69
+ preset: int,
70
+ presetHash: str,
71
+ graduated: bool,
72
+
73
+ graduation: nullable(object({ block: int, timestamp: int, tx: str })),
74
+
75
+ teamSlot: array(object({ wallet: str, place: int })),
76
+ phase: oneOf("bonding", "stacks", "tail"),
77
+ floorX64: big,
78
+ sqrtF: big,
79
+
80
+ floorMoney: big,
81
+ cushionMoney: big,
82
+ vault: big,
83
+ bidMoney: big,
84
+ liquidity: big,
85
+ liquidityMode: oneOf("all", "bid"),
86
+ priceX64: big,
87
+ sqrtPrice: big,
88
+ sqrtLMax: big,
89
+ circulating: object({ sCirc: big, dead: big }),
90
+ marketCap: big,
91
+ supply: big,
92
+ unlisted: bool,
93
+ quoteDecimals: nullable(int),
94
+ teamSlotRateBps: nullable(int),
95
+ bidTopX64: nullable(big),
96
+ teamBuyUnlockAt: nullable(int),
97
+ teamBuyUnlocked: bool,
98
+ teamBuyUnlockedTs: nullable(int),
99
+ milestones: object({ booked: MILESTONES, paid: MILESTONES }),
100
+ holderIndex: object({ index: big, wMatured: big, wPending: big, carry: big, rolls: int }),
101
+ volumeGross: big,
102
+ trades: int,
103
+ feesOut: FEES,
104
+ conservation: nullable(object({ inBook: big, held: big, delta: big })),
105
+ devBuy: nullable(object({ count: int, teamBuyUnlocked: bool, quoteIn: big, tokens: big, latest: DEV_BUY })),
106
+
107
+ created: object({ block: int, timestamp: int, sqrtP0: nullable(big), teamBuy: big }),
108
+ bonding: nullable(BONDING),
109
+
110
+ burns: object({ count: int, burned: big, teamBuyBurned: big, shareBoughtBurned: big, walletBurned: big, last: nullable(BURN), lastScene: nullable(BURN) }),
111
+ };
112
+ export const LAUNCH = object(LAUNCH_FIELDS);
113
+
114
+ export const LISTED_LAUNCH = object({
115
+ ...LAUNCH_FIELDS,
116
+ volume24hGross: nullable(big),
117
+ holders: int,
118
+ backedPpm: nullable(int),
119
+ volume24hUsd: nullable(decimal),
120
+ marketCapUsd: nullable(decimal),
121
+ });
122
+
123
+ export const LIVE_LAUNCH = object({ ...LAUNCH_FIELDS, volume24hGross: nullable(big), holders: int });
124
+
125
+ const TRADE_FIELDS = {
126
+ launch: str,
127
+ trader: str,
128
+ side: oneOf("buy", "sell"),
129
+ tokens: big,
130
+ quoteGross: big,
131
+ quoteNet: big,
132
+ fees: FEES,
133
+ traderRef: big,
134
+ creatorRef: nullable(big),
135
+ recipient: str,
136
+ refund: big,
137
+ fromResale: big,
138
+ fromFirst: big,
139
+ unfilled: big,
140
+ steps: int,
141
+ budgetHit: bool,
142
+ kind: nullable(int),
143
+ credits: object({ backing: big, team: big, platform: big, floorFee: big, holder: big, traderRef: big, creatorRef: nullable(big), teamSlot: nullable(big), teamMilestone: big }),
144
+ priceX64: big,
145
+ floorX64: big,
146
+ circulating: big,
147
+
148
+ floorMoney: nullable(big),
149
+
150
+ bidMoney: nullable(big),
151
+ liquidity: big,
152
+ block: int,
153
+ timestamp: int,
154
+ tx: str,
155
+ txnIndex: int,
156
+ eventIndex: int,
157
+ };
158
+ export const TRADE = object(TRADE_FIELDS);
159
+
160
+ export const PAGED_TRADE = object({ id: str, ...TRADE_FIELDS });
161
+
162
+ export const HEAD = object({
163
+ chain: str,
164
+ indexed,
165
+ safe: nullable(int),
166
+ chainHead: nullable(int),
167
+ lag: nullable(int),
168
+ ready: bool,
169
+ servesUnsafe: bool,
170
+ rollbacks: int,
171
+ startBlock: int,
172
+ stalled: optional(nullable(object({ slot: int, signature: str, cycles: int, error: str, ok: bool }))),
173
+ });
174
+
175
+ export const LATEST_BLOCK = object({ indexed, block: object({ blockNumber: int, blockTimestamp: int }) });
176
+
177
+ export const QUOTES = object({
178
+ indexed,
179
+ priceUpdater: nullable(str),
180
+ priceUpdaterReported: bool,
181
+ maxAgeS: int,
182
+ quotes: array(object({ mint: str, enabled: bool, createFee: big, usdCentsX64: big, updatedAt: int, ageS: int, fresh: bool, symbol: nullable(str), name: nullable(str), decimals: nullable(int) })),
183
+ });
184
+
185
+ export const SUMMARY = object({
186
+ indexed,
187
+ liquidityMode: oneOf("all", "bid"),
188
+ quotes: array(object({
189
+ quote: str,
190
+ launches: int,
191
+ graduated: int,
192
+ backing: big,
193
+ liquidity: big,
194
+ volume: big,
195
+ marketCap: big,
196
+ liquidityUsd: nullable(decimal),
197
+ volumeUsd: nullable(decimal),
198
+ marketCapUsd: nullable(decimal),
199
+ usdSource: nullable(str),
200
+ })),
201
+ });
202
+
203
+ export const FLOOR_ROUTED = object({
204
+ indexed,
205
+ launches: array(object({ launch: str, quote: str, floorFee: big, floorMilestone: big })),
206
+ pending: array(object({ quote: str, amount: big })),
207
+ });
208
+
209
+ export const EVENTS = object({
210
+ events: array(object({
211
+ block: object({ blockNumber: int, blockTimestamp: int }),
212
+ eventType: oneOf("swap"),
213
+ txnId: str,
214
+ txnIndex: int,
215
+ eventIndex: int,
216
+ maker: str,
217
+ pairId: str,
218
+
219
+ asset0In: optional(decimal),
220
+ asset1In: optional(decimal),
221
+ asset0Out: optional(decimal),
222
+ asset1Out: optional(decimal),
223
+ priceNative: decimal,
224
+ reserves: object({ asset0: decimal, asset1: decimal }),
225
+ })),
226
+ });
227
+
228
+ export const LAUNCHES_ALL = object({ indexed, launches: array(LISTED_LAUNCH) });
229
+
230
+ export const LAUNCHES = object({ indexed, total: int, offset: int, launches: array(LISTED_LAUNCH), missing: array(str) });
231
+
232
+ export const LAUNCH_ONE = object({ indexed, launch: LISTED_LAUNCH });
233
+
234
+ export const LAUNCH_STATE = object({ launch: str, mint: str, block: nullable(int), ts: nullable(int), seq: int, state: LIVE_LAUNCH });
235
+
236
+ export const LAUNCH_MILESTONES = object({ indexed, classes: array(str), booked: MILESTONES, paid: MILESTONES });
237
+
238
+ export const HOLDERS = object({ indexed, source: oneOf("positions", "trades"), total: int, holders: array(object({ holder: str, amount: big, openedTs: int })) });
239
+
240
+ export const TRADES = object({ indexed, trades: array(PAGED_TRADE), next: nullable(str) });
241
+
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 });
243
+
244
+ export const LAUNCH_CLAIMS = object({ indexed, claims: array(LAUNCH_CLAIM) });
245
+
246
+ export const DEV_BUYS = object({ indexed, teamBuyUnlocked: bool, teamBuyUnlockedTs: nullable(int), devBuys: array(DEV_BUY) });
247
+
248
+ export const CANDLE_INTERVALS = ["1s", "5s", "1m", "5m", "15m", "1h", "4h", "1d"] ;
249
+
250
+ export const CANDLE_INTERVAL_SECS = { "1s": 1, "5s": 5, "1m": 60, "5m": 300, "15m": 900, "1h": 3_600, "4h": 14_400, "1d": 86_400 };
251
+
252
+ export const CANDLES_MAX = 5_000;
253
+
254
+ export const CANDLE_BUNDLE_LIMIT = 300;
255
+
256
+ export const CANDLE = object({
257
+ time: int,
258
+ open: nullable(decimal),
259
+ high: nullable(decimal),
260
+ low: nullable(decimal),
261
+ close: nullable(decimal),
262
+ openX64: big,
263
+ highX64: big,
264
+ lowX64: big,
265
+ closeX64: big,
266
+ openUsd: nullable(decimal),
267
+ highUsd: nullable(decimal),
268
+ lowUsd: nullable(decimal),
269
+ closeUsd: nullable(decimal),
270
+ volumeQuoteRaw: big,
271
+ volumeUsd: nullable(decimal),
272
+ volumeTokensRaw: big,
273
+ volumeBuyQuoteRaw: big,
274
+ volumeSellQuoteRaw: big,
275
+ buys: int,
276
+ sells: int,
277
+ });
278
+
279
+ const USD_RATE = object({ centsX64: nullable(big), source: nullable(str), ageS: nullable(int) });
280
+
281
+ export const CANDLES = object({
282
+ indexed,
283
+ launch: str,
284
+ token: str,
285
+ quote: str,
286
+ interval: str,
287
+ seconds: int,
288
+ from: int,
289
+ to: int,
290
+ quietBuckets: oneOf("absent"),
291
+ usd: USD_RATE,
292
+ candles: array(CANDLE),
293
+ });
294
+
295
+ export const CANDLE_BUNDLE = object({
296
+ indexed,
297
+ launch: str,
298
+ token: str,
299
+ quote: str,
300
+ quietBuckets: oneOf("absent"),
301
+ usd: USD_RATE,
302
+ limit: int,
303
+ pages: record(object({ interval: str, seconds: int, from: int, to: int, candles: array(CANDLE) })),
304
+ });
305
+
306
+ export const HIGH = object({ timestamp: int, block: int, txnId: nullable(str), txnIndex: int, eventIndex: int, priceX64: big, supply: big, marketCap: big });
307
+
308
+ export const HIGHS = object({ indexed, launch: str, first: nullable(HIGH), highs: array(HIGH), more: bool });
309
+
310
+ export const TRADER_WINDOWS = ["1h", "24h", "7d", "all"] ;
311
+
312
+ export const LAUNCH_TRADERS = object({
313
+ indexed,
314
+ launch: str,
315
+ window: oneOf(...TRADER_WINDOWS),
316
+ traders: array(object({ trader: str, volume: big, bought: big, sold: big, spent: big, received: big, buys: int, sells: int, lastTimestamp: int })),
317
+ });
318
+
319
+ export const QUOTE_CHAIN = object({ indexed, launch: str, chain: array(object({ launch: str, token: str, quote: str })) });
320
+
321
+ export const DEV_TRADES = object({ indexed, launch: str, creator: str, trades: array(TRADE) });
322
+
323
+ export const BURNS = object({ indexed, launch: str, burns: array(object({ amount: big, block: int, timestamp: int })), program: array(BURN), wallet: array(BURN) });
324
+
325
+ const LOCK_HOLDER = object({ wallet: str, place: nullable(int) });
326
+
327
+ export const TEAM_BUY_LOCK = object({ kind: oneOf("teamBuy"), tokens: big, createdAt: int, unlocked: bool, unlockedAt: nullable(int), unlockAt: nullable(int), locked: big, claimed: big, holders: array(LOCK_HOLDER) });
328
+
329
+ export const LAUNCH_LOCKS = object({ indexed, launch: str, locks: array(TEAM_BUY_LOCK) });
330
+
331
+ export const MARK_ROLES = ["creator", "teamSlot", "creatorRef", "top10"] ;
332
+
333
+ export const MARK = object({ id: str, ...TRADE_FIELDS, who: array(oneOf(...MARK_ROLES)) });
334
+
335
+ export const MARKS = object({ indexed, launch: str, trades: array(MARK), next: nullable(str) });
336
+
337
+ export const PRICE = object({
338
+ indexed,
339
+ launch: str,
340
+ phase: oneOf("bonding", "stacks", "tail"),
341
+ priceX64: big,
342
+ livePriceX64: big,
343
+ floorX64: big,
344
+ backedPpm: int,
345
+ bidTopX64: nullable(big),
346
+ lastTrade: nullable(object({ priceAfterX64: big, timestamp: int, block: int })),
347
+ headTimestamp: nullable(int),
348
+ ageS: nullable(int),
349
+ quoteUsd: USD_RATE,
350
+ priceUsd: nullable(decimal),
351
+ });
352
+
353
+ export const WALLET_TRADES = object({ indexed, wallet: str, trades: array(PAGED_TRADE), next: nullable(str) });
354
+
355
+ export const POSITIONS = object({ indexed, wallet: str, positions: array(object({ launch: str, token: str, quote: str, tokens: big })) });
356
+
357
+ export const WALLET_LOCKS = object({
358
+ indexed,
359
+ wallet: str,
360
+ 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) })),
361
+ });
362
+
363
+ const AT = { timestamp: int, block: int };
364
+
365
+ export const INBOX_CLAIMED = object({ ...AT, kind: oneOf("claimed"), launch: str, quote: str, types: int, amount: big, holder: big, txnId: nullable(str) });
366
+
367
+ export const INBOX_GRADUATED = object({ ...AT, kind: oneOf("graduated"), launch: str, priceX64: big, txnId: nullable(str) });
368
+
369
+ export const INBOX_SLOT = object({ ...AT, kind: oneOf("slot"), launch: str, place: int });
370
+
371
+ export const INBOX_DEV_BURN = object({ ...BURN_FIELDS, kind: oneOf("devBurn"), launch: str });
372
+
373
+ 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
+
375
+ export const INBOX_KINDS = ["claimed", "graduated", "slot", "devBurn", "devBuy"] ;
376
+
377
+ const INBOX_BY_KIND = { claimed: INBOX_CLAIMED, graduated: INBOX_GRADUATED, slot: INBOX_SLOT, devBurn: INBOX_DEV_BURN, devBuy: INBOX_DEV_BUY };
378
+
379
+ export function inboxItem(v , p ) {
380
+ const kind = typeof v === "object" && v !== null ? (v ).kind : undefined;
381
+ const d = typeof kind === "string" && Object.hasOwn(INBOX_BY_KIND, kind) ? INBOX_BY_KIND[kind ] : null;
382
+ if (d === null) {
383
+ str(kind, `${p}.kind`);
384
+ return null;
385
+ }
386
+ return d(v, p) ;
387
+ }
388
+
389
+ export const INBOX = object({ indexed, wallet: str, items: (v , p ) => array(inboxItem)(v, p).filter((x) => x !== null) });
390
+
391
+ export const CLAIM_ROW = object({
392
+ block: int,
393
+ timestamp: int,
394
+ txnId: nullable(str),
395
+ sender: str,
396
+ launch: str,
397
+ quote: str,
398
+ types: int,
399
+ creator: big,
400
+ creatorRef: big,
401
+ teamSlot: big,
402
+ traderRef: big,
403
+ holder: big,
404
+ extra: big,
405
+ amount: big,
406
+ teamBuy: big,
407
+ });
408
+
409
+ export const CLAIM_HISTORY = object({ indexed, wallet: str, claims: array(CLAIM_ROW) });
410
+
411
+ const QUOTE_TOTAL = object({ quote: str, total: big, types: int });
412
+
413
+ export const CLAIM_VIEW = object({
414
+ indexed,
415
+ claims: object({
416
+ wallet: str,
417
+ atBlock: nullable(int),
418
+ quotes: array(QUOTE_TOTAL),
419
+ totals: record(big),
420
+ launches: optional(array(object({
421
+ launch: str,
422
+ quoteMint: str,
423
+ places: array(int),
424
+ types: int,
425
+ owed: object({ creator: big, creatorRef: big, teamSlot: big }),
426
+ tokens: object({ teamBuy: big, shareBought: big, teamBuyLockedLot: big }),
427
+ }))),
428
+ refOwed: optional(array(object({ account: str, quoteMint: str, owed: big }))),
429
+ pendingRollUp: optional(array(object({ traderRef: str, quoteMint: str, amount: big }))),
430
+ owed: optional(array(object({ quote: str, creator: big, creatorRef: big, teamSlot: big, traderRef: big, holder: big, teamBuy: big }))),
431
+ }),
432
+ });
433
+
434
+ export const FIRSTS_ROW = object({ firstActivityAt: nullable(int), firstFloorTradeAt: nullable(int) });
435
+
436
+ export const FIRSTS = object({ indexed, wallet: str, firstActivityAt: nullable(int), firstFloorTradeAt: nullable(int) });
437
+ export const FIRSTS_MANY = object({ indexed, wallets: record(FIRSTS_ROW) });
438
+
439
+ const PER_QUOTE = array(object({ quote: str, amount: big }));
440
+
441
+ export const PEOPLE = object({
442
+ indexed,
443
+ wallet: str,
444
+ people: array(object({ wallet: str, chain: str, roles: array(object({ kind: oneOf("trader", "creator"), tier: int })), earned: PER_QUOTE, teamMilestone: PER_QUOTE })),
445
+ });
446
+
447
+ export const ROLES = object({
448
+ indexed,
449
+ wallet: str,
450
+ roles: object({
451
+ traderRefOf: array(object({ quote: str, trader: str, tier: int })),
452
+ registered: array(object({ launch: str, roles: int })),
453
+ refOwedIn: array(str),
454
+ payoutOwedIn: array(str),
455
+ creatorOf: array(str),
456
+ creatorRefOf: array(object({ launch: str, tier: int })),
457
+ teamSlotOf: array(object({ launch: str, place: int })),
458
+ holdings: array(object({ launch: str, token: str, amount: big })),
459
+ }),
460
+ claimed: record(big),
461
+ });
462
+
463
+ export const TRADER_BOARD = object({
464
+ indexed,
465
+ window: oneOf(...TRADER_WINDOWS),
466
+ traders: array(object({ trader: str, volumeUsd: decimal, trades: int, launches: int, volumeByQuote: record(big), tradesByQuote: record(int) })),
467
+ });
468
+
469
+ export const LAUNCHER_BOARD = object({
470
+ indexed,
471
+ 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
+ });
473
+
@@ -0,0 +1,104 @@
1
+
2
+
3
+ import { decode } from "./decode.js";
4
+ import { INDEXER_CONTRACT, clampLimit, routeLimit } from "./contract.js";
5
+
6
+ import { indexerPath, query } from "./paths.js";
7
+
8
+ import { IndexerError } from "./read.js";
9
+
10
+ const need = (s , what ) => {
11
+ if (s === "") throw new RangeError(`an empty ${what}`);
12
+ return s;
13
+ };
14
+
15
+ export const routePath = {
16
+ head: () => indexerPath.head(),
17
+ latestBlock: () => indexerPath.latestBlock(),
18
+ stream: (a) => indexerPath.stream(a),
19
+ quotes: () => indexerPath.quotes(),
20
+ summary: () => indexerPath.summary(),
21
+ floorRouted: () => indexerPath.floorRouted(),
22
+ events: (a) => indexerPath.events(a.fromBlock, a.toBlock),
23
+ launches: (a) => indexerPath.launches(a ?? {}),
24
+ launch: (a) => indexerPath.launch(a.launch),
25
+ launchState: (a) => indexerPath.launchState(a.launch),
26
+ milestones: (a) => indexerPath.milestones(a.launch),
27
+ holders: ({ launch, ...q }) => indexerPath.holders(launch, q),
28
+ trades: ({ launch, ...q }) => indexerPath.trades(launch, q),
29
+ launchClaims: ({ launch, ...q }) => indexerPath.launchClaims(launch, q),
30
+ devBuys: (a) => indexerPath.devBuys(a.launch),
31
+ traders: ({ launch, ...q }) => indexerPath.traders(launch, q),
32
+ quoteChain: (a) => indexerPath.quoteChain(a.launch),
33
+ devTrades: ({ launch, ...q }) => indexerPath.devTrades(launch, q),
34
+ burns: (a) => indexerPath.burns(a.launch),
35
+ launchLocks: (a) => indexerPath.launchLocks(a.launch),
36
+ marks: ({ launch, ...q }) => indexerPath.marks(launch, q),
37
+ price: (a) => indexerPath.price(a.launch),
38
+ highs: ({ launch, ...q }) => indexerPath.highs(launch, q),
39
+ candles: (a) => indexerPath.candles(a),
40
+ candleBundle: ({ launch, ...q }) => indexerPath.candleBundle(launch, q),
41
+ walletTrades: ({ wallet, ...q }) => indexerPath.walletTrades(wallet, q),
42
+ positions: (a) => indexerPath.positions(a.wallet),
43
+ inbox: ({ wallet, ...q }) => indexerPath.inbox(wallet, q),
44
+ walletLocks: (a) => indexerPath.walletLocks(a.wallet),
45
+ claimHistory: (a) => indexerPath.claimHistory(a.wallet),
46
+ firsts: (a) => indexerPath.firsts(a.wallet),
47
+ 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),
51
+ traderBoard: (a) => indexerPath.traderBoard(a ?? {}),
52
+ launcherBoard: (a) => indexerPath.launcherBoard(a ?? {}),
53
+ dexAsset: (a) => `/v2/dex/asset${query({ id: need(a.id, "id") })}`,
54
+ dexSummary: (a) => `/v2/dex/summary${query({ id: need(a.id, "id") })}`,
55
+ dexPair: (a) => `/v2/dex/pair${query({ id: need(a.id, "id") })}`,
56
+ cgPairs: () => "/v2/coingecko/pairs",
57
+ cgTickers: () => "/v2/coingecko/tickers",
58
+ 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 })}`,
59
+ llamaTvl: () => "/v2/defillama/tvl",
60
+ llamaFees: (a) => {
61
+ if (a && a.to < a.from) throw new RangeError("from > to");
62
+ return `/v2/defillama/fees${query({ from: a?.from, to: a?.to })}`;
63
+ },
64
+ health: () => "/health",
65
+ };
66
+
67
+ export function createIndexerClient(opts ) {
68
+
69
+ const clamp = (name , a ) => {
70
+ if (typeof a !== "object" || a === null || !("limit" in a) || typeof (a ).limit !== "number") return a;
71
+ return { ...a, limit: clampLimit(name, (a ).limit) };
72
+ };
73
+ const path = (name , a ) => (routePath[name] )(clamp(name, a));
74
+ const read = async (name , a ) => {
75
+ const c = INDEXER_CONTRACT[name];
76
+ const get = c.mount === "root" ? opts.getRoot : opts.get;
77
+ if (get === undefined) throw new TypeError(`${name} is served at the server's root: pass getRoot`);
78
+ const r = await get(path(name, a));
79
+ if (r.status !== 200) throw new IndexerError(r.status, r.body);
80
+ return decode(c.body , r.body);
81
+ };
82
+ async function* drain(name , a , o = {}) {
83
+ const page = INDEXER_CONTRACT[name].page;
84
+ const max = o.maxPages ?? 100;
85
+ const lim = routeLimit(name) ;
86
+ let args = { ...a };
87
+ for (let i = 0; i < max; i++) {
88
+ const body = (await read(name, args)) ;
89
+ yield body;
90
+ if (page.kind === "cursor") {
91
+ if (body.next === null || body.next === undefined) return;
92
+ args = { ...args, before: body.next };
93
+ } else if (page.kind === "offset") {
94
+ const step = clampLimit(name, (args.limit ) ?? lim.default);
95
+ const offset = ((args.offset ) ?? 0) + step;
96
+ if (offset >= (body.total ?? 0)) return;
97
+ args = { ...args, offset };
98
+ } else throw new TypeError(`${name} does not page`);
99
+ }
100
+ }
101
+ const client = { read, path, drain };
102
+ for (const name of Object.keys(INDEXER_CONTRACT) ) if (name !== "stream") client[name] = (a ) => read(name, a);
103
+ return client ;
104
+ }