@meteora-ag/cp-amm-sdk 1.2.6 → 1.2.8-rc.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.
package/dist/index.js CHANGED
@@ -49,7 +49,7 @@ var cp_amm_default = {
49
49
  address: "cpamdpZCGKUy5JxQXB4dcpGPiikHawvSWAd6mEn1sGG",
50
50
  metadata: {
51
51
  name: "cp_amm",
52
- version: "0.1.5",
52
+ version: "0.1.6",
53
53
  spec: "0.1.0",
54
54
  description: "Created with Anchor"
55
55
  },
@@ -720,19 +720,19 @@ var cp_amm_default = {
720
720
  }
721
721
  },
722
722
  {
723
- name: "claim_fee_operator",
723
+ name: "operator",
724
724
  docs: [
725
725
  "Claim fee operator"
726
726
  ]
727
727
  },
728
728
  {
729
- name: "operator",
729
+ name: "whitelisted_address",
730
730
  docs: [
731
731
  "Operator"
732
732
  ],
733
733
  signer: true,
734
734
  relations: [
735
- "claim_fee_operator"
735
+ "operator"
736
736
  ]
737
737
  },
738
738
  {
@@ -894,29 +894,35 @@ var cp_amm_default = {
894
894
  ]
895
895
  },
896
896
  {
897
- name: "close_claim_fee_operator",
897
+ name: "close_config",
898
898
  discriminator: [
899
- 38,
900
- 134,
901
- 82,
902
- 216,
899
+ 145,
900
+ 9,
901
+ 72,
902
+ 157,
903
903
  95,
904
- 124,
905
- 17,
906
- 99
904
+ 125,
905
+ 61,
906
+ 85
907
907
  ],
908
908
  accounts: [
909
909
  {
910
- name: "claim_fee_operator",
910
+ name: "config",
911
911
  writable: true
912
912
  },
913
913
  {
914
- name: "rent_receiver",
915
- writable: true
914
+ name: "operator"
916
915
  },
917
916
  {
918
- name: "admin",
919
- signer: true
917
+ name: "whitelisted_address",
918
+ signer: true,
919
+ relations: [
920
+ "operator"
921
+ ]
922
+ },
923
+ {
924
+ name: "rent_receiver",
925
+ writable: true
920
926
  },
921
927
  {
922
928
  name: "event_authority",
@@ -954,25 +960,24 @@ var cp_amm_default = {
954
960
  args: []
955
961
  },
956
962
  {
957
- name: "close_config",
963
+ name: "close_operator_account",
958
964
  discriminator: [
959
- 145,
965
+ 171,
960
966
  9,
961
- 72,
962
- 157,
963
- 95,
964
- 125,
965
- 61,
966
- 85
967
+ 213,
968
+ 74,
969
+ 120,
970
+ 23,
971
+ 3,
972
+ 29
967
973
  ],
968
974
  accounts: [
969
975
  {
970
- name: "config",
976
+ name: "operator",
971
977
  writable: true
972
978
  },
973
979
  {
974
980
  name: "admin",
975
- writable: true,
976
981
  signer: true
977
982
  },
978
983
  {
@@ -1127,9 +1132,14 @@ var cp_amm_default = {
1127
1132
  writable: true
1128
1133
  },
1129
1134
  {
1130
- name: "admin",
1131
- writable: true,
1132
- signer: true
1135
+ name: "operator"
1136
+ },
1137
+ {
1138
+ name: "whitelisted_address",
1139
+ signer: true,
1140
+ relations: [
1141
+ "operator"
1142
+ ]
1133
1143
  },
1134
1144
  {
1135
1145
  name: "rent_receiver",
@@ -1171,20 +1181,23 @@ var cp_amm_default = {
1171
1181
  args: []
1172
1182
  },
1173
1183
  {
1174
- name: "create_claim_fee_operator",
1184
+ name: "create_config",
1185
+ docs: [
1186
+ "OPERATOR FUNCTIONS /////"
1187
+ ],
1175
1188
  discriminator: [
1176
- 169,
1177
- 62,
1189
+ 201,
1178
1190
  207,
1179
- 107,
1180
- 58,
1181
- 187,
1182
- 162,
1183
- 109
1191
+ 243,
1192
+ 114,
1193
+ 75,
1194
+ 111,
1195
+ 47,
1196
+ 189
1184
1197
  ],
1185
1198
  accounts: [
1186
1199
  {
1187
- name: "claim_fee_operator",
1200
+ name: "config",
1188
1201
  writable: true,
1189
1202
  pda: {
1190
1203
  seeds: [
@@ -1192,21 +1205,16 @@ var cp_amm_default = {
1192
1205
  kind: "const",
1193
1206
  value: [
1194
1207
  99,
1195
- 102,
1196
- 95,
1197
- 111,
1198
- 112,
1199
- 101,
1200
- 114,
1201
- 97,
1202
- 116,
1203
1208
  111,
1204
- 114
1209
+ 110,
1210
+ 102,
1211
+ 105,
1212
+ 103
1205
1213
  ]
1206
1214
  },
1207
1215
  {
1208
- kind: "account",
1209
- path: "operator"
1216
+ kind: "arg",
1217
+ path: "index"
1210
1218
  }
1211
1219
  ]
1212
1220
  }
@@ -1215,7 +1223,14 @@ var cp_amm_default = {
1215
1223
  name: "operator"
1216
1224
  },
1217
1225
  {
1218
- name: "admin",
1226
+ name: "whitelisted_address",
1227
+ signer: true,
1228
+ relations: [
1229
+ "operator"
1230
+ ]
1231
+ },
1232
+ {
1233
+ name: "payer",
1219
1234
  writable: true,
1220
1235
  signer: true
1221
1236
  },
@@ -1256,22 +1271,32 @@ var cp_amm_default = {
1256
1271
  name: "program"
1257
1272
  }
1258
1273
  ],
1259
- args: []
1274
+ args: [
1275
+ {
1276
+ name: "index",
1277
+ type: "u64"
1278
+ },
1279
+ {
1280
+ name: "config_parameters",
1281
+ type: {
1282
+ defined: {
1283
+ name: "StaticConfigParameters"
1284
+ }
1285
+ }
1286
+ }
1287
+ ]
1260
1288
  },
1261
1289
  {
1262
- name: "create_config",
1263
- docs: [
1264
- "ADMIN FUNCTIONS /////"
1265
- ],
1290
+ name: "create_dynamic_config",
1266
1291
  discriminator: [
1267
- 201,
1268
- 207,
1269
- 243,
1270
- 114,
1271
- 75,
1272
- 111,
1273
- 47,
1274
- 189
1292
+ 81,
1293
+ 251,
1294
+ 122,
1295
+ 78,
1296
+ 66,
1297
+ 57,
1298
+ 208,
1299
+ 82
1275
1300
  ],
1276
1301
  accounts: [
1277
1302
  {
@@ -1298,7 +1323,17 @@ var cp_amm_default = {
1298
1323
  }
1299
1324
  },
1300
1325
  {
1301
- name: "admin",
1326
+ name: "operator"
1327
+ },
1328
+ {
1329
+ name: "whitelisted_address",
1330
+ signer: true,
1331
+ relations: [
1332
+ "operator"
1333
+ ]
1334
+ },
1335
+ {
1336
+ name: "payer",
1302
1337
  writable: true,
1303
1338
  signer: true
1304
1339
  },
@@ -1348,50 +1383,62 @@ var cp_amm_default = {
1348
1383
  name: "config_parameters",
1349
1384
  type: {
1350
1385
  defined: {
1351
- name: "StaticConfigParameters"
1386
+ name: "DynamicConfigParameters"
1352
1387
  }
1353
1388
  }
1354
1389
  }
1355
1390
  ]
1356
1391
  },
1357
1392
  {
1358
- name: "create_dynamic_config",
1393
+ name: "create_operator_account",
1394
+ docs: [
1395
+ "ADMIN FUNCTIONS /////"
1396
+ ],
1359
1397
  discriminator: [
1360
- 81,
1361
- 251,
1362
- 122,
1363
- 78,
1364
- 66,
1365
- 57,
1366
- 208,
1367
- 82
1398
+ 221,
1399
+ 64,
1400
+ 246,
1401
+ 149,
1402
+ 240,
1403
+ 153,
1404
+ 229,
1405
+ 163
1368
1406
  ],
1369
1407
  accounts: [
1370
1408
  {
1371
- name: "config",
1409
+ name: "operator",
1372
1410
  writable: true,
1373
1411
  pda: {
1374
1412
  seeds: [
1375
1413
  {
1376
1414
  kind: "const",
1377
1415
  value: [
1378
- 99,
1379
1416
  111,
1380
- 110,
1381
- 102,
1382
- 105,
1383
- 103
1417
+ 112,
1418
+ 101,
1419
+ 114,
1420
+ 97,
1421
+ 116,
1422
+ 111,
1423
+ 114
1384
1424
  ]
1385
1425
  },
1386
1426
  {
1387
- kind: "arg",
1388
- path: "index"
1427
+ kind: "account",
1428
+ path: "whitelisted_address"
1389
1429
  }
1390
1430
  ]
1391
1431
  }
1392
1432
  },
1433
+ {
1434
+ name: "whitelisted_address"
1435
+ },
1393
1436
  {
1394
1437
  name: "admin",
1438
+ signer: true
1439
+ },
1440
+ {
1441
+ name: "payer",
1395
1442
  writable: true,
1396
1443
  signer: true
1397
1444
  },
@@ -1434,16 +1481,8 @@ var cp_amm_default = {
1434
1481
  ],
1435
1482
  args: [
1436
1483
  {
1437
- name: "index",
1438
- type: "u64"
1439
- },
1440
- {
1441
- name: "config_parameters",
1442
- type: {
1443
- defined: {
1444
- name: "DynamicConfigParameters"
1445
- }
1446
- }
1484
+ name: "permission",
1485
+ type: "u128"
1447
1486
  }
1448
1487
  ]
1449
1488
  },
@@ -1643,7 +1682,17 @@ var cp_amm_default = {
1643
1682
  name: "token_mint"
1644
1683
  },
1645
1684
  {
1646
- name: "admin",
1685
+ name: "operator"
1686
+ },
1687
+ {
1688
+ name: "whitelisted_address",
1689
+ signer: true,
1690
+ relations: [
1691
+ "operator"
1692
+ ]
1693
+ },
1694
+ {
1695
+ name: "payer",
1647
1696
  writable: true,
1648
1697
  signer: true
1649
1698
  },
@@ -1686,6 +1735,40 @@ var cp_amm_default = {
1686
1735
  ],
1687
1736
  args: []
1688
1737
  },
1738
+ {
1739
+ name: "dummy_ix",
1740
+ discriminator: [
1741
+ 234,
1742
+ 95,
1743
+ 176,
1744
+ 185,
1745
+ 7,
1746
+ 42,
1747
+ 35,
1748
+ 159
1749
+ ],
1750
+ accounts: [
1751
+ {
1752
+ name: "pod_aligned_fee_time_scheduler"
1753
+ },
1754
+ {
1755
+ name: "pod_aligned_fee_rate_limiter"
1756
+ },
1757
+ {
1758
+ name: "pod_aligned_fee_market_cap_scheduler"
1759
+ }
1760
+ ],
1761
+ args: [
1762
+ {
1763
+ name: "_ixs",
1764
+ type: {
1765
+ defined: {
1766
+ name: "DummyParams"
1767
+ }
1768
+ }
1769
+ }
1770
+ ]
1771
+ },
1689
1772
  {
1690
1773
  name: "fund_reward",
1691
1774
  discriminator: [
@@ -3247,8 +3330,14 @@ var cp_amm_default = {
3247
3330
  writable: true
3248
3331
  },
3249
3332
  {
3250
- name: "admin",
3251
- signer: true
3333
+ name: "operator"
3334
+ },
3335
+ {
3336
+ name: "whitelisted_address",
3337
+ signer: true,
3338
+ relations: [
3339
+ "operator"
3340
+ ]
3252
3341
  },
3253
3342
  {
3254
3343
  name: "event_authority",
@@ -3628,7 +3717,7 @@ var cp_amm_default = {
3628
3717
  ],
3629
3718
  args: [
3630
3719
  {
3631
- name: "params",
3720
+ name: "_params",
3632
3721
  type: {
3633
3722
  defined: {
3634
3723
  name: "SwapParameters"
@@ -3769,7 +3858,7 @@ var cp_amm_default = {
3769
3858
  ],
3770
3859
  args: [
3771
3860
  {
3772
- name: "params",
3861
+ name: "_params",
3773
3862
  type: {
3774
3863
  defined: {
3775
3864
  name: "SwapParameters2"
@@ -3779,16 +3868,16 @@ var cp_amm_default = {
3779
3868
  ]
3780
3869
  },
3781
3870
  {
3782
- name: "update_reward_duration",
3871
+ name: "update_pool_fees",
3783
3872
  discriminator: [
3784
- 138,
3785
- 174,
3786
- 196,
3787
- 169,
3788
- 213,
3789
- 235,
3790
- 254,
3791
- 107
3873
+ 118,
3874
+ 217,
3875
+ 203,
3876
+ 179,
3877
+ 60,
3878
+ 8,
3879
+ 70,
3880
+ 89
3792
3881
  ],
3793
3882
  accounts: [
3794
3883
  {
@@ -3796,13 +3885,84 @@ var cp_amm_default = {
3796
3885
  writable: true
3797
3886
  },
3798
3887
  {
3799
- name: "signer",
3800
- signer: true
3888
+ name: "operator"
3801
3889
  },
3802
3890
  {
3803
- name: "event_authority",
3804
- pda: {
3805
- seeds: [
3891
+ name: "whitelisted_address",
3892
+ signer: true,
3893
+ relations: [
3894
+ "operator"
3895
+ ]
3896
+ },
3897
+ {
3898
+ name: "event_authority",
3899
+ pda: {
3900
+ seeds: [
3901
+ {
3902
+ kind: "const",
3903
+ value: [
3904
+ 95,
3905
+ 95,
3906
+ 101,
3907
+ 118,
3908
+ 101,
3909
+ 110,
3910
+ 116,
3911
+ 95,
3912
+ 97,
3913
+ 117,
3914
+ 116,
3915
+ 104,
3916
+ 111,
3917
+ 114,
3918
+ 105,
3919
+ 116,
3920
+ 121
3921
+ ]
3922
+ }
3923
+ ]
3924
+ }
3925
+ },
3926
+ {
3927
+ name: "program"
3928
+ }
3929
+ ],
3930
+ args: [
3931
+ {
3932
+ name: "params",
3933
+ type: {
3934
+ defined: {
3935
+ name: "UpdatePoolFeesParameters"
3936
+ }
3937
+ }
3938
+ }
3939
+ ]
3940
+ },
3941
+ {
3942
+ name: "update_reward_duration",
3943
+ discriminator: [
3944
+ 138,
3945
+ 174,
3946
+ 196,
3947
+ 169,
3948
+ 213,
3949
+ 235,
3950
+ 254,
3951
+ 107
3952
+ ],
3953
+ accounts: [
3954
+ {
3955
+ name: "pool",
3956
+ writable: true
3957
+ },
3958
+ {
3959
+ name: "signer",
3960
+ signer: true
3961
+ },
3962
+ {
3963
+ name: "event_authority",
3964
+ pda: {
3965
+ seeds: [
3806
3966
  {
3807
3967
  kind: "const",
3808
3968
  value: [
@@ -3989,19 +4149,6 @@ var cp_amm_default = {
3989
4149
  }
3990
4150
  ],
3991
4151
  accounts: [
3992
- {
3993
- name: "ClaimFeeOperator",
3994
- discriminator: [
3995
- 166,
3996
- 48,
3997
- 134,
3998
- 86,
3999
- 34,
4000
- 200,
4001
- 188,
4002
- 150
4003
- ]
4004
- },
4005
4152
  {
4006
4153
  name: "Config",
4007
4154
  discriminator: [
@@ -4015,6 +4162,58 @@ var cp_amm_default = {
4015
4162
  130
4016
4163
  ]
4017
4164
  },
4165
+ {
4166
+ name: "Operator",
4167
+ discriminator: [
4168
+ 219,
4169
+ 31,
4170
+ 188,
4171
+ 145,
4172
+ 69,
4173
+ 139,
4174
+ 204,
4175
+ 117
4176
+ ]
4177
+ },
4178
+ {
4179
+ name: "PodAlignedFeeMarketCapScheduler",
4180
+ discriminator: [
4181
+ 251,
4182
+ 130,
4183
+ 208,
4184
+ 253,
4185
+ 245,
4186
+ 27,
4187
+ 145,
4188
+ 203
4189
+ ]
4190
+ },
4191
+ {
4192
+ name: "PodAlignedFeeRateLimiter",
4193
+ discriminator: [
4194
+ 160,
4195
+ 219,
4196
+ 8,
4197
+ 251,
4198
+ 179,
4199
+ 7,
4200
+ 16,
4201
+ 117
4202
+ ]
4203
+ },
4204
+ {
4205
+ name: "PodAlignedFeeTimeScheduler",
4206
+ discriminator: [
4207
+ 239,
4208
+ 132,
4209
+ 138,
4210
+ 213,
4211
+ 67,
4212
+ 154,
4213
+ 130,
4214
+ 70
4215
+ ]
4216
+ },
4018
4217
  {
4019
4218
  name: "Pool",
4020
4219
  discriminator: [
@@ -4069,19 +4268,6 @@ var cp_amm_default = {
4069
4268
  }
4070
4269
  ],
4071
4270
  events: [
4072
- {
4073
- name: "EvtAddLiquidity",
4074
- discriminator: [
4075
- 175,
4076
- 242,
4077
- 8,
4078
- 157,
4079
- 30,
4080
- 247,
4081
- 185,
4082
- 169
4083
- ]
4084
- },
4085
4271
  {
4086
4272
  name: "EvtClaimPartnerFee",
4087
4273
  discriminator: [
@@ -4134,19 +4320,6 @@ var cp_amm_default = {
4134
4320
  231
4135
4321
  ]
4136
4322
  },
4137
- {
4138
- name: "EvtCloseClaimFeeOperator",
4139
- discriminator: [
4140
- 111,
4141
- 39,
4142
- 37,
4143
- 55,
4144
- 110,
4145
- 216,
4146
- 194,
4147
- 23
4148
- ]
4149
- },
4150
4323
  {
4151
4324
  name: "EvtCloseConfig",
4152
4325
  discriminator: [
@@ -4173,19 +4346,6 @@ var cp_amm_default = {
4173
4346
  178
4174
4347
  ]
4175
4348
  },
4176
- {
4177
- name: "EvtCreateClaimFeeOperator",
4178
- discriminator: [
4179
- 21,
4180
- 6,
4181
- 153,
4182
- 120,
4183
- 68,
4184
- 116,
4185
- 28,
4186
- 177
4187
- ]
4188
- },
4189
4349
  {
4190
4350
  name: "EvtCreateConfig",
4191
4351
  discriminator: [
@@ -4316,19 +4476,6 @@ var cp_amm_default = {
4316
4476
  11
4317
4477
  ]
4318
4478
  },
4319
- {
4320
- name: "EvtRemoveLiquidity",
4321
- discriminator: [
4322
- 87,
4323
- 46,
4324
- 88,
4325
- 98,
4326
- 175,
4327
- 96,
4328
- 34,
4329
- 91
4330
- ]
4331
- },
4332
4479
  {
4333
4480
  name: "EvtSetPoolStatus",
4334
4481
  discriminator: [
@@ -4355,19 +4502,6 @@ var cp_amm_default = {
4355
4502
  103
4356
4503
  ]
4357
4504
  },
4358
- {
4359
- name: "EvtSwap",
4360
- discriminator: [
4361
- 27,
4362
- 60,
4363
- 21,
4364
- 213,
4365
- 138,
4366
- 170,
4367
- 187,
4368
- 147
4369
- ]
4370
- },
4371
4505
  {
4372
4506
  name: "EvtSwap2",
4373
4507
  discriminator: [
@@ -4381,6 +4515,19 @@ var cp_amm_default = {
4381
4515
  153
4382
4516
  ]
4383
4517
  },
4518
+ {
4519
+ name: "EvtUpdatePoolFees",
4520
+ discriminator: [
4521
+ 76,
4522
+ 165,
4523
+ 246,
4524
+ 102,
4525
+ 102,
4526
+ 217,
4527
+ 156,
4528
+ 44
4529
+ ]
4530
+ },
4384
4531
  {
4385
4532
  name: "EvtUpdateRewardDuration",
4386
4533
  discriminator: [
@@ -4674,7 +4821,7 @@ var cp_amm_default = {
4674
4821
  },
4675
4822
  {
4676
4823
  code: 6050,
4677
- name: "InvalidFeeScheduler",
4824
+ name: "InvalidFeeTimeScheduler",
4678
4825
  msg: "Invalid fee scheduler"
4679
4826
  },
4680
4827
  {
@@ -4686,6 +4833,41 @@ var cp_amm_default = {
4686
4833
  code: 6052,
4687
4834
  name: "InvalidPoolVersion",
4688
4835
  msg: "Invalid pool version"
4836
+ },
4837
+ {
4838
+ code: 6053,
4839
+ name: "InvalidAuthority",
4840
+ msg: "Invalid authority to do that action"
4841
+ },
4842
+ {
4843
+ code: 6054,
4844
+ name: "InvalidPermission",
4845
+ msg: "Invalid permission"
4846
+ },
4847
+ {
4848
+ code: 6055,
4849
+ name: "InvalidFeeMarketCapScheduler",
4850
+ msg: "Invalid fee market cap scheduler"
4851
+ },
4852
+ {
4853
+ code: 6056,
4854
+ name: "CannotUpdateBaseFee",
4855
+ msg: "Cannot update base fee"
4856
+ },
4857
+ {
4858
+ code: 6057,
4859
+ name: "InvalidDynamicFeeParameters",
4860
+ msg: "Invalid dynamic fee parameters"
4861
+ },
4862
+ {
4863
+ code: 6058,
4864
+ name: "InvalidUpdatePoolFeesParameters",
4865
+ msg: "Invalid update pool fees parameters"
4866
+ },
4867
+ {
4868
+ code: 6059,
4869
+ name: "MissingOperatorAccount",
4870
+ msg: "Missing operator account"
4689
4871
  }
4690
4872
  ],
4691
4873
  types: [
@@ -4719,7 +4901,7 @@ var cp_amm_default = {
4719
4901
  }
4720
4902
  },
4721
4903
  {
4722
- name: "BaseFeeConfig",
4904
+ name: "BaseFeeInfo",
4723
4905
  serialization: "bytemuck",
4724
4906
  repr: {
4725
4907
  kind: "c"
@@ -4728,44 +4910,60 @@ var cp_amm_default = {
4728
4910
  kind: "struct",
4729
4911
  fields: [
4730
4912
  {
4731
- name: "cliff_fee_numerator",
4732
- type: "u64"
4733
- },
4734
- {
4735
- name: "base_fee_mode",
4736
- type: "u8"
4737
- },
4738
- {
4739
- name: "padding",
4913
+ name: "data",
4740
4914
  type: {
4741
4915
  array: [
4742
4916
  "u8",
4743
- 5
4917
+ 32
4744
4918
  ]
4745
4919
  }
4746
- },
4747
- {
4748
- name: "first_factor",
4749
- type: "u16"
4750
- },
4920
+ }
4921
+ ]
4922
+ }
4923
+ },
4924
+ {
4925
+ name: "BaseFeeParameters",
4926
+ type: {
4927
+ kind: "struct",
4928
+ fields: [
4751
4929
  {
4752
- name: "second_factor",
4930
+ name: "data",
4753
4931
  type: {
4754
4932
  array: [
4755
4933
  "u8",
4756
- 8
4934
+ 30
4757
4935
  ]
4758
4936
  }
4937
+ }
4938
+ ]
4939
+ }
4940
+ },
4941
+ {
4942
+ name: "BaseFeeStruct",
4943
+ serialization: "bytemuck",
4944
+ repr: {
4945
+ kind: "c"
4946
+ },
4947
+ type: {
4948
+ kind: "struct",
4949
+ fields: [
4950
+ {
4951
+ name: "base_fee_info",
4952
+ type: {
4953
+ defined: {
4954
+ name: "BaseFeeInfo"
4955
+ }
4956
+ }
4759
4957
  },
4760
4958
  {
4761
- name: "third_factor",
4959
+ name: "padding_1",
4762
4960
  type: "u64"
4763
4961
  }
4764
4962
  ]
4765
4963
  }
4766
4964
  },
4767
4965
  {
4768
- name: "BaseFeeParameters",
4966
+ name: "BorshFeeMarketCapScheduler",
4769
4967
  type: {
4770
4968
  kind: "struct",
4771
4969
  fields: [
@@ -4774,35 +4972,52 @@ var cp_amm_default = {
4774
4972
  type: "u64"
4775
4973
  },
4776
4974
  {
4777
- name: "first_factor",
4975
+ name: "number_of_period",
4778
4976
  type: "u16"
4779
4977
  },
4780
4978
  {
4781
- name: "second_factor",
4782
- type: {
4783
- array: [
4784
- "u8",
4785
- 8
4786
- ]
4787
- }
4979
+ name: "sqrt_price_step_bps",
4980
+ type: "u32"
4788
4981
  },
4789
4982
  {
4790
- name: "third_factor",
4983
+ name: "scheduler_expiration_duration",
4984
+ type: "u32"
4985
+ },
4986
+ {
4987
+ name: "reduction_factor",
4791
4988
  type: "u64"
4792
4989
  },
4793
4990
  {
4794
4991
  name: "base_fee_mode",
4795
4992
  type: "u8"
4993
+ },
4994
+ {
4995
+ name: "padding",
4996
+ type: {
4997
+ array: [
4998
+ "u8",
4999
+ 3
5000
+ ]
5001
+ }
4796
5002
  }
4797
5003
  ]
4798
5004
  }
4799
5005
  },
4800
5006
  {
4801
- name: "BaseFeeStruct",
4802
- serialization: "bytemuck",
4803
- repr: {
4804
- kind: "c"
4805
- },
5007
+ name: "BorshFeeRateLimiter",
5008
+ docs: [
5009
+ "we denote reference_amount = x0, cliff_fee_numerator = c, fee_increment = i",
5010
+ "if input_amount <= x0, then fee = input_amount * c",
5011
+ "",
5012
+ "if input_amount > x0, then input_amount = x0 + (a * x0 + b)",
5013
+ "if a < max_index",
5014
+ "then fee = x0 * c + x0 * (c + i) + .... + x0 * (c + i*a) + b * (c + i * (a+1))",
5015
+ "then fee = x0 * (c + c*a + i*a*(a+1)/2) + b * (c + i * (a+1))",
5016
+ "",
5017
+ "if a >= max_index",
5018
+ "if a = max_index + d, input_amount = x0 + max_index * x0 + (d * x0 + b)",
5019
+ "then fee = x0 * (c + c*max_index + i*max_index*(max_index+1)/2) + (d * x0 + b) * MAX_FEE"
5020
+ ],
4806
5021
  type: {
4807
5022
  kind: "struct",
4808
5023
  fields: [
@@ -4811,70 +5026,68 @@ var cp_amm_default = {
4811
5026
  type: "u64"
4812
5027
  },
4813
5028
  {
4814
- name: "base_fee_mode",
4815
- type: "u8"
5029
+ name: "fee_increment_bps",
5030
+ type: "u16"
4816
5031
  },
4817
5032
  {
4818
- name: "padding_0",
4819
- type: {
4820
- array: [
4821
- "u8",
4822
- 5
4823
- ]
4824
- }
5033
+ name: "max_limiter_duration",
5034
+ type: "u32"
4825
5035
  },
4826
5036
  {
4827
- name: "first_factor",
4828
- type: "u16"
5037
+ name: "max_fee_bps",
5038
+ type: "u32"
5039
+ },
5040
+ {
5041
+ name: "reference_amount",
5042
+ type: "u64"
5043
+ },
5044
+ {
5045
+ name: "base_fee_mode",
5046
+ type: "u8"
4829
5047
  },
4830
5048
  {
4831
- name: "second_factor",
5049
+ name: "padding",
4832
5050
  type: {
4833
5051
  array: [
4834
5052
  "u8",
4835
- 8
5053
+ 3
4836
5054
  ]
4837
5055
  }
4838
- },
4839
- {
4840
- name: "third_factor",
4841
- type: "u64"
4842
- },
4843
- {
4844
- name: "padding_1",
4845
- type: "u64"
4846
5056
  }
4847
5057
  ]
4848
5058
  }
4849
5059
  },
4850
5060
  {
4851
- name: "ClaimFeeOperator",
4852
- docs: [
4853
- "Parameter that set by the protocol"
4854
- ],
4855
- serialization: "bytemuck",
4856
- repr: {
4857
- kind: "c"
4858
- },
5061
+ name: "BorshFeeTimeScheduler",
4859
5062
  type: {
4860
5063
  kind: "struct",
4861
5064
  fields: [
4862
5065
  {
4863
- name: "operator",
4864
- docs: [
4865
- "operator"
4866
- ],
4867
- type: "pubkey"
5066
+ name: "cliff_fee_numerator",
5067
+ type: "u64"
4868
5068
  },
4869
5069
  {
4870
- name: "_padding",
4871
- docs: [
4872
- "Reserve"
4873
- ],
5070
+ name: "number_of_period",
5071
+ type: "u16"
5072
+ },
5073
+ {
5074
+ name: "period_frequency",
5075
+ type: "u64"
5076
+ },
5077
+ {
5078
+ name: "reduction_factor",
5079
+ type: "u64"
5080
+ },
5081
+ {
5082
+ name: "base_fee_mode",
5083
+ type: "u8"
5084
+ },
5085
+ {
5086
+ name: "padding",
4874
5087
  type: {
4875
5088
  array: [
4876
5089
  "u8",
4877
- 128
5090
+ 3
4878
5091
  ]
4879
5092
  }
4880
5093
  }
@@ -4985,6 +5198,38 @@ var cp_amm_default = {
4985
5198
  ]
4986
5199
  }
4987
5200
  },
5201
+ {
5202
+ name: "DummyParams",
5203
+ type: {
5204
+ kind: "struct",
5205
+ fields: [
5206
+ {
5207
+ name: "borsh_fee_time_scheduler_params",
5208
+ type: {
5209
+ defined: {
5210
+ name: "BorshFeeTimeScheduler"
5211
+ }
5212
+ }
5213
+ },
5214
+ {
5215
+ name: "borsh_fee_rate_limiter_params",
5216
+ type: {
5217
+ defined: {
5218
+ name: "BorshFeeRateLimiter"
5219
+ }
5220
+ }
5221
+ },
5222
+ {
5223
+ name: "borsh_fee_market_cap_scheduler_params",
5224
+ type: {
5225
+ defined: {
5226
+ name: "BorshFeeMarketCapScheduler"
5227
+ }
5228
+ }
5229
+ }
5230
+ ]
5231
+ }
5232
+ },
4988
5233
  {
4989
5234
  name: "DynamicConfigParameters",
4990
5235
  type: {
@@ -5164,50 +5409,6 @@ var cp_amm_default = {
5164
5409
  ]
5165
5410
  }
5166
5411
  },
5167
- {
5168
- name: "EvtAddLiquidity",
5169
- type: {
5170
- kind: "struct",
5171
- fields: [
5172
- {
5173
- name: "pool",
5174
- type: "pubkey"
5175
- },
5176
- {
5177
- name: "position",
5178
- type: "pubkey"
5179
- },
5180
- {
5181
- name: "owner",
5182
- type: "pubkey"
5183
- },
5184
- {
5185
- name: "params",
5186
- type: {
5187
- defined: {
5188
- name: "AddLiquidityParameters"
5189
- }
5190
- }
5191
- },
5192
- {
5193
- name: "token_a_amount",
5194
- type: "u64"
5195
- },
5196
- {
5197
- name: "token_b_amount",
5198
- type: "u64"
5199
- },
5200
- {
5201
- name: "total_amount_a",
5202
- type: "u64"
5203
- },
5204
- {
5205
- name: "total_amount_b",
5206
- type: "u64"
5207
- }
5208
- ]
5209
- }
5210
- },
5211
5412
  {
5212
5413
  name: "EvtClaimPartnerFee",
5213
5414
  type: {
@@ -5308,25 +5509,6 @@ var cp_amm_default = {
5308
5509
  ]
5309
5510
  }
5310
5511
  },
5311
- {
5312
- name: "EvtCloseClaimFeeOperator",
5313
- docs: [
5314
- "Close claim fee operator"
5315
- ],
5316
- type: {
5317
- kind: "struct",
5318
- fields: [
5319
- {
5320
- name: "claim_fee_operator",
5321
- type: "pubkey"
5322
- },
5323
- {
5324
- name: "operator",
5325
- type: "pubkey"
5326
- }
5327
- ]
5328
- }
5329
- },
5330
5512
  {
5331
5513
  name: "EvtCloseConfig",
5332
5514
  docs: [
@@ -5376,21 +5558,6 @@ var cp_amm_default = {
5376
5558
  ]
5377
5559
  }
5378
5560
  },
5379
- {
5380
- name: "EvtCreateClaimFeeOperator",
5381
- docs: [
5382
- "Create claim fee operator"
5383
- ],
5384
- type: {
5385
- kind: "struct",
5386
- fields: [
5387
- {
5388
- name: "operator",
5389
- type: "pubkey"
5390
- }
5391
- ]
5392
- }
5393
- },
5394
5561
  {
5395
5562
  name: "EvtCreateConfig",
5396
5563
  docs: [
@@ -5804,42 +5971,6 @@ var cp_amm_default = {
5804
5971
  ]
5805
5972
  }
5806
5973
  },
5807
- {
5808
- name: "EvtRemoveLiquidity",
5809
- type: {
5810
- kind: "struct",
5811
- fields: [
5812
- {
5813
- name: "pool",
5814
- type: "pubkey"
5815
- },
5816
- {
5817
- name: "position",
5818
- type: "pubkey"
5819
- },
5820
- {
5821
- name: "owner",
5822
- type: "pubkey"
5823
- },
5824
- {
5825
- name: "params",
5826
- type: {
5827
- defined: {
5828
- name: "RemoveLiquidityParameters"
5829
- }
5830
- }
5831
- },
5832
- {
5833
- name: "token_a_amount",
5834
- type: "u64"
5835
- },
5836
- {
5837
- name: "token_b_amount",
5838
- type: "u64"
5839
- }
5840
- ]
5841
- }
5842
- },
5843
5974
  {
5844
5975
  name: "EvtSetPoolStatus",
5845
5976
  type: {
@@ -5897,69 +6028,25 @@ var cp_amm_default = {
5897
6028
  name: "first_position_info",
5898
6029
  type: {
5899
6030
  defined: {
5900
- name: "SplitPositionInfo"
5901
- }
5902
- }
5903
- },
5904
- {
5905
- name: "second_position_info",
5906
- type: {
5907
- defined: {
5908
- name: "SplitPositionInfo"
5909
- }
5910
- }
5911
- },
5912
- {
5913
- name: "split_position_parameters",
5914
- type: {
5915
- defined: {
5916
- name: "SplitPositionParameters2"
5917
- }
5918
- }
5919
- }
5920
- ]
5921
- }
5922
- },
5923
- {
5924
- name: "EvtSwap",
5925
- type: {
5926
- kind: "struct",
5927
- fields: [
5928
- {
5929
- name: "pool",
5930
- type: "pubkey"
5931
- },
5932
- {
5933
- name: "trade_direction",
5934
- type: "u8"
5935
- },
5936
- {
5937
- name: "has_referral",
5938
- type: "bool"
5939
- },
5940
- {
5941
- name: "params",
5942
- type: {
5943
- defined: {
5944
- name: "SwapParameters"
6031
+ name: "SplitPositionInfo"
5945
6032
  }
5946
6033
  }
5947
6034
  },
5948
6035
  {
5949
- name: "swap_result",
6036
+ name: "second_position_info",
5950
6037
  type: {
5951
6038
  defined: {
5952
- name: "SwapResult"
6039
+ name: "SplitPositionInfo"
5953
6040
  }
5954
6041
  }
5955
6042
  },
5956
6043
  {
5957
- name: "actual_amount_in",
5958
- type: "u64"
5959
- },
5960
- {
5961
- name: "current_timestamp",
5962
- type: "u64"
6044
+ name: "split_position_parameters",
6045
+ type: {
6046
+ defined: {
6047
+ name: "SplitPositionParameters2"
6048
+ }
6049
+ }
5963
6050
  }
5964
6051
  ]
5965
6052
  }
@@ -6028,6 +6115,30 @@ var cp_amm_default = {
6028
6115
  ]
6029
6116
  }
6030
6117
  },
6118
+ {
6119
+ name: "EvtUpdatePoolFees",
6120
+ type: {
6121
+ kind: "struct",
6122
+ fields: [
6123
+ {
6124
+ name: "pool",
6125
+ type: "pubkey"
6126
+ },
6127
+ {
6128
+ name: "operator",
6129
+ type: "pubkey"
6130
+ },
6131
+ {
6132
+ name: "params",
6133
+ type: {
6134
+ defined: {
6135
+ name: "UpdatePoolFeesParameters"
6136
+ }
6137
+ }
6138
+ }
6139
+ ]
6140
+ }
6141
+ },
6031
6142
  {
6032
6143
  name: "EvtUpdateRewardDuration",
6033
6144
  type: {
@@ -6143,7 +6254,7 @@ var cp_amm_default = {
6143
6254
  {
6144
6255
  name: "sqrt_price",
6145
6256
  docs: [
6146
- "The init price of the pool as a sqrt(token_b/token_a) Q64.64 value"
6257
+ "The init price of the pool as a sqrt(token_b/token_a) Q64.64 value. Market cap fee scheduler minimum price will be derived from this value"
6147
6258
  ],
6148
6259
  type: "u128"
6149
6260
  },
@@ -6204,6 +6315,166 @@ var cp_amm_default = {
6204
6315
  ]
6205
6316
  }
6206
6317
  },
6318
+ {
6319
+ name: "Operator",
6320
+ serialization: "bytemuck",
6321
+ repr: {
6322
+ kind: "c"
6323
+ },
6324
+ type: {
6325
+ kind: "struct",
6326
+ fields: [
6327
+ {
6328
+ name: "whitelisted_address",
6329
+ type: "pubkey"
6330
+ },
6331
+ {
6332
+ name: "permission",
6333
+ type: "u128"
6334
+ },
6335
+ {
6336
+ name: "padding",
6337
+ type: {
6338
+ array: [
6339
+ "u64",
6340
+ 2
6341
+ ]
6342
+ }
6343
+ }
6344
+ ]
6345
+ }
6346
+ },
6347
+ {
6348
+ name: "PodAlignedFeeMarketCapScheduler",
6349
+ serialization: "bytemuck",
6350
+ repr: {
6351
+ kind: "c"
6352
+ },
6353
+ type: {
6354
+ kind: "struct",
6355
+ fields: [
6356
+ {
6357
+ name: "cliff_fee_numerator",
6358
+ type: "u64"
6359
+ },
6360
+ {
6361
+ name: "base_fee_mode",
6362
+ type: "u8"
6363
+ },
6364
+ {
6365
+ name: "padding",
6366
+ type: {
6367
+ array: [
6368
+ "u8",
6369
+ 5
6370
+ ]
6371
+ }
6372
+ },
6373
+ {
6374
+ name: "number_of_period",
6375
+ type: "u16"
6376
+ },
6377
+ {
6378
+ name: "sqrt_price_step_bps",
6379
+ type: "u32"
6380
+ },
6381
+ {
6382
+ name: "scheduler_expiration_duration",
6383
+ type: "u32"
6384
+ },
6385
+ {
6386
+ name: "reduction_factor",
6387
+ type: "u64"
6388
+ }
6389
+ ]
6390
+ }
6391
+ },
6392
+ {
6393
+ name: "PodAlignedFeeRateLimiter",
6394
+ serialization: "bytemuck",
6395
+ repr: {
6396
+ kind: "c"
6397
+ },
6398
+ type: {
6399
+ kind: "struct",
6400
+ fields: [
6401
+ {
6402
+ name: "cliff_fee_numerator",
6403
+ type: "u64"
6404
+ },
6405
+ {
6406
+ name: "base_fee_mode",
6407
+ type: "u8"
6408
+ },
6409
+ {
6410
+ name: "padding",
6411
+ type: {
6412
+ array: [
6413
+ "u8",
6414
+ 5
6415
+ ]
6416
+ }
6417
+ },
6418
+ {
6419
+ name: "fee_increment_bps",
6420
+ type: "u16"
6421
+ },
6422
+ {
6423
+ name: "max_limiter_duration",
6424
+ type: "u32"
6425
+ },
6426
+ {
6427
+ name: "max_fee_bps",
6428
+ type: "u32"
6429
+ },
6430
+ {
6431
+ name: "reference_amount",
6432
+ type: "u64"
6433
+ }
6434
+ ]
6435
+ }
6436
+ },
6437
+ {
6438
+ name: "PodAlignedFeeTimeScheduler",
6439
+ serialization: "bytemuck",
6440
+ repr: {
6441
+ kind: "c"
6442
+ },
6443
+ type: {
6444
+ kind: "struct",
6445
+ fields: [
6446
+ {
6447
+ name: "cliff_fee_numerator",
6448
+ type: "u64"
6449
+ },
6450
+ {
6451
+ name: "base_fee_mode",
6452
+ type: "u8"
6453
+ },
6454
+ {
6455
+ name: "padding",
6456
+ type: {
6457
+ array: [
6458
+ "u8",
6459
+ 5
6460
+ ]
6461
+ }
6462
+ },
6463
+ {
6464
+ name: "number_of_period",
6465
+ type: "u16"
6466
+ },
6467
+ {
6468
+ name: "period_frequency",
6469
+ type: "u64"
6470
+ },
6471
+ {
6472
+ name: "reduction_factor",
6473
+ type: "u64"
6474
+ }
6475
+ ]
6476
+ }
6477
+ },
6207
6478
  {
6208
6479
  name: "Pool",
6209
6480
  serialization: "bytemuck",
@@ -6367,7 +6638,7 @@ var cp_amm_default = {
6367
6638
  {
6368
6639
  name: "collect_fee_mode",
6369
6640
  docs: [
6370
- "0 is collect fee in both token, 1 only collect fee in token a, 2 only collect fee in token b"
6641
+ "0 is collect fee in both token, 1 only collect fee only in token b"
6371
6642
  ],
6372
6643
  type: "u8"
6373
6644
  },
@@ -6488,18 +6759,6 @@ var cp_amm_default = {
6488
6759
  }
6489
6760
  }
6490
6761
  },
6491
- {
6492
- name: "padding",
6493
- docs: [
6494
- "padding"
6495
- ],
6496
- type: {
6497
- array: [
6498
- "u8",
6499
- 3
6500
- ]
6501
- }
6502
- },
6503
6762
  {
6504
6763
  name: "dynamic_fee",
6505
6764
  docs: [
@@ -6529,7 +6788,7 @@ var cp_amm_default = {
6529
6788
  name: "base_fee",
6530
6789
  type: {
6531
6790
  defined: {
6532
- name: "BaseFeeConfig"
6791
+ name: "BaseFeeInfo"
6533
6792
  }
6534
6793
  }
6535
6794
  },
@@ -6651,16 +6910,8 @@ var cp_amm_default = {
6651
6910
  }
6652
6911
  },
6653
6912
  {
6654
- name: "padding_1",
6655
- docs: [
6656
- "padding"
6657
- ],
6658
- type: {
6659
- array: [
6660
- "u64",
6661
- 2
6662
- ]
6663
- }
6913
+ name: "init_sqrt_price",
6914
+ type: "u128"
6664
6915
  }
6665
6916
  ]
6666
6917
  }
@@ -7210,67 +7461,32 @@ var cp_amm_default = {
7210
7461
  }
7211
7462
  ]
7212
7463
  }
7213
- },
7214
- {
7215
- name: "SwapParameters2",
7216
- type: {
7217
- kind: "struct",
7218
- fields: [
7219
- {
7220
- name: "amount_0",
7221
- docs: [
7222
- "When it's exact in, partial fill, this will be amount_in. When it's exact out, this will be amount_out"
7223
- ],
7224
- type: "u64"
7225
- },
7226
- {
7227
- name: "amount_1",
7228
- docs: [
7229
- "When it's exact in, partial fill, this will be minimum_amount_out. When it's exact out, this will be maximum_amount_in"
7230
- ],
7231
- type: "u64"
7232
- },
7233
- {
7234
- name: "swap_mode",
7235
- docs: [
7236
- "Swap mode, refer [SwapMode]"
7237
- ],
7238
- type: "u8"
7239
- }
7240
- ]
7241
- }
7242
- },
7243
- {
7244
- name: "SwapResult",
7245
- docs: [
7246
- "Encodes all results of swapping"
7247
- ],
7248
- type: {
7249
- kind: "struct",
7250
- fields: [
7251
- {
7252
- name: "output_amount",
7253
- type: "u64"
7254
- },
7255
- {
7256
- name: "next_sqrt_price",
7257
- type: "u128"
7258
- },
7259
- {
7260
- name: "lp_fee",
7261
- type: "u64"
7262
- },
7464
+ },
7465
+ {
7466
+ name: "SwapParameters2",
7467
+ type: {
7468
+ kind: "struct",
7469
+ fields: [
7263
7470
  {
7264
- name: "protocol_fee",
7471
+ name: "amount_0",
7472
+ docs: [
7473
+ "When it's exact in, partial fill, this will be amount_in. When it's exact out, this will be amount_out"
7474
+ ],
7265
7475
  type: "u64"
7266
7476
  },
7267
7477
  {
7268
- name: "partner_fee",
7478
+ name: "amount_1",
7479
+ docs: [
7480
+ "When it's exact in, partial fill, this will be minimum_amount_out. When it's exact out, this will be maximum_amount_in"
7481
+ ],
7269
7482
  type: "u64"
7270
7483
  },
7271
7484
  {
7272
- name: "referral_fee",
7273
- type: "u64"
7485
+ name: "swap_mode",
7486
+ docs: [
7487
+ "Swap mode, refer [SwapMode]"
7488
+ ],
7489
+ type: "u8"
7274
7490
  }
7275
7491
  ]
7276
7492
  }
@@ -7353,6 +7569,41 @@ var cp_amm_default = {
7353
7569
  ]
7354
7570
  }
7355
7571
  },
7572
+ {
7573
+ name: "UpdatePoolFeesParameters",
7574
+ type: {
7575
+ kind: "struct",
7576
+ fields: [
7577
+ {
7578
+ name: "cliff_fee_numerator",
7579
+ docs: [
7580
+ "Base fee update mode:",
7581
+ "- None: skip base fee update",
7582
+ "- Some: update new cliff_fee_numerator if base fee is static"
7583
+ ],
7584
+ type: {
7585
+ option: "u64"
7586
+ }
7587
+ },
7588
+ {
7589
+ name: "dynamic_fee",
7590
+ docs: [
7591
+ "Dynamic fee update mode:",
7592
+ "- None: skip dynamic fee update",
7593
+ "- Some(with default value): disable dynamic fee",
7594
+ "- Some(with non default value): enable dynamic fee if disabled or update dynamic fee if enabled"
7595
+ ],
7596
+ type: {
7597
+ option: {
7598
+ defined: {
7599
+ name: "DynamicFeeParameters"
7600
+ }
7601
+ }
7602
+ }
7603
+ }
7604
+ ]
7605
+ }
7606
+ },
7356
7607
  {
7357
7608
  name: "UserRewardInfo",
7358
7609
  serialization: "bytemuck",
@@ -7479,6 +7730,94 @@ var cp_amm_default = {
7479
7730
  ]
7480
7731
  }
7481
7732
  }
7733
+ ],
7734
+ constants: [
7735
+ {
7736
+ name: "BIN_STEP_BPS_DEFAULT",
7737
+ type: "u16",
7738
+ value: "1"
7739
+ },
7740
+ {
7741
+ name: "BIN_STEP_U128_DEFAULT_LE_BYTES",
7742
+ type: {
7743
+ array: [
7744
+ "u8",
7745
+ 16
7746
+ ]
7747
+ },
7748
+ value: "[203, 16, 199, 186, 184, 141, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0]"
7749
+ },
7750
+ {
7751
+ name: "CUSTOMIZABLE_POOL_PREFIX",
7752
+ type: "bytes",
7753
+ value: "[99, 112, 111, 111, 108]"
7754
+ },
7755
+ {
7756
+ name: "FEE_DENOMINATOR",
7757
+ docs: [
7758
+ "Default fee denominator. DO NOT simply update it as it will break logic that depends on it as default value."
7759
+ ],
7760
+ type: "u64",
7761
+ value: "1000000000"
7762
+ },
7763
+ {
7764
+ name: "MAX_BASIS_POINT",
7765
+ docs: [
7766
+ "Max basis point. 100% in pct"
7767
+ ],
7768
+ type: "u64",
7769
+ value: "10000"
7770
+ },
7771
+ {
7772
+ name: "MAX_SQRT_PRICE_LE_BYTES",
7773
+ type: {
7774
+ array: [
7775
+ "u8",
7776
+ 16
7777
+ ]
7778
+ },
7779
+ value: "[155, 87, 105, 78, 169, 26, 92, 132, 177, 196, 254, 255, 0, 0, 0, 0]"
7780
+ },
7781
+ {
7782
+ name: "MIN_SQRT_PRICE_LE_BYTES",
7783
+ type: {
7784
+ array: [
7785
+ "u8",
7786
+ 16
7787
+ ]
7788
+ },
7789
+ value: "[80, 59, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]"
7790
+ },
7791
+ {
7792
+ name: "POOL_AUTHORITY_PREFIX",
7793
+ type: "bytes",
7794
+ value: "[112, 111, 111, 108, 95, 97, 117, 116, 104, 111, 114, 105, 116, 121]"
7795
+ },
7796
+ {
7797
+ name: "POOL_PREFIX",
7798
+ type: "bytes",
7799
+ value: "[112, 111, 111, 108]"
7800
+ },
7801
+ {
7802
+ name: "POSITION_NFT_ACCOUNT_PREFIX",
7803
+ type: "bytes",
7804
+ value: "[112, 111, 115, 105, 116, 105, 111, 110, 95, 110, 102, 116, 95, 97, 99, 99, 111, 117, 110, 116]"
7805
+ },
7806
+ {
7807
+ name: "POSITION_PREFIX",
7808
+ type: "bytes",
7809
+ value: "[112, 111, 115, 105, 116, 105, 111, 110]"
7810
+ },
7811
+ {
7812
+ name: "SPLIT_POSITION_DENOMINATOR",
7813
+ type: "u32",
7814
+ value: "1000000000"
7815
+ },
7816
+ {
7817
+ name: "TOKEN_VAULT_PREFIX",
7818
+ type: "bytes",
7819
+ value: "[116, 111, 107, 101, 110, 95, 118, 97, 117, 108, 116]"
7820
+ }
7482
7821
  ]
7483
7822
  };
7484
7823
 
@@ -7501,9 +7840,11 @@ var ActivationPoint = /* @__PURE__ */ ((ActivationPoint2) => {
7501
7840
  return ActivationPoint2;
7502
7841
  })(ActivationPoint || {});
7503
7842
  var BaseFeeMode = /* @__PURE__ */ ((BaseFeeMode3) => {
7504
- BaseFeeMode3[BaseFeeMode3["FeeSchedulerLinear"] = 0] = "FeeSchedulerLinear";
7505
- BaseFeeMode3[BaseFeeMode3["FeeSchedulerExponential"] = 1] = "FeeSchedulerExponential";
7843
+ BaseFeeMode3[BaseFeeMode3["FeeTimeSchedulerLinear"] = 0] = "FeeTimeSchedulerLinear";
7844
+ BaseFeeMode3[BaseFeeMode3["FeeTimeSchedulerExponential"] = 1] = "FeeTimeSchedulerExponential";
7506
7845
  BaseFeeMode3[BaseFeeMode3["RateLimiter"] = 2] = "RateLimiter";
7846
+ BaseFeeMode3[BaseFeeMode3["FeeMarketCapSchedulerLinear"] = 3] = "FeeMarketCapSchedulerLinear";
7847
+ BaseFeeMode3[BaseFeeMode3["FeeMarketCapSchedulerExponential"] = 4] = "FeeMarketCapSchedulerExponential";
7507
7848
  return BaseFeeMode3;
7508
7849
  })(BaseFeeMode || {});
7509
7850
  var CollectFeeMode = /* @__PURE__ */ ((CollectFeeMode3) => {
@@ -7521,10 +7862,10 @@ var ActivationType = /* @__PURE__ */ ((ActivationType3) => {
7521
7862
  ActivationType3[ActivationType3["Timestamp"] = 1] = "Timestamp";
7522
7863
  return ActivationType3;
7523
7864
  })(ActivationType || {});
7524
- var PoolVersion = /* @__PURE__ */ ((PoolVersion5) => {
7525
- PoolVersion5[PoolVersion5["V0"] = 0] = "V0";
7526
- PoolVersion5[PoolVersion5["V1"] = 1] = "V1";
7527
- return PoolVersion5;
7865
+ var PoolVersion = /* @__PURE__ */ ((PoolVersion4) => {
7866
+ PoolVersion4[PoolVersion4["V0"] = 0] = "V0";
7867
+ PoolVersion4[PoolVersion4["V1"] = 1] = "V1";
7868
+ return PoolVersion4;
7528
7869
  })(PoolVersion || {});
7529
7870
  var PoolStatus = /* @__PURE__ */ ((PoolStatus2) => {
7530
7871
  PoolStatus2[PoolStatus2["Enable"] = 0] = "Enable";
@@ -7578,7 +7919,8 @@ var U16_MAX = 65535;
7578
7919
  var MAX_RATE_LIMITER_DURATION_IN_SECONDS = 43200;
7579
7920
  var MAX_RATE_LIMITER_DURATION_IN_SLOTS = 108e3;
7580
7921
  var SPLIT_POSITION_DENOMINATOR = 1e9;
7581
- var CURRENT_POOL_VERSION = 0 /* V0 */;
7922
+ var CURRENT_POOL_VERSION = 1 /* V1 */;
7923
+ var FEE_PADDING = Array.from(Buffer.alloc(3));
7582
7924
 
7583
7925
  // src/pda.ts
7584
7926
  function getFirstKey(key1, key2) {
@@ -7666,6 +8008,12 @@ function derivePositionNftAccount(positionNftMint) {
7666
8008
  CP_AMM_PROGRAM_ID
7667
8009
  )[0];
7668
8010
  }
8011
+ function deriveOperatorAddress(whitelistedAddress) {
8012
+ return _web3js.PublicKey.findProgramAddressSync(
8013
+ [Buffer.from("operator"), whitelistedAddress.toBuffer()],
8014
+ CP_AMM_PROGRAM_ID
8015
+ )[0];
8016
+ }
7669
8017
 
7670
8018
  // src/helpers/token.ts
7671
8019
  var _bytes = require('@coral-xyz/anchor/dist/cjs/utils/bytes');
@@ -8102,6 +8450,7 @@ function offsetBasedFilter(value, offset) {
8102
8450
 
8103
8451
 
8104
8452
 
8453
+
8105
8454
  function calculatePreFeeAmount(transferFee, postFeeAmount) {
8106
8455
  if (postFeeAmount.isZero()) {
8107
8456
  return new (0, _anchor.BN)(0);
@@ -8175,6 +8524,61 @@ function calculateTransferFeeExcludedAmount(transferFeeIncludedAmount, mint, cur
8175
8524
  transferFee: new (0, _anchor.BN)(transferFee.toString())
8176
8525
  };
8177
8526
  }
8527
+ function hasTransferHookExtension(connection, mint) {
8528
+ return __async(this, null, function* () {
8529
+ try {
8530
+ const mintAccountInfo = yield connection.getAccountInfo(mint);
8531
+ if (!mintAccountInfo) {
8532
+ return { hasTransferHook: false };
8533
+ }
8534
+ const isToken2022 = mintAccountInfo.owner.equals(_spltoken.TOKEN_2022_PROGRAM_ID);
8535
+ if (!isToken2022) {
8536
+ return { hasTransferHook: false };
8537
+ }
8538
+ const parsedInfo = yield connection.getParsedAccountInfo(mint);
8539
+ if (parsedInfo.value && "parsed" in parsedInfo.value.data) {
8540
+ const parsedData = parsedInfo.value.data.parsed;
8541
+ if (parsedData && parsedData.info && parsedData.info.extensions) {
8542
+ const extensions = parsedData.info.extensions;
8543
+ const transferHookExtension = extensions.find(
8544
+ (ext) => ext.extension === "transferHook"
8545
+ );
8546
+ if (transferHookExtension && transferHookExtension.state) {
8547
+ return {
8548
+ hasTransferHook: true,
8549
+ transferHookState: {
8550
+ authority: transferHookExtension.state.authority,
8551
+ programId: transferHookExtension.state.programId
8552
+ }
8553
+ };
8554
+ }
8555
+ }
8556
+ }
8557
+ return { hasTransferHook: false };
8558
+ } catch (error) {
8559
+ return { hasTransferHook: false };
8560
+ }
8561
+ });
8562
+ }
8563
+ function validateNoTransferHook(connection, tokenAMint, tokenBMint) {
8564
+ return __async(this, null, function* () {
8565
+ var _a, _b;
8566
+ const [tokenACheck, tokenBCheck] = yield Promise.all([
8567
+ hasTransferHookExtension(connection, tokenAMint),
8568
+ hasTransferHookExtension(connection, tokenBMint)
8569
+ ]);
8570
+ if (tokenACheck.hasTransferHook) {
8571
+ throw new Error(
8572
+ `Token A (${tokenAMint.toBase58()}) has a transfer hook extension. Transfer hook might prevent permissionless pool creation. Transfer hook program: ${(_a = tokenACheck.transferHookState) == null ? void 0 : _a.programId}`
8573
+ );
8574
+ }
8575
+ if (tokenBCheck.hasTransferHook) {
8576
+ throw new Error(
8577
+ `Token B (${tokenBMint.toBase58()}) has a transfer hook extension. Transfer hook might prevent permissionless pool creation. Transfer hook program: ${(_b = tokenBCheck.transferHookState) == null ? void 0 : _b.programId}`
8578
+ );
8579
+ }
8580
+ });
8581
+ }
8178
8582
 
8179
8583
  // src/helpers/vestings.ts
8180
8584
 
@@ -8420,35 +8824,27 @@ function getTotalFeeNumerator(poolFees, baseFeeNumerator, maxFeeNumerator) {
8420
8824
  const totalFeeNumerator = dynamicFeeNumerator.add(baseFeeNumerator);
8421
8825
  return _anchor.BN.min(totalFeeNumerator, maxFeeNumerator);
8422
8826
  }
8423
- function getTotalTradingFeeFromIncludedFeeAmount(poolFees, currentPoint, activationPoint, includedFeeAmount, tradeDirection, maxFeeNumerator) {
8424
- const baseFeeHandler = getBaseFeeHandler(
8425
- poolFees.baseFee.cliffFeeNumerator,
8426
- poolFees.baseFee.firstFactor,
8427
- poolFees.baseFee.secondFactor,
8428
- poolFees.baseFee.thirdFactor,
8429
- poolFees.baseFee.baseFeeMode
8430
- );
8827
+ function getTotalTradingFeeFromIncludedFeeAmount(poolFees, currentPoint, activationPoint, includedFeeAmount, tradeDirection, maxFeeNumerator, initSqrtPrice, currentSqrtPrice) {
8828
+ const baseFeeHandler = getBaseFeeHandler(poolFees.baseFee.baseFeeInfo.data);
8431
8829
  const baseFeeNumerator = baseFeeHandler.getBaseFeeNumeratorFromIncludedFeeAmount(
8432
8830
  currentPoint,
8433
8831
  activationPoint,
8434
8832
  tradeDirection,
8435
- includedFeeAmount
8833
+ includedFeeAmount,
8834
+ initSqrtPrice,
8835
+ currentSqrtPrice
8436
8836
  );
8437
8837
  return getTotalFeeNumerator(poolFees, baseFeeNumerator, maxFeeNumerator);
8438
8838
  }
8439
- function getTotalTradingFeeFromExcludedFeeAmount(poolFees, currentPoint, activationPoint, excludedFeeAmount, tradeDirection, maxFeeNumerator) {
8440
- const baseFeeHandler = getBaseFeeHandler(
8441
- poolFees.baseFee.cliffFeeNumerator,
8442
- poolFees.baseFee.firstFactor,
8443
- poolFees.baseFee.secondFactor,
8444
- poolFees.baseFee.thirdFactor,
8445
- poolFees.baseFee.baseFeeMode
8446
- );
8839
+ function getTotalTradingFeeFromExcludedFeeAmount(poolFees, currentPoint, activationPoint, excludedFeeAmount, tradeDirection, maxFeeNumerator, initSqrtPrice, currentSqrtPrice) {
8840
+ const baseFeeHandler = getBaseFeeHandler(poolFees.baseFee.baseFeeInfo.data);
8447
8841
  const baseFeeNumerator = baseFeeHandler.getBaseFeeNumeratorFromExcludedFeeAmount(
8448
8842
  currentPoint,
8449
8843
  activationPoint,
8450
8844
  tradeDirection,
8451
- excludedFeeAmount
8845
+ excludedFeeAmount,
8846
+ initSqrtPrice,
8847
+ currentSqrtPrice
8452
8848
  );
8453
8849
  return getTotalFeeNumerator(poolFees, baseFeeNumerator, maxFeeNumerator);
8454
8850
  }
@@ -8766,28 +9162,38 @@ function getFeeNumeratorFromExcludedFeeAmount(excludedFeeAmount, referenceAmount
8766
9162
  return feeNumerator;
8767
9163
  }
8768
9164
 
9165
+ // src/math/poolFees/feeTimeScheduler.ts
9166
+
9167
+
8769
9168
  // src/math/poolFees/feeScheduler.ts
8770
9169
 
9170
+ function getFeeNumeratorOnLinearFeeScheduler(cliffFeeNumerator, reductionFactor, period) {
9171
+ const reduction = new (0, _bnjs2.default)(period).mul(reductionFactor);
9172
+ return cliffFeeNumerator.sub(reduction);
9173
+ }
9174
+ function getFeeNumeratorOnExponentialFeeScheduler(cliffFeeNumerator, reductionFactor, period) {
9175
+ if (period === 0) {
9176
+ return cliffFeeNumerator;
9177
+ }
9178
+ const basisPointMax = new (0, _bnjs2.default)(BASIS_POINT_MAX);
9179
+ const bps = new (0, _bnjs2.default)(reductionFactor).shln(64).div(basisPointMax);
9180
+ const base = ONE_Q64.sub(bps);
9181
+ const result = pow(base, new (0, _bnjs2.default)(period));
9182
+ return cliffFeeNumerator.mul(result).div(ONE_Q64);
9183
+ }
8771
9184
  function getMaxBaseFeeNumerator(cliffFeeNumerator) {
8772
9185
  return cliffFeeNumerator;
8773
9186
  }
8774
- function getMinBaseFeeNumerator(cliffFeeNumerator, numberOfPeriod, reductionFactor, feeSchedulerMode) {
8775
- return getBaseFeeNumeratorByPeriod(
8776
- cliffFeeNumerator,
8777
- numberOfPeriod,
8778
- new (0, _bnjs2.default)(numberOfPeriod),
8779
- reductionFactor,
8780
- feeSchedulerMode
8781
- );
8782
- }
8783
- function getBaseFeeNumeratorByPeriod(cliffFeeNumerator, numberOfPeriod, period, reductionFactor, feeSchedulerMode) {
9187
+
9188
+ // src/math/poolFees/feeTimeScheduler.ts
9189
+ function getFeeTimeBaseFeeNumeratorByPeriod(cliffFeeNumerator, numberOfPeriod, period, reductionFactor, feeTimeSchedulerMode) {
8784
9190
  const periodValue = _bnjs2.default.min(period, new (0, _bnjs2.default)(numberOfPeriod));
8785
9191
  const periodNumber = periodValue.toNumber();
8786
9192
  if (periodNumber > U16_MAX) {
8787
9193
  throw new Error("Math overflow");
8788
9194
  }
8789
- switch (feeSchedulerMode) {
8790
- case 0 /* FeeSchedulerLinear */: {
9195
+ switch (feeTimeSchedulerMode) {
9196
+ case 0 /* FeeTimeSchedulerLinear */: {
8791
9197
  const feeNumerator = getFeeNumeratorOnLinearFeeScheduler(
8792
9198
  cliffFeeNumerator,
8793
9199
  reductionFactor,
@@ -8795,7 +9201,7 @@ function getBaseFeeNumeratorByPeriod(cliffFeeNumerator, numberOfPeriod, period,
8795
9201
  );
8796
9202
  return feeNumerator;
8797
9203
  }
8798
- case 1 /* FeeSchedulerExponential */: {
9204
+ case 1 /* FeeTimeSchedulerExponential */: {
8799
9205
  const feeNumerator = getFeeNumeratorOnExponentialFeeScheduler(
8800
9206
  cliffFeeNumerator,
8801
9207
  reductionFactor,
@@ -8804,24 +9210,10 @@ function getBaseFeeNumeratorByPeriod(cliffFeeNumerator, numberOfPeriod, period,
8804
9210
  return feeNumerator;
8805
9211
  }
8806
9212
  default:
8807
- throw new Error("Invalid fee scheduler mode");
8808
- }
8809
- }
8810
- function getFeeNumeratorOnLinearFeeScheduler(cliffFeeNumerator, reductionFactor, period) {
8811
- const reduction = new (0, _bnjs2.default)(period).mul(reductionFactor);
8812
- return cliffFeeNumerator.sub(reduction);
8813
- }
8814
- function getFeeNumeratorOnExponentialFeeScheduler(cliffFeeNumerator, reductionFactor, period) {
8815
- if (period === 0) {
8816
- return cliffFeeNumerator;
9213
+ throw new Error("Invalid fee time scheduler mode");
8817
9214
  }
8818
- const basisPointMax = new (0, _bnjs2.default)(BASIS_POINT_MAX);
8819
- const bps = new (0, _bnjs2.default)(reductionFactor).shln(64).div(basisPointMax);
8820
- const base = ONE_Q64.sub(bps);
8821
- const result = pow(base, new (0, _bnjs2.default)(period));
8822
- return cliffFeeNumerator.mul(result).div(ONE_Q64);
8823
9215
  }
8824
- function getBaseFeeNumerator(cliffFeeNumerator, numberOfPeriod, periodFrequency, reductionFactor, feeSchedulerMode, currentPoint, activationPoint) {
9216
+ function getFeeTimeBaseFeeNumerator(cliffFeeNumerator, numberOfPeriod, periodFrequency, reductionFactor, feeTimeSchedulerMode, currentPoint, activationPoint) {
8825
9217
  if (periodFrequency.isZero()) {
8826
9218
  return cliffFeeNumerator;
8827
9219
  }
@@ -8834,12 +9226,87 @@ function getBaseFeeNumerator(cliffFeeNumerator, numberOfPeriod, periodFrequency,
8834
9226
  period = new (0, _bnjs2.default)(numberOfPeriod);
8835
9227
  }
8836
9228
  }
8837
- return getBaseFeeNumeratorByPeriod(
9229
+ return getFeeTimeBaseFeeNumeratorByPeriod(
9230
+ cliffFeeNumerator,
9231
+ numberOfPeriod,
9232
+ period,
9233
+ reductionFactor,
9234
+ feeTimeSchedulerMode
9235
+ );
9236
+ }
9237
+ function getFeeTimeMinBaseFeeNumerator(cliffFeeNumerator, numberOfPeriod, reductionFactor, feeTimeSchedulerMode) {
9238
+ return getFeeTimeBaseFeeNumeratorByPeriod(
9239
+ cliffFeeNumerator,
9240
+ numberOfPeriod,
9241
+ new (0, _bnjs2.default)(numberOfPeriod),
9242
+ reductionFactor,
9243
+ feeTimeSchedulerMode
9244
+ );
9245
+ }
9246
+
9247
+ // src/math/poolFees/feeMarketCapScheduler.ts
9248
+
9249
+ function getFeeMarketCapBaseFeeNumeratorByPeriod(cliffFeeNumerator, numberOfPeriod, period, reductionFactor, feeMarketCapSchedulerMode) {
9250
+ const periodValue = _bnjs2.default.min(period, new (0, _bnjs2.default)(numberOfPeriod));
9251
+ const periodNumber = periodValue.toNumber();
9252
+ switch (feeMarketCapSchedulerMode) {
9253
+ case 3 /* FeeMarketCapSchedulerLinear */: {
9254
+ const feeNumerator = getFeeNumeratorOnLinearFeeScheduler(
9255
+ cliffFeeNumerator,
9256
+ reductionFactor,
9257
+ periodNumber
9258
+ );
9259
+ return feeNumerator;
9260
+ }
9261
+ case 4 /* FeeMarketCapSchedulerExponential */: {
9262
+ const feeNumerator = getFeeNumeratorOnExponentialFeeScheduler(
9263
+ cliffFeeNumerator,
9264
+ reductionFactor,
9265
+ periodNumber
9266
+ );
9267
+ return feeNumerator;
9268
+ }
9269
+ default:
9270
+ throw new Error("Invalid fee market cap scheduler mode");
9271
+ }
9272
+ }
9273
+ function getFeeMarketCapBaseFeeNumerator(cliffFeeNumerator, numberOfPeriod, sqrtPriceStepBps, schedulerExpirationDuration, reductionFactor, feeMarketCapSchedulerMode, currentPoint, activationPoint, initSqrtPrice, currentSqrtPrice) {
9274
+ const schedulerExpirationPoint = activationPoint.add(
9275
+ new (0, _bnjs2.default)(schedulerExpirationDuration)
9276
+ );
9277
+ let period;
9278
+ if (currentPoint.gt(schedulerExpirationPoint) || currentPoint.lt(activationPoint)) {
9279
+ period = new (0, _bnjs2.default)(numberOfPeriod);
9280
+ } else {
9281
+ if (currentSqrtPrice.lte(initSqrtPrice)) {
9282
+ period = new (0, _bnjs2.default)(0);
9283
+ } else {
9284
+ const maxBps = new (0, _bnjs2.default)(BASIS_POINT_MAX);
9285
+ const stepBps = new (0, _bnjs2.default)(sqrtPriceStepBps);
9286
+ const passedPeriod = currentSqrtPrice.sub(initSqrtPrice).mul(maxBps).div(initSqrtPrice).div(stepBps);
9287
+ if (passedPeriod.gt(new (0, _bnjs2.default)(numberOfPeriod))) {
9288
+ period = new (0, _bnjs2.default)(numberOfPeriod);
9289
+ } else {
9290
+ period = passedPeriod;
9291
+ }
9292
+ }
9293
+ period = _bnjs2.default.min(period, new (0, _bnjs2.default)(numberOfPeriod));
9294
+ }
9295
+ return getFeeMarketCapBaseFeeNumeratorByPeriod(
8838
9296
  cliffFeeNumerator,
8839
9297
  numberOfPeriod,
8840
9298
  period,
8841
9299
  reductionFactor,
8842
- feeSchedulerMode
9300
+ feeMarketCapSchedulerMode
9301
+ );
9302
+ }
9303
+ function getFeeMarketCapMinBaseFeeNumerator(cliffFeeNumerator, numberOfPeriod, reductionFactor, feeMarketCapSchedulerMode) {
9304
+ return getFeeMarketCapBaseFeeNumeratorByPeriod(
9305
+ cliffFeeNumerator,
9306
+ numberOfPeriod,
9307
+ new (0, _bnjs2.default)(numberOfPeriod),
9308
+ reductionFactor,
9309
+ feeMarketCapSchedulerMode
8843
9310
  );
8844
9311
  }
8845
9312
 
@@ -8864,7 +9331,7 @@ var FeeRateLimiter = class {
8864
9331
  poolVersion
8865
9332
  );
8866
9333
  }
8867
- getBaseFeeNumeratorFromIncludedFeeAmount(currentPoint, activationPoint, tradeDirection, includedFeeAmount) {
9334
+ getBaseFeeNumeratorFromIncludedFeeAmount(currentPoint, activationPoint, tradeDirection, includedFeeAmount, _initSqrtPrice, _currentSqrtPrice) {
8868
9335
  if (isRateLimiterApplied(
8869
9336
  this.referenceAmount,
8870
9337
  this.maxLimiterDuration,
@@ -8885,7 +9352,7 @@ var FeeRateLimiter = class {
8885
9352
  return this.cliffFeeNumerator;
8886
9353
  }
8887
9354
  }
8888
- getBaseFeeNumeratorFromExcludedFeeAmount(currentPoint, activationPoint, tradeDirection, excludedFeeAmount) {
9355
+ getBaseFeeNumeratorFromExcludedFeeAmount(currentPoint, activationPoint, tradeDirection, excludedFeeAmount, _initSqrtPrice, _currentSqrtPrice) {
8889
9356
  if (isRateLimiterApplied(
8890
9357
  this.referenceAmount,
8891
9358
  this.maxLimiterDuration,
@@ -8893,101 +9360,191 @@ var FeeRateLimiter = class {
8893
9360
  this.feeIncrementBps,
8894
9361
  currentPoint,
8895
9362
  activationPoint,
8896
- tradeDirection
8897
- )) {
8898
- return getFeeNumeratorFromExcludedFeeAmount(
8899
- excludedFeeAmount,
8900
- this.referenceAmount,
8901
- this.cliffFeeNumerator,
8902
- this.maxFeeBps,
8903
- this.feeIncrementBps
8904
- );
8905
- } else {
8906
- return this.cliffFeeNumerator;
8907
- }
9363
+ tradeDirection
9364
+ )) {
9365
+ return getFeeNumeratorFromExcludedFeeAmount(
9366
+ excludedFeeAmount,
9367
+ this.referenceAmount,
9368
+ this.cliffFeeNumerator,
9369
+ this.maxFeeBps,
9370
+ this.feeIncrementBps
9371
+ );
9372
+ } else {
9373
+ return this.cliffFeeNumerator;
9374
+ }
9375
+ }
9376
+ validateBaseFeeIsStatic(currentPoint, activationPoint) {
9377
+ return validateFeeRateLimiterBaseFeeIsStatic(
9378
+ currentPoint,
9379
+ activationPoint,
9380
+ this.maxLimiterDuration,
9381
+ this.referenceAmount,
9382
+ this.maxFeeBps,
9383
+ this.feeIncrementBps
9384
+ );
9385
+ }
9386
+ getMinBaseFeeNumerator() {
9387
+ return this.cliffFeeNumerator;
9388
+ }
9389
+ };
9390
+ var FeeTimeScheduler = class {
9391
+ constructor(cliffFeeNumerator, numberOfPeriod, periodFrequency, reductionFactor, feeTimeSchedulerMode) {
9392
+ this.cliffFeeNumerator = cliffFeeNumerator;
9393
+ this.numberOfPeriod = numberOfPeriod;
9394
+ this.periodFrequency = periodFrequency;
9395
+ this.reductionFactor = reductionFactor;
9396
+ this.feeTimeSchedulerMode = feeTimeSchedulerMode;
9397
+ }
9398
+ validate(collectFeeMode, activationType, poolVersion) {
9399
+ return validateFeeTimeScheduler(
9400
+ this.numberOfPeriod,
9401
+ this.periodFrequency,
9402
+ this.reductionFactor,
9403
+ this.cliffFeeNumerator,
9404
+ this.feeTimeSchedulerMode,
9405
+ poolVersion
9406
+ );
9407
+ }
9408
+ getBaseFeeNumeratorFromIncludedFeeAmount(currentPoint, activationPoint, _tradeDirection, _includedFeeAmount, _initSqrtPrice, _currentSqrtPrice) {
9409
+ return getFeeTimeBaseFeeNumerator(
9410
+ this.cliffFeeNumerator,
9411
+ this.numberOfPeriod,
9412
+ this.periodFrequency,
9413
+ this.reductionFactor,
9414
+ this.feeTimeSchedulerMode,
9415
+ currentPoint,
9416
+ activationPoint
9417
+ );
9418
+ }
9419
+ getBaseFeeNumeratorFromExcludedFeeAmount(currentPoint, activationPoint, _tradeDirection, _excludedFeeAmount, _initSqrtPrice, _currentSqrtPrice) {
9420
+ return getFeeTimeBaseFeeNumerator(
9421
+ this.cliffFeeNumerator,
9422
+ this.numberOfPeriod,
9423
+ this.periodFrequency,
9424
+ this.reductionFactor,
9425
+ this.feeTimeSchedulerMode,
9426
+ currentPoint,
9427
+ activationPoint
9428
+ );
9429
+ }
9430
+ validateBaseFeeIsStatic(currentPoint, activationPoint) {
9431
+ return validateFeeTimeSchedulerBaseFeeIsStatic(
9432
+ currentPoint,
9433
+ activationPoint,
9434
+ new (0, _bnjs2.default)(this.numberOfPeriod),
9435
+ this.periodFrequency
9436
+ );
9437
+ }
9438
+ getMinBaseFeeNumerator() {
9439
+ return getFeeTimeMinBaseFeeNumerator(
9440
+ this.cliffFeeNumerator,
9441
+ this.numberOfPeriod,
9442
+ this.reductionFactor,
9443
+ this.feeTimeSchedulerMode
9444
+ );
8908
9445
  }
8909
9446
  };
8910
- var FeeScheduler = class {
8911
- constructor(cliffFeeNumerator, numberOfPeriod, periodFrequency, reductionFactor, feeSchedulerMode) {
9447
+ var FeeMarketCapScheduler = class {
9448
+ constructor(cliffFeeNumerator, numberOfPeriod, sqrtPriceStepBps, schedulerExpirationDuration, reductionFactor, feeMarketCapSchedulerMode) {
8912
9449
  this.cliffFeeNumerator = cliffFeeNumerator;
8913
9450
  this.numberOfPeriod = numberOfPeriod;
8914
- this.periodFrequency = periodFrequency;
9451
+ this.sqrtPriceStepBps = sqrtPriceStepBps;
9452
+ this.schedulerExpirationDuration = schedulerExpirationDuration;
8915
9453
  this.reductionFactor = reductionFactor;
8916
- this.feeSchedulerMode = feeSchedulerMode;
9454
+ this.feeMarketCapSchedulerMode = feeMarketCapSchedulerMode;
8917
9455
  }
8918
- validate(collectFeeMode, activationType, poolVersion) {
8919
- return validateFeeScheduler(
9456
+ validate(_collectFeeMode, _activationType, poolVersion) {
9457
+ return validateFeeMarketCapScheduler(
9458
+ this.cliffFeeNumerator,
8920
9459
  this.numberOfPeriod,
8921
- this.periodFrequency,
9460
+ new (0, _bnjs2.default)(this.sqrtPriceStepBps),
8922
9461
  this.reductionFactor,
8923
- this.cliffFeeNumerator,
8924
- this.feeSchedulerMode,
9462
+ new (0, _bnjs2.default)(this.schedulerExpirationDuration),
9463
+ this.feeMarketCapSchedulerMode,
8925
9464
  poolVersion
8926
9465
  );
8927
9466
  }
8928
- getBaseFeeNumeratorFromIncludedFeeAmount(currentPoint, activationPoint) {
8929
- return getBaseFeeNumerator(
9467
+ getBaseFeeNumeratorFromIncludedFeeAmount(currentPoint, activationPoint, _tradeDirection, _includedFeeAmount, initSqrtPrice, currentSqrtPrice) {
9468
+ return getFeeMarketCapBaseFeeNumerator(
8930
9469
  this.cliffFeeNumerator,
8931
9470
  this.numberOfPeriod,
8932
- this.periodFrequency,
9471
+ this.sqrtPriceStepBps,
9472
+ this.schedulerExpirationDuration,
8933
9473
  this.reductionFactor,
8934
- this.feeSchedulerMode,
9474
+ this.feeMarketCapSchedulerMode,
8935
9475
  currentPoint,
8936
- activationPoint
9476
+ activationPoint,
9477
+ initSqrtPrice,
9478
+ currentSqrtPrice
8937
9479
  );
8938
9480
  }
8939
- getBaseFeeNumeratorFromExcludedFeeAmount(currentPoint, activationPoint) {
8940
- return getBaseFeeNumerator(
9481
+ getBaseFeeNumeratorFromExcludedFeeAmount(currentPoint, activationPoint, _tradeDirection, _excludedFeeAmount, initSqrtPrice, currentSqrtPrice) {
9482
+ return getFeeMarketCapBaseFeeNumerator(
8941
9483
  this.cliffFeeNumerator,
8942
9484
  this.numberOfPeriod,
8943
- this.periodFrequency,
9485
+ this.sqrtPriceStepBps,
9486
+ this.schedulerExpirationDuration,
8944
9487
  this.reductionFactor,
8945
- this.feeSchedulerMode,
9488
+ this.feeMarketCapSchedulerMode,
8946
9489
  currentPoint,
8947
- activationPoint
9490
+ activationPoint,
9491
+ initSqrtPrice,
9492
+ currentSqrtPrice
9493
+ );
9494
+ }
9495
+ validateBaseFeeIsStatic(currentPoint, activationPoint) {
9496
+ return validateFeeMarketCapBaseFeeIsStatic(
9497
+ currentPoint,
9498
+ activationPoint,
9499
+ new (0, _bnjs2.default)(this.schedulerExpirationDuration)
9500
+ );
9501
+ }
9502
+ getMinBaseFeeNumerator() {
9503
+ return getFeeMarketCapMinBaseFeeNumerator(
9504
+ this.cliffFeeNumerator,
9505
+ this.numberOfPeriod,
9506
+ this.reductionFactor,
9507
+ this.feeMarketCapSchedulerMode
8948
9508
  );
8949
9509
  }
8950
9510
  };
8951
- function getBaseFeeHandler(cliffFeeNumerator, firstFactor, secondFactor, thirdFactor, baseFeeMode) {
9511
+ function getBaseFeeHandler(rawData) {
9512
+ const data = Buffer.from(rawData);
9513
+ const modeIndex = data.readUInt8(8);
9514
+ const baseFeeMode = modeIndex;
8952
9515
  switch (baseFeeMode) {
8953
- case 0 /* FeeSchedulerLinear */:
8954
- case 1 /* FeeSchedulerExponential */: {
8955
- if (secondFactor.length < 8) {
8956
- throw new Error(
8957
- "TypeCastFailed: secondFactor must be at least 8 bytes"
8958
- );
8959
- }
8960
- const periodFrequency = new (0, _bnjs2.default)(
8961
- Buffer.from(secondFactor.slice(0, 8)),
8962
- "le"
8963
- );
8964
- const feeScheduler = new FeeScheduler(
8965
- cliffFeeNumerator,
8966
- firstFactor,
8967
- periodFrequency,
8968
- thirdFactor,
8969
- baseFeeMode
9516
+ case 0 /* FeeTimeSchedulerLinear */:
9517
+ case 1 /* FeeTimeSchedulerExponential */: {
9518
+ const poolFees = decodePodAlignedFeeTimeScheduler(data);
9519
+ return new FeeTimeScheduler(
9520
+ poolFees.cliffFeeNumerator,
9521
+ poolFees.numberOfPeriod,
9522
+ poolFees.periodFrequency,
9523
+ poolFees.reductionFactor,
9524
+ poolFees.baseFeeMode
8970
9525
  );
8971
- return feeScheduler;
8972
9526
  }
8973
9527
  case 2 /* RateLimiter */: {
8974
- if (secondFactor.length < 8) {
8975
- throw new Error(
8976
- "TypeCastFailed: secondFactor must be at least 8 bytes"
8977
- );
8978
- }
8979
- const maxLimiterDuration = Buffer.from(
8980
- secondFactor.slice(0, 4)
8981
- ).readUInt32LE(0);
8982
- const maxFeeBps = Buffer.from(secondFactor.slice(4, 8)).readUInt32LE(0);
8983
- const feeRateLimiter = new FeeRateLimiter(
8984
- cliffFeeNumerator,
8985
- firstFactor,
8986
- maxFeeBps,
8987
- maxLimiterDuration,
8988
- thirdFactor
9528
+ const poolFees = decodePodAlignedFeeRateLimiter(data);
9529
+ return new FeeRateLimiter(
9530
+ poolFees.cliffFeeNumerator,
9531
+ poolFees.feeIncrementBps,
9532
+ poolFees.maxFeeBps,
9533
+ poolFees.maxLimiterDuration,
9534
+ poolFees.referenceAmount
9535
+ );
9536
+ }
9537
+ case 3 /* FeeMarketCapSchedulerLinear */:
9538
+ case 4 /* FeeMarketCapSchedulerExponential */: {
9539
+ const poolFees = decodePodAlignedFeeMarketCapScheduler(data);
9540
+ return new FeeMarketCapScheduler(
9541
+ poolFees.cliffFeeNumerator,
9542
+ poolFees.numberOfPeriod,
9543
+ poolFees.sqrtPriceStepBps,
9544
+ poolFees.schedulerExpirationDuration,
9545
+ poolFees.reductionFactor,
9546
+ poolFees.baseFeeMode
8989
9547
  );
8990
- return feeRateLimiter;
8991
9548
  }
8992
9549
  default:
8993
9550
  throw new Error("Invalid base fee mode");
@@ -9151,7 +9708,9 @@ function getSwapResultFromExactInput(poolState, amountIn, feeMode, tradeDirectio
9151
9708
  poolState.activationPoint,
9152
9709
  amountIn,
9153
9710
  tradeDirection,
9154
- maxFeeNumerator
9711
+ maxFeeNumerator,
9712
+ poolState.poolFees.initSqrtPrice,
9713
+ poolState.sqrtPrice
9155
9714
  );
9156
9715
  let actualAmountIn;
9157
9716
  if (feeMode.feesOnInput) {
@@ -9262,7 +9821,9 @@ function getSwapResultFromPartialInput(poolState, amountIn, feeMode, tradeDirect
9262
9821
  poolState.activationPoint,
9263
9822
  amountIn,
9264
9823
  tradeDirection,
9265
- maxFeeNumerator
9824
+ maxFeeNumerator,
9825
+ poolState.poolFees.initSqrtPrice,
9826
+ poolState.sqrtPrice
9266
9827
  );
9267
9828
  let actualAmountIn;
9268
9829
  if (feeMode.feesOnInput) {
@@ -9304,7 +9865,9 @@ function getSwapResultFromPartialInput(poolState, amountIn, feeMode, tradeDirect
9304
9865
  poolState.activationPoint,
9305
9866
  actualAmountIn,
9306
9867
  tradeDirection,
9307
- maxFeeNumerator
9868
+ maxFeeNumerator,
9869
+ poolState.poolFees.initSqrtPrice,
9870
+ poolState.sqrtPrice
9308
9871
  );
9309
9872
  const { includedFeeAmount, feeAmount } = getIncludedFeeAmount(
9310
9873
  tradeFeeNumerator2,
@@ -9440,7 +10003,9 @@ function getSwapResultFromExactOutput(poolState, amountOut, feeMode, tradeDirect
9440
10003
  poolState.activationPoint,
9441
10004
  amountOut,
9442
10005
  tradeDirection,
9443
- maxFeeNumerator
10006
+ maxFeeNumerator,
10007
+ poolState.poolFees.initSqrtPrice,
10008
+ poolState.sqrtPrice
9444
10009
  );
9445
10010
  const { includedFeeAmount, feeAmount } = getIncludedFeeAmount(
9446
10011
  tradeFeeNumerator,
@@ -9479,7 +10044,9 @@ function getSwapResultFromExactOutput(poolState, amountOut, feeMode, tradeDirect
9479
10044
  poolState.activationPoint,
9480
10045
  inputAmount,
9481
10046
  tradeDirection,
9482
- maxFeeNumerator
10047
+ maxFeeNumerator,
10048
+ poolState.poolFees.initSqrtPrice,
10049
+ poolState.sqrtPrice
9483
10050
  );
9484
10051
  const { includedFeeAmount, feeAmount } = getIncludedFeeAmount(
9485
10052
  tradeFeeNumerator,
@@ -9732,13 +10299,13 @@ function calculateInitSqrtPrice(tokenAAmount, tokenBAmount, minSqrtPrice, maxSqr
9732
10299
  }
9733
10300
 
9734
10301
  // src/helpers/validation.ts
9735
- function validateFeeScheduler(numberOfPeriod, periodFrequency, reductionFactor, cliffFeeNumerator, baseFeeMode, poolVersion) {
10302
+ function validateFeeTimeScheduler(numberOfPeriod, periodFrequency, reductionFactor, cliffFeeNumerator, baseFeeMode, poolVersion) {
9736
10303
  if (!periodFrequency.eq(new (0, _bnjs2.default)(0)) || numberOfPeriod !== 0 || !reductionFactor.eq(new (0, _bnjs2.default)(0))) {
9737
10304
  if (numberOfPeriod === 0 || periodFrequency.eq(new (0, _bnjs2.default)(0)) || reductionFactor.eq(new (0, _bnjs2.default)(0))) {
9738
- return false;
10305
+ throw new Error("PoolError::InvalidFeeTimeScheduler");
9739
10306
  }
9740
10307
  }
9741
- const minFeeNumerator = getMinBaseFeeNumerator(
10308
+ const minFeeNumerator = getFeeTimeMinBaseFeeNumerator(
9742
10309
  cliffFeeNumerator,
9743
10310
  numberOfPeriod,
9744
10311
  reductionFactor,
@@ -9752,6 +10319,46 @@ function validateFeeScheduler(numberOfPeriod, periodFrequency, reductionFactor,
9752
10319
  }
9753
10320
  return true;
9754
10321
  }
10322
+ function validateFeeTimeSchedulerBaseFeeIsStatic(currentPoint, activationPoint, numberOfPeriod, periodFrequency) {
10323
+ const schedulerExpirationPoint = activationPoint.add(
10324
+ numberOfPeriod.mul(periodFrequency)
10325
+ );
10326
+ return currentPoint.gt(schedulerExpirationPoint);
10327
+ }
10328
+ function validateFeeMarketCapScheduler(cliffFeeNumerator, numberOfPeriod, sqrtPriceStepBps, reductionFactor, schedulerExpirationDuration, feeMarketCapSchedulerMode, poolVersion) {
10329
+ if (reductionFactor.lte(new (0, _bnjs2.default)(0))) {
10330
+ throw new Error("PoolError::InvalidFeeMarketCapScheduler");
10331
+ }
10332
+ if (sqrtPriceStepBps.lte(new (0, _bnjs2.default)(0))) {
10333
+ throw new Error("PoolError::InvalidFeeMarketCapScheduler");
10334
+ }
10335
+ if (schedulerExpirationDuration.lte(new (0, _bnjs2.default)(0))) {
10336
+ throw new Error("PoolError::InvalidFeeMarketCapScheduler");
10337
+ }
10338
+ if (numberOfPeriod <= 0) {
10339
+ throw new Error("PoolError::InvalidFeeMarketCapScheduler");
10340
+ }
10341
+ const minFeeNumerator = getFeeMarketCapMinBaseFeeNumerator(
10342
+ cliffFeeNumerator,
10343
+ numberOfPeriod,
10344
+ reductionFactor,
10345
+ feeMarketCapSchedulerMode
10346
+ );
10347
+ const maxFeeNumerator = cliffFeeNumerator;
10348
+ validateFeeFraction(minFeeNumerator, new (0, _bnjs2.default)(FEE_DENOMINATOR));
10349
+ validateFeeFraction(maxFeeNumerator, new (0, _bnjs2.default)(FEE_DENOMINATOR));
10350
+ const maxAllowedFeeNumerator = getMaxFeeNumerator(poolVersion);
10351
+ if (minFeeNumerator.lt(new (0, _bnjs2.default)(MIN_FEE_NUMERATOR)) || maxFeeNumerator.gt(maxAllowedFeeNumerator)) {
10352
+ throw new Error("PoolError::ExceedMaxFeeBps");
10353
+ }
10354
+ return true;
10355
+ }
10356
+ function validateFeeMarketCapBaseFeeIsStatic(currentPoint, activationPoint, schedulerExpirationDuration) {
10357
+ const schedulerExpirationPoint = activationPoint.add(
10358
+ schedulerExpirationDuration
10359
+ );
10360
+ return currentPoint.gt(schedulerExpirationPoint);
10361
+ }
9755
10362
  function validateFeeRateLimiter(cliffFeeNumerator, feeIncrementBps, maxFeeBps, maxLimiterDuration, referenceAmount, collectFeeMode, activationType, poolVersion) {
9756
10363
  if (collectFeeMode !== 1 /* OnlyB */) {
9757
10364
  return false;
@@ -9812,6 +10419,20 @@ function validateFeeRateLimiter(cliffFeeNumerator, feeIncrementBps, maxFeeBps, m
9812
10419
  }
9813
10420
  return true;
9814
10421
  }
10422
+ function validateFeeRateLimiterBaseFeeIsStatic(currentPoint, activationPoint, maxLimiterDuration, referenceAmount, maxFeeBps, feeIncrementBps) {
10423
+ if (isZeroRateLimiter(
10424
+ referenceAmount,
10425
+ maxLimiterDuration,
10426
+ maxFeeBps,
10427
+ feeIncrementBps
10428
+ )) {
10429
+ return true;
10430
+ }
10431
+ const lastEffectiveRateLimiterPoint = activationPoint.add(
10432
+ new (0, _bnjs2.default)(maxLimiterDuration)
10433
+ );
10434
+ return currentPoint.gt(lastEffectiveRateLimiterPoint);
10435
+ }
9815
10436
  function validateFeeFraction(numerator, denominator) {
9816
10437
  if (denominator.isZero() || numerator.gte(denominator)) {
9817
10438
  throw new Error(
@@ -9824,6 +10445,124 @@ function validateFeeFraction(numerator, denominator) {
9824
10445
 
9825
10446
 
9826
10447
 
10448
+
10449
+ // src/helpers/feeCodec.ts
10450
+
10451
+
10452
+ var cpAmmCoder = new (0, _anchor.BorshCoder)(cp_amm_default);
10453
+ function encodeFeeTimeSchedulerParams(cliffFeeNumerator, numberOfPeriod, periodFrequency, reductionFactor, baseFeeMode) {
10454
+ const feeTimeScheduler = {
10455
+ cliff_fee_numerator: new (0, _bnjs2.default)(cliffFeeNumerator.toString()),
10456
+ number_of_period: numberOfPeriod,
10457
+ period_frequency: new (0, _bnjs2.default)(periodFrequency.toString()),
10458
+ reduction_factor: new (0, _bnjs2.default)(reductionFactor.toString()),
10459
+ base_fee_mode: baseFeeMode,
10460
+ padding: FEE_PADDING
10461
+ };
10462
+ return cpAmmCoder.types.encode("BorshFeeTimeScheduler", feeTimeScheduler);
10463
+ }
10464
+ function decodeFeeTimeSchedulerParams(data) {
10465
+ const decoded = cpAmmCoder.types.decode("BorshFeeTimeScheduler", data);
10466
+ return {
10467
+ cliffFeeNumerator: decoded.cliff_fee_numerator,
10468
+ numberOfPeriod: decoded.number_of_period,
10469
+ periodFrequency: decoded.period_frequency,
10470
+ reductionFactor: decoded.reduction_factor,
10471
+ baseFeeMode: decoded.base_fee_mode,
10472
+ padding: decoded.padding
10473
+ };
10474
+ }
10475
+ function decodePodAlignedFeeTimeScheduler(data) {
10476
+ const decoded = cpAmmCoder.types.decode("PodAlignedFeeTimeScheduler", data);
10477
+ return {
10478
+ cliffFeeNumerator: decoded.cliff_fee_numerator,
10479
+ numberOfPeriod: decoded.number_of_period,
10480
+ periodFrequency: decoded.period_frequency,
10481
+ reductionFactor: decoded.reduction_factor,
10482
+ baseFeeMode: decoded.base_fee_mode,
10483
+ padding: decoded.padding
10484
+ };
10485
+ }
10486
+ function encodeFeeMarketCapSchedulerParams(cliffFeeNumerator, numberOfPeriod, sqrtPriceStepBps, schedulerExpirationDuration, reductionFactor, baseFeeMode) {
10487
+ const feeMarketCapScheduler = {
10488
+ cliff_fee_numerator: new (0, _bnjs2.default)(cliffFeeNumerator.toString()),
10489
+ number_of_period: numberOfPeriod,
10490
+ sqrt_price_step_bps: sqrtPriceStepBps,
10491
+ scheduler_expiration_duration: schedulerExpirationDuration,
10492
+ reduction_factor: new (0, _bnjs2.default)(reductionFactor.toString()),
10493
+ base_fee_mode: baseFeeMode,
10494
+ padding: FEE_PADDING
10495
+ };
10496
+ return cpAmmCoder.types.encode(
10497
+ "BorshFeeMarketCapScheduler",
10498
+ feeMarketCapScheduler
10499
+ );
10500
+ }
10501
+ function decodeFeeMarketCapSchedulerParams(data) {
10502
+ const decoded = cpAmmCoder.types.decode("BorshFeeMarketCapScheduler", data);
10503
+ return {
10504
+ cliffFeeNumerator: decoded.cliff_fee_numerator,
10505
+ numberOfPeriod: decoded.number_of_period,
10506
+ sqrtPriceStepBps: decoded.sqrt_price_step_bps,
10507
+ schedulerExpirationDuration: decoded.scheduler_expiration_duration,
10508
+ reductionFactor: decoded.reduction_factor,
10509
+ baseFeeMode: decoded.base_fee_mode,
10510
+ padding: decoded.padding
10511
+ };
10512
+ }
10513
+ function decodePodAlignedFeeMarketCapScheduler(data) {
10514
+ const decoded = cpAmmCoder.types.decode(
10515
+ "PodAlignedFeeMarketCapScheduler",
10516
+ data
10517
+ );
10518
+ return {
10519
+ cliffFeeNumerator: decoded.cliff_fee_numerator,
10520
+ numberOfPeriod: decoded.number_of_period,
10521
+ sqrtPriceStepBps: decoded.sqrt_price_step_bps,
10522
+ schedulerExpirationDuration: decoded.scheduler_expiration_duration,
10523
+ reductionFactor: decoded.reduction_factor,
10524
+ baseFeeMode: decoded.base_fee_mode,
10525
+ padding: decoded.padding
10526
+ };
10527
+ }
10528
+ function encodeFeeRateLimiterParams(cliffFeeNumerator, feeIncrementBps, maxLimiterDuration, maxFeeBps, referenceAmount) {
10529
+ const feeRateLimiter = {
10530
+ cliff_fee_numerator: new (0, _bnjs2.default)(cliffFeeNumerator.toString()),
10531
+ fee_increment_bps: feeIncrementBps,
10532
+ max_limiter_duration: maxLimiterDuration,
10533
+ max_fee_bps: maxFeeBps,
10534
+ reference_amount: new (0, _bnjs2.default)(referenceAmount.toString()),
10535
+ base_fee_mode: 2 /* RateLimiter */,
10536
+ padding: FEE_PADDING
10537
+ };
10538
+ return cpAmmCoder.types.encode("BorshFeeRateLimiter", feeRateLimiter);
10539
+ }
10540
+ function decodeFeeRateLimiterParams(data) {
10541
+ const decoded = cpAmmCoder.types.decode("BorshFeeRateLimiter", data);
10542
+ return {
10543
+ cliffFeeNumerator: decoded.cliff_fee_numerator,
10544
+ feeIncrementBps: decoded.fee_increment_bps,
10545
+ maxLimiterDuration: decoded.max_limiter_duration,
10546
+ maxFeeBps: decoded.max_fee_bps,
10547
+ referenceAmount: decoded.reference_amount,
10548
+ baseFeeMode: decoded.base_fee_mode,
10549
+ padding: decoded.padding
10550
+ };
10551
+ }
10552
+ function decodePodAlignedFeeRateLimiter(data) {
10553
+ const decoded = cpAmmCoder.types.decode("PodAlignedFeeRateLimiter", data);
10554
+ return {
10555
+ cliffFeeNumerator: decoded.cliff_fee_numerator,
10556
+ feeIncrementBps: decoded.fee_increment_bps,
10557
+ maxLimiterDuration: decoded.max_limiter_duration,
10558
+ maxFeeBps: decoded.max_fee_bps,
10559
+ referenceAmount: decoded.reference_amount,
10560
+ baseFeeMode: decoded.base_fee_mode,
10561
+ padding: decoded.padding
10562
+ };
10563
+ }
10564
+
10565
+ // src/helpers/common.ts
9827
10566
  function hasPartner(poolState) {
9828
10567
  return !poolState.partner.equals(_web3js.PublicKey.default);
9829
10568
  }
@@ -9875,17 +10614,20 @@ function convertToLamports(amount, tokenDecimal) {
9875
10614
  function fromDecimalToBN(value) {
9876
10615
  return new (0, _bnjs2.default)(value.floor().toFixed());
9877
10616
  }
9878
- function getFeeSchedulerParams(startingBaseFeeBps, endingBaseFeeBps, baseFeeMode, numberOfPeriod, totalDuration) {
10617
+ function getFeeTimeSchedulerParams(startingBaseFeeBps, endingBaseFeeBps, baseFeeMode, numberOfPeriod, totalDuration) {
9879
10618
  if (startingBaseFeeBps == endingBaseFeeBps) {
9880
10619
  if (numberOfPeriod != 0 || totalDuration != 0) {
9881
10620
  throw new Error("numberOfPeriod and totalDuration must both be zero");
9882
10621
  }
10622
+ const data2 = encodeFeeTimeSchedulerParams(
10623
+ bpsToFeeNumerator(startingBaseFeeBps),
10624
+ 0,
10625
+ new (0, _bnjs2.default)(0),
10626
+ new (0, _bnjs2.default)(0),
10627
+ 0 /* FeeTimeSchedulerLinear */
10628
+ );
9883
10629
  return {
9884
- cliffFeeNumerator: bpsToFeeNumerator(startingBaseFeeBps),
9885
- firstFactor: 0,
9886
- secondFactor: Array.from(new (0, _bnjs2.default)(0).toArrayLike(Buffer, "le", 8)),
9887
- thirdFactor: new (0, _bnjs2.default)(0),
9888
- baseFeeMode: 0 /* FeeSchedulerLinear */
10630
+ data: Array.from(data2)
9889
10631
  };
9890
10632
  }
9891
10633
  if (numberOfPeriod <= 0) {
@@ -9910,9 +10652,8 @@ function getFeeSchedulerParams(startingBaseFeeBps, endingBaseFeeBps, baseFeeMode
9910
10652
  const maxBaseFeeNumerator = bpsToFeeNumerator(startingBaseFeeBps);
9911
10653
  const minBaseFeeNumerator = bpsToFeeNumerator(endingBaseFeeBps);
9912
10654
  const periodFrequency = new (0, _bnjs2.default)(totalDuration / numberOfPeriod);
9913
- const secondFactor = convertToFeeSchedulerSecondFactor(periodFrequency);
9914
10655
  let reductionFactor;
9915
- if (baseFeeMode == 0 /* FeeSchedulerLinear */) {
10656
+ if (baseFeeMode == 0 /* FeeTimeSchedulerLinear */) {
9916
10657
  const totalReduction = maxBaseFeeNumerator.sub(minBaseFeeNumerator);
9917
10658
  reductionFactor = totalReduction.divn(numberOfPeriod);
9918
10659
  } else {
@@ -9920,12 +10661,58 @@ function getFeeSchedulerParams(startingBaseFeeBps, endingBaseFeeBps, baseFeeMode
9920
10661
  const decayBase = Math.pow(ratio, 1 / numberOfPeriod);
9921
10662
  reductionFactor = new (0, _bnjs2.default)(BASIS_POINT_MAX * (1 - decayBase));
9922
10663
  }
10664
+ const data = encodeFeeTimeSchedulerParams(
10665
+ maxBaseFeeNumerator,
10666
+ numberOfPeriod,
10667
+ periodFrequency,
10668
+ reductionFactor,
10669
+ baseFeeMode
10670
+ );
9923
10671
  return {
9924
- cliffFeeNumerator: maxBaseFeeNumerator,
9925
- firstFactor: numberOfPeriod,
9926
- secondFactor,
9927
- thirdFactor: reductionFactor,
10672
+ data: Array.from(data)
10673
+ };
10674
+ }
10675
+ function getFeeMarketCapSchedulerParams(startingBaseFeeBps, endingBaseFeeBps, baseFeeMode, numberOfPeriod, sqrtPriceStepBps, schedulerExpirationDuration) {
10676
+ if (numberOfPeriod <= 0) {
10677
+ throw new Error("Total periods must be greater than zero");
10678
+ }
10679
+ const poolMaxFeeBps = getMaxFeeBps(CURRENT_POOL_VERSION);
10680
+ if (startingBaseFeeBps <= endingBaseFeeBps) {
10681
+ throw new Error(
10682
+ `startingBaseFeeBps (${startingBaseFeeBps} bps) must be greater than endingBaseFeeBps (${endingBaseFeeBps} bps)`
10683
+ );
10684
+ }
10685
+ if (startingBaseFeeBps > poolMaxFeeBps) {
10686
+ throw new Error(
10687
+ `startingBaseFeeBps (${startingBaseFeeBps} bps) exceeds maximum allowed value of ${poolMaxFeeBps} bps`
10688
+ );
10689
+ }
10690
+ if (numberOfPeriod == 0 || sqrtPriceStepBps == 0 || schedulerExpirationDuration == 0) {
10691
+ throw new Error(
10692
+ "numberOfPeriod, sqrtPriceStepBps, and schedulerExpirationDuration must be greater than zero"
10693
+ );
10694
+ }
10695
+ const maxBaseFeeNumerator = bpsToFeeNumerator(startingBaseFeeBps);
10696
+ const minBaseFeeNumerator = bpsToFeeNumerator(endingBaseFeeBps);
10697
+ let reductionFactor;
10698
+ if (baseFeeMode == 3 /* FeeMarketCapSchedulerLinear */) {
10699
+ const totalReduction = maxBaseFeeNumerator.sub(minBaseFeeNumerator);
10700
+ reductionFactor = totalReduction.divn(numberOfPeriod);
10701
+ } else {
10702
+ const ratio = minBaseFeeNumerator.toNumber() / maxBaseFeeNumerator.toNumber();
10703
+ const decayBase = Math.pow(ratio, 1 / numberOfPeriod);
10704
+ reductionFactor = new (0, _bnjs2.default)(BASIS_POINT_MAX * (1 - decayBase));
10705
+ }
10706
+ const data = encodeFeeMarketCapSchedulerParams(
10707
+ maxBaseFeeNumerator,
10708
+ numberOfPeriod,
10709
+ sqrtPriceStepBps,
10710
+ schedulerExpirationDuration,
10711
+ reductionFactor,
9928
10712
  baseFeeMode
10713
+ );
10714
+ return {
10715
+ data: Array.from(data)
9929
10716
  };
9930
10717
  }
9931
10718
  function getRateLimiterParams(baseFeeBps, feeIncrementBps, referenceAmount, maxLimiterDuration, maxFeeBps, tokenBDecimal, activationType) {
@@ -9974,55 +10761,83 @@ function getRateLimiterParams(baseFeeBps, feeIncrementBps, referenceAmount, maxL
9974
10761
  referenceAmount,
9975
10762
  tokenBDecimal
9976
10763
  );
9977
- const secondFactor = convertToRateLimiterSecondFactor(
9978
- new (0, _bnjs2.default)(maxLimiterDuration),
9979
- new (0, _bnjs2.default)(maxFeeBps)
10764
+ const data = encodeFeeRateLimiterParams(
10765
+ cliffFeeNumerator,
10766
+ feeIncrementBps,
10767
+ maxLimiterDuration,
10768
+ maxFeeBps,
10769
+ referenceAmountInLamports
9980
10770
  );
9981
10771
  return {
9982
- cliffFeeNumerator,
9983
- firstFactor: feeIncrementBps,
9984
- secondFactor,
9985
- thirdFactor: new (0, _bnjs2.default)(referenceAmountInLamports),
9986
- baseFeeMode: 2 /* RateLimiter */
10772
+ data: Array.from(data)
9987
10773
  };
9988
10774
  }
9989
10775
  function getBaseFeeParams(baseFeeParams, tokenBDecimal, activationType) {
9990
- if (baseFeeParams.baseFeeMode === 2 /* RateLimiter */) {
9991
- if (!baseFeeParams.rateLimiterParam) {
9992
- throw new Error(
9993
- "Rate limiter parameters are required for RateLimiter mode"
10776
+ switch (baseFeeParams.baseFeeMode) {
10777
+ case 0 /* FeeTimeSchedulerLinear */:
10778
+ case 1 /* FeeTimeSchedulerExponential */: {
10779
+ if (!baseFeeParams.feeTimeSchedulerParam) {
10780
+ throw new Error(
10781
+ "Fee scheduler parameters are required for FeeTimeScheduler mode"
10782
+ );
10783
+ }
10784
+ const { startingFeeBps, endingFeeBps, numberOfPeriod, totalDuration } = baseFeeParams.feeTimeSchedulerParam;
10785
+ return getFeeTimeSchedulerParams(
10786
+ startingFeeBps,
10787
+ endingFeeBps,
10788
+ baseFeeParams.baseFeeMode,
10789
+ numberOfPeriod,
10790
+ totalDuration
9994
10791
  );
9995
10792
  }
9996
- const {
9997
- baseFeeBps,
9998
- feeIncrementBps,
9999
- referenceAmount,
10000
- maxLimiterDuration,
10001
- maxFeeBps
10002
- } = baseFeeParams.rateLimiterParam;
10003
- return getRateLimiterParams(
10004
- baseFeeBps,
10005
- feeIncrementBps,
10006
- referenceAmount,
10007
- maxLimiterDuration,
10008
- maxFeeBps,
10009
- tokenBDecimal,
10010
- activationType
10011
- );
10012
- } else {
10013
- if (!baseFeeParams.feeSchedulerParam) {
10014
- throw new Error(
10015
- "Fee scheduler parameters are required for FeeScheduler mode"
10793
+ case 2 /* RateLimiter */: {
10794
+ if (!baseFeeParams.rateLimiterParam) {
10795
+ throw new Error(
10796
+ "Rate limiter parameters are required for RateLimiter mode"
10797
+ );
10798
+ }
10799
+ const {
10800
+ baseFeeBps,
10801
+ feeIncrementBps,
10802
+ referenceAmount,
10803
+ maxLimiterDuration,
10804
+ maxFeeBps
10805
+ } = baseFeeParams.rateLimiterParam;
10806
+ return getRateLimiterParams(
10807
+ baseFeeBps,
10808
+ feeIncrementBps,
10809
+ referenceAmount,
10810
+ maxLimiterDuration,
10811
+ maxFeeBps,
10812
+ tokenBDecimal,
10813
+ activationType
10016
10814
  );
10017
10815
  }
10018
- const { startingFeeBps, endingFeeBps, numberOfPeriod, totalDuration } = baseFeeParams.feeSchedulerParam;
10019
- return getFeeSchedulerParams(
10020
- startingFeeBps,
10021
- endingFeeBps,
10022
- baseFeeParams.baseFeeMode,
10023
- numberOfPeriod,
10024
- totalDuration
10025
- );
10816
+ case 3 /* FeeMarketCapSchedulerLinear */:
10817
+ case 4 /* FeeMarketCapSchedulerExponential */: {
10818
+ if (!baseFeeParams.feeMarketCapSchedulerParam) {
10819
+ throw new Error(
10820
+ "Fee scheduler parameters are required for FeeMarketCapScheduler mode"
10821
+ );
10822
+ }
10823
+ const {
10824
+ startingFeeBps,
10825
+ endingFeeBps,
10826
+ numberOfPeriod,
10827
+ sqrtPriceStepBps,
10828
+ schedulerExpirationDuration
10829
+ } = baseFeeParams.feeMarketCapSchedulerParam;
10830
+ return getFeeMarketCapSchedulerParams(
10831
+ startingFeeBps,
10832
+ endingFeeBps,
10833
+ baseFeeParams.baseFeeMode,
10834
+ numberOfPeriod,
10835
+ sqrtPriceStepBps,
10836
+ schedulerExpirationDuration
10837
+ );
10838
+ }
10839
+ default:
10840
+ throw new Error("Invalid base fee mode");
10026
10841
  }
10027
10842
  }
10028
10843
  function getDynamicFeeParams(baseFeeBps, maxPriceChangeBps = MAX_PRICE_CHANGE_BPS_DEFAULT) {
@@ -10545,9 +11360,7 @@ var CpAmm = class {
10545
11360
  */
10546
11361
  fetchConfigState(config) {
10547
11362
  return __async(this, null, function* () {
10548
- const configState = yield this._program.account.config.fetchNullable(
10549
- config
10550
- );
11363
+ const configState = yield this._program.account.config.fetchNullable(config);
10551
11364
  _invariant2.default.call(void 0, configState, `Config account: ${config} not found`);
10552
11365
  return configState;
10553
11366
  });
@@ -10576,6 +11389,36 @@ var CpAmm = class {
10576
11389
  return pools;
10577
11390
  });
10578
11391
  }
11392
+ fetchPoolFees(pool) {
11393
+ return __async(this, null, function* () {
11394
+ const poolState = yield this._program.account.pool.fetchNullable(pool);
11395
+ if (!poolState) {
11396
+ throw new Error(`Pool account: ${pool} not found`);
11397
+ }
11398
+ const data = Buffer.from(poolState.poolFees.baseFee.baseFeeInfo.data);
11399
+ const modeIndex = data.readUInt8(8);
11400
+ const baseFeeMode = modeIndex;
11401
+ switch (baseFeeMode) {
11402
+ case 0 /* FeeTimeSchedulerLinear */:
11403
+ case 1 /* FeeTimeSchedulerExponential */: {
11404
+ const poolFees = decodePodAlignedFeeTimeScheduler(data);
11405
+ return poolFees;
11406
+ }
11407
+ case 2 /* RateLimiter */: {
11408
+ const poolFees = decodePodAlignedFeeRateLimiter(data);
11409
+ return poolFees;
11410
+ }
11411
+ case 3 /* FeeMarketCapSchedulerLinear */:
11412
+ case 4 /* FeeMarketCapSchedulerExponential */: {
11413
+ const poolFees = decodePodAlignedFeeMarketCapScheduler(data);
11414
+ return poolFees;
11415
+ }
11416
+ default: {
11417
+ throw new Error(`Invalid base fee mode: ${baseFeeMode}`);
11418
+ }
11419
+ }
11420
+ });
11421
+ }
10579
11422
  /**
10580
11423
  * Fetches the Position state.
10581
11424
  * @param position - Public key of the position.
@@ -10583,13 +11426,56 @@ var CpAmm = class {
10583
11426
  */
10584
11427
  fetchPositionState(position) {
10585
11428
  return __async(this, null, function* () {
10586
- const positionState = yield this._program.account.position.fetchNullable(
10587
- position
10588
- );
11429
+ const positionState = yield this._program.account.position.fetchNullable(position);
10589
11430
  _invariant2.default.call(void 0, positionState, `Position account: ${position} not found`);
10590
11431
  return positionState;
10591
11432
  });
10592
11433
  }
11434
+ /**
11435
+ * Fetches multiple Config states.
11436
+ * @param configs - Array of public keys of config accounts.
11437
+ * @returns Array of parsed ConfigState.
11438
+ */
11439
+ getMultipleConfigs(configs) {
11440
+ return __async(this, null, function* () {
11441
+ const configStates = yield this._program.account.config.fetchMultiple(configs);
11442
+ configStates.forEach((configState, index) => {
11443
+ _invariant2.default.call(void 0, configState, `Config account: ${configs[index]} not found`);
11444
+ });
11445
+ return configStates;
11446
+ });
11447
+ }
11448
+ /**
11449
+ * Fetches multiple Pool states.
11450
+ * @param pools - Array of public keys of pool accounts.
11451
+ * @returns Array of parsed PoolState.
11452
+ */
11453
+ getMultiplePools(pools) {
11454
+ return __async(this, null, function* () {
11455
+ const poolStates = yield this._program.account.pool.fetchMultiple(pools);
11456
+ poolStates.forEach((poolState, index) => {
11457
+ _invariant2.default.call(void 0, poolState, `Pool account: ${pools[index]} not found`);
11458
+ });
11459
+ return poolStates;
11460
+ });
11461
+ }
11462
+ /**
11463
+ * Fetches multiple Position states.
11464
+ * @param positions - Array of public keys of position accounts.
11465
+ * @returns Array of parsed PositionState.
11466
+ */
11467
+ getMultiplePositions(positions) {
11468
+ return __async(this, null, function* () {
11469
+ const positionStates = yield this._program.account.position.fetchMultiple(positions);
11470
+ positionStates.forEach((positionState, index) => {
11471
+ _invariant2.default.call(void 0,
11472
+ positionState,
11473
+ `Position account: ${positions[index]} not found`
11474
+ );
11475
+ });
11476
+ return positionStates;
11477
+ });
11478
+ }
10593
11479
  /**
10594
11480
  * Retrieves all config accounts.
10595
11481
  * @returns Array of config public keys and their states.
@@ -10663,9 +11549,7 @@ var CpAmm = class {
10663
11549
  const positionAddresses = userPositionAccounts.map(
10664
11550
  (account) => derivePositionAddress(account.positionNft)
10665
11551
  );
10666
- const positionStates = yield this._program.account.position.fetchMultiple(
10667
- positionAddresses
10668
- );
11552
+ const positionStates = yield this._program.account.position.fetchMultiple(positionAddresses);
10669
11553
  const positionResult = userPositionAccounts.map((account, index) => {
10670
11554
  const positionState = positionStates[index];
10671
11555
  if (!positionState) return null;
@@ -11738,7 +12622,8 @@ var CpAmm = class {
11738
12622
  tokenBMint,
11739
12623
  tokenAProgram,
11740
12624
  tokenBProgram,
11741
- referralTokenAccount
12625
+ referralTokenAccount,
12626
+ receiver
11742
12627
  } = params;
11743
12628
  const [inputTokenProgram, outputTokenProgram] = inputTokenMint.equals(
11744
12629
  tokenAMint
@@ -11750,8 +12635,8 @@ var CpAmm = class {
11750
12635
  instructions: preInstructions
11751
12636
  } = yield this.prepareTokenAccounts({
11752
12637
  payer,
11753
- tokenAOwner: payer,
11754
- tokenBOwner: payer,
12638
+ tokenAOwner: receiver != null ? receiver : payer,
12639
+ tokenBOwner: receiver != null ? receiver : payer,
11755
12640
  tokenAMint: inputTokenMint,
11756
12641
  tokenBMint: outputTokenMint,
11757
12642
  tokenAProgram: inputTokenProgram,
@@ -11759,7 +12644,7 @@ var CpAmm = class {
11759
12644
  });
11760
12645
  if (inputTokenMint.equals(_spltoken.NATIVE_MINT)) {
11761
12646
  const wrapSOLIx = wrapSOLInstruction(
11762
- payer,
12647
+ receiver != null ? receiver : payer,
11763
12648
  inputTokenAccount,
11764
12649
  BigInt(amountIn.toString())
11765
12650
  );
@@ -11769,25 +12654,26 @@ var CpAmm = class {
11769
12654
  if ([tokenAMint.toBase58(), tokenBMint.toBase58()].includes(
11770
12655
  _spltoken.NATIVE_MINT.toBase58()
11771
12656
  )) {
11772
- const closeWrappedSOLIx = yield unwrapSOLInstruction(payer);
12657
+ const closeWrappedSOLIx = yield unwrapSOLInstruction(receiver != null ? receiver : payer);
11773
12658
  closeWrappedSOLIx && postInstructions.push(closeWrappedSOLIx);
11774
12659
  }
11775
12660
  let { poolState } = params;
11776
12661
  poolState = poolState != null ? poolState : yield this.fetchPoolState(pool);
11777
- const { maxLimiterDuration, maxFeeBps } = parseRateLimiterSecondFactor(
11778
- poolState.poolFees.baseFee.secondFactor
11779
- );
12662
+ const data = Buffer.from(poolState.poolFees.baseFee.baseFeeInfo.data);
12663
+ const modeIndex = data.readUInt8(8);
12664
+ const baseFeeMode = modeIndex;
11780
12665
  let rateLimiterApplied = false;
11781
- if (poolState.poolFees.baseFee.baseFeeMode === 2 /* RateLimiter */) {
12666
+ if (baseFeeMode === 2 /* RateLimiter */) {
11782
12667
  const currentPoint = yield getCurrentPoint(
11783
12668
  this._program.provider.connection,
11784
12669
  poolState.activationType
11785
12670
  );
12671
+ const rateLimiterPoolFees = decodePodAlignedFeeRateLimiter(data);
11786
12672
  rateLimiterApplied = isRateLimiterApplied(
11787
- poolState.poolFees.baseFee.thirdFactor,
11788
- maxLimiterDuration,
11789
- maxFeeBps,
11790
- poolState.poolFees.baseFee.firstFactor,
12673
+ rateLimiterPoolFees.referenceAmount,
12674
+ rateLimiterPoolFees.maxLimiterDuration,
12675
+ rateLimiterPoolFees.maxFeeBps,
12676
+ rateLimiterPoolFees.feeIncrementBps,
11791
12677
  currentPoint,
11792
12678
  poolState.activationPoint,
11793
12679
  tradeDirection
@@ -11806,7 +12692,7 @@ var CpAmm = class {
11806
12692
  }).accountsPartial({
11807
12693
  poolAuthority: this.poolAuthority,
11808
12694
  pool,
11809
- payer,
12695
+ payer: receiver != null ? receiver : payer,
11810
12696
  inputTokenAccount,
11811
12697
  outputTokenAccount,
11812
12698
  tokenAVault,
@@ -11838,7 +12724,8 @@ var CpAmm = class {
11838
12724
  tokenAProgram,
11839
12725
  tokenBProgram,
11840
12726
  referralTokenAccount,
11841
- swapMode
12727
+ swapMode,
12728
+ receiver
11842
12729
  } = params;
11843
12730
  const [inputTokenProgram, outputTokenProgram] = inputTokenMint.equals(
11844
12731
  tokenAMint
@@ -11850,8 +12737,8 @@ var CpAmm = class {
11850
12737
  instructions: preInstructions
11851
12738
  } = yield this.prepareTokenAccounts({
11852
12739
  payer,
11853
- tokenAOwner: payer,
11854
- tokenBOwner: payer,
12740
+ tokenAOwner: receiver != null ? receiver : payer,
12741
+ tokenBOwner: receiver != null ? receiver : payer,
11855
12742
  tokenAMint: inputTokenMint,
11856
12743
  tokenBMint: outputTokenMint,
11857
12744
  tokenAProgram: inputTokenProgram,
@@ -11869,7 +12756,7 @@ var CpAmm = class {
11869
12756
  if (inputTokenMint.equals(_spltoken.NATIVE_MINT)) {
11870
12757
  const amount = swapMode === 0 /* ExactIn */ || swapMode === 1 /* PartialFill */ ? amount0 : amount1;
11871
12758
  const wrapSOLIx = wrapSOLInstruction(
11872
- payer,
12759
+ receiver != null ? receiver : payer,
11873
12760
  inputTokenAccount,
11874
12761
  BigInt(amount.toString())
11875
12762
  );
@@ -11879,25 +12766,26 @@ var CpAmm = class {
11879
12766
  if ([tokenAMint.toBase58(), tokenBMint.toBase58()].includes(
11880
12767
  _spltoken.NATIVE_MINT.toBase58()
11881
12768
  )) {
11882
- const closeWrappedSOLIx = yield unwrapSOLInstruction(payer);
12769
+ const closeWrappedSOLIx = yield unwrapSOLInstruction(receiver != null ? receiver : payer);
11883
12770
  closeWrappedSOLIx && postInstructions.push(closeWrappedSOLIx);
11884
12771
  }
11885
12772
  let { poolState } = params;
11886
12773
  poolState = poolState != null ? poolState : yield this.fetchPoolState(pool);
11887
- const { maxLimiterDuration, maxFeeBps } = parseRateLimiterSecondFactor(
11888
- poolState.poolFees.baseFee.secondFactor
11889
- );
12774
+ const data = Buffer.from(poolState.poolFees.baseFee.baseFeeInfo.data);
12775
+ const modeIndex = data.readUInt8(8);
12776
+ const baseFeeMode = modeIndex;
11890
12777
  let rateLimiterApplied = false;
11891
- if (poolState.poolFees.baseFee.baseFeeMode === 2 /* RateLimiter */) {
12778
+ if (baseFeeMode === 2 /* RateLimiter */) {
11892
12779
  const currentPoint = yield getCurrentPoint(
11893
12780
  this._program.provider.connection,
11894
12781
  poolState.activationType
11895
12782
  );
12783
+ const rateLimiterPoolFees = decodePodAlignedFeeRateLimiter(data);
11896
12784
  rateLimiterApplied = isRateLimiterApplied(
11897
- poolState.poolFees.baseFee.thirdFactor,
11898
- maxLimiterDuration,
11899
- maxFeeBps,
11900
- poolState.poolFees.baseFee.firstFactor,
12785
+ rateLimiterPoolFees.referenceAmount,
12786
+ rateLimiterPoolFees.maxLimiterDuration,
12787
+ rateLimiterPoolFees.maxFeeBps,
12788
+ rateLimiterPoolFees.feeIncrementBps,
11901
12789
  currentPoint,
11902
12790
  poolState.activationPoint,
11903
12791
  tradeDirection
@@ -11917,7 +12805,7 @@ var CpAmm = class {
11917
12805
  }).accountsPartial({
11918
12806
  poolAuthority: this.poolAuthority,
11919
12807
  pool,
11920
- payer,
12808
+ payer: receiver != null ? receiver : payer,
11921
12809
  inputTokenAccount,
11922
12810
  outputTokenAccount,
11923
12811
  tokenAVault,
@@ -12880,5 +13768,28 @@ var CpAmm = class {
12880
13768
 
12881
13769
 
12882
13770
 
12883
- exports.ActivationPoint = ActivationPoint; exports.ActivationType = ActivationType; exports.BASIS_POINT_MAX = BASIS_POINT_MAX; exports.BIN_STEP_BPS_DEFAULT = BIN_STEP_BPS_DEFAULT; exports.BIN_STEP_BPS_U128_DEFAULT = BIN_STEP_BPS_U128_DEFAULT; exports.BaseFeeMode = BaseFeeMode; exports.CP_AMM_PROGRAM_ID = CP_AMM_PROGRAM_ID; exports.CURRENT_POOL_VERSION = CURRENT_POOL_VERSION; exports.CollectFeeMode = CollectFeeMode; exports.CpAmm = CpAmm; exports.CpAmmIdl = cp_amm_default; exports.DYNAMIC_FEE_DECAY_PERIOD_DEFAULT = DYNAMIC_FEE_DECAY_PERIOD_DEFAULT; exports.DYNAMIC_FEE_FILTER_PERIOD_DEFAULT = DYNAMIC_FEE_FILTER_PERIOD_DEFAULT; exports.DYNAMIC_FEE_REDUCTION_FACTOR_DEFAULT = DYNAMIC_FEE_REDUCTION_FACTOR_DEFAULT; exports.DYNAMIC_FEE_ROUNDING_OFFSET = DYNAMIC_FEE_ROUNDING_OFFSET; exports.DYNAMIC_FEE_SCALING_FACTOR = DYNAMIC_FEE_SCALING_FACTOR; exports.FEE_DENOMINATOR = FEE_DENOMINATOR; exports.FeeRateLimiter = FeeRateLimiter; exports.FeeScheduler = FeeScheduler; exports.LIQUIDITY_SCALE = LIQUIDITY_SCALE; exports.MAX = MAX; exports.MAX_CU_BUFFER = MAX_CU_BUFFER; exports.MAX_EXPONENTIAL = MAX_EXPONENTIAL; exports.MAX_FEE_BPS_V0 = MAX_FEE_BPS_V0; exports.MAX_FEE_BPS_V1 = MAX_FEE_BPS_V1; exports.MAX_FEE_NUMERATOR_V0 = MAX_FEE_NUMERATOR_V0; exports.MAX_FEE_NUMERATOR_V1 = MAX_FEE_NUMERATOR_V1; exports.MAX_PRICE_CHANGE_BPS_DEFAULT = MAX_PRICE_CHANGE_BPS_DEFAULT; exports.MAX_RATE_LIMITER_DURATION_IN_SECONDS = MAX_RATE_LIMITER_DURATION_IN_SECONDS; exports.MAX_RATE_LIMITER_DURATION_IN_SLOTS = MAX_RATE_LIMITER_DURATION_IN_SLOTS; exports.MAX_SQRT_PRICE = MAX_SQRT_PRICE; exports.MIN_CU_BUFFER = MIN_CU_BUFFER; exports.MIN_FEE_BPS = MIN_FEE_BPS; exports.MIN_FEE_NUMERATOR = MIN_FEE_NUMERATOR; exports.MIN_SQRT_PRICE = MIN_SQRT_PRICE; exports.ONE_Q64 = ONE_Q64; exports.PoolStatus = PoolStatus; exports.PoolVersion = PoolVersion; exports.Rounding = Rounding; exports.SCALE_OFFSET = SCALE_OFFSET; exports.SPLIT_POSITION_DENOMINATOR = SPLIT_POSITION_DENOMINATOR; exports.SwapMode = SwapMode; exports.TradeDirection = TradeDirection; exports.U128_MAX = U128_MAX; exports.U16_MAX = U16_MAX; exports.U64_MAX = U64_MAX; exports.bpsToFeeNumerator = bpsToFeeNumerator; exports.calculateAtoBFromAmountIn = calculateAtoBFromAmountIn; exports.calculateAtoBFromAmountOut = calculateAtoBFromAmountOut; exports.calculateAtoBFromPartialAmountIn = calculateAtoBFromPartialAmountIn; exports.calculateBtoAFromAmountIn = calculateBtoAFromAmountIn; exports.calculateBtoAFromAmountOut = calculateBtoAFromAmountOut; exports.calculateBtoAFromPartialAmountIn = calculateBtoAFromPartialAmountIn; exports.calculateInitSqrtPrice = calculateInitSqrtPrice; exports.calculateTransferFeeExcludedAmount = calculateTransferFeeExcludedAmount; exports.calculateTransferFeeIncludedAmount = calculateTransferFeeIncludedAmount; exports.convertToFeeSchedulerSecondFactor = convertToFeeSchedulerSecondFactor; exports.convertToLamports = convertToLamports; exports.convertToRateLimiterSecondFactor = convertToRateLimiterSecondFactor; exports.decimalToQ64 = decimalToQ64; exports.deriveClaimFeeOperatorAddress = deriveClaimFeeOperatorAddress; exports.deriveConfigAddress = deriveConfigAddress; exports.deriveCustomizablePoolAddress = deriveCustomizablePoolAddress; exports.derivePoolAddress = derivePoolAddress; exports.derivePoolAuthority = derivePoolAuthority; exports.derivePositionAddress = derivePositionAddress; exports.derivePositionNftAccount = derivePositionNftAccount; exports.deriveRewardVaultAddress = deriveRewardVaultAddress; exports.deriveTokenBadgeAddress = deriveTokenBadgeAddress; exports.deriveTokenVaultAddress = deriveTokenVaultAddress; exports.feeNumeratorToBps = feeNumeratorToBps; exports.fromDecimalToBN = fromDecimalToBN; exports.getAllPositionNftAccountByOwner = getAllPositionNftAccountByOwner; exports.getAllUserPositionNftAccount = getAllUserPositionNftAccount; exports.getAmountAFromLiquidityDelta = getAmountAFromLiquidityDelta; exports.getAmountBFromLiquidityDelta = getAmountBFromLiquidityDelta; exports.getAmountWithSlippage = getAmountWithSlippage; exports.getAvailableVestingLiquidity = getAvailableVestingLiquidity; exports.getBaseFeeHandler = getBaseFeeHandler; exports.getBaseFeeNumerator = getBaseFeeNumerator; exports.getBaseFeeNumeratorByPeriod = getBaseFeeNumeratorByPeriod; exports.getBaseFeeParams = getBaseFeeParams; exports.getCheckedAmounts = getCheckedAmounts; exports.getCurrentPoint = getCurrentPoint; exports.getDynamicFeeNumerator = getDynamicFeeNumerator; exports.getDynamicFeeParams = getDynamicFeeParams; exports.getEstimatedComputeUnitIxWithBuffer = getEstimatedComputeUnitIxWithBuffer; exports.getEstimatedComputeUnitUsageWithBuffer = getEstimatedComputeUnitUsageWithBuffer; exports.getExcludedFeeAmount = getExcludedFeeAmount; exports.getExcludedFeeAmountFromIncludedFeeAmount = getExcludedFeeAmountFromIncludedFeeAmount; exports.getFeeInPeriod = getFeeInPeriod; exports.getFeeMode = getFeeMode; exports.getFeeNumeratorFromExcludedFeeAmount = getFeeNumeratorFromExcludedFeeAmount; exports.getFeeNumeratorFromIncludedFeeAmount = getFeeNumeratorFromIncludedFeeAmount; exports.getFeeNumeratorOnExponentialFeeScheduler = getFeeNumeratorOnExponentialFeeScheduler; exports.getFeeNumeratorOnLinearFeeScheduler = getFeeNumeratorOnLinearFeeScheduler; exports.getFeeOnAmount = getFeeOnAmount; exports.getFeeSchedulerParams = getFeeSchedulerParams; exports.getFirstKey = getFirstKey; exports.getIncludedFeeAmount = getIncludedFeeAmount; exports.getLiquidityDeltaFromAmountA = getLiquidityDeltaFromAmountA; exports.getLiquidityDeltaFromAmountB = getLiquidityDeltaFromAmountB; exports.getMaxAmountWithSlippage = getMaxAmountWithSlippage; exports.getMaxBaseFeeNumerator = getMaxBaseFeeNumerator; exports.getMaxFeeBps = getMaxFeeBps; exports.getMaxFeeNumerator = getMaxFeeNumerator; exports.getMaxIndex = getMaxIndex; exports.getMinBaseFeeNumerator = getMinBaseFeeNumerator; exports.getNextSqrtPriceFromAmountInARoundingUp = getNextSqrtPriceFromAmountInARoundingUp; exports.getNextSqrtPriceFromAmountInBRoundingDown = getNextSqrtPriceFromAmountInBRoundingDown; exports.getNextSqrtPriceFromAmountOutARoundingUp = getNextSqrtPriceFromAmountOutARoundingUp; exports.getNextSqrtPriceFromAmountOutBRoundingDown = getNextSqrtPriceFromAmountOutBRoundingDown; exports.getNextSqrtPriceFromInput = getNextSqrtPriceFromInput; exports.getNextSqrtPriceFromOutput = getNextSqrtPriceFromOutput; exports.getOrCreateATAInstruction = getOrCreateATAInstruction; exports.getPriceChange = getPriceChange; exports.getPriceFromSqrtPrice = getPriceFromSqrtPrice; exports.getPriceImpact = getPriceImpact; exports.getRateLimiterParams = getRateLimiterParams; exports.getRewardInfo = getRewardInfo; exports.getSecondKey = getSecondKey; exports.getSimulationComputeUnits = getSimulationComputeUnits; exports.getSqrtPriceFromPrice = getSqrtPriceFromPrice; exports.getSwapResultFromExactInput = getSwapResultFromExactInput; exports.getSwapResultFromExactOutput = getSwapResultFromExactOutput; exports.getSwapResultFromPartialInput = getSwapResultFromPartialInput; exports.getTokenDecimals = getTokenDecimals; exports.getTokenProgram = getTokenProgram; exports.getTotalFeeNumerator = getTotalFeeNumerator; exports.getTotalLockedLiquidity = getTotalLockedLiquidity; exports.getTotalTradingFeeFromExcludedFeeAmount = getTotalTradingFeeFromExcludedFeeAmount; exports.getTotalTradingFeeFromIncludedFeeAmount = getTotalTradingFeeFromIncludedFeeAmount; exports.getUnClaimLpFee = getUnClaimLpFee; exports.getUserRewardPending = getUserRewardPending; exports.hasPartner = hasPartner; exports.isDynamicFeeEnabled = isDynamicFeeEnabled; exports.isNonZeroRateLimiter = isNonZeroRateLimiter; exports.isRateLimiterApplied = isRateLimiterApplied; exports.isSwapEnabled = isSwapEnabled; exports.isVestingComplete = isVestingComplete; exports.isZeroRateLimiter = isZeroRateLimiter; exports.mulDiv = mulDiv; exports.offsetBasedFilter = offsetBasedFilter; exports.parseFeeSchedulerSecondFactor = parseFeeSchedulerSecondFactor; exports.parseRateLimiterSecondFactor = parseRateLimiterSecondFactor; exports.positionByPoolFilter = positionByPoolFilter; exports.pow = pow; exports.q64ToDecimal = q64ToDecimal; exports.splitFees = splitFees; exports.sqrt = sqrt; exports.swapQuoteExactInput = swapQuoteExactInput; exports.swapQuoteExactOutput = swapQuoteExactOutput; exports.swapQuotePartialInput = swapQuotePartialInput; exports.toNumerator = toNumerator; exports.unwrapSOLInstruction = unwrapSOLInstruction; exports.validateFeeFraction = validateFeeFraction; exports.validateFeeRateLimiter = validateFeeRateLimiter; exports.validateFeeScheduler = validateFeeScheduler; exports.vestingByPositionFilter = vestingByPositionFilter; exports.wrapSOLInstruction = wrapSOLInstruction;
13771
+
13772
+
13773
+
13774
+
13775
+
13776
+
13777
+
13778
+
13779
+
13780
+
13781
+
13782
+
13783
+
13784
+
13785
+
13786
+
13787
+
13788
+
13789
+
13790
+
13791
+
13792
+
13793
+
13794
+ exports.ActivationPoint = ActivationPoint; exports.ActivationType = ActivationType; exports.BASIS_POINT_MAX = BASIS_POINT_MAX; exports.BIN_STEP_BPS_DEFAULT = BIN_STEP_BPS_DEFAULT; exports.BIN_STEP_BPS_U128_DEFAULT = BIN_STEP_BPS_U128_DEFAULT; exports.BaseFeeMode = BaseFeeMode; exports.CP_AMM_PROGRAM_ID = CP_AMM_PROGRAM_ID; exports.CURRENT_POOL_VERSION = CURRENT_POOL_VERSION; exports.CollectFeeMode = CollectFeeMode; exports.CpAmm = CpAmm; exports.CpAmmIdl = cp_amm_default; exports.DYNAMIC_FEE_DECAY_PERIOD_DEFAULT = DYNAMIC_FEE_DECAY_PERIOD_DEFAULT; exports.DYNAMIC_FEE_FILTER_PERIOD_DEFAULT = DYNAMIC_FEE_FILTER_PERIOD_DEFAULT; exports.DYNAMIC_FEE_REDUCTION_FACTOR_DEFAULT = DYNAMIC_FEE_REDUCTION_FACTOR_DEFAULT; exports.DYNAMIC_FEE_ROUNDING_OFFSET = DYNAMIC_FEE_ROUNDING_OFFSET; exports.DYNAMIC_FEE_SCALING_FACTOR = DYNAMIC_FEE_SCALING_FACTOR; exports.FEE_DENOMINATOR = FEE_DENOMINATOR; exports.FEE_PADDING = FEE_PADDING; exports.FeeMarketCapScheduler = FeeMarketCapScheduler; exports.FeeRateLimiter = FeeRateLimiter; exports.FeeTimeScheduler = FeeTimeScheduler; exports.LIQUIDITY_SCALE = LIQUIDITY_SCALE; exports.MAX = MAX; exports.MAX_CU_BUFFER = MAX_CU_BUFFER; exports.MAX_EXPONENTIAL = MAX_EXPONENTIAL; exports.MAX_FEE_BPS_V0 = MAX_FEE_BPS_V0; exports.MAX_FEE_BPS_V1 = MAX_FEE_BPS_V1; exports.MAX_FEE_NUMERATOR_V0 = MAX_FEE_NUMERATOR_V0; exports.MAX_FEE_NUMERATOR_V1 = MAX_FEE_NUMERATOR_V1; exports.MAX_PRICE_CHANGE_BPS_DEFAULT = MAX_PRICE_CHANGE_BPS_DEFAULT; exports.MAX_RATE_LIMITER_DURATION_IN_SECONDS = MAX_RATE_LIMITER_DURATION_IN_SECONDS; exports.MAX_RATE_LIMITER_DURATION_IN_SLOTS = MAX_RATE_LIMITER_DURATION_IN_SLOTS; exports.MAX_SQRT_PRICE = MAX_SQRT_PRICE; exports.MIN_CU_BUFFER = MIN_CU_BUFFER; exports.MIN_FEE_BPS = MIN_FEE_BPS; exports.MIN_FEE_NUMERATOR = MIN_FEE_NUMERATOR; exports.MIN_SQRT_PRICE = MIN_SQRT_PRICE; exports.ONE_Q64 = ONE_Q64; exports.PoolStatus = PoolStatus; exports.PoolVersion = PoolVersion; exports.Rounding = Rounding; exports.SCALE_OFFSET = SCALE_OFFSET; exports.SPLIT_POSITION_DENOMINATOR = SPLIT_POSITION_DENOMINATOR; exports.SwapMode = SwapMode; exports.TradeDirection = TradeDirection; exports.U128_MAX = U128_MAX; exports.U16_MAX = U16_MAX; exports.U64_MAX = U64_MAX; exports.bpsToFeeNumerator = bpsToFeeNumerator; exports.calculateAtoBFromAmountIn = calculateAtoBFromAmountIn; exports.calculateAtoBFromAmountOut = calculateAtoBFromAmountOut; exports.calculateAtoBFromPartialAmountIn = calculateAtoBFromPartialAmountIn; exports.calculateBtoAFromAmountIn = calculateBtoAFromAmountIn; exports.calculateBtoAFromAmountOut = calculateBtoAFromAmountOut; exports.calculateBtoAFromPartialAmountIn = calculateBtoAFromPartialAmountIn; exports.calculateInitSqrtPrice = calculateInitSqrtPrice; exports.calculateTransferFeeExcludedAmount = calculateTransferFeeExcludedAmount; exports.calculateTransferFeeIncludedAmount = calculateTransferFeeIncludedAmount; exports.convertToFeeSchedulerSecondFactor = convertToFeeSchedulerSecondFactor; exports.convertToLamports = convertToLamports; exports.convertToRateLimiterSecondFactor = convertToRateLimiterSecondFactor; exports.cpAmmCoder = cpAmmCoder; exports.decimalToQ64 = decimalToQ64; exports.decodeFeeMarketCapSchedulerParams = decodeFeeMarketCapSchedulerParams; exports.decodeFeeRateLimiterParams = decodeFeeRateLimiterParams; exports.decodeFeeTimeSchedulerParams = decodeFeeTimeSchedulerParams; exports.decodePodAlignedFeeMarketCapScheduler = decodePodAlignedFeeMarketCapScheduler; exports.decodePodAlignedFeeRateLimiter = decodePodAlignedFeeRateLimiter; exports.decodePodAlignedFeeTimeScheduler = decodePodAlignedFeeTimeScheduler; exports.deriveClaimFeeOperatorAddress = deriveClaimFeeOperatorAddress; exports.deriveConfigAddress = deriveConfigAddress; exports.deriveCustomizablePoolAddress = deriveCustomizablePoolAddress; exports.deriveOperatorAddress = deriveOperatorAddress; exports.derivePoolAddress = derivePoolAddress; exports.derivePoolAuthority = derivePoolAuthority; exports.derivePositionAddress = derivePositionAddress; exports.derivePositionNftAccount = derivePositionNftAccount; exports.deriveRewardVaultAddress = deriveRewardVaultAddress; exports.deriveTokenBadgeAddress = deriveTokenBadgeAddress; exports.deriveTokenVaultAddress = deriveTokenVaultAddress; exports.encodeFeeMarketCapSchedulerParams = encodeFeeMarketCapSchedulerParams; exports.encodeFeeRateLimiterParams = encodeFeeRateLimiterParams; exports.encodeFeeTimeSchedulerParams = encodeFeeTimeSchedulerParams; exports.feeNumeratorToBps = feeNumeratorToBps; exports.fromDecimalToBN = fromDecimalToBN; exports.getAllPositionNftAccountByOwner = getAllPositionNftAccountByOwner; exports.getAllUserPositionNftAccount = getAllUserPositionNftAccount; exports.getAmountAFromLiquidityDelta = getAmountAFromLiquidityDelta; exports.getAmountBFromLiquidityDelta = getAmountBFromLiquidityDelta; exports.getAmountWithSlippage = getAmountWithSlippage; exports.getAvailableVestingLiquidity = getAvailableVestingLiquidity; exports.getBaseFeeHandler = getBaseFeeHandler; exports.getBaseFeeParams = getBaseFeeParams; exports.getCheckedAmounts = getCheckedAmounts; exports.getCurrentPoint = getCurrentPoint; exports.getDynamicFeeNumerator = getDynamicFeeNumerator; exports.getDynamicFeeParams = getDynamicFeeParams; exports.getEstimatedComputeUnitIxWithBuffer = getEstimatedComputeUnitIxWithBuffer; exports.getEstimatedComputeUnitUsageWithBuffer = getEstimatedComputeUnitUsageWithBuffer; exports.getExcludedFeeAmount = getExcludedFeeAmount; exports.getExcludedFeeAmountFromIncludedFeeAmount = getExcludedFeeAmountFromIncludedFeeAmount; exports.getFeeInPeriod = getFeeInPeriod; exports.getFeeMarketCapBaseFeeNumerator = getFeeMarketCapBaseFeeNumerator; exports.getFeeMarketCapBaseFeeNumeratorByPeriod = getFeeMarketCapBaseFeeNumeratorByPeriod; exports.getFeeMarketCapMinBaseFeeNumerator = getFeeMarketCapMinBaseFeeNumerator; exports.getFeeMarketCapSchedulerParams = getFeeMarketCapSchedulerParams; exports.getFeeMode = getFeeMode; exports.getFeeNumeratorFromExcludedFeeAmount = getFeeNumeratorFromExcludedFeeAmount; exports.getFeeNumeratorFromIncludedFeeAmount = getFeeNumeratorFromIncludedFeeAmount; exports.getFeeNumeratorOnExponentialFeeScheduler = getFeeNumeratorOnExponentialFeeScheduler; exports.getFeeNumeratorOnLinearFeeScheduler = getFeeNumeratorOnLinearFeeScheduler; exports.getFeeOnAmount = getFeeOnAmount; exports.getFeeTimeBaseFeeNumerator = getFeeTimeBaseFeeNumerator; exports.getFeeTimeBaseFeeNumeratorByPeriod = getFeeTimeBaseFeeNumeratorByPeriod; exports.getFeeTimeMinBaseFeeNumerator = getFeeTimeMinBaseFeeNumerator; exports.getFeeTimeSchedulerParams = getFeeTimeSchedulerParams; exports.getFirstKey = getFirstKey; exports.getIncludedFeeAmount = getIncludedFeeAmount; exports.getLiquidityDeltaFromAmountA = getLiquidityDeltaFromAmountA; exports.getLiquidityDeltaFromAmountB = getLiquidityDeltaFromAmountB; exports.getMaxAmountWithSlippage = getMaxAmountWithSlippage; exports.getMaxBaseFeeNumerator = getMaxBaseFeeNumerator; exports.getMaxFeeBps = getMaxFeeBps; exports.getMaxFeeNumerator = getMaxFeeNumerator; exports.getMaxIndex = getMaxIndex; exports.getNextSqrtPriceFromAmountInARoundingUp = getNextSqrtPriceFromAmountInARoundingUp; exports.getNextSqrtPriceFromAmountInBRoundingDown = getNextSqrtPriceFromAmountInBRoundingDown; exports.getNextSqrtPriceFromAmountOutARoundingUp = getNextSqrtPriceFromAmountOutARoundingUp; exports.getNextSqrtPriceFromAmountOutBRoundingDown = getNextSqrtPriceFromAmountOutBRoundingDown; exports.getNextSqrtPriceFromInput = getNextSqrtPriceFromInput; exports.getNextSqrtPriceFromOutput = getNextSqrtPriceFromOutput; exports.getOrCreateATAInstruction = getOrCreateATAInstruction; exports.getPriceChange = getPriceChange; exports.getPriceFromSqrtPrice = getPriceFromSqrtPrice; exports.getPriceImpact = getPriceImpact; exports.getRateLimiterParams = getRateLimiterParams; exports.getRewardInfo = getRewardInfo; exports.getSecondKey = getSecondKey; exports.getSimulationComputeUnits = getSimulationComputeUnits; exports.getSqrtPriceFromPrice = getSqrtPriceFromPrice; exports.getSwapResultFromExactInput = getSwapResultFromExactInput; exports.getSwapResultFromExactOutput = getSwapResultFromExactOutput; exports.getSwapResultFromPartialInput = getSwapResultFromPartialInput; exports.getTokenDecimals = getTokenDecimals; exports.getTokenProgram = getTokenProgram; exports.getTotalFeeNumerator = getTotalFeeNumerator; exports.getTotalLockedLiquidity = getTotalLockedLiquidity; exports.getTotalTradingFeeFromExcludedFeeAmount = getTotalTradingFeeFromExcludedFeeAmount; exports.getTotalTradingFeeFromIncludedFeeAmount = getTotalTradingFeeFromIncludedFeeAmount; exports.getUnClaimLpFee = getUnClaimLpFee; exports.getUserRewardPending = getUserRewardPending; exports.hasPartner = hasPartner; exports.hasTransferHookExtension = hasTransferHookExtension; exports.isDynamicFeeEnabled = isDynamicFeeEnabled; exports.isNonZeroRateLimiter = isNonZeroRateLimiter; exports.isRateLimiterApplied = isRateLimiterApplied; exports.isSwapEnabled = isSwapEnabled; exports.isVestingComplete = isVestingComplete; exports.isZeroRateLimiter = isZeroRateLimiter; exports.mulDiv = mulDiv; exports.offsetBasedFilter = offsetBasedFilter; exports.parseFeeSchedulerSecondFactor = parseFeeSchedulerSecondFactor; exports.parseRateLimiterSecondFactor = parseRateLimiterSecondFactor; exports.positionByPoolFilter = positionByPoolFilter; exports.pow = pow; exports.q64ToDecimal = q64ToDecimal; exports.splitFees = splitFees; exports.sqrt = sqrt; exports.swapQuoteExactInput = swapQuoteExactInput; exports.swapQuoteExactOutput = swapQuoteExactOutput; exports.swapQuotePartialInput = swapQuotePartialInput; exports.toNumerator = toNumerator; exports.unwrapSOLInstruction = unwrapSOLInstruction; exports.validateFeeFraction = validateFeeFraction; exports.validateFeeMarketCapBaseFeeIsStatic = validateFeeMarketCapBaseFeeIsStatic; exports.validateFeeMarketCapScheduler = validateFeeMarketCapScheduler; exports.validateFeeRateLimiter = validateFeeRateLimiter; exports.validateFeeRateLimiterBaseFeeIsStatic = validateFeeRateLimiterBaseFeeIsStatic; exports.validateFeeTimeScheduler = validateFeeTimeScheduler; exports.validateFeeTimeSchedulerBaseFeeIsStatic = validateFeeTimeSchedulerBaseFeeIsStatic; exports.validateNoTransferHook = validateNoTransferHook; exports.vestingByPositionFilter = vestingByPositionFilter; exports.wrapSOLInstruction = wrapSOLInstruction;
12884
13795
  //# sourceMappingURL=index.js.map