@floorlaunchpad/sdk 0.1.1 → 0.3.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 (298) hide show
  1. package/CHANGELOG.md +114 -0
  2. package/LICENSE +201 -60
  3. package/README.md +54 -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 +130 -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 +803 -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 +148 -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/squid.js +107 -0
  37. package/dist/evm/zap.js +128 -0
  38. package/dist/fixtures.js +53 -0
  39. package/dist/generated/index.js +28 -0
  40. package/dist/generated/interface.gen.js +146 -0
  41. package/dist/handle.js +22 -0
  42. package/dist/index.js +93 -7
  43. package/dist/indexer/bodies.js +473 -0
  44. package/dist/indexer/client.js +105 -0
  45. package/dist/indexer/contract.js +358 -0
  46. package/dist/indexer/decode.js +97 -0
  47. package/dist/indexer/partners.js +105 -0
  48. package/dist/indexer/paths.js +127 -0
  49. package/dist/indexer/read.js +109 -0
  50. package/dist/indexer/stream.js +71 -0
  51. package/dist/lock.js +16 -0
  52. package/dist/math/fixed.js +154 -0
  53. package/dist/math/genesis.js +39 -0
  54. package/dist/math/index.js +20 -0
  55. package/dist/math/u256.js +49 -0
  56. package/dist/math/v2/ask.js +162 -0
  57. package/dist/math/v2/book.js +607 -0
  58. package/dist/math/v2/circulating.js +62 -0
  59. package/dist/math/v2/create.js +122 -0
  60. package/dist/math/v2/display.js +208 -0
  61. package/dist/math/v2/error.js +17 -0
  62. package/dist/math/v2/feasibility.js +174 -0
  63. package/dist/math/v2/fees.js +121 -0
  64. package/dist/math/v2/holders.js +105 -0
  65. package/dist/math/v2/milestones.js +40 -0
  66. package/dist/math/v2/pow.js +69 -0
  67. package/dist/math/v2/preset.js +151 -0
  68. package/dist/math/v2/receipt.js +108 -0
  69. package/dist/math/v2/relay.js +217 -0
  70. package/dist/math/v2/rows.js +365 -0
  71. package/dist/math/v2/split.js +111 -0
  72. package/dist/math/v2/sqrt.js +84 -0
  73. package/dist/math/v2/supply.js +21 -0
  74. package/dist/math/v2/team.js +75 -0
  75. package/dist/math/v2/trade.js +126 -0
  76. package/dist/math/v2/wide.js +51 -0
  77. package/dist/quote.js +6 -0
  78. package/dist/registryPrice.js +23 -0
  79. package/dist/route/edge-jupiter.js +42 -0
  80. package/dist/route/edge.js +11 -0
  81. package/dist/route/graph.js +51 -0
  82. package/dist/route/path.js +75 -0
  83. package/dist/route/quote.js +15 -0
  84. package/dist/route-jupiter.js +35 -0
  85. package/dist/route.js +8 -0
  86. package/dist/sha256.js +61 -0
  87. package/dist/solana/alt.js +18 -0
  88. package/dist/solana/floor/accounts.js +392 -0
  89. package/dist/solana/floor/borsh.js +66 -0
  90. package/dist/solana/floor/create.js +65 -0
  91. package/dist/solana/floor/events.js +144 -0
  92. package/dist/solana/floor/genesis.js +91 -0
  93. package/dist/solana/floor/genesisList.js +68 -0
  94. package/dist/solana/floor/instructions.js +448 -0
  95. package/dist/solana/floor/metadata.js +198 -0
  96. package/dist/solana/floor/mint.js +206 -0
  97. package/dist/solana/floor/program.js +64 -0
  98. package/dist/solana/floor/registry.js +83 -0
  99. package/dist/solana/instruction.js +49 -0
  100. package/dist/solana/pda.js +88 -0
  101. package/dist/solana/tx.js +138 -0
  102. package/dist/v2/burnPreview.js +35 -0
  103. package/dist/v2/circulating.js +11 -0
  104. package/dist/v2/claimAllEvm.js +70 -0
  105. package/dist/v2/claims-evm.js +120 -0
  106. package/dist/v2/claims.js +218 -0
  107. package/dist/v2/dead.js +21 -0
  108. package/dist/v2/devbuy.js +37 -0
  109. package/dist/v2/events.js +115 -0
  110. package/dist/v2/evm.js +299 -0
  111. package/dist/v2/evmReads.js +76 -0
  112. package/dist/v2/genesis.js +76 -0
  113. package/dist/v2/layouts.js +217 -0
  114. package/dist/v2/market-evm.js +74 -0
  115. package/dist/v2/presetRowEvm.js +45 -0
  116. package/dist/v2/press.js +106 -0
  117. package/dist/v2/quoteMint.js +52 -0
  118. package/dist/v2/receipt-tx.js +149 -0
  119. package/dist/v2/route-alt.js +114 -0
  120. package/dist/v2/route.js +389 -0
  121. package/dist/v2/router.js +22 -0
  122. package/dist/v2/solana.js +391 -0
  123. package/dist/v2/solanaSettle.js +97 -0
  124. package/dist/v2/tx/evm.js +126 -0
  125. package/dist/v2/tx/genesis.js +47 -0
  126. package/dist/v2/tx/index.js +5 -0
  127. package/dist/v2/tx/solana.js +118 -0
  128. package/dist/v2/types.js +13 -0
  129. package/docs/aggregator.md +61 -0
  130. package/docs/bot.md +50 -0
  131. package/docs/floor-line.md +66 -0
  132. package/docs/frontend.md +29 -0
  133. package/docs/wallet.md +54 -0
  134. package/examples/floor-line.html +104 -0
  135. package/package.json +429 -32
  136. package/src/abi/evm-event-names.ts +12 -0
  137. package/src/abi/evm.gen.ts +139 -0
  138. package/src/abi/functions.gen.ts +154 -0
  139. package/src/abi/index.ts +30 -0
  140. package/src/abi/solana.gen.ts +140 -0
  141. package/src/burn.ts +37 -0
  142. package/src/client/evm/index.ts +199 -0
  143. package/src/client/index.ts +23 -0
  144. package/src/client/solana/index.ts +260 -0
  145. package/src/client/types.ts +162 -0
  146. package/src/codec.ts +77 -0
  147. package/src/config/codeHash.ts +9 -0
  148. package/src/config/generated.ts +803 -0
  149. package/src/config/index.ts +93 -0
  150. package/src/config/registry.gen.ts +118 -0
  151. package/src/config/solana-genesis.ts +7 -0
  152. package/src/ed25519.ts +31 -0
  153. package/src/errors.ts +270 -0
  154. package/src/events/index.ts +44 -0
  155. package/src/events/types.gen.ts +842 -0
  156. package/src/evm/abi.ts +292 -0
  157. package/src/evm/balances.ts +26 -0
  158. package/src/evm/chains.ts +171 -0
  159. package/src/evm/floor/abi.gen.ts +195 -0
  160. package/src/evm/floor/calls.ts +247 -0
  161. package/src/evm/floor/create.ts +68 -0
  162. package/src/evm/floor/events.ts +51 -0
  163. package/src/evm/floor/iface.ts +45 -0
  164. package/src/evm/items.ts +252 -0
  165. package/src/evm/keccak.ts +118 -0
  166. package/src/evm/multicall.ts +43 -0
  167. package/src/evm/router.ts +209 -0
  168. package/src/evm/squid.ts +138 -0
  169. package/src/evm/zap.ts +152 -0
  170. package/src/fixtures.ts +53 -0
  171. package/src/generated/index.ts +29 -0
  172. package/src/generated/interface.gen.ts +153 -0
  173. package/src/handle.ts +22 -0
  174. package/src/index.ts +93 -6
  175. package/src/indexer/bodies.ts +528 -0
  176. package/src/indexer/client.ts +180 -0
  177. package/src/indexer/contract.ts +419 -0
  178. package/src/indexer/decode.ts +109 -0
  179. package/src/indexer/partners.ts +115 -0
  180. package/src/indexer/paths.ts +190 -0
  181. package/src/indexer/read.ts +119 -0
  182. package/src/indexer/stream.ts +83 -0
  183. package/src/lock.ts +16 -0
  184. package/src/math/fixed.ts +154 -0
  185. package/src/math/genesis.ts +39 -0
  186. package/src/math/index.ts +24 -0
  187. package/src/math/u256.ts +49 -0
  188. package/src/math/v2/ask.ts +218 -0
  189. package/src/math/v2/book.ts +660 -0
  190. package/src/math/v2/circulating.ts +69 -0
  191. package/src/math/v2/create.ts +139 -0
  192. package/src/math/v2/display.ts +250 -0
  193. package/src/math/v2/error.ts +19 -0
  194. package/src/math/v2/feasibility.ts +200 -0
  195. package/src/math/v2/fees.ts +121 -0
  196. package/src/math/v2/holders.ts +124 -0
  197. package/src/math/v2/milestones.ts +51 -0
  198. package/src/math/v2/pow.ts +71 -0
  199. package/src/math/v2/preset.ts +189 -0
  200. package/src/math/v2/receipt.ts +162 -0
  201. package/src/math/v2/relay.ts +235 -0
  202. package/src/math/v2/rows.ts +412 -0
  203. package/src/math/v2/split.ts +160 -0
  204. package/src/math/v2/sqrt.ts +86 -0
  205. package/src/math/v2/supply.ts +27 -0
  206. package/src/math/v2/team.ts +75 -0
  207. package/src/math/v2/trade.ts +145 -0
  208. package/src/math/v2/wide.ts +52 -0
  209. package/src/quote.ts +6 -0
  210. package/src/registryPrice.ts +28 -0
  211. package/src/route/edge-jupiter.ts +71 -0
  212. package/src/route/edge.ts +22 -0
  213. package/src/route/graph.ts +77 -0
  214. package/src/route/path.ts +84 -0
  215. package/src/route/quote.ts +46 -0
  216. package/src/route-jupiter.ts +36 -0
  217. package/src/route.ts +8 -0
  218. package/src/sha256.ts +61 -0
  219. package/src/solana/alt.ts +25 -0
  220. package/src/solana/floor/accounts.ts +395 -0
  221. package/src/solana/floor/borsh.ts +66 -0
  222. package/src/solana/floor/create.ts +89 -0
  223. package/src/solana/floor/events.ts +151 -0
  224. package/src/solana/floor/genesis.ts +111 -0
  225. package/src/solana/floor/genesisList.ts +75 -0
  226. package/src/solana/floor/instructions.ts +504 -0
  227. package/src/solana/floor/metadata.ts +246 -0
  228. package/src/solana/floor/mint.ts +242 -0
  229. package/src/solana/floor/program.ts +64 -0
  230. package/src/solana/floor/registry.ts +96 -0
  231. package/src/solana/instruction.ts +61 -0
  232. package/src/solana/pda.ts +91 -0
  233. package/src/solana/tx.ts +143 -0
  234. package/src/v2/burnPreview.ts +52 -0
  235. package/src/v2/circulating.ts +22 -0
  236. package/src/v2/claimAllEvm.ts +97 -0
  237. package/src/v2/claims-evm.ts +179 -0
  238. package/src/v2/claims.ts +288 -0
  239. package/src/v2/dead.ts +21 -0
  240. package/src/v2/devbuy.ts +55 -0
  241. package/src/v2/events.ts +131 -0
  242. package/src/v2/evm.ts +349 -0
  243. package/src/v2/evmReads.ts +121 -0
  244. package/src/v2/genesis.ts +80 -0
  245. package/src/v2/layouts.ts +219 -0
  246. package/src/v2/market-evm.ts +95 -0
  247. package/src/v2/presetRowEvm.ts +54 -0
  248. package/src/v2/press.ts +124 -0
  249. package/src/v2/quoteMint.ts +63 -0
  250. package/src/v2/receipt-tx.ts +251 -0
  251. package/src/v2/route-alt.ts +114 -0
  252. package/src/v2/route.ts +494 -0
  253. package/src/v2/router.ts +22 -0
  254. package/src/v2/solana.ts +439 -0
  255. package/src/v2/solanaSettle.ts +117 -0
  256. package/src/v2/tx/evm.ts +152 -0
  257. package/src/v2/tx/genesis.ts +66 -0
  258. package/src/v2/tx/index.ts +5 -0
  259. package/src/v2/tx/solana.ts +140 -0
  260. package/src/v2/types.ts +284 -0
  261. package/dist/adapter.d.ts +0 -28
  262. package/dist/adapter.d.ts.map +0 -1
  263. package/dist/adapter.js +0 -2
  264. package/dist/adapter.js.map +0 -1
  265. package/dist/chain.d.ts +0 -23
  266. package/dist/chain.d.ts.map +0 -1
  267. package/dist/chain.js +0 -25
  268. package/dist/chain.js.map +0 -1
  269. package/dist/client.d.ts +0 -26
  270. package/dist/client.d.ts.map +0 -1
  271. package/dist/client.js +0 -43
  272. package/dist/client.js.map +0 -1
  273. package/dist/dex-adapter.d.ts +0 -228
  274. package/dist/dex-adapter.d.ts.map +0 -1
  275. package/dist/dex-adapter.js +0 -407
  276. package/dist/dex-adapter.js.map +0 -1
  277. package/dist/index.d.ts +0 -7
  278. package/dist/index.d.ts.map +0 -1
  279. package/dist/index.js.map +0 -1
  280. package/dist/quotes.d.ts +0 -12
  281. package/dist/quotes.d.ts.map +0 -1
  282. package/dist/quotes.gen.d.ts +0 -8
  283. package/dist/quotes.gen.d.ts.map +0 -1
  284. package/dist/quotes.gen.js +0 -2170
  285. package/dist/quotes.gen.js.map +0 -1
  286. package/dist/quotes.js +0 -24
  287. package/dist/quotes.js.map +0 -1
  288. package/dist/types.d.ts +0 -111
  289. package/dist/types.d.ts.map +0 -1
  290. package/dist/types.js +0 -2
  291. package/dist/types.js.map +0 -1
  292. package/src/adapter.ts +0 -20
  293. package/src/chain.ts +0 -39
  294. package/src/client.ts +0 -41
  295. package/src/dex-adapter.ts +0 -477
  296. package/src/quotes.gen.ts +0 -2170
  297. package/src/quotes.ts +0 -29
  298. package/src/types.ts +0 -115
