@cubee_ee/sdk 0.2.3 → 0.2.4

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.
@@ -500,6 +500,111 @@
500
500
  }
501
501
  ]
502
502
  },
503
+ {
504
+ "name": "initialize_pool_alt",
505
+ "docs": [
506
+ "Provision a per-pool Address Lookup Table so client SDKs can build",
507
+ "`VersionedTransaction`s for `add_liquidity` / `remove_liquidity` on",
508
+ "pools whose account count exceeds the legacy 1232-byte ceiling",
509
+ "(≥ 7 tokens in practice).",
510
+ "",
511
+ "# Parameters",
512
+ "* `recent_slot` — recent slot used by the ALT program to derive",
513
+ "the table address. Caller should pass",
514
+ "`connection.getSlot('finalized')`.",
515
+ "",
516
+ "# Flow",
517
+ "One transaction performs three CPIs into the ALT program:",
518
+ "`create_lookup_table` → `extend_lookup_table` (pool, BPT mint,",
519
+ "vaults, mints, standard programs) → `freeze_lookup_table`.",
520
+ "The ALT becomes immutable forever — its rent (~0.005 SOL for a",
521
+ "7-token pool) is permanently locked.",
522
+ "",
523
+ "# Authority",
524
+ "`pool.pool_admin`. Idempotent: rejects with `AltAlreadyInitialized`",
525
+ "if `pool.lookup_table != Pubkey::default()`.",
526
+ "",
527
+ "# Used by",
528
+ "`scripts/cli/initialize-pool-alts.ts` (one-shot bootstrap for",
529
+ "existing prod pools), and `sdk` after `initialize_cubic_pool` on",
530
+ "fresh pools."
531
+ ],
532
+ "discriminator": [
533
+ 251,
534
+ 135,
535
+ 66,
536
+ 2,
537
+ 244,
538
+ 73,
539
+ 12,
540
+ 144
541
+ ],
542
+ "accounts": [
543
+ {
544
+ "name": "pool",
545
+ "docs": [
546
+ "Pool to provision the ALT for. Must have `lookup_table ==",
547
+ "Pubkey::default()`. The handler writes the new ALT address back",
548
+ "onto this account."
549
+ ],
550
+ "writable": true
551
+ },
552
+ {
553
+ "name": "config",
554
+ "docs": [
555
+ "`CubicPoolConfig` this pool inherits governance from. Pinned via",
556
+ "`pool.config`. Reading it lets the handler also accept",
557
+ "`config.protocol_admin` as an authority — which is the Treasury",
558
+ "PDA, only signable through `protocol_admin.pool_initialize_alt`."
559
+ ]
560
+ },
561
+ {
562
+ "name": "authority",
563
+ "docs": [
564
+ "Authority. Must equal either `pool.pool_admin` (per-pool owner",
565
+ "path) or `config.protocol_admin` (Treasury PDA via the",
566
+ "protocol-admin CPI wrapper). Authorises the ALT creation; the",
567
+ "derived ALT address is `[authority, recent_slot]`."
568
+ ],
569
+ "signer": true
570
+ },
571
+ {
572
+ "name": "payer",
573
+ "docs": [
574
+ "Payer for ALT rent + per-extend top-ups. Decoupled from",
575
+ "`authority` because Treasury PDA (the wrapper-path authority)",
576
+ "owns data and so cannot be `from` in `system_program::transfer`.",
577
+ "In the pool-admin path callers pass the same key for both — no",
578
+ "behavioural change."
579
+ ],
580
+ "writable": true,
581
+ "signer": true
582
+ },
583
+ {
584
+ "name": "lookup_table",
585
+ "docs": [
586
+ "`[authority, recent_slot]` by the ALT program. Re-derived and",
587
+ "matched against this account in the handler."
588
+ ],
589
+ "writable": true
590
+ },
591
+ {
592
+ "name": "system_program"
593
+ },
594
+ {
595
+ "name": "alt_program",
596
+ "docs": [
597
+ "`solana_address_lookup_table_interface::id()` in the handler."
598
+ ]
599
+ }
600
+ ],
601
+ "args": [
602
+ {
603
+ "name": "recent_slot",
604
+ "type": "u64"
605
+ }
606
+ ]
607
+ },
503
608
  {
504
609
  "name": "initiate_pool_admin_transfer",
505
610
  "docs": [
@@ -564,6 +669,123 @@
564
669
  }
565
670
  ]
566
671
  },
