@meteora-ag/cp-amm-sdk 1.0.1 → 1.0.2-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -30,7 +30,7 @@ var cp_amm_default = {
30
30
  address: "cpamdpZCGKUy5JxQXB4dcpGPiikHawvSWAd6mEn1sGG",
31
31
  metadata: {
32
32
  name: "cp_amm",
33
- version: "0.1.0",
33
+ version: "0.1.1",
34
34
  spec: "0.1.0",
35
35
  description: "Created with Anchor"
36
36
  },
@@ -591,38 +591,38 @@ var cp_amm_default = {
591
591
  {
592
592
  kind: "const",
593
593
  value: [
594
- 153,
595
- 10,
596
- 107,
597
- 154,
598
- 255,
599
- 249,
600
- 210,
594
+ 48,
595
+ 9,
596
+ 89,
597
+ 123,
598
+ 106,
599
+ 114,
600
+ 131,
601
+ 251,
602
+ 50,
601
603
  173,
602
- 176,
603
- 67,
604
- 220,
605
- 214,
606
- 152,
607
- 71,
608
- 46,
609
- 146,
610
- 161,
611
- 33,
604
+ 254,
605
+ 250,
606
+ 10,
607
+ 80,
608
+ 160,
609
+ 84,
610
+ 143,
611
+ 100,
612
612
  81,
613
- 148,
613
+ 249,
614
+ 134,
615
+ 112,
616
+ 30,
617
+ 213,
618
+ 50,
614
619
  166,
615
- 119,
616
- 5,
617
- 189,
618
- 142,
619
- 11,
620
- 57,
621
- 68,
622
- 162,
623
- 70,
624
- 126,
625
- 100
620
+ 239,
621
+ 78,
622
+ 53,
623
+ 175,
624
+ 188,
625
+ 85
626
626
  ]
627
627
  },
628
628
  {
@@ -684,38 +684,38 @@ var cp_amm_default = {
684
684
  {
685
685
  kind: "const",
686
686
  value: [
687
- 153,
688
- 10,
689
- 107,
690
- 154,
691
- 255,
692
- 249,
693
- 210,
687
+ 48,
688
+ 9,
689
+ 89,
690
+ 123,
691
+ 106,
692
+ 114,
693
+ 131,
694
+ 251,
695
+ 50,
694
696
  173,
695
- 176,
696
- 67,
697
- 220,
698
- 214,
699
- 152,
700
- 71,
701
- 46,
702
- 146,
703
- 161,
704
- 33,
697
+ 254,
698
+ 250,
699
+ 10,
700
+ 80,
701
+ 160,
702
+ 84,
703
+ 143,
704
+ 100,
705
705
  81,
706
- 148,
706
+ 249,
707
+ 134,
708
+ 112,
709
+ 30,
710
+ 213,
711
+ 50,
707
712
  166,
708
- 119,
709
- 5,
710
- 189,
711
- 142,
712
- 11,
713
- 57,
714
- 68,
715
- 162,
716
- 70,
717
- 126,
718
- 100
713
+ 239,
714
+ 78,
715
+ 53,
716
+ 175,
717
+ 188,
718
+ 85
719
719
  ]
720
720
  },
721
721
  {
@@ -1309,7 +1309,7 @@ var cp_amm_default = {
1309
1309
  },
1310
1310
  {
1311
1311
  kind: "arg",
1312
- path: "config_parameters.index"
1312
+ path: "index"
1313
1313
  }
1314
1314
  ]
1315
1315
  }
@@ -1357,11 +1357,108 @@ var cp_amm_default = {
1357
1357
  }
1358
1358
  ],
1359
1359
  args: [
1360
+ {
1361
+ name: "index",
1362
+ type: "u64"
1363
+ },
1360
1364
  {
1361
1365
  name: "config_parameters",
1362
1366
  type: {
1363
1367
  defined: {
1364
- name: "ConfigParameters"
1368
+ name: "StaticConfigParameters"
1369
+ }
1370
+ }
1371
+ }
1372
+ ]
1373
+ },
1374
+ {
1375
+ name: "create_dynamic_config",
1376
+ discriminator: [
1377
+ 81,
1378
+ 251,
1379
+ 122,
1380
+ 78,
1381
+ 66,
1382
+ 57,
1383
+ 208,
1384
+ 82
1385
+ ],
1386
+ accounts: [
1387
+ {
1388
+ name: "config",
1389
+ writable: true,
1390
+ pda: {
1391
+ seeds: [
1392
+ {
1393
+ kind: "const",
1394
+ value: [
1395
+ 99,
1396
+ 111,
1397
+ 110,
1398
+ 102,
1399
+ 105,
1400
+ 103
1401
+ ]
1402
+ },
1403
+ {
1404
+ kind: "arg",
1405
+ path: "index"
1406
+ }
1407
+ ]
1408
+ }
1409
+ },
1410
+ {
1411
+ name: "admin",
1412
+ writable: true,
1413
+ signer: true
1414
+ },
1415
+ {
1416
+ name: "system_program",
1417
+ address: "11111111111111111111111111111111"
1418
+ },
1419
+ {
1420
+ name: "event_authority",
1421
+ pda: {
1422
+ seeds: [
1423
+ {
1424
+ kind: "const",
1425
+ value: [
1426
+ 95,
1427
+ 95,
1428
+ 101,
1429
+ 118,
1430
+ 101,
1431
+ 110,
1432
+ 116,
1433
+ 95,
1434
+ 97,
1435
+ 117,
1436
+ 116,
1437
+ 104,
1438
+ 111,
1439
+ 114,
1440
+ 105,
1441
+ 116,
1442
+ 121
1443
+ ]
1444
+ }
1445
+ ]
1446
+ }
1447
+ },
1448
+ {
1449
+ name: "program"
1450
+ }
1451
+ ],
1452
+ args: [
1453
+ {
1454
+ name: "index",
1455
+ type: "u64"
1456
+ },
1457
+ {
1458
+ name: "config_parameters",
1459
+ type: {
1460
+ defined: {
1461
+ name: "DynamicConfigParameters"
1365
1462
  }
1366
1463
  }
1367
1464
  }
@@ -2306,6 +2403,312 @@ var cp_amm_default = {
2306
2403
  }
2307
2404
  ]
2308
2405
  },
2406
+ {
2407
+ name: "initialize_pool_with_dynamic_config",
2408
+ discriminator: [
2409
+ 149,
2410
+ 82,
2411
+ 72,
2412
+ 197,
2413
+ 253,
2414
+ 252,
2415
+ 68,
2416
+ 15
2417
+ ],
2418
+ accounts: [
2419
+ {
2420
+ name: "creator"
2421
+ },
2422
+ {
2423
+ name: "position_nft_mint",
2424
+ docs: [
2425
+ "position_nft_mint"
2426
+ ],
2427
+ writable: true,
2428
+ signer: true
2429
+ },
2430
+ {
2431
+ name: "position_nft_account",
2432
+ docs: [
2433
+ "position nft account"
2434
+ ],
2435
+ writable: true,
2436
+ pda: {
2437
+ seeds: [
2438
+ {
2439
+ kind: "const",
2440
+ value: [
2441
+ 112,
2442
+ 111,
2443
+ 115,
2444
+ 105,
2445
+ 116,
2446
+ 105,
2447
+ 111,
2448
+ 110,
2449
+ 95,
2450
+ 110,
2451
+ 102,
2452
+ 116,
2453
+ 95,
2454
+ 97,
2455
+ 99,
2456
+ 99,
2457
+ 111,
2458
+ 117,
2459
+ 110,
2460
+ 116
2461
+ ]
2462
+ },
2463
+ {
2464
+ kind: "account",
2465
+ path: "position_nft_mint"
2466
+ }
2467
+ ]
2468
+ }
2469
+ },
2470
+ {
2471
+ name: "payer",
2472
+ docs: [
2473
+ "Address paying to create the pool. Can be anyone"
2474
+ ],
2475
+ writable: true,
2476
+ signer: true
2477
+ },
2478
+ {
2479
+ name: "pool_creator_authority",
2480
+ signer: true,
2481
+ relations: [
2482
+ "config"
2483
+ ]
2484
+ },
2485
+ {
2486
+ name: "config",
2487
+ docs: [
2488
+ "Which config the pool belongs to."
2489
+ ]
2490
+ },
2491
+ {
2492
+ name: "pool_authority",
2493
+ pda: {
2494
+ seeds: [
2495
+ {
2496
+ kind: "const",
2497
+ value: [
2498
+ 112,
2499
+ 111,
2500
+ 111,
2501
+ 108,
2502
+ 95,
2503
+ 97,
2504
+ 117,
2505
+ 116,
2506
+ 104,
2507
+ 111,
2508
+ 114,
2509
+ 105,
2510
+ 116,
2511
+ 121
2512
+ ]
2513
+ }
2514
+ ]
2515
+ }
2516
+ },
2517
+ {
2518
+ name: "pool",
2519
+ docs: [
2520
+ "Initialize an account to store the pool state"
2521
+ ],
2522
+ writable: true
2523
+ },
2524
+ {
2525
+ name: "position",
2526
+ writable: true,
2527
+ pda: {
2528
+ seeds: [
2529
+ {
2530
+ kind: "const",
2531
+ value: [
2532
+ 112,
2533
+ 111,
2534
+ 115,
2535
+ 105,
2536
+ 116,
2537
+ 105,
2538
+ 111,
2539
+ 110
2540
+ ]
2541
+ },
2542
+ {
2543
+ kind: "account",
2544
+ path: "position_nft_mint"
2545
+ }
2546
+ ]
2547
+ }
2548
+ },
2549
+ {
2550
+ name: "token_a_mint",
2551
+ docs: [
2552
+ "Token a mint"
2553
+ ]
2554
+ },
2555
+ {
2556
+ name: "token_b_mint",
2557
+ docs: [
2558
+ "Token b mint"
2559
+ ]
2560
+ },
2561
+ {
2562
+ name: "token_a_vault",
2563
+ docs: [
2564
+ "Token a vault for the pool"
2565
+ ],
2566
+ writable: true,
2567
+ pda: {
2568
+ seeds: [
2569
+ {
2570
+ kind: "const",
2571
+ value: [
2572
+ 116,
2573
+ 111,
2574
+ 107,
2575
+ 101,
2576
+ 110,
2577
+ 95,
2578
+ 118,
2579
+ 97,
2580
+ 117,
2581
+ 108,
2582
+ 116
2583
+ ]
2584
+ },
2585
+ {
2586
+ kind: "account",
2587
+ path: "token_a_mint"
2588
+ },
2589
+ {
2590
+ kind: "account",
2591
+ path: "pool"
2592
+ }
2593
+ ]
2594
+ }
2595
+ },
2596
+ {
2597
+ name: "token_b_vault",
2598
+ docs: [
2599
+ "Token b vault for the pool"
2600
+ ],
2601
+ writable: true,
2602
+ pda: {
2603
+ seeds: [
2604
+ {
2605
+ kind: "const",
2606
+ value: [
2607
+ 116,
2608
+ 111,
2609
+ 107,
2610
+ 101,
2611
+ 110,
2612
+ 95,
2613
+ 118,
2614
+ 97,
2615
+ 117,
2616
+ 108,
2617
+ 116
2618
+ ]
2619
+ },
2620
+ {
2621
+ kind: "account",
2622
+ path: "token_b_mint"
2623
+ },
2624
+ {
2625
+ kind: "account",
2626
+ path: "pool"
2627
+ }
2628
+ ]
2629
+ }
2630
+ },
2631
+ {
2632
+ name: "payer_token_a",
2633
+ docs: [
2634
+ "payer token a account"
2635
+ ],
2636
+ writable: true
2637
+ },
2638
+ {
2639
+ name: "payer_token_b",
2640
+ docs: [
2641
+ "creator token b account"
2642
+ ],
2643
+ writable: true
2644
+ },
2645
+ {
2646
+ name: "token_a_program",
2647
+ docs: [
2648
+ "Program to create mint account and mint tokens"
2649
+ ]
2650
+ },
2651
+ {
2652
+ name: "token_b_program",
2653
+ docs: [
2654
+ "Program to create mint account and mint tokens"
2655
+ ]
2656
+ },
2657
+ {
2658
+ name: "token_2022_program",
2659
+ docs: [
2660
+ "Program to create NFT mint/token account and transfer for token22 account"
2661
+ ],
2662
+ address: "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"
2663
+ },
2664
+ {
2665
+ name: "system_program",
2666
+ address: "11111111111111111111111111111111"
2667
+ },
2668
+ {
2669
+ name: "event_authority",
2670
+ pda: {
2671
+ seeds: [
2672
+ {
2673
+ kind: "const",
2674
+ value: [
2675
+ 95,
2676
+ 95,
2677
+ 101,
2678
+ 118,
2679
+ 101,
2680
+ 110,
2681
+ 116,
2682
+ 95,
2683
+ 97,
2684
+ 117,
2685
+ 116,
2686
+ 104,
2687
+ 111,
2688
+ 114,
2689
+ 105,
2690
+ 116,
2691
+ 121
2692
+ ]
2693
+ }
2694
+ ]
2695
+ }
2696
+ },
2697
+ {
2698
+ name: "program"
2699
+ }
2700
+ ],
2701
+ args: [
2702
+ {
2703
+ name: "params",
2704
+ type: {
2705
+ defined: {
2706
+ name: "InitializeCustomizablePoolParameters"
2707
+ }
2708
+ }
2709
+ }
2710
+ ]
2711
+ },
2309
2712
  {
2310
2713
  name: "initialize_reward",
2311
2714
  discriminator: [
@@ -3660,6 +4063,19 @@ var cp_amm_default = {
3660
4063
  54
3661
4064
  ]
3662
4065
  },
4066
+ {
4067
+ name: "EvtCreateDynamicConfig",
4068
+ discriminator: [
4069
+ 231,
4070
+ 197,
4071
+ 13,
4072
+ 164,
4073
+ 248,
4074
+ 213,
4075
+ 133,
4076
+ 152
4077
+ ]
4078
+ },
3663
4079
  {
3664
4080
  name: "EvtCreatePosition",
3665
4081
  discriminator: [
@@ -4030,6 +4446,16 @@ var cp_amm_default = {
4030
4446
  code: 6039,
4031
4447
  name: "PositionIsNotEmpty",
4032
4448
  msg: "Position is not empty"
4449
+ },
4450
+ {
4451
+ code: 6040,
4452
+ name: "InvalidPoolCreatorAuthority",
4453
+ msg: "Invalid pool creator authority"
4454
+ },
4455
+ {
4456
+ code: 6041,
4457
+ name: "InvalidConfigType",
4458
+ msg: "Invalid config type"
4033
4459
  }
4034
4460
  ],
4035
4461
  types: [
@@ -4258,6 +4684,13 @@ var cp_amm_default = {
4258
4684
  ],
4259
4685
  type: "u8"
4260
4686
  },
4687
+ {
4688
+ name: "config_type",
4689
+ docs: [
4690
+ "Config type mode, 0 for static, 1 for dynamic"
4691
+ ],
4692
+ type: "u8"
4693
+ },
4261
4694
  {
4262
4695
  name: "_padding_0",
4263
4696
  docs: [
@@ -4266,7 +4699,7 @@ var cp_amm_default = {
4266
4699
  type: {
4267
4700
  array: [
4268
4701
  "u8",
4269
- 6
4702
+ 5
4270
4703
  ]
4271
4704
  }
4272
4705
  },
@@ -4308,45 +4741,13 @@ var cp_amm_default = {
4308
4741
  }
4309
4742
  },
4310
4743
  {
4311
- name: "ConfigParameters",
4744
+ name: "DynamicConfigParameters",
4312
4745
  type: {
4313
4746
  kind: "struct",
4314
- fields: [
4315
- {
4316
- name: "pool_fees",
4317
- type: {
4318
- defined: {
4319
- name: "PoolFeeParameters"
4320
- }
4321
- }
4322
- },
4323
- {
4324
- name: "sqrt_min_price",
4325
- type: "u128"
4326
- },
4327
- {
4328
- name: "sqrt_max_price",
4329
- type: "u128"
4330
- },
4331
- {
4332
- name: "vault_config_key",
4333
- type: "pubkey"
4334
- },
4747
+ fields: [
4335
4748
  {
4336
4749
  name: "pool_creator_authority",
4337
4750
  type: "pubkey"
4338
- },
4339
- {
4340
- name: "activation_type",
4341
- type: "u8"
4342
- },
4343
- {
4344
- name: "collect_fee_mode",
4345
- type: "u8"
4346
- },
4347
- {
4348
- name: "index",
4349
- type: "u64"
4350
4751
  }
4351
4752
  ]
4352
4753
  }
@@ -4748,7 +5149,7 @@ var cp_amm_default = {
4748
5149
  {
4749
5150
  name: "EvtCreateConfig",
4750
5151
  docs: [
4751
- "Create config"
5152
+ "Create static config"
4752
5153
  ],
4753
5154
  type: {
4754
5155
  kind: "struct",
@@ -4796,6 +5197,29 @@ var cp_amm_default = {
4796
5197
  ]
4797
5198
  }
4798
5199
  },
5200
+ {
5201
+ name: "EvtCreateDynamicConfig",
5202
+ docs: [
5203
+ "Create dynamic config"
5204
+ ],
5205
+ type: {
5206
+ kind: "struct",
5207
+ fields: [
5208
+ {
5209
+ name: "config",
5210
+ type: "pubkey"
5211
+ },
5212
+ {
5213
+ name: "pool_creator_authority",
5214
+ type: "pubkey"
5215
+ },
5216
+ {
5217
+ name: "index",
5218
+ type: "u64"
5219
+ }
5220
+ ]
5221
+ }
5222
+ },
4799
5223
  {
4800
5224
  name: "EvtCreatePosition",
4801
5225
  type: {
@@ -5401,18 +5825,11 @@ var cp_amm_default = {
5401
5825
  type: "u128"
5402
5826
  },
5403
5827
  {
5404
- name: "token_a_reserve",
5405
- docs: [
5406
- "token a reserve"
5407
- ],
5408
- type: "u64"
5409
- },
5410
- {
5411
- name: "token_b_reserve",
5828
+ name: "_padding",
5412
5829
  docs: [
5413
- "token b reserve"
5830
+ "padding, previous reserve amount, be careful to use that field"
5414
5831
  ],
5415
- type: "u64"
5832
+ type: "u128"
5416
5833
  },
5417
5834
  {
5418
5835
  name: "protocol_a_fee",
@@ -6135,6 +6552,46 @@ var cp_amm_default = {
6135
6552
  ]
6136
6553
  }
6137
6554
  },
6555
+ {
6556
+ name: "StaticConfigParameters",
6557
+ type: {
6558
+ kind: "struct",
6559
+ fields: [
6560
+ {
6561
+ name: "pool_fees",
6562
+ type: {
6563
+ defined: {
6564
+ name: "PoolFeeParameters"
6565
+ }
6566
+ }
6567
+ },
6568
+ {
6569
+ name: "sqrt_min_price",
6570
+ type: "u128"
6571
+ },
6572
+ {
6573
+ name: "sqrt_max_price",
6574
+ type: "u128"
6575
+ },
6576
+ {
6577
+ name: "vault_config_key",
6578
+ type: "pubkey"
6579
+ },
6580
+ {
6581
+ name: "pool_creator_authority",
6582
+ type: "pubkey"
6583
+ },
6584
+ {
6585
+ name: "activation_type",
6586
+ type: "u8"
6587
+ },
6588
+ {
6589
+ name: "collect_fee_mode",
6590
+ type: "u8"
6591
+ }
6592
+ ]
6593
+ }
6594
+ },
6138
6595
  {
6139
6596
  name: "SwapParameters",
6140
6597
  type: {
@@ -7278,6 +7735,7 @@ var CpAmm = class {
7278
7735
  });
7279
7736
  this.poolAuthority = derivePoolAuthority();
7280
7737
  }
7738
+ //// ANCHOR: PRIVATE FUNCTIONS //////
7281
7739
  /**
7282
7740
  * Prepares token accounts for a transaction by retrieving or creating associated token accounts.
7283
7741
  * @private
@@ -7618,6 +8076,72 @@ var CpAmm = class {
7618
8076
  };
7619
8077
  });
7620
8078
  }
8079
+ /**
8080
+ * Private helper method to prepare common customizable pool creation logic
8081
+ * @param {PrepareCustomizablePoolParams} params - Common parameters for pool creation
8082
+ * @returns Prepared transaction data including instructions and accounts
8083
+ */
8084
+ prepareCreateCustomizablePoolParams(params) {
8085
+ return __async(this, null, function* () {
8086
+ const {
8087
+ pool,
8088
+ tokenAMint,
8089
+ tokenBMint,
8090
+ tokenAAmount,
8091
+ tokenBAmount,
8092
+ payer,
8093
+ positionNft,
8094
+ tokenAProgram,
8095
+ tokenBProgram
8096
+ } = params;
8097
+ const position = derivePositionAddress(positionNft);
8098
+ const positionNftAccount = derivePositionNftAccount(positionNft);
8099
+ const tokenAVault = deriveTokenVaultAddress(tokenAMint, pool);
8100
+ const tokenBVault = deriveTokenVaultAddress(tokenBMint, pool);
8101
+ const {
8102
+ tokenAAta: payerTokenA,
8103
+ tokenBAta: payerTokenB,
8104
+ instructions: preInstructions
8105
+ } = yield this.prepareTokenAccounts(
8106
+ payer,
8107
+ tokenAMint,
8108
+ tokenBMint,
8109
+ tokenAProgram,
8110
+ tokenBProgram
8111
+ );
8112
+ if (tokenAMint.equals(_spltoken.NATIVE_MINT)) {
8113
+ const wrapSOLIx = wrapSOLInstruction(
8114
+ payer,
8115
+ payerTokenA,
8116
+ BigInt(tokenAAmount.toString())
8117
+ );
8118
+ preInstructions.push(...wrapSOLIx);
8119
+ }
8120
+ if (tokenBMint.equals(_spltoken.NATIVE_MINT)) {
8121
+ const wrapSOLIx = wrapSOLInstruction(
8122
+ payer,
8123
+ payerTokenB,
8124
+ BigInt(tokenBAmount.toString())
8125
+ );
8126
+ preInstructions.push(...wrapSOLIx);
8127
+ }
8128
+ const tokenBadgeAccounts = this.getTokenBadgeAccounts(
8129
+ tokenAMint,
8130
+ tokenBMint
8131
+ );
8132
+ return {
8133
+ position,
8134
+ positionNftAccount,
8135
+ tokenAVault,
8136
+ tokenBVault,
8137
+ payerTokenA,
8138
+ payerTokenB,
8139
+ preInstructions,
8140
+ tokenBadgeAccounts
8141
+ };
8142
+ });
8143
+ }
8144
+ //// ANCHOR: GETTER/FETCHER FUNCTIONS //////
7621
8145
  /**
7622
8146
  * Fetches the Config state of the program.
7623
8147
  * @param config - Public key of the config account.
@@ -7941,13 +8465,11 @@ var CpAmm = class {
7941
8465
  maxSqrtPrice,
7942
8466
  sqrtPrice
7943
8467
  } = params;
7944
- const actualAmountIn = inputTokenInfo ? inAmount.sub(
7945
- calculateTransferFeeIncludedAmount(
7946
- inAmount,
7947
- inputTokenInfo.mint,
7948
- inputTokenInfo.currentEpoch
7949
- ).transferFee
7950
- ) : inAmount;
8468
+ const actualAmountIn = inputTokenInfo ? calculateTransferFeeExcludedAmount(
8469
+ inAmount,
8470
+ inputTokenInfo.mint,
8471
+ inputTokenInfo.currentEpoch
8472
+ ).amount : inAmount;
7951
8473
  const { liquidityDelta, rawAmount } = isTokenA ? {
7952
8474
  liquidityDelta: getLiquidityDeltaFromAmountA(
7953
8475
  actualAmountIn,
@@ -8122,6 +8644,7 @@ var CpAmm = class {
8122
8644
  liquidityDelta
8123
8645
  };
8124
8646
  }
8647
+ //// ANCHOR: MAIN ENDPOINT //////
8125
8648
  /**
8126
8649
  * Builds a transaction to create a permissionless pool.
8127
8650
  * @param params - Parameters for pool creation.
@@ -8235,43 +8758,104 @@ var CpAmm = class {
8235
8758
  tokenBProgram
8236
8759
  } = params;
8237
8760
  const pool = deriveCustomizablePoolAddress(tokenAMint, tokenBMint);
8238
- const position = derivePositionAddress(positionNft);
8239
- const positionNftAccount = derivePositionNftAccount(positionNft);
8240
- const tokenAVault = deriveTokenVaultAddress(tokenAMint, pool);
8241
- const tokenBVault = deriveTokenVaultAddress(tokenBMint, pool);
8242
8761
  const {
8243
- tokenAAta: payerTokenA,
8244
- tokenBAta: payerTokenB,
8245
- instructions: preInstructions
8246
- } = yield this.prepareTokenAccounts(
8762
+ position,
8763
+ positionNftAccount,
8764
+ tokenAVault,
8765
+ tokenBVault,
8766
+ payerTokenA,
8767
+ payerTokenB,
8768
+ preInstructions,
8769
+ tokenBadgeAccounts
8770
+ } = yield this.prepareCreateCustomizablePoolParams({
8771
+ pool,
8772
+ tokenAMint,
8773
+ tokenBMint,
8774
+ tokenAAmount,
8775
+ tokenBAmount: tokenBMint.equals(_spltoken.NATIVE_MINT) ? _bnjs.max.call(void 0, tokenBAmount, new (0, _anchor.BN)(1)) : tokenBAmount,
8776
+ payer,
8777
+ positionNft,
8778
+ tokenAProgram,
8779
+ tokenBProgram
8780
+ });
8781
+ const transaction = yield this._program.methods.initializeCustomizablePool({
8782
+ poolFees,
8783
+ sqrtMinPrice,
8784
+ sqrtMaxPrice,
8785
+ hasAlphaVault,
8786
+ liquidity: liquidityDelta,
8787
+ sqrtPrice: initSqrtPrice,
8788
+ activationType,
8789
+ collectFeeMode,
8790
+ activationPoint
8791
+ }).accountsPartial({
8792
+ creator,
8793
+ positionNftAccount,
8794
+ positionNftMint: positionNft,
8247
8795
  payer,
8796
+ poolAuthority: this.poolAuthority,
8797
+ pool,
8798
+ position,
8799
+ tokenAMint,
8800
+ tokenBMint,
8801
+ tokenAVault,
8802
+ tokenBVault,
8803
+ payerTokenA,
8804
+ payerTokenB,
8805
+ token2022Program: _spltoken.TOKEN_2022_PROGRAM_ID,
8806
+ tokenAProgram,
8807
+ tokenBProgram,
8808
+ systemProgram: _web3js.SystemProgram.programId
8809
+ }).preInstructions(preInstructions).remainingAccounts(tokenBadgeAccounts).transaction();
8810
+ return { tx: transaction, pool, position };
8811
+ });
8812
+ }
8813
+ createCustomPoolWithDynamicConfig(params) {
8814
+ return __async(this, null, function* () {
8815
+ const {
8248
8816
  tokenAMint,
8249
8817
  tokenBMint,
8818
+ tokenAAmount,
8819
+ tokenBAmount,
8820
+ sqrtMinPrice,
8821
+ sqrtMaxPrice,
8822
+ liquidityDelta,
8823
+ initSqrtPrice,
8824
+ payer,
8825
+ config,
8826
+ poolCreatorAuthority,
8827
+ creator,
8828
+ positionNft,
8829
+ poolFees,
8830
+ hasAlphaVault,
8831
+ collectFeeMode,
8832
+ activationPoint,
8833
+ activationType,
8250
8834
  tokenAProgram,
8251
8835
  tokenBProgram
8252
- );
8253
- if (tokenAMint.equals(_spltoken.NATIVE_MINT)) {
8254
- const wrapSOLIx = wrapSOLInstruction(
8255
- payer,
8256
- payerTokenA,
8257
- BigInt(tokenAAmount.toString())
8258
- );
8259
- preInstructions.push(...wrapSOLIx);
8260
- }
8261
- if (tokenBMint.equals(_spltoken.NATIVE_MINT)) {
8262
- const lamports = tokenBAmount.eq(new (0, _anchor.BN)(0)) ? new (0, _anchor.BN)(1) : tokenBAmount;
8263
- const wrapSOLIx = wrapSOLInstruction(
8264
- payer,
8265
- payerTokenB,
8266
- BigInt(lamports.toString())
8267
- );
8268
- preInstructions.push(...wrapSOLIx);
8269
- }
8270
- const tokenBadgeAccounts = this.getTokenBadgeAccounts(
8836
+ } = params;
8837
+ const pool = derivePoolAddress(config, tokenAMint, tokenBMint);
8838
+ const {
8839
+ position,
8840
+ positionNftAccount,
8841
+ tokenAVault,
8842
+ tokenBVault,
8843
+ payerTokenA,
8844
+ payerTokenB,
8845
+ preInstructions,
8846
+ tokenBadgeAccounts
8847
+ } = yield this.prepareCreateCustomizablePoolParams({
8848
+ pool,
8271
8849
  tokenAMint,
8272
- tokenBMint
8273
- );
8274
- const transaction = yield this._program.methods.initializeCustomizablePool({
8850
+ tokenBMint,
8851
+ tokenAAmount,
8852
+ tokenBAmount,
8853
+ payer,
8854
+ positionNft,
8855
+ tokenAProgram,
8856
+ tokenBProgram
8857
+ });
8858
+ const transaction = yield this._program.methods.initializePoolWithDynamicConfig({
8275
8859
  poolFees,
8276
8860
  sqrtMinPrice,
8277
8861
  sqrtMaxPrice,
@@ -8289,6 +8873,8 @@ var CpAmm = class {
8289
8873
  poolAuthority: this.poolAuthority,
8290
8874
  pool,
8291
8875
  position,
8876
+ poolCreatorAuthority,
8877
+ config,
8292
8878
  tokenAMint,
8293
8879
  tokenBMint,
8294
8880
  tokenAVault,