@cubee_ee/sdk 0.1.8 → 0.2.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 (44) hide show
  1. package/README.md +50 -0
  2. package/dist/clients/CubicPoolClient.d.ts.map +1 -1
  3. package/dist/clients/CubicPoolClient.js +1 -0
  4. package/dist/clients/CubicPoolClient.js.map +1 -1
  5. package/dist/clients/index.d.ts +1 -0
  6. package/dist/clients/index.d.ts.map +1 -1
  7. package/dist/clients/index.js +1 -0
  8. package/dist/clients/index.js.map +1 -1
  9. package/dist/clients/tx-builders.d.ts +44 -0
  10. package/dist/clients/tx-builders.d.ts.map +1 -1
  11. package/dist/clients/tx-builders.js +59 -0
  12. package/dist/clients/tx-builders.js.map +1 -1
  13. package/dist/clients/versioned.d.ts +34 -0
  14. package/dist/clients/versioned.d.ts.map +1 -0
  15. package/dist/clients/versioned.js +55 -0
  16. package/dist/clients/versioned.js.map +1 -0
  17. package/dist/idl/cubic_pool.json +1101 -114
  18. package/dist/idl/index.d.ts +380 -16
  19. package/dist/idl/index.d.ts.map +1 -1
  20. package/dist/idl/protocol_admin.json +513 -2
  21. package/dist/index.d.ts +3 -1
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +7 -1
  24. package/dist/index.js.map +1 -1
  25. package/dist/parsers/poolAccount.d.ts +42 -11
  26. package/dist/parsers/poolAccount.d.ts.map +1 -1
  27. package/dist/parsers/poolAccount.js +96 -37
  28. package/dist/parsers/poolAccount.js.map +1 -1
  29. package/dist/types/pool.d.ts +6 -0
  30. package/dist/types/pool.d.ts.map +1 -1
  31. package/dist/types/result.d.ts +1 -1
  32. package/dist/types/result.d.ts.map +1 -1
  33. package/dist/types/result.js.map +1 -1
  34. package/package.json +1 -1
  35. package/src/clients/CubicPoolClient.ts +1 -0
  36. package/src/clients/index.ts +1 -0
  37. package/src/clients/tx-builders.ts +100 -0
  38. package/src/clients/versioned.ts +80 -0
  39. package/src/idl/cubic_pool.json +1101 -114
  40. package/src/idl/protocol_admin.json +513 -2
  41. package/src/index.ts +5 -0
  42. package/src/parsers/poolAccount.ts +151 -48
  43. package/src/types/pool.ts +6 -0
  44. package/src/types/result.ts +1 -0
@@ -138,6 +138,50 @@
138
138
  ],
139
139
  "args": []
140
140
  },
141
+ {
142
+ "name": "freeze_pools",
143
+ "docs": [
144
+ "Batch-freeze pools — pause swaps + add/remove liquidity on every",
145
+ "`[config_i, pool_i]` pair passed via `remaining_accounts`. CPIs",
146
+ "`cubic_pool::set_pool_enabled(false)` per pair, signed by the",
147
+ "Treasury PDA.",
148
+ "",
149
+ "# Authority",
150
+ "`treasury.admin` OR `treasury.supervisor` (when set)."
151
+ ],
152
+ "discriminator": [
153
+ 145,
154
+ 66,
155
+ 173,
156
+ 210,
157
+ 162,
158
+ 200,
159
+ 248,
160
+ 22
161
+ ],
162
+ "accounts": [
163
+ {
164
+ "name": "treasury",
165
+ "docs": [
166
+ "Treasury PDA (signs the cubic-pool CPI). Read-only here; the",
167
+ "CPI uses `treasury.to_account_info()` with `invoke_signed`",
168
+ "seeds, so this account doesn't need `mut`."
169
+ ]
170
+ },
171
+ {
172
+ "name": "authority",
173
+ "docs": [
174
+ "Either `treasury.admin` or `treasury.supervisor` — handler",
175
+ "enforces."
176
+ ],
177
+ "signer": true
178
+ },
179
+ {
180
+ "name": "cubic_pool_program"
181
+ }
182
+ ],
183
+ "args": []
184
+ },
141
185
  {
142
186
  "name": "initialize",
143
187
  "docs": [
@@ -349,6 +393,67 @@
349
393
  }
350
394
  ]
