@meteora-ag/cp-amm-sdk 1.1.3 → 1.1.5-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.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.3";
17
+ version: "0.1.5";
17
18
  spec: "0.1.0";
18
19
  description: "Created with Anchor";
19
20
  };
@@ -2668,6 +2669,83 @@ type CpAmm$1 = {
2668
2669
  }
2669
2670
  ];
2670
2671
  },
2672
+ {
2673
+ name: "splitPosition2";
2674
+ discriminator: [221, 147, 228, 207, 140, 212, 17, 119];
2675
+ accounts: [
2676
+ {
2677
+ name: "pool";
2678
+ writable: true;
2679
+ relations: ["firstPosition", "secondPosition"];
2680
+ },
2681
+ {
2682
+ name: "firstPosition";
2683
+ docs: ["The first position"];
2684
+ writable: true;
2685
+ },
2686
+ {
2687
+ name: "firstPositionNftAccount";
2688
+ docs: ["The token account for position nft"];
2689
+ },
2690
+ {
2691
+ name: "secondPosition";
2692
+ docs: ["The second position"];
2693
+ writable: true;
2694
+ },
2695
+ {
2696
+ name: "secondPositionNftAccount";
2697
+ docs: ["The token account for position nft"];
2698
+ },
2699
+ {
2700
+ name: "firstOwner";
2701
+ docs: ["Owner of first position"];
2702
+ signer: true;
2703
+ },
2704
+ {
2705
+ name: "secondOwner";
2706
+ docs: ["Owner of second position"];
2707
+ signer: true;
2708
+ },
2709
+ {
2710
+ name: "eventAuthority";
2711
+ pda: {
2712
+ seeds: [
2713
+ {
2714
+ kind: "const";
2715
+ value: [
2716
+ 95,
2717
+ 95,
2718
+ 101,
2719
+ 118,
2720
+ 101,
2721
+ 110,
2722
+ 116,
2723
+ 95,
2724
+ 97,
2725
+ 117,
2726
+ 116,
2727
+ 104,
2728
+ 111,
2729
+ 114,
2730
+ 105,
2731
+ 116,
2732
+ 121
2733
+ ];
2734
+ }
2735
+ ];
2736
+ };
2737
+ },
2738
+ {
2739
+ name: "program";
2740
+ }
2741
+ ];
2742
+ args: [
2743
+ {
2744
+ name: "numerator";
2745
+ type: "u32";
2746
+ }
2747
+ ];
2748
+ },
2671
2749
  {
2672
2750
  name: "swap";
2673
2751
  discriminator: [248, 198, 158, 145, 225, 117, 135, 200];
@@ -2774,6 +2852,112 @@ type CpAmm$1 = {
2774
2852
  }
2775
2853
  ];
2776
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
+ },
2777
2961
  {
2778
2962
  name: "updateRewardDuration";
2779
2963
  discriminator: [138, 174, 196, 169, 213, 235, 254, 107];
@@ -3048,6 +3232,10 @@ type CpAmm$1 = {
3048
3232
  name: "evtInitializeReward";
3049
3233
  discriminator: [129, 91, 188, 3, 246, 52, 185, 249];
3050
3234
  },
3235
+ {
3236
+ name: "evtLiquidityChange";
3237
+ discriminator: [197, 171, 78, 127, 224, 211, 87, 13];
3238
+ },
3051
3239
  {
3052
3240
  name: "evtLockPosition";
3053
3241
  discriminator: [168, 63, 108, 83, 219, 82, 2, 200];
@@ -3065,13 +3253,17 @@ type CpAmm$1 = {
3065
3253
  discriminator: [100, 213, 74, 3, 95, 91, 228, 146];
3066
3254
  },
3067
3255
  {
3068
- name: "evtSplitPosition";
3069
- discriminator: [182, 138, 42, 254, 27, 94, 82, 221];
3256
+ name: "evtSplitPosition2";
3257
+ discriminator: [165, 32, 203, 174, 72, 100, 233, 103];
3070
3258
  },
3071
3259
  {
3072
3260
  name: "evtSwap";
3073
3261
  discriminator: [27, 60, 21, 213, 138, 170, 187, 147];
3074
3262
  },
3263
+ {
3264
+ name: "evtSwap2";
3265
+ discriminator: [189, 66, 51, 168, 38, 80, 117, 153];
3266
+ },
3075
3267
  {
3076
3268
  name: "evtUpdateRewardDuration";
3077
3269
  discriminator: [149, 135, 65, 231, 129, 153, 65, 57];
@@ -3320,6 +3512,36 @@ type CpAmm$1 = {
3320
3512
  code: 6046;
3321
3513
  name: "samePosition";
3322
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";
3323
3545
  }
3324
3546
  ];
3325
3547
  types: [
@@ -3360,7 +3582,7 @@ type CpAmm$1 = {
3360
3582
  type: "u64";
3361
3583
  },
3362
3584
  {
3363
- name: "feeSchedulerMode";
3585
+ name: "baseFeeMode";
3364
3586
  type: "u8";
3365
3587
  },
3366
3588
  {
@@ -3370,15 +3592,17 @@ type CpAmm$1 = {
3370
3592
  };
3371
3593
  },
3372
3594
  {
3373
- name: "numberOfPeriod";
3595
+ name: "firstFactor";
3374
3596
  type: "u16";
3375
3597
  },
3376
3598
  {
3377
- name: "periodFrequency";
3378
- type: "u64";
3599
+ name: "secondFactor";
3600
+ type: {
3601
+ array: ["u8", 8];
3602
+ };
3379
3603
  },
3380
3604
  {
3381
- name: "reductionFactor";
3605
+ name: "thirdFactor";
3382
3606
  type: "u64";
3383
3607
  }
3384
3608
  ];
@@ -3394,19 +3618,21 @@ type CpAmm$1 = {
3394
3618
  type: "u64";
3395
3619
  },
3396
3620
  {
3397
- name: "numberOfPeriod";
3621
+ name: "firstFactor";
3398
3622
  type: "u16";
3399
3623
  },
3400
3624
  {
3401
- name: "periodFrequency";
3402
- type: "u64";
3625
+ name: "secondFactor";
3626
+ type: {
3627
+ array: ["u8", 8];
3628
+ };
3403
3629
  },
3404
3630
  {
3405
- name: "reductionFactor";
3631
+ name: "thirdFactor";
3406
3632
  type: "u64";
3407
3633
  },
3408
3634
  {
3409
- name: "feeSchedulerMode";
3635
+ name: "baseFeeMode";
3410
3636
  type: "u8";
3411
3637
  }
3412
3638
  ];
@@ -3426,7 +3652,7 @@ type CpAmm$1 = {
3426
3652
  type: "u64";
3427
3653
  },
3428
3654
  {
3429
- name: "feeSchedulerMode";
3655
+ name: "baseFeeMode";
3430
3656
  type: "u8";
3431
3657
  },
3432
3658
  {
@@ -3436,15 +3662,17 @@ type CpAmm$1 = {
3436
3662
  };
3437
3663
  },
3438
3664
  {
3439
- name: "numberOfPeriod";
3665
+ name: "firstFactor";
3440
3666
  type: "u16";
3441
3667
  },
3442
3668
  {
3443
- name: "periodFrequency";
3444
- type: "u64";
3669
+ name: "secondFactor";
3670
+ type: {
3671
+ array: ["u8", 8];
3672
+ };
3445
3673
  },
3446
3674
  {
3447
- name: "reductionFactor";
3675
+ name: "thirdFactor";
3448
3676
  type: "u64";
3449
3677
  },
3450
3678
  {
@@ -4223,7 +4451,7 @@ type CpAmm$1 = {
4223
4451
  };
4224
4452
  },
4225
4453
  {
4226
- name: "evtLockPosition";
4454
+ name: "evtLiquidityChange";
4227
4455
  type: {
4228
4456
  kind: "struct";
4229
4457
  fields: [
@@ -4240,34 +4468,50 @@ type CpAmm$1 = {
4240
4468
  type: "pubkey";
4241
4469
  },
4242
4470
  {
4243
- name: "vesting";
4244
- type: "pubkey";
4471
+ name: "tokenAAmount";
4472
+ type: "u64";
4245
4473
  },
4246
4474
  {
4247
- name: "cliffPoint";
4475
+ name: "tokenBAmount";
4248
4476
  type: "u64";
4249
4477
  },
4250
4478
  {
4251
- name: "periodFrequency";
4479
+ name: "transferFeeIncludedTokenAAmount";
4252
4480
  type: "u64";
4253
4481
  },
4254
4482
  {
4255
- name: "cliffUnlockLiquidity";
4256
- type: "u128";
4483
+ name: "transferFeeIncludedTokenBAmount";
4484
+ type: "u64";
4257
4485
  },
4258
4486
  {
4259
- name: "liquidityPerPeriod";
4487
+ name: "reserveAAmount";
4488
+ type: "u64";
4489
+ },
4490
+ {
4491
+ name: "reserveBAmount";
4492
+ type: "u64";
4493
+ },
4494
+ {
4495
+ name: "liquidityDelta";
4260
4496
  type: "u128";
4261
4497
  },
4262
4498
  {
4263
- name: "numberOfPeriod";
4264
- type: "u16";
4499
+ name: "tokenAAmountThreshold";
4500
+ type: "u64";
4501
+ },
4502
+ {
4503
+ name: "tokenBAmountThreshold";
4504
+ type: "u64";
4505
+ },
4506
+ {
4507
+ name: "changeType";
4508
+ type: "u8";
4265
4509
  }
4266
4510
  ];
4267
4511
  };
4268
4512
  },
4269
4513
  {
4270
- name: "evtPermanentLockPosition";
4514
+ name: "evtLockPosition";
4271
4515
  type: {
4272
4516
  kind: "struct";
4273
4517
  fields: [
@@ -4280,15 +4524,59 @@ type CpAmm$1 = {
4280
4524
  type: "pubkey";
4281
4525
  },
4282
4526
  {
4283
- name: "lockLiquidityAmount";
4284
- type: "u128";
4527
+ name: "owner";
4528
+ type: "pubkey";
4285
4529
  },
4286
4530
  {
4287
- name: "totalPermanentLockedLiquidity";
4288
- type: "u128";
4289
- }
4290
- ];
4291
- };
4531
+ name: "vesting";
4532
+ type: "pubkey";
4533
+ },
4534
+ {
4535
+ name: "cliffPoint";
4536
+ type: "u64";
4537
+ },
4538
+ {
4539
+ name: "periodFrequency";
4540
+ type: "u64";
4541
+ },
4542
+ {
4543
+ name: "cliffUnlockLiquidity";
4544
+ type: "u128";
4545
+ },
4546
+ {
4547
+ name: "liquidityPerPeriod";
4548
+ type: "u128";
4549
+ },
4550
+ {
4551
+ name: "numberOfPeriod";
4552
+ type: "u16";
4553
+ }
4554
+ ];
4555
+ };
4556
+ },
4557
+ {
4558
+ name: "evtPermanentLockPosition";
4559
+ type: {
4560
+ kind: "struct";
4561
+ fields: [
4562
+ {
4563
+ name: "pool";
4564
+ type: "pubkey";
4565
+ },
4566
+ {
4567
+ name: "position";
4568
+ type: "pubkey";
4569
+ },
4570
+ {
4571
+ name: "lockLiquidityAmount";
4572
+ type: "u128";
4573
+ },
4574
+ {
4575
+ name: "totalPermanentLockedLiquidity";
4576
+ type: "u128";
4577
+ }
4578
+ ];
4579
+ };
4292
4580
  },
