@meteora-ag/cp-amm-sdk 1.1.5 → 1.1.7

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.d.mts CHANGED
@@ -1,7 +1,8 @@
1
- import { Program, IdlAccounts, BN, IdlTypes } from '@coral-xyz/anchor';
2
1
  import { PublicKey, Transaction, Connection, TransactionInstruction, AddressLookupTableAccount, Commitment, GetProgramAccountsFilter } from '@solana/web3.js';
2
+ import { Program, IdlAccounts, BN, IdlTypes } from '@coral-xyz/anchor';
3
3
  import { Mint } from '@solana/spl-token';
4
4
  import Decimal from 'decimal.js';
5
+ import BN$1 from 'bn.js';
5
6
 
6
7
  /**
7
8
  * Program IDL in camelCase format in order to be used in JS/TS.
@@ -13,7 +14,7 @@ type CpAmm$1 = {
13
14
  address: "cpamdpZCGKUy5JxQXB4dcpGPiikHawvSWAd6mEn1sGG";
14
15
  metadata: {
15
16
  name: "cpAmm";
16
- version: "0.1.4";
17
+ version: "0.1.5";
17
18
  spec: "0.1.0";
18
19
  description: "Created with Anchor";
19
20
  };
@@ -2851,6 +2852,112 @@ type CpAmm$1 = {
2851
2852
  }
2852
2853
  ];
2853
2854
  },
2855
+ {
2856
+ name: "swap2";
2857
+ discriminator: [65, 75, 63, 76, 235, 91, 91, 136];
2858
+ accounts: [
2859
+ {
2860
+ name: "poolAuthority";
2861
+ address: "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC";
2862
+ },
2863
+ {
2864
+ name: "pool";
2865
+ docs: ["Pool account"];
2866
+ writable: true;
2867
+ },
2868
+ {
2869
+ name: "inputTokenAccount";
2870
+ docs: ["The user token account for input token"];
2871
+ writable: true;
2872
+ },
2873
+ {
2874
+ name: "outputTokenAccount";
2875
+ docs: ["The user token account for output token"];
2876
+ writable: true;
2877
+ },
2878
+ {
2879
+ name: "tokenAVault";
2880
+ docs: ["The vault token account for input token"];
2881
+ writable: true;
2882
+ relations: ["pool"];
2883
+ },
2884
+ {
2885
+ name: "tokenBVault";
2886
+ docs: ["The vault token account for output token"];
2887
+ writable: true;
2888
+ relations: ["pool"];
2889
+ },
2890
+ {
2891
+ name: "tokenAMint";
2892
+ docs: ["The mint of token a"];
2893
+ },
2894
+ {
2895
+ name: "tokenBMint";
2896
+ docs: ["The mint of token b"];
2897
+ },
2898
+ {
2899
+ name: "payer";
2900
+ docs: ["The user performing the swap"];
2901
+ signer: true;
2902
+ },
2903
+ {
2904
+ name: "tokenAProgram";
2905
+ docs: ["Token a program"];
2906
+ },
2907
+ {
2908
+ name: "tokenBProgram";
2909
+ docs: ["Token b program"];
2910
+ },
2911
+ {
2912
+ name: "referralTokenAccount";
2913
+ docs: ["referral token account"];
2914
+ writable: true;
2915
+ optional: true;
2916
+ },
2917
+ {
2918
+ name: "eventAuthority";
2919
+ pda: {
2920
+ seeds: [
2921
+ {
2922
+ kind: "const";
2923
+ value: [
2924
+ 95,
2925
+ 95,
2926
+ 101,
2927
+ 118,
2928
+ 101,
2929
+ 110,
2930
+ 116,
2931
+ 95,
2932
+ 97,
2933
+ 117,
2934
+ 116,
2935
+ 104,
2936
+ 111,
2937
+ 114,
2938
+ 105,
2939
+ 116,
2940
+ 121
2941
+ ];
2942
+ }
2943
+ ];
2944
+ };
2945
+ },
2946
+ {
2947
+ name: "program";
2948
+ }
2949
+ ];
2950
+ args: [
2951
+ {
2952
+ name: "params";
2953
+ type: {
2954
+ defined: {
2955
+ name: "swapParameters2";
2956
+ };
2957
+ };
2958
+ }
2959
+ ];
2960
+ },
2854
2961
  {
2855
2962
  name: "updateRewardDuration";
2856
2963
  discriminator: [138, 174, 196, 169, 213, 235, 254, 107];
@@ -3125,6 +3232,10 @@ type CpAmm$1 = {
3125
3232
  name: "evtInitializeReward";
3126
3233
  discriminator: [129, 91, 188, 3, 246, 52, 185, 249];
3127
3234
  },
3235
+ {
3236
+ name: "evtLiquidityChange";
3237
+ discriminator: [197, 171, 78, 127, 224, 211, 87, 13];
3238
+ },
3128
3239
  {
3129
3240
  name: "evtLockPosition";
3130
3241
  discriminator: [168, 63, 108, 83, 219, 82, 2, 200];
@@ -3149,6 +3260,10 @@ type CpAmm$1 = {
3149
3260
  name: "evtSwap";
3150
3261
  discriminator: [27, 60, 21, 213, 138, 170, 187, 147];
3151
3262
  },
3263
+ {
3264
+ name: "evtSwap2";
3265
+ discriminator: [189, 66, 51, 168, 38, 80, 117, 153];
3266
+ },
3152
3267
  {
3153
3268
  name: "evtUpdateRewardDuration";
3154
3269
  discriminator: [149, 135, 65, 231, 129, 153, 65, 57];
@@ -3397,6 +3512,36 @@ type CpAmm$1 = {
3397
3512
  code: 6046;
3398
3513
  name: "samePosition";
3399
3514
  msg: "Same position";
3515
+ },
3516
+ {
3517
+ code: 6047;
3518
+ name: "invalidBaseFeeMode";
3519
+ msg: "Invalid base fee mode";
3520
+ },
3521
+ {
3522
+ code: 6048;
3523
+ name: "invalidFeeRateLimiter";
3524
+ msg: "Invalid fee rate limiter";
3525
+ },
3526
+ {
3527
+ code: 6049;
3528
+ name: "failToValidateSingleSwapInstruction";
3529
+ msg: "Fail to validate single swap instruction in rate limiter";
3530
+ },
3531
+ {
3532
+ code: 6050;
3533
+ name: "invalidFeeScheduler";
3534
+ msg: "Invalid fee scheduler";
3535
+ },
3536
+ {
3537
+ code: 6051;
3538
+ name: "undeterminedError";
3539
+ msg: "Undetermined error";
3540
+ },
3541
+ {
3542
+ code: 6052;
3543
+ name: "invalidPoolVersion";
3544
+ msg: "Invalid pool version";
3400
3545
  }
3401
3546
  ];
3402
3547
  types: [
@@ -3437,7 +3582,7 @@ type CpAmm$1 = {
3437
3582
  type: "u64";
3438
3583
  },
3439
3584
  {
3440
- name: "feeSchedulerMode";
3585
+ name: "baseFeeMode";
3441
3586
  type: "u8";
3442
3587
  },
3443
3588
  {
@@ -3447,15 +3592,17 @@ type CpAmm$1 = {
3447
3592
  };
3448
3593
  },
3449
3594
  {
3450
- name: "numberOfPeriod";
3595
+ name: "firstFactor";
3451
3596
  type: "u16";
3452
3597
  },
3453
3598
  {
3454
- name: "periodFrequency";
3455
- type: "u64";
3599
+ name: "secondFactor";
3600
+ type: {
3601
+ array: ["u8", 8];
3602
+ };
3456
3603
  },
3457
3604
  {
3458
- name: "reductionFactor";
3605
+ name: "thirdFactor";
3459
3606
  type: "u64";
3460
3607
  }
3461
3608
  ];
@@ -3471,19 +3618,21 @@ type CpAmm$1 = {
3471
3618
  type: "u64";
3472
3619
  },
3473
3620
  {
3474
- name: "numberOfPeriod";
3621
+ name: "firstFactor";
3475
3622
  type: "u16";
3476
3623
  },
3477
3624
  {
3478
- name: "periodFrequency";
3479
- type: "u64";
3625
+ name: "secondFactor";
3626
+ type: {
3627
+ array: ["u8", 8];
3628
+ };
3480
3629
  },
3481
3630
  {
3482
- name: "reductionFactor";
3631
+ name: "thirdFactor";
3483
3632
  type: "u64";
3484
3633
  },
3485
3634
  {
3486
- name: "feeSchedulerMode";
3635
+ name: "baseFeeMode";
3487
3636
  type: "u8";
3488
3637
  }
3489
3638
  ];
@@ -3503,7 +3652,7 @@ type CpAmm$1 = {
3503
3652
  type: "u64";
3504
3653
  },
3505
3654
  {
3506
- name: "feeSchedulerMode";
3655
+ name: "baseFeeMode";
3507
3656
  type: "u8";
3508
3657
  },
3509
3658
  {
@@ -3513,15 +3662,17 @@ type CpAmm$1 = {
3513
3662
  };
3514
3663
  },
3515
3664
  {
3516
- name: "numberOfPeriod";
3665
+ name: "firstFactor";
3517
3666
  type: "u16";
3518
3667
  },
3519
3668
  {
3520
- name: "periodFrequency";
3521
- type: "u64";
3669
+ name: "secondFactor";
3670
+ type: {
3671
+ array: ["u8", 8];
3672
+ };
3522
3673
  },
3523
3674
  {
3524
- name: "reductionFactor";
3675
+ name: "thirdFactor";
3525
3676
  type: "u64";
3526
3677
  },
3527
3678
  {
@@ -4299,6 +4450,66 @@ type CpAmm$1 = {
4299
4450
  ];
4300
4451
  };
4301
4452
  },
4453
+ {
4454
+ name: "evtLiquidityChange";
4455
+ type: {
4456
+ kind: "struct";
4457
+ fields: [
4458
+ {
4459
+ name: "pool";
4460
+ type: "pubkey";
4461
+ },
4462
+ {
4463
+ name: "position";
4464
+ type: "pubkey";
4465
+ },
4466
+ {
4467
+ name: "owner";
4468
+ type: "pubkey";
4469
+ },
4470
+ {
4471
+ name: "tokenAAmount";
4472
+ type: "u64";
4473
+ },
4474
+ {
4475
+ name: "tokenBAmount";
4476
+ type: "u64";
4477
+ },
4478
+ {
4479
+ name: "transferFeeIncludedTokenAAmount";
4480
+ type: "u64";
4481
+ },
4482
+ {
4483
+ name: "transferFeeIncludedTokenBAmount";
4484
+ type: "u64";
4485
+ },
4486
+ {
4487
+ name: "reserveAAmount";
4488
+ type: "u64";
4489
+ },
4490
+ {
4491
+ name: "reserveBAmount";
4492
+ type: "u64";
4493
+ },
4494
+ {
4495
+ name: "liquidityDelta";
4496
+ type: "u128";
4497
+ },
4498
+ {
4499
+ name: "tokenAAmountThreshold";
4500
+ type: "u64";
4501
+ },
4502
+ {
4503
+ name: "tokenBAmountThreshold";
4504
+ type: "u64";
4505
+ },
4506
+ {
4507
+ name: "changeType";
4508
+ type: "u8";
4509
+ }
4510
+ ];
4511
+ };
4512
+ },
4302
4513
  {
4303
4514
  name: "evtLockPosition";
4304
4515
  type: {
@@ -4527,6 +4738,70 @@ type CpAmm$1 = {
4527
4738
  ];
4528
4739
  };
4529
4740
  },
4741
+ {
4742
+ name: "evtSwap2";
4743
+ type: {
4744
+ kind: "struct";
4745
+ fields: [
4746
+ {
4747
+ name: "pool";
4748
+ type: "pubkey";
4749
+ },
4750
+ {
4751
+ name: "tradeDirection";
4752
+ type: "u8";
4753
+ },
4754
+ {
4755
+ name: "collectFeeMode";
4756
+ type: "u8";
4757
+ },
4758
+ {
4759
+ name: "hasReferral";
4760
+ type: "bool";
4761
+ },
4762
+ {
4763
+ name: "params";
4764
+ type: {
4765
+ defined: {
4766
+ name: "swapParameters2";
4767
+ };
4768
+ };
4769
+ },
4770
+ {
4771
+ name: "swapResult";
4772
+ type: {
4773
+ defined: {
4774
+ name: "swapResult2";
4775
+ };
4776
+ };
4777
+ },
4778
+ {
4779
+ name: "includedTransferFeeAmountIn";
4780
+ type: "u64";
4781
+ },
4782
+ {
4783
+ name: "includedTransferFeeAmountOut";
4784
+ type: "u64";
4785
+ },
4786
+ {
4787
+ name: "excludedTransferFeeAmountOut";
4788
+ type: "u64";
4789
+ },
4790
+ {
4791
+ name: "currentTimestamp";
4792
+ type: "u64";
4793
+ },
4794
+ {
4795
+ name: "reserveAAmount";
4796
+ type: "u64";
4797
+ },
4798
+ {
4799
+ name: "reserveBAmount";
4800
+ type: "u64";
4801
+ }
4802
+ ];
4803
+ };
4804
+ },
4530
4805
  {
4531
4806
  name: "evtUpdateRewardDuration";
4532
4807
  type: {
@@ -4818,11 +5093,16 @@ type CpAmm$1 = {
4818
5093
  type: "u8";
4819
5094
  },
4820
5095
  {
4821
- name: "padding0";
4822
- docs: ["padding"];
4823
- type: {
4824
- array: ["u8", 2];
4825
- };
5096
+ name: "version";
5097
+ docs: [
5098
+ "pool version, 0: max_fee is still capped at 50%, 1: max_fee is capped at 99%"
5099
+ ];
5100
+ type: "u8";
5101
+ },
5102
+ {
5103
+ name: "padding0";
5104
+ docs: ["padding"];
5105
+ type: "u8";
4826
5106
  },
4827
5107
  {
4828
5108
  name: "feeAPerLiquidity";
@@ -5512,6 +5792,33 @@ type CpAmm$1 = {
5512
5792
  ];
5513
5793
  };
5514
5794
  },
5795
+ {
5796
+ name: "swapParameters2";
5797
+ type: {
5798
+ kind: "struct";
5799
+ fields: [
5800
+ {
5801
+ name: "amount0";
5802
+ docs: [
5803
+ "When it's exact in, partial fill, this will be amount_in. When it's exact out, this will be amount_out"
5804
+ ];
5805
+ type: "u64";
5806
+ },
5807
+ {
5808
+ name: "amount1";
5809
+ docs: [
5810
+ "When it's exact in, partial fill, this will be minimum_amount_out. When it's exact out, this will be maximum_amount_in"
5811
+ ];
5812
+ type: "u64";
5813
+ },
5814
+ {
5815
+ name: "swapMode";
5816
+ docs: ["Swap mode, refer [SwapMode]"];
5817
+ type: "u8";
5818
+ }
5819
+ ];
5820
+ };
5821
+ },
5515
5822
  {
5516
5823
  name: "swapResult";
5517
5824
  docs: ["Encodes all results of swapping"];
@@ -5545,6 +5852,50 @@ type CpAmm$1 = {
5545
5852
  ];
5546
5853
  };
5547
5854
  },
5855
+ {
5856
+ name: "swapResult2";
5857
+ type: {
5858
+ kind: "struct";
5859
+ fields: [
5860
+ {
5861
+ name: "includedFeeInputAmount";
5862
+ type: "u64";
5863
+ },
5864
+ {
5865
+ name: "excludedFeeInputAmount";
5866
+ type: "u64";
5867
+ },
5868
+ {
5869
+ name: "amountLeft";
5870
+ type: "u64";
5871
+ },
5872
+ {
5873
+ name: "outputAmount";
5874
+ type: "u64";
5875
+ },
5876
+ {
5877
+ name: "nextSqrtPrice";
5878
+ type: "u128";
5879
+ },
5880
+ {
5881
+ name: "tradingFee";
5882
+ type: "u64";
5883
+ },
5884
+ {
5885
+ name: "protocolFee";
5886
+ type: "u64";
5887
+ },
5888
+ {
5889
+ name: "partnerFee";
5890
+ type: "u64";
5891
+ },
5892
+ {
5893
+ name: "referralFee";
5894
+ type: "u64";
5895
+ }
5896
+ ];
5897
+ };
5898
+ },
5548
5899
  {
5549
5900
  name: "tokenBadge";
5550
5901
  docs: ["Parameter that set by the protocol"];
@@ -5694,9 +6045,10 @@ declare enum ActivationPoint {
5694
6045
  Timestamp = 0,
5695
6046
  Slot = 1
5696
6047
  }
5697
- declare enum FeeSchedulerMode {
5698
- Linear = 0,
5699
- Exponential = 1
6048
+ declare enum BaseFeeMode {
6049
+ FeeSchedulerLinear = 0,
6050
+ FeeSchedulerExponential = 1,
6051
+ RateLimiter = 2
5700
6052
  }
5701
6053
  declare enum CollectFeeMode {
5702
6054
  BothToken = 0,
@@ -5710,32 +6062,68 @@ declare enum ActivationType {
5710
6062
  Slot = 0,
5711
6063
  Timestamp = 1
5712
6064
  }
6065
+ declare enum PoolVersion {
6066
+ V0 = 0,
6067
+ V1 = 1
6068
+ }
5713
6069
  type FeeMode = {
5714
- feeOnInput: boolean;
6070
+ feesOnInput: boolean;
5715
6071
  feesOnTokenA: boolean;
6072
+ hasReferral: boolean;
5716
6073
  };
6074
+ declare enum PoolStatus {
6075
+ Enable = 0,
6076
+ Disable = 1
6077
+ }
6078
+ declare enum SwapMode {
6079
+ ExactIn = 0,
6080
+ PartialFill = 1,
6081
+ ExactOut = 2
6082
+ }
5717
6083
  type PoolState = IdlAccounts<CpAmm$1>["pool"];
5718
6084
  type PositionState = IdlAccounts<CpAmm$1>["position"];
5719
6085
  type VestingState = IdlAccounts<CpAmm$1>["vesting"];
5720
6086
  type ConfigState = IdlAccounts<CpAmm$1>["config"];
5721
6087
  type TokenBadgeState = IdlAccounts<CpAmm$1>["tokenBadge"];
5722
6088
  type RewardInfo = IdlTypes<CpAmm$1>["rewardInfo"];
5723
- type DynamicFee = {
5724
- binStep: number;
5725
- binStepU128: BN;
5726
- filterPeriod: number;
5727
- decayPeriod: number;
5728
- reductionFactor: number;
5729
- maxVolatilityAccumulator: number;
5730
- variableFeeControl: number;
5731
- };
5732
- type BaseFee = {
5733
- cliffFeeNumerator: BN;
5734
- numberOfPeriod: number;
5735
- periodFrequency: BN;
5736
- reductionFactor: BN;
5737
- feeSchedulerMode: number;
5738
- };
6089
+ /**
6090
+ * Dynamic fee parameters
6091
+ * @param binStep
6092
+ * @param binStepU128
6093
+ * @param filterPeriod
6094
+ * @param decayPeriod
6095
+ * @param reductionFactor
6096
+ * @param maxVolatilityAccumulator
6097
+ * @param variableFeeControl
6098
+ */
6099
+ type DynamicFee = IdlTypes<CpAmm$1>["dynamicFeeParameters"];
6100
+ /**
6101
+ * Dynamic fee struct
6102
+ * @param initialized
6103
+ * @param padding
6104
+ * @param maxVolatilityAccumulator
6105
+ * @param variableFeeControl
6106
+ * @param binStep
6107
+ * @param filterPeriod
6108
+ * @param decayPeriod
6109
+ * @param reductionFactor
6110
+ * @param lastUpdateTimestamp
6111
+ * @param binStepU128
6112
+ * @param sqrtPriceReference
6113
+ * @param volatilityAccumulator
6114
+ * @param volatilityReference
6115
+ */
6116
+ type DynamicFeeStruct = IdlTypes<CpAmm$1>["dynamicFeeStruct"];
6117
+ /**
6118
+ * Base fee parameters
6119
+ * @param cliffFeeNumerator
6120
+ * @param firstFactor // feeScheduler: numberOfPeriod, rateLimiter: feeIncrementBps
6121
+ * @param secondFactor // feeScheduler: periodFrequency, rateLimiter: maxLimiterDuration
6122
+ * @param thirdFactor // feeScheduler: reductionFactor, rateLimiter: referenceAmount
6123
+ * @param baseFeeMode
6124
+ */
6125
+ type BaseFee = IdlTypes<CpAmm$1>["baseFeeParameters"];
6126
+ type PoolFeesStruct = IdlTypes<CpAmm$1>["poolFeesStruct"];
5739
6127
  type PoolFeesParams = {
5740
6128
  baseFee: BaseFee;
5741
6129
  padding: number[];
@@ -6004,18 +6392,13 @@ type GetQuoteParams = {
6004
6392
  };
6005
6393
  tokenADecimal: number;
6006
6394
  tokenBDecimal: number;
6395
+ hasReferral?: boolean;
6007
6396
  };