351
395
  },
396
+ {
397
+ "name": "pool_initialize_alt",
398
+ "docs": [
399
+ "Operator-driven per-pool ALT provisioning. Treasury PDA signs",
400
+ "the CPI to `cubic_pool::initialize_pool_alt`. ALT account",
401
+ "address is derived from `[Treasury PDA, recent_slot]`. `admin`",
402
+ "pays ALT rent (~0.005 SOL).",
403
+ "",
404
+ "# Authority",
405
+ "`treasury.admin` only."
406
+ ],
407
+ "discriminator": [
408
+ 252,
409
+ 45,
410
+ 53,
411
+ 31,
412
+ 10,
413
+ 50,
414
+ 82,
415
+ 104
416
+ ],
417
+ "accounts": [
418
+ {
419
+ "name": "treasury"
420
+ },
421
+ {
422
+ "name": "admin",
423
+ "writable": true,
424
+ "signer": true
425
+ },
426
+ {
427
+ "name": "pool",
428
+ "writable": true
429
+ },
430
+ {
431
+ "name": "config"
432
+ },
433
+ {
434
+ "name": "lookup_table",
435
+ "docs": [
436
+ "address `[Treasury PDA, recent_slot]`."
437
+ ],
438
+ "writable": true
439
+ },
440
+ {
441
+ "name": "system_program"
442
+ },
443
+ {
444
+ "name": "alt_program"
445
+ },
446
+ {
447
+ "name": "cubic_pool_program"
448
+ }
449
+ ],
450
+ "args": [
451
+ {
452
+ "name": "recent_slot",
453
+ "type": "u64"
454
+ }
455
+ ]
456
+ },
352
457
  {
353
458
  "name": "pool_initialize_config",
354
459
  "discriminator": [
@@ -431,6 +536,75 @@
431
536
  }
432
537
  ]
433
538
  },
539
+ {
540
+ "name": "pool_migrate_v4",
541
+ "docs": [
542
+ "Operator-driven v3 → v4 pool storage migration. Treasury PDA",
543
+ "signs the CPI to `cubic_pool::migrate_pool_v4`; cubic-pool",
544
+ "accepts `config.protocol_admin` as authority in addition to",
545
+ "`pool.pool_admin`. `admin` pays the rent diff for the realloc.",
546
+ "",
547
+ "# Authority",
548
+ "`treasury.admin` only — supervisor cannot trigger storage",
549
+ "migrations."
550
+ ],
551
+ "discriminator": [
552
+ 159,
553
+ 77,
554
+ 21,
555
+ 158,
556
+ 41,
557
+ 172,
558
+ 31,
559
+ 249
560
+ ],
561
+ "accounts": [
562
+ {
563
+ "name": "treasury",
564
+ "docs": [
565
+ "Treasury PDA — signs the cubic-pool CPI via `signer_seeds`.",
566
+ "Marked `mut` because cubic-pool's `MigratePoolV4` declares",
567
+ "`authority: #[account(mut)]` (it conditionally transfers from",
568
+ "authority for the realloc rent top-up). Anchor's CPI machinery",
569
+ "requires the outer writability flag to match the inner one even",
570
+ "when no actual write happens (in our flow the transfer is a",
571
+ "no-op because we pre-fund the pool directly from `admin`).",
572
+ "Without `mut` here the runtime reports \"writable privilege",
573
+ "escalated\"."
574
+ ],
575
+ "writable": true
576
+ },
577
+ {
578
+ "name": "admin",
579
+ "docs": [
580
+ "Operator — pays both tx fees and the rent diff."
581
+ ],
582
+ "writable": true,
583
+ "signer": true
584
+ },
585
+ {
586
+ "name": "pool",
587
+ "docs": [
588
+ "(owner = cubic-pool, size = `LEN_V3`, discriminator matches)."
589
+ ],
590
+ "writable": true
591
+ },
592
+ {
593
+ "name": "config",
594
+ "docs": [
595
+ "and reads `protocol_admin` from its raw bytes to gate the",
596
+ "alternative-authority path."
597
+ ]
598
+ },
599
+ {
600
+ "name": "system_program"
601
+ },
602
+ {
603
+ "name": "cubic_pool_program"
604
+ }
605
+ ],
606
+ "args": []
607
+ },
434
608
  {
435
609
  "name": "pool_set_banned_extensions",
436
610
  "discriminator": [
@@ -666,6 +840,58 @@
666
840
  ],
667
841
  "args": []
668
842
  },
