@@ -66,7 +66,7 @@ export const TokenSwapLayout = BufferLayout.struct([
66
66
BufferLayout . u8 ( 'version' ) ,
67
67
BufferLayout . u8 ( 'isInitialized' ) ,
68
68
BufferLayout . u8 ( 'bumpSeed' ) ,
69
- Layout . publicKey ( 'tokenProgramId ' ) ,
69
+ Layout . publicKey ( 'poolTokenProgramId ' ) ,
70
70
Layout . publicKey ( 'tokenAccountA' ) ,
71
71
Layout . publicKey ( 'tokenAccountB' ) ,
72
72
Layout . publicKey ( 'tokenPool' ) ,
@@ -101,7 +101,7 @@ export class TokenSwap {
101
101
* @param connection The connection to use
102
102
* @param tokenSwap The token swap account
103
103
* @param swapProgramId The program ID of the token-swap program
104
- * @param tokenProgramId The program ID of the token program
104
+ * @param poolTokenProgramId The program ID of the token program for the pool tokens
105
105
* @param poolToken The pool token
106
106
* @param authority The authority over the swap and accounts
107
107
* @param tokenAccountA The token swap's Token A account
@@ -123,7 +123,7 @@ export class TokenSwap {
123
123
private connection : Connection ,
124
124
public tokenSwap : PublicKey ,
125
125
public swapProgramId : PublicKey ,
126
- public tokenProgramId : PublicKey ,
126
+ public poolTokenProgramId : PublicKey ,
127
127
public poolToken : PublicKey ,
128
128
public feeAccount : PublicKey ,
129
129
public authority : PublicKey ,
@@ -145,7 +145,7 @@ export class TokenSwap {
145
145
this . connection = connection ;
146
146
this . tokenSwap = tokenSwap ;
147
147
this . swapProgramId = swapProgramId ;
148
- this . tokenProgramId = tokenProgramId ;
148
+ this . poolTokenProgramId = poolTokenProgramId ;
149
149
this . poolToken = poolToken ;
150
150
this . feeAccount = feeAccount ;
151
151
this . authority = authority ;
@@ -186,7 +186,7 @@ export class TokenSwap {
186
186
tokenPool : PublicKey ,
187
187
feeAccount : PublicKey ,
188
188
tokenAccountPool : PublicKey ,
189
- tokenProgramId : PublicKey ,
189
+ poolTokenProgramId : PublicKey ,
190
190
swapProgramId : PublicKey ,
191
191
tradeFeeNumerator : number ,
192
192
tradeFeeDenominator : number ,
@@ -207,7 +207,7 @@ export class TokenSwap {
207
207
{ pubkey : tokenPool , isSigner : false , isWritable : true } ,
208
208
{ pubkey : feeAccount , isSigner : false , isWritable : false } ,
209
209
{ pubkey : tokenAccountPool , isSigner : false , isWritable : true } ,
210
- { pubkey : tokenProgramId , isSigner : false , isWritable : false } ,
210
+ { pubkey : poolTokenProgramId , isSigner : false , isWritable : false } ,
211
211
] ;
212
212
const commandDataLayout = BufferLayout . struct ( [
213
213
BufferLayout . u8 ( 'instruction' ) ,
@@ -279,7 +279,7 @@ export class TokenSwap {
279
279
const tokenAccountB = new PublicKey ( tokenSwapData . tokenAccountB ) ;
280
280
const mintA = new PublicKey ( tokenSwapData . mintA ) ;
281
281
const mintB = new PublicKey ( tokenSwapData . mintB ) ;
282
- const tokenProgramId = new PublicKey ( tokenSwapData . tokenProgramId ) ;
282
+ const poolTokenProgramId = new PublicKey ( tokenSwapData . poolTokenProgramId ) ;
283
283
284
284
const tradeFeeNumerator = Numberu64 . fromBuffer (
285
285
tokenSwapData . tradeFeeNumerator ,
@@ -311,7 +311,7 @@ export class TokenSwap {
311
311
connection ,
312
312
address ,
313
313
programId ,
314
- tokenProgramId ,
314
+ poolTokenProgramId ,
315
315
poolToken ,
316
316
feeAccount ,
317
317
authority ,
@@ -343,7 +343,7 @@ export class TokenSwap {
343
343
* @param tokenAccountB: The token swap's Token B account
344
344
* @param poolToken The pool token
345
345
* @param tokenAccountPool The token swap's pool token account
346
- * @param tokenProgramId The program ID of the token program
346
+ * @param poolTokenProgramId The program ID of the token program for pool tokens
347
347
* @param swapProgramId The program ID of the token-swap program
348
348
* @param feeNumerator Numerator of the fee ratio
349
349
* @param feeDenominator Denominator of the fee ratio
@@ -362,7 +362,7 @@ export class TokenSwap {
362
362
feeAccount : PublicKey ,
363
363
tokenAccountPool : PublicKey ,
364
364
swapProgramId : PublicKey ,
365
- tokenProgramId : PublicKey ,
365
+ poolTokenProgramId : PublicKey ,
366
366
tradeFeeNumerator : number ,
367
367
tradeFeeDenominator : number ,
368
368
ownerTradeFeeNumerator : number ,
@@ -380,7 +380,7 @@ export class TokenSwap {
380
380
connection ,
381
381
tokenSwapAccount . publicKey ,
382
382
swapProgramId ,
383
- tokenProgramId ,
383
+ poolTokenProgramId ,
384
384
poolToken ,
385
385
feeAccount ,
386
386
authority ,
@@ -423,7 +423,7 @@ export class TokenSwap {
423
423
poolToken ,
424
424
feeAccount ,
425
425
tokenAccountPool ,
426
- tokenProgramId ,
426
+ poolTokenProgramId ,
427
427
swapProgramId ,
428
428
tradeFeeNumerator ,
429
429
tradeFeeDenominator ,
@@ -455,6 +455,8 @@ export class TokenSwap {
455
455
* @param poolSource Pool's source token account
456
456
* @param poolDestination Pool's destination token account
457
457
* @param userDestination User's destination token account
458
+ * @param sourceTokenProgramId Program id for the source token
459
+ * @param destinationTokenProgramId Program id for the destination token
458
460
* @param hostFeeAccount Host account to gather fees
459
461
* @param userTransferAuthority Account delegated to transfer user's tokens
460
462
* @param amountIn Amount to transfer from source account
@@ -465,6 +467,8 @@ export class TokenSwap {
465
467
poolSource : PublicKey ,
466
468
poolDestination : PublicKey ,
467
469
userDestination : PublicKey ,
470
+ sourceTokenProgramId : PublicKey ,
471
+ destinationTokenProgramId : PublicKey ,
468
472
hostFeeAccount : PublicKey | null ,
469
473
userTransferAuthority : Account ,
470
474
amountIn : number | Numberu64 ,
@@ -486,7 +490,9 @@ export class TokenSwap {
486
490
this . feeAccount ,
487
491
hostFeeAccount ,
488
492
this . swapProgramId ,
489
- this . tokenProgramId ,
493
+ sourceTokenProgramId ,
494
+ destinationTokenProgramId ,
495
+ this . poolTokenProgramId ,
490
496
amountIn ,
491
497
minimumAmountOut ,
492
498
) ,
@@ -508,7 +514,9 @@ export class TokenSwap {
508
514
feeAccount : PublicKey ,
509
515
hostFeeAccount : PublicKey | null ,
510
516
swapProgramId : PublicKey ,
511
- tokenProgramId : PublicKey ,
517
+ sourceTokenProgramId : PublicKey ,
518
+ destinationTokenProgramId : PublicKey ,
519
+ poolTokenProgramId : PublicKey ,
512
520
amountIn : number | Numberu64 ,
513
521
minimumAmountOut : number | Numberu64 ,
514
522
) : TransactionInstruction {
@@ -538,7 +546,9 @@ export class TokenSwap {
538
546
{ pubkey : userDestination , isSigner : false , isWritable : true } ,
539
547
{ pubkey : poolMint , isSigner : false , isWritable : true } ,
540
548
{ pubkey : feeAccount , isSigner : false , isWritable : true } ,
541
- { pubkey : tokenProgramId , isSigner : false , isWritable : false } ,
549
+ { pubkey : sourceTokenProgramId , isSigner : false , isWritable : false } ,
550
+ { pubkey : destinationTokenProgramId , isSigner : false , isWritable : false } ,
551
+ { pubkey : poolTokenProgramId , isSigner : false , isWritable : false } ,
542
552
] ;
543
553
if ( hostFeeAccount !== null ) {
544
554
keys . push ( { pubkey : hostFeeAccount , isSigner : false , isWritable : true } ) ;
@@ -555,6 +565,8 @@ export class TokenSwap {
555
565
* @param userAccountA User account for token A
556
566
* @param userAccountB User account for token B
557
567
* @param poolAccount User account for pool token
568
+ * @param tokenProgramIdA Program id for token A
569
+ * @param tokenProgramIdB Program id for token B
558
570
* @param userTransferAuthority Account delegated to transfer user's tokens
559
571
* @param poolTokenAmount Amount of pool tokens to mint
560
572
* @param maximumTokenA The maximum amount of token A to deposit
@@ -564,6 +576,8 @@ export class TokenSwap {
564
576
userAccountA : PublicKey ,
565
577
userAccountB : PublicKey ,
566
578
poolAccount : PublicKey ,
579
+ tokenProgramIdA : PublicKey ,
580
+ tokenProgramIdB : PublicKey ,
567
581
userTransferAuthority : Account ,
568
582
poolTokenAmount : number | Numberu64 ,
569
583
maximumTokenA : number | Numberu64 ,
@@ -584,7 +598,9 @@ export class TokenSwap {
584
598
this . poolToken ,
585
599
poolAccount ,
586
600
this . swapProgramId ,
587
- this . tokenProgramId ,
601
+ tokenProgramIdA ,
602
+ tokenProgramIdB ,
603
+ this . poolTokenProgramId ,
588
604
poolTokenAmount ,
589
605
maximumTokenA ,
590
606
maximumTokenB ,
@@ -606,7 +622,9 @@ export class TokenSwap {
606
622
poolToken : PublicKey ,
607
623
poolAccount : PublicKey ,
608
624
swapProgramId : PublicKey ,
609
- tokenProgramId : PublicKey ,
625
+ tokenProgramIdA : PublicKey ,
626
+ tokenProgramIdB : PublicKey ,
627
+ poolTokenProgramId : PublicKey ,
610
628
poolTokenAmount : number | Numberu64 ,
611
629
maximumTokenA : number | Numberu64 ,
612
630
maximumTokenB : number | Numberu64 ,
@@ -639,7 +657,9 @@ export class TokenSwap {
639
657
{ pubkey : intoB , isSigner : false , isWritable : true } ,
640
658
{ pubkey : poolToken , isSigner : false , isWritable : true } ,
641
659
{ pubkey : poolAccount , isSigner : false , isWritable : true } ,
642
- { pubkey : tokenProgramId , isSigner : false , isWritable : false } ,
660
+ { pubkey : tokenProgramIdA , isSigner : false , isWritable : false } ,
661
+ { pubkey : tokenProgramIdB , isSigner : false , isWritable : false } ,
662
+ { pubkey : poolTokenProgramId , isSigner : false , isWritable : false } ,
643
663
] ;
644
664
return new TransactionInstruction ( {
645
665
keys,
@@ -654,6 +674,8 @@ export class TokenSwap {
654
674
* @param userAccountA User account for token A
655
675
* @param userAccountB User account for token B
656
676
* @param poolAccount User account for pool token
677
+ * @param tokenProgramIdA Program id for token A
678
+ * @param tokenProgramIdB Program id for token B
657
679
* @param userTransferAuthority Account delegated to transfer user's tokens
658
680
* @param poolTokenAmount Amount of pool tokens to burn
659
681
* @param minimumTokenA The minimum amount of token A to withdraw
@@ -663,6 +685,8 @@ export class TokenSwap {
663
685
userAccountA : PublicKey ,
664
686
userAccountB : PublicKey ,
665
687
poolAccount : PublicKey ,
688
+ tokenProgramIdA : PublicKey ,
689
+ tokenProgramIdB : PublicKey ,
666
690
userTransferAuthority : Account ,
667
691
poolTokenAmount : number | Numberu64 ,
668
692
minimumTokenA : number | Numberu64 ,
@@ -684,7 +708,9 @@ export class TokenSwap {
684
708
userAccountA ,
685
709
userAccountB ,
686
710
this . swapProgramId ,
687
- this . tokenProgramId ,
711
+ this . poolTokenProgramId ,
712
+ tokenProgramIdA ,
713
+ tokenProgramIdB ,
688
714
poolTokenAmount ,
689
715
minimumTokenA ,
690
716
minimumTokenB ,
@@ -707,7 +733,9 @@ export class TokenSwap {
707
733
userAccountA : PublicKey ,
708
734
userAccountB : PublicKey ,
709
735
swapProgramId : PublicKey ,
710
- tokenProgramId : PublicKey ,
736
+ poolTokenProgramId : PublicKey ,
737
+ tokenProgramIdA : PublicKey ,
738
+ tokenProgramIdB : PublicKey ,
711
739
poolTokenAmount : number | Numberu64 ,
712
740
minimumTokenA : number | Numberu64 ,
713
741
minimumTokenB : number | Numberu64 ,
@@ -741,7 +769,9 @@ export class TokenSwap {
741
769
{ pubkey : userAccountA , isSigner : false , isWritable : true } ,
742
770
{ pubkey : userAccountB , isSigner : false , isWritable : true } ,
743
771
{ pubkey : feeAccount , isSigner : false , isWritable : true } ,
744
- { pubkey : tokenProgramId , isSigner : false , isWritable : false } ,
772
+ { pubkey : poolTokenProgramId , isSigner : false , isWritable : false } ,
773
+ { pubkey : tokenProgramIdA , isSigner : false , isWritable : false } ,
774
+ { pubkey : tokenProgramIdB , isSigner : false , isWritable : false } ,
745
775
] ;
746
776
return new TransactionInstruction ( {
747
777
keys,
@@ -754,13 +784,15 @@ export class TokenSwap {
754
784
* Deposit one side of tokens into the pool
755
785
* @param userAccount User account to deposit token A or B
756
786
* @param poolAccount User account to receive pool tokens
787
+ * @param sourceTokenProgramId Program id for the source token
757
788
* @param userTransferAuthority Account delegated to transfer user's tokens
758
789
* @param sourceTokenAmount The amount of token A or B to deposit
759
790
* @param minimumPoolTokenAmount Minimum amount of pool tokens to mint
760
791
*/
761
792
async depositSingleTokenTypeExactAmountIn (
762
793
userAccount : PublicKey ,
763
794
poolAccount : PublicKey ,
795
+ sourceTokenProgramId : PublicKey ,
764
796
userTransferAuthority : Account ,
765
797
sourceTokenAmount : number | Numberu64 ,
766
798
minimumPoolTokenAmount : number | Numberu64 ,
@@ -779,7 +811,8 @@ export class TokenSwap {
779
811
this . poolToken ,
780
812
poolAccount ,
781
813
this . swapProgramId ,
782
- this . tokenProgramId ,
814
+ sourceTokenProgramId ,
815
+ this . poolTokenProgramId ,
783
816
sourceTokenAmount ,
784
817
minimumPoolTokenAmount ,
785
818
) ,
@@ -799,7 +832,8 @@ export class TokenSwap {
799
832
poolToken : PublicKey ,
800
833
poolAccount : PublicKey ,
801
834
swapProgramId : PublicKey ,
802
- tokenProgramId : PublicKey ,
835
+ sourceTokenProgramId : PublicKey ,
836
+ poolTokenProgramId : PublicKey ,
803
837
sourceTokenAmount : number | Numberu64 ,
804
838
minimumPoolTokenAmount : number | Numberu64 ,
805
839
) : TransactionInstruction {
@@ -830,7 +864,8 @@ export class TokenSwap {
830
864
{ pubkey : intoB , isSigner : false , isWritable : true } ,
831
865
{ pubkey : poolToken , isSigner : false , isWritable : true } ,
832
866
{ pubkey : poolAccount , isSigner : false , isWritable : true } ,
833
- { pubkey : tokenProgramId , isSigner : false , isWritable : false } ,
867
+ { pubkey : sourceTokenProgramId , isSigner : false , isWritable : false } ,
868
+ { pubkey : poolTokenProgramId , isSigner : false , isWritable : false } ,
834
869
] ;
835
870
return new TransactionInstruction ( {
836
871
keys,
@@ -844,13 +879,15 @@ export class TokenSwap {
844
879
*
845
880
* @param userAccount User account to receive token A or B
846
881
* @param poolAccount User account to burn pool token
882
+ * @param destinationTokenProgramId Program id for the destination token
847
883
* @param userTransferAuthority Account delegated to transfer user's tokens
848
884
* @param destinationTokenAmount The amount of token A or B to withdraw
849
885
* @param maximumPoolTokenAmount Maximum amount of pool tokens to burn
850
886
*/
851
887
async withdrawSingleTokenTypeExactAmountOut (
852
888
userAccount : PublicKey ,
853
889
poolAccount : PublicKey ,
890
+ destinationTokenProgramId : PublicKey ,
854
891
userTransferAuthority : Account ,
855
892
destinationTokenAmount : number | Numberu64 ,
856
893
maximumPoolTokenAmount : number | Numberu64 ,
@@ -870,7 +907,8 @@ export class TokenSwap {
870
907
this . tokenAccountB ,
871
908
userAccount ,
872
909
this . swapProgramId ,
873
- this . tokenProgramId ,
910
+ this . poolTokenProgramId ,
911
+ destinationTokenProgramId ,
874
912
destinationTokenAmount ,
875
913
maximumPoolTokenAmount ,
876
914
) ,
@@ -891,7 +929,8 @@ export class TokenSwap {
891
929
fromB : PublicKey ,
892
930
userAccount : PublicKey ,
893
931
swapProgramId : PublicKey ,
894
- tokenProgramId : PublicKey ,
932
+ poolTokenProgramId : PublicKey ,
933
+ destinationTokenProgramId : PublicKey ,
895
934
destinationTokenAmount : number | Numberu64 ,
896
935
maximumPoolTokenAmount : number | Numberu64 ,
897
936
) : TransactionInstruction {
@@ -925,7 +964,8 @@ export class TokenSwap {
925
964
{ pubkey : fromB , isSigner : false , isWritable : true } ,
926
965
{ pubkey : userAccount , isSigner : false , isWritable : true } ,
927
966
{ pubkey : feeAccount , isSigner : false , isWritable : true } ,
928
- { pubkey : tokenProgramId , isSigner : false , isWritable : false } ,
967
+ { pubkey : poolTokenProgramId , isSigner : false , isWritable : false } ,
968
+ { pubkey : destinationTokenProgramId , isSigner : false , isWritable : false } ,
929
969
] ;
930
970
return new TransactionInstruction ( {
931
971
keys,
0 commit comments