6008
- type SwapAmount = {
6009
- outputAmount: BN;
6010
- nextSqrtPrice: BN;
6011
- };
6012
- type GetQuoteExactOutParams = {
6013
- outAmount: BN;
6014
- outputTokenMint: PublicKey;
6397
+ type GetQuote2Params = {
6398
+ inputTokenMint: PublicKey;
6015
6399
  slippage: number;
6400
+ currentPoint: BN;
6016
6401
  poolState: PoolState;
6017
- currentTime: number;
6018
- currentSlot: number;
6019
6402
  inputTokenInfo?: {
6020
6403
  mint: Mint;
6021
6404
  currentEpoch: number;
@@ -6026,26 +6409,28 @@ type GetQuoteExactOutParams = {
6026
6409
  };
6027
6410
  tokenADecimal: number;
6028
6411
  tokenBDecimal: number;
6029
- };
6030
- type SwapResult = {
6412
+ hasReferral: boolean;
6413
+ } & ({
6414
+ swapMode: SwapMode.ExactIn;
6415
+ amountIn: BN;
6416
+ } | {
6417
+ swapMode: SwapMode.PartialFill;
6418
+ amountIn: BN;
6419
+ } | {
6420
+ swapMode: SwapMode.ExactOut;
6421
+ amountOut: BN;
6422
+ });
6423
+ type SwapAmount = {
6031
6424
  outputAmount: BN;
6032
6425
  nextSqrtPrice: BN;
6033
- lpFee: BN;
6034
- protocolFee: BN;
6035
- referralFee: BN;
6036
- partnerFee: BN;
6037
- };
6038
- type QuoteExactOutResult = {
6039
- swapResult: SwapResult;
6040
- inputAmount: BN;
6041
- maxInputAmount: BN;
6042
- priceImpact: number;
6043
- };
6044
- type SwapQuotes = {
6045
- totalFee: BN;
6046
- minOutAmount: BN;
6047
- actualAmount: BN;
6048
6426
  };
6427
+ type SwapResult = IdlTypes<CpAmm$1>["swapResult"];
6428
+ type SwapResult2 = IdlTypes<CpAmm$1>["swapResult2"];
6429
+ interface Quote2Result extends SwapResult2 {
6430
+ priceImpact: Decimal;
6431
+ minimumAmountOut?: BN;
6432
+ maximumAmountIn?: BN;
6433
+ }
6049
6434
  type SwapParams = {
6050
6435
  payer: PublicKey;
6051
6436
  pool: PublicKey;
@@ -6061,6 +6446,31 @@ type SwapParams = {
6061
6446
  tokenBProgram: PublicKey;
6062
6447
  referralTokenAccount: PublicKey | null;
6063
6448
  };
6449
+ type Swap2Params = {
6450
+ payer: PublicKey;
6451
+ pool: PublicKey;
6452
+ inputTokenMint: PublicKey;
6453
+ outputTokenMint: PublicKey;
6454
+ tokenAMint: PublicKey;
6455
+ tokenBMint: PublicKey;
6456
+ tokenAVault: PublicKey;
6457
+ tokenBVault: PublicKey;
6458
+ tokenAProgram: PublicKey;
6459
+ tokenBProgram: PublicKey;
6460
+ referralTokenAccount: PublicKey | null;
6461
+ } & ({
6462
+ swapMode: SwapMode.ExactIn;
6463
+ amountIn: BN;
6464
+ minimumAmountOut: BN;
6465
+ } | {
6466
+ swapMode: SwapMode.PartialFill;
6467
+ amountIn: BN;
6468
+ minimumAmountOut: BN;
6469
+ } | {
6470
+ swapMode: SwapMode.ExactOut;
6471
+ amountOut: BN;
6472
+ maximumAmountIn: BN;
6473
+ });
6064
6474
  type LockPositionParams = {
6065
6475
  owner: PublicKey;
6066
6476
  payer: PublicKey;
@@ -6270,6 +6680,24 @@ type SplitPosition2Params = {
6270
6680
  secondPositionNftAccount: PublicKey;
6271
6681
  numerator: number;
6272
6682
  };
6683
+ interface BaseFeeHandler {
6684
+ validate(collectFeeMode: CollectFeeMode, activationType: ActivationType, poolVersion: PoolVersion): boolean;
6685
+ getBaseFeeNumeratorFromIncludedFeeAmount(currentPoint: BN, activationPoint: BN, tradeDirection: TradeDirection, includedFeeAmount: BN): BN;
6686
+ getBaseFeeNumeratorFromExcludedFeeAmount(currentPoint: BN, activationPoint: BN, tradeDirection: TradeDirection, excludedFeeAmount: BN): BN;
6687
+ }
6688
+ interface FeeOnAmountResult {
6689
+ amount: BN;
6690
+ tradingFee: BN;
6691
+ protocolFee: BN;
6692
+ partnerFee: BN;
6693
+ referralFee: BN;
6694
+ }
6695
+ interface SplitFees {
6696
+ tradingFee: BN;
6697
+ protocolFee: BN;
6698
+ referralFee: BN;
6699
+ partnerFee: BN;
6700
+ }
6273
6701
 
6274
6702
  /**
6275
6703
  * CpAmm SDK class to interact with the DAMM-V2
@@ -6454,7 +6882,7 @@ declare class CpAmm {
6454
6882
  canUnlockPosition(positionState: PositionState, vestings: Array<{
6455
6883
  account: PublicKey;
6456
6884
  vestingState: VestingState;
6457
- }>, currentPoint: BN): {
6885
+ }>, currentPoint: BN$1): {
6458
6886
  canUnlock: boolean;
6459
6887
  reason?: string;
6460
6888
  };
@@ -6465,26 +6893,21 @@ declare class CpAmm {
6465
6893
  * @param {LiquidityDeltaParams} params - The parameters for liquidity calculation
6466
6894
  * @returns {Promise<BN>} - The computed liquidity delta in Q64 value.
6467
6895
  */
6468
- getLiquidityDelta(params: LiquidityDeltaParams): BN;
6896
+ getLiquidityDelta(params: LiquidityDeltaParams): BN$1;
6469
6897
  /**
6470
6898
  * Calculates swap quote based on input amount and pool state.
6471
6899
  * @param params - Swap parameters including input amount, pool state, slippage, etc.
6472
6900
  * @returns Swap quote including expected output amount, fee, and price impact.
6473
6901
  */
6474
6902
  getQuote(params: GetQuoteParams): {
6475
- swapInAmount: BN;
6476
- consumedInAmount: BN;
6477
- swapOutAmount: BN;
6478
- minSwapOutAmount: BN;
6479
- totalFee: BN;
6903
+ swapInAmount: BN$1;
6904
+ consumedInAmount: BN$1;
6905
+ swapOutAmount: BN$1;
6906
+ minSwapOutAmount: BN$1;
6907
+ totalFee: BN$1;
6480
6908
  priceImpact: Decimal;
6481
6909
  };
6482
- /**
6483
- * Calculates swap quote based on desired output amount and pool state.
6484
- * @param params - Swap parameters including output amount, pool state, slippage, etc.
6485
- * @returns Swap quote including required input amount, fees, and price impact.
6486
- */
6487
- getQuoteExactOut(params: GetQuoteExactOutParams): QuoteExactOutResult;
6910
+ getQuote2(params: GetQuote2Params): Quote2Result;
6488
6911
  /**
6489
6912
  * Calculates the deposit quote for liquidity pool.
6490
6913
  *
@@ -6516,7 +6939,7 @@ declare class CpAmm {
6516
6939
  * @param params Parameters for single-sided pool creation
6517
6940
  * @returns Calculated liquidity delta
6518
6941
  */
6519
- preparePoolCreationSingleSide(params: PreparePoolCreationSingleSide): BN;
6942
+ preparePoolCreationSingleSide(params: PreparePoolCreationSingleSide): BN$1;
6520
6943
  /**
6521
6944
  * Prepares parameters required for pool creation, including initial sqrt price and liquidity.
6522
6945
  * @private
@@ -6585,6 +7008,7 @@ declare class CpAmm {
6585
7008
  * @returns Transaction builder.
6586
7009
  */
6587
7010
  swap(params: SwapParams): TxBuilder;
7011
+ swap2(params: Swap2Params): TxBuilder;
6588
7012
  /**
6589
7013
  * Builds a transaction to lock a position with vesting schedule.
6590
7014
  * @param {LockPositionParams} params - Locking parameters.
@@ -6698,38 +7122,611 @@ declare const CP_AMM_PROGRAM_ID: PublicKey;
6698
7122
  declare const LIQUIDITY_SCALE = 128;
6699
7123
  declare const SCALE_OFFSET = 64;
6700
7124
  declare const BASIS_POINT_MAX = 10000;
6701
- declare const MAX_FEE_NUMERATOR = 500000000;
6702
7125
  declare const FEE_DENOMINATOR = 1000000000;
6703
- declare const MIN_SQRT_PRICE: BN;
6704
- declare const MAX_SQRT_PRICE: BN;
7126
+ declare const ONE_Q64: BN$1;
7127
+ declare const MAX_EXPONENTIAL: BN$1;
7128
+ declare const MAX: BN$1;
7129
+ declare const MIN_FEE_BPS = 1;
7130
+ declare const MIN_FEE_NUMERATOR = 100000;
7131
+ declare const MAX_FEE_BPS_V0 = 5000;
7132
+ declare const MAX_FEE_NUMERATOR_V0 = 500000000;
7133
+ declare const MAX_FEE_BPS_V1 = 9900;
7134
+ declare const MAX_FEE_NUMERATOR_V1 = 990000000;
7135
+ declare const MIN_SQRT_PRICE: BN$1;
7136
+ declare const MAX_SQRT_PRICE: BN$1;
6705
7137
  declare const MIN_CU_BUFFER = 50000;
6706
7138
  declare const MAX_CU_BUFFER = 200000;
7139
+ declare const DYNAMIC_FEE_SCALING_FACTOR: BN$1;
7140
+ declare const DYNAMIC_FEE_ROUNDING_OFFSET: BN$1;
6707
7141
  declare const DYNAMIC_FEE_FILTER_PERIOD_DEFAULT = 10;
6708
7142
  declare const DYNAMIC_FEE_DECAY_PERIOD_DEFAULT = 120;
6709
7143
  declare const DYNAMIC_FEE_REDUCTION_FACTOR_DEFAULT = 5000;
6710
7144
  declare const BIN_STEP_BPS_DEFAULT = 1;
6711
- declare const BIN_STEP_BPS_U128_DEFAULT: BN;
7145
+ declare const BIN_STEP_BPS_U128_DEFAULT: BN$1;
6712
7146
  declare const MAX_PRICE_CHANGE_BPS_DEFAULT = 1500;
7147
+ declare const U128_MAX: BN$1;
7148
+ declare const U64_MAX: BN$1;
7149
+ declare const U16_MAX = 65535;
7150
+ declare const MAX_RATE_LIMITER_DURATION_IN_SECONDS = 43200;
7151
+ declare const MAX_RATE_LIMITER_DURATION_IN_SLOTS = 108000;
6713
7152
  declare const SPLIT_POSITION_DENOMINATOR = 1000000000;
7153
+ declare const CURRENT_POOL_VERSION = PoolVersion.V0;
6714
7154
 
7155
+ /**
7156
+ * Gets the token program
7157
+ * @param flag - The flag
7158
+ * @returns The token program
7159
+ */
6715
7160
  declare function getTokenProgram(flag: number): PublicKey;
7161
+ /**
7162
+ * Gets the token decimals
7163
+ * @param connection - The connection
7164
+ * @param mint - The mint
7165
+ * @returns The token decimals
7166
+ */
6716
7167
  declare const getTokenDecimals: (connection: Connection, mint: PublicKey) => Promise<number>;
7168
+ /**
7169
+ * Gets the or creates the ATA instruction
7170
+ * @param connection - The connection
7171
+ * @param tokenMint - The token mint
7172
+ * @param owner - The owner
7173
+ * @param payer - The payer
7174
+ * @param allowOwnerOffCurve - The allow owner off curve
7175
+ * @param tokenProgram - The token program
7176
+ * @returns The ATA instruction
7177
+ */
6717
7178
  declare const getOrCreateATAInstruction: (connection: Connection, tokenMint: PublicKey, owner: PublicKey, payer: PublicKey, allowOwnerOffCurve: boolean, tokenProgram: PublicKey) => Promise<{
6718
7179
  ataPubkey: PublicKey;
6719
7180
  ix?: TransactionInstruction;
6720
7181
  }>;
7182
+ /**
7183
+ * Gets the wrap SOL instruction
7184
+ * @param from - The from
7185
+ * @param to - The to
7186
+ * @param amount - The amount
7187
+ * @returns The wrap SOL instruction
7188
+ */
6721
7189
  declare const wrapSOLInstruction: (from: PublicKey, to: PublicKey, amount: bigint) => TransactionInstruction[];
7190
+ /**
7191
+ * Gets the unwrap SOL instruction
7192
+ * @param owner - The owner
7193
+ * @param receiver - The receiver
7194
+ * @param allowOwnerOffCurve - The allow owner off curve
7195
+ * @returns The unwrap SOL instruction
7196
+ */
6722
7197
  declare const unwrapSOLInstruction: (owner: PublicKey, receiver?: PublicKey, allowOwnerOffCurve?: boolean) => Promise<TransactionInstruction>;
7198
+ /**
7199
+ * Gets all the user position NFT accounts
7200
+ * @param connection - The connection
7201
+ * @param user - The user
7202
+ * @returns The user position NFT accounts
7203
+ */
6723
7204
  declare function getAllUserPositionNftAccount(connection: Connection, user: PublicKey): Promise<Array<{
6724
7205
  positionNft: PublicKey;
6725
7206
  positionNftAccount: PublicKey;
6726
7207
  }>>;
7208
+ /**
7209
+ * Gets all the position NFT accounts by owner
7210
+ * @param connection - The connection
7211
+ * @param user - The user
7212
+ * @returns The position NFT accounts by owner
7213
+ */
6727
7214
  declare function getAllPositionNftAccountByOwner(connection: Connection, user: PublicKey): Promise<Array<{
6728
7215
  positionNft: PublicKey;
6729
7216
  positionNftAccount: PublicKey;
6730
7217
  }>>;
6731
7218
 
6732
- declare function getBaseFeeNumerator(feeSchedulerMode: FeeSchedulerMode, cliffFeeNumerator: BN, period: BN, reductionFactor: BN): BN;
7219
+ /**
7220
+ * Gets the estimated compute unit usage for a transaction.
7221
+ * @param connection - The connection to the Solana cluster
7222
+ * @param instructions - The instructions to simulate
7223
+ * @param payer - The public key of the fee payer
7224
+ * @param lookupTables - The lookup tables to simulate
7225
+ * @param commitment - The commitment level to simulate
7226
+ * @returns The estimated compute unit usage
7227
+ */
7228
+ declare const getSimulationComputeUnits: (connection: Connection, instructions: Array<TransactionInstruction>, payer: PublicKey, lookupTables: Array<AddressLookupTableAccount> | [], commitment?: Commitment) => Promise<number | null>;
7229
+ /**
7230
+ * Gets the estimated compute unit usage with a buffer.
7231
+ * @param connection A Solana connection object.
7232
+ * @param instructions The instructions of the transaction to simulate.
7233
+ * @param feePayer The public key of the fee payer.
7234
+ * @param buffer The buffer to add to the estimated compute unit usage. Max value is 1. Default value is 0.1 if not provided, and will be capped between 50k - 200k.
7235
+ * @returns The estimated compute unit usage with the buffer.
7236
+ */
7237
+ declare const getEstimatedComputeUnitUsageWithBuffer: (connection: Connection, instructions: TransactionInstruction[], feePayer: PublicKey, buffer?: number) => Promise<number>;
7238
+ /**
7239
+ * Gets the estimated compute unit usage with a buffer and converts it to a SetComputeUnitLimit instruction.
7240
+ * If the estimated compute unit usage cannot be retrieved, returns a SetComputeUnitLimit instruction with the fallback unit.
7241
+ * @param connection A Solana connection object.
7242
+ * @param instructions The instructions of the transaction to simulate.
7243
+ * @param feePayer The public key of the fee payer.
7244
+ * @param buffer The buffer to add to the estimated compute unit usage. Max value is 1. Default value is 0.1 if not provided, and will be capped between 50k - 200k.
7245
+ * @returns A SetComputeUnitLimit instruction with the estimated compute unit usage.
7246
+ */
7247
+ declare const getEstimatedComputeUnitIxWithBuffer: (connection: Connection, instructions: TransactionInstruction[], feePayer: PublicKey, buffer?: number) => Promise<TransactionInstruction>;
7248
+
7249
+ /**
7250
+ * It takes an amount and a slippage rate, and returns the maximum amount that can be received with
7251
+ * that slippage rate
7252
+ * @param {BN} amount - The amount of tokens you want to buy.
7253
+ * @param {number} rate - The maximum percentage of slippage you're willing to accept. (Max to 2 decimal place)
7254
+ * @returns The maximum amount of tokens that can be bought with the given amount of ETH, given the
7255
+ * slippage rate.
7256
+ */
7257
+ declare const getMaxAmountWithSlippage: (amount: BN, rate: number) => BN;
7258
+ /**
7259
+ * Calculates minimum amount out or maximum amount in based on slippage and swap mode.
7260
+ * For ExactIn/PartialFill: returns minimum amount out.
7261
+ * For ExactOut: returns maximum amount in.
7262
+ *
7263
+ * @param {BN} amount - The base amount (outputAmount for ExactIn/PartialFill, includedFeeInputAmount for ExactOut)
7264
+ * @param {number} slippageBps - Slippage in basis points (1% = 100)
7265
+ * @param {SwapMode} swapMode - Swap mode (ExactIn, PartialFill, ExactOut)
7266
+ * @returns {BN} - Minimum amount out (for ExactIn/PartialFill) or maximum amount in (for ExactOut)
7267
+ */
7268
+ declare const getAmountWithSlippage: (amount: BN, slippageBps: number, swapMode: SwapMode) => BN;
7269
+ /**
7270
+ * Calculate price impact as a percentage
7271
+ * Price impact measures how much worse the user's execution was compared to the current market price
7272
+ * @param amountIn - Input amount (in base units)
7273
+ * @param amountOut - Output amount (in base units)
7274
+ * @param currentSqrtPrice - Current pool sqrt price (spot price)
7275
+ * @param aToB - Direction of swap: true for token A to token B, false for token B to token A
7276
+ * @param tokenADecimal - Decimal places for token A
7277
+ * @param tokenBDecimal - Decimal places for token B
7278
+ * @returns Price impact as a percentage (e.g., 1.5 means 1.5% worse than spot price)
7279
+ */
7280
+ declare const getPriceImpact: (amountIn: BN, amountOut: BN, currentSqrtPrice: BN, aToB: boolean, tokenADecimal: number, tokenBDecimal: number) => Decimal;
7281
+ /**
7282
+ * Calculate price change as a percentage (old implementation)
7283
+ * This measures the percentage change in pool price after a swap
7284
+ * @param nextSqrtPrice sqrt price after swap
7285
+ * @param currentSqrtPrice current pool sqrt price
7286
+ * @returns Price change as a percentage (e.g., 1.5 means 1.5% change)
7287
+ */
7288
+ declare const getPriceChange: (nextSqrtPrice: BN, currentSqrtPrice: BN) => number;
7289
+ /**
7290
+ * Converts a sqrt price to a price
7291
+ * (sqrtPrice)^2 * 10 ** (base_decimal - quote_decimal) / 2^128
7292
+ * @param sqrtPrice - The sqrt price
7293
+ * @param tokenADecimal - The token A decimal
7294
+ * @param tokenBDecimal - The token B decimal
7295
+ * @returns The price
7296
+ */
7297
+ declare const getPriceFromSqrtPrice: (sqrtPrice: BN, tokenADecimal: number, tokenBDecimal: number) => Decimal;
7298
+ /**
7299
+ * Converts a price to a sqrt price
7300
+ * sqrt(price / 10^(tokenADecimal - tokenBDecimal)) * 2^64
7301
+ * @param price - The price
7302
+ * @param tokenADecimal - The token A decimal
7303
+ * @param tokenBDecimal - The token B decimal
7304
+ * @returns The sqrt price
7305
+ */
7306
+ declare const getSqrtPriceFromPrice: (price: string, tokenADecimal: number, tokenBDecimal: number) => BN;
7307
+ /**
7308
+ * Gets the unclaimed reward
7309
+ * fee = totalLiquidity * feePerTokenStore
7310
+ * precision: (totalLiquidity * feePerTokenStore) >> 128
7311
+ * @param poolState - The pool state
7312
+ * @param positionState - The position state
7313
+ * @returns The unclaimed reward
7314
+ */
7315
+ declare const getUnClaimReward: (poolState: PoolState, positionState: PositionState) => {
7316
+ feeTokenA: BN;
7317
+ feeTokenB: BN;
7318
+ rewards: BN[];
7319
+ };
7320
+
7321
+ /**
7322
+ * Filters for the position by pool
7323
+ * @param pool - The pool address
7324
+ * @returns The filter for the position by pool
7325
+ */
7326
+ declare const positionByPoolFilter: (pool: PublicKey) => GetProgramAccountsFilter;
7327
+ /**
7328
+ * Filters for the vesting by position
7329
+ * @param position - The position address
7330
+ * @returns The filter for the vesting by position
7331
+ */
7332
+ declare const vestingByPositionFilter: (position: PublicKey) => GetProgramAccountsFilter;
7333
+
7334
+ interface TransferFeeIncludedAmount {
7335
+ amount: BN;
7336
+ transferFee: BN;
7337
+ }
7338
+ /**
7339
+ * Calculates the transfer fee included amount
7340
+ * @param transferFeeExcludedAmount - The transfer fee excluded amount
7341
+ * @param mint - The mint
7342
+ * @param currentEpoch - The current epoch
7343
+ * @returns The transfer fee included amount
7344
+ */
7345
+ declare function calculateTransferFeeIncludedAmount(transferFeeExcludedAmount: BN, mint: Mint, currentEpoch: number): TransferFeeIncludedAmount;
7346
+ interface TransferFeeExcludedAmount {
7347
+ amount: BN;
7348
+ transferFee: BN;
7349
+ }
7350
+ /**
7351
+ * Calculates the transfer fee excluded amount
7352
+ * @param transferFeeIncludedAmount - The transfer fee included amount
7353
+ * @param mint - The mint
7354
+ * @param currentEpoch - The current epoch
7355
+ * @returns The transfer fee excluded amount
7356
+ */
7357
+ declare function calculateTransferFeeExcludedAmount(transferFeeIncludedAmount: BN, mint: Mint, currentEpoch: number): TransferFeeExcludedAmount;
7358
+
7359
+ /**
7360
+ * Checks if a vesting schedule is ready for full release
7361
+ * @param vestingData The vesting account data
7362
+ * @param currentPoint Current timestamp or slot
7363
+ * @returns True if the vesting is complete and all liquidity can be released
7364
+ */
7365
+ declare function isVestingComplete(vestingData: VestingState, currentPoint: BN): boolean;
7366
+ /**
7367
+ * Gets the total amount of liquidity in the vesting schedule
7368
+ * @param vestingData The vesting account data
7369
+ * @returns The total locked liquidity amount
7370
+ */
7371
+ declare function getTotalLockedLiquidity(vestingData: VestingState): BN;
7372
+ /**
7373
+ * Calculates the available liquidity to withdraw based on vesting schedule
7374
+ * @param vestingData The vesting account data
7375
+ * @param positionData The position account data
7376
+ * @param currentPoint Current timestamp or slot
7377
+ * @returns The amount of liquidity available to withdraw
7378
+ */
7379
+ declare function getAvailableVestingLiquidity(vestingData: VestingState, currentPoint: BN): BN;
7380
+
7381
+ /**
7382
+ * Validate fee scheduler parameters
7383
+ * @param numberOfPeriod Number of periods
7384
+ * @param periodFrequency Period frequency
7385
+ * @param reductionFactor Reduction factor
7386
+ * @param cliffFeeNumerator Cliff fee numerator
7387
+ * @returns Validation result
7388
+ */
7389
+ declare function validateFeeScheduler(numberOfPeriod: number, periodFrequency: BN$1, reductionFactor: BN$1, cliffFeeNumerator: BN$1, baseFeeMode: BaseFeeMode, poolVersion: PoolVersion): boolean;
7390
+ /**
7391
+ * Validate rate limiter parameters
7392
+ * @param cliffFeeNumerator - Cliff fee numerator
7393
+ * @param feeIncrementBps - Fee increment bps
7394
+ * @param maxLimiterDuration - Max limiter duration
7395
+ * @param referenceAmount - Reference amount
7396
+ * @param collectFeeMode - Collect fee mode
7397
+ * @param activationType - Activation type (slot or timestamp)
7398
+ * @returns Validation result
7399
+ */
7400
+ declare function validateFeeRateLimiter(cliffFeeNumerator: BN$1, feeIncrementBps: number, maxFeeBps: number, maxLimiterDuration: number, referenceAmount: BN$1, collectFeeMode: CollectFeeMode, activationType: ActivationType, poolVersion: PoolVersion): boolean;
7401
+ /**
7402
+ * Validates that the fee fraction is valid (numerator < denominator, denominator != 0)
7403
+ * @param numerator - The numerator of the fee fraction
7404
+ * @param denominator - The denominator of the fee fraction
7405
+ * @throws Error if the fee fraction is invalid
7406
+ */
7407
+ declare function validateFeeFraction(numerator: BN$1, denominator: BN$1): void;
7408
+
7409
+ /**
7410
+ * Checks if the partner is valid
7411
+ * @param partner - The partner address
7412
+ * @returns True if the partner is valid, false otherwise
7413
+ */
7414
+ declare function hasPartner(poolState: PoolState): boolean;
7415
+ /**
7416
+ * Gets the current point
7417
+ * @param connection - The connection to the Solana cluster
7418
+ * @param activationType - The activation type
7419
+ * @returns The current point
7420
+ */
7421
+ declare function getCurrentPoint(connection: Connection, activationType: ActivationType): Promise<BN$1>;
7422
+ /**
7423
+ * Checks if the swap is enabled
7424
+ * @param pool - The pool
7425
+ * @param currentPoint - The current point
7426
+ * @returns True if the swap is enabled, false otherwise
7427
+ */
7428
+ declare function isSwapEnabled(pool: {
7429
+ poolStatus: PoolStatus;
7430
+ activationPoint: BN$1;
7431
+ }, currentPoint: BN$1): boolean;
7432
+ /**
7433
+ * Converts the value to a fee scheduler second factor
7434
+ * @param value - The value to convert
7435
+ * @returns The fee scheduler second factor
7436
+ */
7437
+ declare function convertToFeeSchedulerSecondFactor(value: BN$1): number[];
7438
+ /**
7439
+ * Parses the fee scheduler second factor
7440
+ * @param secondFactor - The fee scheduler second factor
7441
+ * @returns The fee scheduler second factor
7442
+ */
7443
+ declare function parseFeeSchedulerSecondFactor(secondFactor: number[]): BN$1;
7444
+ /**
7445
+ * Converts the value to a rate limiter second factor
7446
+ * @param maxLimiterDuration - The max limiter duration
7447
+ * @param maxFeeBps - The max fee in basis points
7448
+ * @returns The rate limiter second factor
7449
+ */
7450
+ declare function convertToRateLimiterSecondFactor(maxLimiterDuration: BN$1, maxFeeBps: BN$1): number[];
7451
+ /**
7452
+ * Parses the rate limiter second factor
7453
+ * @param secondFactor - The rate limiter second factor
7454
+ * @returns The rate limiter second factor
7455
+ */
7456
+ declare function parseRateLimiterSecondFactor(secondFactor: number[]): {
7457
+ maxLimiterDuration: number;
7458
+ maxFeeBps: number;
7459
+ };
7460
+ /**
7461
+ * Converts basis points (bps) to a fee numerator
7462
+ * 1 bps = 0.01% = 0.0001 in decimal
7463
+ *
7464
+ * @param bps - The value in basis points [1-10_000]
7465
+ * @returns The equivalent fee numerator
7466
+ */
7467
+ declare function bpsToFeeNumerator(bps: number): BN$1;
7468
+ /**
7469
+ * Converts a fee numerator back to basis points (bps)
7470
+ *
7471
+ * @param feeNumerator - The fee numerator to convert
7472
+ * @returns The equivalent value in basis points [1-10_000]
7473
+ */
7474
+ declare function feeNumeratorToBps(feeNumerator: BN$1): number;
7475
+ /**
7476
+ * Converts the amount to lamports
7477
+ * @param amount - The amount to convert
7478
+ * @param tokenDecimal - The token decimal
7479
+ * @returns The amount in lamports
7480
+ */
7481
+ declare function convertToLamports(amount: number | string, tokenDecimal: number): BN$1;
7482
+ /**
7483
+ * Converts the value to a BN
7484
+ * @param value - The value to convert
7485
+ * @returns The value in BN
7486
+ */
7487
+ declare function fromDecimalToBN(value: Decimal): BN$1;
7488
+ /**
7489
+ * Gets the fee scheduler parameters
7490
+ * @param startingBaseFeeBps - The starting base fee in basis points
7491
+ * @param endingBaseFeeBps - The ending base fee in basis points
7492
+ * @param baseFeeMode - The base fee mode
7493
+ * @param numberOfPeriod - The number of periods
7494
+ * @param totalDuration - The total duration
7495
+ * @param poolVersion - The pool version
7496
+ * @returns The fee scheduler parameters
7497
+ */
7498
+ declare function getFeeSchedulerParams(startingBaseFeeBps: number, endingBaseFeeBps: number, baseFeeMode: BaseFeeMode, numberOfPeriod: number, totalDuration: number): BaseFee;
7499
+ /**
7500
+ * Gets the rate limiter parameters
7501
+ * @param baseFeeBps - The base fee in basis points
7502
+ * @param feeIncrementBps - The fee increment in basis points
7503
+ * @param referenceAmount - The reference amount
7504
+ * @param maxLimiterDuration - The max limiter duration
7505
+ * @param maxFeeBps - The max fee in basis points
7506
+ * @param tokenBDecimal - The token B decimal
7507
+ * @param activationType - The activation type
7508
+ * @param poolVersion - The pool version
7509
+ * @returns The rate limiter parameters
7510
+ */
7511
+ declare function getRateLimiterParams(baseFeeBps: number, feeIncrementBps: number, referenceAmount: number, maxLimiterDuration: number, maxFeeBps: number, tokenBDecimal: number, activationType: ActivationType): BaseFee;
7512
+ /**
7513
+ * Gets the base fee parameters
7514
+ * @param baseFeeParams - The base fee parameters
7515
+ * @param tokenBDecimal - The token B decimal
7516
+ * @param activationType - The activation type
7517
+ * @param poolVersion - The pool version
7518
+ * @returns The base fee parameters
7519
+ */
7520
+ declare function getBaseFeeParams(baseFeeParams: {
7521
+ baseFeeMode: BaseFeeMode;
7522
+ rateLimiterParam?: {
7523
+ baseFeeBps: number;
7524
+ feeIncrementBps: number;
7525
+ referenceAmount: number;
7526
+ maxLimiterDuration: number;
7527
+ maxFeeBps: number;
7528
+ };
7529
+ feeSchedulerParam?: {
7530
+ startingFeeBps: number;
7531
+ endingFeeBps: number;
7532
+ numberOfPeriod: number;
7533
+ totalDuration: number;
7534
+ };
7535
+ }, tokenBDecimal: number, activationType: ActivationType): BaseFee;
7536
+ /**
7537
+ * Gets the dynamic fee parameters
7538
+ * @param baseFeeBps - The base fee in basis points
7539
+ * @param maxPriceChangeBps - The max price change in basis points
7540
+ * @returns The dynamic fee parameters
7541
+ */
7542
+ declare function getDynamicFeeParams(baseFeeBps: number, maxPriceChangeBps?: number): DynamicFee;
7543
+
7544
+ /**
7545
+ * Converts basis points to a numerator
7546
+ * @param bps - The basis points
7547
+ * @param feeDenominator - The fee denominator
7548
+ * @returns The numerator
7549
+ */
7550
+ declare function toNumerator(bps: BN, feeDenominator: BN): BN;
7551
+ /**
7552
+ * Gets the fee in a period
7553
+ * @param cliffFeeNumerator - The cliff fee numerator
7554
+ * @param reductionFactor - The reduction factor
7555
+ * @param passedPeriod - The passed period
7556
+ * @returns The fee in a period
7557
+ */
7558
+ declare function getFeeInPeriod(cliffFeeNumerator: BN, reductionFactor: BN, passedPeriod: number): BN;
7559
+ /**
7560
+ * Gets the fee mode
7561
+ * @param collectFeeMode - The collect fee mode
7562
+ * @param tradeDirection - The trade direction
7563
+ * @param hasReferral - The has referral
7564
+ * @returns The fee mode
7565
+ */
7566
+ declare function getFeeMode(collectFeeMode: CollectFeeMode, tradeDirection: TradeDirection, hasReferral: boolean): FeeMode;
7567
+ /**
7568
+ * Gets the total fee numerator
7569
+ * @param poolFees - The pool fees
7570
+ * @param baseFeeNumerator - The base fee numerator
7571
+ * @param maxFeeNumerator - The max fee numerator
7572
+ * @returns The total fee numerator
7573
+ */
7574
+ declare function getTotalFeeNumerator(poolFees: PoolFeesStruct, baseFeeNumerator: BN, maxFeeNumerator: BN): BN;
7575
+ /**
7576
+ * Gets the total trading fee from included fee amount
7577
+ * @param poolFees - The pool fees
7578
+ * @param currentPoint - The current point
7579
+ * @param activationPoint - The activation point
7580
+ * @param includedFeeAmount - The included fee amount
7581
+ * @param tradeDirection - The trade direction
7582
+ * @param maxFeeNumerator - The max fee numerator
7583
+ * @returns The total trading fee from included fee amount
7584
+ */
7585
+ declare function getTotalTradingFeeFromIncludedFeeAmount(poolFees: PoolFeesStruct, currentPoint: BN, activationPoint: BN, includedFeeAmount: BN, tradeDirection: TradeDirection, maxFeeNumerator: BN): BN;
7586
+ /**
7587
+ * Gets the total trading fee from excluded fee amount
7588
+ * @param poolFees - The pool fees
7589
+ * @param currentPoint - The current point
7590
+ * @param activationPoint - The activation point
7591
+ * @param excludedFeeAmount - The excluded fee amount
7592
+ * @param tradeDirection - The trade direction
7593
+ * @param maxFeeNumerator - The max fee numerator
7594
+ * @returns The total trading fee from excluded fee amount
7595
+ */
7596
+ declare function getTotalTradingFeeFromExcludedFeeAmount(poolFees: PoolFeesStruct, currentPoint: BN, activationPoint: BN, excludedFeeAmount: BN, tradeDirection: TradeDirection, maxFeeNumerator: BN): BN;
7597
+ /**
7598
+ * Splits the fees
7599
+ * @param poolFees - The pool fees
7600
+ * @param feeAmount - The fee amount
7601
+ * @param hasReferral - The has referral
7602
+ * @param hasPartner - The has partner
7603
+ * @returns The split fees
7604
+ */
7605
+ declare function splitFees(poolFees: PoolFeesStruct, feeAmount: BN, hasReferral: boolean, hasPartner: boolean): SplitFees;
7606
+ /**
7607
+ * Gets the fee on amount
7608
+ * @param poolFees - The pool fees
7609
+ * @param amount - The amount
7610
+ * @param tradeFeeNumerator - The trade fee numerator
7611
+ * @param hasReferral - The has referral
7612
+ * @param hasPartner - The has partner
7613
+ * @returns The fee on amount result
7614
+ */
7615
+ declare function getFeeOnAmount(poolFees: PoolFeesStruct, amount: BN, tradeFeeNumerator: BN, hasReferral: boolean, hasPartner: boolean): FeeOnAmountResult;
7616
+ /**
7617
+ * Calculates the excluded fee amount and trading fee from an included fee amount
7618
+ * @param tradeFeeNumerator - The fee numerator
7619
+ * @param includedFeeAmount - The amount that includes the fee
7620
+ * @returns Tuple of [excluded_fee_amount, trading_fee]
7621
+ */
7622
+ declare function getExcludedFeeAmount(tradeFeeNumerator: BN, includedFeeAmount: BN): {
7623
+ excludedFeeAmount: BN;
7624
+ tradingFee: BN;
7625
+ };
7626
+ /**
7627
+ * Calculates the included fee amount and fee amount from an excluded fee amount
7628
+ * @param tradeFeeNumerator - The fee numerator
7629
+ * @param excludedFeeAmount - The amount that excludes the fee
7630
+ * @returns Tuple of [included_fee_amount, fee_amount]
7631
+ */
7632
+ declare function getIncludedFeeAmount(tradeFeeNumerator: BN, excludedFeeAmount: BN): {
7633
+ includedFeeAmount: BN;
7634
+ feeAmount: BN;
7635
+ };
7636
+ /**
7637
+ * Gets the max fee numerator
7638
+ * @param poolVersion - The pool version
7639
+ * @returns The max fee numerator
7640
+ */
7641
+ declare function getMaxFeeNumerator(poolVersion: PoolVersion): BN;
7642
+ /**
7643
+ * Gets the max fee bps
7644
+ * @param poolVersion - The pool version
7645
+ * @returns The max fee bps
7646
+ */
7647
+ declare function getMaxFeeBps(poolVersion: PoolVersion): number;
7648
+
7649
+ /**
7650
+ * Multiplies two numbers and divides by a denominator, rounding up or down
7651
+ * @param x - The first number
7652
+ * @param y - The second number
7653
+ * @param denominator - The denominator
7654
+ * @param rounding - The rounding mode
7655
+ * @returns The result of the multiplication and division
7656
+ */
7657
+ declare function mulDiv(x: BN$1, y: BN$1, denominator: BN$1, rounding: Rounding): BN$1;
7658
+ /**
7659
+ * Converts a Q64 number to a Decimal
7660
+ * @param num - The Q64 number
7661
+ * @param decimalPlaces - The number of decimal places
7662
+ * @returns The Decimal number
7663
+ */
7664
+ declare function q64ToDecimal(num: BN$1, decimalPlaces?: number): Decimal;
7665
+ /**
7666
+ * Converts a Decimal number to a Q64 number
7667
+ * @param num - The Decimal number
7668
+ * @returns The Q64 number
7669
+ */
7670
+ declare function decimalToQ64(num: Decimal): BN$1;
7671
+ /**
7672
+ * Calculates the square root of a number
7673
+ * @param value - The number
7674
+ * @returns The square root of the number
7675
+ */
7676
+ declare function sqrt(value: BN$1): BN$1;
7677
+ /**
7678
+ * Calculates the power of a number
7679
+ * @param base - The base
7680
+ * @param exp - The exponent
7681
+ * @returns The power of the number
7682
+ */
7683
+ declare function pow(base: BN$1, exp: BN$1): BN$1;
7684
+
7685
+ /**
7686
+ * Fee Rate Limiter class
7687
+ */
7688
+ declare class FeeRateLimiter implements BaseFeeHandler {
7689
+ cliffFeeNumerator: BN$1;
7690
+ feeIncrementBps: number;
7691
+ maxFeeBps: number;
7692
+ maxLimiterDuration: number;
7693
+ referenceAmount: BN$1;
7694
+ constructor(cliffFeeNumerator: BN$1, feeIncrementBps: number, maxFeeBps: number, maxLimiterDuration: number, referenceAmount: BN$1);
7695
+ validate(collectFeeMode: CollectFeeMode, activationType: ActivationType, poolVersion: PoolVersion): boolean;
7696
+ getBaseFeeNumeratorFromIncludedFeeAmount(currentPoint: BN$1, activationPoint: BN$1, tradeDirection: TradeDirection, includedFeeAmount: BN$1): BN$1;
7697
+ getBaseFeeNumeratorFromExcludedFeeAmount(currentPoint: BN$1, activationPoint: BN$1, tradeDirection: TradeDirection, excludedFeeAmount: BN$1): BN$1;
7698
+ }
7699
+ /**
7700
+ * Fee Scheduler implementation
7701
+ */
7702
+ declare class FeeScheduler implements BaseFeeHandler {
7703
+ cliffFeeNumerator: BN$1;
7704
+ numberOfPeriod: number;
7705
+ periodFrequency: BN$1;
7706
+ reductionFactor: BN$1;
7707
+ feeSchedulerMode: BaseFeeMode;
7708
+ constructor(cliffFeeNumerator: BN$1, numberOfPeriod: number, periodFrequency: BN$1, reductionFactor: BN$1, feeSchedulerMode: BaseFeeMode);
7709
+ validate(collectFeeMode: CollectFeeMode, activationType: ActivationType, poolVersion: PoolVersion): boolean;
7710
+ getBaseFeeNumeratorFromIncludedFeeAmount(currentPoint: BN$1, activationPoint: BN$1): BN$1;
7711
+ getBaseFeeNumeratorFromExcludedFeeAmount(currentPoint: BN$1, activationPoint: BN$1): BN$1;
7712
+ }
7713
+ /**
7714
+ * Get base fee handler based on base fee mode
7715
+ * @param cliffFeeNumerator Cliff fee numerator
7716
+ * @param firstFactor First factor (feeScheduler: numberOfPeriod, rateLimiter: feeIncrementBps)
7717
+ * @param secondFactor Second factor (feeScheduler: periodFrequency, rateLimiter: maxLimiterDuration)
7718
+ * @param thirdFactor Third factor (feeScheduler: reductionFactor, rateLimiter: referenceAmount)
7719
+ * @param baseFeeMode Base fee mode
7720
+ * @returns Base fee handler instance
7721
+ */
7722
+ declare function getBaseFeeHandler(cliffFeeNumerator: BN$1, firstFactor: number, secondFactor: number[], thirdFactor: BN$1, baseFeeMode: BaseFeeMode): BaseFeeHandler;
7723
+
7724
+ /**
7725
+ * Check if dynamic fee is enabled
7726
+ * @param dynamicFee Dynamic fee parameters
7727
+ * @returns True if dynamic fee is enabled
7728
+ */
7729
+ declare function isDynamicFeeEnabled(dynamicFee: DynamicFeeStruct): boolean;
6733
7730
  /**
6734
7731
  * Calculates the dynamic fee numerator based on market volatility metrics
6735
7732
  *
@@ -6738,248 +7735,421 @@ declare function getBaseFeeNumerator(feeSchedulerMode: FeeSchedulerMode, cliffFe
6738
7735
  * @param variableFeeControl - Parameter controlling the impact of volatility on fees (BN)
6739
7736
  * @returns The calculated dynamic fee numerator (BN)
6740
7737
  */
6741
- declare function getDynamicFeeNumerator(volatilityAccumulator: BN, binStep: BN, variableFeeControl: BN): BN;
7738
+ declare function getDynamicFeeNumerator(volatilityAccumulator: BN$1, binStep: BN$1, variableFeeControl: BN$1): BN$1;
7739
+
7740
+ /**
7741
+ * Gets the max base fee numerator.
7742
+ * @param cliffFeeNumerator - The cliff fee numerator.
7743
+ * @returns The max base fee numerator.
7744
+ */
7745
+ declare function getMaxBaseFeeNumerator(cliffFeeNumerator: BN$1): BN$1;
7746
+ /**
7747
+ * Gets the min base fee numerator.
7748
+ * @param cliffFeeNumerator - The cliff fee numerator.
7749
+ * @param numberOfPeriod - The number of periods.
7750
+ * @param periodFrequency - The period frequency.
7751
+ * @param reductionFactor - The reduction factor.
7752
+ * @param feeSchedulerMode - The fee scheduler mode.
7753
+ * @returns The min base fee numerator.
7754
+ */
7755
+ declare function getMinBaseFeeNumerator(cliffFeeNumerator: BN$1, numberOfPeriod: number, periodFrequency: BN$1, reductionFactor: BN$1, feeSchedulerMode: BaseFeeMode): BN$1;
7756
+ /**
7757
+ * Gets the base fee numerator by period.
7758
+ * @param cliffFeeNumerator - The cliff fee numerator.
7759
+ * @param numberOfPeriod - The number of periods.
7760
+ * @param period - The period.
7761
+ * @param reductionFactor - The reduction factor.
7762
+ * @param feeSchedulerMode - The fee scheduler mode.
7763
+ * @returns The base fee numerator by period.
7764
+ */
7765
+ declare function getBaseFeeNumeratorByPeriod(cliffFeeNumerator: BN$1, numberOfPeriod: number, period: BN$1, reductionFactor: BN$1, feeSchedulerMode: BaseFeeMode): BN$1;
7766
+ /**
7767
+ * Gets the fee numerator on linear fee scheduler.
7768
+ * @param cliffFeeNumerator - The cliff fee numerator.
7769
+ * @param reductionFactor - The reduction factor.
7770
+ * @param period - The period.
7771
+ * @returns The fee numerator on linear fee scheduler.
7772
+ */
7773
+ declare function getFeeNumeratorOnLinearFeeScheduler(cliffFeeNumerator: BN$1, reductionFactor: BN$1, period: number): BN$1;
7774
+ /**
7775
+ * Gets the fee numerator on exponential fee scheduler.
7776
+ * @param cliffFeeNumerator - The cliff fee numerator.
7777
+ * @param reductionFactor - The reduction factor.
7778
+ * @param period - The period.
7779
+ * @returns The fee numerator on exponential fee scheduler.
7780
+ */
7781
+ declare function getFeeNumeratorOnExponentialFeeScheduler(cliffFeeNumerator: BN$1, reductionFactor: BN$1, period: number): BN$1;
7782
+ /**
7783
+ * Gets the base fee numerator.
7784
+ * @param cliffFeeNumerator - The cliff fee numerator.
7785
+ * @param numberOfPeriod - The number of periods.
7786
+ * @param periodFrequency - The period frequency.
7787
+ * @param reductionFactor - The reduction factor.
7788
+ * @param feeSchedulerMode - The fee scheduler mode.
7789
+ * @param currentPoint - The current point.
7790
+ * @param activationPoint - The activation point.
7791
+ * @returns The base fee numerator.
7792
+ */
7793
+ declare function getBaseFeeNumerator(cliffFeeNumerator: BN$1, numberOfPeriod: number, periodFrequency: BN$1, reductionFactor: BN$1, feeSchedulerMode: BaseFeeMode, currentPoint: BN$1, activationPoint: BN$1): BN$1;
7794
+
7795
+ /**
7796
+ * Checks if the rate limiter is zero.
7797
+ * @param referenceAmount - The reference amount.
7798
+ * @param maxLimiterDuration - The maximum rate limiter duration.
7799
+ * @param maxFeeBps - The maximum fee in basis points.
7800
+ * @param feeIncrementBps - The fee increment in basis points.
7801
+ * @returns True if the rate limiter is zero, false otherwise.
7802
+ */
7803
+ declare function isZeroRateLimiter(referenceAmount: BN$1, maxLimiterDuration: number, maxFeeBps: number, feeIncrementBps: number): boolean;
7804
+ /**
7805
+ * Checks if the rate limiter is non-zero.
7806
+ * @param referenceAmount - The reference amount.
7807
+ * @param maxLimiterDuration - The maximum rate limiter duration.
7808
+ * @param maxFeeBps - The maximum fee in basis points.
7809
+ * @param feeIncrementBps - The fee increment in basis points.
7810
+ * @returns True if the rate limiter is non-zero, false otherwise.
7811
+ */
7812
+ declare function isNonZeroRateLimiter(referenceAmount: BN$1, maxLimiterDuration: number, maxFeeBps: number, feeIncrementBps: number): boolean;
7813
+ /**
7814
+ * Checks if the rate limiter is applied.
7815
+ * @param referenceAmount - The reference amount.
7816
+ * @param maxLimiterDuration - The maximum rate limiter duration.
7817
+ * @param maxFeeBps - The maximum fee in basis points.
7818
+ * @param feeIncrementBps - The fee increment in basis points.
7819
+ * @param currentPoint - The current point.
7820
+ * @param activationPoint - The activation point.
7821
+ * @param tradeDirection - The trade direction.
7822
+ * @returns True if the rate limiter is applied, false otherwise.
7823
+ */
7824
+ declare function isRateLimiterApplied(referenceAmount: BN$1, maxLimiterDuration: number, maxFeeBps: number, feeIncrementBps: number, currentPoint: BN$1, activationPoint: BN$1, tradeDirection: TradeDirection): boolean;
7825
+ /**
7826
+ * Gets the maximum index.
7827
+ * @param maxFeeBps - The maximum fee in basis points.
7828
+ * @param cliffFeeNumerator - The cliff fee numerator.
7829
+ * @param feeIncrementBps - The fee increment in basis points.
7830
+ * @returns The maximum index.
7831
+ */
7832
+ declare function getMaxIndex(maxFeeBps: number, cliffFeeNumerator: BN$1, feeIncrementBps: number): BN$1;
7833
+ /**
7834
+ * Gets the fee numerator from included fee amount.
7835
+ * @param inputAmount - The input amount.
7836
+ * @param referenceAmount - The reference amount.
7837
+ * @param cliffFeeNumerator - The cliff fee numerator.
7838
+ * @param maxFeeBps - The maximum fee in basis points.
7839
+ * @param feeIncrementBps - The fee increment in basis points.
7840
+ * @returns The fee numerator from included fee amount.
7841
+ */
7842
+ declare function getFeeNumeratorFromIncludedFeeAmount(inputAmount: BN$1, referenceAmount: BN$1, cliffFeeNumerator: BN$1, maxFeeBps: number, feeIncrementBps: number): BN$1;
7843
+ /**
7844
+ * Gets the excluded fee amount from included fee amount.
7845
+ * @param includedFeeAmount - The included fee amount.
7846
+ * @param referenceAmount - The reference amount.
7847
+ * @param cliffFeeNumerator - The cliff fee numerator.
7848
+ * @param maxFeeBps - The maximum fee in basis points.
7849
+ * @param feeIncrementBps - The fee increment in basis points.
7850
+ * @returns The excluded fee amount.
7851
+ */
7852
+ declare function getExcludedFeeAmountFromIncludedFeeAmount(includedFeeAmount: BN$1, referenceAmount: BN$1, cliffFeeNumerator: BN$1, maxFeeBps: number, feeIncrementBps: number): BN$1;
7853
+ /**
7854
+ * Returns checked output and input amounts, and a flag indicating if the input was capped at u64::MAX.
7855
+ * @param referenceAmount - The reference amount
7856
+ * @param cliffFeeNumerator - The cliff fee numerator
7857
+ * @param maxFeeBps - The maximum fee in basis points
7858
+ * @param feeIncrementBps - The fee increment in basis points
7859
+ * @returns [checkedOutputAmount: BN, checkedIncludedFeeAmount: BN, capped: boolean]
7860
+ */
7861
+ declare function getCheckedAmounts(referenceAmount: BN$1, cliffFeeNumerator: BN$1, maxFeeBps: number, feeIncrementBps: number): {
7862
+ checkedExcludedFeeAmount: BN$1;
7863
+ checkedIncludedFeeAmount: BN$1;
7864
+ isOverflow: boolean;
7865
+ };
7866
+ /**
7867
+ * Calculates the fee numerator from an excluded fee amount.
7868
+ * @param excludedFeeAmount - The excluded fee amount
7869
+ * @param referenceAmount - The reference amount
7870
+ * @param cliffFeeNumerator - The cliff fee numerator
7871
+ * @param maxFeeBps - The maximum fee in basis points
7872
+ * @param feeIncrementBps - The fee increment in basis points
7873
+ * @returns The fee numerator
7874
+ */
7875
+ declare function getFeeNumeratorFromExcludedFeeAmount(excludedFeeAmount: BN$1, referenceAmount: BN$1, cliffFeeNumerator: BN$1, maxFeeBps: number, feeIncrementBps: number): BN$1;
7876
+
6742
7877
  /**
6743
- * Calculates the fee numerator based on current market conditions and fee schedule configuration
6744
- *
6745
- * @param currentPoint - The current price point in the liquidity curve
6746
- * @param activationPoint - The price point at which the fee schedule is activated (BN)
6747
- * @param numberOfPeriod - The total number of periods in the fee schedule
6748
- * @param periodFrequency - The frequency at which periods change (BN)
6749
- * @param feeSchedulerMode - The mode determining how fees are calculated (0 = constant, 1 = linear, etc.)
6750
- * @param cliffFeeNumerator - The initial fee numerator at the cliff point (BN)
6751
- * @param reductionFactor - The factor by which fees are reduced in each period (BN)
6752
- * @param dynamicFeeParams - Optional parameters for dynamic fee calculation
6753
- * @param dynamicFeeParams.volatilityAccumulator - Measure of accumulated market volatility (BN)
6754
- * @param dynamicFeeParams.binStep - Size of price bins in the liquidity distribution (BN)
6755
- * @param dynamicFeeParams.variableFeeControl - Parameter controlling the impact of volatility (BN)
6756
- * @returns The calculated fee numerator (BN), capped at MAX_FEE_NUMERATOR
7878
+ * Gets the swap result from exact input
7879
+ * @param poolState - The pool state
7880
+ * @param amountIn - The amount in
7881
+ * @param feeMode - The fee mode
7882
+ * @param tradeDirection - The trade direction
7883
+ * @param currentPoint - The current point
7884
+ * @returns The swap result from exact input
6757
7885
  */
6758
- declare function getFeeNumerator(currentPoint: number, activationPoint: BN, numberOfPeriod: number, periodFrequency: BN, feeSchedulerMode: number, cliffFeeNumerator: BN, reductionFactor: BN, dynamicFeeParams?: {
6759
- volatilityAccumulator: BN;
6760
- binStep: number;
6761
- variableFeeControl: number;
6762
- }): BN;
7886
+ declare function getSwapResultFromExactInput(poolState: PoolState, amountIn: BN$1, feeMode: FeeMode, tradeDirection: TradeDirection, currentPoint: BN$1): SwapResult2;
6763
7887
  /**
6764
- * Determines the fee mode based on the swap direction and fee collection configuration
6765
- *
6766
- * @param collectFeeMode - The fee collection mode (e.g., OnlyB, BothToken)
6767
- * @param btoA - Boolean indicating if the swap is from token B to token A
6768
- * @returns { feeOnInput, feesOnTokenA }
7888
+ * Calculates the swap result from exact input
7889
+ * @param poolState - The pool state
7890
+ * @param amountIn - The amount in
7891
+ * @returns The swap result from exact input
6769
7892
  */
6770
- declare function getFeeMode(collectFeeMode: CollectFeeMode, btoA: boolean): FeeMode;
7893
+ declare function calculateAtoBFromAmountIn(poolState: PoolState, amountIn: BN$1): {
7894
+ outputAmount: BN$1;
7895
+ nextSqrtPrice: BN$1;
7896
+ amountLeft: BN$1;
7897
+ };
6771
7898
  /**
6772
- *
6773
- * Calculates the output amount and fees for a swap operation in a concentrated liquidity pool.
6774
- *
6775
- * @param inAmount - The input amount of tokens the user is swapping
6776
- * @param sqrtPrice - The current square root price of the pool
6777
- * @param liquidity - The current liquidity available in the pool
6778
- * @param tradeFeeNumerator - The fee numerator used to calculate trading fees
6779
- * @param aToB - Direction of the swap: true for token A to token B, false for token B to token A
6780
- * @param collectFeeMode - Determines how fees are collected (0: both tokens, 1: only token B)
6781
- * @returns Object containing the actual output amount after fees and the total fee amount
7899
+ * Calculates the swap result from exact input
7900
+ * @param poolState - The pool state
7901
+ * @param amountIn - The amount in
7902
+ * @returns The swap result from exact input
6782
7903
  */
6783
- declare function getSwapAmount(inAmount: BN, sqrtPrice: BN, liquidity: BN, tradeFeeNumerator: BN, aToB: boolean, collectFeeMode: number): {
6784
- amountOut: BN;
6785
- totalFee: BN;
6786
- nextSqrtPrice: BN;
7904
+ declare function calculateBtoAFromAmountIn(poolState: PoolState, amountIn: BN$1): {
7905
+ outputAmount: BN$1;
7906
+ nextSqrtPrice: BN$1;
7907
+ amountLeft: BN$1;
6787
7908
  };
6788
7909
  /**
6789
- * Converts basis points (bps) to a fee numerator
6790
- * 1 bps = 0.01% = 0.0001 in decimal
6791
- *
6792
- * @param bps - The value in basis points [1-10_000]
6793
- * @returns The equivalent fee numerator
7910
+ * Gets the swap result from partial input
7911
+ * @param poolState - The pool state
7912
+ * @param amountIn - The amount in
7913
+ * @param feeMode - The fee mode
7914
+ * @param tradeDirection - The trade direction
7915
+ * @param currentPoint - The current point
7916
+ * @returns The swap result from partial input
6794
7917
  */
6795
- declare function bpsToFeeNumerator(bps: number): BN;
7918
+ declare function getSwapResultFromPartialInput(poolState: PoolState, amountIn: BN$1, feeMode: FeeMode, tradeDirection: TradeDirection, currentPoint: BN$1): SwapResult2;
6796
7919
  /**
6797
- * Converts a fee numerator back to basis points (bps)
6798
- *
6799
- * @param feeNumerator - The fee numerator to convert
6800
- * @returns The equivalent value in basis points [1-10_000]
7920
+ * Calculates the swap result from partial input
7921
+ * @param poolState - The pool state
7922
+ * @param amountIn - The amount in
7923
+ * @returns The swap result from partial input
6801
7924
  */
6802
- declare function feeNumeratorToBps(feeNumerator: BN): number;
7925
+ declare function calculateAtoBFromPartialAmountIn(poolState: PoolState, amountIn: BN$1): {
7926
+ outputAmount: BN$1;
7927
+ nextSqrtPrice: BN$1;
7928
+ amountLeft: BN$1;
7929
+ };
6803
7930
  /**
6804
- * Calculates base fee parameters for a fee scheduler system.
6805
- * @param {number} maxBaseFeeBps - Maximum fee in basis points
6806
- * @param {number} minBaseFeeBps - Minimum fee in basis points
6807
- * @param {FeeSchedulerMode} feeSchedulerMode - Mode for fee reduction (Linear or Exponential)
6808
- * @param {number} numberOfPeriod - Number of periods over which to schedule fee reduction
6809
- * @param {BN} periodFrequency - Time interval between fee reductions
6810
- *
6811
- * @returns {BaseFee}
7931
+ * Calculates the swap result from partial input
7932
+ * @param poolState - The pool state
7933
+ * @param amountIn - The amount in
7934
+ * @returns The swap result from partial input
6812
7935
  */
6813
- declare function getBaseFeeParams(maxBaseFeeBps: number, minBaseFeeBps: number, feeSchedulerMode: FeeSchedulerMode, numberOfPeriod: number, totalDuration: number): BaseFee;
7936
+ declare function calculateBtoAFromPartialAmountIn(poolState: PoolState, amountIn: BN$1): {
7937
+ outputAmount: BN$1;
7938
+ nextSqrtPrice: BN$1;
7939
+ amountLeft: BN$1;
7940
+ };
6814
7941
  /**
6815
- * Calculate dynamic fee parameters
6816
- * @param {number} baseFeeBps - Base fee in basis points
6817
- * @param {number} [maxPriceChangeBps=1500] - Maximum price change to consider for fee calculation (in basis points)
6818
- *
6819
- * @returns {DynamicFee}
7942
+ * Gets the swap result from exact output
7943
+ * @param poolState - The pool state
7944
+ * @param amountOut - The amount out
7945
+ * @param feeMode - The fee mode
7946
+ * @param tradeDirection - The trade direction
7947
+ * @param currentPoint - The current point
7948
+ * @returns The swap result from exact output
6820
7949
  */
6821
- declare function getDynamicFeeParams(baseFeeBps: number, maxPriceChangeBps?: number): DynamicFee;
7950
+ declare function getSwapResultFromExactOutput(poolState: PoolState, amountOut: BN$1, feeMode: FeeMode, tradeDirection: TradeDirection, currentPoint: BN$1): SwapResult2;
6822
7951
  /**
6823
- * Calculates the excluded fee amount and trading fee from an included fee amount
6824
- * @param tradeFeeNumerator - The fee numerator
6825
- * @param includedFeeAmount - The amount that includes the fee
6826
- * @returns Tuple of [excluded_fee_amount, trading_fee]
7952
+ * Calculates the swap result from exact output
7953
+ * @param poolState - The pool state
7954
+ * @param amountOut - The amount out
7955
+ * @returns The swap result from exact output
6827
7956
  */
6828
- declare function getExcludedFeeAmount(tradeFeeNumerator: BN, includedFeeAmount: BN): {
6829
- excludedFeeAmount: BN;
6830
- tradingFee: BN;
7957
+ declare function calculateAtoBFromAmountOut(poolState: PoolState, amountOut: BN$1): {
7958
+ inputAmount: BN$1;
7959
+ nextSqrtPrice: BN$1;
6831
7960
  };
6832
7961
  /**
6833
- * Calculates the included fee amount from an excluded fee amount
6834
- * @param tradeFeeNumerator - The fee numerator
6835
- * @param excludedFeeAmount - The amount that excludes the fee
6836
- * @returns The amount including the fee
7962
+ * Calculates the swap result from exact output
7963
+ * @param poolState - The pool state
7964
+ * @param amountOut - The amount out
7965
+ * @returns The swap result from exact output
6837
7966
  */
6838
- declare function getIncludedFeeAmount(tradeFeeNumerator: BN, excludedFeeAmount: BN): BN;
7967
+ declare function calculateBtoAFromAmountOut(poolState: PoolState, amountOut: BN$1): {
7968
+ inputAmount: BN$1;
7969
+ nextSqrtPrice: BN$1;
7970
+ };
6839
7971
  /**
6840
- * Calculates the swap result from a given output amount
6841
- * @param pool - The pool state
6842
- * @param outAmount - The desired output amount
6843
- * @param feeMode - The fee mode configuration
6844
- * @param tradeDirection - The direction of the trade
6845
- * @param currentPoint - The current time/slot point
6846
- * @returns Tuple of [SwapResult, input_amount]
7972
+ * Swaps quote exact input
7973
+ * @param pool - The pool
7974
+ * @param currentPoint - The current point
7975
+ * @param amountIn - The amount in
7976
+ * @param slippage - The slippage
7977
+ * @param aToB - The trade direction
7978
+ * @param hasReferral - The has referral
7979
+ * @param tokenADecimal - The token A decimal
7980
+ * @param tokenBDecimal - The token B decimal
7981
+ * @param inputTokenInfo - The input token info
7982
+ * @param outputTokenInfo - The output token info
7983
+ * @returns The swap quote exact input
6847
7984
  */
6848
- declare function getSwapResultFromOutAmount(pool: PoolState, outAmount: BN, feeMode: FeeMode & {
6849
- hasReferral?: boolean;
6850
- }, tradeDirection: TradeDirection, currentPoint: number): {
6851
- swapResult: SwapResult;
6852
- inputAmount: BN;
6853
- };
6854
-
6855
- declare function getNextSqrtPrice(amount: BN, sqrtPrice: BN, liquidity: BN, aToB: boolean): BN;
6856
- declare function getLiquidityDeltaFromAmountA(amountA: BN, lowerSqrtPrice: BN, // current sqrt price
6857
- upperSqrtPrice: BN): BN;
6858
- declare function getLiquidityDeltaFromAmountB(amountB: BN, lowerSqrtPrice: BN, // min sqrt price
6859
- upperSqrtPrice: BN): BN;
6860
- declare function getAmountAFromLiquidityDelta(liquidity: BN, currentSqrtPrice: BN, // current sqrt price
6861
- maxSqrtPrice: BN, rounding: Rounding): BN;
6862
- declare function getAmountBFromLiquidityDelta(liquidity: BN, currentSqrtPrice: BN, // current sqrt price,
6863
- minSqrtPrice: BN, rounding: Rounding): BN;
6864
- declare function getNextSqrtPriceFromAmountBRoundingUp(sqrtPrice: BN, liquidity: BN, amount: BN): BN;
6865
- declare function getNextSqrtPriceFromAmountARoundingDown(sqrtPrice: BN, liquidity: BN, amount: BN): BN;
6866
- declare function getNextSqrtPriceFromOutput(sqrtPrice: BN, liquidity: BN, outAmount: BN, isB: boolean): BN;
6867
-
6868
- declare const getSimulationComputeUnits: (connection: Connection, instructions: Array<TransactionInstruction>, payer: PublicKey, lookupTables: Array<AddressLookupTableAccount> | [], commitment?: Commitment) => Promise<number | null>;
7985
+ declare function swapQuoteExactInput(pool: PoolState, currentPoint: BN$1, amountIn: BN$1, slippage: number, aToB: boolean, hasReferral: boolean, tokenADecimal: number, tokenBDecimal: number, inputTokenInfo?: {
7986
+ mint: Mint;
7987
+ currentEpoch: number;
7988
+ }, outputTokenInfo?: {
7989
+ mint: Mint;
7990
+ currentEpoch: number;
7991
+ }): Quote2Result;
6869
7992
  /**
6870
- * Gets the estimated compute unit usage with a buffer.
6871
- * @param connection A Solana connection object.
6872
- * @param instructions The instructions of the transaction to simulate.
6873
- * @param feePayer The public key of the fee payer.
6874
- * @param buffer The buffer to add to the estimated compute unit usage. Max value is 1. Default value is 0.1 if not provided, and will be capped between 50k - 200k.
6875
- * @returns The estimated compute unit usage with the buffer.
7993
+ * Swaps quote exact output
7994
+ * @param pool - The pool
7995
+ * @param currentPoint - The current point
7996
+ * @param amountOut - The amount out
7997
+ * @param slippage - The slippage
7998
+ * @param aToB - The trade direction
7999
+ * @param hasReferral - The has referral
8000
+ * @param tokenADecimal - The token A decimal
8001
+ * @param tokenBDecimal - The token B decimal
8002
+ * @param inputTokenInfo - The input token info
8003
+ * @param outputTokenInfo - The output token info
8004
+ * @returns The swap quote exact output
6876
8005
  */
6877
- declare const getEstimatedComputeUnitUsageWithBuffer: (connection: Connection, instructions: TransactionInstruction[], feePayer: PublicKey, buffer?: number) => Promise<number>;
8006
+ declare function swapQuoteExactOutput(pool: PoolState, currentPoint: BN$1, amountOut: BN$1, slippage: number, aToB: boolean, hasReferral: boolean, tokenADecimal: number, tokenBDecimal: number, inputTokenInfo?: {
8007
+ mint: Mint;
8008
+ currentEpoch: number;
8009
+ }, outputTokenInfo?: {
8010
+ mint: Mint;
8011
+ currentEpoch: number;
8012
+ }): Quote2Result;
6878
8013
  /**
6879
- * Gets the estimated compute unit usage with a buffer and converts it to a SetComputeUnitLimit instruction.
6880
- * If the estimated compute unit usage cannot be retrieved, returns a SetComputeUnitLimit instruction with the fallback unit.
6881
- * @param connection A Solana connection object.
6882
- * @param instructions The instructions of the transaction to simulate.
6883
- * @param feePayer The public key of the fee payer.
6884
- * @param buffer The buffer to add to the estimated compute unit usage. Max value is 1. Default value is 0.1 if not provided, and will be capped between 50k - 200k.
6885
- * @returns A SetComputeUnitLimit instruction with the estimated compute unit usage.
8014
+ * Swaps quote partial input
8015
+ * @param pool - The pool
8016
+ * @param currentPoint - The current point
8017
+ * @param amountIn - The amount in
8018
+ * @param slippage - The slippage
8019
+ * @param aToB - The trade direction
8020
+ * @param hasReferral - The has referral
8021
+ * @param tokenADecimal - The token A decimal
8022
+ * @param tokenBDecimal - The token B decimal
8023
+ * @param inputTokenInfo - The input token info
8024
+ * @param outputTokenInfo - The output token info
8025
+ * @returns The swap quote partial input
6886
8026
  */
6887
- declare const getEstimatedComputeUnitIxWithBuffer: (connection: Connection, instructions: TransactionInstruction[], feePayer: PublicKey, buffer?: number) => Promise<TransactionInstruction>;
8027
+ declare function swapQuotePartialInput(pool: PoolState, currentPoint: BN$1, amountIn: BN$1, slippage: number, aToB: boolean, hasReferral: boolean, tokenADecimal: number, tokenBDecimal: number, inputTokenInfo?: {
8028
+ mint: Mint;
8029
+ currentEpoch: number;
8030
+ }, outputTokenInfo?: {
8031
+ mint: Mint;
8032
+ currentEpoch: number;
8033
+ }): Quote2Result;
6888
8034
 
6889
8035
  /**
6890
- * It takes an amount and a slippage rate, and returns the maximum amount that can be received with
6891
- * that slippage rate
6892
- * @param {BN} amount - The amount of tokens you want to buy.
6893
- * @param {number} rate - The maximum percentage of slippage you're willing to accept. (Max to 2 decimal place)
6894
- * @returns The maximum amount of tokens that can be bought with the given amount of ETH, given the
6895
- * slippage rate.
8036
+ * Gets the next sqrt price given a delta of token_b (input), rounding down.
8037
+ * √P' = √P + Δb / L
8038
+ * @param sqrtPrice - current sqrt price (BN)
8039
+ * @param liquidity - current liquidity (BN)
8040
+ * @param amount - delta of token_b (BN)
8041
+ * @returns next sqrt price (BN)
6896
8042
  */
6897
- declare const getMaxAmountWithSlippage: (amount: BN, rate: number) => BN;
8043
+ declare function getNextSqrtPriceFromAmountInBRoundingDown(sqrtPrice: BN$1, liquidity: BN$1, amount: BN$1): BN$1;
6898
8044
  /**
6899
- * It takes an amount and a slippage rate, and returns the minimum amount that will be received after
6900
- * slippage
6901
- * @param {BN} amount - The amount of tokens you want to sell.
6902
- * @param {number} rate - The percentage of slippage you're willing to accept. (Max to 2 decimal place)
6903
- * @returns The minimum amount that can be received after slippage is applied.
8045
+ * Gets the next sqrt price given a delta of token_b (output), rounding down.
8046
+ * √P' = √P - Δb / L
8047
+ * @param sqrtPrice - current sqrt price (BN)
8048
+ * @param liquidity - current liquidity (BN)
8049
+ * @param amount - delta of token_b (BN)
8050
+ * @returns next sqrt price (BN)
6904
8051
  */
6905
- declare const getMinAmountWithSlippage: (amount: BN, rate: number) => BN;
8052
+ declare function getNextSqrtPriceFromAmountOutBRoundingDown(sqrtPrice: BN$1, liquidity: BN$1, amount: BN$1): BN$1;
6906
8053
  /**
6907
- * Calculate price impact as a percentage
6908
- * Price impact measures how much worse the user's execution was compared to the current market price
6909
- * @param amountIn - Input amount (in base units)
6910
- * @param amountOut - Output amount (in base units)
6911
- * @param currentSqrtPrice - Current pool sqrt price (spot price)
6912
- * @param aToB - Direction of swap: true for token A to token B, false for token B to token A
6913
- * @param tokenADecimal - Decimal places for token A
6914
- * @param tokenBDecimal - Decimal places for token B
6915
- * @returns Price impact as a percentage (e.g., 1.5 means 1.5% worse than spot price)
8054
+ * Gets the next sqrt price √P' given a delta of token_a, rounding up.
8055
+ * √P' = √P * L / (L + Δa * √P)
8056
+ * @param sqrtPrice - current sqrt price (BN)
8057
+ * @param liquidity - current liquidity (BN)
8058
+ * @param amount - delta of token_a (BN)
8059
+ * @returns next sqrt price (BN)
6916
8060
  */
6917
- declare const getPriceImpact: (amountIn: BN, amountOut: BN, currentSqrtPrice: BN, aToB: boolean, tokenADecimal: number, tokenBDecimal: number) => Decimal;
8061
+ declare function getNextSqrtPriceFromAmountInARoundingUp(sqrtPrice: BN$1, liquidity: BN$1, amount: BN$1): BN$1;
6918
8062
  /**
6919
- * Calculate price change as a percentage (old implementation)
6920
- * This measures the percentage change in pool price after a swap
6921
- * @param nextSqrtPrice sqrt price after swap
6922
- * @param currentSqrtPrice current pool sqrt price
6923
- * @returns Price change as a percentage (e.g., 1.5 means 1.5% change)
8063
+ * Gets the next sqrt price √P' given a delta of token_a (output), rounding up.
8064
+ * √P' = √P * L / (L - Δa * √P)
8065
+ * @param sqrtPrice - current sqrt price (BN)
8066
+ * @param liquidity - current liquidity (BN)
8067
+ * @param amount - delta of token_a (BN)
8068
+ * @returns next sqrt price (BN)
6924
8069
  */
6925
- declare const getPriceChange: (nextSqrtPrice: BN, currentSqrtPrice: BN) => number;
6926
- declare const getPriceFromSqrtPrice: (sqrtPrice: BN, tokenADecimal: number, tokenBDecimal: number) => Decimal;
6927
- declare const getSqrtPriceFromPrice: (price: string, tokenADecimal: number, tokenBDecimal: number) => BN;
6928
- declare const getUnClaimReward: (poolState: PoolState, positionState: PositionState) => {
6929
- feeTokenA: BN;
6930
- feeTokenB: BN;
6931
- rewards: BN[];
6932
- };
6933
-
6934
- declare const positionByPoolFilter: (pool: PublicKey) => GetProgramAccountsFilter;
6935
- declare const vestingByPositionFilter: (position: PublicKey) => GetProgramAccountsFilter;
6936
-
6937
- declare function calculateInitSqrtPrice(tokenAAmount: BN, tokenBAmount: BN, minSqrtPrice: BN, maxSqrtPrice: BN): BN;
6938
-
6939
- interface TransferFeeIncludedAmount {
6940
- amount: BN;
6941
- transferFee: BN;
6942
- }
6943
- declare function calculateTransferFeeIncludedAmount(transferFeeExcludedAmount: BN, mint: Mint, currentEpoch: number): TransferFeeIncludedAmount;
6944
- interface TransferFeeExcludedAmount {
6945
- amount: BN;
6946
- transferFee: BN;
6947
- }
6948
- declare function calculateTransferFeeExcludedAmount(transferFeeIncludedAmount: BN, mint: Mint, currentEpoch: number): TransferFeeExcludedAmount;
6949
-
8070
+ declare function getNextSqrtPriceFromAmountOutARoundingUp(sqrtPrice: BN$1, liquidity: BN$1, amount: BN$1): BN$1;
6950
8071
  /**
6951
- * Checks if a vesting schedule is ready for full release
6952
- * @param vestingData The vesting account data
6953
- * @param currentPoint Current timestamp or slot
6954
- * @returns True if the vesting is complete and all liquidity can be released
8072
+ * Gets the next sqrt price given an output amount of token_a or token_b.
8073
+ * @param sqrtPrice - current sqrt price (BN)
8074
+ * @param liquidity - current liquidity (BN)
8075
+ * @param amountOut - output amount (BN)
8076
+ * @param aForB - true if swapping A for B, false if B for A
8077
+ * @returns next sqrt price (BN)
6955
8078
  */
6956
- declare function isVestingComplete(vestingData: VestingState, currentPoint: BN): boolean;
8079
+ declare function getNextSqrtPriceFromOutput(sqrtPrice: BN$1, liquidity: BN$1, amountOut: BN$1, aForB: boolean): BN$1;
6957
8080
  /**
6958
- * Gets the total amount of liquidity in the vesting schedule
6959
- * @param vestingData The vesting account data
6960
- * @returns The total locked liquidity amount
8081
+ * Gets the next sqrt price given an input amount of token_a or token_b
8082
+ * @param sqrtPrice - current sqrt price (BN)
8083
+ * @param liquidity - current liquidity (BN)
8084
+ * @param amountIn - input amount (BN)
8085
+ * @param aForB - true if swapping A for B, false if B for A
8086
+ * @returns next sqrt price (BN)
6961
8087
  */
6962
- declare function getTotalLockedLiquidity(vestingData: VestingState): BN;
8088
+ declare function getNextSqrtPriceFromInput(sqrtPrice: BN$1, liquidity: BN$1, amountIn: BN$1, aForB: boolean): BN$1;
6963
8089
  /**
6964
- * Calculates the available liquidity to withdraw based on vesting schedule
6965
- * @param vestingData The vesting account data
6966
- * @param positionData The position account data
6967
- * @param currentPoint Current timestamp or slot
6968
- * @returns The amount of liquidity available to withdraw
8090
+ * Gets the delta amount of token_b for given liquidity and price range. (getDeltaAmountBUnsigned)
8091
+ * @param lowerSqrtPrice - lower sqrt price (BN)
8092
+ * @param upperSqrtPrice - upper sqrt price (BN)
8093
+ * @param liquidity - current liquidity (BN)
8094
+ * @param rounding - rounding (Rounding)
8095
+ * @returns delta amount of token_b (BN)
6969
8096
  */
6970
- declare function getAvailableVestingLiquidity(vestingData: VestingState, currentPoint: BN): BN;
6971
-
6972
- declare const ONE: BN;
6973
- declare function pow(base: BN, exp: BN): BN;
8097
+ declare function getAmountBFromLiquidityDelta(lowerSqrtPrice: BN$1, upperSqrtPrice: BN$1, liquidity: BN$1, rounding: Rounding): BN$1;
8098
+ /**
8099
+ * Gets the delta amount_a for given liquidity and price range. (getDeltaAmountAUnsigned)
8100
+ * `Δa = L * (1 / √P_lower - 1 / √P_upper)`
8101
+ * i.e. `L * (√P_upper - √P_lower) / (√P_upper * √P_lower)`
8102
+ * @param lowerSqrtPrice - lower sqrt price (BN)
8103
+ * @param upperSqrtPrice - upper sqrt price (BN)
8104
+ * @param liquidity - current liquidity (BN)
8105
+ * @param rounding - rounding (Rounding)
8106
+ * @returns delta amount of token_a (BN)
8107
+ */
8108
+ declare function getAmountAFromLiquidityDelta(lowerSqrtPrice: BN$1, upperSqrtPrice: BN$1, liquidity: BN$1, rounding: Rounding): BN$1;
8109
+ /**
8110
+ * Gets the liquidity delta from amount A
8111
+ * Δa = L * (1 / √P_lower - 1 / √P_upper)
8112
+ * Δa = L * (√P_upper - √P_lower) / (√P_upper * √P_lower)
8113
+ * L = Δa * √P_upper * √P_lower / (√P_upper - √P_lower)
8114
+ * @param amountA - The amount of token A
8115
+ * @param lowerSqrtPrice - The lower sqrt price
8116
+ * @param upperSqrtPrice - The upper sqrt price
8117
+ * @returns The liquidity delta from amount A
8118
+ */
8119
+ declare function getLiquidityDeltaFromAmountA(amountA: BN$1, lowerSqrtPrice: BN$1, // current sqrt price
8120
+ upperSqrtPrice: BN$1): BN$1;
8121
+ /**
8122
+ * Gets the liquidity delta from amount B
8123
+ * Δb = L (√P_upper - √P_lower)
8124
+ * L = Δb / (√P_upper - √P_lower)
8125
+ * @param amountB - The amount of token B
8126
+ * @param lowerSqrtPrice - The lower sqrt price
8127
+ * @param upperSqrtPrice - The upper sqrt price
8128
+ * @returns The liquidity delta from amount B
8129
+ */
8130
+ declare function getLiquidityDeltaFromAmountB(amountB: BN$1, lowerSqrtPrice: BN$1, // min sqrt price
8131
+ upperSqrtPrice: BN$1): BN$1;
6974
8132
 
6975
- declare function mulDiv(x: BN, y: BN, denominator: BN, rounding: Rounding): BN;
6976
- declare function q64ToDecimal(num: BN, decimalPlaces?: number): Decimal;
6977
- declare function decimalToQ64(num: Decimal): BN;
8133
+ /**
8134
+ * Calculates the initial sqrt price
8135
+ * a = L * (1/s - 1/pb)
8136
+ * b = L * (s - pa)
8137
+ * b/a = (s - pa) / (1/s - 1/pb)
8138
+ * With: x = 1 / pb and y = b/a
8139
+ * => s ^ 2 + s * (-pa + x * y) - y = 0
8140
+ * s = [(pa - xy) + √((xy - pa)² + 4y)]/2
8141
+ * @param tokenAAmount - The token A amount
8142
+ * @param tokenBAmount - The token B amount
8143
+ * @param minSqrtPrice - The min sqrt price
8144
+ * @param maxSqrtPrice - The max sqrt price
8145
+ * @returns The initial sqrt price
8146
+ */
8147
+ declare function calculateInitSqrtPrice(tokenAAmount: BN, tokenBAmount: BN, minSqrtPrice: BN, maxSqrtPrice: BN): BN;
6978
8148
 
6979
8149
  var address = "cpamdpZCGKUy5JxQXB4dcpGPiikHawvSWAd6mEn1sGG";
6980
8150
  var metadata = {
6981
8151
  name: "cp_amm",
6982
- version: "0.1.4",
8152
+ version: "0.1.5",
6983
8153
  spec: "0.1.0",
6984
8154
  description: "Created with Anchor"
6985
8155
  };
@@ -10570,7 +11740,148 @@ var instructions = [
10570
11740
  name: "params",
10571
11741
  type: {
10572
11742
  defined: {
10573
- name: "SwapParameters"
11743
+ name: "SwapParameters"
11744
+ }
11745
+ }
11746
+ }
11747
+ ]
11748
+ },
11749
+ {
11750
+ name: "swap2",
11751
+ discriminator: [
11752
+ 65,
11753
+ 75,
11754
+ 63,
11755
+ 76,
11756
+ 235,
11757
+ 91,
11758
+ 91,
11759
+ 136
11760
+ ],
11761
+ accounts: [
11762
+ {
11763
+ name: "pool_authority",
11764
+ address: "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC"
11765
+ },
11766
+ {
11767
+ name: "pool",
11768
+ docs: [
11769
+ "Pool account"
11770
+ ],
11771
+ writable: true
11772
+ },
11773
+ {
11774
+ name: "input_token_account",
11775
+ docs: [
11776
+ "The user token account for input token"
11777
+ ],
11778
+ writable: true
11779
+ },
11780
+ {
11781
+ name: "output_token_account",
11782
+ docs: [
11783
+ "The user token account for output token"
11784
+ ],
11785
+ writable: true
11786
+ },
11787
+ {
11788
+ name: "token_a_vault",
11789
+ docs: [
11790
+ "The vault token account for input token"
11791
+ ],
11792
+ writable: true,
11793
+ relations: [
11794
+ "pool"
11795
+ ]
11796
+ },
11797
+ {
11798
+ name: "token_b_vault",
11799
+ docs: [
11800
+ "The vault token account for output token"
11801
+ ],
11802
+ writable: true,
11803
+ relations: [
11804
+ "pool"
11805
+ ]
11806
+ },
11807
+ {
11808
+ name: "token_a_mint",
11809
+ docs: [
11810
+ "The mint of token a"
11811
+ ]
11812
+ },
11813
+ {
11814
+ name: "token_b_mint",
11815
+ docs: [
11816
+ "The mint of token b"
11817
+ ]
11818
+ },
11819
+ {
11820
+ name: "payer",
11821
+ docs: [
11822
+ "The user performing the swap"
11823
+ ],
11824
+ signer: true
11825
+ },
11826
+ {
11827
+ name: "token_a_program",
11828
+ docs: [
11829
+ "Token a program"
11830
+ ]
11831
+ },
11832
+ {
11833
+ name: "token_b_program",
11834
+ docs: [
11835
+ "Token b program"
11836
+ ]
11837
+ },
11838
+ {
11839
+ name: "referral_token_account",
11840
+ docs: [
11841
+ "referral token account"
11842
+ ],
11843
+ writable: true,
11844
+ optional: true
11845
+ },
11846
+ {
11847
+ name: "event_authority",
11848
+ pda: {
11849
+ seeds: [
11850
+ {
11851
+ kind: "const",
11852
+ value: [
11853
+ 95,
11854
+ 95,
11855
+ 101,
11856
+ 118,
11857
+ 101,
11858
+ 110,
11859
+ 116,
11860
+ 95,
11861
+ 97,
11862
+ 117,
11863
+ 116,
11864
+ 104,
11865
+ 111,
11866
+ 114,
11867
+ 105,
11868
+ 116,
11869
+ 121
11870
+ ]
11871
+ }
11872
+ ]
11873
+ }
11874
+ },
11875
+ {
11876
+ name: "program"
11877
+ }
11878
+ ],
11879
+ args: [
11880
+ {
11881
+ name: "params",
11882
+ type: {
11883
+ defined: {
11884
+ name: "SwapParameters2"
10574
11885
  }
10575
11886
  }
10576
11887
  }
@@ -11075,6 +12386,19 @@ var events = [
11075
12386
  249
11076
12387
  ]
11077
12388
  },
12389
+ {
12390
+ name: "EvtLiquidityChange",
12391
+ discriminator: [
12392
+ 197,
12393
+ 171,
12394
+ 78,
12395
+ 127,
12396
+ 224,
12397
+ 211,
12398
+ 87,
12399
+ 13
12400
+ ]
12401
+ },
11078
12402
  {
11079
12403
  name: "EvtLockPosition",
11080
12404
  discriminator: [
@@ -11153,6 +12477,19 @@ var events = [
11153
12477
  147
11154
12478
  ]
11155
12479
  },
12480
+ {
12481
+ name: "EvtSwap2",
12482
+ discriminator: [
12483
+ 189,
12484
+ 66,
12485
+ 51,
12486
+ 168,
12487
+ 38,
12488
+ 80,
12489
+ 117,
12490
+ 153
12491
+ ]
12492
+ },
11156
12493
  {
11157
12494
  name: "EvtUpdateRewardDuration",
11158
12495
  discriminator: [
@@ -11428,6 +12765,36 @@ var errors = [
11428
12765
  code: 6046,
11429
12766
  name: "SamePosition",
11430
12767
  msg: "Same position"
12768
+ },
12769
+ {
12770
+ code: 6047,
12771
+ name: "InvalidBaseFeeMode",
12772
+ msg: "Invalid base fee mode"
12773
+ },
12774
+ {
12775
+ code: 6048,
12776
+ name: "InvalidFeeRateLimiter",
12777
+ msg: "Invalid fee rate limiter"
12778
+ },
12779
+ {
12780
+ code: 6049,
12781
+ name: "FailToValidateSingleSwapInstruction",
12782
+ msg: "Fail to validate single swap instruction in rate limiter"
12783
+ },
12784
+ {
12785
+ code: 6050,
12786
+ name: "InvalidFeeScheduler",
12787
+ msg: "Invalid fee scheduler"
12788
+ },
12789
+ {
12790
+ code: 6051,
12791
+ name: "UndeterminedError",
12792
+ msg: "Undetermined error"
12793
+ },
12794
+ {
12795
+ code: 6052,
12796
+ name: "InvalidPoolVersion",
12797
+ msg: "Invalid pool version"
11431
12798
  }
11432
12799
  ];
11433
12800
  var types = [
@@ -11474,7 +12841,7 @@ var types = [
11474
12841
  type: "u64"
11475
12842
  },
11476
12843
  {
11477
- name: "fee_scheduler_mode",
12844
+ name: "base_fee_mode",
11478
12845
  type: "u8"
11479
12846
  },
11480
12847
  {
@@ -11487,15 +12854,20 @@ var types = [
11487
12854
  }
11488
12855
  },
11489
12856
  {
11490
- name: "number_of_period",
12857
+ name: "first_factor",
11491
12858
  type: "u16"
11492
12859
  },
11493
12860
  {
11494
- name: "period_frequency",
11495
- type: "u64"
12861
+ name: "second_factor",
12862
+ type: {
12863
+ array: [
12864
+ "u8",
12865
+ 8
12866
+ ]
12867
+ }
11496
12868
  },
11497
12869
  {
11498
- name: "reduction_factor",
12870
+ name: "third_factor",
11499
12871
  type: "u64"
11500
12872
  }
11501
12873
  ]
@@ -11511,19 +12883,24 @@ var types = [
11511
12883
  type: "u64"
11512
12884
  },
11513
12885
  {
11514
- name: "number_of_period",
12886
+ name: "first_factor",
11515
12887
  type: "u16"
11516
12888
  },
11517
12889
  {
11518
- name: "period_frequency",
11519
- type: "u64"
12890
+ name: "second_factor",
12891
+ type: {
12892
+ array: [
12893
+ "u8",
12894
+ 8
12895
+ ]
12896
+ }
11520
12897
  },
11521
12898
  {
11522
- name: "reduction_factor",
12899
+ name: "third_factor",
11523
12900
  type: "u64"
11524
12901
  },
11525
12902
  {
11526
- name: "fee_scheduler_mode",
12903
+ name: "base_fee_mode",
11527
12904
  type: "u8"
11528
12905
  }
11529
12906
  ]
@@ -11543,7 +12920,7 @@ var types = [
11543
12920
  type: "u64"
11544
12921
  },
11545
12922
  {
11546
- name: "fee_scheduler_mode",
12923
+ name: "base_fee_mode",
11547
12924
  type: "u8"
11548
12925
  },
11549
12926
  {
@@ -11556,15 +12933,20 @@ var types = [
11556
12933
  }
11557
12934
  },
11558
12935
  {
11559
- name: "number_of_period",
12936
+ name: "first_factor",
11560
12937
  type: "u16"
11561
12938
  },
11562
12939
  {
11563
- name: "period_frequency",
11564
- type: "u64"
12940
+ name: "second_factor",
12941
+ type: {
12942
+ array: [
12943
+ "u8",
12944
+ 8
12945
+ ]
12946
+ }
11565
12947
  },
11566
12948
  {
11567
- name: "reduction_factor",
12949
+ name: "third_factor",
11568
12950
  type: "u64"
11569
12951
  },
11570
12952
  {
@@ -12403,6 +13785,66 @@ var types = [
12403
13785
  ]
12404
13786
  }
12405
13787
  },
13788
+ {
13789
+ name: "EvtLiquidityChange",
13790
+ type: {
13791
+ kind: "struct",
13792
+ fields: [
13793
+ {
13794
+ name: "pool",
13795
+ type: "pubkey"
13796
+ },
13797
+ {
13798
+ name: "position",
13799
+ type: "pubkey"
13800
+ },
13801
+ {
13802
+ name: "owner",
13803
+ type: "pubkey"
13804
+ },
13805
+ {
13806
+ name: "token_a_amount",
13807
+ type: "u64"
13808
+ },
13809
+ {
13810
+ name: "token_b_amount",
13811
+ type: "u64"
13812
+ },
13813
+ {
13814
+ name: "transfer_fee_included_token_a_amount",
13815
+ type: "u64"
13816
+ },
13817
+ {
13818
+ name: "transfer_fee_included_token_b_amount",
13819
+ type: "u64"
13820
+ },
13821
+ {
13822
+ name: "reserve_a_amount",
13823
+ type: "u64"
13824
+ },
13825
+ {
13826
+ name: "reserve_b_amount",
13827
+ type: "u64"
13828
+ },
13829
+ {
13830
+ name: "liquidity_delta",
13831
+ type: "u128"
13832
+ },
13833
+ {
13834
+ name: "token_a_amount_threshold",
13835
+ type: "u64"
13836
+ },
13837
+ {
13838
+ name: "token_b_amount_threshold",
13839
+ type: "u64"
13840
+ },
13841
+ {
13842
+ name: "change_type",
13843
+ type: "u8"
13844
+ }
13845
+ ]
13846
+ }
13847
+ },
12406
13848
  {
12407
13849
  name: "EvtLockPosition",
12408
13850
  type: {
@@ -12631,6 +14073,70 @@ var types = [
12631
14073
  ]
12632
14074
  }
12633
14075
  },
14076
+ {
14077
+ name: "EvtSwap2",
14078
+ type: {
14079
+ kind: "struct",
14080
+ fields: [
14081
+ {
14082
+ name: "pool",
14083
+ type: "pubkey"
14084
+ },
14085
+ {
14086
+ name: "trade_direction",
14087
+ type: "u8"
14088
+ },
14089
+ {
14090
+ name: "collect_fee_mode",
14091
+ type: "u8"
14092
+ },
14093
+ {
14094
+ name: "has_referral",
14095
+ type: "bool"
14096
+ },
14097
+ {
14098
+ name: "params",
14099
+ type: {
14100
+ defined: {
14101
+ name: "SwapParameters2"
14102
+ }
14103
+ }
14104
+ },
14105
+ {
14106
+ name: "swap_result",
14107
+ type: {
14108
+ defined: {
14109
+ name: "SwapResult2"
14110
+ }
14111
+ }
14112
+ },
14113
+ {
14114
+ name: "included_transfer_fee_amount_in",
14115
+ type: "u64"
14116
+ },
14117
+ {
14118
+ name: "included_transfer_fee_amount_out",
14119
+ type: "u64"
14120
+ },
14121
+ {
14122
+ name: "excluded_transfer_fee_amount_out",
14123
+ type: "u64"
14124
+ },
14125
+ {
14126
+ name: "current_timestamp",
14127
+ type: "u64"
14128
+ },
14129
+ {
14130
+ name: "reserve_a_amount",
14131
+ type: "u64"
14132
+ },
14133
+ {
14134
+ name: "reserve_b_amount",
14135
+ type: "u64"
14136
+ }
14137
+ ]
14138
+ }
14139
+ },
12634
14140
  {
12635
14141
  name: "EvtUpdateRewardDuration",
12636
14142
  type: {
@@ -12981,17 +14487,19 @@ var types = [
12981
14487
  ],
12982
14488
  type: "u8"
12983
14489
  },
14490
+ {
14491
+ name: "version",
14492
+ docs: [
14493
+ "pool version, 0: max_fee is still capped at 50%, 1: max_fee is capped at 99%"
14494
+ ],
14495
+ type: "u8"
14496
+ },
12984
14497
  {
12985
14498
  name: "_padding_0",
12986
14499
  docs: [
12987
14500
  "padding"
12988
14501
  ],
12989
- type: {
12990
- array: [
12991
- "u8",
12992
- 2
12993
- ]
12994
- }
14502
+ type: "u8"
12995
14503
  },
12996
14504
  {
12997
14505
  name: "fee_a_per_liquidity",
@@ -13812,6 +15320,35 @@ var types = [
13812
15320
  ]
13813
15321
  }
13814
15322
  },
15323
+ {
15324
+ name: "SwapParameters2",
15325
+ type: {
15326
+ kind: "struct",
15327
+ fields: [
15328
+ {
15329
+ name: "amount_0",
15330
+ docs: [
15331
+ "When it's exact in, partial fill, this will be amount_in. When it's exact out, this will be amount_out"
15332
+ ],
15333
+ type: "u64"
15334
+ },
15335
+ {
15336
+ name: "amount_1",
15337
+ docs: [
15338
+ "When it's exact in, partial fill, this will be minimum_amount_out. When it's exact out, this will be maximum_amount_in"
15339
+ ],
15340
+ type: "u64"
15341
+ },
15342
+ {
15343
+ name: "swap_mode",
15344
+ docs: [
15345
+ "Swap mode, refer [SwapMode]"
15346
+ ],
15347
+ type: "u8"
15348
+ }
15349
+ ]
15350
+ }
15351
+ },
13815
15352
  {
13816
15353
  name: "SwapResult",
13817
15354
  docs: [
@@ -13847,6 +15384,50 @@ var types = [
13847
15384
  ]
13848
15385
  }
13849
15386
  },
15387
+ {
15388
+ name: "SwapResult2",
15389
+ type: {
15390
+ kind: "struct",
15391
+ fields: [
15392
+ {
15393
+ name: "included_fee_input_amount",
15394
+ type: "u64"
15395
+ },
15396
+ {
15397
+ name: "excluded_fee_input_amount",
15398
+ type: "u64"
15399
+ },
15400
+ {
15401
+ name: "amount_left",
15402
+ type: "u64"
15403
+ },
15404
+ {
15405
+ name: "output_amount",
15406
+ type: "u64"
15407
+ },
15408
+ {
15409
+ name: "next_sqrt_price",
15410
+ type: "u128"
15411
+ },
15412
+ {
15413
+ name: "trading_fee",
15414
+ type: "u64"
15415
+ },
15416
+ {
15417
+ name: "protocol_fee",
15418
+ type: "u64"
15419
+ },
15420
+ {
15421
+ name: "partner_fee",
15422
+ type: "u64"
15423
+ },
15424
+ {
15425
+ name: "referral_fee",
15426
+ type: "u64"
15427
+ }
15428
+ ]
15429
+ }
15430
+ },
13850
15431
  {
13851
15432
  name: "TokenBadge",
13852
15433
  docs: [
@@ -14018,4 +15599,4 @@ var CpAmmIDL = {
14018
15599
  types: types
14019
15600
  };
14020
15601
 
14021
- export { ActivationPoint, ActivationType, type AddLiquidityParams, type AmmProgram, BASIS_POINT_MAX, BIN_STEP_BPS_DEFAULT, BIN_STEP_BPS_U128_DEFAULT, type BaseFee, type BuildAddLiquidityParams, type BuildLiquidatePositionInstructionParams, type BuildRemoveAllLiquidityInstructionParams, CP_AMM_PROGRAM_ID, type ClaimPartnerFeeParams, type ClaimPositionFeeInstructionParams, type ClaimPositionFeeParams, type ClaimPositionFeeParams2, type ClaimRewardParams, type ClosePositionInstructionParams, type ClosePositionParams, CollectFeeMode, type ConfigState, CpAmm, type CpAmm$1 as CpAmmTypes, type CreatePoolParams, type CreatePositionAndAddLiquidity, type CreatePositionParams, DYNAMIC_FEE_DECAY_PERIOD_DEFAULT, DYNAMIC_FEE_FILTER_PERIOD_DEFAULT, DYNAMIC_FEE_REDUCTION_FACTOR_DEFAULT, type DepositQuote, type DynamicFee, type DynamicFeeParams, FEE_DENOMINATOR, type FeeMode, FeeSchedulerMode, type FundRewardParams, type GetDepositQuoteParams, type GetQuoteExactOutParams, type GetQuoteParams, type GetWithdrawQuoteParams, type InitializeCustomizeablePoolParams, type InitializeCustomizeablePoolWithDynamicConfigParams, type InitializeRewardParams, LIQUIDITY_SCALE, type LiquidityDeltaParams, type LockPositionParams, MAX_CU_BUFFER, MAX_FEE_NUMERATOR, MAX_PRICE_CHANGE_BPS_DEFAULT, MAX_SQRT_PRICE, MIN_CU_BUFFER, MIN_SQRT_PRICE, type MergePositionParams, ONE, type PermanentLockParams, type PoolFeesParams, type PoolState, type PositionState, type PrepareCustomizablePoolParams, type PreparePoolCreationParams, type PreparePoolCreationSingleSide, type PrepareTokenAccountParams, type PreparedPoolCreation, type QuoteExactOutResult, type RefreshVestingParams, type RemoveAllLiquidityAndClosePositionParams, type RemoveAllLiquidityParams, type RemoveLiquidityParams, type RewardInfo, Rounding, SCALE_OFFSET, SPLIT_POSITION_DENOMINATOR, type SetupFeeClaimAccountsParams, type SplitPosition2Params, type SplitPositionParams, type SwapAmount, type SwapParams, type SwapQuotes, type SwapResult, type TokenBadgeState, TradeDirection, type TxBuilder, type UpdateRewardDurationParams, type UpdateRewardFunderParams, type VestingState, type WithdrawIneligibleRewardParams, type WithdrawQuote, bpsToFeeNumerator, calculateInitSqrtPrice, calculateTransferFeeExcludedAmount, calculateTransferFeeIncludedAmount, decimalToQ64, CpAmmIDL as default, deriveClaimFeeOperatorAddress, deriveConfigAddress, deriveCustomizablePoolAddress, derivePoolAddress, derivePoolAuthority, derivePositionAddress, derivePositionNftAccount, deriveRewardVaultAddress, deriveTokenBadgeAddress, deriveTokenVaultAddress, feeNumeratorToBps, getAllPositionNftAccountByOwner, getAllUserPositionNftAccount, getAmountAFromLiquidityDelta, getAmountBFromLiquidityDelta, getAvailableVestingLiquidity, getBaseFeeNumerator, getBaseFeeParams, getDynamicFeeNumerator, getDynamicFeeParams, getEstimatedComputeUnitIxWithBuffer, getEstimatedComputeUnitUsageWithBuffer, getExcludedFeeAmount, getFeeMode, getFeeNumerator, getFirstKey, getIncludedFeeAmount, getLiquidityDeltaFromAmountA, getLiquidityDeltaFromAmountB, getMaxAmountWithSlippage, getMinAmountWithSlippage, getNextSqrtPrice, getNextSqrtPriceFromAmountARoundingDown, getNextSqrtPriceFromAmountBRoundingUp, getNextSqrtPriceFromOutput, getOrCreateATAInstruction, getPriceChange, getPriceFromSqrtPrice, getPriceImpact, getSecondKey, getSimulationComputeUnits, getSqrtPriceFromPrice, getSwapAmount, getSwapResultFromOutAmount, getTokenDecimals, getTokenProgram, getTotalLockedLiquidity, getUnClaimReward, isVestingComplete, mulDiv, positionByPoolFilter, pow, q64ToDecimal, unwrapSOLInstruction, vestingByPositionFilter, wrapSOLInstruction };
15602
+ export { ActivationPoint, ActivationType, type AddLiquidityParams, type AmmProgram, BASIS_POINT_MAX, BIN_STEP_BPS_DEFAULT, BIN_STEP_BPS_U128_DEFAULT, type BaseFee, type BaseFeeHandler, BaseFeeMode, type BuildAddLiquidityParams, type BuildLiquidatePositionInstructionParams, type BuildRemoveAllLiquidityInstructionParams, CP_AMM_PROGRAM_ID, CURRENT_POOL_VERSION, type ClaimPartnerFeeParams, type ClaimPositionFeeInstructionParams, type ClaimPositionFeeParams, type ClaimPositionFeeParams2, type ClaimRewardParams, type ClosePositionInstructionParams, type ClosePositionParams, CollectFeeMode, type ConfigState, CpAmm, type CpAmm$1 as CpAmmTypes, type CreatePoolParams, type CreatePositionAndAddLiquidity, type CreatePositionParams, DYNAMIC_FEE_DECAY_PERIOD_DEFAULT, DYNAMIC_FEE_FILTER_PERIOD_DEFAULT, DYNAMIC_FEE_REDUCTION_FACTOR_DEFAULT, DYNAMIC_FEE_ROUNDING_OFFSET, DYNAMIC_FEE_SCALING_FACTOR, type DepositQuote, type DynamicFee, type DynamicFeeParams, type DynamicFeeStruct, FEE_DENOMINATOR, type FeeMode, type FeeOnAmountResult, FeeRateLimiter, FeeScheduler, type FundRewardParams, type GetDepositQuoteParams, type GetQuote2Params, type GetQuoteParams, type GetWithdrawQuoteParams, type InitializeCustomizeablePoolParams, type InitializeCustomizeablePoolWithDynamicConfigParams, type InitializeRewardParams, LIQUIDITY_SCALE, type LiquidityDeltaParams, type LockPositionParams, MAX, MAX_CU_BUFFER, MAX_EXPONENTIAL, MAX_FEE_BPS_V0, MAX_FEE_BPS_V1, MAX_FEE_NUMERATOR_V0, MAX_FEE_NUMERATOR_V1, MAX_PRICE_CHANGE_BPS_DEFAULT, MAX_RATE_LIMITER_DURATION_IN_SECONDS, MAX_RATE_LIMITER_DURATION_IN_SLOTS, MAX_SQRT_PRICE, MIN_CU_BUFFER, MIN_FEE_BPS, MIN_FEE_NUMERATOR, MIN_SQRT_PRICE, type MergePositionParams, ONE_Q64, type PermanentLockParams, type PoolFeesParams, type PoolFeesStruct, type PoolState, PoolStatus, PoolVersion, type PositionState, type PrepareCustomizablePoolParams, type PreparePoolCreationParams, type PreparePoolCreationSingleSide, type PrepareTokenAccountParams, type PreparedPoolCreation, type Quote2Result, type RefreshVestingParams, type RemoveAllLiquidityAndClosePositionParams, type RemoveAllLiquidityParams, type RemoveLiquidityParams, type RewardInfo, Rounding, SCALE_OFFSET, SPLIT_POSITION_DENOMINATOR, type SetupFeeClaimAccountsParams, type SplitFees, type SplitPosition2Params, type SplitPositionParams, type Swap2Params, type SwapAmount, SwapMode, type SwapParams, type SwapResult, type SwapResult2, type TokenBadgeState, TradeDirection, type TxBuilder, U128_MAX, U16_MAX, U64_MAX, type UpdateRewardDurationParams, type UpdateRewardFunderParams, type VestingState, type WithdrawIneligibleRewardParams, type WithdrawQuote, bpsToFeeNumerator, calculateAtoBFromAmountIn, calculateAtoBFromAmountOut, calculateAtoBFromPartialAmountIn, calculateBtoAFromAmountIn, calculateBtoAFromAmountOut, calculateBtoAFromPartialAmountIn, calculateInitSqrtPrice, calculateTransferFeeExcludedAmount, calculateTransferFeeIncludedAmount, convertToFeeSchedulerSecondFactor, convertToLamports, convertToRateLimiterSecondFactor, decimalToQ64, CpAmmIDL as default, deriveClaimFeeOperatorAddress, deriveConfigAddress, deriveCustomizablePoolAddress, derivePoolAddress, derivePoolAuthority, derivePositionAddress, derivePositionNftAccount, deriveRewardVaultAddress, deriveTokenBadgeAddress, deriveTokenVaultAddress, feeNumeratorToBps, fromDecimalToBN, getAllPositionNftAccountByOwner, getAllUserPositionNftAccount, getAmountAFromLiquidityDelta, getAmountBFromLiquidityDelta, getAmountWithSlippage, getAvailableVestingLiquidity, getBaseFeeHandler, getBaseFeeNumerator, getBaseFeeNumeratorByPeriod, getBaseFeeParams, getCheckedAmounts, getCurrentPoint, getDynamicFeeNumerator, getDynamicFeeParams, getEstimatedComputeUnitIxWithBuffer, getEstimatedComputeUnitUsageWithBuffer, getExcludedFeeAmount, getExcludedFeeAmountFromIncludedFeeAmount, getFeeInPeriod, getFeeMode, getFeeNumeratorFromExcludedFeeAmount, getFeeNumeratorFromIncludedFeeAmount, getFeeNumeratorOnExponentialFeeScheduler, getFeeNumeratorOnLinearFeeScheduler, getFeeOnAmount, getFeeSchedulerParams, getFirstKey, getIncludedFeeAmount, getLiquidityDeltaFromAmountA, getLiquidityDeltaFromAmountB, getMaxAmountWithSlippage, getMaxBaseFeeNumerator, getMaxFeeBps, getMaxFeeNumerator, getMaxIndex, getMinBaseFeeNumerator, getNextSqrtPriceFromAmountInARoundingUp, getNextSqrtPriceFromAmountInBRoundingDown, getNextSqrtPriceFromAmountOutARoundingUp, getNextSqrtPriceFromAmountOutBRoundingDown, getNextSqrtPriceFromInput, getNextSqrtPriceFromOutput, getOrCreateATAInstruction, getPriceChange, getPriceFromSqrtPrice, getPriceImpact, getRateLimiterParams, getSecondKey, getSimulationComputeUnits, getSqrtPriceFromPrice, getSwapResultFromExactInput, getSwapResultFromExactOutput, getSwapResultFromPartialInput, getTokenDecimals, getTokenProgram, getTotalFeeNumerator, getTotalLockedLiquidity, getTotalTradingFeeFromExcludedFeeAmount, getTotalTradingFeeFromIncludedFeeAmount, getUnClaimReward, hasPartner, isDynamicFeeEnabled, isNonZeroRateLimiter, isRateLimiterApplied, isSwapEnabled, isVestingComplete, isZeroRateLimiter, mulDiv, parseFeeSchedulerSecondFactor, parseRateLimiterSecondFactor, positionByPoolFilter, pow, q64ToDecimal, splitFees, sqrt, swapQuoteExactInput, swapQuoteExactOutput, swapQuotePartialInput, toNumerator, unwrapSOLInstruction, validateFeeFraction, validateFeeRateLimiter, validateFeeScheduler, vestingByPositionFilter, wrapSOLInstruction };