@@ -156,14 +156,13 @@ export class StrategyCurveLPNG {
156
156
)
157
157
158
158
const amountOutMin = applySlippage ( amountOut , swapParams . slippage )
159
-
160
159
const { swapMulticallItem : removeLiquidityMulticallItem } =
161
160
encodeRemoveLiquidityOneCoinMulticallItem (
162
161
swapParams ,
163
162
lpData . lp ,
164
163
assetIndex ,
165
164
swapParams . amount ,
166
- amountOutMin ,
165
+ amountOut ,
167
166
swapParams . receiver ,
168
167
)
169
168
@@ -174,7 +173,7 @@ export class StrategyCurveLPNG {
174
173
swapParams . chainId ,
175
174
swapParams . receiver ,
176
175
swapParams . accountOut ,
177
- amountOut ,
176
+ amountOutMin ,
178
177
swapParams . deadline ,
179
178
)
180
179
@@ -286,7 +285,7 @@ export class StrategyCurveLPNG {
286
285
amountIn : String ( amountIn ) , // adjusted for accruing debt
287
286
amountInMax : String ( amountIn ) ,
288
287
amountOut : String ( amountOut ) ,
289
- amountOutMin : String ( amountOut ) ,
288
+ amountOutMin : String ( swapParams . amount ) ,
290
289
vaultIn : swapParams . vaultIn ,
291
290
receiver : swapParams . receiver ,
292
291
accountIn : swapParams . accountIn ,
@@ -456,116 +455,7 @@ const encodeRemoveLiquidityOneCoinMulticallItem = (
456
455
}
457
456
}
458
457
459
- export async function encodeMint (
460
- swapParams : SwapParams ,
461
- vault : Address ,
462
- amountOut : bigint ,
463
- receiver : Address ,
464
- ) {
465
- const amountIn = await fetchPreviewMint ( swapParams . chainId , vault , amountOut )
466
-
467
- const abiItem = {
468
- inputs : [
469
- { name : "amount" , type : "uint256" } ,
470
- { name : "receiver" , type : "address" } ,
471
- ] ,
472
- name : "mint" ,
473
- stateMutability : "nonpayable" ,
474
- type : "function" ,
475
- }
476
-
477
- const mintData = encodeFunctionData ( {
478
- abi : [ abiItem ] ,
479
- args : [ amountOut , receiver ] ,
480
- } )
481
-
482
- const swapData = encodeAbiParameters ( parseAbiParameters ( "address, bytes" ) , [
483
- vault ,
484
- mintData ,
485
- ] )
486
-
487
- const swapperAmountOut =
488
- swapParams . swapperMode === SwapperMode . EXACT_IN
489
- ? 0n //ignored
490
- : swapParams . swapperMode === SwapperMode . EXACT_OUT
491
- ? amountOut
492
- : swapParams . targetDebt
493
-
494
- const swapMulticallItem = encodeSwapMulticallItem ( {
495
- handler : SWAPPER_HANDLER_GENERIC ,
496
- mode : BigInt ( swapParams . swapperMode ) ,
497
- account : swapParams . accountOut ,
498
- tokenIn : swapParams . tokenIn . addressInfo ,
499
- tokenOut : swapParams . tokenOut . addressInfo ,
500
- vaultIn : swapParams . vaultIn ,
501
- accountIn : swapParams . accountIn ,
502
- receiver : swapParams . receiver ,
503
- amountOut : swapperAmountOut ,
504
- data : swapData ,
505
- } )
506
-
507
- return {
508
- amountIn,
509
- amountOut,
510
- swapMulticallItem,
511
- }
512
- }
513
-
514
- export async function fetchPreviewRedeem (
515
- chainId : number ,
516
- vault : Address ,
517
- amount : bigint ,
518
- ) {
519
- const client = getViemClient ( chainId )
520
-
521
- const abiItem = {
522
- name : "previewRedeem" ,
523
- inputs : [ { name : "shares" , type : "uint256" } ] ,
524
- outputs : [ { name : "" , type : "uint256" } ] ,
525
- stateMutability : "view" ,
526
- type : "function" ,
527
- }
528
-
529
- const query = {
530
- address : vault ,
531
- abi : [ abiItem ] ,
532
- functionName : "previewRedeem" ,
533
- args : [ amount ] ,
534
- } as const
535
-
536
- const data = ( await client . readContract ( query ) ) as bigint
537
-
538
- return data
539
- }
540
-
541
- export async function fetchPreviewWithdraw (
542
- chainId : number ,
543
- vault : Address ,
544
- amount : bigint ,
545
- ) {
546
- const client = getViemClient ( chainId )
547
-
548
- const abiItem = {
549
- name : "previewWithdraw" ,
550
- inputs : [ { name : "assets" , type : "uint256" } ] ,
551
- outputs : [ { name : "" , type : "uint256" } ] ,
552
- stateMutability : "view" ,
553
- type : "function" ,
554
- }
555
-
556
- const query = {
557
- address : vault ,
558
- abi : [ abiItem ] ,
559
- functionName : "previewWithdraw" ,
560
- args : [ amount ] ,
561
- } as const
562
-
563
- const data = ( await client . readContract ( query ) ) as bigint
564
-
565
- return data
566
- }
567
-
568
- export async function fetchCalcTokenAmount (
458
+ async function fetchCalcTokenAmount (
569
459
chainId : number ,
570
460
lp : Address ,
571
461
amounts : bigint [ ] ,
@@ -596,7 +486,7 @@ export async function fetchCalcTokenAmount(
596
486
return data
597
487
}
598
488
599
- export async function fetchCalcWithdrawOneCoin (
489
+ async function fetchCalcWithdrawOneCoin (
600
490
chainId : number ,
601
491
lp : Address ,
602
492
amount : bigint ,
@@ -627,33 +517,6 @@ export async function fetchCalcWithdrawOneCoin(
627
517
return data
628
518
}
629
519
630
- export async function fetchPreviewMint (
631
- chainId : number ,
632
- vault : Address ,
633
- amount : bigint ,
634
- ) {
635
- const client = getViemClient ( chainId )
636
-
637
- const abiItem = {
638
- name : "previewMint" ,
639
- inputs : [ { name : "shares" , type : "uint256" } ] ,
640
- outputs : [ { name : "" , type : "uint256" } ] ,
641
- stateMutability : "view" ,
642
- type : "function" ,
643
- }
644
-
645
- const query = {
646
- address : vault ,
647
- abi : [ abiItem ] ,
648
- functionName : "previewMint" ,
649
- args : [ amount ] ,
650
- } as const
651
-
652
- const data = ( await client . readContract ( query ) ) as bigint
653
-
654
- return data
655
- }
656
-
657
520
const getViemClient = ( chainId : number ) => {
658
521
if ( ! viemClients [ chainId ] )
659
522
throw new Error ( `No client found for chainId ${ chainId } ` )
0 commit comments