672
+ {
673
+ "name": "migrate_pool_v4",
674
+ "docs": [
675
+ "Rewrite a v3-layout pool account into the v4 AoS layout. One-shot,",
676
+ "idempotent, signed by `pool.pool_admin`. Required exactly once per",
677
+ "pre-existing pool after the cubic-pool program is upgraded to a",
678
+ "binary built against the v4 struct.",
679
+ "",
680
+ "# Used by",
681
+ "`scripts/ping-prod-pools.ts` reports which pools need this; the",
682
+ "admin runs it as a follow-up. New pools created via",
683
+ "`initialize_cubic_pool` skip migration entirely (they're v4 from",
684
+ "birth)."
685
+ ],
686
+ "discriminator": [
687
+ 227,
688
+ 124,
689
+ 203,
690
+ 29,
691
+ 107,
692
+ 79,
693
+ 175,
694
+ 240
695
+ ],
696
+ "accounts": [
697
+ {
698
+ "name": "pool",
699
+ "writable": true
700
+ },
701
+ {
702
+ "name": "config",
703
+ "docs": [
704
+ "referenced by the pool's v3 header. We read `protocol_admin` from",
705
+ "its raw bytes so the alternative signer path doesn't need Anchor",
706
+ "to deserialise the config (which is cheap, but this keeps the",
707
+ "migration handler's account list as flat as the v3 layout it's",
708
+ "rewriting)."
709
+ ]
710
+ },
711
+ {
712
+ "name": "authority",
713
+ "docs": [
714
+ "Must equal either the v3 `pool_admin` field stored inside",
715
+ "`pool.data`, OR the `protocol_admin` field stored inside",
716
+ "`config.data` (= Treasury PDA on mainnet, only reachable via",
717
+ "`protocol_admin.pool_migrate_v4` CPI which signs the PDA via",
718
+ "`signer_seeds`)."
719
+ ],
720
+ "writable": true,
721
+ "signer": true
722
+ },
723
+ {
724
+ "name": "system_program"
725
+ }
726
+ ],
727
+ "args": []
728
+ },
729
+ {
730
+ "name": "range_manager_update",
731
+ "docs": [
732
+ "Tweak any subset of `virtual_balances` and / or `normalized_weights`",
733
+ "within the configured envelope. Range-manager only.",
734
+ "",
735
+ "# Parameters",
736
+ "* `vb_changes` — sparse `[(index, new_vb)]`; may be empty.",
737
+ "* `weight_changes` — sparse `[(index, new_weight_bps)]`; may be",
738
+ "empty. The resulting weight vector must sum to `WEIGHT_SCALE`",
739
+ "and stay within `[MIN_WEIGHT, MAX_WEIGHT]` per token, otherwise",
740
+ "the whole instruction reverts."
741
+ ],
742
+ "discriminator": [
743
+ 245,
744
+ 183,
745
+ 35,
746
+ 69,
747
+ 200,
748
+ 10,
749
+ 172,
750
+ 44
751
+ ],
752
+ "accounts": [
753
+ {
754
+ "name": "pool",
755
+ "docs": [
756
+ "Mutated — handler writes new virtual_balances / normalized_weights",
757
+ "and bumps `range_manager_last_updated`."
758
+ ],
759
+ "writable": true
760
+ },
761
+ {
762
+ "name": "authority",
763
+ "signer": true
764
+ }
765
+ ],
766
+ "args": [
767
+ {
768
+ "name": "vb_changes",
769
+ "type": {
770
+ "vec": {
771
+ "defined": {
772
+ "name": "TokenChange"
773
+ }
774
+ }
775
+ }
776
+ },
777
+ {
778
+ "name": "weight_changes",
779
+ "type": {
780
+ "vec": {
781
+ "defined": {
782
+ "name": "TokenChange"
783
+ }
784
+ }
785
+ }
786
+ }
787
+ ]
788
+ },
567
789
  {
568
790
  "name": "remove_liquidity",
569
791
  "docs": [
@@ -667,6 +889,53 @@
667
889
  }
668
890
  ]
669
891
  },
892
+ {
893
+ "name": "set_max_selloff",
894
+ "docs": [
895
+ "Set `(max_selloff, max_selloff_period_length)` for every active",
896
+ "token in a single call. Pool-admin only.",
897
+ "",
898
+ "# Parameters",
899
+ "* `max_selloffs` — length == `token_count`. Raw units; `0`",
900
+ "disables the check on that token.",
901
+ "* `period_lengths` — length == `token_count`. Seconds. Must be",
902
+ "`> 0` when paired `max_selloff > 0`."
903
+ ],
904
+ "discriminator": [
905
+ 100,
906
+ 44,
907
+ 68,
908
+ 198,
909
+ 33,
910
+ 58,
911
+ 147,
912
+ 254
913
+ ],
914
+ "accounts": [
915
+ {
916
+ "name": "pool",
917
+ "writable": true
918
+ },
919
+ {
920
+ "name": "authority",
921
+ "signer": true
922
+ }
923
+ ],
924
+ "args": [
925
+ {
926
+ "name": "max_selloffs",
927
+ "type": {
928
+ "vec": "u64"
929
+ }
930
+ },
931
+ {
932
+ "name": "period_lengths",
933
+ "type": {
934
+ "vec": "u32"
935
+ }
936
+ }
937
+ ]
938
+ },
670
939
  {
671
940
  "name": "set_pool_enabled",
672
941
  "docs": [
@@ -753,6 +1022,98 @@
753
1022
  }
754
1023
  ]
755
1024
  },
1025
+ {
1026
+ "name": "set_range_manager",
1027
+ "docs": [
1028
+ "Set or disable the range-manager pubkey on `pool`. Pool-admin only —",
1029
+ "protocol-admin cannot reach this. Combine `new_manager =",
1030
+ "Pubkey::default()` with `enabled = false` for the fully-disabled",
1031
+ "state. New pools deploy with this off by default.",
1032
+ "",
1033
+ "# Parameters",
1034
+ "* `new_manager` — pubkey allowed to call `range_manager_update`.",
1035
+ "* `enabled` — gate flag; `false` blocks the manager even if",
1036
+ "pubkey is set."
1037
+ ],
1038
+ "discriminator": [
1039
+ 103,
1040
+ 102,
1041
+ 173,
1042
+ 112,
1043
+ 8,
1044
+ 2,
1045
+ 37,
1046
+ 132
1047
+ ],
1048
+ "accounts": [
1049
+ {
1050
+ "name": "pool",
1051
+ "writable": true
1052
+ },
1053
+ {
1054
+ "name": "authority",
1055
+ "signer": true
1056
+ }
1057
+ ],
1058
+ "args": [
1059
+ {
1060
+ "name": "new_manager",
1061
+ "type": "pubkey"
1062
+ },
1063
+ {
1064
+ "name": "enabled",
1065
+ "type": "bool"
1066
+ }
1067
+ ]
1068
+ },
1069
+ {
1070
+ "name": "set_range_manager_config",
1071
+ "docs": [
1072
+ "Configure the envelope the range-manager must stay within. Pool-",
1073
+ "admin only. Limits are per-token (applied independently in the",
1074
+ "update loop) and basis points of the CURRENT value.",
1075
+ "",
1076
+ "# Parameters",
1077
+ "* `max_vb_change_bps` — ≤ 10_000. 5% = 500.",
1078
+ "* `max_weight_change_bps` — ≤ 10_000.",
1079
+ "* `min_update_interval_secs` — rate-limit between successive",
1080
+ "`range_manager_update` calls."
1081
+ ],
1082
+ "discriminator": [
1083
+ 103,
1084
+ 211,
1085
+ 0,
1086
+ 200,
1087
+ 164,
1088
+ 189,
1089
+ 245,
1090
+ 205
1091
+ ],
1092
+ "accounts": [
1093
+ {
1094
+ "name": "pool",
1095
+ "writable": true
1096
+ },
1097
+ {
1098
+ "name": "authority",
1099
+ "signer": true
1100
+ }
1101
+ ],
1102
+ "args": [
1103
+ {
1104
+ "name": "max_vb_change_bps",
1105
+ "type": "u16"
1106
+ },
1107
+ {
1108
+ "name": "max_weight_change_bps",
1109
+ "type": "u16"
1110
+ },
1111
+ {
1112
+ "name": "min_update_interval_secs",
1113
+ "type": "u32"
1114
+ }
1115
+ ]
1116
+ },
756
1117
  {
757
1118
  "name": "set_swap_fee_rate",
758
1119
  "docs": [
@@ -1060,6 +1421,32 @@
1060
1421
  189
1061
1422
  ]
1062
1423
  },
