@meteora-ag/cp-amm-sdk 1.0.2 → 1.0.3
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 +1201 -322
- package/dist/index.d.ts +1201 -322
- package/dist/index.js +1009 -332
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1010 -333
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
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.
|
|
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
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
594
|
+
48,
|
|
595
|
+
9,
|
|
596
|
+
89,
|
|
597
|
+
123,
|
|
598
|
+
106,
|
|
599
|
+
114,
|
|
600
|
+
131,
|
|
601
|
+
251,
|
|
602
|
+
50,
|
|
601
603
|
173,
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
161,
|
|
611
|
-
33,
|
|
604
|
+
254,
|
|
605
|
+
250,
|
|
606
|
+
10,
|
|
607
|
+
80,
|
|
608
|
+
160,
|
|
609
|
+
84,
|
|
610
|
+
143,
|
|
611
|
+
100,
|
|
612
612
|
81,
|
|
613
|
-
|
|
613
|
+
249,
|
|
614
|
+
134,
|
|
615
|
+
112,
|
|
616
|
+
30,
|
|
617
|
+
213,
|
|
618
|
+
50,
|
|
614
619
|
166,
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
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
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
687
|
+
48,
|
|
688
|
+
9,
|
|
689
|
+
89,
|
|
690
|
+
123,
|
|
691
|
+
106,
|
|
692
|
+
114,
|
|
693
|
+
131,
|
|
694
|
+
251,
|
|
695
|
+
50,
|
|
694
696
|
173,
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
161,
|
|
704
|
-
33,
|
|
697
|
+
254,
|
|
698
|
+
250,
|
|
699
|
+
10,
|
|
700
|
+
80,
|
|
701
|
+
160,
|
|
702
|
+
84,
|
|
703
|
+
143,
|
|
704
|
+
100,
|
|
705
705
|
81,
|
|
706
|
-
|
|
706
|
+
249,
|
|
707
|
+
134,
|
|
708
|
+
112,
|
|
709
|
+
30,
|
|
710
|
+
213,
|
|
711
|
+
50,
|
|
707
712
|
166,
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
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,100 @@ var cp_amm_default = {
|
|
|
1309
1309
|
},
|
|
1310
1310
|
{
|
|
1311
1311
|
kind: "arg",
|
|
1312
|
-
path: "
|
|
1312
|
+
path: "index"
|
|
1313
|
+
}
|
|
1314
|
+
]
|
|
1315
|
+
}
|
|
1316
|
+
},
|
|
1317
|
+
{
|
|
1318
|
+
name: "admin",
|
|
1319
|
+
writable: true,
|
|
1320
|
+
signer: true
|
|
1321
|
+
},
|
|
1322
|
+
{
|
|
1323
|
+
name: "system_program",
|
|
1324
|
+
address: "11111111111111111111111111111111"
|
|
1325
|
+
},
|
|
1326
|
+
{
|
|
1327
|
+
name: "event_authority",
|
|
1328
|
+
pda: {
|
|
1329
|
+
seeds: [
|
|
1330
|
+
{
|
|
1331
|
+
kind: "const",
|
|
1332
|
+
value: [
|
|
1333
|
+
95,
|
|
1334
|
+
95,
|
|
1335
|
+
101,
|
|
1336
|
+
118,
|
|
1337
|
+
101,
|
|
1338
|
+
110,
|
|
1339
|
+
116,
|
|
1340
|
+
95,
|
|
1341
|
+
97,
|
|
1342
|
+
117,
|
|
1343
|
+
116,
|
|
1344
|
+
104,
|
|
1345
|
+
111,
|
|
1346
|
+
114,
|
|
1347
|
+
105,
|
|
1348
|
+
116,
|
|
1349
|
+
121
|
|
1350
|
+
]
|
|
1351
|
+
}
|
|
1352
|
+
]
|
|
1353
|
+
}
|
|
1354
|
+
},
|
|
1355
|
+
{
|
|
1356
|
+
name: "program"
|
|
1357
|
+
}
|
|
1358
|
+
],
|
|
1359
|
+
args: [
|
|
1360
|
+
{
|
|
1361
|
+
name: "index",
|
|
1362
|
+
type: "u64"
|
|
1363
|
+
},
|
|
1364
|
+
{
|
|
1365
|
+
name: "config_parameters",
|
|
1366
|
+
type: {
|
|
1367
|
+
defined: {
|
|
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"
|
|
1313
1406
|
}
|
|
1314
1407
|
]
|
|
1315
1408
|
}
|
|
@@ -1357,11 +1450,15 @@ var cp_amm_default = {
|
|
|
1357
1450
|
}
|
|
1358
1451
|
],
|
|
1359
1452
|
args: [
|
|
1453
|
+
{
|
|
1454
|
+
name: "index",
|
|
1455
|
+
type: "u64"
|
|
1456
|
+
},
|
|
1360
1457
|
{
|
|
1361
1458
|
name: "config_parameters",
|
|
1362
1459
|
type: {
|
|
1363
1460
|
defined: {
|
|
1364
|
-
name: "
|
|
1461
|
+
name: "DynamicConfigParameters"
|
|
1365
1462
|
}
|
|
1366
1463
|
}
|
|
1367
1464
|
}
|
|
@@ -2307,18 +2404,90 @@ var cp_amm_default = {
|
|
|
2307
2404
|
]
|
|
2308
2405
|
},
|
|
2309
2406
|
{
|
|
2310
|
-
name: "
|
|
2407
|
+
name: "initialize_pool_with_dynamic_config",
|
|
2311
2408
|
discriminator: [
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2409
|
+
149,
|
|
2410
|
+
82,
|
|
2411
|
+
72,
|
|
2412
|
+
197,
|
|
2413
|
+
253,
|
|
2414
|
+
252,
|
|
2415
|
+
68,
|
|
2416
|
+
15
|
|
2320
2417
|
],
|
|
2321
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
|
+
},
|
|
2322
2491
|
{
|
|
2323
2492
|
name: "pool_authority",
|
|
2324
2493
|
pda: {
|
|
@@ -2347,67 +2516,301 @@ var cp_amm_default = {
|
|
|
2347
2516
|
},
|
|
2348
2517
|
{
|
|
2349
2518
|
name: "pool",
|
|
2519
|
+
docs: [
|
|
2520
|
+
"Initialize an account to store the pool state"
|
|
2521
|
+
],
|
|
2350
2522
|
writable: true
|
|
2351
2523
|
},
|
|
2352
2524
|
{
|
|
2353
|
-
name: "
|
|
2525
|
+
name: "position",
|
|
2354
2526
|
writable: true,
|
|
2355
2527
|
pda: {
|
|
2356
2528
|
seeds: [
|
|
2357
2529
|
{
|
|
2358
2530
|
kind: "const",
|
|
2359
2531
|
value: [
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
97,
|
|
2369
|
-
117,
|
|
2370
|
-
108,
|
|
2371
|
-
116
|
|
2532
|
+
112,
|
|
2533
|
+
111,
|
|
2534
|
+
115,
|
|
2535
|
+
105,
|
|
2536
|
+
116,
|
|
2537
|
+
105,
|
|
2538
|
+
111,
|
|
2539
|
+
110
|
|
2372
2540
|
]
|
|
2373
2541
|
},
|
|
2374
2542
|
{
|
|
2375
2543
|
kind: "account",
|
|
2376
|
-
path: "
|
|
2377
|
-
},
|
|
2378
|
-
{
|
|
2379
|
-
kind: "arg",
|
|
2380
|
-
path: "reward_index"
|
|
2544
|
+
path: "position_nft_mint"
|
|
2381
2545
|
}
|
|
2382
2546
|
]
|
|
2383
2547
|
}
|
|
2384
2548
|
},
|
|
2385
2549
|
{
|
|
2386
|
-
name: "
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
writable: true,
|
|
2391
|
-
signer: true
|
|
2392
|
-
},
|
|
2393
|
-
{
|
|
2394
|
-
name: "token_program"
|
|
2550
|
+
name: "token_a_mint",
|
|
2551
|
+
docs: [
|
|
2552
|
+
"Token a mint"
|
|
2553
|
+
]
|
|
2395
2554
|
},
|
|
2396
2555
|
{
|
|
2397
|
-
name: "
|
|
2398
|
-
|
|
2556
|
+
name: "token_b_mint",
|
|
2557
|
+
docs: [
|
|
2558
|
+
"Token b mint"
|
|
2559
|
+
]
|
|
2399
2560
|
},
|
|
2400
2561
|
{
|
|
2401
|
-
name: "
|
|
2562
|
+
name: "token_a_vault",
|
|
2563
|
+
docs: [
|
|
2564
|
+
"Token a vault for the pool"
|
|
2565
|
+
],
|
|
2566
|
+
writable: true,
|
|
2402
2567
|
pda: {
|
|
2403
2568
|
seeds: [
|
|
2404
2569
|
{
|
|
2405
2570
|
kind: "const",
|
|
2406
2571
|
value: [
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
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
|
+
},
|
|
2712
|
+
{
|
|
2713
|
+
name: "initialize_reward",
|
|
2714
|
+
discriminator: [
|
|
2715
|
+
95,
|
|
2716
|
+
135,
|
|
2717
|
+
192,
|
|
2718
|
+
196,
|
|
2719
|
+
242,
|
|
2720
|
+
129,
|
|
2721
|
+
230,
|
|
2722
|
+
68
|
|
2723
|
+
],
|
|
2724
|
+
accounts: [
|
|
2725
|
+
{
|
|
2726
|
+
name: "pool_authority",
|
|
2727
|
+
pda: {
|
|
2728
|
+
seeds: [
|
|
2729
|
+
{
|
|
2730
|
+
kind: "const",
|
|
2731
|
+
value: [
|
|
2732
|
+
112,
|
|
2733
|
+
111,
|
|
2734
|
+
111,
|
|
2735
|
+
108,
|
|
2736
|
+
95,
|
|
2737
|
+
97,
|
|
2738
|
+
117,
|
|
2739
|
+
116,
|
|
2740
|
+
104,
|
|
2741
|
+
111,
|
|
2742
|
+
114,
|
|
2743
|
+
105,
|
|
2744
|
+
116,
|
|
2745
|
+
121
|
|
2746
|
+
]
|
|
2747
|
+
}
|
|
2748
|
+
]
|
|
2749
|
+
}
|
|
2750
|
+
},
|
|
2751
|
+
{
|
|
2752
|
+
name: "pool",
|
|
2753
|
+
writable: true
|
|
2754
|
+
},
|
|
2755
|
+
{
|
|
2756
|
+
name: "reward_vault",
|
|
2757
|
+
writable: true,
|
|
2758
|
+
pda: {
|
|
2759
|
+
seeds: [
|
|
2760
|
+
{
|
|
2761
|
+
kind: "const",
|
|
2762
|
+
value: [
|
|
2763
|
+
114,
|
|
2764
|
+
101,
|
|
2765
|
+
119,
|
|
2766
|
+
97,
|
|
2767
|
+
114,
|
|
2768
|
+
100,
|
|
2769
|
+
95,
|
|
2770
|
+
118,
|
|
2771
|
+
97,
|
|
2772
|
+
117,
|
|
2773
|
+
108,
|
|
2774
|
+
116
|
|
2775
|
+
]
|
|
2776
|
+
},
|
|
2777
|
+
{
|
|
2778
|
+
kind: "account",
|
|
2779
|
+
path: "pool"
|
|
2780
|
+
},
|
|
2781
|
+
{
|
|
2782
|
+
kind: "arg",
|
|
2783
|
+
path: "reward_index"
|
|
2784
|
+
}
|
|
2785
|
+
]
|
|
2786
|
+
}
|
|
2787
|
+
},
|
|
2788
|
+
{
|
|
2789
|
+
name: "reward_mint"
|
|
2790
|
+
},
|
|
2791
|
+
{
|
|
2792
|
+
name: "admin",
|
|
2793
|
+
writable: true,
|
|
2794
|
+
signer: true
|
|
2795
|
+
},
|
|
2796
|
+
{
|
|
2797
|
+
name: "token_program"
|
|
2798
|
+
},
|
|
2799
|
+
{
|
|
2800
|
+
name: "system_program",
|
|
2801
|
+
address: "11111111111111111111111111111111"
|
|
2802
|
+
},
|
|
2803
|
+
{
|
|
2804
|
+
name: "event_authority",
|
|
2805
|
+
pda: {
|
|
2806
|
+
seeds: [
|
|
2807
|
+
{
|
|
2808
|
+
kind: "const",
|
|
2809
|
+
value: [
|
|
2810
|
+
95,
|
|
2811
|
+
95,
|
|
2812
|
+
101,
|
|
2813
|
+
118,
|
|
2411
2814
|
101,
|
|
2412
2815
|
110,
|
|
2413
2816
|
116,
|
|
@@ -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: [
|
|
@@ -4259,14 +4685,21 @@ var cp_amm_default = {
|
|
|
4259
4685
|
type: "u8"
|
|
4260
4686
|
},
|
|
4261
4687
|
{
|
|
4262
|
-
name: "
|
|
4688
|
+
name: "config_type",
|
|
4263
4689
|
docs: [
|
|
4264
|
-
"
|
|
4690
|
+
"Config type mode, 0 for static, 1 for dynamic"
|
|
4265
4691
|
],
|
|
4266
|
-
type:
|
|
4692
|
+
type: "u8"
|
|
4693
|
+
},
|
|
4694
|
+
{
|
|
4695
|
+
name: "_padding_0",
|
|
4696
|
+
docs: [
|
|
4697
|
+
"padding 0"
|
|
4698
|
+
],
|
|
4699
|
+
type: {
|
|
4267
4700
|
array: [
|
|
4268
4701
|
"u8",
|
|
4269
|
-
|
|
4702
|
+
5
|
|
4270
4703
|
]
|
|
4271
4704
|
}
|
|
4272
4705
|
},
|
|
@@ -4308,45 +4741,13 @@ var cp_amm_default = {
|
|
|
4308
4741
|
}
|
|
4309
4742
|
},
|
|
4310
4743
|
{
|
|
4311
|
-
name: "
|
|
4744
|
+
name: "DynamicConfigParameters",
|
|
4312
4745
|
type: {
|
|
4313
4746
|
kind: "struct",
|
|
4314
4747
|
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
|
-
},
|
|
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: "
|
|
5405
|
-
docs: [
|
|
5406
|
-
"token a reserve"
|
|
5407
|
-
],
|
|
5408
|
-
type: "u64"
|
|
5409
|
-
},
|
|
5410
|
-
{
|
|
5411
|
-
name: "token_b_reserve",
|
|
5828
|
+
name: "_padding",
|
|
5412
5829
|
docs: [
|
|
5413
|
-
"
|
|
5830
|
+
"padding, previous reserve amount, be careful to use that field"
|
|
5414
5831
|
],
|
|
5415
|
-
type: "
|
|
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: {
|
|
@@ -6570,7 +7027,7 @@ var wrapSOLInstruction = (from, to, amount) => {
|
|
|
6570
7027
|
})
|
|
6571
7028
|
];
|
|
6572
7029
|
};
|
|
6573
|
-
var unwrapSOLInstruction = (
|
|
7030
|
+
var unwrapSOLInstruction = (_0, ..._1) => __async(void 0, [_0, ..._1], function* (owner, receiver = owner, allowOwnerOffCurve = true) {
|
|
6574
7031
|
const wSolATAAccount = getAssociatedTokenAddressSync(
|
|
6575
7032
|
NATIVE_MINT,
|
|
6576
7033
|
owner,
|
|
@@ -6579,7 +7036,7 @@ var unwrapSOLInstruction = (owner, allowOwnerOffCurve = true) => __async(void 0,
|
|
|
6579
7036
|
if (wSolATAAccount) {
|
|
6580
7037
|
const closedWrappedSolInstruction = createCloseAccountInstruction(
|
|
6581
7038
|
wSolATAAccount,
|
|
6582
|
-
|
|
7039
|
+
receiver,
|
|
6583
7040
|
owner,
|
|
6584
7041
|
[],
|
|
6585
7042
|
TOKEN_PROGRAM_ID
|
|
@@ -7270,7 +7727,7 @@ function getAvailableVestingLiquidity(vestingData, currentPoint) {
|
|
|
7270
7727
|
}
|
|
7271
7728
|
|
|
7272
7729
|
// src/CpAmm.ts
|
|
7273
|
-
import { min as min2 } from "bn.js";
|
|
7730
|
+
import { min as min2, max } from "bn.js";
|
|
7274
7731
|
var CpAmm = class {
|
|
7275
7732
|
constructor(connection) {
|
|
7276
7733
|
this._program = new Program(cp_amm_default, {
|
|
@@ -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
|
|
@@ -7289,8 +7747,17 @@ var CpAmm = class {
|
|
|
7289
7747
|
* @returns {Promise<{tokenAAta: PublicKey, tokenBAta: PublicKey, instructions: TransactionInstruction[]}>}
|
|
7290
7748
|
* The token account addresses and any instructions needed to create them
|
|
7291
7749
|
*/
|
|
7292
|
-
prepareTokenAccounts(
|
|
7750
|
+
prepareTokenAccounts(params) {
|
|
7293
7751
|
return __async(this, null, function* () {
|
|
7752
|
+
const {
|
|
7753
|
+
payer,
|
|
7754
|
+
tokenAOwner,
|
|
7755
|
+
tokenBOwner,
|
|
7756
|
+
tokenAMint,
|
|
7757
|
+
tokenBMint,
|
|
7758
|
+
tokenAProgram,
|
|
7759
|
+
tokenBProgram
|
|
7760
|
+
} = params;
|
|
7294
7761
|
const instructions = [];
|
|
7295
7762
|
const [
|
|
7296
7763
|
{ ataPubkey: tokenAAta, ix: createInputTokenAccountIx },
|
|
@@ -7299,16 +7766,16 @@ var CpAmm = class {
|
|
|
7299
7766
|
getOrCreateATAInstruction(
|
|
7300
7767
|
this._program.provider.connection,
|
|
7301
7768
|
tokenAMint,
|
|
7302
|
-
|
|
7303
|
-
|
|
7769
|
+
tokenAOwner,
|
|
7770
|
+
payer,
|
|
7304
7771
|
true,
|
|
7305
7772
|
tokenAProgram
|
|
7306
7773
|
),
|
|
7307
7774
|
getOrCreateATAInstruction(
|
|
7308
7775
|
this._program.provider.connection,
|
|
7309
7776
|
tokenBMint,
|
|
7310
|
-
|
|
7311
|
-
|
|
7777
|
+
tokenBOwner,
|
|
7778
|
+
payer,
|
|
7312
7779
|
true,
|
|
7313
7780
|
tokenBProgram
|
|
7314
7781
|
)
|
|
@@ -7618,6 +8085,127 @@ var CpAmm = class {
|
|
|
7618
8085
|
};
|
|
7619
8086
|
});
|
|
7620
8087
|
}
|
|
8088
|
+
/**
|
|
8089
|
+
* Private helper method to prepare common customizable pool creation logic
|
|
8090
|
+
* @param {PrepareCustomizablePoolParams} params - Common parameters for pool creation
|
|
8091
|
+
* @returns Prepared transaction data including instructions and accounts
|
|
8092
|
+
*/
|
|
8093
|
+
prepareCreatePoolParams(params) {
|
|
8094
|
+
return __async(this, null, function* () {
|
|
8095
|
+
const {
|
|
8096
|
+
pool,
|
|
8097
|
+
tokenAMint,
|
|
8098
|
+
tokenBMint,
|
|
8099
|
+
tokenAAmount,
|
|
8100
|
+
tokenBAmount,
|
|
8101
|
+
payer,
|
|
8102
|
+
positionNft,
|
|
8103
|
+
tokenAProgram,
|
|
8104
|
+
tokenBProgram
|
|
8105
|
+
} = params;
|
|
8106
|
+
const position = derivePositionAddress(positionNft);
|
|
8107
|
+
const positionNftAccount = derivePositionNftAccount(positionNft);
|
|
8108
|
+
const tokenAVault = deriveTokenVaultAddress(tokenAMint, pool);
|
|
8109
|
+
const tokenBVault = deriveTokenVaultAddress(tokenBMint, pool);
|
|
8110
|
+
const {
|
|
8111
|
+
tokenAAta: payerTokenA,
|
|
8112
|
+
tokenBAta: payerTokenB,
|
|
8113
|
+
instructions: preInstructions
|
|
8114
|
+
} = yield this.prepareTokenAccounts({
|
|
8115
|
+
payer,
|
|
8116
|
+
tokenAOwner: payer,
|
|
8117
|
+
tokenBOwner: payer,
|
|
8118
|
+
tokenAMint,
|
|
8119
|
+
tokenBMint,
|
|
8120
|
+
tokenAProgram,
|
|
8121
|
+
tokenBProgram
|
|
8122
|
+
});
|
|
8123
|
+
if (tokenAMint.equals(NATIVE_MINT2)) {
|
|
8124
|
+
const wrapSOLIx = wrapSOLInstruction(
|
|
8125
|
+
payer,
|
|
8126
|
+
payerTokenA,
|
|
8127
|
+
BigInt(tokenAAmount.toString())
|
|
8128
|
+
);
|
|
8129
|
+
preInstructions.push(...wrapSOLIx);
|
|
8130
|
+
}
|
|
8131
|
+
if (tokenBMint.equals(NATIVE_MINT2)) {
|
|
8132
|
+
const wrapSOLIx = wrapSOLInstruction(
|
|
8133
|
+
payer,
|
|
8134
|
+
payerTokenB,
|
|
8135
|
+
BigInt(tokenBAmount.toString())
|
|
8136
|
+
);
|
|
8137
|
+
preInstructions.push(...wrapSOLIx);
|
|
8138
|
+
}
|
|
8139
|
+
const tokenBadgeAccounts = this.getTokenBadgeAccounts(
|
|
8140
|
+
tokenAMint,
|
|
8141
|
+
tokenBMint
|
|
8142
|
+
);
|
|
8143
|
+
return {
|
|
8144
|
+
position,
|
|
8145
|
+
positionNftAccount,
|
|
8146
|
+
tokenAVault,
|
|
8147
|
+
tokenBVault,
|
|
8148
|
+
payerTokenA,
|
|
8149
|
+
payerTokenB,
|
|
8150
|
+
preInstructions,
|
|
8151
|
+
tokenBadgeAccounts
|
|
8152
|
+
};
|
|
8153
|
+
});
|
|
8154
|
+
}
|
|
8155
|
+
/**
|
|
8156
|
+
* Sets up token accounts and instructions for fee claim operations.
|
|
8157
|
+
* @private
|
|
8158
|
+
* @param {SetupFeeClaimAccountsParams} params - Parameters for setting up fee claim accounts.
|
|
8159
|
+
* @returns Token accounts and instructions for fee claiming.
|
|
8160
|
+
*/
|
|
8161
|
+
setupFeeClaimAccounts(params) {
|
|
8162
|
+
return __async(this, null, function* () {
|
|
8163
|
+
const {
|
|
8164
|
+
payer,
|
|
8165
|
+
tokenAMint,
|
|
8166
|
+
tokenBMint,
|
|
8167
|
+
tokenAProgram,
|
|
8168
|
+
tokenBProgram,
|
|
8169
|
+
receiver,
|
|
8170
|
+
tempWSolAccount
|
|
8171
|
+
} = params;
|
|
8172
|
+
const tokenAIsSOL = tokenAMint.equals(NATIVE_MINT2);
|
|
8173
|
+
const tokenBIsSOL = tokenBMint.equals(NATIVE_MINT2);
|
|
8174
|
+
const hasSolToken = tokenAIsSOL || tokenBIsSOL;
|
|
8175
|
+
const preInstructions = [];
|
|
8176
|
+
const postInstructions = [];
|
|
8177
|
+
let tokenAAccount;
|
|
8178
|
+
let tokenBAccount;
|
|
8179
|
+
const tokenAOwner = tempWSolAccount && tokenAIsSOL ? tempWSolAccount : receiver;
|
|
8180
|
+
const tokenBOwner = tempWSolAccount && tokenBIsSOL ? tempWSolAccount : receiver;
|
|
8181
|
+
const { tokenAAta, tokenBAta, instructions } = yield this.prepareTokenAccounts({
|
|
8182
|
+
payer,
|
|
8183
|
+
tokenAOwner,
|
|
8184
|
+
tokenBOwner,
|
|
8185
|
+
tokenAMint,
|
|
8186
|
+
tokenBMint,
|
|
8187
|
+
tokenAProgram,
|
|
8188
|
+
tokenBProgram
|
|
8189
|
+
});
|
|
8190
|
+
tokenAAccount = tokenAAta;
|
|
8191
|
+
tokenBAccount = tokenBAta;
|
|
8192
|
+
preInstructions.push(...instructions);
|
|
8193
|
+
if (hasSolToken) {
|
|
8194
|
+
const closeWrappedSOLIx = yield unwrapSOLInstruction(
|
|
8195
|
+
tempWSolAccount != null ? tempWSolAccount : receiver,
|
|
8196
|
+
receiver
|
|
8197
|
+
);
|
|
8198
|
+
closeWrappedSOLIx && postInstructions.push(closeWrappedSOLIx);
|
|
8199
|
+
}
|
|
8200
|
+
return {
|
|
8201
|
+
tokenAAccount,
|
|
8202
|
+
tokenBAccount,
|
|
8203
|
+
preInstructions,
|
|
8204
|
+
postInstructions
|
|
8205
|
+
};
|
|
8206
|
+
});
|
|
8207
|
+
}
|
|
8208
|
+
//// ANCHOR: GETTER/FETCHER FUNCTIONS //////
|
|
7621
8209
|
/**
|
|
7622
8210
|
* Fetches the Config state of the program.
|
|
7623
8211
|
* @param config - Public key of the config account.
|
|
@@ -7941,13 +8529,11 @@ var CpAmm = class {
|
|
|
7941
8529
|
maxSqrtPrice,
|
|
7942
8530
|
sqrtPrice
|
|
7943
8531
|
} = params;
|
|
7944
|
-
const actualAmountIn = inputTokenInfo ?
|
|
7945
|
-
|
|
7946
|
-
|
|
7947
|
-
|
|
7948
|
-
|
|
7949
|
-
).transferFee
|
|
7950
|
-
) : inAmount;
|
|
8532
|
+
const actualAmountIn = inputTokenInfo ? calculateTransferFeeExcludedAmount(
|
|
8533
|
+
inAmount,
|
|
8534
|
+
inputTokenInfo.mint,
|
|
8535
|
+
inputTokenInfo.currentEpoch
|
|
8536
|
+
).amount : inAmount;
|
|
7951
8537
|
const { liquidityDelta, rawAmount } = isTokenA ? {
|
|
7952
8538
|
liquidityDelta: getLiquidityDeltaFromAmountA(
|
|
7953
8539
|
actualAmountIn,
|
|
@@ -8122,6 +8708,7 @@ var CpAmm = class {
|
|
|
8122
8708
|
liquidityDelta
|
|
8123
8709
|
};
|
|
8124
8710
|
}
|
|
8711
|
+
//// ANCHOR: MAIN ENDPOINT //////
|
|
8125
8712
|
/**
|
|
8126
8713
|
* Builds a transaction to create a permissionless pool.
|
|
8127
8714
|
* @param params - Parameters for pool creation.
|
|
@@ -8142,44 +8729,40 @@ var CpAmm = class {
|
|
|
8142
8729
|
tokenAAmount,
|
|
8143
8730
|
tokenBAmount,
|
|
8144
8731
|
tokenAProgram,
|
|
8145
|
-
tokenBProgram
|
|
8732
|
+
tokenBProgram,
|
|
8733
|
+
isLockLiquidity
|
|
8146
8734
|
} = params;
|
|
8147
8735
|
const pool = derivePoolAddress(config, tokenAMint, tokenBMint);
|
|
8148
|
-
const position = derivePositionAddress(positionNft);
|
|
8149
|
-
const positionNftAccount = derivePositionNftAccount(positionNft);
|
|
8150
|
-
const tokenAVault = deriveTokenVaultAddress(tokenAMint, pool);
|
|
8151
|
-
const tokenBVault = deriveTokenVaultAddress(tokenBMint, pool);
|
|
8152
8736
|
const {
|
|
8153
|
-
|
|
8154
|
-
|
|
8155
|
-
|
|
8156
|
-
|
|
8157
|
-
|
|
8737
|
+
position,
|
|
8738
|
+
positionNftAccount,
|
|
8739
|
+
tokenAVault,
|
|
8740
|
+
tokenBVault,
|
|
8741
|
+
payerTokenA,
|
|
8742
|
+
payerTokenB,
|
|
8743
|
+
preInstructions,
|
|
8744
|
+
tokenBadgeAccounts
|
|
8745
|
+
} = yield this.prepareCreatePoolParams({
|
|
8746
|
+
pool,
|
|
8158
8747
|
tokenAMint,
|
|
8159
8748
|
tokenBMint,
|
|
8749
|
+
tokenAAmount,
|
|
8750
|
+
tokenBAmount,
|
|
8751
|
+
payer,
|
|
8752
|
+
positionNft,
|
|
8160
8753
|
tokenAProgram,
|
|
8161
8754
|
tokenBProgram
|
|
8162
|
-
);
|
|
8163
|
-
|
|
8164
|
-
|
|
8165
|
-
|
|
8166
|
-
|
|
8167
|
-
|
|
8168
|
-
|
|
8169
|
-
|
|
8755
|
+
});
|
|
8756
|
+
const postInstruction = [];
|
|
8757
|
+
if (isLockLiquidity) {
|
|
8758
|
+
const permanentLockIx = yield this._program.methods.permanentLockPosition(liquidityDelta).accountsPartial({
|
|
8759
|
+
position,
|
|
8760
|
+
positionNftAccount,
|
|
8761
|
+
pool,
|
|
8762
|
+
owner: creator
|
|
8763
|
+
}).instruction();
|
|
8764
|
+
postInstruction.push(permanentLockIx);
|
|
8170
8765
|
}
|
|
8171
|
-
if (tokenBMint.equals(NATIVE_MINT2)) {
|
|
8172
|
-
const wrapSOLIx = wrapSOLInstruction(
|
|
8173
|
-
payer,
|
|
8174
|
-
payerTokenB,
|
|
8175
|
-
BigInt(tokenBAmount.toString())
|
|
8176
|
-
);
|
|
8177
|
-
preInstructions.push(...wrapSOLIx);
|
|
8178
|
-
}
|
|
8179
|
-
const tokenBadgeAccounts = this.getTokenBadgeAccounts(
|
|
8180
|
-
tokenAMint,
|
|
8181
|
-
tokenBMint
|
|
8182
|
-
);
|
|
8183
8766
|
const tx = yield this._program.methods.initializePool({
|
|
8184
8767
|
liquidity: liquidityDelta,
|
|
8185
8768
|
sqrtPrice: initSqrtPrice,
|
|
@@ -8203,7 +8786,7 @@ var CpAmm = class {
|
|
|
8203
8786
|
tokenAProgram,
|
|
8204
8787
|
tokenBProgram,
|
|
8205
8788
|
systemProgram: SystemProgram2.programId
|
|
8206
|
-
}).preInstructions(preInstructions).remainingAccounts(tokenBadgeAccounts).transaction();
|
|
8789
|
+
}).preInstructions(preInstructions).postInstructions(postInstruction).remainingAccounts(tokenBadgeAccounts).transaction();
|
|
8207
8790
|
return tx;
|
|
8208
8791
|
});
|
|
8209
8792
|
}
|
|
@@ -8232,45 +8815,40 @@ var CpAmm = class {
|
|
|
8232
8815
|
activationPoint,
|
|
8233
8816
|
activationType,
|
|
8234
8817
|
tokenAProgram,
|
|
8235
|
-
tokenBProgram
|
|
8818
|
+
tokenBProgram,
|
|
8819
|
+
isLockLiquidity
|
|
8236
8820
|
} = params;
|
|
8237
8821
|
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
8822
|
const {
|
|
8243
|
-
|
|
8244
|
-
|
|
8245
|
-
|
|
8246
|
-
|
|
8247
|
-
|
|
8823
|
+
position,
|
|
8824
|
+
positionNftAccount,
|
|
8825
|
+
tokenAVault,
|
|
8826
|
+
tokenBVault,
|
|
8827
|
+
payerTokenA,
|
|
8828
|
+
payerTokenB,
|
|
8829
|
+
preInstructions,
|
|
8830
|
+
tokenBadgeAccounts
|
|
8831
|
+
} = yield this.prepareCreatePoolParams({
|
|
8832
|
+
pool,
|
|
8248
8833
|
tokenAMint,
|
|
8249
8834
|
tokenBMint,
|
|
8835
|
+
tokenAAmount,
|
|
8836
|
+
tokenBAmount: tokenBMint.equals(NATIVE_MINT2) ? max(tokenBAmount, new BN10(1)) : tokenBAmount,
|
|
8837
|
+
payer,
|
|
8838
|
+
positionNft,
|
|
8250
8839
|
tokenAProgram,
|
|
8251
8840
|
tokenBProgram
|
|
8252
|
-
);
|
|
8253
|
-
|
|
8254
|
-
|
|
8255
|
-
|
|
8256
|
-
|
|
8257
|
-
|
|
8258
|
-
|
|
8259
|
-
|
|
8260
|
-
|
|
8261
|
-
|
|
8262
|
-
const lamports = tokenBAmount.eq(new BN10(0)) ? new BN10(1) : tokenBAmount;
|
|
8263
|
-
const wrapSOLIx = wrapSOLInstruction(
|
|
8264
|
-
payer,
|
|
8265
|
-
payerTokenB,
|
|
8266
|
-
BigInt(lamports.toString())
|
|
8267
|
-
);
|
|
8268
|
-
preInstructions.push(...wrapSOLIx);
|
|
8841
|
+
});
|
|
8842
|
+
const postInstruction = [];
|
|
8843
|
+
if (isLockLiquidity) {
|
|
8844
|
+
const permanentLockIx = yield this._program.methods.permanentLockPosition(liquidityDelta).accountsPartial({
|
|
8845
|
+
position,
|
|
8846
|
+
positionNftAccount,
|
|
8847
|
+
pool,
|
|
8848
|
+
owner: creator
|
|
8849
|
+
}).instruction();
|
|
8850
|
+
postInstruction.push(permanentLockIx);
|
|
8269
8851
|
}
|
|
8270
|
-
const tokenBadgeAccounts = this.getTokenBadgeAccounts(
|
|
8271
|
-
tokenAMint,
|
|
8272
|
-
tokenBMint
|
|
8273
|
-
);
|
|
8274
8852
|
const transaction = yield this._program.methods.initializeCustomizablePool({
|
|
8275
8853
|
poolFees,
|
|
8276
8854
|
sqrtMinPrice,
|
|
@@ -8299,7 +8877,97 @@ var CpAmm = class {
|
|
|
8299
8877
|
tokenAProgram,
|
|
8300
8878
|
tokenBProgram,
|
|
8301
8879
|
systemProgram: SystemProgram2.programId
|
|
8302
|
-
}).preInstructions(preInstructions).remainingAccounts(tokenBadgeAccounts).transaction();
|
|
8880
|
+
}).preInstructions(preInstructions).postInstructions(postInstruction).remainingAccounts(tokenBadgeAccounts).transaction();
|
|
8881
|
+
return { tx: transaction, pool, position };
|
|
8882
|
+
});
|
|
8883
|
+
}
|
|
8884
|
+
createCustomPoolWithDynamicConfig(params) {
|
|
8885
|
+
return __async(this, null, function* () {
|
|
8886
|
+
const {
|
|
8887
|
+
tokenAMint,
|
|
8888
|
+
tokenBMint,
|
|
8889
|
+
tokenAAmount,
|
|
8890
|
+
tokenBAmount,
|
|
8891
|
+
sqrtMinPrice,
|
|
8892
|
+
sqrtMaxPrice,
|
|
8893
|
+
liquidityDelta,
|
|
8894
|
+
initSqrtPrice,
|
|
8895
|
+
payer,
|
|
8896
|
+
config,
|
|
8897
|
+
poolCreatorAuthority,
|
|
8898
|
+
creator,
|
|
8899
|
+
positionNft,
|
|
8900
|
+
poolFees,
|
|
8901
|
+
hasAlphaVault,
|
|
8902
|
+
collectFeeMode,
|
|
8903
|
+
activationPoint,
|
|
8904
|
+
activationType,
|
|
8905
|
+
tokenAProgram,
|
|
8906
|
+
tokenBProgram,
|
|
8907
|
+
isLockLiquidity
|
|
8908
|
+
} = params;
|
|
8909
|
+
const pool = derivePoolAddress(config, tokenAMint, tokenBMint);
|
|
8910
|
+
const {
|
|
8911
|
+
position,
|
|
8912
|
+
positionNftAccount,
|
|
8913
|
+
tokenAVault,
|
|
8914
|
+
tokenBVault,
|
|
8915
|
+
payerTokenA,
|
|
8916
|
+
payerTokenB,
|
|
8917
|
+
preInstructions,
|
|
8918
|
+
tokenBadgeAccounts
|
|
8919
|
+
} = yield this.prepareCreatePoolParams({
|
|
8920
|
+
pool,
|
|
8921
|
+
tokenAMint,
|
|
8922
|
+
tokenBMint,
|
|
8923
|
+
tokenAAmount,
|
|
8924
|
+
tokenBAmount,
|
|
8925
|
+
payer,
|
|
8926
|
+
positionNft,
|
|
8927
|
+
tokenAProgram,
|
|
8928
|
+
tokenBProgram
|
|
8929
|
+
});
|
|
8930
|
+
const postInstruction = [];
|
|
8931
|
+
if (isLockLiquidity) {
|
|
8932
|
+
const permanentLockIx = yield this._program.methods.permanentLockPosition(liquidityDelta).accountsPartial({
|
|
8933
|
+
position,
|
|
8934
|
+
positionNftAccount,
|
|
8935
|
+
pool,
|
|
8936
|
+
owner: creator
|
|
8937
|
+
}).instruction();
|
|
8938
|
+
postInstruction.push(permanentLockIx);
|
|
8939
|
+
}
|
|
8940
|
+
const transaction = yield this._program.methods.initializePoolWithDynamicConfig({
|
|
8941
|
+
poolFees,
|
|
8942
|
+
sqrtMinPrice,
|
|
8943
|
+
sqrtMaxPrice,
|
|
8944
|
+
hasAlphaVault,
|
|
8945
|
+
liquidity: liquidityDelta,
|
|
8946
|
+
sqrtPrice: initSqrtPrice,
|
|
8947
|
+
activationType,
|
|
8948
|
+
collectFeeMode,
|
|
8949
|
+
activationPoint
|
|
8950
|
+
}).accountsPartial({
|
|
8951
|
+
creator,
|
|
8952
|
+
positionNftAccount,
|
|
8953
|
+
positionNftMint: positionNft,
|
|
8954
|
+
payer,
|
|
8955
|
+
poolAuthority: this.poolAuthority,
|
|
8956
|
+
pool,
|
|
8957
|
+
position,
|
|
8958
|
+
poolCreatorAuthority,
|
|
8959
|
+
config,
|
|
8960
|
+
tokenAMint,
|
|
8961
|
+
tokenBMint,
|
|
8962
|
+
tokenAVault,
|
|
8963
|
+
tokenBVault,
|
|
8964
|
+
payerTokenA,
|
|
8965
|
+
payerTokenB,
|
|
8966
|
+
token2022Program: TOKEN_2022_PROGRAM_ID2,
|
|
8967
|
+
tokenAProgram,
|
|
8968
|
+
tokenBProgram,
|
|
8969
|
+
systemProgram: SystemProgram2.programId
|
|
8970
|
+
}).preInstructions(preInstructions).postInstructions(postInstruction).remainingAccounts(tokenBadgeAccounts).transaction();
|
|
8303
8971
|
return { tx: transaction, pool, position };
|
|
8304
8972
|
});
|
|
8305
8973
|
}
|
|
@@ -8342,13 +9010,15 @@ var CpAmm = class {
|
|
|
8342
9010
|
tokenAAta: tokenAAccount,
|
|
8343
9011
|
tokenBAta: tokenBAccount,
|
|
8344
9012
|
instructions: preInstructions
|
|
8345
|
-
} = yield this.prepareTokenAccounts(
|
|
8346
|
-
owner,
|
|
9013
|
+
} = yield this.prepareTokenAccounts({
|
|
9014
|
+
payer: owner,
|
|
9015
|
+
tokenAOwner: owner,
|
|
9016
|
+
tokenBOwner: owner,
|
|
8347
9017
|
tokenAMint,
|
|
8348
9018
|
tokenBMint,
|
|
8349
9019
|
tokenAProgram,
|
|
8350
9020
|
tokenBProgram
|
|
8351
|
-
);
|
|
9021
|
+
});
|
|
8352
9022
|
if (tokenAMint.equals(NATIVE_MINT2)) {
|
|
8353
9023
|
const wrapSOLIx = wrapSOLInstruction(
|
|
8354
9024
|
owner,
|
|
@@ -8429,13 +9099,15 @@ var CpAmm = class {
|
|
|
8429
9099
|
tokenAAta: tokenAAccount,
|
|
8430
9100
|
tokenBAta: tokenBAccount,
|
|
8431
9101
|
instructions: preInstructions
|
|
8432
|
-
} = yield this.prepareTokenAccounts(
|
|
8433
|
-
owner,
|
|
9102
|
+
} = yield this.prepareTokenAccounts({
|
|
9103
|
+
payer: owner,
|
|
9104
|
+
tokenAOwner: owner,
|
|
9105
|
+
tokenBOwner: owner,
|
|
8434
9106
|
tokenAMint,
|
|
8435
9107
|
tokenBMint,
|
|
8436
9108
|
tokenAProgram,
|
|
8437
9109
|
tokenBProgram
|
|
8438
|
-
);
|
|
9110
|
+
});
|
|
8439
9111
|
if (tokenAMint.equals(NATIVE_MINT2)) {
|
|
8440
9112
|
const wrapSOLIx = wrapSOLInstruction(
|
|
8441
9113
|
owner,
|
|
@@ -8523,13 +9195,15 @@ var CpAmm = class {
|
|
|
8523
9195
|
tokenAAta: tokenAAccount,
|
|
8524
9196
|
tokenBAta: tokenBAccount,
|
|
8525
9197
|
instructions: preInstructions
|
|
8526
|
-
} = yield this.prepareTokenAccounts(
|
|
8527
|
-
owner,
|
|
9198
|
+
} = yield this.prepareTokenAccounts({
|
|
9199
|
+
payer: owner,
|
|
9200
|
+
tokenAOwner: owner,
|
|
9201
|
+
tokenBOwner: owner,
|
|
8528
9202
|
tokenAMint,
|
|
8529
9203
|
tokenBMint,
|
|
8530
9204
|
tokenAProgram,
|
|
8531
9205
|
tokenBProgram
|
|
8532
|
-
);
|
|
9206
|
+
});
|
|
8533
9207
|
const postInstructions = [];
|
|
8534
9208
|
if ([tokenAMint.toBase58(), tokenBMint.toBase58()].includes(
|
|
8535
9209
|
NATIVE_MINT2.toBase58()
|
|
@@ -8594,13 +9268,15 @@ var CpAmm = class {
|
|
|
8594
9268
|
tokenAAta: tokenAAccount,
|
|
8595
9269
|
tokenBAta: tokenBAccount,
|
|
8596
9270
|
instructions: preInstructions
|
|
8597
|
-
} = yield this.prepareTokenAccounts(
|
|
8598
|
-
owner,
|
|
9271
|
+
} = yield this.prepareTokenAccounts({
|
|
9272
|
+
payer: owner,
|
|
9273
|
+
tokenAOwner: owner,
|
|
9274
|
+
tokenBOwner: owner,
|
|
8599
9275
|
tokenAMint,
|
|
8600
9276
|
tokenBMint,
|
|
8601
9277
|
tokenAProgram,
|
|
8602
9278
|
tokenBProgram
|
|
8603
|
-
);
|
|
9279
|
+
});
|
|
8604
9280
|
const postInstructions = [];
|
|
8605
9281
|
if ([tokenAMint.toBase58(), tokenBMint.toBase58()].includes(
|
|
8606
9282
|
NATIVE_MINT2.toBase58()
|
|
@@ -8673,13 +9349,15 @@ var CpAmm = class {
|
|
|
8673
9349
|
tokenAAta: inputTokenAccount,
|
|
8674
9350
|
tokenBAta: outputTokenAccount,
|
|
8675
9351
|
instructions: preInstructions
|
|
8676
|
-
} = yield this.prepareTokenAccounts(
|
|
9352
|
+
} = yield this.prepareTokenAccounts({
|
|
8677
9353
|
payer,
|
|
8678
|
-
|
|
8679
|
-
|
|
8680
|
-
|
|
8681
|
-
|
|
8682
|
-
|
|
9354
|
+
tokenAOwner: payer,
|
|
9355
|
+
tokenBOwner: payer,
|
|
9356
|
+
tokenAMint: inputTokenMint,
|
|
9357
|
+
tokenBMint: outputTokenMint,
|
|
9358
|
+
tokenAProgram: inputTokenProgram,
|
|
9359
|
+
tokenBProgram: outputTokenProgram
|
|
9360
|
+
});
|
|
8683
9361
|
if (inputTokenMint.equals(NATIVE_MINT2)) {
|
|
8684
9362
|
const wrapSOLIx = wrapSOLInstruction(
|
|
8685
9363
|
payer,
|
|
@@ -8779,67 +9457,6 @@ var CpAmm = class {
|
|
|
8779
9457
|
return new Transaction().add(instruction);
|
|
8780
9458
|
});
|
|
8781
9459
|
}
|
|
8782
|
-
/**
|
|
8783
|
-
* Builds a transaction to claim position fee rewards.
|
|
8784
|
-
* @param {ClaimPositionFeeParams} params - Parameters for claiming position fee.
|
|
8785
|
-
* @returns Transaction builder.
|
|
8786
|
-
*/
|
|
8787
|
-
claimPositionFee(params) {
|
|
8788
|
-
return __async(this, null, function* () {
|
|
8789
|
-
const {
|
|
8790
|
-
owner,
|
|
8791
|
-
pool,
|
|
8792
|
-
position,
|
|
8793
|
-
positionNftAccount,
|
|
8794
|
-
tokenAVault,
|
|
8795
|
-
tokenBVault,
|
|
8796
|
-
tokenAMint,
|
|
8797
|
-
tokenBMint,
|
|
8798
|
-
tokenAProgram,
|
|
8799
|
-
tokenBProgram
|
|
8800
|
-
} = params;
|
|
8801
|
-
const {
|
|
8802
|
-
tokenAAta: tokenAAccount,
|
|
8803
|
-
tokenBAta: tokenBAccount,
|
|
8804
|
-
instructions: preInstructions
|
|
8805
|
-
} = yield this.prepareTokenAccounts(
|
|
8806
|
-
owner,
|
|
8807
|
-
tokenAMint,
|
|
8808
|
-
tokenBMint,
|
|
8809
|
-
tokenAProgram,
|
|
8810
|
-
tokenBProgram
|
|
8811
|
-
);
|
|
8812
|
-
const postInstructions = [];
|
|
8813
|
-
if ([tokenAMint.toBase58(), tokenBMint.toBase58()].includes(
|
|
8814
|
-
NATIVE_MINT2.toBase58()
|
|
8815
|
-
)) {
|
|
8816
|
-
const closeWrappedSOLIx = yield unwrapSOLInstruction(owner);
|
|
8817
|
-
closeWrappedSOLIx && postInstructions.push(closeWrappedSOLIx);
|
|
8818
|
-
}
|
|
8819
|
-
const claimPositionFeeInstruction = yield this.buildClaimPositionFeeInstruction({
|
|
8820
|
-
owner,
|
|
8821
|
-
poolAuthority: this.poolAuthority,
|
|
8822
|
-
pool,
|
|
8823
|
-
position,
|
|
8824
|
-
positionNftAccount,
|
|
8825
|
-
tokenAAccount,
|
|
8826
|
-
tokenBAccount,
|
|
8827
|
-
tokenAVault,
|
|
8828
|
-
tokenBVault,
|
|
8829
|
-
tokenAMint,
|
|
8830
|
-
tokenBMint,
|
|
8831
|
-
tokenAProgram,
|
|
8832
|
-
tokenBProgram
|
|
8833
|
-
});
|
|
8834
|
-
const transaction = new Transaction();
|
|
8835
|
-
transaction.add(
|
|
8836
|
-
...preInstructions.length > 0 ? preInstructions : [],
|
|
8837
|
-
claimPositionFeeInstruction,
|
|
8838
|
-
...postInstructions.length > 0 ? postInstructions : []
|
|
8839
|
-
);
|
|
8840
|
-
return transaction;
|
|
8841
|
-
});
|
|
8842
|
-
}
|
|
8843
9460
|
closePosition(params) {
|
|
8844
9461
|
return __async(this, null, function* () {
|
|
8845
9462
|
const { owner, pool, position, positionNftMint, positionNftAccount } = params;
|
|
@@ -8894,13 +9511,15 @@ var CpAmm = class {
|
|
|
8894
9511
|
tokenAAta: tokenAAccount,
|
|
8895
9512
|
tokenBAta: tokenBAccount,
|
|
8896
9513
|
instructions: preInstructions
|
|
8897
|
-
} = yield this.prepareTokenAccounts(
|
|
8898
|
-
owner,
|
|
9514
|
+
} = yield this.prepareTokenAccounts({
|
|
9515
|
+
payer: owner,
|
|
9516
|
+
tokenAOwner: owner,
|
|
9517
|
+
tokenBOwner: owner,
|
|
8899
9518
|
tokenAMint,
|
|
8900
9519
|
tokenBMint,
|
|
8901
9520
|
tokenAProgram,
|
|
8902
9521
|
tokenBProgram
|
|
8903
|
-
);
|
|
9522
|
+
});
|
|
8904
9523
|
const postInstructions = [];
|
|
8905
9524
|
if ([tokenAMint.toBase58(), tokenBMint.toBase58()].includes(
|
|
8906
9525
|
NATIVE_MINT2.toBase58()
|
|
@@ -8985,13 +9604,15 @@ var CpAmm = class {
|
|
|
8985
9604
|
tokenAAta: tokenAAccount,
|
|
8986
9605
|
tokenBAta: tokenBAccount,
|
|
8987
9606
|
instructions: preInstructions
|
|
8988
|
-
} = yield this.prepareTokenAccounts(
|
|
8989
|
-
owner,
|
|
9607
|
+
} = yield this.prepareTokenAccounts({
|
|
9608
|
+
payer: owner,
|
|
9609
|
+
tokenAOwner: owner,
|
|
9610
|
+
tokenBOwner: owner,
|
|
8990
9611
|
tokenAMint,
|
|
8991
9612
|
tokenBMint,
|
|
8992
9613
|
tokenAProgram,
|
|
8993
9614
|
tokenBProgram
|
|
8994
|
-
);
|
|
9615
|
+
});
|
|
8995
9616
|
let positionBLiquidityDelta = positionBState.unlockedLiquidity;
|
|
8996
9617
|
if (positionBVestings.length > 0) {
|
|
8997
9618
|
const totalAvailableVestingLiquidity = positionBVestings.reduce(
|
|
@@ -9191,7 +9812,15 @@ var CpAmm = class {
|
|
|
9191
9812
|
*/
|
|
9192
9813
|
claimPartnerFee(params) {
|
|
9193
9814
|
return __async(this, null, function* () {
|
|
9194
|
-
const {
|
|
9815
|
+
const {
|
|
9816
|
+
feePayer,
|
|
9817
|
+
receiver,
|
|
9818
|
+
tempWSolAccount,
|
|
9819
|
+
partner,
|
|
9820
|
+
pool,
|
|
9821
|
+
maxAmountA,
|
|
9822
|
+
maxAmountB
|
|
9823
|
+
} = params;
|
|
9195
9824
|
const poolState = yield this.fetchPoolState(pool);
|
|
9196
9825
|
const {
|
|
9197
9826
|
tokenAVault,
|
|
@@ -9203,25 +9832,16 @@ var CpAmm = class {
|
|
|
9203
9832
|
} = poolState;
|
|
9204
9833
|
const tokenAProgram = getTokenProgram(tokenAFlag);
|
|
9205
9834
|
const tokenBProgram = getTokenProgram(tokenBFlag);
|
|
9206
|
-
const
|
|
9207
|
-
|
|
9208
|
-
|
|
9209
|
-
instructions: preInstructions
|
|
9210
|
-
} = yield this.prepareTokenAccounts(
|
|
9211
|
-
partner,
|
|
9835
|
+
const payer = feePayer != null ? feePayer : partner;
|
|
9836
|
+
const { tokenAAccount, tokenBAccount, preInstructions, postInstructions } = yield this.setupFeeClaimAccounts({
|
|
9837
|
+
payer,
|
|
9212
9838
|
tokenAMint,
|
|
9213
9839
|
tokenBMint,
|
|
9214
9840
|
tokenAProgram,
|
|
9215
|
-
tokenBProgram
|
|
9216
|
-
|
|
9217
|
-
|
|
9218
|
-
|
|
9219
|
-
poolState.tokenAMint.toBase58(),
|
|
9220
|
-
poolState.tokenBMint.toBase58()
|
|
9221
|
-
].includes(NATIVE_MINT2.toBase58())) {
|
|
9222
|
-
const closeWrappedSOLIx = yield unwrapSOLInstruction(partner);
|
|
9223
|
-
closeWrappedSOLIx && postInstructions.push(closeWrappedSOLIx);
|
|
9224
|
-
}
|
|
9841
|
+
tokenBProgram,
|
|
9842
|
+
receiver,
|
|
9843
|
+
tempWSolAccount
|
|
9844
|
+
});
|
|
9225
9845
|
return yield this._program.methods.claimPartnerFee(maxAmountA, maxAmountB).accountsPartial({
|
|
9226
9846
|
poolAuthority: this.poolAuthority,
|
|
9227
9847
|
pool,
|
|
@@ -9237,6 +9857,62 @@ var CpAmm = class {
|
|
|
9237
9857
|
}).preInstructions(preInstructions).postInstructions(postInstructions).transaction();
|
|
9238
9858
|
});
|
|
9239
9859
|
}
|
|
9860
|
+
/**
|
|
9861
|
+
* Builds a transaction to claim position fee rewards.
|
|
9862
|
+
* @param {ClaimPositionFeeParams} params - Parameters for claiming position fee.
|
|
9863
|
+
* @returns Transaction builder.
|
|
9864
|
+
*/
|
|
9865
|
+
claimPositionFee(params) {
|
|
9866
|
+
return __async(this, null, function* () {
|
|
9867
|
+
const {
|
|
9868
|
+
receiver,
|
|
9869
|
+
tempWSolAccount,
|
|
9870
|
+
feePayer,
|
|
9871
|
+
owner,
|
|
9872
|
+
pool,
|
|
9873
|
+
position,
|
|
9874
|
+
positionNftAccount,
|
|
9875
|
+
tokenAVault,
|
|
9876
|
+
tokenBVault,
|
|
9877
|
+
tokenAMint,
|
|
9878
|
+
tokenBMint,
|
|
9879
|
+
tokenAProgram,
|
|
9880
|
+
tokenBProgram
|
|
9881
|
+
} = params;
|
|
9882
|
+
const payer = feePayer != null ? feePayer : owner;
|
|
9883
|
+
const { tokenAAccount, tokenBAccount, preInstructions, postInstructions } = yield this.setupFeeClaimAccounts({
|
|
9884
|
+
payer,
|
|
9885
|
+
tokenAMint,
|
|
9886
|
+
tokenBMint,
|
|
9887
|
+
tokenAProgram,
|
|
9888
|
+
tokenBProgram,
|
|
9889
|
+
receiver,
|
|
9890
|
+
tempWSolAccount
|
|
9891
|
+
});
|
|
9892
|
+
const claimPositionFeeInstruction = yield this.buildClaimPositionFeeInstruction({
|
|
9893
|
+
owner,
|
|
9894
|
+
poolAuthority: this.poolAuthority,
|
|
9895
|
+
pool,
|
|
9896
|
+
position,
|
|
9897
|
+
positionNftAccount,
|
|
9898
|
+
tokenAAccount,
|
|
9899
|
+
tokenBAccount,
|
|
9900
|
+
tokenAVault,
|
|
9901
|
+
tokenBVault,
|
|
9902
|
+
tokenAMint,
|
|
9903
|
+
tokenBMint,
|
|
9904
|
+
tokenAProgram,
|
|
9905
|
+
tokenBProgram
|
|
9906
|
+
});
|
|
9907
|
+
const transaction = new Transaction();
|
|
9908
|
+
transaction.add(
|
|
9909
|
+
...preInstructions.length > 0 ? preInstructions : [],
|
|
9910
|
+
claimPositionFeeInstruction,
|
|
9911
|
+
...postInstructions.length > 0 ? postInstructions : []
|
|
9912
|
+
);
|
|
9913
|
+
return transaction;
|
|
9914
|
+
});
|
|
9915
|
+
}
|
|
9240
9916
|
/**
|
|
9241
9917
|
* Builds a transaction to claim reward from a position.
|
|
9242
9918
|
* @param {ClaimRewardParams} params - Parameters for claiming reward.
|
|
@@ -9245,6 +9921,7 @@ var CpAmm = class {
|
|
|
9245
9921
|
claimReward(params) {
|
|
9246
9922
|
return __async(this, null, function* () {
|
|
9247
9923
|
const {
|
|
9924
|
+
feePayer,
|
|
9248
9925
|
user,
|
|
9249
9926
|
position,
|
|
9250
9927
|
positionNftAccount,
|
|
@@ -9260,7 +9937,7 @@ var CpAmm = class {
|
|
|
9260
9937
|
this._program.provider.connection,
|
|
9261
9938
|
rewardInfo.mint,
|
|
9262
9939
|
user,
|
|
9263
|
-
user,
|
|
9940
|
+
feePayer != null ? feePayer : user,
|
|
9264
9941
|
true,
|
|
9265
9942
|
tokenProgram
|
|
9266
9943
|
);
|