843
+ {
844
+ "name": "set_supervisor",
845
+ "docs": [
846
+ "Set or revoke the `supervisor` pubkey on Treasury.",
847
+ "",
848
+ "Supervisor can call ONLY `freeze_pools` and `unfreeze_pools` —",
849
+ "nothing else. Single-step: admin sets it directly, no claim flow.",
850
+ "Pass `Pubkey::default()` to revoke.",
851
+ "",
852
+ "# Authority",
853
+ "`treasury.admin` only.",
854
+ "",
855
+ "# Migration side-effect",
856
+ "First call after the v2 upgrade reallocs the Treasury account",
857
+ "from 786 → 818 bytes (admin pays the rent diff). Subsequent",
858
+ "calls are no-op on size."
859
+ ],
860
+ "discriminator": [
861
+ 45,
862
+ 205,
863
+ 198,
864
+ 102,
865
+ 110,
866
+ 132,
867
+ 55,
868
+ 38
869
+ ],
870
+ "accounts": [
871
+ {
872
+ "name": "treasury",
873
+ "docs": [
874
+ "and write below. The PDA seed constraint guarantees this is the",
875
+ "Treasury — but its on-chain size may be v1 (786) or v2 (818)."
876
+ ],
877
+ "writable": true
878
+ },
879
+ {
880
+ "name": "admin",
881
+ "writable": true,
882
+ "signer": true
883
+ },
884
+ {
885
+ "name": "system_program"
886
+ }
887
+ ],
888
+ "args": [
889
+ {
890
+ "name": "new_supervisor",
891
+ "type": "pubkey"
892
+ }
893
+ ]
894
+ },
669
895
  {
670
896
  "name": "stld_withdraw_sol",
671
897
  "discriminator": [
@@ -752,6 +978,49 @@
752
978
  }
753
979
  ]
754
980
  },
981
+ {
982
+ "name": "unfreeze_pools",
983
+ "docs": [
984
+ "Batch-unfreeze pools — re-enable operations on every",
985
+ "`[config_i, pool_i]` pair passed via `remaining_accounts`.",
986
+ "Mirror of `freeze_pools`.",
987
+ "",
988
+ "# Authority",
989
+ "`treasury.admin` OR `treasury.supervisor` (when set)."
990
+ ],
991
+ "discriminator": [
992
+ 19,
993
+ 205,
994
+ 34,
995
+ 128,
996
+ 205,
997
+ 228,
998
+ 105,
999
+ 112
1000
+ ],
1001
+ "accounts": [
1002
+ {
1003
+ "name": "treasury",
1004
+ "docs": [
1005
+ "Treasury PDA (signs the cubic-pool CPI). Read-only here; the",
1006
+ "CPI uses `treasury.to_account_info()` with `invoke_signed`",
1007
+ "seeds, so this account doesn't need `mut`."
1008
+ ]
1009
+ },
1010
+ {
1011
+ "name": "authority",
1012
+ "docs": [
1013
+ "Either `treasury.admin` or `treasury.supervisor` — handler",
1014
+ "enforces."
1015
+ ],
1016
+ "signer": true
1017
+ },
1018
+ {
1019
+ "name": "cubic_pool_program"
1020
+ }
1021
+ ],
1022
+ "args": []
1023
+ },
755
1024
  {
756
1025
  "name": "upgrade_pool_program",
757
1026
  "docs": [
@@ -950,6 +1219,19 @@
950
1219
  118
951
1220
  ]
952
1221
  },