1424
+ {
1425
+ "name": "MaxSelloffSet",
1426
+ "discriminator": [
1427
+ 134,
1428
+ 183,
1429
+ 49,
1430
+ 134,
1431
+ 82,
1432
+ 138,
1433
+ 85,
1434
+ 234
1435
+ ]
1436
+ },
1437
+ {
1438
+ "name": "MaxSelloffWindowAdvanced",
1439
+ "discriminator": [
1440
+ 229,
1441
+ 227,
1442
+ 163,
1443
+ 30,
1444
+ 22,
1445
+ 183,
1446
+ 78,
1447
+ 57
1448
+ ]
1449
+ },
1063
1450
  {
1064
1451
  "name": "PoolAdminDisabled",
1065
1452
  "discriminator": [
@@ -1113,12 +1500,25 @@
1113
1500
  ]
1114
1501
  },
1115
1502
  {
1116
- "name": "PoolEnabledUpdated",
1503
+ "name": "PoolAltInitialized",
1117
1504
  "discriminator": [
1118
- 101,
1119
- 47,
1120
- 3,
1121
- 240,
1505
+ 61,
1506
+ 210,
1507
+ 86,
1508
+ 20,
1509
+ 100,
1510
+ 253,
1511
+ 41,
1512
+ 133
1513
+ ]
1514
+ },
1515
+ {
1516
+ "name": "PoolEnabledUpdated",
1517
+ "discriminator": [
1518
+ 101,
1519
+ 47,
1520
+ 3,
1521
+ 240,
1122
1522
  197,
1123
1523
  181,
1124
1524
  236,
@@ -1151,6 +1551,19 @@
1151
1551
  229
1152
1552
  ]
1153
1553
  },
1554
+ {
1555
+ "name": "PoolMigratedToV4",
1556
+ "discriminator": [
1557
+ 168,
1558
+ 224,
1559
+ 51,
1560
+ 159,
1561
+ 66,
1562
+ 20,
1563
+ 83,
1564
+ 146
1565
+ ]
1566
+ },
1154
1567
  {
1155
1568
  "name": "PoolSolWithdrawn",
1156
1569
  "discriminator": [
@@ -1242,6 +1655,45 @@
1242
1655
  191
1243
1656
  ]
1244
1657
  },
