@cubee_ee/sdk 0.1.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 (179) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +110 -0
  3. package/dist/clients/AdminClient.d.ts +61 -0
  4. package/dist/clients/AdminClient.d.ts.map +1 -0
  5. package/dist/clients/AdminClient.js +196 -0
  6. package/dist/clients/AdminClient.js.map +1 -0
  7. package/dist/clients/CubeBackendClient.d.ts +67 -0
  8. package/dist/clients/CubeBackendClient.d.ts.map +1 -0
  9. package/dist/clients/CubeBackendClient.js +126 -0
  10. package/dist/clients/CubeBackendClient.js.map +1 -0
  11. package/dist/clients/CubicPoolClient.d.ts +73 -0
  12. package/dist/clients/CubicPoolClient.d.ts.map +1 -0
  13. package/dist/clients/CubicPoolClient.js +425 -0
  14. package/dist/clients/CubicPoolClient.js.map +1 -0
  15. package/dist/clients/PoolFactoryClient.d.ts +45 -0
  16. package/dist/clients/PoolFactoryClient.d.ts.map +1 -0
  17. package/dist/clients/PoolFactoryClient.js +83 -0
  18. package/dist/clients/PoolFactoryClient.js.map +1 -0
  19. package/dist/clients/RpcClient.d.ts +28 -0
  20. package/dist/clients/RpcClient.d.ts.map +1 -0
  21. package/dist/clients/RpcClient.js +58 -0
  22. package/dist/clients/RpcClient.js.map +1 -0
  23. package/dist/clients/SingleTokenDepositClient.d.ts +45 -0
  24. package/dist/clients/SingleTokenDepositClient.d.ts.map +1 -0
  25. package/dist/clients/SingleTokenDepositClient.js +63 -0
  26. package/dist/clients/SingleTokenDepositClient.js.map +1 -0
  27. package/dist/clients/index.d.ts +8 -0
  28. package/dist/clients/index.d.ts.map +1 -0
  29. package/dist/clients/index.js +24 -0
  30. package/dist/clients/index.js.map +1 -0
  31. package/dist/clients/tx-builders.d.ts +32 -0
  32. package/dist/clients/tx-builders.d.ts.map +1 -0
  33. package/dist/clients/tx-builders.js +398 -0
  34. package/dist/clients/tx-builders.js.map +1 -0
  35. package/dist/config/index.d.ts +60 -0
  36. package/dist/config/index.d.ts.map +1 -0
  37. package/dist/config/index.js +59 -0
  38. package/dist/config/index.js.map +1 -0
  39. package/dist/config/networks.d.ts +10 -0
  40. package/dist/config/networks.d.ts.map +1 -0
  41. package/dist/config/networks.js +31 -0
  42. package/dist/config/networks.js.map +1 -0
  43. package/dist/config/tokens.d.ts +19 -0
  44. package/dist/config/tokens.d.ts.map +1 -0
  45. package/dist/config/tokens.js +43 -0
  46. package/dist/config/tokens.js.map +1 -0
  47. package/dist/idl/cubic_pool.json +2497 -0
  48. package/dist/idl/index.d.ts +975 -0
  49. package/dist/idl/index.d.ts.map +1 -0
  50. package/dist/idl/index.js +18 -0
  51. package/dist/idl/index.js.map +1 -0
  52. package/dist/idl/protocol_admin.json +1816 -0
  53. package/dist/idl/single_token_liquidity.json +745 -0
  54. package/dist/index.d.ts +48 -0
  55. package/dist/index.d.ts.map +1 -0
  56. package/dist/index.js +136 -0
  57. package/dist/index.js.map +1 -0
  58. package/dist/math/cubicMath.d.ts +40 -0
  59. package/dist/math/cubicMath.d.ts.map +1 -0
  60. package/dist/math/cubicMath.js +75 -0
  61. package/dist/math/cubicMath.js.map +1 -0
  62. package/dist/math/fixedPoint.d.ts +14 -0
  63. package/dist/math/fixedPoint.d.ts.map +1 -0
  64. package/dist/math/fixedPoint.js +46 -0
  65. package/dist/math/fixedPoint.js.map +1 -0
  66. package/dist/math/index.d.ts +7 -0
  67. package/dist/math/index.d.ts.map +1 -0
  68. package/dist/math/index.js +23 -0
  69. package/dist/math/index.js.map +1 -0
  70. package/dist/math/logExp.d.ts +15 -0
  71. package/dist/math/logExp.d.ts.map +1 -0
  72. package/dist/math/logExp.js +91 -0
  73. package/dist/math/logExp.js.map +1 -0
  74. package/dist/math/singleToken.d.ts +53 -0
  75. package/dist/math/singleToken.d.ts.map +1 -0
  76. package/dist/math/singleToken.js +185 -0
  77. package/dist/math/singleToken.js.map +1 -0
  78. package/dist/math/slippage.d.ts +24 -0
  79. package/dist/math/slippage.d.ts.map +1 -0
  80. package/dist/math/slippage.js +54 -0
  81. package/dist/math/slippage.js.map +1 -0
  82. package/dist/math/weightedMath.d.ts +18 -0
  83. package/dist/math/weightedMath.d.ts.map +1 -0
  84. package/dist/math/weightedMath.js +45 -0
  85. package/dist/math/weightedMath.js.map +1 -0
  86. package/dist/parsers/borsh.d.ts +24 -0
  87. package/dist/parsers/borsh.d.ts.map +1 -0
  88. package/dist/parsers/borsh.js +80 -0
  89. package/dist/parsers/borsh.js.map +1 -0
  90. package/dist/parsers/events.d.ts +3 -0
  91. package/dist/parsers/events.d.ts.map +1 -0
  92. package/dist/parsers/events.js +172 -0
  93. package/dist/parsers/events.js.map +1 -0
  94. package/dist/parsers/index.d.ts +5 -0
  95. package/dist/parsers/index.d.ts.map +1 -0
  96. package/dist/parsers/index.js +21 -0
  97. package/dist/parsers/index.js.map +1 -0
  98. package/dist/parsers/mintAccount.d.ts +22 -0
  99. package/dist/parsers/mintAccount.d.ts.map +1 -0
  100. package/dist/parsers/mintAccount.js +22 -0
  101. package/dist/parsers/mintAccount.js.map +1 -0
  102. package/dist/parsers/poolAccount.d.ts +32 -0
  103. package/dist/parsers/poolAccount.d.ts.map +1 -0
  104. package/dist/parsers/poolAccount.js +88 -0
  105. package/dist/parsers/poolAccount.js.map +1 -0
  106. package/dist/types/events.d.ts +82 -0
  107. package/dist/types/events.d.ts.map +1 -0
  108. package/dist/types/events.js +3 -0
  109. package/dist/types/events.js.map +1 -0
  110. package/dist/types/index.d.ts +5 -0
  111. package/dist/types/index.d.ts.map +1 -0
  112. package/dist/types/index.js +21 -0
  113. package/dist/types/index.js.map +1 -0
  114. package/dist/types/pool.d.ts +66 -0
  115. package/dist/types/pool.d.ts.map +1 -0
  116. package/dist/types/pool.js +3 -0
  117. package/dist/types/pool.js.map +1 -0
  118. package/dist/types/result.d.ts +23 -0
  119. package/dist/types/result.d.ts.map +1 -0
  120. package/dist/types/result.js +11 -0
  121. package/dist/types/result.js.map +1 -0
  122. package/dist/types/tx.d.ts +80 -0
  123. package/dist/types/tx.d.ts.map +1 -0
  124. package/dist/types/tx.js +3 -0
  125. package/dist/types/tx.js.map +1 -0
  126. package/dist/utils/errors.d.ts +8 -0
  127. package/dist/utils/errors.d.ts.map +1 -0
  128. package/dist/utils/errors.js +83 -0
  129. package/dist/utils/errors.js.map +1 -0
  130. package/dist/utils/index.d.ts +4 -0
  131. package/dist/utils/index.d.ts.map +1 -0
  132. package/dist/utils/index.js +20 -0
  133. package/dist/utils/index.js.map +1 -0
  134. package/dist/utils/pda.d.ts +8 -0
  135. package/dist/utils/pda.d.ts.map +1 -0
  136. package/dist/utils/pda.js +27 -0
  137. package/dist/utils/pda.js.map +1 -0
  138. package/dist/utils/retry.d.ts +22 -0
  139. package/dist/utils/retry.d.ts.map +1 -0
  140. package/dist/utils/retry.js +62 -0
  141. package/dist/utils/retry.js.map +1 -0
  142. package/package.json +54 -0
  143. package/src/clients/AdminClient.ts +254 -0
  144. package/src/clients/CubeBackendClient.ts +193 -0
  145. package/src/clients/CubicPoolClient.ts +492 -0
  146. package/src/clients/PoolFactoryClient.ts +102 -0
  147. package/src/clients/RpcClient.ts +78 -0
  148. package/src/clients/SingleTokenDepositClient.ts +91 -0
  149. package/src/clients/index.ts +7 -0
  150. package/src/clients/tx-builders.ts +538 -0
  151. package/src/config/index.ts +82 -0
  152. package/src/config/networks.ts +49 -0
  153. package/src/config/tokens.ts +52 -0
  154. package/src/idl/cubic_pool.json +2497 -0
  155. package/src/idl/index.ts +13 -0
  156. package/src/idl/protocol_admin.json +1816 -0
  157. package/src/idl/single_token_liquidity.json +745 -0
  158. package/src/index.ts +154 -0
  159. package/src/math/cubicMath.ts +89 -0
  160. package/src/math/fixedPoint.ts +39 -0
  161. package/src/math/index.ts +6 -0
  162. package/src/math/logExp.ts +82 -0
  163. package/src/math/singleToken.ts +250 -0
  164. package/src/math/slippage.ts +49 -0
  165. package/src/math/weightedMath.ts +48 -0
  166. package/src/parsers/borsh.ts +80 -0
  167. package/src/parsers/events.ts +172 -0
  168. package/src/parsers/index.ts +4 -0
  169. package/src/parsers/mintAccount.ts +37 -0
  170. package/src/parsers/poolAccount.ts +113 -0
  171. package/src/types/events.ts +100 -0
  172. package/src/types/index.ts +4 -0
  173. package/src/types/pool.ts +64 -0
  174. package/src/types/result.ts +45 -0
  175. package/src/types/tx.ts +87 -0
  176. package/src/utils/errors.ts +78 -0
  177. package/src/utils/index.ts +3 -0
  178. package/src/utils/pda.ts +58 -0
  179. package/src/utils/retry.ts +85 -0
