1- import { CHAIN_ID , MARKET_ADDRESS , PT_ADDRESS , RECEIVER_ADDRESS , SY_ADDRESS , wstETH } from "./constants" ;
1+ import { CHAIN_ID , MARKET_ADDRESS , PT_ADDRESS , RECEIVER_ADDRESS , SY_ADDRESS , USDC , wstETH } from "./constants" ;
22import { callSDK , getSigner } from "./helper" ;
33import { AddLiquidityData } from "./types" ;
44
55export async function addLiquiditySinglePt ( ) {
66 // Use 1 PT to add liquidity to wstETH pool with 1% slippage
7- const res = await callSDK < AddLiquidityData > ( `/v1 /sdk/${ CHAIN_ID } /markets/${ MARKET_ADDRESS } /add-liquidity` , {
7+ const resp = await callSDK < AddLiquidityData > ( `/v2 /sdk/${ CHAIN_ID } /markets/${ MARKET_ADDRESS } /add-liquidity` , {
88 receiver : RECEIVER_ADDRESS ,
99 slippage : 0.01 ,
1010 tokenIn : PT_ADDRESS ,
1111 amountIn : '1000000000000000000'
1212 } ) ;
1313
14- console . log ( 'Amount LP Out: ' , res . data . amountLpOut ) ;
15- console . log ( 'Price impact: ' , res . data . priceImpact ) ;
14+ console . log ( 'Amount LP Out: ' , resp . data . data . amountLpOut ) ;
15+ console . log ( 'Price impact: ' , resp . data . data . priceImpact ) ;
16+ console . log ( 'Computing unit: ' , resp . headers [ 'x-computing-unit' ] ) ;
1617
1718 // Send tx
18- getSigner ( ) . sendTransaction ( res . tx ) ;
19+ // getSigner().sendTransaction(resp.data .tx);
1920}
2021
2122export async function addLiquiditySingleSy ( ) {
2223 // Use 1 SY to add liquidity to wstETH pool with 1% slippage
23- const res = await callSDK < AddLiquidityData > ( `/v1 /sdk/${ CHAIN_ID } /markets/${ MARKET_ADDRESS } /add-liquidity` , {
24+ const resp = await callSDK < AddLiquidityData > ( `/v2 /sdk/${ CHAIN_ID } /markets/${ MARKET_ADDRESS } /add-liquidity` , {
2425 receiver : RECEIVER_ADDRESS ,
2526 slippage : 0.01 ,
2627 tokenIn : SY_ADDRESS ,
2728 amountIn : '1000000000000000000' ,
2829 } ) ;
2930
30- console . log ( 'Amount LP Out: ' , res . data . amountLpOut ) ;
31- console . log ( 'Price impact: ' , res . data . priceImpact ) ;
31+ console . log ( 'Amount LP Out: ' , resp . data . data . amountLpOut ) ;
32+ console . log ( 'Price impact: ' , resp . data . data . priceImpact ) ;
33+ console . log ( 'Computing unit: ' , resp . headers [ 'x-computing-unit' ] ) ;
3234
3335 // Send tx
34- getSigner ( ) . sendTransaction ( res . tx ) ;
36+ // getSigner().sendTransaction(resp.data .tx);
3537}
3638
3739export async function addLiquiditySingleSyKeepYt ( ) {
3840 // Use 1 SY to add liquidity to wstETH pool (zero price impact mode) with 1% slippage
39- const res = await callSDK < AddLiquidityData > ( `/v1 /sdk/${ CHAIN_ID } /markets/${ MARKET_ADDRESS } /add-liquidity` , {
41+ const resp = await callSDK < AddLiquidityData > ( `/v2 /sdk/${ CHAIN_ID } /markets/${ MARKET_ADDRESS } /add-liquidity` , {
4042 receiver : RECEIVER_ADDRESS ,
4143 slippage : 0.01 ,
4244 tokenIn : SY_ADDRESS ,
4345 amountIn : '1000000000000000000' ,
4446 zpi : true ,
4547 } ) ;
4648
47- console . log ( 'Amount LP Out: ' , res . data . amountLpOut ) ;
48- console . log ( 'Amount YT Out: ' , res . data . amountYtOut ) ;
49- console . log ( 'Price impact: ' , res . data . priceImpact ) ;
49+ console . log ( 'Amount LP Out: ' , resp . data . data . amountLpOut ) ;
50+ console . log ( 'Amount YT Out: ' , resp . data . data . amountYtOut ) ;
51+ console . log ( 'Price impact: ' , resp . data . data . priceImpact ) ;
52+ console . log ( 'Computing unit: ' , resp . headers [ 'x-computing-unit' ] ) ;
5053
5154 // Send tx
52- getSigner ( ) . sendTransaction ( res . tx ) ;
55+ // getSigner().sendTransaction(resp.data .tx);
5356}
5457
5558export async function addLiquiditySingleToken ( ) {
5659 // Use 1 wstETH to add liquidity to wstETH pool with 1% slippage
57- const res = await callSDK < AddLiquidityData > ( `/v1 /sdk/${ CHAIN_ID } /markets/${ MARKET_ADDRESS } /add-liquidity` , {
60+ const resp = await callSDK < AddLiquidityData > ( `/v2 /sdk/${ CHAIN_ID } /markets/${ MARKET_ADDRESS } /add-liquidity` , {
5861 receiver : RECEIVER_ADDRESS ,
5962 slippage : 0.01 ,
6063 tokenIn : wstETH ,
6164 amountIn : '1000000000000000000'
6265 } ) ;
6366
64- console . log ( 'Amount LP Out: ' , res . data . amountLpOut ) ;
65- console . log ( 'Price impact: ' , res . data . priceImpact ) ;
67+ console . log ( 'Amount LP Out: ' , resp . data . data . amountLpOut ) ;
68+ console . log ( 'Price impact: ' , resp . data . data . priceImpact ) ;
69+ console . log ( 'Computing unit: ' , resp . headers [ 'x-computing-unit' ] ) ;
6670
6771 // Send tx
68- getSigner ( ) . sendTransaction ( res . tx ) ;
72+ // getSigner().sendTransaction(resp.data .tx);
6973}
7074
7175export async function addLiquiditySingleTokenKeepYt ( ) {
7276 // Use 1 wstETH to add liquidity to wstETH pool (zero price impact mode) with 1% slippage
73- const res = await callSDK < AddLiquidityData > ( `/v1 /sdk/${ CHAIN_ID } /markets/${ MARKET_ADDRESS } /add-liquidity` , {
77+ const resp = await callSDK < AddLiquidityData > ( `/v2 /sdk/${ CHAIN_ID } /markets/${ MARKET_ADDRESS } /add-liquidity` , {
7478 receiver : RECEIVER_ADDRESS ,
7579 slippage : 0.01 ,
7680 tokenIn : wstETH ,
7781 amountIn : '1000000000000000000' ,
7882 zpi : true ,
7983 } ) ;
8084
81- console . log ( 'Amount LP Out: ' , res . data . amountLpOut ) ;
82- console . log ( 'Amount YT Out: ' , res . data . amountYtOut ) ;
83- console . log ( 'Price impact: ' , res . data . priceImpact ) ;
85+ console . log ( 'Amount LP Out: ' , resp . data . data . amountLpOut ) ;
86+ console . log ( 'Amount YT Out: ' , resp . data . data . amountYtOut ) ;
87+ console . log ( 'Price impact: ' , resp . data . data . priceImpact ) ;
88+ console . log ( 'Computing unit: ' , resp . headers [ 'x-computing-unit' ] ) ;
8489
8590 // Send tx
86- getSigner ( ) . sendTransaction ( res . tx ) ;
87- }
91+ // getSigner().sendTransaction(resp.data.tx);
92+ }
93+
94+
95+ // addLiquiditySinglePt();
96+ // addLiquiditySingleSy();
97+ // addLiquiditySingleSyKeepYt();
98+ // addLiquiditySingleToken();
99+ // addLiquiditySingleTokenKeepYt();
0 commit comments