1658
+ {
1659
+ "name": "RangeManagerConfigSet",
1660
+ "discriminator": [
1661
+ 187,
1662
+ 59,
1663
+ 98,
1664
+ 47,
1665
+ 108,
1666
+ 2,
1667
+ 229,
1668
+ 152
1669
+ ]
1670
+ },
1671
+ {
1672
+ "name": "RangeManagerSet",
1673
+ "discriminator": [
1674
+ 62,
1675
+ 152,
1676
+ 235,
1677
+ 91,
1678
+ 195,
1679
+ 238,
1680
+ 83,
1681
+ 202
1682
+ ]
1683
+ },
1684
+ {
1685
+ "name": "RangeManagerUpdated",
1686
+ "discriminator": [
1687
+ 132,
1688
+ 144,
1689
+ 100,
1690
+ 144,
1691
+ 149,
1692
+ 205,
1693
+ 212,
1694
+ 24
1695
+ ]
1696
+ },
1245
1697
  {
1246
1698
  "name": "Swap",
1247
1699
  "discriminator": [
@@ -1477,9 +1929,258 @@
1477
1929
  "code": 6038,
1478
1930
  "name": "ProtocolAdminNotTreasury",
1479
1931
  "msg": "protocol_admin must equal the hardcoded Treasury PDA"
1932
+ },
1933
+ {
1934
+ "code": 6039,
1935
+ "name": "RangeManagerDisabled",
1936
+ "msg": "Range manager is not enabled for this pool"
1937
+ },
1938
+ {
1939
+ "code": 6040,
1940
+ "name": "RangeManagerUnauthorized",
1941
+ "msg": "Signer is not the configured range manager"
1942
+ },
1943
+ {
1944
+ "code": 6041,
1945
+ "name": "RangeManagerUpdateTooFrequent",
1946
+ "msg": "Range manager update too frequent — minimum interval not yet elapsed"
1947
+ },
1948
+ {
1949
+ "code": 6042,
1950
+ "name": "RangeManagerVbChangeTooLarge",
1951
+ "msg": "Range manager virtual balance change exceeds configured bps cap"
1952
+ },
1953
+ {
1954
+ "code": 6043,
1955
+ "name": "RangeManagerWeightChangeTooLarge",
1956
+ "msg": "Range manager weight change exceeds configured bps cap"
1957
+ },
1958
+ {
1959
+ "code": 6044,
1960
+ "name": "RangeManagerEmptyUpdate",
1961
+ "msg": "Range manager update must change at least one virtual balance or weight"
1962
+ },
1963
+ {
1964
+ "code": 6045,
1965
+ "name": "RangeManagerInvalidBps",
1966
+ "msg": "Range manager bps parameter exceeds 10000"
1967
+ },
1968
+ {
1969
+ "code": 6046,
1970
+ "name": "RangeManagerWeightSumInvalid",
1971
+ "msg": "Resulting weights do not sum to WEIGHT_SCALE after range manager update"
1972
+ },
1973
+ {
1974
+ "code": 6047,
1975
+ "name": "RangeManagerDuplicateIndex",
1976
+ "msg": "Duplicate token index in range manager update"
1977
+ },
1978
+ {
1979
+ "code": 6048,
1980
+ "name": "MaxSelloffInvalidConfig",
1981
+ "msg": "max_selloff_period_length must be > 0 when max_selloff > 0"
1982
+ },
1983
+ {
1984
+ "code": 6049,
1985
+ "name": "MaxSelloffExceeded",
1986
+ "msg": "Token max-selloff threshold exceeded for current window"
1987
+ },
1988
+ {
1989
+ "code": 6050,
1990
+ "name": "AlreadyMigrated",
1991
+ "msg": "Pool is already migrated to v4"
1992
+ },
1993
+ {
1994
+ "code": 6051,
1995
+ "name": "UnexpectedPoolSize",
1996
+ "msg": "Unexpected pool account size — not v3 or v4"
1997
+ },
1998
+ {
1999
+ "code": 6052,
2000
+ "name": "InvalidPoolDiscriminator",
2001
+ "msg": "Account discriminator does not match CubicPool"
2002
+ },
2003
+ {
2004
+ "code": 6053,
2005
+ "name": "AltAlreadyInitialized",
2006
+ "msg": "Pool already has an Address Lookup Table initialised"
2007
+ },
2008
+ {
2009
+ "code": 6054,
2010
+ "name": "AltAddressMismatch",
2011
+ "msg": "ALT address mismatch — re-derived from recent_slot doesn't match passed account"
2012
+ },
2013
+ {
2014
+ "code": 6055,
2015
+ "name": "InvalidAltProgram",
2016
+ "msg": "Invalid Address Lookup Table program id"
1480
2017
  }
1481
2018
  ],