1222
+ {
1223
+ "name": "PoolAltInitializedByTreasury",
1224
+ "discriminator": [
1225
+ 49,
1226
+ 149,
1227
+ 148,
1228
+ 98,
1229
+ 223,
1230
+ 127,
1231
+ 132,
1232
+ 111
1233
+ ]
1234
+ },
953
1235
  {
954
1236
  "name": "PoolBannedExtensionsSet",
955
1237
  "discriminator": [
@@ -1015,6 +1297,19 @@
1015
1297
  242
1016
1298
  ]
1017
1299
  },
1300
+ {
1301
+ "name": "PoolMigratedV4ByTreasury",
1302
+ "discriminator": [
1303
+ 222,
1304
+ 163,
1305
+ 236,
1306
+ 129,
1307
+ 117,
1308
+ 208,
1309
+ 55,
1310
+ 12
1311
+ ]
1312
+ },
1018
1313
  {
1019
1314
  "name": "PoolProtocolAdminTransferAccepted",
1020
1315
  "discriminator": [
@@ -1093,6 +1388,32 @@
1093
1388
  168
1094
1389
  ]
1095
1390
  },
1391
+ {
1392
+ "name": "PoolsFrozen",
1393
+ "discriminator": [
1394
+ 113,
1395
+ 120,
1396
+ 15,
1397
+ 95,
1398
+ 223,
1399
+ 23,
1400
+ 172,
1401
+ 162
1402
+ ]
1403
+ },
1404
+ {
1405
+ "name": "PoolsUnfrozen",
1406
+ "discriminator": [
1407
+ 124,
1408
+ 35,
1409
+ 103,
1410
+ 45,
1411
+ 1,
1412
+ 42,
1413
+ 62,
1414
+ 84
1415
+ ]
1416
+ },
1096
1417
  {
1097
1418
  "name": "ProgramClosed",
1098
1419
  "discriminator": [
@@ -1158,6 +1479,19 @@
1158
1479
  80
1159
1480
  ]
1160
1481
  },
1482
+ {
1483
+ "name": "SupervisorSet",
1484
+ "discriminator": [
1485
+ 250,
1486
+ 252,
1487
+ 67,
1488
+ 215,
1489
+ 142,
1490
+ 52,
1491
+ 106,
1492
+ 61
1493
+ ]
1494
+ },
1161
1495
  {
1162
1496
  "name": "TokenRegistered",
1163
1497
  "discriminator": [
@@ -1238,6 +1572,11 @@
1238
1572
  "code": 6007,
1239
1573
  "name": "MathError",
1240
1574
  "msg": "Math error"
1575
+ },
1576
+ {
1577
+ "code": 6008,
1578
+ "name": "InvalidAccountLayout",
1579
+ "msg": "Invalid remaining_accounts layout: expected non-empty [config, pool] pairs"
1241
1580
  }
1242
1581
  ],
1243
1582
  "types": [
@@ -1345,6 +1684,38 @@
1345
1684
  ]
1346
1685
  }
1347
1686
  },