@@ -0,0 +1,392 @@
1
+
2
+
3
+ import { addressBytes, base58Encode, hex } from "../../codec.js";
4
+ import { accountDiscriminator } from "../instruction.js";
5
+
6
+ export const SLOT_MEMBER = [
7
+ ["key", "bytes:32"],
8
+ ["kind", "u8"],
9
+ ["state", "u8"],
10
+ ["pad", "bytes:6"],
11
+ ["paid", "u64"],
12
+ ["requested", "u64"],
13
+ ["earned", "u64"],
14
+ ["withdrawn", "u64"],
15
+ ["reserved", "bytes:8"],
16
+ ];
17
+
18
+ export const CONFIG = [
19
+ ["version", "u8"],
20
+ ["bump", "u8"],
21
+ ["create_paused", "u8"],
22
+ ["next_preset_id", "u8"],
23
+ ["pad0", "bytes:4"],
24
+ ["authority", "pubkey"],
25
+ ["pending_authority", "pubkey"],
26
+ ["timelock", "pubkey"],
27
+ ["referral_authority", "pubkey"],
28
+ ["launch_count", "u64"],
29
+ ["holder_dest", "pubkey"],
30
+
31
+ ["native_create_fee", "u64"],
32
+ ["native_fees_owed", "u64"],
33
+
34
+ ["metadata_base", "bytes:72"],
35
+ ["metadata_base_len", "u8"],
36
+
37
+ ["pad_metadata_base_len", "bytes:7"],
38
+
39
+ ["treasury", "pubkey"],
40
+
41
+ ["price_updater", "pubkey"],
42
+ ];
43
+
44
+ export const QUOTE_ENTRY = [
45
+ ["version", "u8"],
46
+ ["bump", "u8"],
47
+ ["enabled", "u8"],
48
+ ["decimals", "u8"],
49
+ ["pad0", "bytes:4"],
50
+ ["mint", "pubkey"],
51
+ ["token_program", "pubkey"],
52
+ ["create_fee", "u64"],
53
+ ["usd_cents_x64", "u128l"],
54
+ ["launches", "u64"],
55
+ ["updated_at", "i64"],
56
+
57
+ ["admitted_caps", "u32"],
58
+ ["pad1", "u32"],
59
+ ["reserved", "bytes:56"],
60
+ ];
61
+
62
+ export const TEAM_SLOT = [
63
+ ["version", "u8"],
64
+ ["bump", "u8"],
65
+ ["member_count", "u8"],
66
+ ["flags", "u8"],
67
+ ["rate_bps", "u16"],
68
+ ["pad0", "bytes:2"],
69
+ ["price", "u64"],
70
+ ["bought", "u64"],
71
+ ["reserved_total", "u64"],
72
+ ["opened_at", "i64"],
73
+ ["launch", "pubkey"],
74
+ ["creator", "pubkey"],
75
+ ["members", "SlotMember[10]"],
76
+ ["reserved", "bytes:64"],
77
+ ];
78
+
79
+ export const TRADER_REF = [
80
+ ["trader", "pubkey"],
81
+ ["quote_mint", "pubkey"],
82
+ ["tiers", "pubkey[3]"],
83
+ ["owed", "u64[3]"],
84
+ ["rolled", "u64[3]"],
85
+ ["bump", "u8"],
86
+ ["escrow_bump", "u8"],
87
+ ["revoked", "u8"],
88
+
89
+ ["pad0", "bytes:5"],
90
+ ["reserved", "bytes:24"],
91
+ ];
92
+
93
+ export const TRADER_LINK = [
94
+ ["wallet", "pubkey"],
95
+ ["tiers", "pubkey[3]"],
96
+ ["bump", "u8"],
97
+ ["reserved", "bytes:24"],
98
+ ];
99
+
100
+ export const REF_OWED = [
101
+ ["referrer", "pubkey"],
102
+ ["quote_mint", "pubkey"],
103
+ ["owed", "u64"],
104
+ ["paid", "u64"],
105
+ ["bump", "u8"],
106
+ ["pad0", "bytes:7"],
107
+ ["reserved", "bytes:24"],
108
+ ];
109
+
110
+ export const GENESIS_RAISE = [
111
+ ["version", "u8"],
112
+ ["bump", "u8"],
113
+ ["accepted", "u8"],
114
+ ["vault_bump", "u8"],
115
+ ["count", "u16"],
116
+ ["pad0", "bytes:2"],
117
+ ["old_sale", "pubkey"],
118
+ ["total_migrated", "u64"],
119
+ ["donation", "u64"],
120
+ ["accepted_at", "i64"],
121
+ ["accepted_slot", "u64"],
122
+
123
+ ["preset_id", "u8"],
124
+ ["opened", "u8"],
125
+
126
+ ["public_open", "u8"],
127
+ ["pad1", "bytes:5"],
128
+ ["cap", "u64"],
129
+ ["ends_at", "i64"],
130
+ ["migrated_refunded", "u64"],
131
+ ["phase3_total", "u64"],
132
+ ["raised_final", "u64"],
133
+ ["tokens_out", "u64"],
134
+ ["tokens_claimed", "u64"],
135
+ ["weight_total", "u64"],
136
+ ["launch", "pubkey"],
137
+ ["base_mint", "pubkey"],
138
+ ["deployer", "pubkey"],
139
+
140
+ ["refund_total", "u64"],
141
+ ["refund_claimed", "u64"],
142
+ ["credit_claimed", "u64"],
143
+ ["refund_owed", "u64"],
144
+ ["refund_dust", "u64"],
145
+
146
+ ["creator", "pubkey"],
147
+ ["list_root", "bytes:32"],
148
+ ["listed_reserve", "u64"],
149
+ ["listed_total", "u64"],
150
+
151
+ ["wagmi_preset_id", "u8"],
152
+ ["wagmi_opened", "u8"],
153
+ ["pad2", "bytes:6"],
154
+ ["usdc_converted", "u64"],
155
+ ["sol_unconverted", "u64"],
156
+ ["wagmi_usdc", "u64"],
157
+ ["wagmi_floor_in", "u64"],
158
+ ["wagmi_floor_refund", "u64"],
159
+ ["wagmi_floor_refund_claimed", "u64"],
160
+ ["wagmi_tokens_out", "u64"],
161
+ ["wagmi_tokens_claimed", "u64"],
162
+ ["wagmi_launch", "pubkey"],
163
+ ["wagmi_mint", "pubkey"],
164
+ ["sol_converted", "u64"],
165
+ ["floor_usdc_in", "u64"],
166
+ ["usdc_refund_total", "u64"],
167
+ ["usdc_refund_claimed", "u64"],
168
+ ["usdc_refund_owed", "u64"],
169
+ ["usdc_excess", "u64"],
170
+
171
+ ["wagmi_credit_claimed", "u64"],
172
+ ["wagmi_floor_dust", "u64"],
173
+
174
+ ["wagmi_cap_tokens", "u64"],
175
+ ["wagmi_over_cap_floor", "u64"],
176
+ ["wagmi_over_cap_out", "u64"],
177
+
178
+ ["wagmi_buy_fees", "u64[5]"],
179
+ ];
180
+
181
+ export const GENESIS_ALLOCATION = [
182
+ ["wallet", "pubkey"],
183
+ ["contributed", "u64"],
184
+ ["claimed_tokens", "u64"],
185
+ ["refunded", "u64"],
186
+ ["bump", "u8"],
187
+ ["flags", "u8"],
188
+ ["pad0", "bytes:6"],
189
+ ["migrated", "u64"],
190
+
191
+ ["raise_refund", "u64"],
192
+ ["refund_owed", "u64"],
193
+
194
+ ["listed_old", "u64"],
195
+ ["listed", "u64"],
196
+
197
+ ["wagmi_claimed", "u64"],
198
+ ["usdc_refund", "u64"],
199
+ ["usdc_owed", "u64"],
200
+ ];
201
+
202
+ export const GENESIS_ALLOC_MIGRATED = 1;
203
+ export const GENESIS_ALLOC_REFUNDED = 2;
204
+ export const GENESIS_ALLOC_CLAIMED = 4;
205
+ export const GENESIS_ALLOC_WAGMI_CLAIMED = 8;
206
+
207
+ const NESTED = { SlotMember: SLOT_MEMBER };
208
+
209
+ export const LAYOUTS = { Config: CONFIG, QuoteEntry: QUOTE_ENTRY, TeamSlot: TEAM_SLOT, SlotMember: SLOT_MEMBER, TraderRef: TRADER_REF, TraderLink: TRADER_LINK, RefOwed: REF_OWED, GenesisRaise: GENESIS_RAISE, GenesisAllocation: GENESIS_ALLOCATION } ;
210
+
211
+ function scalarSize(t ) {
212
+ switch (t) {
213
+ case "u8":
214
+ return 1;
215
+ case "u16":
216
+ return 2;
217
+ case "u32":
218
+ return 4;
219
+ case "u64":
220
+ case "i64":
221
+ return 8;
222
+ case "u128l":
223
+ return 16;
224
+ case "pubkey":
225
+ return 32;
226
+ }
227
+ if (t.startsWith("bytes:")) return Number(t.slice(6));
228
+ if (t in NESTED) return layoutSize(NESTED[t]);
229
+ throw new Error(`unknown field type ${t}`);
230
+ }
231
+
232
+ export function fieldSize(t ) {
233
+ const m = /^(.+)\[(\d+)\]$/.exec(t);
234
+ return m ? scalarSize(m[1]) * Number(m[2]) : scalarSize(t);
235
+ }
236
+
237
+ export function layoutOffsets(l ) {
238
+ let o = 0;
239
+ return l.map(([n, t]) => {
240
+ const s = fieldSize(t);
241
+ const r = [n, o, s];
242
+ o += s;
243
+ return r;
244
+ });
245
+ }
246
+
247
+ export function layoutSize(l ) {
248
+ return l.reduce((a, [, t]) => a + fieldSize(t), 0);
249
+ }
250
+
251
+ const camel = (s ) => s.replace(/_([a-z0-9])/g, (_, c ) => c.toUpperCase());
252
+
253
+ function readUint(b , o , n ) {
254
+ let v = 0n;
255
+ for (let i = n - 1; i >= 0; i--) v = (v << 8n) | BigInt(b[o + i]);
256
+ return v;
257
+ }
258
+
259
+ function readScalar(b , o , t ) {
260
+ switch (t) {
261
+ case "u8":
262
+ case "u16":
263
+ case "u32":
264
+ return Number(readUint(b, o, scalarSize(t)));
265
+ case "u64":
266
+ return readUint(b, o, 8);
267
+ case "i64": {
268
+ const v = readUint(b, o, 8);
269
+ return v >= 1n << 63n ? v - (1n << 64n) : v;
270
+ }
271
+ case "u128l":
272
+ return readUint(b, o, 16);
273
+ case "pubkey":
274
+ return base58Encode(b.slice(o, o + 32));
275
+ }
276
+ if (t.startsWith("bytes:")) return b.slice(o, o + Number(t.slice(6)));
277
+ if (t in NESTED) return decodeStruct(NESTED[t], b, o);
278
+ throw new Error(`unknown field type ${t}`);
279
+ }
280
+
281
+ export function decodeStruct(l , b , o = 0) {
282
+ const out = {};
283
+ let at = o;
284
+ for (const [n, t] of l) {
285
+ const m = /^(.+)\[(\d+)\]$/.exec(t);
286
+ if (m) {
287
+ const s = scalarSize(m[1]);
288
+ out[camel(n)] = Array.from({ length: Number(m[2]) }, (_, i) => readScalar(b, at + i * s, m[1]));
289
+ } else out[camel(n)] = readScalar(b, at, t);
290
+ at += fieldSize(t);
291
+ }
292
+ return out;
293
+ }
294
+
295
+ function writeScalar(b , o , t , v ) {
296
+ if (v === undefined) return;
297
+ if (t === "pubkey") {
298
+ b.set(addressBytes(v), o);
299
+ return;
300
+ }
301
+ if (t.startsWith("bytes:")) {
302
+ b.set(v, o);
303
+ return;
304
+ }
305
+ if (t in NESTED) {
306
+ encodeStructInto(NESTED[t], v, b, o);
307
+ return;
308
+ }
309
+ const n = scalarSize(t);
310
+ let x = BigInt(v);
311
+ if (t === "i64" && x < 0n) x += 1n << 64n;
312
+ for (let i = 0; i < n; i++) {
313
+ b[o + i] = Number(x & 0xffn);
314
+ x >>= 8n;
315
+ }
316
+ }
317
+
318
+ function encodeStructInto(l , v , b , o ) {
319
+ let at = o;
320
+ for (const [n, t] of l) {
321
+ const x = v[camel(n)];
322
+ const m = /^(.+)\[(\d+)\]$/.exec(t);
323
+ if (m && x !== undefined) {
324
+ const s = scalarSize(m[1]);
325
+ (x ).forEach((e, i) => writeScalar(b, at + i * s, m[1], e));
326
+ } else if (!m) writeScalar(b, at, t, x);
327
+ at += fieldSize(t);
328
+ }
329
+ }
330
+
331
+ export function encodeStruct(l , v ) {
332
+ const b = new Uint8Array(layoutSize(l));
333
+ encodeStructInto(l, v, b, 0);
334
+ return b;
335
+ }
336
+
337
+ export function encodeAccount(name , v ) {
338
+ const l = LAYOUTS[name];
339
+ const b = new Uint8Array(8 + layoutSize(l));
340
+ if (name !== "SlotMember") b.set(accountDiscriminator(name), 0);
341
+ encodeStructInto(l, v, b, 8);
342
+ return b;
343
+ }
344
+
345
+ export class AccountDecodeError extends Error {
346
+ constructor(detail ) {
347
+ super(`floor_amm account: ${detail}`);
348
+ this.name = "AccountDecodeError";
349
+ }
350
+ }
351
+
352
+ export function decodeAccount(name , data ) {
353
+ const l = LAYOUTS[name];
354
+ const d = accountDiscriminator(name);
355
+
356
+ if (data.length !== 8 + layoutSize(l)) throw new AccountDecodeError(`${name}: ${data.length} bytes, want ${8 + layoutSize(l)}`);
357
+ if (hex(data.slice(0, 8)) !== hex(d)) throw new AccountDecodeError(`${name}: wrong discriminator`);
358
+ return decodeStruct(l, data, 8);
359
+ }
360
+
361
+ export const decodeConfig = (d ) => decodeAccount("Config", d);
362
+ export const decodeQuoteEntry = (d ) => decodeAccount("QuoteEntry", d);
363
+ export const decodeTeamSlot = (d ) => decodeAccount("TeamSlot", d);
364
+ export const decodeTraderRef = (d ) => decodeAccount("TraderRef", d);
365
+ export const decodeTraderLink = (d ) => decodeAccount("TraderLink", d);
366
+ export const decodeRefOwed = (d ) => decodeAccount("RefOwed", d);
367
+ export const decodeGenesisRaise = (d ) => decodeAccount("GenesisRaise", d);
368
+ export const decodeGenesisAllocation = (d ) => decodeAccount("GenesisAllocation", d);
369
+
370
+ export function accountKind(data ) {
371
+ const d = hex(data.slice(0, 8));
372
+ for (const name of Object.keys(LAYOUTS) ) {
373
+ if (name === "SlotMember" || hex(accountDiscriminator(name)) !== d) continue;
374
+ if (data.length !== 8 + layoutSize(LAYOUTS[name])) throw new AccountDecodeError(`${name}: ${data.length} bytes, want ${8 + layoutSize(LAYOUTS[name])}`);
375
+ return name;
376
+ }
377
+ return null;
378
+ }
379
+
380
+ export const STATUS_LIVE = 1;
381
+
382
+ export const PRESET_CHECKED_ALL = 2;
383
+
384
+ export const PRESET_CHECKED_STEP1 = 1;
385
+ export const SLOT_ACTIVE = 1;
386
+ export const SLOT_FREE = 2;
387
+
388
+ export function metadataBaseOf(configData ) {
389
+ const c = decodeConfig(configData);
390
+ const n = Math.min(Number(c.metadataBaseLen), 72);
391
+ return new TextDecoder().decode((c.metadataBase ).slice(0, n));
392
+ }
@@ -0,0 +1,66 @@
1
+
2
+
3
+ import { addressBytes, base58Encode } from "../../codec.js";
4
+
5
+ export class Writer {
6
+ parts = [];
7
+ uint(v , n ) {
8
+ let x = BigInt(v);
9
+ if (x < 0n || x >= 1n << BigInt(8 * n)) throw new RangeError(`a ${8 * n}-bit value out of range: ${v}`);
10
+ for (let i = 0; i < n; i++) {
11
+ this.parts.push(Number(x & 0xffn));
12
+ x >>= 8n;
13
+ }
14
+ return this;
15
+ }
16
+ u8 = (v ) => this.uint(v, 1);
17
+ u16 = (v ) => this.uint(v, 2);
18
+ u32 = (v ) => this.uint(v, 4);
19
+ u64 = (v ) => this.uint(v, 8);
20
+ u128 = (v ) => this.uint(v, 16);
21
+ bool = (v ) => this.u8(v ? 1 : 0);
22
+ pubkey = (a ) => this.bytes(addressBytes(a));
23
+ bytes(b ) {
24
+ for (const x of b) this.parts.push(x);
25
+ return this;
26
+ }
27
+ string(s ) {
28
+ const b = new TextEncoder().encode(s);
29
+ return this.u32(b.length).bytes(b);
30
+ }
31
+ done() {
32
+ return Uint8Array.from(this.parts);
33
+ }
34
+ }
35
+
36
+ export class Reader {
37
+ o = 0;
38
+ b ;
39
+ constructor(b ) {
40
+ this.b = b;
41
+ }
42
+ uint(n ) {
43
+ if (this.o + n > this.b.length) throw new RangeError("borsh: data too short");
44
+ let v = 0n;
45
+ for (let i = n - 1; i >= 0; i--) v = (v << 8n) | BigInt(this.b[this.o + i]);
46
+ this.o += n;
47
+ return v;
48
+ }
49
+ u8 = () => Number(this.uint(1));
50
+ u16 = () => Number(this.uint(2));
51
+ u32 = () => Number(this.uint(4));
52
+ u64 = () => this.uint(8);
53
+ i64 = () => {
54
+ const v = this.uint(8);
55
+ return v >= 1n << 63n ? v - (1n << 64n) : v;
56
+ };
57
+ u128 = () => this.uint(16);
58
+ bool = () => this.u8() !== 0;
59
+ bytes(n ) {
60
+ if (this.o + n > this.b.length) throw new RangeError("borsh: data too short");
61
+ const r = this.b.slice(this.o, this.o + n);
62
+ this.o += n;
63
+ return r;
64
+ }
65
+ pubkey = () => base58Encode(this.bytes(32));
66
+ }
@@ -0,0 +1,65 @@
1
+
2
+
3
+ import { MEMBERS_MAX as MAX_MEMBERS } from "../../v2/layouts.js";
4
+ import { createLaunchInstructionV2 } from "../../v2/solana.js";
5
+
6
+ import { computeUnitLimitInstruction, computeUnitPriceInstruction } from "../instruction.js";
7
+ import { PACKET_DATA_SIZE, compileV0Message, transactionSize } from "../tx.js";
8
+
9
+ import { createMintAccounts, teamSlotAddInstruction, TEAM_SLOT_PENDING_HANDLE, TEAM_SLOT_WALLET } from "./instructions.js";
10
+ import { FLOOR_AMM_PROGRAM_ID, teamSlotPda } from "./program.js";
11
+
12
+ export const MAX_TX_LOCKS = 64;
13
+
14
+    
15
+
16
+  
17
+
18
+ export function planCreateWithSlot(p
19
+
20
+ ) {
21
+ const c = p.create;
22
+ const pid = c.programId ?? FLOOR_AMM_PROGRAM_ID;
23
+ if (p.members.length > MAX_MEMBERS) throw new RangeError(`a Team Slot has at most ${MAX_MEMBERS} members (R103)`);
24
+ const mint = createMintAccounts({ ...c, programId: pid });
25
+ const teamSlot = teamSlotPda(mint.launch, pid)[0];
26
+ const pay = { payer: c.creator, launch: mint.launch, teamSlot, quoteMint: c.quoteMint, payerQuote: c.creatorQuote, quoteVault: mint.quoteVault, quoteTokenProgram: c.quoteTokenProgram, baseMint: mint.baseMint, programId: pid };
27
+ const instructions = [
28
+ ...(p.computeUnitLimit !== undefined ? [computeUnitLimitInstruction(p.computeUnitLimit)] : []),
29
+ ...(p.microLamports !== undefined ? [computeUnitPriceInstruction(p.microLamports)] : []),
30
+ createLaunchInstructionV2(c),
31
+
32
+ ...[...p.members.filter((m) => m.payNow), ...p.members.filter((m) => !m.payNow)].map((m) => teamSlotAddInstruction({ ...pay, key: m.key, kind: m.kind, amount: m.amount, payNow: m.payNow })),
33
+ ];
34
+ const compile = (ixs ) => {
35
+ const m = compileV0Message({ payer: c.creator, instructions: ixs, recentBlockhash: p.recentBlockhash, lookupTables: p.lookupTables });
36
+ return { instructions: ixs, message: m, size: transactionSize(m) };
37
+ };
38
+ const whole = compile(instructions);
39
+ const { message, size } = whole;
40
+ const lockSet = new Set ([c.creator]);
41
+ for (const ix of instructions) {
42
+ lockSet.add(ix.programAddress);
43
+ for (const a of ix.accounts) lockSet.add(a.address);
44
+ }
45
+ const fits = size <= PACKET_DATA_SIZE && lockSet.size <= MAX_TX_LOCKS;
46
+
47
+ const transactions = [];
48
+ if (fits) transactions.push(whole);
49
+ else {
50
+ const budget = instructions.slice(0, instructions.length - 1 - p.members.length);
51
+ const adds = instructions.slice(instructions.length - p.members.length);
52
+ let cur = instructions.slice(0, instructions.length - p.members.length);
53
+ for (const a of adds) {
54
+ const next = compile([...cur, a]);
55
+ if (next.size <= PACKET_DATA_SIZE) cur = [...cur, a];
56
+ else {
57
+ transactions.push(compile(cur));
58
+ cur = [...budget, a];
59
+ }
60
+ }
61
+ transactions.push(compile(cur));
62
+ for (const t of transactions) if (t.size > PACKET_DATA_SIZE) throw new RangeError(`a create transaction is ${t.size} B even alone: give a lookup table`);
63
+ }
64
+ return { instructions, message, size, locks: lockSet.size, fits, transactions, teamSlot };
65
+ }
@@ -0,0 +1,144 @@
1
+
2
+
3
+ import { hex } from "../../codec.js";
4
+ import { EVENT_IX_TAG_LE, eventDiscriminator } from "../instruction.js";
5
+ import { Reader } from "./borsh.js";
6
+
7
+ const S = (...f ) => f;
8
+
9
+ export const EVENTS = {
10
+ LaunchCreated: S(["launch", "pubkey"], ["mint", "pubkey"], ["quoteMint", "pubkey"], ["creator", "pubkey"], ["id", "u64"], ["presetId", "u8"], ["presetVersion", "u32"], ["presetHash", "bytes:32"], ["p0X64", "u128"], ["raise", "u64"], ["windowTokens", "u64"], ["creatorBuyTokens", "u64"], ["createFee", "u64"], ["name", "bytes:32"], ["symbol", "bytes:10"], ["slot", "u64"], ["ts", "i64"], ["listed", "bool"], ["quoteUsdCentsX64", "u128"], ["nativeCreateFee", "u64"]),
11
+
12
+ Graduated: S(["launch", "pubkey"], ["priceX64", "u128"], ["windowRaised", "u64"], ["windowTokens", "u64"], ["slot", "u64"], ["ts", "i64"]),
13
+ PotsSwept: S(["launch", "pubkey"], ["amount", "u64"], ["reason", "u8"]),
14
+ Claimed: S(["wallet", "pubkey"], ["sender", "pubkey"], ["launch", "pubkey"], ["quoteMint", "pubkey"], ["types", "u8"], ["creator", "u64"], ["creatorRef", "u64"], ["teamSlot", "u64"], ["traderRef", "u64"], ["extra", "u64"], ["amount", "u64"], ["teamBuy", "u64?"], ["shareBought", "u64?"], ["typesHi", "u8?"]),
15
+
16
+ TeamShareBought: S(["launch", "pubkey"], ["member", "pubkey"], ["place", "u8"], ["spent", "u64"], ["refund", "u64"], ["tokens", "u64"], ["shareLeft", "u64"], ["boughtOwed", "u64"], ["day", "u64"], ["firstToday", "bool"], ["ts", "i64"]),
17
+ PlatformWithdrawn: S(["launch", "pubkey"], ["quoteMint", "pubkey"], ["destination", "pubkey"], ["amount", "u64"], ["owedAfter", "u64"]),
18
+
19
+ HolderWithdrawn: S(["launch", "pubkey"], ["quoteMint", "pubkey"], ["destination", "pubkey"], ["amount", "u64"], ["owedAfter", "u64"]),
20
+ PresetWritten: S(["id", "u8"], ["rowVersion", "u32"], ["enabled", "bool"], ["deleted", "bool"]),
21
+ QuoteWritten: S(["mint", "pubkey"], ["enabled", "bool"], ["createFee", "u64"], ["usdCentsX64", "u128"], ["admittedCaps", "u32"]),
22
+ ConfigWritten: S(["authority", "pubkey"], ["pendingAuthority", "pubkey"], ["timelock", "pubkey"], ["referralAuthority", "pubkey"], ["createPaused", "bool"], ["holderDest", "pubkey"], ["nativeCreateFee", "u64"], ["treasury", "pubkey?"], ["priceUpdater", "pubkey?"]),
23
+
24
+ MetadataBaseSet: S(["base", "bytes:72"], ["len", "u8"]),
25
+ TeamSlotOpened: S(["launch", "pubkey"], ["rateBps", "u16"], ["price", "u64"]),
26
+ TeamSlotMember: S(["launch", "pubkey"], ["index", "u8"], ["key", "bytes:32"], ["kind", "u8"], ["state", "u8"], ["paid", "u64"], ["requested", "u64"], ["bought", "u64"], ["boughtPpm", "u32"]),
27
+ TraderRefOpened: S(["trader", "pubkey"], ["quoteMint", "pubkey"], ["tiers", "pubkey[3]"]),
28
+
29
+ TraderLinkOpened: S(["trader", "pubkey"], ["tiers", "pubkey[3]"]),
30
+
31
+ TraderRefCleared: S(["trader", "pubkey"], ["records", "u16"]),
32
+ CreatorBuyUnlocked: S(["launch", "pubkey"], ["creator", "pubkey"], ["tokens", "u64"], ["members", "u64[10]?"], ["paid", "u64?"]),
33
+ RefOwedOpened: S(["referrer", "pubkey"], ["quoteMint", "pubkey"]),
34
+ RefsRolled: S(["quoteMint", "pubkey"], ["traderRefs", "u16"], ["amount", "u64"]),
35
+ GenesisAccepted: S(["oldSale", "pubkey"], ["count", "u16"], ["totalMigrated", "u64"], ["donation", "u64"]),
36
+ HandleBound: S(["launch", "pubkey"], ["index", "u8"], ["handle", "bytes:32"], ["wallet", "pubkey"]),
37
+
38
+ QuoteShort: S(["launch", "pubkey"], ["quoteVault", "u64"], ["quoteBooked", "u64"], ["short", "u64"], ["slot", "u64"]),
39
+ BackingCredited: S(["launch", "pubkey"], ["donor", "pubkey"], ["amount", "u64"], ["fAfter", "u64"], ["slot", "u64"]),
40
+ CutWithdrawn: S(["launch", "pubkey"], ["amount", "u64"], ["cutOwedAfter", "u64"]),
41
+
42
+ RoleRegistered: S(["wallet", "pubkey"], ["page", "u16"], ["launch", "pubkey"], ["roles", "u8"]),
43
+ ClaimsLutSet: S(["wallet", "pubkey"], ["lookupTable", "pubkey"]),
44
+
45
+ NativeFeesWithdrawn: S(["destination", "pubkey"], ["amount", "u64"], ["owedAfter", "u64"]),
46
+
47
+ GenesisContributed: S(["wallet", "pubkey"], ["amount", "u64"], ["walletTotal", "u64"], ["liveTotal", "u64"]),
48
+ GenesisMigratedRefunded: S(["wallet", "pubkey"], ["amount", "u64"], ["liveTotal", "u64"]),
49
+
50
+ GenesisOpened: S(["launch", "pubkey"], ["mint", "pubkey"], ["raised", "u64"], ["tokens", "u64"], ["donation", "u64"], ["p0X64", "u128"], ["weightTotal", "u64"], ["slotRateBps", "u16"], ["quoteMint", "pubkey?"], ["floorUsdcIn", "u64?"], ["refund", "u64?"], ["usdcExcess", "u64?"], ["solConverted", "u64?"], ["usdcConverted", "u64?"], ["solUnconverted", "u64?"], ["usdcRefund", "u64?"]),
51
+
52
+ GenesisClaimed: S(["wallet", "pubkey"], ["migratedCredit", "u64"], ["phase3Credit", "u64"], ["tokens", "u64"], ["refund", "u64?"], ["listedCredit", "u64?"], ["usdcRefund", "u64?"]),
53
+
54
+ GenesisRefundOwed: S(["wallet", "pubkey"], ["amount", "u64"], ["usdc", "u64?"]),
55
+
56
+ GenesisRefundPaid: S(["wallet", "pubkey"], ["to", "pubkey"], ["amount", "u64"], ["usdc", "u64?"], ["usdcTo", "pubkey?"]),
57
+ GenesisDustSwept: S(["launch", "pubkey"], ["amount", "u64"], ["usdc", "u64?"]),
58
+
59
+ GenesisSolConverted: S(["caller", "pubkey"], ["lamports", "u64"], ["usdc", "u64"], ["solUsdCentsX64", "u128"], ["usdcUsdCentsX64", "u128"], ["discountBps", "u16"], ["solConverted", "u64"], ["usdcConverted", "u64"], ["usdcCaps", "u64"]),
60
+
61
+ GenesisWagmiBought: S(["floorLaunch", "pubkey"], ["usdcIn", "u64"], ["floorOut", "u64"]),
62
+ GenesisWagmiOpened: S(["launch", "pubkey"], ["mint", "pubkey"], ["floorIn", "u64"], ["tokens", "u64"], ["floorRefund", "u64"], ["p0X64", "u128"],
63
+
64
+ ["quoteUsdCentsX64", "u128?"], ["capTokens", "u64?"], ["overCapFloor", "u64?"], ["overCapTokens", "u64?"]),
65
+ GenesisWagmiClaimed: S(["wallet", "pubkey"], ["tokens", "u64"], ["floorBack", "u64"]),
66
+
67
+ GenesisWagmiDustSwept: S(["launch", "pubkey"], ["floor", "u64"]),
68
+
69
+ GenesisListedContributed: S(["wallet", "pubkey"], ["amount", "u64"], ["walletListed", "u64"], ["allowanceLeft", "u64"], ["liveTotal", "u64"]),
70
+
71
+ GenesisListRootSet: S(["signer", "pubkey"], ["oldRoot", "bytes:32"], ["newRoot", "bytes:32"]),
72
+
73
+ BurnsSynced: S(["launch", "pubkey"], ["incinerated", "u64"], ["supply", "u64"], ["sOut", "u64"], ["floorAfterX64", "u128"], ["slot", "u64"]),
74
+
75
+ TokensBurned: S(["launch", "pubkey"], ["wallet", "pubkey"], ["role", "u8"], ["place", "u8"], ["fromTeamBuy", "u64"], ["fromWallet", "u64"], ["balanceBefore", "u64"], ["owedAfter", "u64"], ["split", "u64[10]"], ["supply", "u64"], ["sOut", "u64"], ["floorAfterX64", "u128"], ["slot", "u64"], ["fromShareBought", "u64?"]),
76
+
77
+ GenesisPublicStarted: S(["signer", "pubkey"], ["at", "i64"]),
78
+
79
+ GenesisEndSet: S(["signer", "pubkey"], ["oldEndsAt", "i64"], ["newEndsAt", "i64"]),
80
+ };
81
+
82
+ export const SWEPT_BURN = 0;
83
+ export const SWEPT_EXIT = 1;
84
+
85
+ export const SWEPT_DUST = 3;
86
+
87
+ let disc ;
88
+ const DISC = () => (disc ??= new Map(Object.keys(EVENTS).map((n) => [hex(eventDiscriminator(n)), n])));
89
+
90
+ function readField(r , t ) {
91
+ switch (t) {
92
+ case "pubkey":
93
+ return r.pubkey();
94
+ case "bool":
95
+ return r.bool();
96
+ case "u8":
97
+ return r.u8();
98
+ case "u16":
99
+ return r.u16();
100
+ case "u32":
101
+ return r.u32();
102
+ case "u64":
103
+ return r.u64();
104
+ case "i64":
105
+ return r.i64();
106
+ case "u128":
107
+ return r.u128();
108
+ }
109
+ const m = /^(\w+)[:[](\d+)\]?$/.exec(t) ;
110
+ const n = Number(m[2]);
111
+ if (m[1] === "bytes") return r.bytes(n);
112
+ if (m[1] === "u64") return Array.from({ length: n }, () => r.u64());
113
+ return Array.from({ length: n }, () => r.pubkey());
114
+ }
115
+
116
+ export function decodeEventData(data ) {
117
+ const name = DISC().get(hex(data.slice(0, 8)));
118
+ if (!name) return null;
119
+ const r = new Reader(data.slice(8));
120
+ const fields = {};
121
+ let ended = false;
122
+ for (const [f, t] of EVENTS[name]) {
123
+ if (t.endsWith("?")) {
124
+
125
+ if (ended || r.o === r.b.length) {
126
+ ended = true;
127
+ fields[f] = null;
128
+ continue;
129
+ }
130
+ fields[f] = readField(r, t.slice(0, -1) );
131
+ continue;
132
+ }
133
+ if (ended) throw new RangeError(`${name}: a required field ${f} after an absent appended one`);
134
+ fields[f] = readField(r, t );
135
+ }
136
+
137
+ if (r.o !== r.b.length) throw new RangeError(`${name}: ${r.b.length} body bytes, the schema reads ${r.o}`);
138
+ return { name, fields };
139
+ }
140
+
141
+ export function decodeEventCpi(ixData ) {
142
+ if (ixData.length < 16 || hex(ixData.slice(0, 8)) !== hex(EVENT_IX_TAG_LE)) return null;
143
+ return decodeEventData(ixData.slice(8));
144
+ }