1482
2019
  "types": [
2020
+ {
2021
+ "name": "AssetConfig",
2022
+ "docs": [
2023
+ "`CubicPool` v4 — per-pool state for a weighted AMM with virtual liquidity.",
2024
+ "",
2025
+ "Storage layout: **Array-of-Structs (AoS)**. Per-token data lives in",
2026
+ "`tokens: [TokenSlot; MAX_TOKENS]`. Each `TokenSlot` carries TWO nested",
2027
+ "sub-structs:",
2028
+ "",
2029
+ "- `config: AssetConfig` — admin-controlled, rarely changes (mint,",
2030
+ "token_program, weight, max_selloff, period).",
2031
+ "- `dynamics: AssetDynamics` — auto-updated by user txs (balances,",
2032
+ "protocol_fees_owed, sliding-window selloff state).",
2033
+ "",
2034
+ "This mirrors Solend / MarginFi / Kamino's `Reserve { config, ... }`",
2035
+ "pattern. Reading per-token data is a single struct lookup; auditors",
2036
+ "see at a glance which fields a user can mutate vs which need pool",
2037
+ "admin authority.",
2038
+ "",
2039
+ "## Storage layout — DO NOT REORDER",
2040
+ "Backends (`onchainPoolFetcher.ts`, indexer) and v3-to-v4 migration",
2041
+ "code both read fields by raw offset. Adding fields is OK if appended",
2042
+ "at the END (before the trailing `reserved`) and `reserved` shrinks",
2043
+ "accordingly. Inserting in the middle requires a new migration.",
2044
+ "",
2045
+ "## Derived (not stored) state",
2046
+ "- `bpt_mint` — derived as `[BPT_MINT_SEED, pool]` PDA.",
2047
+ "- `bpt_total_supply`— read from `bpt_mint.supply` at runtime.",
2048
+ "- `token_vaults[i]` — derived as ATA(pool, mint, tokens[i].config.token_program).",
2049
+ "- `token_decimals` — read from each mint account at runtime.",
2050
+ "",
2051
+ "## Migrating from v3",
2052
+ "v3 stored per-token data as parallel arrays (`token_mints[10]`,",
2053
+ "`token_programs[10]`, `normalized_weights[10]`, …). v4 packs the same",
2054
+ "info into `tokens: [TokenSlot; 10]`. A one-time `migrate_pool_v4`",
2055
+ "instruction rewrites existing accounts."
2056
+ ],
2057
+ "type": {
2058
+ "kind": "struct",
2059
+ "fields": [
2060
+ {
2061
+ "name": "mint",
2062
+ "docs": [
2063
+ "Token mint pubkey for this slot. `Pubkey::default()` past `token_count`."
2064
+ ],
2065
+ "type": "pubkey"
2066
+ },
2067
+ {
2068
+ "name": "token_program",
2069
+ "docs": [
2070
+ "SPL Token or Token-2022 program ID for this token's vault/transfers."
2071
+ ],
2072
+ "type": "pubkey"
2073
+ },
2074
+ {
2075
+ "name": "normalized_weight",
2076
+ "docs": [
2077
+ "Normalised weight in basis points (sum across active slots == 10_000)."
2078
+ ],
2079
+ "type": "u64"
2080
+ },
2081
+ {
2082
+ "name": "max_selloff",
2083
+ "docs": [
2084
+ "Max cumulative sell volume of this token (as `amount_in` in swaps)",
2085
+ "over the sliding window `max_selloff_period_length`. `0` disables",
2086
+ "the check for this token. Set by pool_admin only."
2087
+ ],
2088
+ "type": "u64"
2089
+ },
2090
+ {
2091
+ "name": "max_selloff_period_length",
2092
+ "docs": [
2093
+ "Length of the sliding window in seconds. Ignored when",
2094
+ "`max_selloff == 0`. Set by pool_admin only."
2095
+ ],
2096
+ "type": "u32"
2097
+ },
2098
+ {
2099
+ "name": "reserved",
2100
+ "docs": [
2101
+ "Future-compat (do not repurpose)."
2102
+ ],
2103
+ "type": {
2104
+ "array": [
2105
+ "u8",
2106
+ 4
2107
+ ]
2108
+ }
2109
+ }
2110
+ ]
2111
+ }
2112
+ },
2113
+ {
2114
+ "name": "AssetDynamics",
2115
+ "type": {
2116
+ "kind": "struct",
2117
+ "fields": [
2118
+ {
2119
+ "name": "virtual_balance",
2120
+ "docs": [
2121
+ "Virtual balance (raw token units) used by the cubic invariant",
2122
+ "math. Decoupled from `actual_balance` to enable concentrated",
2123
+ "liquidity. Updated by swap / add_liquidity / remove_liquidity."
2124
+ ],
2125
+ "type": "u64"
2126
+ },
2127
+ {
2128
+ "name": "actual_balance",
2129
+ "docs": [
2130
+ "Mirrors the on-chain vault balance for this token. Always equals",
2131
+ "the vault's `amount` after every successful tx (CEI ordering",
2132
+ "keeps them in sync)."
2133
+ ],
2134
+ "type": "u64"
2135
+ },
2136
+ {
2137
+ "name": "protocol_fees_owed",
2138
+ "docs": [
2139
+ "Accumulated protocol fees for this token (raw units), awaiting",
2140
+ "`collect_protocol_fees`. Stored separately from `actual_balance`",
2141
+ "so LP value isn't diluted by uncollected fees."
2142
+ ],
2143
+ "type": "u64"
2144
+ },
2145
+ {
2146
+ "name": "previous_selloff",
2147
+ "docs": [
2148
+ "Sliding-window rate limiter: amount sold in the PREVIOUS window",
2149
+ "(Cloudflare-style approximation, Solend RateLimiter pattern)."
2150
+ ],
2151
+ "type": "u64"
2152
+ },
2153
+ {
2154
+ "name": "current_selloff",
2155
+ "docs": [
2156
+ "Amount sold in the CURRENT window."
2157
+ ],
2158
+ "type": "u64"
2159
+ },
2160
+ {
2161
+ "name": "window_start_timestamp",
2162
+ "docs": [
2163
+ "`Clock::unix_timestamp` when the current window started. New",
2164
+ "pools: set to `now()` at init. After v3→v4 migration: set to",
2165
+ "`now()` at migration time."
2166
+ ],
2167
+ "type": "i64"
2168
+ },
2169
+ {
2170
+ "name": "reserved",
2171
+ "docs": [
2172
+ "Future-compat."
2173
+ ],
2174
+ "type": {
2175
+ "array": [
2176
+ "u8",
2177
+ 8
2178
+ ]
2179
+ }
2180
+ }
2181
+ ]
2182
+ }
2183
+ },
1483
2184
  {
1484
2185
  "name": "BannedExtensionsUpdated",
1485
2186
  "docs": [
@@ -1514,23 +2215,6 @@
1514
2215
  },
1515
2216
  {
1516
2217
  "name": "CubicPool",
1517
- "docs": [
1518
- "`CubicPool` — per-pool state for a weighted AMM with virtual liquidity.",
1519
- "",
1520
- "Each pool is a PDA derived from `[CUBIC_POOL_SEED, config_pubkey,",
1521
- "pool_id_le]`. One config can host many pools (different `pool_id`s).",
1522
- "",
1523
- "## Storage layout — DO NOT REORDER",
1524
- "Backends (`onchainPoolFetcher.ts`, indexer) read fields by raw offset.",
1525
- "Adding fields is fine if appended **before** `reserved` and `reserved`",
1526
- "shrinks accordingly so total `LEN` stays the same.",
1527
- "",
1528
- "## Derived (not stored) state",
1529
- "- `bpt_mint` — derived as `[BPT_MINT_SEED, pool]` PDA.",
1530
- "- `bpt_total_supply`— read from `bpt_mint.supply` at runtime.",
1531
- "- `token_vaults[i]` — derived as ATA(pool, mint, token_programs[i]).",
1532
- "- `token_decimals` — read from each mint account at runtime."
1533
- ],
1534
2218
  "type": {
1535
2219
  "kind": "struct",
1536
2220
  "fields": [
@@ -1567,72 +2251,6 @@
1567
2251
  ],
1568
2252
  "type": "u64"
1569
2253
  },
1570
- {
1571
- "name": "token_mints",
1572
- "docs": [
1573
- "Mint pubkeys for each active token, fixed length array padded with",
1574
- "`Pubkey::default()` past `token_count`."
1575
- ],
1576
- "type": {
1577
- "array": [
1578
- "pubkey",
1579
- 10
1580
- ]
1581
- }
1582
- },
1583
- {
1584
- "name": "token_programs",
1585
- "docs": [
1586
- "Per-token program ID (`spl_token::ID` or `spl_token_2022::ID`). A",
1587
- "single pool may mix legacy SPL tokens and Token-2022 mints."
1588
- ],
1589
- "type": {
1590
- "array": [
1591
- "pubkey",
1592
- 10
1593
- ]
1594
- }
1595
- },
1596
- {
1597
- "name": "normalized_weights",
1598
- "docs": [
1599
- "Normalised weights in basis points (sum = `WEIGHT_SCALE` = 10_000).",
1600
- "`weights[i] / WEIGHT_SCALE` is the target value-share of token i."
1601
- ],
1602
- "type": {
1603
- "array": [
1604
- "u64",
1605
- 10
1606
- ]
1607
- }
1608
- },
1609
- {
1610
- "name": "virtual_balances",
1611
- "docs": [
1612
- "Virtual balances (raw token units) used by the cubic invariant",
1613
- "math. Decoupled from actual vault holdings to enable concentrated",
1614
- "liquidity à la Cubic AMM. Updated by every swap / add / remove."
1615
- ],
1616
- "type": {
1617
- "array": [
1618
- "u64",
1619
- 10
1620
- ]
1621
- }
1622
- },
1623
- {
1624
- "name": "actual_balances",
1625
- "docs": [
1626
- "Actual balances mirrored from the on-chain vaults. Always",
1627
- "== vault.amount for that token (CEI ordering keeps them in sync)."
1628
- ],
1629
- "type": {
1630
- "array": [
1631
- "u64",
1632
- 10
1633
- ]
1634
- }
1635
- },
1636
2254
  {
1637
2255
  "name": "swap_fee_rate",
1638
2256
  "docs": [
@@ -1649,20 +2267,6 @@
1649
2267
  ],
1650
2268
  "type": "u16"
1651
2269
  },
1652
- {
1653
- "name": "protocol_fees_owed",
1654
- "docs": [
1655
- "Accumulated protocol fees per token (raw units), waiting on",
1656
- "`collect_protocol_fees`. Stored separately from `actual_balances`",
1657
- "so LP value isn't diluted by uncollected fees."
1658
- ],
1659
- "type": {
1660
- "array": [
1661
- "u64",
1662
- 10
1663
- ]
1664
- }
1665
- },
1666
2270
  {
1667
2271
  "name": "created_at",
1668
2272
  "docs": [
@@ -1674,8 +2278,7 @@
1674
2278
  "name": "pool_enabled",
1675
2279
  "docs": [
1676
2280
  "Master kill switch — when `false`, swaps and add/remove liquidity",
1677
- "all revert. Only `protocol_admin` can flip this; required to be",
1678
- "`false` before `debug_withdraw_liquidity` is callable."
2281
+ "all revert. Only `protocol_admin` can flip this."
1679
2282
  ],
1680
2283
  "type": "bool"
1681
2284
  },
@@ -1690,32 +2293,89 @@
1690
2293
  {
1691
2294
  "name": "pool_admin",
1692
2295
  "docs": [
1693
- "Per-pool admin. Initialised to the wallet that called",
1694
- "`initialize_cubic_pool`. Allowed to: rotate `swap_fee_rate`,",
1695
- "toggle `swaps_enabled`, transfer / disable itself via the",
1696
- "pending/accept/disable flow. Set to `Pubkey::default()` once the",
1697
- "admin role is renounced — after that, no pool-admin function is",
1698
- "callable on this pool, ever."
2296
+ "Per-pool admin. Owns: rotate swap_fee_rate, toggle swaps_enabled,",
2297
+ "set range_manager, set max_selloff, transfer/disable itself."
1699
2298
  ],
1700
2299
  "type": "pubkey"
1701
2300
  },
1702
2301
  {
1703
2302
  "name": "pending_pool_admin",
1704
2303
  "docs": [
1705
- "Pending successor for `pool_admin` during a 2-step transfer.",
1706
- "`Pubkey::default()` ⇒ no transfer in flight."
2304
+ "Pending successor for `pool_admin` during a 2-step transfer."
2305
+ ],
2306
+ "type": "pubkey"
2307
+ },
2308
+ {
2309
+ "name": "range_manager",
2310
+ "docs": [
2311
+ "Pubkey allowed to call `range_manager_update`. `Pubkey::default()`",
2312
+ "⇒ no manager set."
2313
+ ],
2314
+ "type": "pubkey"
2315
+ },
2316
+ {
2317
+ "name": "range_manager_enabled",
2318
+ "docs": [
2319
+ "`false` ⇒ all `range_manager_update` calls revert."
2320
+ ],
2321
+ "type": "bool"
2322
+ },
2323
+ {
2324
+ "name": "range_manager_max_vb_change_bps",
2325
+ "type": "u16"
2326
+ },
2327
+ {
2328
+ "name": "range_manager_max_weight_change_bps",
2329
+ "type": "u16"
2330
+ },
2331
+ {
2332
+ "name": "range_manager_min_update_interval_secs",
2333
+ "type": "u32"
2334
+ },
2335
+ {
2336
+ "name": "range_manager_last_updated",
2337
+ "type": "i64"
2338
+ },
2339
+ {
2340
+ "name": "tokens",
2341
+ "docs": [
2342
+ "All per-token state. Slot `i` is for the i-th token. Slots past",
2343
+ "`token_count` are zero-initialised and ignored."
2344
+ ],
2345
+ "type": {
2346
+ "array": [
2347
+ {
2348
+ "defined": {
2349
+ "name": "TokenSlot"
2350
+ }
2351
+ },
2352
+ 10
2353
+ ]
2354
+ }
2355
+ },
2356
+ {
2357
+ "name": "lookup_table",
2358
+ "docs": [
2359
+ "Per-pool Address Lookup Table address. Holds pool-scoped accounts",
2360
+ "(pool PDA, BPT mint, vaults, mints, token programs) so client SDKs",
2361
+ "can build VersionedTransactions for `add_liquidity` / `remove_liquidity`",
2362
+ "without hitting the 1232-byte legacy-tx ceiling on multi-token pools.",
2363
+ "",
2364
+ "`Pubkey::default()` ⇒ ALT not yet initialised. SDK falls back to",
2365
+ "legacy tx (will only work for small pools). Set by `initialize_pool_alt`,",
2366
+ "frozen on-chain so depositors don't worry about authority abuse."
1707
2367
  ],
1708
2368
  "type": "pubkey"
1709
2369
  },
1710
2370
  {
1711
2371
  "name": "reserved",
1712
2372
  "docs": [
1713
- "Forward-compat padding (do not repurpose without a migration plan)."
2373
+ "Forward-compat padding for pool-level fields."
1714
2374
  ],
1715
2375
  "type": {
1716
2376
  "array": [
1717
2377
  "u8",
1718
- 64
2378
+ 32
1719
2379
  ]
1720
2380
  }
1721
2381
  }
@@ -1897,6 +2557,89 @@
1897
2557
  ]
1898
2558
  }
1899
2559
  },
2560
+ {
2561
+ "name": "MaxSelloffSet",
2562
+ "docs": [
2563
+ "Emitted by `set_max_selloff`. `max_selloff` and",
2564
+ "`max_selloff_period_length` are the post-update arrays of length",
2565
+ "`token_count`. A zero in `max_selloff[i]` means the check is",
2566
+ "disabled for token i."
2567
+ ],
2568
+ "type": {
2569
+ "kind": "struct",
2570
+ "fields": [
2571
+ {
2572
+ "name": "pool",
2573
+ "type": "pubkey"
2574
+ },
2575
+ {
2576
+ "name": "authority",
2577
+ "type": "pubkey"
2578
+ },
2579
+ {
2580
+ "name": "max_selloff",
2581
+ "type": {
2582
+ "vec": "u64"
2583
+ }
2584
+ },
2585
+ {
2586
+ "name": "max_selloff_period_length",
2587
+ "type": {
2588
+ "vec": "u32"
2589
+ }
2590
+ },
2591
+ {
2592
+ "name": "timestamp",
2593
+ "type": "i64"
2594
+ }
2595
+ ]
2596
+ }
2597
+ },
2598
+ {
2599
+ "name": "MaxSelloffWindowAdvanced",
2600
+ "docs": [
2601
+ "Emitted from inside `swap` whenever the sliding-window check for",
2602
+ "`token_in_index` runs. Carries effective_selloff (post-update) for",
2603
+ "indexers / monitoring dashboards."
2604
+ ],
2605
+ "type": {
2606
+ "kind": "struct",
2607
+ "fields": [
2608
+ {
2609
+ "name": "pool",
2610
+ "type": "pubkey"
2611
+ },
2612
+ {
2613
+ "name": "token_index",
2614
+ "type": "u8"
2615
+ },
2616
+ {
2617
+ "name": "effective_selloff",
2618
+ "type": "u64"
2619
+ },
2620
+ {
2621
+ "name": "max_selloff",
2622
+ "type": "u64"
2623
+ },
2624
+ {
2625
+ "name": "previous_selloff",
2626
+ "type": "u64"
2627
+ },
2628
+ {
2629
+ "name": "current_selloff",
2630
+ "type": "u64"
2631
+ },
2632
+ {
2633
+ "name": "window_start_timestamp",
2634
+ "type": "i64"
2635
+ },
2636
+ {
2637
+ "name": "timestamp",
2638
+ "type": "i64"
2639
+ }
2640
+ ]
2641
+ }
2642
+ },
1900
2643
  {
1901
2644
  "name": "PoolAdminDisabled",
1902
2645
  "type": {
@@ -1989,6 +2732,55 @@
1989
2732
  ]
1990
2733
  }
1991
2734
  },