1687
+ {
1688
+ "name": "PoolAltInitializedByTreasury",
1689
+ "docs": [
1690
+ "Emitted when the operator provisions a per-pool ALT via",
1691
+ "`pool_initialize_alt`. Counterpart to cubic_pools `PoolAltInitialized`."
1692
+ ],
1693
+ "type": {
1694
+ "kind": "struct",
1695
+ "fields": [
1696
+ {
1697
+ "name": "treasury",
1698
+ "type": "pubkey"
1699
+ },
1700
+ {
1701
+ "name": "pool",
1702
+ "type": "pubkey"
1703
+ },
1704
+ {
1705
+ "name": "lookup_table",
1706
+ "type": "pubkey"
1707
+ },
1708
+ {
1709
+ "name": "admin",
1710
+ "type": "pubkey"
1711
+ },
1712
+ {
1713
+ "name": "timestamp",
1714
+ "type": "i64"
1715
+ }
1716
+ ]
1717
+ }
1718
+ },
1348
1719
  {
1349
1720
  "name": "PoolBannedExtensionsSet",
1350
1721
  "type": {
@@ -1457,6 +1828,37 @@
1457
1828
  ]
1458
1829
  }
1459
1830
  },
1831
+ {
1832
+ "name": "PoolMigratedV4ByTreasury",
1833
+ "docs": [
1834
+ "Emitted when the operator (`treasury.admin`) migrates a v3 pool to",
1835
+ "v4 via `pool_migrate_v4`, bypassing the per-pool `pool_admin` path.",
1836
+ "Distinguishable from `cubic_pool::PoolMigratedToV4` (which is also",
1837
+ "emitted by the inner CPI) so observers can attribute operator-driven",
1838
+ "migrations."
1839
+ ],
1840
+ "type": {
1841
+ "kind": "struct",
1842
+ "fields": [
1843
+ {
1844
+ "name": "treasury",
1845
+ "type": "pubkey"
1846
+ },
1847
+ {
1848
+ "name": "pool",
1849
+ "type": "pubkey"
1850
+ },
1851
+ {
1852
+ "name": "admin",
1853
+ "type": "pubkey"
1854
+ },
1855
+ {
1856
+ "name": "timestamp",
1857
+ "type": "i64"
1858
+ }
1859
+ ]
1860
+ }
1861
+ },
1460
1862
  {
1461
1863
  "name": "PoolProtocolAdminTransferAccepted",
1462
1864
  "type": {
@@ -1601,6 +2003,63 @@
1601
2003
  ]
1602
2004
  }
1603
2005
  },
2006
+ {
2007
+ "name": "PoolsFrozen",
2008
+ "docs": [
2009
+ "Emitted by `freeze_pools` after every per-pool CPI has succeeded.",
2010
+ "`pool_count` matches the number of `[config, pool]` pairs the caller",
2011
+ "passed via `remaining_accounts`. `authority` is the actual signer —",
2012
+ "either `treasury.admin` or `treasury.supervisor`."
2013
+ ],
2014
+ "type": {
2015
+ "kind": "struct",
2016
+ "fields": [
2017
+ {
2018
+ "name": "treasury",
2019
+ "type": "pubkey"
2020
+ },
2021
+ {
2022
+ "name": "authority",
2023
+ "type": "pubkey"
2024
+ },
2025
+ {
2026
+ "name": "pool_count",
2027
+ "type": "u32"
2028
+ },
2029
+ {
2030
+ "name": "timestamp",
2031
+ "type": "i64"
2032
+ }
2033
+ ]
2034
+ }
2035
+ },
2036
+ {
2037
+ "name": "PoolsUnfrozen",
2038
+ "docs": [
2039
+ "Emitted by `unfreeze_pools`. Mirrors `PoolsFrozen`."
2040
+ ],
2041
+ "type": {
2042
+ "kind": "struct",
2043
+ "fields": [
2044
+ {
2045
+ "name": "treasury",
2046
+ "type": "pubkey"
2047
+ },
2048
+ {
2049
+ "name": "authority",
2050
+ "type": "pubkey"
2051
+ },
2052
+ {
2053
+ "name": "pool_count",
2054
+ "type": "u32"
2055
+ },
2056
+ {
2057
+ "name": "timestamp",
2058
+ "type": "i64"
2059
+ }
2060
+ ]
2061
+ }
2062
+ },
1604
2063
  {
1605
2064
  "name": "ProgramClosed",
1606
2065
  "type": {
@@ -1725,6 +2184,38 @@
1725
2184
  ]
1726
2185
  }
