@@ -16,7 +16,7 @@ const AMOUNT = process.env.AMOUNT!;
1616const POOL_STATE = new PublicKey ( process . env . POOL ! ) ;
1717const MICRO_LAMPORTS = parseInt ( process . env . DEFAULT_CU_LAMPORTS ?? "1200000" ) ;
1818const SLIPPAGE_BPS = parseInt ( process . env . SLIPPAGE_BPS ?? "1000" ) ;
19- const BASE_IN = process . env . BASE_IN === undefined ? true : process . env . BASE_IN === "true" ;
19+ const BASE_SPECIFIED = process . env . BASE_SPECIFIED === undefined ? true : process . env . BASE_SPECIFIED === "true" ;
2020
2121async function mainFn ( ) : Promise < void > {
2222 const keypair = createKeypairFromFile ( KEYPAIR_PATH ) ;
@@ -37,54 +37,54 @@ async function mainFn(): Promise<void> {
3737 baseReserve : info . rpcData . baseReserve ,
3838 quoteReserve : info . rpcData . quoteReserve ,
3939 slippage,
40- baseIn : BASE_IN ,
40+ baseSpecified : BASE_SPECIFIED ,
4141 amount : new Decimal ( AMOUNT . toString ( ) )
42- . div ( 10 ** ( BASE_IN ? info . poolInfo . mintA . decimals : info . poolInfo . mintB . decimals ) )
42+ . div ( 10 ** ( BASE_SPECIFIED ? info . poolInfo . mintA . decimals : info . poolInfo . mintB . decimals ) )
4343 . toString ( ) ,
4444 epochInfo : await client . connection . getEpochInfo ( ) ,
4545 } ) ;
4646
47- // let { transaction: addTxn } = await client.cpmm.addLiquidity({
48- // poolInfo: info.poolInfo,
49- // poolKeys: info.poolKeys,
50- // payer: keypair.publicKey,
51- // inputAmount: new BN(AMOUNT),
52- // baseIn: BASE_IN ,
53- // slippage,
54- // computeResult: compute,
55- // computeBudgetConfig: {
56- // microLamports: MICRO_LAMPORTS,
57- // },
58- // txVersion: TxVersion.V0,
59- // });
47+ let { transaction : addTxn } = await client . cpmm . addLiquidity ( {
48+ poolInfo : info . poolInfo ,
49+ poolKeys : info . poolKeys ,
50+ payer : keypair . publicKey ,
51+ inputAmount : new BN ( AMOUNT ) ,
52+ baseSpecified : BASE_SPECIFIED ,
53+ slippage,
54+ computeResult : compute ,
55+ computeBudgetConfig : {
56+ microLamports : MICRO_LAMPORTS ,
57+ } ,
58+ txVersion : TxVersion . V0 ,
59+ } ) ;
6060
6161 let latestBlockhash = await client . connection . getLatestBlockhash ( ) ;
62- // addTxn.message.recentBlockhash = latestBlockhash.blockhash;
63- // addTxn.sign([
64- // {
65- // publicKey: keypair.publicKey,
66- // secretKey: keypair.secretKey,
67- // },
68- // ]);
62+ addTxn . message . recentBlockhash = latestBlockhash . blockhash ;
63+ addTxn . sign ( [
64+ {
65+ publicKey : keypair . publicKey ,
66+ secretKey : keypair . secretKey ,
67+ } ,
68+ ] ) ;
6969
7070 const sendConnection = new Connection ( SEND_RPC_URL ) ;
71- // console.log("Sending addLiquidity transaction");
72- // let signature = await sendConnection.sendTransaction(addTxn as unknown as VersionedTransaction, {
73- // skipPreflight: true,
74- // preflightCommitment: "confirmed",
75- // maxRetries: 0,
76- // });
77- // console.log(`Waiting to confirm transaction ${signature}`);
71+ console . log ( "Sending addLiquidity transaction" ) ;
72+ let signature = await sendConnection . sendTransaction ( addTxn as unknown as VersionedTransaction , {
73+ skipPreflight : true ,
74+ preflightCommitment : "confirmed" ,
75+ maxRetries : 0 ,
76+ } ) ;
77+ console . log ( `Waiting to confirm transaction ${ signature } ` ) ;
7878
79- // await client.connection.confirmTransaction(
80- // {
81- // signature,
82- // blockhash: latestBlockhash.blockhash,
83- // lastValidBlockHeight: latestBlockhash.lastValidBlockHeight,
84- // },
85- // "confirmed",
86- // );
87- // console.log(`addLiquidity txn confirmed. View at https://solscan.io/tx/${signature}`);
79+ await client . connection . confirmTransaction (
80+ {
81+ signature,
82+ blockhash : latestBlockhash . blockhash ,
83+ lastValidBlockHeight : latestBlockhash . lastValidBlockHeight ,
84+ } ,
85+ "confirmed" ,
86+ ) ;
87+ console . log ( `addLiquidity txn confirmed. View at https://solscan.io/tx/${ signature } ` ) ;
8888
8989 latestBlockhash = await client . connection . getLatestBlockhash ( ) ;
9090 let { transaction : withdrawTxn } = await client . cpmm . withdrawLiquidity ( {
@@ -107,7 +107,7 @@ async function mainFn(): Promise<void> {
107107 ] ) ;
108108
109109 console . log ( "Sending removeLiquidity transaction" ) ;
110- let signature = await sendConnection . sendTransaction ( withdrawTxn as unknown as VersionedTransaction , {
110+ signature = await sendConnection . sendTransaction ( withdrawTxn as unknown as VersionedTransaction , {
111111 skipPreflight : false ,
112112 preflightCommitment : "confirmed" ,
113113 maxRetries : 0 ,
0 commit comments