2735
+ {
2736
+ "name": "PoolAltInitialized",
2737
+ "docs": [
2738
+ "Emitted by `initialize_pool_alt` once the ALT is created, extended",
2739
+ "with all pool-scoped addresses, and frozen. Off-chain SDK / indexer",
2740
+ "uses this as the signal that v0 transactions are usable for this pool."
2741
+ ],
2742
+ "type": {
2743
+ "kind": "struct",
2744
+ "fields": [
2745
+ {
2746
+ "name": "pool",
2747
+ "docs": [
2748
+ "Pool PDA."
2749
+ ],
2750
+ "type": "pubkey"
2751
+ },
2752
+ {
2753
+ "name": "lookup_table",
2754
+ "docs": [
2755
+ "Address Lookup Table account created."
2756
+ ],
2757
+ "type": "pubkey"
2758
+ },
2759
+ {
2760
+ "name": "authority",
2761
+ "docs": [
2762
+ "Wallet that authored creation (matches `pool.pool_admin` at the",
2763
+ "time of the call). After freeze the ALT has no authority."
2764
+ ],
2765
+ "type": "pubkey"
2766
+ },
2767
+ {
2768
+ "name": "address_count",
2769
+ "docs": [
2770
+ "Number of addresses written into the ALT."
2771
+ ],
2772
+ "type": "u8"
2773
+ },
2774
+ {
2775
+ "name": "timestamp",
2776
+ "docs": [
2777
+ "`Clock::unix_timestamp` at initialisation."
2778
+ ],
2779
+ "type": "i64"
2780
+ }
2781
+ ]
2782
+ }
2783
+ },
1992
2784
  {
1993
2785
  "name": "PoolEnabledUpdated",
1994
2786
  "docs": [
@@ -2154,6 +2946,39 @@
2154
2946
  ]
2155
2947
  }