1727
2186
  },
2187
+ {
2188
+ "name": "SupervisorSet",
2189
+ "docs": [
2190
+ "Emitted by `set_supervisor`. `new_supervisor == Pubkey::default()`",
2191
+ "means the role was revoked."
2192
+ ],
2193
+ "type": {
2194
+ "kind": "struct",
2195
+ "fields": [
2196
+ {
2197
+ "name": "treasury",
2198
+ "type": "pubkey"
2199
+ },
2200
+ {
2201
+ "name": "admin",
2202
+ "type": "pubkey"
2203
+ },
2204
+ {
2205
+ "name": "old_supervisor",
2206
+ "type": "pubkey"
2207
+ },
2208
+ {
2209
+ "name": "new_supervisor",
2210
+ "type": "pubkey"
2211
+ },
2212
+ {
2213
+ "name": "timestamp",
2214
+ "type": "i64"
2215
+ }
2216
+ ]
2217
+ }
2218
+ },
1728
2219
  {
1729
2220
  "name": "TokenRegistered",
1730
2221
  "type": {
@@ -1757,8 +2248,16 @@
1757
2248
  "name": "Treasury",
1758
2249
  "docs": [
1759
2250
  "Singleton governance account at PDA `[b\"treasury\"]`. Holds the human",
1760
- "admin pubkey, a list of registered token mints + vault addresses, and",
1761
- "pending-admin state for the 2-step transfer flow."
2251
+ "admin pubkey, a list of registered token mints + vault addresses,",
2252
+ "pending-admin state for the 2-step transfer flow, and the limited",
2253
+ "`supervisor` circuit-breaker pubkey.",
2254
+ "",
2255
+ "## Layout history",
2256
+ "v1 (786 bytes): admin, pending_admin, bump, token_count, mints,",
2257
+ "vaults, created_at, reserved[64].",
2258
+ "v2 (818 bytes): same + `supervisor: Pubkey` appended at the end.",
2259
+ "Existing v1 accounts are grown to v2 via the `realloc` constraint",
2260
+ "on `set_supervisor`'s context (admin pays the lamport diff)."
1762
2261
  ],
1763
2262
  "type": {
1764
2263
  "kind": "struct",
@@ -1834,6 +2333,18 @@
1834
2333
  64
1835
2334
  ]
1836
2335
  }
2336
+ },
2337
+ {
2338
+ "name": "supervisor",
2339
+ "docs": [
2340
+ "Limited circuit-breaker pubkey. Allowed to call ONLY",
2341
+ "`freeze_pools` and `unfreeze_pools`. Cannot transfer itself, has",
2342
+ "no claim flow — admin sets it directly via `set_supervisor`.",
2343
+ "`Pubkey::default()` ⇒ no supervisor; only admin can freeze.",
2344
+ "Added in v2; reads as `Pubkey::default()` on un-migrated v1",
2345
+ "accounts after `set_supervisor`'s realloc grows the account."
2346
+ ],
2347
+ "type": "pubkey"
1837
2348
  }
1838
2349
  ]
1839
2350
  }
package/src/index.ts CHANGED
@@ -97,7 +97,12 @@ export {
97
97
  buildInitializeConfigIx,
98
98
  buildInitializeCubicPoolIx,
99
99
  buildDeployPoolTx,
100
+ buildInitializePoolAltIx,
101
+ buildInitializePoolAltTx,
102
+ deriveAltAddress,
100
103
  } from "./clients/tx-builders";
104
+ export { buildVersionedTx, compileBuiltTx } from "./clients/versioned";
105
+ export type { InitializePoolAltParams } from "./clients/tx-builders";
101
106
  export { decodePoolAccount, POOL_DISCRIMINATOR_LEN } from "./parsers/poolAccount";
102
107
  export { decodeMintAccount } from "./parsers/mintAccount";
103
108
  export { parseCubicPoolEvents } from "./parsers/events";