4293
4581
  {
4294
4582
  name: "evtRemoveLiquidity";
@@ -4343,7 +4631,7 @@ type CpAmm$1 = {
4343
4631
  };
4344
4632
  },
4345
4633
  {
4346
- name: "evtSplitPosition";
4634
+ name: "evtSplitPosition2";
4347
4635
  type: {
4348
4636
  kind: "struct";
4349
4637
  fields: [
@@ -4399,7 +4687,7 @@ type CpAmm$1 = {
4399
4687
  name: "splitPositionParameters";
4400
4688
  type: {
4401
4689
  defined: {
4402
- name: "splitPositionParameters";
4690
+ name: "splitPositionParameters2";
4403
4691
  };
4404
4692
  };
4405
4693
  }
@@ -4450,6 +4738,70 @@ type CpAmm$1 = {
4450
4738
  ];
4451
4739
  };
4452
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
+ },
4453
4805
  {
4454
4806
  name: "evtUpdateRewardDuration";
4455
4807
  type: {
@@ -4740,12 +5092,17 @@ type CpAmm$1 = {
4740
5092
  docs: ["pool type"];
4741
5093
  type: "u8";
4742
5094
  },
5095
+ {
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
+ },
4743
5102
  {
4744
5103
  name: "padding0";
4745
5104
  docs: ["padding"];
4746
- type: {
4747
- array: ["u8", 2];
4748
- };
5105
+ type: "u8";
4749
5106
  },
4750
5107
  {
4751
5108
  name: "feeAPerLiquidity";
@@ -5347,6 +5704,38 @@ type CpAmm$1 = {
5347
5704
  ];
5348
5705
  };
5349
5706
  },
5707
+ {
5708
+ name: "splitPositionParameters2";
5709
+ type: {
5710
+ kind: "struct";
5711
+ fields: [
5712
+ {
5713
+ name: "unlockedLiquidityNumerator";
5714
+ type: "u32";
5715
+ },
5716
+ {
5717
+ name: "permanentLockedLiquidityNumerator";
5718
+ type: "u32";
5719
+ },
5720
+ {
5721
+ name: "feeANumerator";
5722
+ type: "u32";
5723
+ },
5724
+ {
5725
+ name: "feeBNumerator";
5726
+ type: "u32";
5727
+ },
5728
+ {
5729
+ name: "reward0Numerator";
5730
+ type: "u32";
5731
+ },
5732
+ {
5733
+ name: "reward1Numerator";
5734
+ type: "u32";
5735
+ }
5736
+ ];
5737
+ };
5738
+ },
5350
5739
  {
5351
5740
  name: "staticConfigParameters";
5352
5741
  type: {
@@ -5403,6 +5792,33 @@ type CpAmm$1 = {
5403
5792
  ];
5404
5793
  };
5405
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
+ },
5406
5822
  {
5407
5823
  name: "swapResult";
5408
5824
  docs: ["Encodes all results of swapping"];
@@ -5436,6 +5852,50 @@ type CpAmm$1 = {
5436
5852
  ];
5437
5853
  };
5438
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
+ },
5439
5899
  {
5440
5900
  name: "tokenBadge";
5441
5901
  docs: ["Parameter that set by the protocol"];
@@ -5585,9 +6045,10 @@ declare enum ActivationPoint {
5585
6045
  Timestamp = 0,
5586
6046
  Slot = 1
5587
6047
  }
5588
- declare enum FeeSchedulerMode {
5589
- Linear = 0,
5590
- Exponential = 1
6048
+ declare enum BaseFeeMode {
6049
+ FeeSchedulerLinear = 0,
6050
+ FeeSchedulerExponential = 1,
6051
+ RateLimiter = 2
5591
6052
  }
5592
6053
  declare enum CollectFeeMode {
5593
6054
  BothToken = 0,
@@ -5601,32 +6062,68 @@ declare enum ActivationType {
5601
6062
  Slot = 0,
5602
6063
  Timestamp = 1
5603
6064
  }
6065
+ declare enum PoolVersion {
6066
+ V0 = 0,
6067
+ V1 = 1
6068
+ }
5604
6069
  type FeeMode = {
5605
- feeOnInput: boolean;
6070
+ feesOnInput: boolean;
5606
6071
  feesOnTokenA: boolean;
6072
+ hasReferral: boolean;
5607
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
+ }
5608
6083
  type PoolState = IdlAccounts<CpAmm$1>["pool"];
5609
6084
  type PositionState = IdlAccounts<CpAmm$1>["position"];
5610
6085
  type VestingState = IdlAccounts<CpAmm$1>["vesting"];
5611
6086
  type ConfigState = IdlAccounts<CpAmm$1>["config"];
5612
6087
  type TokenBadgeState = IdlAccounts<CpAmm$1>["tokenBadge"];
5613
6088
  type RewardInfo = IdlTypes<CpAmm$1>["rewardInfo"];
5614
- type DynamicFee = {
5615
- binStep: number;
5616
- binStepU128: BN;
5617
- filterPeriod: number;
5618
- decayPeriod: number;
5619
- reductionFactor: number;
5620
- maxVolatilityAccumulator: number;
5621
- variableFeeControl: number;
5622
- };
5623
- type BaseFee = {
5624
- cliffFeeNumerator: BN;
5625
- numberOfPeriod: number;
5626
- periodFrequency: BN;
5627
- reductionFactor: BN;
5628
- feeSchedulerMode: number;
5629
- };
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"];
5630
6127
  type PoolFeesParams = {
5631
6128
  baseFee: BaseFee;
5632
6129
  padding: number[];
@@ -5895,18 +6392,13 @@ type GetQuoteParams = {
5895
6392
  };
5896
6393
  tokenADecimal: number;
5897
6394
  tokenBDecimal: number;
6395
+ hasReferral?: boolean;
5898
6396
  };
5899
- type SwapAmount = {
5900
- outputAmount: BN;
5901
- nextSqrtPrice: BN;
5902
- };
5903
- type GetQuoteExactOutParams = {
5904
- outAmount: BN;
5905
- outputTokenMint: PublicKey;
6397
+ type GetQuote2Params = {
6398
+ inputTokenMint: PublicKey;
5906
6399
  slippage: number;
6400
+ currentPoint: BN;
5907
6401
  poolState: PoolState;
5908
- currentTime: number;
5909
- currentSlot: number;
5910
6402
  inputTokenInfo?: {
5911
6403
  mint: Mint;
5912
6404
  currentEpoch: number;
@@ -5917,26 +6409,28 @@ type GetQuoteExactOutParams = {
5917
6409
  };
5918
6410
  tokenADecimal: number;
5919
6411
  tokenBDecimal: number;
5920
- };
5921
- 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 = {
5922
6424
  outputAmount: BN;
5923
6425
  nextSqrtPrice: BN;
5924
- lpFee: BN;
5925
- protocolFee: BN;
5926
- referralFee: BN;
5927
- partnerFee: BN;
5928
- };
5929
- type QuoteExactOutResult = {
5930
- swapResult: SwapResult;
5931
- inputAmount: BN;
5932
- maxInputAmount: BN;
5933
- priceImpact: number;
5934
- };
5935
- type SwapQuotes = {
5936
- totalFee: BN;
5937
- minOutAmount: BN;
5938
- actualAmount: BN;
5939
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
+ }
5940
6434
  type SwapParams = {
5941
6435
  payer: PublicKey;
5942
6436
  pool: PublicKey;
@@ -5952,6 +6446,31 @@ type SwapParams = {
5952
6446
  tokenBProgram: PublicKey;
5953
6447
  referralTokenAccount: PublicKey | null;
5954
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
+ });
5955
6474
  type LockPositionParams = {
5956
6475
  owner: PublicKey;
5957
6476
  payer: PublicKey;
@@ -6151,13 +6670,41 @@ type SplitPositionParams = {
6151
6670
  reward0Percentage: number;
6152
6671
  reward1Percentage: number;
6153
6672
  };
6154
-
6155
- /**
6156
- * CpAmm SDK class to interact with the DAMM-V2
6157
- */
6158
- declare class CpAmm {
6159
- _program: AmmProgram;
6160
- private poolAuthority;
6673
+ type SplitPosition2Params = {
6674
+ firstPositionOwner: PublicKey;
6675
+ secondPositionOwner: PublicKey;
6676
+ pool: PublicKey;
6677
+ firstPosition: PublicKey;
6678
+ firstPositionNftAccount: PublicKey;
6679
+ secondPosition: PublicKey;
6680
+ secondPositionNftAccount: PublicKey;
6681
+ numerator: number;
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
+ }
6701
+
6702
+ /**
6703
+ * CpAmm SDK class to interact with the DAMM-V2
6704
+ */
6705
+ declare class CpAmm {
6706
+ _program: AmmProgram;
6707
+ private poolAuthority;
6161
6708
  constructor(connection: Connection);
6162
6709
  /**
6163
6710
  * Prepares token accounts for a transaction by retrieving or creating associated token accounts.
@@ -6335,7 +6882,7 @@ declare class CpAmm {
6335
6882
  canUnlockPosition(positionState: PositionState, vestings: Array<{
6336
6883
  account: PublicKey;
6337
6884
  vestingState: VestingState;
6338
- }>, currentPoint: BN): {
6885
+ }>, currentPoint: BN$1): {
6339
6886
  canUnlock: boolean;
6340
6887
  reason?: string;
6341
6888
  };
@@ -6346,26 +6893,21 @@ declare class CpAmm {
6346
6893
  * @param {LiquidityDeltaParams} params - The parameters for liquidity calculation
6347
6894
  * @returns {Promise<BN>} - The computed liquidity delta in Q64 value.
6348
6895
  */
6349
- getLiquidityDelta(params: LiquidityDeltaParams): BN;
6896
+ getLiquidityDelta(params: LiquidityDeltaParams): BN$1;
6350
6897
  /**
6351
6898
  * Calculates swap quote based on input amount and pool state.
6352
6899
  * @param params - Swap parameters including input amount, pool state, slippage, etc.
6353
6900
  * @returns Swap quote including expected output amount, fee, and price impact.
6354
6901
  */
6355
6902
  getQuote(params: GetQuoteParams): {
6356
- swapInAmount: BN;
6357
- consumedInAmount: BN;
6358
- swapOutAmount: BN;
6359
- minSwapOutAmount: BN;
6360
- totalFee: BN;
6903
+ swapInAmount: BN$1;
6904
+ consumedInAmount: BN$1;
6905
+ swapOutAmount: BN$1;
6906
+ minSwapOutAmount: BN$1;
6907
+ totalFee: BN$1;
6361
6908
  priceImpact: Decimal;
6362
6909
  };
6363
- /**
6364
- * Calculates swap quote based on desired output amount and pool state.
6365
- * @param params - Swap parameters including output amount, pool state, slippage, etc.
6366
- * @returns Swap quote including required input amount, fees, and price impact.
6367
- */
6368
- getQuoteExactOut(params: GetQuoteExactOutParams): QuoteExactOutResult;
6910
+ getQuote2(params: GetQuote2Params): Quote2Result;
6369
6911
  /**
6370
6912
  * Calculates the deposit quote for liquidity pool.
6371
6913
  *
@@ -6397,7 +6939,7 @@ declare class CpAmm {
6397
6939
  * @param params Parameters for single-sided pool creation
6398
6940
  * @returns Calculated liquidity delta
6399
6941
  */
6400
- preparePoolCreationSingleSide(params: PreparePoolCreationSingleSide): BN;
6942
+ preparePoolCreationSingleSide(params: PreparePoolCreationSingleSide): BN$1;
6401
6943
  /**
6402
6944
  * Prepares parameters required for pool creation, including initial sqrt price and liquidity.
6403
6945
  * @private
@@ -6466,6 +7008,7 @@ declare class CpAmm {
6466
7008
  * @returns Transaction builder.
6467
7009
  */
6468
7010
  swap(params: SwapParams): TxBuilder;
7011
+ swap2(params: Swap2Params): TxBuilder;
6469
7012
  /**
6470
7013
  * Builds a transaction to lock a position with vesting schedule.
6471
7014
  * @param {LockPositionParams} params - Locking parameters.
@@ -6559,6 +7102,7 @@ declare class CpAmm {
6559
7102
  */
6560
7103
  claimReward(params: ClaimRewardParams): TxBuilder;
6561
7104
  splitPosition(params: SplitPositionParams): TxBuilder;
7105
+ splitPosition2(params: SplitPosition2Params): TxBuilder;
6562
7106
  }
6563
7107
 
6564
7108
  declare function getFirstKey(key1: PublicKey, key2: PublicKey): Buffer<ArrayBufferLike>;
@@ -6578,172 +7122,109 @@ declare const CP_AMM_PROGRAM_ID: PublicKey;
6578
7122
  declare const LIQUIDITY_SCALE = 128;
6579
7123
  declare const SCALE_OFFSET = 64;
6580
7124
  declare const BASIS_POINT_MAX = 10000;
6581
- declare const MAX_FEE_NUMERATOR = 500000000;
6582
7125
  declare const FEE_DENOMINATOR = 1000000000;
6583
- declare const MIN_SQRT_PRICE: BN;
6584
- 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;
6585
7137
  declare const MIN_CU_BUFFER = 50000;
6586
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;
6587
7141
  declare const DYNAMIC_FEE_FILTER_PERIOD_DEFAULT = 10;
6588
7142
  declare const DYNAMIC_FEE_DECAY_PERIOD_DEFAULT = 120;
6589
7143
  declare const DYNAMIC_FEE_REDUCTION_FACTOR_DEFAULT = 5000;
6590
7144
  declare const BIN_STEP_BPS_DEFAULT = 1;
6591
- declare const BIN_STEP_BPS_U128_DEFAULT: BN;
7145
+ declare const BIN_STEP_BPS_U128_DEFAULT: BN$1;
6592
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;
7152
+ declare const SPLIT_POSITION_DENOMINATOR = 1000000000;
7153
+ declare const CURRENT_POOL_VERSION = PoolVersion.V0;
6593
7154
 
7155
+ /**
7156
+ * Gets the token program
7157
+ * @param flag - The flag
7158
+ * @returns The token program
7159
+ */
6594
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
+ */
6595
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
+ */
6596
7178
  declare const getOrCreateATAInstruction: (connection: Connection, tokenMint: PublicKey, owner: PublicKey, payer: PublicKey, allowOwnerOffCurve: boolean, tokenProgram: PublicKey) => Promise<{
6597
7179
  ataPubkey: PublicKey;
6598
7180
  ix?: TransactionInstruction;
6599
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
+ */
6600
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
+ */
6601
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
+ */
6602
7204
  declare function getAllUserPositionNftAccount(connection: Connection, user: PublicKey): Promise<Array<{
6603
7205
  positionNft: PublicKey;
6604
7206
  positionNftAccount: PublicKey;
6605
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
+ */
6606
7214
  declare function getAllPositionNftAccountByOwner(connection: Connection, user: PublicKey): Promise<Array<{
6607
7215
  positionNft: PublicKey;
6608
7216
  positionNftAccount: PublicKey;
6609
7217
  }>>;
6610
7218
 
6611
- declare function getBaseFeeNumerator(feeSchedulerMode: FeeSchedulerMode, cliffFeeNumerator: BN, period: BN, reductionFactor: BN): BN;
6612
- /**
6613
- * Calculates the dynamic fee numerator based on market volatility metrics
6614
- *
6615
- * @param volatilityAccumulator - A measure of accumulated market volatility (BN)
6616
- * @param binStep - The size of price bins in the liquidity distribution (BN)
6617
- * @param variableFeeControl - Parameter controlling the impact of volatility on fees (BN)
6618
- * @returns The calculated dynamic fee numerator (BN)
6619
- */
6620
- declare function getDynamicFeeNumerator(volatilityAccumulator: BN, binStep: BN, variableFeeControl: BN): BN;
6621
- /**
6622
- * Calculates the fee numerator based on current market conditions and fee schedule configuration
6623
- *
6624
- * @param currentPoint - The current price point in the liquidity curve
6625
- * @param activationPoint - The price point at which the fee schedule is activated (BN)
6626
- * @param numberOfPeriod - The total number of periods in the fee schedule
6627
- * @param periodFrequency - The frequency at which periods change (BN)
6628
- * @param feeSchedulerMode - The mode determining how fees are calculated (0 = constant, 1 = linear, etc.)
6629
- * @param cliffFeeNumerator - The initial fee numerator at the cliff point (BN)
6630
- * @param reductionFactor - The factor by which fees are reduced in each period (BN)
6631
- * @param dynamicFeeParams - Optional parameters for dynamic fee calculation
6632
- * @param dynamicFeeParams.volatilityAccumulator - Measure of accumulated market volatility (BN)
6633
- * @param dynamicFeeParams.binStep - Size of price bins in the liquidity distribution (BN)
6634
- * @param dynamicFeeParams.variableFeeControl - Parameter controlling the impact of volatility (BN)
6635
- * @returns The calculated fee numerator (BN), capped at MAX_FEE_NUMERATOR
6636
- */
6637
- declare function getFeeNumerator(currentPoint: number, activationPoint: BN, numberOfPeriod: number, periodFrequency: BN, feeSchedulerMode: number, cliffFeeNumerator: BN, reductionFactor: BN, dynamicFeeParams?: {
6638
- volatilityAccumulator: BN;
6639
- binStep: number;
6640
- variableFeeControl: number;
6641
- }): BN;
6642
- /**
6643
- * Determines the fee mode based on the swap direction and fee collection configuration
6644
- *
6645
- * @param collectFeeMode - The fee collection mode (e.g., OnlyB, BothToken)
6646
- * @param btoA - Boolean indicating if the swap is from token B to token A
6647
- * @returns { feeOnInput, feesOnTokenA }
6648
- */
6649
- declare function getFeeMode(collectFeeMode: CollectFeeMode, btoA: boolean): FeeMode;
6650
- /**
6651
- *
6652
- * Calculates the output amount and fees for a swap operation in a concentrated liquidity pool.
6653
- *
6654
- * @param inAmount - The input amount of tokens the user is swapping
6655
- * @param sqrtPrice - The current square root price of the pool
6656
- * @param liquidity - The current liquidity available in the pool
6657
- * @param tradeFeeNumerator - The fee numerator used to calculate trading fees
6658
- * @param aToB - Direction of the swap: true for token A to token B, false for token B to token A
6659
- * @param collectFeeMode - Determines how fees are collected (0: both tokens, 1: only token B)
6660
- * @returns Object containing the actual output amount after fees and the total fee amount
6661
- */
6662
- declare function getSwapAmount(inAmount: BN, sqrtPrice: BN, liquidity: BN, tradeFeeNumerator: BN, aToB: boolean, collectFeeMode: number): {
6663
- amountOut: BN;
6664
- totalFee: BN;
6665
- nextSqrtPrice: BN;
6666
- };
6667
- /**
6668
- * Converts basis points (bps) to a fee numerator
6669
- * 1 bps = 0.01% = 0.0001 in decimal
6670
- *
6671
- * @param bps - The value in basis points [1-10_000]
6672
- * @returns The equivalent fee numerator
6673
- */
6674
- declare function bpsToFeeNumerator(bps: number): BN;
6675
- /**
6676
- * Converts a fee numerator back to basis points (bps)
6677
- *
6678
- * @param feeNumerator - The fee numerator to convert
6679
- * @returns The equivalent value in basis points [1-10_000]
6680
- */
6681
- declare function feeNumeratorToBps(feeNumerator: BN): number;
6682
- /**
6683
- * Calculates base fee parameters for a fee scheduler system.
6684
- * @param {number} maxBaseFeeBps - Maximum fee in basis points
6685
- * @param {number} minBaseFeeBps - Minimum fee in basis points
6686
- * @param {FeeSchedulerMode} feeSchedulerMode - Mode for fee reduction (Linear or Exponential)
6687
- * @param {number} numberOfPeriod - Number of periods over which to schedule fee reduction
6688
- * @param {BN} periodFrequency - Time interval between fee reductions
6689
- *
6690
- * @returns {BaseFee}
6691
- */
6692
- declare function getBaseFeeParams(maxBaseFeeBps: number, minBaseFeeBps: number, feeSchedulerMode: FeeSchedulerMode, numberOfPeriod: number, totalDuration: number): BaseFee;
6693
- /**
6694
- * Calculate dynamic fee parameters
6695
- * @param {number} baseFeeBps - Base fee in basis points
6696
- * @param {number} [maxPriceChangeBps=1500] - Maximum price change to consider for fee calculation (in basis points)
6697
- *
6698
- * @returns {DynamicFee}
6699
- */
6700
- declare function getDynamicFeeParams(baseFeeBps: number, maxPriceChangeBps?: number): DynamicFee;
6701
7219
  /**
6702
- * Calculates the excluded fee amount and trading fee from an included fee amount
6703
- * @param tradeFeeNumerator - The fee numerator
6704
- * @param includedFeeAmount - The amount that includes the fee
6705
- * @returns Tuple of [excluded_fee_amount, trading_fee]
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
6706
7227
  */
6707
- declare function getExcludedFeeAmount(tradeFeeNumerator: BN, includedFeeAmount: BN): {
6708
- excludedFeeAmount: BN;
6709
- tradingFee: BN;
6710
- };
6711
- /**
6712
- * Calculates the included fee amount from an excluded fee amount
6713
- * @param tradeFeeNumerator - The fee numerator
6714
- * @param excludedFeeAmount - The amount that excludes the fee
6715
- * @returns The amount including the fee
6716
- */
6717
- declare function getIncludedFeeAmount(tradeFeeNumerator: BN, excludedFeeAmount: BN): BN;
6718
- /**
6719
- * Calculates the swap result from a given output amount
6720
- * @param pool - The pool state
6721
- * @param outAmount - The desired output amount
6722
- * @param feeMode - The fee mode configuration
6723
- * @param tradeDirection - The direction of the trade
6724
- * @param currentPoint - The current time/slot point
6725
- * @returns Tuple of [SwapResult, input_amount]
6726
- */
6727
- declare function getSwapResultFromOutAmount(pool: PoolState, outAmount: BN, feeMode: FeeMode & {
6728
- hasReferral?: boolean;
6729
- }, tradeDirection: TradeDirection, currentPoint: number): {
6730
- swapResult: SwapResult;
6731
- inputAmount: BN;
6732
- };
6733
-
6734
- declare function getNextSqrtPrice(amount: BN, sqrtPrice: BN, liquidity: BN, aToB: boolean): BN;
6735
- declare function getLiquidityDeltaFromAmountA(amountA: BN, lowerSqrtPrice: BN, // current sqrt price
6736
- upperSqrtPrice: BN): BN;
6737
- declare function getLiquidityDeltaFromAmountB(amountB: BN, lowerSqrtPrice: BN, // min sqrt price
6738
- upperSqrtPrice: BN): BN;
6739
- declare function getAmountAFromLiquidityDelta(liquidity: BN, currentSqrtPrice: BN, // current sqrt price
6740
- maxSqrtPrice: BN, rounding: Rounding): BN;
6741
- declare function getAmountBFromLiquidityDelta(liquidity: BN, currentSqrtPrice: BN, // current sqrt price,
6742
- minSqrtPrice: BN, rounding: Rounding): BN;
6743
- declare function getNextSqrtPriceFromAmountBRoundingUp(sqrtPrice: BN, liquidity: BN, amount: BN): BN;
6744
- declare function getNextSqrtPriceFromAmountARoundingDown(sqrtPrice: BN, liquidity: BN, amount: BN): BN;
6745
- declare function getNextSqrtPriceFromOutput(sqrtPrice: BN, liquidity: BN, outAmount: BN, isB: boolean): BN;
6746
-
6747
7228
  declare const getSimulationComputeUnits: (connection: Connection, instructions: Array<TransactionInstruction>, payer: PublicKey, lookupTables: Array<AddressLookupTableAccount> | [], commitment?: Commitment) => Promise<number | null>;
6748
7229
  /**
6749
7230
  * Gets the estimated compute unit usage with a buffer.
@@ -6775,13 +7256,16 @@ declare const getEstimatedComputeUnitIxWithBuffer: (connection: Connection, inst
6775
7256
  */
6776
7257
  declare const getMaxAmountWithSlippage: (amount: BN, rate: number) => BN;
6777
7258
  /**
6778
- * It takes an amount and a slippage rate, and returns the minimum amount that will be received after
6779
- * slippage
6780
- * @param {BN} amount - The amount of tokens you want to sell.
6781
- * @param {number} rate - The percentage of slippage you're willing to accept. (Max to 2 decimal place)
6782
- * @returns The minimum amount that can be received after slippage is applied.
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)
6783
7267
  */
6784
- declare const getMinAmountWithSlippage: (amount: BN, rate: number) => BN;
7268
+ declare const getAmountWithSlippage: (amount: BN, slippageBps: number, swapMode: SwapMode) => BN;
6785
7269
  /**
6786
7270
  * Calculate price impact as a percentage
6787
7271
  * Price impact measures how much worse the user's execution was compared to the current market price
@@ -6802,28 +7286,74 @@ declare const getPriceImpact: (amountIn: BN, amountOut: BN, currentSqrtPrice: BN
6802
7286
  * @returns Price change as a percentage (e.g., 1.5 means 1.5% change)
6803
7287
  */
6804
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
+ */
6805
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
+ */
6806
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
+ */
6807
7315
  declare const getUnClaimReward: (poolState: PoolState, positionState: PositionState) => {
6808
7316
  feeTokenA: BN;
6809
7317
  feeTokenB: BN;
6810
7318
  rewards: BN[];
6811
7319
  };
6812
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
+ */
6813
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
+ */
6814
7332
  declare const vestingByPositionFilter: (position: PublicKey) => GetProgramAccountsFilter;
6815
7333
 
6816
- declare function calculateInitSqrtPrice(tokenAAmount: BN, tokenBAmount: BN, minSqrtPrice: BN, maxSqrtPrice: BN): BN;
6817
-
6818
7334
  interface TransferFeeIncludedAmount {
6819
7335
  amount: BN;
6820
7336
  transferFee: BN;
6821
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
+ */
6822
7345
  declare function calculateTransferFeeIncludedAmount(transferFeeExcludedAmount: BN, mint: Mint, currentEpoch: number): TransferFeeIncludedAmount;
6823
7346
  interface TransferFeeExcludedAmount {
6824
7347
  amount: BN;
6825
7348
  transferFee: BN;
6826
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
+ */
6827
7357
  declare function calculateTransferFeeExcludedAmount(transferFeeIncludedAmount: BN, mint: Mint, currentEpoch: number): TransferFeeExcludedAmount;
6828
7358
 
6829
7359
  /**
@@ -6848,17 +7378,774 @@ declare function getTotalLockedLiquidity(vestingData: VestingState): BN;
6848
7378
  */
6849
7379
  declare function getAvailableVestingLiquidity(vestingData: VestingState, currentPoint: BN): BN;
6850
7380
 
6851
- declare const ONE: BN;
6852
- declare function pow(base: BN, exp: BN): BN;
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(partner: PublicKey): 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;
6853
7684
 
6854
- declare function mulDiv(x: BN, y: BN, denominator: BN, rounding: Rounding): BN;
6855
- declare function q64ToDecimal(num: BN, decimalPlaces?: number): Decimal;
6856
- declare function decimalToQ64(num: Decimal): BN;
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;
7730
+ /**
7731
+ * Calculates the dynamic fee numerator based on market volatility metrics
7732
+ *
7733
+ * @param volatilityAccumulator - A measure of accumulated market volatility (BN)
7734
+ * @param binStep - The size of price bins in the liquidity distribution (BN)
7735
+ * @param variableFeeControl - Parameter controlling the impact of volatility on fees (BN)
7736
+ * @returns The calculated dynamic fee numerator (BN)
7737
+ */
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): [BN$1, BN$1, boolean];
7862
+ /**
7863
+ * Calculates the fee numerator from an excluded fee amount.
7864
+ * @param excludedFeeAmount - The excluded fee amount
7865
+ * @param referenceAmount - The reference amount
7866
+ * @param cliffFeeNumerator - The cliff fee numerator
7867
+ * @param maxFeeBps - The maximum fee in basis points
7868
+ * @param feeIncrementBps - The fee increment in basis points
7869
+ * @returns The fee numerator
7870
+ */
7871
+ declare function getFeeNumeratorFromExcludedFeeAmount(excludedFeeAmount: BN$1, referenceAmount: BN$1, cliffFeeNumerator: BN$1, maxFeeBps: number, feeIncrementBps: number): BN$1;
7872
+
7873
+ /**
7874
+ * Gets the swap result from exact input
7875
+ * @param poolState - The pool state
7876
+ * @param amountIn - The amount in
7877
+ * @param feeMode - The fee mode
7878
+ * @param tradeDirection - The trade direction
7879
+ * @param currentPoint - The current point
7880
+ * @returns The swap result from exact input
7881
+ */
7882
+ declare function getSwapResultFromExactInput(poolState: PoolState, amountIn: BN$1, feeMode: FeeMode, tradeDirection: TradeDirection, currentPoint: BN$1): SwapResult2;
7883
+ /**
7884
+ * Calculates the swap result from exact input
7885
+ * @param poolState - The pool state
7886
+ * @param amountIn - The amount in
7887
+ * @returns The swap result from exact input
7888
+ */
7889
+ declare function calculateAtoBFromAmountIn(poolState: PoolState, amountIn: BN$1): {
7890
+ outputAmount: BN$1;
7891
+ nextSqrtPrice: BN$1;
7892
+ amountLeft: BN$1;
7893
+ };
7894
+ /**
7895
+ * Calculates the swap result from exact input
7896
+ * @param poolState - The pool state
7897
+ * @param amountIn - The amount in
7898
+ * @returns The swap result from exact input
7899
+ */
7900
+ declare function calculateBtoAFromAmountIn(poolState: PoolState, amountIn: BN$1): {
7901
+ outputAmount: BN$1;
7902
+ nextSqrtPrice: BN$1;
7903
+ amountLeft: BN$1;
7904
+ };
7905
+ /**
7906
+ * Gets the swap result from partial input
7907
+ * @param poolState - The pool state
7908
+ * @param amountIn - The amount in
7909
+ * @param feeMode - The fee mode
7910
+ * @param tradeDirection - The trade direction
7911
+ * @param currentPoint - The current point
7912
+ * @returns The swap result from partial input
7913
+ */
7914
+ declare function getSwapResultFromPartialInput(poolState: PoolState, amountIn: BN$1, feeMode: FeeMode, tradeDirection: TradeDirection, currentPoint: BN$1): SwapResult2;
7915
+ /**
7916
+ * Calculates the swap result from partial input
7917
+ * @param poolState - The pool state
7918
+ * @param amountIn - The amount in
7919
+ * @returns The swap result from partial input
7920
+ */
7921
+ declare function calculateAtoBFromPartialAmountIn(poolState: PoolState, amountIn: BN$1): {
7922
+ outputAmount: BN$1;
7923
+ nextSqrtPrice: BN$1;
7924
+ amountLeft: BN$1;
7925
+ };
7926
+ /**
7927
+ * Calculates the swap result from partial input
7928
+ * @param poolState - The pool state
7929
+ * @param amountIn - The amount in
7930
+ * @returns The swap result from partial input
7931
+ */
7932
+ declare function calculateBtoAFromPartialAmountIn(poolState: PoolState, amountIn: BN$1): {
7933
+ outputAmount: BN$1;
7934
+ nextSqrtPrice: BN$1;
7935
+ amountLeft: BN$1;
7936
+ };
7937
+ /**
7938
+ * Gets the swap result from exact output
7939
+ * @param poolState - The pool state
7940
+ * @param amountOut - The amount out
7941
+ * @param feeMode - The fee mode
7942
+ * @param tradeDirection - The trade direction
7943
+ * @param currentPoint - The current point
7944
+ * @returns The swap result from exact output
7945
+ */
7946
+ declare function getSwapResultFromExactOutput(poolState: PoolState, amountOut: BN$1, feeMode: FeeMode, tradeDirection: TradeDirection, currentPoint: BN$1): SwapResult2;
7947
+ /**
7948
+ * Calculates the swap result from exact output
7949
+ * @param poolState - The pool state
7950
+ * @param amountOut - The amount out
7951
+ * @returns The swap result from exact output
7952
+ */
7953
+ declare function calculateAtoBFromAmountOut(poolState: PoolState, amountOut: BN$1): {
7954
+ inputAmount: BN$1;
7955
+ nextSqrtPrice: BN$1;
7956
+ };
7957
+ /**
7958
+ * Calculates the swap result from exact output
7959
+ * @param poolState - The pool state
7960
+ * @param amountOut - The amount out
7961
+ * @returns The swap result from exact output
7962
+ */
7963
+ declare function calculateBtoAFromAmountOut(poolState: PoolState, amountOut: BN$1): {
7964
+ inputAmount: BN$1;
7965
+ nextSqrtPrice: BN$1;
7966
+ };
7967
+ /**
7968
+ * Swaps quote exact input
7969
+ * @param pool - The pool
7970
+ * @param currentPoint - The current point
7971
+ * @param amountIn - The amount in
7972
+ * @param slippage - The slippage
7973
+ * @param aToB - The trade direction
7974
+ * @param hasReferral - The has referral
7975
+ * @param tokenADecimal - The token A decimal
7976
+ * @param tokenBDecimal - The token B decimal
7977
+ * @param inputTokenInfo - The input token info
7978
+ * @param outputTokenInfo - The output token info
7979
+ * @returns The swap quote exact input
7980
+ */
7981
+ declare function swapQuoteExactInput(pool: PoolState, currentPoint: BN$1, amountIn: BN$1, slippage: number, aToB: boolean, hasReferral: boolean, tokenADecimal: number, tokenBDecimal: number, inputTokenInfo?: {
7982
+ mint: Mint;
7983
+ currentEpoch: number;
7984
+ }, outputTokenInfo?: {
7985
+ mint: Mint;
7986
+ currentEpoch: number;
7987
+ }): Quote2Result;
7988
+ /**
7989
+ * Swaps quote exact output
7990
+ * @param pool - The pool
7991
+ * @param currentPoint - The current point
7992
+ * @param amountOut - The amount out
7993
+ * @param slippage - The slippage
7994
+ * @param aToB - The trade direction
7995
+ * @param hasReferral - The has referral
7996
+ * @param tokenADecimal - The token A decimal
7997
+ * @param tokenBDecimal - The token B decimal
7998
+ * @param inputTokenInfo - The input token info
7999
+ * @param outputTokenInfo - The output token info
8000
+ * @returns The swap quote exact output
8001
+ */
8002
+ declare function swapQuoteExactOutput(pool: PoolState, currentPoint: BN$1, amountOut: BN$1, slippage: number, aToB: boolean, hasReferral: boolean, tokenADecimal: number, tokenBDecimal: number, inputTokenInfo?: {
8003
+ mint: Mint;
8004
+ currentEpoch: number;
8005
+ }, outputTokenInfo?: {
8006
+ mint: Mint;
8007
+ currentEpoch: number;
8008
+ }): Quote2Result;
8009
+ /**
8010
+ * Swaps quote partial input
8011
+ * @param pool - The pool
8012
+ * @param currentPoint - The current point
8013
+ * @param amountIn - The amount in
8014
+ * @param slippage - The slippage
8015
+ * @param aToB - The trade direction
8016
+ * @param hasReferral - The has referral
8017
+ * @param tokenADecimal - The token A decimal
8018
+ * @param tokenBDecimal - The token B decimal
8019
+ * @param inputTokenInfo - The input token info
8020
+ * @param outputTokenInfo - The output token info
8021
+ * @returns The swap quote partial input
8022
+ */
8023
+ declare function swapQuotePartialInput(pool: PoolState, currentPoint: BN$1, amountIn: BN$1, slippage: number, aToB: boolean, hasReferral: boolean, tokenADecimal: number, tokenBDecimal: number, inputTokenInfo?: {
8024
+ mint: Mint;
8025
+ currentEpoch: number;
8026
+ }, outputTokenInfo?: {
8027
+ mint: Mint;
8028
+ currentEpoch: number;
8029
+ }): Quote2Result;
8030
+
8031
+ /**
8032
+ * Gets the next sqrt price given a delta of token_b (input), rounding down.
8033
+ * √P' = √P + Δb / L
8034
+ * @param sqrtPrice - current sqrt price (BN)
8035
+ * @param liquidity - current liquidity (BN)
8036
+ * @param amount - delta of token_b (BN)
8037
+ * @returns next sqrt price (BN)
8038
+ */
8039
+ declare function getNextSqrtPriceFromAmountInBRoundingDown(sqrtPrice: BN$1, liquidity: BN$1, amount: BN$1): BN$1;
8040
+ /**
8041
+ * Gets the next sqrt price given a delta of token_b (output), rounding down.
8042
+ * √P' = √P - Δb / L
8043
+ * @param sqrtPrice - current sqrt price (BN)
8044
+ * @param liquidity - current liquidity (BN)
8045
+ * @param amount - delta of token_b (BN)
8046
+ * @returns next sqrt price (BN)
8047
+ */
8048
+ declare function getNextSqrtPriceFromAmountOutBRoundingDown(sqrtPrice: BN$1, liquidity: BN$1, amount: BN$1): BN$1;
8049
+ /**
8050
+ * Gets the next sqrt price √P' given a delta of token_a, rounding up.
8051
+ * √P' = √P * L / (L + Δa * √P)
8052
+ * @param sqrtPrice - current sqrt price (BN)
8053
+ * @param liquidity - current liquidity (BN)
8054
+ * @param amount - delta of token_a (BN)
8055
+ * @returns next sqrt price (BN)
8056
+ */
8057
+ declare function getNextSqrtPriceFromAmountInARoundingUp(sqrtPrice: BN$1, liquidity: BN$1, amount: BN$1): BN$1;
8058
+ /**
8059
+ * Gets the next sqrt price √P' given a delta of token_a (output), rounding up.
8060
+ * √P' = √P * L / (L - Δa * √P)
8061
+ * @param sqrtPrice - current sqrt price (BN)
8062
+ * @param liquidity - current liquidity (BN)
8063
+ * @param amount - delta of token_a (BN)
8064
+ * @returns next sqrt price (BN)
8065
+ */
8066
+ declare function getNextSqrtPriceFromAmountOutARoundingUp(sqrtPrice: BN$1, liquidity: BN$1, amount: BN$1): BN$1;
8067
+ /**
8068
+ * Gets the next sqrt price given an output amount of token_a or token_b.
8069
+ * @param sqrtPrice - current sqrt price (BN)
8070
+ * @param liquidity - current liquidity (BN)
8071
+ * @param amountOut - output amount (BN)
8072
+ * @param aForB - true if swapping A for B, false if B for A
8073
+ * @returns next sqrt price (BN)
8074
+ */
8075
+ declare function getNextSqrtPriceFromOutput(sqrtPrice: BN$1, liquidity: BN$1, amountOut: BN$1, aForB: boolean): BN$1;
8076
+ /**
8077
+ * Gets the next sqrt price given an input amount of token_a or token_b
8078
+ * @param sqrtPrice - current sqrt price (BN)
8079
+ * @param liquidity - current liquidity (BN)
8080
+ * @param amountIn - input amount (BN)
8081
+ * @param aForB - true if swapping A for B, false if B for A
8082
+ * @returns next sqrt price (BN)
8083
+ */
8084
+ declare function getNextSqrtPriceFromInput(sqrtPrice: BN$1, liquidity: BN$1, amountIn: BN$1, aForB: boolean): BN$1;
8085
+ /**
8086
+ * Gets the delta amount of token_b for given liquidity and price range. (getDeltaAmountBUnsigned)
8087
+ * @param lowerSqrtPrice - lower sqrt price (BN)
8088
+ * @param upperSqrtPrice - upper sqrt price (BN)
8089
+ * @param liquidity - current liquidity (BN)
8090
+ * @param rounding - rounding (Rounding)
8091
+ * @returns delta amount of token_b (BN)
8092
+ */
8093
+ declare function getAmountBFromLiquidityDelta(lowerSqrtPrice: BN$1, upperSqrtPrice: BN$1, liquidity: BN$1, rounding: Rounding): BN$1;
8094
+ /**
8095
+ * Gets the delta amount_a for given liquidity and price range. (getDeltaAmountAUnsigned)
8096
+ * `Δa = L * (1 / √P_lower - 1 / √P_upper)`
8097
+ * i.e. `L * (√P_upper - √P_lower) / (√P_upper * √P_lower)`
8098
+ * @param lowerSqrtPrice - lower sqrt price (BN)
8099
+ * @param upperSqrtPrice - upper sqrt price (BN)
8100
+ * @param liquidity - current liquidity (BN)
8101
+ * @param rounding - rounding (Rounding)
8102
+ * @returns delta amount of token_a (BN)
8103
+ */
8104
+ declare function getAmountAFromLiquidityDelta(lowerSqrtPrice: BN$1, upperSqrtPrice: BN$1, liquidity: BN$1, rounding: Rounding): BN$1;
8105
+ /**
8106
+ * Gets the liquidity delta from amount A
8107
+ * Δa = L * (1 / √P_lower - 1 / √P_upper)
8108
+ * Δa = L * (√P_upper - √P_lower) / (√P_upper * √P_lower)
8109
+ * L = Δa * √P_upper * √P_lower / (√P_upper - √P_lower)
8110
+ * @param amountA - The amount of token A
8111
+ * @param lowerSqrtPrice - The lower sqrt price
8112
+ * @param upperSqrtPrice - The upper sqrt price
8113
+ * @returns The liquidity delta from amount A
8114
+ */
8115
+ declare function getLiquidityDeltaFromAmountA(amountA: BN$1, lowerSqrtPrice: BN$1, // current sqrt price
8116
+ upperSqrtPrice: BN$1): BN$1;
8117
+ /**
8118
+ * Gets the liquidity delta from amount B
8119
+ * Δb = L (√P_upper - √P_lower)
8120
+ * L = Δb / (√P_upper - √P_lower)
8121
+ * @param amountB - The amount of token B
8122
+ * @param lowerSqrtPrice - The lower sqrt price
8123
+ * @param upperSqrtPrice - The upper sqrt price
8124
+ * @returns The liquidity delta from amount B
8125
+ */
8126
+ declare function getLiquidityDeltaFromAmountB(amountB: BN$1, lowerSqrtPrice: BN$1, // min sqrt price
8127
+ upperSqrtPrice: BN$1): BN$1;
8128
+
8129
+ /**
8130
+ * Calculates the initial sqrt price
8131
+ * a = L * (1/s - 1/pb)
8132
+ * b = L * (s - pa)
8133
+ * b/a = (s - pa) / (1/s - 1/pb)
8134
+ * With: x = 1 / pb and y = b/a
8135
+ * => s ^ 2 + s * (-pa + x * y) - y = 0
8136
+ * s = [(pa - xy) + √((xy - pa)² + 4y)]/2
8137
+ * @param tokenAAmount - The token A amount
8138
+ * @param tokenBAmount - The token B amount
8139
+ * @param minSqrtPrice - The min sqrt price
8140
+ * @param maxSqrtPrice - The max sqrt price
8141
+ * @returns The initial sqrt price
8142
+ */
8143
+ declare function calculateInitSqrtPrice(tokenAAmount: BN, tokenBAmount: BN, minSqrtPrice: BN, maxSqrtPrice: BN): BN;
6857
8144
 
6858
8145
  var address = "cpamdpZCGKUy5JxQXB4dcpGPiikHawvSWAd6mEn1sGG";
6859
8146
  var metadata = {
6860
8147
  name: "cp_amm",
6861
- version: "0.1.3",
8148
+ version: "0.1.5",
6862
8149
  spec: "0.1.0",
6863
8150
  description: "Created with Anchor"
6864
8151
  };
@@ -9941,67 +11228,233 @@ var instructions = [
9941
11228
  writable: true
9942
11229
  },
9943
11230
  {
9944
- name: "token_a_vault",
9945
- docs: [
9946
- "The vault token account for input token"
9947
- ],
11231
+ name: "token_a_vault",
11232
+ docs: [
11233
+ "The vault token account for input token"
11234
+ ],
11235
+ writable: true,
11236
+ relations: [
11237
+ "pool"
11238
+ ]
11239
+ },
11240
+ {
11241
+ name: "token_b_vault",
11242
+ docs: [
11243
+ "The vault token account for output token"
11244
+ ],
11245
+ writable: true,
11246
+ relations: [
11247
+ "pool"
11248
+ ]
11249
+ },
11250
+ {
11251
+ name: "token_a_mint",
11252
+ docs: [
11253
+ "The mint of token a"
11254
+ ],
11255
+ relations: [
11256
+ "pool"
11257
+ ]
11258
+ },
11259
+ {
11260
+ name: "token_b_mint",
11261
+ docs: [
11262
+ "The mint of token b"
11263
+ ],
11264
+ relations: [
11265
+ "pool"
11266
+ ]
11267
+ },
11268
+ {
11269
+ name: "position_nft_account",
11270
+ docs: [
11271
+ "The token account for nft"
11272
+ ]
11273
+ },
11274
+ {
11275
+ name: "owner",
11276
+ docs: [
11277
+ "owner of position"
11278
+ ],
11279
+ signer: true
11280
+ },
11281
+ {
11282
+ name: "token_a_program",
11283
+ docs: [
11284
+ "Token a program"
11285
+ ]
11286
+ },
11287
+ {
11288
+ name: "token_b_program",
11289
+ docs: [
11290
+ "Token b program"
11291
+ ]
11292
+ },
11293
+ {
11294
+ name: "event_authority",
11295
+ pda: {
11296
+ seeds: [
11297
+ {
11298
+ kind: "const",
11299
+ value: [
11300
+ 95,
11301
+ 95,
11302
+ 101,
11303
+ 118,
11304
+ 101,
11305
+ 110,
11306
+ 116,
11307
+ 95,
11308
+ 97,
11309
+ 117,
11310
+ 116,
11311
+ 104,
11312
+ 111,
11313
+ 114,
11314
+ 105,
11315
+ 116,
11316
+ 121
11317
+ ]
11318
+ }
11319
+ ]
11320
+ }
11321
+ },
11322
+ {
11323
+ name: "program"
11324
+ }
11325
+ ],
11326
+ args: [
11327
+ {
11328
+ name: "params",
11329
+ type: {
11330
+ defined: {
11331
+ name: "RemoveLiquidityParameters"
11332
+ }
11333
+ }
11334
+ }
11335
+ ]
11336
+ },
11337
+ {
11338
+ name: "set_pool_status",
11339
+ discriminator: [
11340
+ 112,
11341
+ 87,
11342
+ 135,
11343
+ 223,
11344
+ 83,
11345
+ 204,
11346
+ 132,
11347
+ 53
11348
+ ],
11349
+ accounts: [
11350
+ {
11351
+ name: "pool",
11352
+ writable: true
11353
+ },
11354
+ {
11355
+ name: "admin",
11356
+ signer: true
11357
+ },
11358
+ {
11359
+ name: "event_authority",
11360
+ pda: {
11361
+ seeds: [
11362
+ {
11363
+ kind: "const",
11364
+ value: [
11365
+ 95,
11366
+ 95,
11367
+ 101,
11368
+ 118,
11369
+ 101,
11370
+ 110,
11371
+ 116,
11372
+ 95,
11373
+ 97,
11374
+ 117,
11375
+ 116,
11376
+ 104,
11377
+ 111,
11378
+ 114,
11379
+ 105,
11380
+ 116,
11381
+ 121
11382
+ ]
11383
+ }
11384
+ ]
11385
+ }
11386
+ },
11387
+ {
11388
+ name: "program"
11389
+ }
11390
+ ],
11391
+ args: [
11392
+ {
11393
+ name: "status",
11394
+ type: "u8"
11395
+ }
11396
+ ]
11397
+ },
11398
+ {
11399
+ name: "split_position",
11400
+ discriminator: [
11401
+ 172,
11402
+ 241,
11403
+ 221,
11404
+ 138,
11405
+ 161,
11406
+ 29,
11407
+ 253,
11408
+ 42
11409
+ ],
11410
+ accounts: [
11411
+ {
11412
+ name: "pool",
9948
11413
  writable: true,
9949
11414
  relations: [
9950
- "pool"
11415
+ "first_position",
11416
+ "second_position"
9951
11417
  ]
9952
11418
  },
9953
11419
  {
9954
- name: "token_b_vault",
11420
+ name: "first_position",
9955
11421
  docs: [
9956
- "The vault token account for output token"
11422
+ "The first position"
9957
11423
  ],
9958
- writable: true,
9959
- relations: [
9960
- "pool"
9961
- ]
11424
+ writable: true
9962
11425
  },
9963
11426
  {
9964
- name: "token_a_mint",
11427
+ name: "first_position_nft_account",
9965
11428
  docs: [
9966
- "The mint of token a"
9967
- ],
9968
- relations: [
9969
- "pool"
11429
+ "The token account for position nft"
9970
11430
  ]
9971
11431
  },
9972
11432
  {
9973
- name: "token_b_mint",
11433
+ name: "second_position",
9974
11434
  docs: [
9975
- "The mint of token b"
11435
+ "The second position"
9976
11436
  ],
9977
- relations: [
9978
- "pool"
9979
- ]
11437
+ writable: true
9980
11438
  },
9981
11439
  {
9982
- name: "position_nft_account",
11440
+ name: "second_position_nft_account",
9983
11441
  docs: [
9984
- "The token account for nft"
11442
+ "The token account for position nft"
9985
11443
  ]
9986
11444
  },
9987
11445
  {
9988
- name: "owner",
11446
+ name: "first_owner",
9989
11447
  docs: [
9990
- "owner of position"
11448
+ "Owner of first position"
9991
11449
  ],
9992
11450
  signer: true
9993
11451
  },
9994
11452
  {
9995
- name: "token_a_program",
9996
- docs: [
9997
- "Token a program"
9998
- ]
9999
- },
10000
- {
10001
- name: "token_b_program",
11453
+ name: "second_owner",
10002
11454
  docs: [
10003
- "Token b program"
10004
- ]
11455
+ "Owner of second position"
11456
+ ],
11457
+ signer: true
10005
11458
  },
10006
11459
  {
10007
11460
  name: "event_authority",
@@ -10041,31 +11494,71 @@ var instructions = [
10041
11494
  name: "params",
10042
11495
  type: {
10043
11496
  defined: {
10044
- name: "RemoveLiquidityParameters"
11497
+ name: "SplitPositionParameters"
10045
11498
  }
10046
11499
  }
10047
11500
  }
10048
11501
  ]
10049
11502
  },
10050
11503
  {
10051
- name: "set_pool_status",
11504
+ name: "split_position2",
10052
11505
  discriminator: [
10053
- 112,
10054
- 87,
10055
- 135,
10056
- 223,
10057
- 83,
10058
- 204,
10059
- 132,
10060
- 53
11506
+ 221,
11507
+ 147,
11508
+ 228,
11509
+ 207,
11510
+ 140,
11511
+ 212,
11512
+ 17,
11513
+ 119
10061
11514
  ],
10062
11515
  accounts: [
10063
11516
  {
10064
11517
  name: "pool",
11518
+ writable: true,
11519
+ relations: [
11520
+ "first_position",
11521
+ "second_position"
11522
+ ]
11523
+ },
11524
+ {
11525
+ name: "first_position",
11526
+ docs: [
11527
+ "The first position"
11528
+ ],
10065
11529
  writable: true
10066
11530
  },
10067
11531
  {
10068
- name: "admin",
11532
+ name: "first_position_nft_account",
11533
+ docs: [
11534
+ "The token account for position nft"
11535
+ ]
11536
+ },
11537
+ {
11538
+ name: "second_position",
11539
+ docs: [
11540
+ "The second position"
11541
+ ],
11542
+ writable: true
11543
+ },
11544
+ {
11545
+ name: "second_position_nft_account",
11546
+ docs: [
11547
+ "The token account for position nft"
11548
+ ]
11549
+ },
11550
+ {
11551
+ name: "first_owner",
11552
+ docs: [
11553
+ "Owner of first position"
11554
+ ],
11555
+ signer: true
11556
+ },
11557
+ {
11558
+ name: "second_owner",
11559
+ docs: [
11560
+ "Owner of second position"
11561
+ ],
10069
11562
  signer: true
10070
11563
  },
10071
11564
  {
@@ -10103,71 +11596,107 @@ var instructions = [
10103
11596
  ],
10104
11597
  args: [
10105
11598
  {
10106
- name: "status",
10107
- type: "u8"
11599
+ name: "numerator",
11600
+ type: "u32"
10108
11601
  }
10109
11602
  ]
10110
11603
  },
10111
11604
  {
10112
- name: "split_position",
11605
+ name: "swap",
10113
11606
  discriminator: [
10114
- 172,
10115
- 241,
10116
- 221,
10117
- 138,
10118
- 161,
10119
- 29,
10120
- 253,
10121
- 42
11607
+ 248,
11608
+ 198,
11609
+ 158,
11610
+ 145,
11611
+ 225,
11612
+ 117,
11613
+ 135,
11614
+ 200
10122
11615
  ],
10123
11616
  accounts: [
11617
+ {
11618
+ name: "pool_authority",
11619
+ address: "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC"
11620
+ },
10124
11621
  {
10125
11622
  name: "pool",
10126
- writable: true,
10127
- relations: [
10128
- "first_position",
10129
- "second_position"
10130
- ]
11623
+ docs: [
11624
+ "Pool account"
11625
+ ],
11626
+ writable: true
10131
11627
  },
10132
11628
  {
10133
- name: "first_position",
11629
+ name: "input_token_account",
10134
11630
  docs: [
10135
- "The first position"
11631
+ "The user token account for input token"
10136
11632
  ],
10137
11633
  writable: true
10138
11634
  },
10139
11635
  {
10140
- name: "first_position_nft_account",
11636
+ name: "output_token_account",
10141
11637
  docs: [
10142
- "The token account for position nft"
11638
+ "The user token account for output token"
11639
+ ],
11640
+ writable: true
11641
+ },
11642
+ {
11643
+ name: "token_a_vault",
11644
+ docs: [
11645
+ "The vault token account for input token"
11646
+ ],
11647
+ writable: true,
11648
+ relations: [
11649
+ "pool"
10143
11650
  ]
10144
11651
  },
10145
11652
  {
10146
- name: "second_position",
11653
+ name: "token_b_vault",
10147
11654
  docs: [
10148
- "The second position"
11655
+ "The vault token account for output token"
10149
11656
  ],
10150
- writable: true
11657
+ writable: true,
11658
+ relations: [
11659
+ "pool"
11660
+ ]
10151
11661
  },
10152
11662
  {
10153
- name: "second_position_nft_account",
11663
+ name: "token_a_mint",
10154
11664
  docs: [
10155
- "The token account for position nft"
11665
+ "The mint of token a"
10156
11666
  ]
10157
11667
  },
10158
11668
  {
10159
- name: "first_owner",
11669
+ name: "token_b_mint",
10160
11670
  docs: [
10161
- "Owner of first position"
11671
+ "The mint of token b"
11672
+ ]
11673
+ },
11674
+ {
11675
+ name: "payer",
11676
+ docs: [
11677
+ "The user performing the swap"
10162
11678
  ],
10163
11679
  signer: true
10164
11680
  },
10165
11681
  {
10166
- name: "second_owner",
11682
+ name: "token_a_program",
10167
11683
  docs: [
10168
- "Owner of second position"
11684
+ "Token a program"
11685
+ ]
11686
+ },
11687
+ {
11688
+ name: "token_b_program",
11689
+ docs: [
11690
+ "Token b program"
11691
+ ]
11692
+ },
11693
+ {
11694
+ name: "referral_token_account",
11695
+ docs: [
11696
+ "referral token account"
10169
11697
  ],
10170
- signer: true
11698
+ writable: true,
11699
+ optional: true
10171
11700
  },
10172
11701
  {
10173
11702
  name: "event_authority",
@@ -10207,23 +11736,23 @@ var instructions = [
10207
11736
  name: "params",
10208
11737
  type: {
10209
11738
  defined: {
10210
- name: "SplitPositionParameters"
11739
+ name: "SwapParameters"
10211
11740
  }
10212
11741
  }
10213
11742
  }
10214
11743
  ]
10215
11744
  },
10216
11745
  {
10217
- name: "swap",
11746
+ name: "swap2",
10218
11747
  discriminator: [
10219
- 248,
10220
- 198,
10221
- 158,
10222
- 145,
10223
- 225,
10224
- 117,
10225
- 135,
10226
- 200
11748
+ 65,
11749
+ 75,
11750
+ 63,
11751
+ 76,
11752
+ 235,
11753
+ 91,
11754
+ 91,
11755
+ 136
10227
11756
  ],
10228
11757
  accounts: [
10229
11758
  {
@@ -10348,7 +11877,7 @@ var instructions = [
10348
11877
  name: "params",
10349
11878
  type: {
10350
11879
  defined: {
10351
- name: "SwapParameters"
11880
+ name: "SwapParameters2"
10352
11881
  }
10353
11882
  }
10354
11883
  }
@@ -10853,6 +12382,19 @@ var events = [
10853
12382
  249
10854
12383
  ]
10855
12384
  },
12385
+ {
12386
+ name: "EvtLiquidityChange",
12387
+ discriminator: [
12388
+ 197,
12389
+ 171,
12390
+ 78,
12391
+ 127,
12392
+ 224,
12393
+ 211,
12394
+ 87,
12395
+ 13
12396
+ ]
12397
+ },
10856
12398
  {
10857
12399
  name: "EvtLockPosition",
10858
12400
  discriminator: [
@@ -10906,16 +12448,16 @@ var events = [
10906
12448
  ]
10907
12449
  },
10908
12450
  {
10909
- name: "EvtSplitPosition",
12451
+ name: "EvtSplitPosition2",
10910
12452
  discriminator: [
10911
- 182,
10912
- 138,
10913
- 42,
10914
- 254,
10915
- 27,
10916
- 94,
10917
- 82,
10918
- 221
12453
+ 165,
12454
+ 32,
12455
+ 203,
12456
+ 174,
12457
+ 72,
12458
+ 100,
12459
+ 233,
12460
+ 103
10919
12461
  ]
10920
12462
  },
10921
12463
  {
@@ -10931,6 +12473,19 @@ var events = [
10931
12473
  147
10932
12474
  ]
10933
12475
  },
12476
+ {
12477
+ name: "EvtSwap2",
12478
+ discriminator: [
12479
+ 189,
12480
+ 66,
12481
+ 51,
12482
+ 168,
12483
+ 38,
12484
+ 80,
12485
+ 117,
12486
+ 153
12487
+ ]
12488
+ },
10934
12489
  {
10935
12490
  name: "EvtUpdateRewardDuration",
10936
12491
  discriminator: [
@@ -11206,6 +12761,36 @@ var errors = [
11206
12761
  code: 6046,
11207
12762
  name: "SamePosition",
11208
12763
  msg: "Same position"
12764
+ },
12765
+ {
12766
+ code: 6047,
12767
+ name: "InvalidBaseFeeMode",
12768
+ msg: "Invalid base fee mode"
12769
+ },
12770
+ {
12771
+ code: 6048,
12772
+ name: "InvalidFeeRateLimiter",
12773
+ msg: "Invalid fee rate limiter"
12774
+ },
12775
+ {
12776
+ code: 6049,
12777
+ name: "FailToValidateSingleSwapInstruction",
12778
+ msg: "Fail to validate single swap instruction in rate limiter"
12779
+ },
12780
+ {
12781
+ code: 6050,
12782
+ name: "InvalidFeeScheduler",
12783
+ msg: "Invalid fee scheduler"
12784
+ },
12785
+ {
12786
+ code: 6051,
12787
+ name: "UndeterminedError",
12788
+ msg: "Undetermined error"
12789
+ },
12790
+ {
12791
+ code: 6052,
12792
+ name: "InvalidPoolVersion",
12793
+ msg: "Invalid pool version"
11209
12794
  }
11210
12795
  ];
11211
12796
  var types = [
@@ -11252,7 +12837,7 @@ var types = [
11252
12837
  type: "u64"
11253
12838
  },
11254
12839
  {
11255
- name: "fee_scheduler_mode",
12840
+ name: "base_fee_mode",
11256
12841
  type: "u8"
11257
12842
  },
11258
12843
  {
@@ -11265,15 +12850,20 @@ var types = [
11265
12850
  }
11266
12851
  },
11267
12852
  {
11268
- name: "number_of_period",
12853
+ name: "first_factor",
11269
12854
  type: "u16"
11270
12855
  },
11271
12856
  {
11272
- name: "period_frequency",
11273
- type: "u64"
12857
+ name: "second_factor",
12858
+ type: {
12859
+ array: [
12860
+ "u8",
12861
+ 8
12862
+ ]
12863
+ }
11274
12864
  },
11275
12865
  {
11276
- name: "reduction_factor",
12866
+ name: "third_factor",
11277
12867
  type: "u64"
11278
12868
  }
11279
12869
  ]
@@ -11289,19 +12879,24 @@ var types = [
11289
12879
  type: "u64"
11290
12880
  },
11291
12881
  {
11292
- name: "number_of_period",
12882
+ name: "first_factor",
11293
12883
  type: "u16"
11294
12884
  },
11295
12885
  {
11296
- name: "period_frequency",
11297
- type: "u64"
12886
+ name: "second_factor",
12887
+ type: {
12888
+ array: [
12889
+ "u8",
12890
+ 8
12891
+ ]
12892
+ }
11298
12893
  },
11299
12894
  {
11300
- name: "reduction_factor",
12895
+ name: "third_factor",
11301
12896
  type: "u64"
11302
12897
  },
11303
12898
  {
11304
- name: "fee_scheduler_mode",
12899
+ name: "base_fee_mode",
11305
12900
  type: "u8"
11306
12901
  }
11307
12902
  ]
@@ -11321,7 +12916,7 @@ var types = [
11321
12916
  type: "u64"
11322
12917
  },
11323
12918
  {
11324
- name: "fee_scheduler_mode",
12919
+ name: "base_fee_mode",
11325
12920
  type: "u8"
11326
12921
  },
11327
12922
  {
@@ -11334,15 +12929,20 @@ var types = [
11334
12929
  }
11335
12930
  },
11336
12931
  {
11337
- name: "number_of_period",
12932
+ name: "first_factor",
11338
12933
  type: "u16"
11339
12934
  },
11340
12935
  {
11341
- name: "period_frequency",
11342
- type: "u64"
12936
+ name: "second_factor",
12937
+ type: {
12938
+ array: [
12939
+ "u8",
12940
+ 8
12941
+ ]
12942
+ }
11343
12943
  },
11344
12944
  {
11345
- name: "reduction_factor",
12945
+ name: "third_factor",
11346
12946
  type: "u64"
11347
12947
  },
11348
12948
  {
@@ -12181,6 +13781,66 @@ var types = [
12181
13781
  ]
12182
13782
  }
12183
13783
  },
13784
+ {
13785
+ name: "EvtLiquidityChange",
13786
+ type: {
13787
+ kind: "struct",
13788
+ fields: [
13789
+ {
13790
+ name: "pool",
13791
+ type: "pubkey"
13792
+ },
13793
+ {
13794
+ name: "position",
13795
+ type: "pubkey"
13796
+ },
13797
+ {
13798
+ name: "owner",
13799
+ type: "pubkey"
13800
+ },
13801
+ {
13802
+ name: "token_a_amount",
13803
+ type: "u64"
13804
+ },
13805
+ {
13806
+ name: "token_b_amount",
13807
+ type: "u64"
13808
+ },
13809
+ {
13810
+ name: "transfer_fee_included_token_a_amount",
13811
+ type: "u64"
13812
+ },
13813
+ {
13814
+ name: "transfer_fee_included_token_b_amount",
13815
+ type: "u64"
13816
+ },
13817
+ {
13818
+ name: "reserve_a_amount",
13819
+ type: "u64"
13820
+ },
13821
+ {
13822
+ name: "reserve_b_amount",
13823
+ type: "u64"
13824
+ },
13825
+ {
13826
+ name: "liquidity_delta",
13827
+ type: "u128"
13828
+ },
13829
+ {
13830
+ name: "token_a_amount_threshold",
13831
+ type: "u64"
13832
+ },
13833
+ {
13834
+ name: "token_b_amount_threshold",
13835
+ type: "u64"
13836
+ },
13837
+ {
13838
+ name: "change_type",
13839
+ type: "u8"
13840
+ }
13841
+ ]
13842
+ }
13843
+ },
12184
13844
  {
12185
13845
  name: "EvtLockPosition",
12186
13846
  type: {
@@ -12302,7 +13962,7 @@ var types = [
12302
13962
  }
12303
13963
  },
12304
13964
  {
12305
- name: "EvtSplitPosition",
13965
+ name: "EvtSplitPosition2",
12306
13966
  type: {
12307
13967
  kind: "struct",
12308
13968
  fields: [
@@ -12358,7 +14018,7 @@ var types = [
12358
14018
  name: "split_position_parameters",
12359
14019
  type: {
12360
14020
  defined: {
12361
- name: "SplitPositionParameters"
14021
+ name: "SplitPositionParameters2"
12362
14022
  }
12363
14023
  }
12364
14024
  }
@@ -12409,6 +14069,70 @@ var types = [
12409
14069
  ]
12410
14070
  }
12411
14071
  },
14072
+ {
14073
+ name: "EvtSwap2",
14074
+ type: {
14075
+ kind: "struct",
14076
+ fields: [
14077
+ {
14078
+ name: "pool",
14079
+ type: "pubkey"
14080
+ },
14081
+ {
14082
+ name: "trade_direction",
14083
+ type: "u8"
14084
+ },
14085
+ {
14086
+ name: "collect_fee_mode",
14087
+ type: "u8"
14088
+ },
14089
+ {
14090
+ name: "has_referral",
14091
+ type: "bool"
14092
+ },
14093
+ {
14094
+ name: "params",
14095
+ type: {
14096
+ defined: {
14097
+ name: "SwapParameters2"
14098
+ }
14099
+ }
14100
+ },
14101
+ {
14102
+ name: "swap_result",
14103
+ type: {
14104
+ defined: {
14105
+ name: "SwapResult2"
14106
+ }
14107
+ }
14108
+ },
14109
+ {
14110
+ name: "included_transfer_fee_amount_in",
14111
+ type: "u64"
14112
+ },
14113
+ {
14114
+ name: "included_transfer_fee_amount_out",
14115
+ type: "u64"
14116
+ },
14117
+ {
14118
+ name: "excluded_transfer_fee_amount_out",
14119
+ type: "u64"
14120
+ },
14121
+ {
14122
+ name: "current_timestamp",
14123
+ type: "u64"
14124
+ },
14125
+ {
14126
+ name: "reserve_a_amount",
14127
+ type: "u64"
14128
+ },
14129
+ {
14130
+ name: "reserve_b_amount",
14131
+ type: "u64"
14132
+ }
14133
+ ]
14134
+ }
14135
+ },
12412
14136
  {
12413
14137
  name: "EvtUpdateRewardDuration",
12414
14138
  type: {
@@ -12759,17 +14483,19 @@ var types = [
12759
14483
  ],
12760
14484
  type: "u8"
12761
14485
  },
14486
+ {
14487
+ name: "version",
14488
+ docs: [
14489
+ "pool version, 0: max_fee is still capped at 50%, 1: max_fee is capped at 99%"
14490
+ ],
14491
+ type: "u8"
14492
+ },
12762
14493
  {
12763
14494
  name: "_padding_0",
12764
14495
  docs: [
12765
14496
  "padding"
12766
14497
  ],
12767
- type: {
12768
- array: [
12769
- "u8",
12770
- 2
12771
- ]
12772
- }
14498
+ type: "u8"
12773
14499
  },
12774
14500
  {
12775
14501
  name: "fee_a_per_liquidity",
@@ -13502,6 +15228,38 @@ var types = [
13502
15228
  ]
13503
15229
  }
13504
15230
  },
15231
+ {
15232
+ name: "SplitPositionParameters2",
15233
+ type: {
15234
+ kind: "struct",
15235
+ fields: [
15236
+ {
15237
+ name: "unlocked_liquidity_numerator",
15238
+ type: "u32"
15239
+ },
15240
+ {
15241
+ name: "permanent_locked_liquidity_numerator",
15242
+ type: "u32"
15243
+ },
15244
+ {
15245
+ name: "fee_a_numerator",
15246
+ type: "u32"
15247
+ },
15248
+ {
15249
+ name: "fee_b_numerator",
15250
+ type: "u32"
15251
+ },
15252
+ {
15253
+ name: "reward_0_numerator",
15254
+ type: "u32"
15255
+ },
15256
+ {
15257
+ name: "reward_1_numerator",
15258
+ type: "u32"
15259
+ }
15260
+ ]
15261
+ }
15262
+ },
13505
15263
  {
13506
15264
  name: "StaticConfigParameters",
13507
15265
  type: {
@@ -13558,6 +15316,35 @@ var types = [
13558
15316
  ]
13559
15317
  }
13560
15318
  },
15319
+ {
15320
+ name: "SwapParameters2",
15321
+ type: {
15322
+ kind: "struct",
15323
+ fields: [
15324
+ {
15325
+ name: "amount_0",
15326
+ docs: [
15327
+ "When it's exact in, partial fill, this will be amount_in. When it's exact out, this will be amount_out"
15328
+ ],
15329
+ type: "u64"
15330
+ },
15331
+ {
15332
+ name: "amount_1",
15333
+ docs: [
15334
+ "When it's exact in, partial fill, this will be minimum_amount_out. When it's exact out, this will be maximum_amount_in"
15335
+ ],
15336
+ type: "u64"
15337
+ },
15338
+ {
15339
+ name: "swap_mode",
15340
+ docs: [
15341
+ "Swap mode, refer [SwapMode]"
15342
+ ],
15343
+ type: "u8"
15344
+ }
15345
+ ]
15346
+ }
15347
+ },
13561
15348
  {
13562
15349
  name: "SwapResult",
13563
15350
  docs: [
@@ -13593,6 +15380,50 @@ var types = [
13593
15380
  ]
13594
15381
  }
13595
15382
  },
15383
+ {
15384
+ name: "SwapResult2",
15385
+ type: {
15386
+ kind: "struct",
15387
+ fields: [
15388
+ {
15389
+ name: "included_fee_input_amount",
15390
+ type: "u64"
15391
+ },
15392
+ {
15393
+ name: "excluded_fee_input_amount",
15394
+ type: "u64"
15395
+ },
15396
+ {
15397
+ name: "amount_left",
15398
+ type: "u64"
15399
+ },
15400
+ {
15401
+ name: "output_amount",
15402
+ type: "u64"
15403
+ },
15404
+ {
15405
+ name: "next_sqrt_price",
15406
+ type: "u128"
15407
+ },
15408
+ {
15409
+ name: "trading_fee",
15410
+ type: "u64"
15411
+ },
15412
+ {
15413
+ name: "protocol_fee",
15414
+ type: "u64"
15415
+ },
15416
+ {
15417
+ name: "partner_fee",
15418
+ type: "u64"
15419
+ },
15420
+ {
15421
+ name: "referral_fee",
15422
+ type: "u64"
15423
+ }
15424
+ ]
15425
+ }
15426
+ },
13596
15427
  {
13597
15428
  name: "TokenBadge",
13598
15429
  docs: [
@@ -13764,4 +15595,4 @@ var CpAmmIDL = {
13764
15595
  types: types
13765
15596
  };
13766
15597
 
13767
- 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, type SetupFeeClaimAccountsParams, 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 };
15598
+ 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 };