@@ -0,0 +1,2497 @@
1
+ {
2
+ "address": "8iQtGj9mcUfFUGaiCpPy89swC3s8YTC8FhVZWfgeZhwu",
3
+ "metadata": {
4
+ "name": "cubic_pool",
5
+ "version": "0.5.1",
6
+ "spec": "0.1.0",
7
+ "description": "Cubic Pool DEX - Multi-pool DEX with virtual liquidity and leverage logic"
8
+ },
9
+ "instructions": [
10
+ {
11
+ "name": "accept_pool_admin_transfer",
12
+ "docs": [
13
+ "Step 2 — pending admin claims."
14
+ ],
15
+ "discriminator": [
16
+ 155,
17
+ 46,
18
+ 127,
19
+ 94,
20
+ 247,
21
+ 5,
22
+ 46,
23
+ 184
24
+ ],
25
+ "accounts": [
26
+ {
27
+ "name": "pool",
28
+ "writable": true
29
+ },
30
+ {
31
+ "name": "new_admin",
32
+ "signer": true
33
+ }
34
+ ],
35
+ "args": []
36
+ },
37
+ {
38
+ "name": "accept_protocol_admin_transfer",
39
+ "docs": [
40
+ "Step 2 — pending admin claims."
41
+ ],
42
+ "discriminator": [
43
+ 109,
44
+ 70,
45
+ 85,
46
+ 195,
47
+ 244,
48
+ 39,
49
+ 244,
50
+ 102
51
+ ],
52
+ "accounts": [
53
+ {
54
+ "name": "config",
55
+ "writable": true
56
+ },
57
+ {
58
+ "name": "new_admin",
59
+ "signer": true
60
+ }
61
+ ],
62
+ "args": []
63
+ },
64
+ {
65
+ "name": "add_liquidity",
66
+ "docs": [
67
+ "Add proportional liquidity and mint BPT to the user.",
68
+ "",
69
+ "# Parameters",
70
+ "* `token_amounts` — per-token deposit amounts in pool order.",
71
+ "* `minimum_bpt_amount`— slippage floor on BPT received.",
72
+ "",
73
+ "# Used by",
74
+ "User wallets, single-token-liquidity helper."
75
+ ],
76
+ "discriminator": [
77
+ 181,
78
+ 157,
79
+ 89,
80
+ 67,
81
+ 143,
82
+ 182,
83
+ 52,
84
+ 72
85
+ ],
86
+ "accounts": [
87
+ {
88
+ "name": "pool",
89
+ "writable": true
90
+ },
91
+ {
92
+ "name": "bpt_mint",
93
+ "writable": true
94
+ },
95
+ {
96
+ "name": "user_bpt_account",
97
+ "writable": true
98
+ },
99
+ {
100
+ "name": "user",
101
+ "signer": true
102
+ },
103
+ {
104
+ "name": "token_program",
105
+ "docs": [
106
+ "Token program for the BPT mint (same one used for `bpt_mint`).",
107
+ "Per-token programs come via `remaining_accounts` because each",
108
+ "pool token may use a different program."
109
+ ]
110
+ }
111
+ ],
112
+ "args": [
113
+ {
114
+ "name": "token_amounts",
115
+ "type": {
116
+ "vec": "u64"
117
+ }
118
+ },
119
+ {
120
+ "name": "minimum_bpt_amount",
121
+ "type": "u64"
122
+ }
123
+ ]
124
+ },
125
+ {
126
+ "name": "cancel_pool_admin_transfer",
127
+ "docs": [
128
+ "Cancel a pending pool-admin transfer."
129
+ ],
130
+ "discriminator": [
131
+ 151,
132
+ 135,
133
+ 205,
134
+ 125,
135
+ 93,
136
+ 160,
137
+ 135,
138
+ 143
139
+ ],
140
+ "accounts": [
141
+ {
142
+ "name": "pool",
143
+ "writable": true
144
+ },
145
+ {
146
+ "name": "authority",
147
+ "signer": true
148
+ }
149
+ ],
150
+ "args": []
151
+ },
152
+ {
153
+ "name": "cancel_protocol_admin_transfer",
154
+ "docs": [
155
+ "Cancel a pending protocol-admin transfer."
156
+ ],
157
+ "discriminator": [
158
+ 183,
159
+ 26,
160
+ 130,
161
+ 6,
162
+ 131,
163
+ 36,
164
+ 32,
165
+ 186
166
+ ],
167
+ "accounts": [
168
+ {
169
+ "name": "config",
170
+ "writable": true
171
+ },
172
+ {
173
+ "name": "authority",
174
+ "signer": true
175
+ }
176
+ ],
177
+ "args": []
178
+ },
179
+ {
180
+ "name": "collect_protocol_fees",
181
+ "docs": [
182
+ "Sweep `protocol_fees_owed` for every token to caller-supplied",
183
+ "recipients and zero the counters.",
184
+ "",
185
+ "# Authority",
186
+ "`protocol_admin` AND Treasury PDA.",
187
+ "",
188
+ "# remaining_accounts",
189
+ "`[vault_i, recipient_i, token_program_i]` per token.",
190
+ "",
191
+ "# Used by",
192
+ "`protocol_admin::pool_collect_protocol_fees` (CPI)."
193
+ ],
194
+ "discriminator": [
195
+ 22,
196
+ 67,
197
+ 23,
198
+ 98,
199
+ 150,
200
+ 178,
201
+ 70,
202
+ 220
203
+ ],
204
+ "accounts": [
205
+ {
206
+ "name": "config"
207
+ },
208
+ {
209
+ "name": "pool",
210
+ "writable": true
211
+ },
212
+ {
213
+ "name": "authority",
214
+ "signer": true
215
+ }
216
+ ],
217
+ "args": []
218
+ },
219
+ {
220
+ "name": "debug_withdraw_liquidity",
221
+ "docs": [
222
+ "Emergency drain — pool becomes BRICKED.",
223
+ "",
224
+ "`actual_balances` and `virtual_balances` are intentionally NOT",
225
+ "updated. Once vaults are drained out-of-band the invariant math",
226
+ "is meaningless, so the pool MUST stay `pool_enabled = false`",
227
+ "forever. Re-enabling would let users swap/join against stale",
228
+ "state and extract value at LP / protocol expense.",
229
+ "",
230
+ "# Authority",
231
+ "`protocol_admin` AND Treasury PDA.",
232
+ "",
233
+ "# Prerequisites",
234
+ "`pool.pool_enabled == false` (handler enforces).",
235
+ "",
236
+ "# Parameters",
237
+ "* `token_amounts` — per-token withdraw amounts (use 0 to skip).",
238
+ "",
239
+ "# Used by",
240
+ "`protocol_admin::pool_debug_withdraw_liquidity` (CPI),",
241
+ "driven by `admin-panel/03-emergency-withdraw.ts`."
242
+ ],
243
+ "discriminator": [
244
+ 139,
245
+ 40,
246
+ 126,
247
+ 103,
248
+ 199,
249
+ 34,
250
+ 143,
251
+ 137
252
+ ],
253
+ "accounts": [
254
+ {
255
+ "name": "config"
256
+ },
257
+ {
258
+ "name": "pool",
259
+ "writable": true
260
+ },
261
+ {
262
+ "name": "authority",
263
+ "signer": true
264
+ }
265
+ ],
266
+ "args": [
267
+ {
268
+ "name": "token_amounts",
269
+ "type": {
270
+ "vec": "u64"
271
+ }
272
+ }
273
+ ]
274
+ },
275
+ {
276
+ "name": "disable_pool_admin",
277
+ "docs": [
278
+ "Permanently renounce pool-admin on this pool. Single-step,",
279
+ "irreversible."
280
+ ],
281
+ "discriminator": [
282
+ 106,
283
+ 106,
284
+ 112,
285
+ 255,
286
+ 92,
287
+ 31,
288
+ 2,
289
+ 138
290
+ ],
291
+ "accounts": [
292
+ {
293
+ "name": "pool",
294
+ "writable": true
295
+ },
296
+ {
297
+ "name": "authority",
298
+ "signer": true
299
+ }
300
+ ],
301
+ "args": []
302
+ },
303
+ {
304
+ "name": "get_pool_info",
305
+ "docs": [
306
+ "Read-only \"view\": emit a `PoolInfo` event with the pool's full",
307
+ "state. Intended for `simulate({ commitment: ... })` calls; not",
308
+ "useful as part of a signed transaction.",
309
+ "",
310
+ "# Used by",
311
+ "SDK helpers, frontend pool-detail pages, indexer health-check",
312
+ "fallback."
313
+ ],
314
+ "discriminator": [
315
+ 9,
316
+ 48,
317
+ 220,
318
+ 101,
319
+ 22,
320
+ 240,
321
+ 78,
322
+ 200
323
+ ],
324
+ "accounts": [
325
+ {
326
+ "name": "pool"
327
+ }
328
+ ],
329
+ "args": []
330
+ },
331
+ {
332
+ "name": "initialize_config",
333
+ "docs": [
334
+ "Initialise a new `CubicPoolConfig`. Treasury wrapper passes the",
335
+ "Treasury PDA as both admin pubkeys; direct calls produce",
336
+ "Initialise a fresh `CubicPoolConfig`.",
337
+ "",
338
+ "# Parameters",
339
+ "* `protocol_admin` — pubkey allowed to pause pools, set",
340
+ "`protocol_fee_rate`, collect fees, drain via debug-withdraw,",
341
+ "update banned extensions, and rotate itself via the",
342
+ "pending/accept flow.",
343
+ "* `default_protocol_fee_rate`— seeded onto every new pool under",
344
+ "this config (basis points, ≤ `MAX_PROTOCOL_FEE_RATE`).",
345
+ "",
346
+ "Pool-admin (level-1) is per-pool — set automatically to the wallet",
347
+ "that calls `initialize_cubic_pool`."
348
+ ],
349
+ "discriminator": [
350
+ 208,
351
+ 127,
352
+ 21,
353
+ 1,
354
+ 194,
355
+ 190,
356
+ 196,
357
+ 70
358
+ ],
359
+ "accounts": [
360
+ {
361
+ "name": "config",
362
+ "writable": true,
363
+ "signer": true
364
+ },
365
+ {
366
+ "name": "payer",
367
+ "docs": [
368
+ "Pays the rent for `config`. Must be a `Signer`."
369
+ ],
370
+ "writable": true,
371
+ "signer": true
372
+ },
373
+ {
374
+ "name": "system_program"
375
+ }
376
+ ],
377
+ "args": [
378
+ {
379
+ "name": "protocol_admin",
380
+ "type": "pubkey"
381
+ },
382
+ {
383
+ "name": "default_protocol_fee_rate",
384
+ "type": "u16"
385
+ }
386
+ ]
387
+ },
388
+ {
389
+ "name": "initialize_cubic_pool",
390
+ "docs": [
391
+ "Initialise a fresh pool under `config`. Creates the pool PDA and",
392
+ "BPT mint, validates token mints / weights / virtual balances, and",
393
+ "pins per-token programs.",
394
+ "",
395
+ "# Parameters",
396
+ "* `tokens` — pool token mints, length 2..=10,",
397
+ "unique.",
398
+ "* `normalized_weights` — basis points, sum = `WEIGHT_SCALE`.",
399
+ "* `initial_virtual_balances` — seed virtual balances (raw units),",
400
+ "each > 0.",
401
+ "* `swap_fee_rate` — hundredths of bps,",
402
+ "≤ `MAX_SWAP_FEE_RATE`.",
403
+ "* `pool_id` — caller-chosen 64-bit salt baked",
404
+ "into PDA seeds. Unique per config.",
405
+ "",
406
+ "# remaining_accounts",
407
+ "One mint account per token in `tokens` order.",
408
+ "",
409
+ "# Used by",
410
+ "SDK `PoolFactoryClient.buildDeployPoolTx`, deploy-pool scripts."
411
+ ],
412
+ "discriminator": [
413
+ 215,
414
+ 148,
415
+ 116,
416
+ 207,
417
+ 121,
418
+ 104,
419
+ 111,
420
+ 131
421
+ ],
422
+ "accounts": [
423
+ {
424
+ "name": "config",
425
+ "docs": [
426
+ "Parent governance config. Read-only — only its pubkey and the",
427
+ "`default_protocol_fee_rate` / `banned_extensions` are consumed."
428
+ ]
429
+ },
430
+ {
431
+ "name": "pool",
432
+ "docs": [
433
+ "New pool PDA. Seeded so multiple pools per config are possible",
434
+ "via distinct `pool_id` values."
435
+ ],
436
+ "writable": true
437
+ },
438
+ {
439
+ "name": "bpt_mint",
440
+ "docs": [
441
+ "Brand-new BPT mint. Authority is the pool PDA, decimals fixed at",
442
+ "`BPT_DECIMALS` (= 9). `mint::token_program` follows the",
443
+ "`token_program` account passed below — this only constrains BPT,",
444
+ "not the per-pool tokens."
445
+ ],
446
+ "writable": true
447
+ },
448
+ {
449
+ "name": "payer",
450
+ "writable": true,
451
+ "signer": true
452
+ },
453
+ {
454
+ "name": "token_program"
455
+ },
456
+ {
457
+ "name": "associated_token_program"
458
+ },
459
+ {
460
+ "name": "system_program"
461
+ }
462
+ ],
463
+ "args": [
464
+ {
465
+ "name": "tokens",
466
+ "type": {
467
+ "vec": "pubkey"
468
+ }
469
+ },
470
+ {
471
+ "name": "normalized_weights",
472
+ "type": {
473
+ "vec": "u64"
474
+ }
475
+ },
476
+ {
477
+ "name": "initial_virtual_balances",
478
+ "type": {
479
+ "vec": "u64"
480
+ }
481
+ },
482
+ {
483
+ "name": "swap_fee_rate",
484
+ "type": "u32"
485
+ },
486
+ {
487
+ "name": "pool_id",
488
+ "type": "u64"
489
+ }
490
+ ]
491
+ },
492
+ {
493
+ "name": "initiate_pool_admin_transfer",
494
+ "docs": [
495
+ "Step 1 — current `pool.pool_admin` proposes a successor."
496
+ ],
497
+ "discriminator": [
498
+ 10,
499
+ 148,
500
+ 147,
501
+ 98,
502
+ 73,
503
+ 190,
504
+ 31,
505
+ 43
506
+ ],
507
+ "accounts": [
508
+ {
509
+ "name": "pool",
510
+ "writable": true
511
+ },
512
+ {
513
+ "name": "authority",
514
+ "signer": true
515
+ }
516
+ ],
517
+ "args": [
518
+ {
519
+ "name": "new_admin",
520
+ "type": "pubkey"
521
+ }
522
+ ]
523
+ },
524
+ {
525
+ "name": "initiate_protocol_admin_transfer",
526
+ "docs": [
527
+ "Step 1 — current `config.protocol_admin` proposes a successor."
528
+ ],
529
+ "discriminator": [
530
+ 167,
531
+ 129,
532
+ 39,
533
+ 182,
534
+ 10,
535
+ 106,
536
+ 51,
537
+ 148
538
+ ],
539
+ "accounts": [
540
+ {
541
+ "name": "config",
542
+ "writable": true
543
+ },
544
+ {
545
+ "name": "authority",
546
+ "signer": true
547
+ }
548
+ ],
549
+ "args": [
550
+ {
551
+ "name": "new_admin",
552
+ "type": "pubkey"
553
+ }
554
+ ]
555
+ },
556
+ {
557
+ "name": "remove_liquidity",
558
+ "docs": [
559
+ "Burn BPT proportionally and pay out tokens.",
560
+ "",
561
+ "# Minimum-supply floor",
562
+ "The pool always retains at least `MINIMUM_INITIAL_BPT` of supply",
563
+ "so the proportional math never sees a zero-supply state. If the",
564
+ "caller's `bpt_amount` would push supply below the floor, the burn",
565
+ "is silently capped at `total_supply - MINIMUM_INITIAL_BPT` and",
566
+ "the residual BPT stays in the user's wallet.",
567
+ "",
568
+ "# Parameters",
569
+ "* `bpt_amount` — caller's requested burn (raw BPT).",
570
+ "* `minimum_token_amounts` — per-token slippage floors against the",
571
+ "*effective* (capped) burn.",
572
+ "",
573
+ "# Used by",
574
+ "User wallets, SDK `LiquidityClient`."
575
+ ],
576
+ "discriminator": [
577
+ 80,
578
+ 85,
579
+ 209,
580
+ 72,
581
+ 24,
582
+ 206,
583
+ 177,
584
+ 108
585
+ ],
586
+ "accounts": [
587
+ {
588
+ "name": "pool",
589
+ "writable": true
590
+ },
591
+ {
592
+ "name": "bpt_mint",
593
+ "writable": true
594
+ },
595
+ {
596
+ "name": "user_bpt_account",
597
+ "writable": true
598
+ },
599
+ {
600
+ "name": "user",
601
+ "signer": true
602
+ },
603
+ {
604
+ "name": "token_program"
605
+ }
606
+ ],
607
+ "args": [
608
+ {
609
+ "name": "bpt_amount",
610
+ "type": "u64"
611
+ },
612
+ {
613
+ "name": "minimum_token_amounts",
614
+ "type": {
615
+ "vec": "u64"
616
+ }
617
+ }
618
+ ]
619
+ },
620
+ {
621
+ "name": "set_banned_extensions",
622
+ "docs": [
623
+ "Update the Token-2022 banned-extensions bitmap on a config.",
624
+ "Only affects future pool inits.",
625
+ "",
626
+ "# Authority",
627
+ "`protocol_admin` AND Treasury PDA.",
628
+ "",
629
+ "# Used by",
630
+ "`protocol_admin::pool_set_banned_extensions` (CPI)."
631
+ ],
632
+ "discriminator": [
633
+ 86,
634
+ 95,
635
+ 249,
636
+ 149,
637
+ 142,
638
+ 105,
639
+ 100,
640
+ 151
641
+ ],
642
+ "accounts": [
643
+ {
644
+ "name": "config",
645
+ "writable": true
646
+ },
647
+ {
648
+ "name": "authority",
649
+ "signer": true
650
+ }
651
+ ],
652
+ "args": [
653
+ {
654
+ "name": "banned_extensions",
655
+ "type": "u64"
656
+ }
657
+ ]
658
+ },
659
+ {
660
+ "name": "set_pool_enabled",
661
+ "docs": [
662
+ "Master pool kill-switch. When `enabled = false`, swaps and",
663
+ "add/remove liquidity all revert.",
664
+ "",
665
+ "# Authority",
666
+ "`protocol_admin` AND Treasury PDA.",
667
+ "",
668
+ "# Used by",
669
+ "`protocol_admin::pool_set_pool_enabled` (CPI)."
670
+ ],
671
+ "discriminator": [
672
+ 53,
673
+ 76,
674
+ 170,
675
+ 37,
676
+ 55,
677
+ 222,
678
+ 63,
679
+ 21
680
+ ],
681
+ "accounts": [
682
+ {
683
+ "name": "config"
684
+ },
685
+ {
686
+ "name": "pool",
687
+ "writable": true
688
+ },
689
+ {
690
+ "name": "authority",
691
+ "signer": true
692
+ }
693
+ ],
694
+ "args": [
695
+ {
696
+ "name": "enabled",
697
+ "type": "bool"
698
+ }
699
+ ]
700
+ },
701
+ {
702
+ "name": "set_protocol_fee_rate",
703
+ "docs": [
704
+ "Set `pool.protocol_fee_rate`.",
705
+ "",
706
+ "# Authority",
707
+ "`protocol_admin` AND Treasury PDA.",
708
+ "",
709
+ "# Parameters",
710
+ "* `protocol_fee_rate` — basis points, ≤ `MAX_PROTOCOL_FEE_RATE`.",
711
+ "",
712
+ "# Used by",
713
+ "`protocol_admin::pool_set_protocol_fee_rate` (CPI)."
714
+ ],
715
+ "discriminator": [
716
+ 95,
717
+ 7,
718
+ 4,
719
+ 50,
720
+ 154,
721
+ 79,
722
+ 156,
723
+ 131
724
+ ],
725
+ "accounts": [
726
+ {
727
+ "name": "config"
728
+ },
729
+ {
730
+ "name": "pool",
731
+ "writable": true
732
+ },
733
+ {
734
+ "name": "authority",
735
+ "signer": true
736
+ }
737
+ ],
738
+ "args": [
739
+ {
740
+ "name": "protocol_fee_rate",
741
+ "type": "u16"
742
+ }
743
+ ]
744
+ },
745
+ {
746
+ "name": "set_swap_fee_rate",
747
+ "docs": [
748
+ "Set `pool.swap_fee_rate`.",
749
+ "",
750
+ "# Authority",
751
+ "`pool_admin` AND Treasury PDA.",
752
+ "",
753
+ "# Parameters",
754
+ "* `swap_fee_rate` — hundredths of bps, ≤ `MAX_SWAP_FEE_RATE`.",
755
+ "",
756
+ "# Used by",
757
+ "`protocol_admin::pool_set_swap_fee_rate` (CPI)."
758
+ ],
759
+ "discriminator": [
760
+ 144,
761
+ 102,
762
+ 81,
763
+ 175,
764
+ 135,
765
+ 50,
766
+ 36,
767
+ 191
768
+ ],
769
+ "accounts": [
770
+ {
771
+ "name": "pool",
772
+ "docs": [
773
+ "Mutated. `authority` must equal `pool.pool_admin` (storage-only",
774
+ "admin pubkey; no hardcoded address)."
775
+ ],
776
+ "writable": true
777
+ },
778
+ {
779
+ "name": "authority",
780
+ "signer": true
781
+ }
782
+ ],
783
+ "args": [
784
+ {
785
+ "name": "swap_fee_rate",
786
+ "type": "u32"
787
+ }
788
+ ]
789
+ },
790
+ {
791
+ "name": "set_swaps_enabled",
792
+ "docs": [
793
+ "Per-pool swap toggle (less invasive than `set_pool_enabled` —",
794
+ "LPs can still add/remove liquidity).",
795
+ "",
796
+ "# Authority",
797
+ "`pool_admin` OR `protocol_admin`, AND Treasury PDA.",
798
+ "",
799
+ "# Used by",
800
+ "`protocol_admin::pool_set_swaps_enabled` (CPI)."
801
+ ],
802
+ "discriminator": [
803
+ 144,
804
+ 154,
805
+ 205,
806
+ 58,
807
+ 241,
808
+ 169,
809
+ 64,
810
+ 40
811
+ ],
812
+ "accounts": [
813
+ {
814
+ "name": "config"
815
+ },
816
+ {
817
+ "name": "pool",
818
+ "writable": true
819
+ },
820
+ {
821
+ "name": "authority",
822
+ "signer": true
823
+ }
824
+ ],
825
+ "args": [
826
+ {
827
+ "name": "enabled",
828
+ "type": "bool"
829
+ }
830
+ ]
831
+ },
832
+ {
833
+ "name": "swap",
834
+ "docs": [
835
+ "Swap one pool token for another using `calc_out_given_in`.",
836
+ "",
837
+ "# Parameters",
838
+ "* `amount_in` — raw input token units (pre-fee).",
839
+ "* `minimum_amount_out`— slippage floor.",
840
+ "* `token_in_index` — index in `pool.token_mints`.",
841
+ "* `token_out_index` — different index in `pool.token_mints`.",
842
+ "",
843
+ "# Used by",
844
+ "User wallets, SDK `SwapClient`, single-token-liquidity helper."
845
+ ],
846
+ "discriminator": [
847
+ 248,
848
+ 198,
849
+ 158,
850
+ 145,
851
+ 225,
852
+ 117,
853
+ 135,
854
+ 200
855
+ ],
856
+ "accounts": [
857
+ {
858
+ "name": "pool",
859
+ "writable": true
860
+ },
861
+ {
862
+ "name": "token_mint_in"
863
+ },
864
+ {
865
+ "name": "token_mint_out"
866
+ },
867
+ {
868
+ "name": "user_token_account_in",
869
+ "docs": [
870
+ "User's input-token account. Mint and owner cross-checked."
871
+ ],
872
+ "writable": true
873
+ },
874
+ {
875
+ "name": "user_token_account_out",
876
+ "writable": true
877
+ },
878
+ {
879
+ "name": "vault_in",
880
+ "docs": [
881
+ "Pool input vault. ATA(pool, mint_in, token_program_in) — verified",
882
+ "in handler."
883
+ ],
884
+ "writable": true
885
+ },
886
+ {
887
+ "name": "vault_out",
888
+ "writable": true
889
+ },
890
+ {
891
+ "name": "user",
892
+ "signer": true
893
+ },
894
+ {
895
+ "name": "token_program_in"
896
+ },
897
+ {
898
+ "name": "token_program_out"
899
+ }
900
+ ],
901
+ "args": [
902
+ {
903
+ "name": "amount_in",
904
+ "type": "u64"
905
+ },
906
+ {
907
+ "name": "minimum_amount_out",
908
+ "type": "u64"
909
+ },
910
+ {
911
+ "name": "token_in_index",
912
+ "type": "u8"
913
+ },
914
+ {
915
+ "name": "token_out_index",
916
+ "type": "u8"
917
+ }
918
+ ]
919
+ },
920
+ {
921
+ "name": "withdraw_sol",
922
+ "docs": [
923
+ "Drain lamports from a cubic-pool-owned account, leaving at least",
924
+ "the rent-exempt minimum.",
925
+ "",
926
+ "# Authority",
927
+ "Treasury PDA only.",
928
+ "",
929
+ "# Parameters",
930
+ "* `amount` — lamports; must be > 0 and ≤",
931
+ "`source.lamports() - rent_exempt_minimum(source.data_len())`.",
932
+ "",
933
+ "# Used by",
934
+ "`protocol_admin::pool_withdraw_sol` (CPI)."
935
+ ],
936
+ "discriminator": [
937
+ 145,
938
+ 131,
939
+ 74,
940
+ 136,
941
+ 65,
942
+ 137,
943
+ 42,
944
+ 38
945
+ ],
946
+ "accounts": [
947
+ {
948
+ "name": "config"
949
+ },
950
+ {
951
+ "name": "source",
952
+ "writable": true
953
+ },
954
+ {
955
+ "name": "recipient",
956
+ "writable": true
957
+ },
958
+ {
959
+ "name": "authority",
960
+ "signer": true
961
+ }
962
+ ],
963
+ "args": [
964
+ {
965
+ "name": "amount",
966
+ "type": "u64"
967
+ }
968
+ ]
969
+ }
970
+ ],
971
+ "accounts": [
972
+ {
973
+ "name": "CubicPool",
974
+ "discriminator": [
975
+ 137,
976
+ 210,
977
+ 42,
978
+ 22,
979
+ 209,
980
+ 156,
981
+ 43,
982
+ 78
983
+ ]
984
+ },
985
+ {
986
+ "name": "CubicPoolConfig",
987
+ "discriminator": [
988
+ 4,
989
+ 29,
990
+ 243,
991
+ 10,
992
+ 142,
993
+ 64,
994
+ 232,
995
+ 118
996
+ ]
997
+ }
998
+ ],
999
+ "events": [
1000
+ {
1001
+ "name": "BannedExtensionsUpdated",
1002
+ "discriminator": [
1003
+ 107,
1004
+ 126,
1005
+ 13,
1006
+ 149,
1007
+ 182,
1008
+ 108,
1009
+ 139,
1010
+ 202
1011
+ ]
1012
+ },
1013
+ {
1014
+ "name": "DebugLiquidityWithdrawn",
1015
+ "discriminator": [
1016
+ 174,
1017
+ 59,
1018
+ 149,
1019
+ 22,
1020
+ 135,
1021
+ 129,
1022
+ 129,
1023
+ 83
1024
+ ]
1025
+ },
1026
+ {
1027
+ "name": "LiquidityAdded",
1028
+ "discriminator": [
1029
+ 154,
1030
+ 26,
1031
+ 221,
1032
+ 108,
1033
+ 238,
1034
+ 64,
1035
+ 217,
1036
+ 161
1037
+ ]
1038
+ },
1039
+ {
1040
+ "name": "LiquidityRemoved",
1041
+ "discriminator": [
1042
+ 225,
1043
+ 105,
1044
+ 216,
1045
+ 39,
1046
+ 124,
1047
+ 116,
1048
+ 169,
1049
+ 189
1050
+ ]
1051
+ },
1052
+ {
1053
+ "name": "PoolAdminDisabled",
1054
+ "discriminator": [
1055
+ 158,
1056
+ 98,
1057
+ 202,
1058
+ 37,
1059
+ 243,
1060
+ 57,
1061
+ 247,
1062
+ 87
1063
+ ]
1064
+ },
1065
+ {
1066
+ "name": "PoolAdminTransferCancelled",
1067
+ "discriminator": [
1068
+ 238,
1069
+ 53,
1070
+ 38,
1071
+ 143,
1072
+ 194,
1073
+ 45,
1074
+ 206,
1075
+ 179
1076
+ ]
1077
+ },
1078
+ {
1079
+ "name": "PoolAdminTransferInitiated",
1080
+ "discriminator": [
1081
+ 33,
1082
+ 195,
1083
+ 202,
1084
+ 133,
1085
+ 209,
1086
+ 42,
1087
+ 157,
1088
+ 78
1089
+ ]
1090
+ },
1091
+ {
1092
+ "name": "PoolAdminTransferred",
1093
+ "discriminator": [
1094
+ 123,
1095
+ 48,
1096
+ 231,
1097
+ 186,
1098
+ 53,
1099
+ 67,
1100
+ 156,
1101
+ 254
1102
+ ]
1103
+ },
1104
+ {
1105
+ "name": "PoolEnabledUpdated",
1106
+ "discriminator": [
1107
+ 101,
1108
+ 47,
1109
+ 3,
1110
+ 240,
1111
+ 197,
1112
+ 181,
1113
+ 236,
1114
+ 142
1115
+ ]
1116
+ },
1117
+ {
1118
+ "name": "PoolInfo",
1119
+ "discriminator": [
1120
+ 207,
1121
+ 20,
1122
+ 87,
1123
+ 97,
1124
+ 251,
1125
+ 212,
1126
+ 234,
1127
+ 45
1128
+ ]
1129
+ },
1130
+ {
1131
+ "name": "PoolInitialized",
1132
+ "discriminator": [
1133
+ 100,
1134
+ 118,
1135
+ 173,
1136
+ 87,
1137
+ 12,
1138
+ 198,
1139
+ 254,
1140
+ 229
1141
+ ]
1142
+ },
1143
+ {
1144
+ "name": "PoolSolWithdrawn",
1145
+ "discriminator": [
1146
+ 82,
1147
+ 220,
1148
+ 173,
1149
+ 175,
1150
+ 24,
1151
+ 165,
1152
+ 172,
1153
+ 233
1154
+ ]
1155
+ },
1156
+ {
1157
+ "name": "PoolStateLog",
1158
+ "discriminator": [
1159
+ 59,
1160
+ 254,
1161
+ 237,
1162
+ 111,
1163
+ 163,
1164
+ 10,
1165
+ 140,
1166
+ 224
1167
+ ]
1168
+ },
1169
+ {
1170
+ "name": "ProtocolAdminTransferCancelled",
1171
+ "discriminator": [
1172
+ 46,
1173
+ 120,
1174
+ 187,
1175
+ 57,
1176
+ 136,
1177
+ 63,
1178
+ 89,
1179
+ 7
1180
+ ]
1181
+ },
1182
+ {
1183
+ "name": "ProtocolAdminTransferInitiated",
1184
+ "discriminator": [
1185
+ 78,
1186
+ 207,
1187
+ 188,
1188
+ 146,
1189
+ 26,
1190
+ 65,
1191
+ 40,
1192
+ 167
1193
+ ]
1194
+ },
1195
+ {
1196
+ "name": "ProtocolAdminTransferred",
1197
+ "discriminator": [
1198
+ 140,
1199
+ 30,
1200
+ 55,
1201
+ 121,
1202
+ 105,
1203
+ 75,
1204
+ 148,
1205
+ 68
1206
+ ]
1207
+ },
1208
+ {
1209
+ "name": "ProtocolFeeRateUpdated",
1210
+ "discriminator": [
1211
+ 189,
1212
+ 56,
1213
+ 7,
1214
+ 65,
1215
+ 0,
1216
+ 95,
1217
+ 192,
1218
+ 6
1219
+ ]
1220
+ },
1221
+ {
1222
+ "name": "ProtocolFeesCollected",
1223
+ "discriminator": [
1224
+ 165,
1225
+ 34,
1226
+ 125,
1227
+ 155,
1228
+ 15,
1229
+ 86,
1230
+ 99,
1231
+ 191
1232
+ ]
1233
+ },
1234
+ {
1235
+ "name": "Swap",
1236
+ "discriminator": [
1237
+ 81,
1238
+ 108,
1239
+ 227,
1240
+ 190,
1241
+ 205,
1242
+ 208,
1243
+ 10,
1244
+ 196
1245
+ ]
1246
+ },
1247
+ {
1248
+ "name": "SwapFeeRateUpdated",
1249
+ "discriminator": [
1250
+ 101,
1251
+ 132,
1252
+ 24,
1253
+ 255,
1254
+ 91,
1255
+ 253,
1256
+ 227,
1257
+ 101
1258
+ ]
1259
+ },
1260
+ {
1261
+ "name": "SwapsEnabledUpdated",
1262
+ "discriminator": [
1263
+ 55,
1264
+ 116,
1265
+ 118,
1266
+ 138,
1267
+ 102,
1268
+ 26,
1269
+ 227,
1270
+ 223
1271
+ ]
1272
+ }
1273
+ ],
1274
+ "errors": [
1275
+ {
1276
+ "code": 6000,
1277
+ "name": "InvalidTokenCount",
1278
+ "msg": "Invalid token count. Must be between 2 and 10"
1279
+ },
1280
+ {
1281
+ "code": 6001,
1282
+ "name": "InvalidTokenIndex",
1283
+ "msg": "Invalid token index"
1284
+ },
1285
+ {
1286
+ "code": 6002,
1287
+ "name": "InvalidWeights",
1288
+ "msg": "Invalid weights. Must sum to 10000 (WEIGHT_SCALE)"
1289
+ },
1290
+ {
1291
+ "code": 6003,
1292
+ "name": "InvalidVirtualBalances",
1293
+ "msg": "Invalid virtual balances. Must be greater than zero"
1294
+ },
1295
+ {
1296
+ "code": 6004,
1297
+ "name": "InsufficientLiquidity",
1298
+ "msg": "Insufficient liquidity in the pool"
1299
+ },
1300
+ {
1301
+ "code": 6005,
1302
+ "name": "SlippageExceeded",
1303
+ "msg": "Slippage tolerance exceeded"
1304
+ },
1305
+ {
1306
+ "code": 6006,
1307
+ "name": "InvalidAmounts",
1308
+ "msg": "Invalid amounts provided"
1309
+ },
1310
+ {
1311
+ "code": 6007,
1312
+ "name": "InsufficientBptOut",
1313
+ "msg": "Insufficient BPT minted"
1314
+ },
1315
+ {
1316
+ "code": 6008,
1317
+ "name": "InsufficientTokensOut",
1318
+ "msg": "Insufficient tokens received"
1319
+ },
1320
+ {
1321
+ "code": 6009,
1322
+ "name": "FeeRateMaxExceeded",
1323
+ "msg": "Fee rate exceeds maximum"
1324
+ },
1325
+ {
1326
+ "code": 6010,
1327
+ "name": "ProtocolFeeRateMaxExceeded",
1328
+ "msg": "Protocol fee rate exceeds maximum"
1329
+ },
1330
+ {
1331
+ "code": 6011,
1332
+ "name": "MathOverflow",
1333
+ "msg": "Math overflow"
1334
+ },
1335
+ {
1336
+ "code": 6012,
1337
+ "name": "MathUnderflow",
1338
+ "msg": "Math underflow"
1339
+ },
1340
+ {
1341
+ "code": 6013,
1342
+ "name": "DivisionByZero",
1343
+ "msg": "Division by zero"
1344
+ },
1345
+ {
1346
+ "code": 6014,
1347
+ "name": "TokenMintMismatch",
1348
+ "msg": "Token mint mismatch"
1349
+ },
1350
+ {
1351
+ "code": 6015,
1352
+ "name": "InvalidTokenDecimals",
1353
+ "msg": "Invalid token decimals"
1354
+ },
1355
+ {
1356
+ "code": 6016,
1357
+ "name": "AmountOutExceedsBalance",
1358
+ "msg": "Amount out exceeds available balance"
1359
+ },
1360
+ {
1361
+ "code": 6017,
1362
+ "name": "InvalidBptAmount",
1363
+ "msg": "Invalid BPT amount"
1364
+ },
1365
+ {
1366
+ "code": 6018,
1367
+ "name": "Unauthorized",
1368
+ "msg": "Unauthorized"
1369
+ },
1370
+ {
1371
+ "code": 6019,
1372
+ "name": "InvalidMint",
1373
+ "msg": "Invalid mint account"
1374
+ },
1375
+ {
1376
+ "code": 6020,
1377
+ "name": "PoolDisabled",
1378
+ "msg": "Pool is disabled. No operations allowed."
1379
+ },
1380
+ {
1381
+ "code": 6021,
1382
+ "name": "SwapsDisabled",
1383
+ "msg": "Swaps are disabled for this pool."
1384
+ },
1385
+ {
1386
+ "code": 6022,
1387
+ "name": "PoolMustBeDisabled",
1388
+ "msg": "Pool must be disabled before debug operations."
1389
+ },
1390
+ {
1391
+ "code": 6023,
1392
+ "name": "ZeroAmount",
1393
+ "msg": "Amount must be greater than zero"
1394
+ },
1395
+ {
1396
+ "code": 6024,
1397
+ "name": "ZeroFeeAmount",
1398
+ "msg": "Swap amount is too small: fee rounds to zero"
1399
+ },
1400
+ {
1401
+ "code": 6025,
1402
+ "name": "BannedExtension",
1403
+ "msg": "Token mint has a banned Token-2022 extension"
1404
+ },
1405
+ {
1406
+ "code": 6026,
1407
+ "name": "TokenProgramMismatch",
1408
+ "msg": "Token program does not match pool's token program"
1409
+ },
1410
+ {
1411
+ "code": 6027,
1412
+ "name": "UserTokenAccountOwnerMismatch",
1413
+ "msg": "User token account owner mismatch"
1414
+ },
1415
+ {
1416
+ "code": 6028,
1417
+ "name": "InitialLiquidityTooSmall",
1418
+ "msg": "Initial liquidity too small - pool would be bricked"
1419
+ },
1420
+ {
1421
+ "code": 6029,
1422
+ "name": "InvalidTokenProgram",
1423
+ "msg": "Invalid token program - must be SPL Token or Token-2022"
1424
+ },
1425
+ {
1426
+ "code": 6030,
1427
+ "name": "InvalidVault",
1428
+ "msg": "Invalid vault account"
1429
+ },
1430
+ {
1431
+ "code": 6031,
1432
+ "name": "InvalidSourceOwner",
1433
+ "msg": "Source account must be owned by this program"
1434
+ },
1435
+ {
1436
+ "code": 6032,
1437
+ "name": "WouldBreakRentExempt",
1438
+ "msg": "Withdrawal would break rent exemption"
1439
+ },
1440
+ {
1441
+ "code": 6033,
1442
+ "name": "PoolAdminDisabled",
1443
+ "msg": "Pool admin is disabled"
1444
+ },
1445
+ {
1446
+ "code": 6034,
1447
+ "name": "ProtocolAdminUnset",
1448
+ "msg": "Protocol admin is unset"
1449
+ },
1450
+ {
1451
+ "code": 6035,
1452
+ "name": "NoPendingAdmin",
1453
+ "msg": "No pending admin transfer"
1454
+ },
1455
+ {
1456
+ "code": 6036,
1457
+ "name": "NotPendingAdmin",
1458
+ "msg": "Signer is not the pending admin"
1459
+ },
1460
+ {
1461
+ "code": 6037,
1462
+ "name": "InvalidPendingAdmin",
1463
+ "msg": "Pending admin cannot be the zero pubkey"
1464
+ }
1465
+ ],
1466
+ "types": [
1467
+ {
1468
+ "name": "BannedExtensionsUpdated",
1469
+ "docs": [
1470
+ "Emitted by `set_banned_extensions`. Off-chain validators use this to",
1471
+ "refresh the cached blocklist without rereading the config account."
1472
+ ],
1473
+ "type": {
1474
+ "kind": "struct",
1475
+ "fields": [
1476
+ {
1477
+ "name": "config",
1478
+ "type": "pubkey"
1479
+ },
1480
+ {
1481
+ "name": "authority",
1482
+ "type": "pubkey"
1483
+ },
1484
+ {
1485
+ "name": "old_value",
1486
+ "type": "u64"
1487
+ },
1488
+ {
1489
+ "name": "new_value",
1490
+ "type": "u64"
1491
+ },
1492
+ {
1493
+ "name": "timestamp",
1494
+ "type": "i64"
1495
+ }
1496
+ ]
1497
+ }
1498
+ },
1499
+ {
1500
+ "name": "CubicPool",
1501
+ "docs": [
1502
+ "`CubicPool` — per-pool state for a weighted AMM with virtual liquidity.",
1503
+ "",
1504
+ "Each pool is a PDA derived from `[CUBIC_POOL_SEED, config_pubkey,",
1505
+ "pool_id_le]`. One config can host many pools (different `pool_id`s).",
1506
+ "",
1507
+ "## Storage layout — DO NOT REORDER",
1508
+ "Backends (`onchainPoolFetcher.ts`, indexer) read fields by raw offset.",
1509
+ "Adding fields is fine if appended **before** `reserved` and `reserved`",
1510
+ "shrinks accordingly so total `LEN` stays the same.",
1511
+ "",
1512
+ "## Derived (not stored) state",
1513
+ "- `bpt_mint` — derived as `[BPT_MINT_SEED, pool]` PDA.",
1514
+ "- `bpt_total_supply`— read from `bpt_mint.supply` at runtime.",
1515
+ "- `token_vaults[i]` — derived as ATA(pool, mint, token_programs[i]).",
1516
+ "- `token_decimals` — read from each mint account at runtime."
1517
+ ],
1518
+ "type": {
1519
+ "kind": "struct",
1520
+ "fields": [
1521
+ {
1522
+ "name": "config",
1523
+ "docs": [
1524
+ "`CubicPoolConfig` this pool inherits governance from. Pinned at",
1525
+ "init, used both as a PDA seed and at runtime in admin-instruction",
1526
+ "constraints (`pool.config == config.key()`)."
1527
+ ],
1528
+ "type": "pubkey"
1529
+ },
1530
+ {
1531
+ "name": "bump",
1532
+ "docs": [
1533
+ "Bump seed for the pool PDA. Stored so signer-seed reconstruction is",
1534
+ "O(1) instead of an expensive `find_program_address` per CPI."
1535
+ ],
1536
+ "type": "u8"
1537
+ },
1538
+ {
1539
+ "name": "token_count",
1540
+ "docs": [
1541
+ "Number of active tokens in the pool, in [MIN_TOKENS, MAX_TOKENS] =",
1542
+ "[2, 10]. Slots beyond `token_count` are zeroed and ignored."
1543
+ ],
1544
+ "type": "u8"
1545
+ },
1546
+ {
1547
+ "name": "pool_id",
1548
+ "docs": [
1549
+ "User-chosen 64-bit salt baked into the PDA seeds, allowing multiple",
1550
+ "pools per config without re-deploying. Unique per (config, pool_id)."
1551
+ ],
1552
+ "type": "u64"
1553
+ },
1554
+ {
1555
+ "name": "token_mints",
1556
+ "docs": [
1557
+ "Mint pubkeys for each active token, fixed length array padded with",
1558
+ "`Pubkey::default()` past `token_count`."
1559
+ ],
1560
+ "type": {
1561
+ "array": [
1562
+ "pubkey",
1563
+ 10
1564
+ ]
1565
+ }
1566
+ },
1567
+ {
1568
+ "name": "token_programs",
1569
+ "docs": [
1570
+ "Per-token program ID (`spl_token::ID` or `spl_token_2022::ID`). A",
1571
+ "single pool may mix legacy SPL tokens and Token-2022 mints."
1572
+ ],
1573
+ "type": {
1574
+ "array": [
1575
+ "pubkey",
1576
+ 10
1577
+ ]
1578
+ }
1579
+ },
1580
+ {
1581
+ "name": "normalized_weights",
1582
+ "docs": [
1583
+ "Normalised weights in basis points (sum = `WEIGHT_SCALE` = 10_000).",
1584
+ "`weights[i] / WEIGHT_SCALE` is the target value-share of token i."
1585
+ ],
1586
+ "type": {
1587
+ "array": [
1588
+ "u64",
1589
+ 10
1590
+ ]
1591
+ }
1592
+ },
1593
+ {
1594
+ "name": "virtual_balances",
1595
+ "docs": [
1596
+ "Virtual balances (raw token units) used by the cubic invariant",
1597
+ "math. Decoupled from actual vault holdings to enable concentrated",
1598
+ "liquidity à la Cubic AMM. Updated by every swap / add / remove."
1599
+ ],
1600
+ "type": {
1601
+ "array": [
1602
+ "u64",
1603
+ 10
1604
+ ]
1605
+ }
1606
+ },
1607
+ {
1608
+ "name": "actual_balances",
1609
+ "docs": [
1610
+ "Actual balances mirrored from the on-chain vaults. Always",
1611
+ "== vault.amount for that token (CEI ordering keeps them in sync)."
1612
+ ],
1613
+ "type": {
1614
+ "array": [
1615
+ "u64",
1616
+ 10
1617
+ ]
1618
+ }
1619
+ },
1620
+ {
1621
+ "name": "swap_fee_rate",
1622
+ "docs": [
1623
+ "Swap fee in hundredths of a basis point (precision",
1624
+ "`SWAP_FEE_PRECISION` = 1_000_000). 100_000 = 10% (current cap)."
1625
+ ],
1626
+ "type": "u32"
1627
+ },
1628
+ {
1629
+ "name": "protocol_fee_rate",
1630
+ "docs": [
1631
+ "Share of each swap fee taken by the protocol, in basis points",
1632
+ "(precision `PROTOCOL_FEE_PRECISION` = 10_000). 5_000 = 50% (cap)."
1633
+ ],
1634
+ "type": "u16"
1635
+ },
1636
+ {
1637
+ "name": "protocol_fees_owed",
1638
+ "docs": [
1639
+ "Accumulated protocol fees per token (raw units), waiting on",
1640
+ "`collect_protocol_fees`. Stored separately from `actual_balances`",
1641
+ "so LP value isn't diluted by uncollected fees."
1642
+ ],
1643
+ "type": {
1644
+ "array": [
1645
+ "u64",
1646
+ 10
1647
+ ]
1648
+ }
1649
+ },
1650
+ {
1651
+ "name": "created_at",
1652
+ "docs": [
1653
+ "Pool creation `Clock::unix_timestamp`. Informational only."
1654
+ ],
1655
+ "type": "i64"
1656
+ },
1657
+ {
1658
+ "name": "pool_enabled",
1659
+ "docs": [
1660
+ "Master kill switch — when `false`, swaps and add/remove liquidity",
1661
+ "all revert. Only `protocol_admin` can flip this; required to be",
1662
+ "`false` before `debug_withdraw_liquidity` is callable."
1663
+ ],
1664
+ "type": "bool"
1665
+ },
1666
+ {
1667
+ "name": "swaps_enabled",
1668
+ "docs": [
1669
+ "Trading switch — `false` blocks swaps but still allows LP",
1670
+ "add/remove. Either `pool_admin` or `config.protocol_admin` can flip."
1671
+ ],
1672
+ "type": "bool"
1673
+ },
1674
+ {
1675
+ "name": "pool_admin",
1676
+ "docs": [
1677
+ "Per-pool admin. Initialised to the wallet that called",
1678
+ "`initialize_cubic_pool`. Allowed to: rotate `swap_fee_rate`,",
1679
+ "toggle `swaps_enabled`, transfer / disable itself via the",
1680
+ "pending/accept/disable flow. Set to `Pubkey::default()` once the",
1681
+ "admin role is renounced — after that, no pool-admin function is",
1682
+ "callable on this pool, ever."
1683
+ ],
1684
+ "type": "pubkey"
1685
+ },
1686
+ {
1687
+ "name": "pending_pool_admin",
1688
+ "docs": [
1689
+ "Pending successor for `pool_admin` during a 2-step transfer.",
1690
+ "`Pubkey::default()` ⇒ no transfer in flight."
1691
+ ],
1692
+ "type": "pubkey"
1693
+ },
1694
+ {
1695
+ "name": "reserved",
1696
+ "docs": [
1697
+ "Forward-compat padding (do not repurpose without a migration plan)."
1698
+ ],
1699
+ "type": {
1700
+ "array": [
1701
+ "u8",
1702
+ 64
1703
+ ]
1704
+ }
1705
+ }
1706
+ ]
1707
+ }
1708
+ },
1709
+ {
1710
+ "name": "CubicPoolConfig",
1711
+ "docs": [
1712
+ "`CubicPoolConfig` — protocol-level governance for every pool created",
1713
+ "against this account.",
1714
+ "",
1715
+ "One config can host many pools (each pool stores `config: Pubkey`).",
1716
+ "Per-pool admin (level-1: rotates `swap_fee_rate`, toggles `swaps_enabled`)",
1717
+ "lives on `CubicPool::pool_admin`. This config carries only the",
1718
+ "protocol-level admin (level-2) plus protocol-wide defaults."
1719
+ ],
1720
+ "type": {
1721
+ "kind": "struct",
1722
+ "fields": [
1723
+ {
1724
+ "name": "protocol_admin",
1725
+ "docs": [
1726
+ "Protocol-level admin. Allowed to: pause pools, change",
1727
+ "`protocol_fee_rate`, collect protocol fees, drain via",
1728
+ "`debug_withdraw_liquidity`, update `banned_extensions`, withdraw",
1729
+ "SOL from program-owned accounts, and rotate itself via the",
1730
+ "pending/accept flow. Set to a designated authority (typically the",
1731
+ "Treasury PDA of the `protocol-admin` program) at config init."
1732
+ ],
1733
+ "type": "pubkey"
1734
+ },
1735
+ {
1736
+ "name": "pending_protocol_admin",
1737
+ "docs": [
1738
+ "Pending successor for `protocol_admin` during a 2-step transfer.",
1739
+ "`Pubkey::default()` ⇒ no transfer in flight."
1740
+ ],
1741
+ "type": "pubkey"
1742
+ },
1743
+ {
1744
+ "name": "default_protocol_fee_rate",
1745
+ "docs": [
1746
+ "Default `protocol_fee_rate` (in basis points, max 5000 = 50%) seeded",
1747
+ "onto every new pool created against this config. Pools may diverge",
1748
+ "later via `set_protocol_fee_rate`."
1749
+ ],
1750
+ "type": "u16"
1751
+ },
1752
+ {
1753
+ "name": "banned_extensions",
1754
+ "docs": [
1755
+ "Bitmap of banned Token-2022 extension types. Bit N set ⇒ extension",
1756
+ "type N is rejected at pool init. Maintained by `protocol_admin` via",
1757
+ "`set_banned_extensions`. Defaults to `DEFAULT_BANNED_EXTENSIONS`",
1758
+ "(TransferFee, ConfidentialTransfer, NonTransferable, …)."
1759
+ ],
1760
+ "type": "u64"
1761
+ },
1762
+ {
1763
+ "name": "reserved",
1764
+ "docs": [
1765
+ "Forward-compatibility padding so future fields can be added without",
1766
+ "migrating existing config accounts."
1767
+ ],
1768
+ "type": {
1769
+ "array": [
1770
+ "u8",
1771
+ 120
1772
+ ]
1773
+ }
1774
+ }
1775
+ ]
1776
+ }
1777
+ },
1778
+ {
1779
+ "name": "DebugLiquidityWithdrawn",
1780
+ "docs": [
1781
+ "Emitted by `debug_withdraw_liquidity`. Listening for this event is the",
1782
+ "canonical way for off-chain monitors to know that a pool has",
1783
+ "transitioned to the \"bricked\" state — `actual_balances` and",
1784
+ "`virtual_balances` no longer match vault holdings after this fires."
1785
+ ],
1786
+ "type": {
1787
+ "kind": "struct",
1788
+ "fields": [
1789
+ {
1790
+ "name": "pool",
1791
+ "type": "pubkey"
1792
+ },
1793
+ {
1794
+ "name": "authority",
1795
+ "type": "pubkey"
1796
+ },
1797
+ {
1798
+ "name": "token_amounts",
1799
+ "type": {
1800
+ "vec": "u64"
1801
+ }
1802
+ },
1803
+ {
1804
+ "name": "timestamp",
1805
+ "type": "i64"
1806
+ }
1807
+ ]
1808
+ }
1809
+ },
1810
+ {
1811
+ "name": "LiquidityAdded",
1812
+ "docs": [
1813
+ "Emitted by `add_liquidity` after BPT is minted.",
1814
+ "",
1815
+ "# Fields",
1816
+ "* `token_amounts` — what the user actually deposited (raw units, in",
1817
+ "pool order)",
1818
+ "* `bpt_amount` — BPT minted to the user"
1819
+ ],
1820
+ "type": {
1821
+ "kind": "struct",
1822
+ "fields": [
1823
+ {
1824
+ "name": "pool",
1825
+ "type": "pubkey"
1826
+ },
1827
+ {
1828
+ "name": "user",
1829
+ "type": "pubkey"
1830
+ },
1831
+ {
1832
+ "name": "token_amounts",
1833
+ "type": {
1834
+ "vec": "u64"
1835
+ }
1836
+ },
1837
+ {
1838
+ "name": "bpt_amount",
1839
+ "type": "u64"
1840
+ },
1841
+ {
1842
+ "name": "timestamp",
1843
+ "type": "i64"
1844
+ }
1845
+ ]
1846
+ }
1847
+ },
1848
+ {
1849
+ "name": "LiquidityRemoved",
1850
+ "docs": [
1851
+ "Emitted by `remove_liquidity` after BPT is burned. `bpt_amount` is the",
1852
+ "**effective** burn (capped to `total_supply - MINIMUM_INITIAL_BPT`),",
1853
+ "not the original request — clients reading this know exactly how much",
1854
+ "supply changed."
1855
+ ],
1856
+ "type": {
1857
+ "kind": "struct",
1858
+ "fields": [
1859
+ {
1860
+ "name": "pool",
1861
+ "type": "pubkey"
1862
+ },
1863
+ {
1864
+ "name": "user",
1865
+ "type": "pubkey"
1866
+ },
1867
+ {
1868
+ "name": "bpt_amount",
1869
+ "type": "u64"
1870
+ },
1871
+ {
1872
+ "name": "token_amounts",
1873
+ "type": {
1874
+ "vec": "u64"
1875
+ }
1876
+ },
1877
+ {
1878
+ "name": "timestamp",
1879
+ "type": "i64"
1880
+ }
1881
+ ]
1882
+ }
1883
+ },
1884
+ {
1885
+ "name": "PoolAdminDisabled",
1886
+ "type": {
1887
+ "kind": "struct",
1888
+ "fields": [
1889
+ {
1890
+ "name": "pool",
1891
+ "type": "pubkey"
1892
+ },
1893
+ {
1894
+ "name": "old_admin",
1895
+ "type": "pubkey"
1896
+ },
1897
+ {
1898
+ "name": "timestamp",
1899
+ "type": "i64"
1900
+ }
1901
+ ]
1902
+ }
1903
+ },
1904
+ {
1905
+ "name": "PoolAdminTransferCancelled",
1906
+ "type": {
1907
+ "kind": "struct",
1908
+ "fields": [
1909
+ {
1910
+ "name": "pool",
1911
+ "type": "pubkey"
1912
+ },
1913
+ {
1914
+ "name": "admin",
1915
+ "type": "pubkey"
1916
+ },
1917
+ {
1918
+ "name": "cancelled_pending",
1919
+ "type": "pubkey"
1920
+ },
1921
+ {
1922
+ "name": "timestamp",
1923
+ "type": "i64"
1924
+ }
1925
+ ]
1926
+ }
1927
+ },
1928
+ {
1929
+ "name": "PoolAdminTransferInitiated",
1930
+ "type": {
1931
+ "kind": "struct",
1932
+ "fields": [
1933
+ {
1934
+ "name": "pool",
1935
+ "type": "pubkey"
1936
+ },
1937
+ {
1938
+ "name": "current_admin",
1939
+ "type": "pubkey"
1940
+ },
1941
+ {
1942
+ "name": "pending_admin",
1943
+ "type": "pubkey"
1944
+ },
1945
+ {
1946
+ "name": "timestamp",
1947
+ "type": "i64"
1948
+ }
1949
+ ]
1950
+ }
1951
+ },
1952
+ {
1953
+ "name": "PoolAdminTransferred",
1954
+ "type": {
1955
+ "kind": "struct",
1956
+ "fields": [
1957
+ {
1958
+ "name": "pool",
1959
+ "type": "pubkey"
1960
+ },
1961
+ {
1962
+ "name": "old_admin",
1963
+ "type": "pubkey"
1964
+ },
1965
+ {
1966
+ "name": "new_admin",
1967
+ "type": "pubkey"
1968
+ },
1969
+ {
1970
+ "name": "timestamp",
1971
+ "type": "i64"
1972
+ }
1973
+ ]
1974
+ }
1975
+ },
1976
+ {
1977
+ "name": "PoolEnabledUpdated",
1978
+ "docs": [
1979
+ "Emitted by `set_pool_enabled`."
1980
+ ],
1981
+ "type": {
1982
+ "kind": "struct",
1983
+ "fields": [
1984
+ {
1985
+ "name": "pool",
1986
+ "type": "pubkey"
1987
+ },
1988
+ {
1989
+ "name": "authority",
1990
+ "type": "pubkey"
1991
+ },
1992
+ {
1993
+ "name": "old_value",
1994
+ "type": "bool"
1995
+ },
1996
+ {
1997
+ "name": "new_value",
1998
+ "type": "bool"
1999
+ },
2000
+ {
2001
+ "name": "timestamp",
2002
+ "type": "i64"
2003
+ }
2004
+ ]
2005
+ }
2006
+ },
2007
+ {
2008
+ "name": "PoolInfo",
2009
+ "docs": [
2010
+ "Read-only view event emitted by the simulation-only `get_pool_info`",
2011
+ "instruction. Off-chain clients call `simulate({ commitment: ... })`",
2012
+ "and parse this event from the returned logs. Strictly more verbose",
2013
+ "than `PoolStateLog` (also includes derived addresses)."
2014
+ ],
2015
+ "type": {
2016
+ "kind": "struct",
2017
+ "fields": [
2018
+ {
2019
+ "name": "pool",
2020
+ "type": "pubkey"
2021
+ },
2022
+ {
2023
+ "name": "config",
2024
+ "type": "pubkey"
2025
+ },
2026
+ {
2027
+ "name": "bpt_mint",
2028
+ "type": "pubkey"
2029
+ },
2030
+ {
2031
+ "name": "token_count",
2032
+ "type": "u8"
2033
+ },
2034
+ {
2035
+ "name": "pool_id",
2036
+ "type": "u64"
2037
+ },
2038
+ {
2039
+ "name": "tokens",
2040
+ "type": {
2041
+ "vec": "pubkey"
2042
+ }
2043
+ },
2044
+ {
2045
+ "name": "token_vaults",
2046
+ "type": {
2047
+ "vec": "pubkey"
2048
+ }
2049
+ },
2050
+ {
2051
+ "name": "normalized_weights",
2052
+ "type": {
2053
+ "vec": "u64"
2054
+ }
2055
+ },
2056
+ {
2057
+ "name": "virtual_balances",
2058
+ "type": {
2059
+ "vec": "u64"
2060
+ }
2061
+ },
2062
+ {
2063
+ "name": "actual_balances",
2064
+ "type": {
2065
+ "vec": "u64"
2066
+ }
2067
+ },
2068
+ {
2069
+ "name": "protocol_fees_owed",
2070
+ "type": {
2071
+ "vec": "u64"
2072
+ }
2073
+ },
2074
+ {
2075
+ "name": "swap_fee_rate",
2076
+ "type": "u32"
2077
+ },
2078
+ {
2079
+ "name": "protocol_fee_rate",
2080
+ "type": "u16"
2081
+ },
2082
+ {
2083
+ "name": "pool_enabled",
2084
+ "type": "bool"
2085
+ },
2086
+ {
2087
+ "name": "swaps_enabled",
2088
+ "type": "bool"
2089
+ },
2090
+ {
2091
+ "name": "token_programs",
2092
+ "type": {
2093
+ "vec": "pubkey"
2094
+ }
2095
+ },
2096
+ {
2097
+ "name": "timestamp",
2098
+ "type": "i64"
2099
+ }
2100
+ ]
2101
+ }
2102
+ },
2103
+ {
2104
+ "name": "PoolInitialized",
2105
+ "docs": [
2106
+ "Emitted at the end of `initialize_cubic_pool`. Marks a new pool live.",
2107
+ "",
2108
+ "# Fields",
2109
+ "* `pool` — pool PDA pubkey",
2110
+ "* `config` — parent config pubkey",
2111
+ "* `token_count` — active tokens (2..=10)",
2112
+ "* `bpt_mint` — BPT mint PDA pubkey",
2113
+ "* `timestamp` — `Clock::unix_timestamp` at init"
2114
+ ],
2115
+ "type": {
2116
+ "kind": "struct",
2117
+ "fields": [
2118
+ {
2119
+ "name": "pool",
2120
+ "type": "pubkey"
2121
+ },
2122
+ {
2123
+ "name": "config",
2124
+ "type": "pubkey"
2125
+ },
2126
+ {
2127
+ "name": "token_count",
2128
+ "type": "u8"
2129
+ },
2130
+ {
2131
+ "name": "bpt_mint",
2132
+ "type": "pubkey"
2133
+ },
2134
+ {
2135
+ "name": "timestamp",
2136
+ "type": "i64"
2137
+ }
2138
+ ]
2139
+ }
2140
+ },
2141
+ {
2142
+ "name": "PoolSolWithdrawn",
2143
+ "docs": [
2144
+ "Emitted by `withdraw_sol` when SOL is recovered from a cubic-pool-owned",
2145
+ "account."
2146
+ ],
2147
+ "type": {
2148
+ "kind": "struct",
2149
+ "fields": [
2150
+ {
2151
+ "name": "source",
2152
+ "type": "pubkey"
2153
+ },
2154
+ {
2155
+ "name": "authority",
2156
+ "type": "pubkey"
2157
+ },
2158
+ {
2159
+ "name": "recipient",
2160
+ "type": "pubkey"
2161
+ },
2162
+ {
2163
+ "name": "amount",
2164
+ "type": "u64"
2165
+ },
2166
+ {
2167
+ "name": "timestamp",
2168
+ "type": "i64"
2169
+ }
2170
+ ]
2171
+ }
2172
+ },
2173
+ {
2174
+ "name": "PoolStateLog",
2175
+ "docs": [
2176
+ "Mutating-instruction state snapshot consumed by the backend indexer to",
2177
+ "keep its denormalised pool table in sync without an additional account",
2178
+ "fetch. Emitted by `swap`, `add_liquidity`, and `remove_liquidity`.",
2179
+ "",
2180
+ "`bpt_total_supply` is the post-tx supply (0 for `swap`, which does not",
2181
+ "touch supply — clients should fall back to the mint account)."
2182
+ ],
2183
+ "type": {
2184
+ "kind": "struct",
2185
+ "fields": [
2186
+ {
2187
+ "name": "pool",
2188
+ "type": "pubkey"
2189
+ },
2190
+ {
2191
+ "name": "token_count",
2192
+ "type": "u8"
2193
+ },
2194
+ {
2195
+ "name": "token_mints",
2196
+ "type": {
2197
+ "vec": "pubkey"
2198
+ }
2199
+ },
2200
+ {
2201
+ "name": "normalized_weights",
2202
+ "type": {
2203
+ "vec": "u64"
2204
+ }
2205
+ },
2206
+ {
2207
+ "name": "virtual_balances",
2208
+ "type": {
2209
+ "vec": "u64"
2210
+ }
2211
+ },
2212
+ {
2213
+ "name": "actual_balances",
2214
+ "type": {
2215
+ "vec": "u64"
2216
+ }
2217
+ },
2218
+ {
2219
+ "name": "bpt_total_supply",
2220
+ "type": "u64"
2221
+ },
2222
+ {
2223
+ "name": "swap_fee_rate",
2224
+ "type": "u32"
2225
+ },
2226
+ {
2227
+ "name": "protocol_fee_rate",
2228
+ "type": "u16"
2229
+ },
2230
+ {
2231
+ "name": "protocol_fees_owed",
2232
+ "type": {
2233
+ "vec": "u64"
2234
+ }
2235
+ },
2236
+ {
2237
+ "name": "pool_enabled",
2238
+ "type": "bool"
2239
+ },
2240
+ {
2241
+ "name": "swaps_enabled",
2242
+ "type": "bool"
2243
+ },
2244
+ {
2245
+ "name": "timestamp",
2246
+ "type": "i64"
2247
+ }
2248
+ ]
2249
+ }
2250
+ },
2251
+ {
2252
+ "name": "ProtocolAdminTransferCancelled",
2253
+ "type": {
2254
+ "kind": "struct",
2255
+ "fields": [
2256
+ {
2257
+ "name": "config",
2258
+ "type": "pubkey"
2259
+ },
2260
+ {
2261
+ "name": "admin",
2262
+ "type": "pubkey"
2263
+ },
2264
+ {
2265
+ "name": "cancelled_pending",
2266
+ "type": "pubkey"
2267
+ },
2268
+ {
2269
+ "name": "timestamp",
2270
+ "type": "i64"
2271
+ }
2272
+ ]
2273
+ }
2274
+ },
2275
+ {
2276
+ "name": "ProtocolAdminTransferInitiated",
2277
+ "type": {
2278
+ "kind": "struct",
2279
+ "fields": [
2280
+ {
2281
+ "name": "config",
2282
+ "type": "pubkey"
2283
+ },
2284
+ {
2285
+ "name": "current_admin",
2286
+ "type": "pubkey"
2287
+ },
2288
+ {
2289
+ "name": "pending_admin",
2290
+ "type": "pubkey"
2291
+ },
2292
+ {
2293
+ "name": "timestamp",
2294
+ "type": "i64"
2295
+ }
2296
+ ]
2297
+ }
2298
+ },
2299
+ {
2300
+ "name": "ProtocolAdminTransferred",
2301
+ "type": {
2302
+ "kind": "struct",
2303
+ "fields": [
2304
+ {
2305
+ "name": "config",
2306
+ "type": "pubkey"
2307
+ },
2308
+ {
2309
+ "name": "old_admin",
2310
+ "type": "pubkey"
2311
+ },
2312
+ {
2313
+ "name": "new_admin",
2314
+ "type": "pubkey"
2315
+ },
2316
+ {
2317
+ "name": "timestamp",
2318
+ "type": "i64"
2319
+ }
2320
+ ]
2321
+ }
2322
+ },
2323
+ {
2324
+ "name": "ProtocolFeeRateUpdated",
2325
+ "docs": [
2326
+ "Emitted by `set_protocol_fee_rate`."
2327
+ ],
2328
+ "type": {
2329
+ "kind": "struct",
2330
+ "fields": [
2331
+ {
2332
+ "name": "pool",
2333
+ "type": "pubkey"
2334
+ },
2335
+ {
2336
+ "name": "old_rate",
2337
+ "type": "u16"
2338
+ },
2339
+ {
2340
+ "name": "new_rate",
2341
+ "type": "u16"
2342
+ },
2343
+ {
2344
+ "name": "timestamp",
2345
+ "type": "i64"
2346
+ }
2347
+ ]
2348
+ }
2349
+ },
2350
+ {
2351
+ "name": "ProtocolFeesCollected",
2352
+ "docs": [
2353
+ "Emitted by `collect_protocol_fees` once per call (one event covers all",
2354
+ "tokens, with zero-amounts kept in `token_amounts` to preserve order)."
2355
+ ],
2356
+ "type": {
2357
+ "kind": "struct",
2358
+ "fields": [
2359
+ {
2360
+ "name": "pool",
2361
+ "type": "pubkey"
2362
+ },
2363
+ {
2364
+ "name": "authority",
2365
+ "type": "pubkey"
2366
+ },
2367
+ {
2368
+ "name": "token_amounts",
2369
+ "type": {
2370
+ "vec": "u64"
2371
+ }
2372
+ },
2373
+ {
2374
+ "name": "timestamp",
2375
+ "type": "i64"
2376
+ }
2377
+ ]
2378
+ }
2379
+ },
2380
+ {
2381
+ "name": "Swap",
2382
+ "docs": [
2383
+ "Emitted by `swap` after the trade executes.",
2384
+ "",
2385
+ "# Fields",
2386
+ "* `pool` — pool PDA",
2387
+ "* `user` — signer that initiated the swap",
2388
+ "* `token_in/out` — mint pubkeys of the two legs",
2389
+ "* `amount_in/out` — raw token units (pre-fee on input side)",
2390
+ "* `fee_amount` — total swap fee (raw units, in token_in)",
2391
+ "* `protocol_fee_amount`— share of `fee_amount` that went to the",
2392
+ "protocol-fees-owed bucket (raw units, in token_in)",
2393
+ "* `timestamp` — `Clock::unix_timestamp`"
2394
+ ],
2395
+ "type": {
2396
+ "kind": "struct",
2397
+ "fields": [
2398
+ {
2399
+ "name": "pool",
2400
+ "type": "pubkey"
2401
+ },
2402
+ {
2403
+ "name": "user",
2404
+ "type": "pubkey"
2405
+ },
2406
+ {
2407
+ "name": "token_in",
2408
+ "type": "pubkey"
2409
+ },
2410
+ {
2411
+ "name": "token_out",
2412
+ "type": "pubkey"
2413
+ },
2414
+ {
2415
+ "name": "amount_in",
2416
+ "type": "u64"
2417
+ },
2418
+ {
2419
+ "name": "amount_out",
2420
+ "type": "u64"
2421
+ },
2422
+ {
2423
+ "name": "fee_amount",
2424
+ "type": "u64"
2425
+ },
2426
+ {
2427
+ "name": "protocol_fee_amount",
2428
+ "type": "u64"
2429
+ },
2430
+ {
2431
+ "name": "timestamp",
2432
+ "type": "i64"
2433
+ }
2434
+ ]
2435
+ }
2436
+ },
2437
+ {
2438
+ "name": "SwapFeeRateUpdated",
2439
+ "docs": [
2440
+ "Emitted by `set_swap_fee_rate`. Carries both old and new for cheap",
2441
+ "audit reconstruction without re-reading prior state."
2442
+ ],
2443
+ "type": {
2444
+ "kind": "struct",
2445
+ "fields": [
2446
+ {
2447
+ "name": "pool",
2448
+ "type": "pubkey"
2449
+ },
2450
+ {
2451
+ "name": "old_rate",
2452
+ "type": "u32"
2453
+ },
2454
+ {
2455
+ "name": "new_rate",
2456
+ "type": "u32"
2457
+ },
2458
+ {
2459
+ "name": "timestamp",
2460
+ "type": "i64"
2461
+ }
2462
+ ]
2463
+ }
2464
+ },
2465
+ {
2466
+ "name": "SwapsEnabledUpdated",
2467
+ "docs": [
2468
+ "Emitted by `set_swaps_enabled`."
2469
+ ],
2470
+ "type": {
2471
+ "kind": "struct",
2472
+ "fields": [
2473
+ {
2474
+ "name": "pool",
2475
+ "type": "pubkey"
2476
+ },
2477
+ {
2478
+ "name": "authority",
2479
+ "type": "pubkey"
2480
+ },
2481
+ {
2482
+ "name": "old_value",
2483
+ "type": "bool"
2484
+ },
2485
+ {
2486
+ "name": "new_value",
2487
+ "type": "bool"
2488
+ },
2489
+ {
2490
+ "name": "timestamp",
2491
+ "type": "i64"
2492
+ }
2493
+ ]
2494
+ }
2495
+ }
2496
+ ]
2497
+ }