2156
2948
  },
2949
+ {
2950
+ "name": "PoolMigratedToV4",
2951
+ "docs": [
2952
+ "Emitted by `migrate_pool_v4` after a successful v3 → v4 storage",
2953
+ "reorganization. Off-chain monitors should treat this as the",
2954
+ "\"this specific pool is now safe to interact with at v4\" signal."
2955
+ ],
2956
+ "type": {
2957
+ "kind": "struct",
2958
+ "fields": [
2959
+ {
2960
+ "name": "pool",
2961
+ "type": "pubkey"
2962
+ },
2963
+ {
2964
+ "name": "authority",
2965
+ "type": "pubkey"
2966
+ },
2967
+ {
2968
+ "name": "old_size",
2969
+ "type": "u32"
2970
+ },
2971
+ {
2972
+ "name": "new_size",
2973
+ "type": "u32"
2974
+ },
2975
+ {
2976
+ "name": "timestamp",
2977
+ "type": "i64"
2978
+ }
2979
+ ]
2980
+ }
2981
+ },
2157
2982
  {
2158
2983
  "name": "PoolSolWithdrawn",
2159
2984
  "docs": [
@@ -2393,6 +3218,124 @@
2393
3218
  ]
2394
3219
  }
2395
3220
  },
3221
+ {
3222
+ "name": "RangeManagerConfigSet",
3223
+ "docs": [
3224
+ "Emitted by `set_range_manager_config`. Carries the full effective",
3225
+ "envelope so off-chain indexers don't need to re-fetch the pool."
3226
+ ],
3227
+ "type": {
3228
+ "kind": "struct",
3229
+ "fields": [
3230
+ {
3231
+ "name": "pool",
3232
+ "type": "pubkey"
3233
+ },
3234
+ {
3235
+ "name": "authority",
3236
+ "type": "pubkey"
3237
+ },
3238
+ {
3239
+ "name": "max_vb_change_bps",
3240
+ "type": "u16"
3241
+ },
3242
+ {
3243
+ "name": "max_weight_change_bps",
3244
+ "type": "u16"
3245
+ },
3246
+ {
3247
+ "name": "min_update_interval_secs",
3248
+ "type": "u32"
3249
+ },
3250
+ {
3251
+ "name": "timestamp",
3252
+ "type": "i64"
3253
+ }
3254
+ ]
3255
+ }
3256
+ },
3257
+ {
3258
+ "name": "RangeManagerSet",
3259
+ "docs": [
3260
+ "Emitted by `set_range_manager`. Both the pubkey and the enabled flag",
3261
+ "are bundled into a single event. `new_manager == Pubkey::default()`",
3262
+ "AND `enabled = false` is the \"fully disabled\" state."
3263
+ ],
3264
+ "type": {
3265
+ "kind": "struct",
3266
+ "fields": [
3267
+ {
3268
+ "name": "pool",
3269
+ "type": "pubkey"
3270
+ },
3271
+ {
3272
+ "name": "authority",
3273
+ "type": "pubkey"
3274
+ },
3275
+ {
3276
+ "name": "old_manager",
3277
+ "type": "pubkey"
3278
+ },
3279
+ {
3280
+ "name": "new_manager",
3281
+ "type": "pubkey"
3282
+ },
3283
+ {
3284
+ "name": "enabled",
3285
+ "type": "bool"
3286
+ },
3287
+ {
3288
+ "name": "timestamp",
3289
+ "type": "i64"
3290
+ }
3291
+ ]
3292
+ }
3293
+ },
3294
+ {
3295
+ "name": "RangeManagerUpdated",
3296
+ "docs": [
3297
+ "Emitted by `range_manager_update` after every check passes and state",
3298
+ "is committed. `vb_indices` / `vb_new_values` and `weight_indices` /",
3299
+ "`weight_new_values` are aligned slices (may be empty)."
3300
+ ],
3301
+ "type": {
3302
+ "kind": "struct",
3303
+ "fields": [
3304
+ {
3305
+ "name": "pool",
3306
+ "type": "pubkey"
3307
+ },
3308
+ {
3309
+ "name": "manager",
3310
+ "type": "pubkey"
3311
+ },
3312
+ {
3313
+ "name": "vb_indices",
3314
+ "type": "bytes"
3315
+ },
3316
+ {
3317
+ "name": "vb_new_values",
3318
+ "type": {
3319
+ "vec": "u64"
3320
+ }
3321
+ },
3322
+ {
3323
+ "name": "weight_indices",
3324
+ "type": "bytes"
3325
+ },
3326
+ {
3327
+ "name": "weight_new_values",
3328
+ "type": {
3329
+ "vec": "u64"
3330
+ }
3331
+ },
3332
+ {
3333
+ "name": "timestamp",
3334
+ "type": "i64"
3335
+ }
3336
+ ]
3337
+ }
3338
+ },
2396
3339
  {
2397
3340
  "name": "Swap",
2398
3341
  "docs": [
@@ -2508,6 +3451,50 @@
2508
3451
  }
2509
3452
  ]
2510
3453
  }
3454
+ },
3455
+ {
3456
+ "name": "TokenChange",
3457
+ "docs": [
3458
+ "Single (token_index, new_value) entry. Used by both the",
3459
+ "virtual-balance and weight change lists."
3460
+ ],
3461
+ "type": {
3462
+ "kind": "struct",
3463
+ "fields": [
3464
+ {
3465
+ "name": "index",
3466
+ "type": "u8"
3467
+ },
3468
+ {
3469
+ "name": "new_value",
3470
+ "type": "u64"
3471
+ }
3472
+ ]
3473
+ }
3474
+ },
3475
+ {
3476
+ "name": "TokenSlot",
3477
+ "type": {
3478
+ "kind": "struct",
3479
+ "fields": [
3480
+ {
3481
+ "name": "config",
3482
+ "type": {
3483
+ "defined": {
3484
+ "name": "AssetConfig"
3485
+ }
3486
+ }
3487
+ },
3488
+ {
3489
+ "name": "dynamics",
3490
+ "type": {
3491
+ "defined": {
3492
+ "name": "AssetDynamics"
3493
+ }
3494
+ }
3495
+ }
3496
+ ]
3497
+ }
2511
3498
  }
2512
3499
  ]
2513
3500
  }