@@ -204,9 +204,12 @@ task("ops:trancheAndDeposit")
204204 console . log ( "Signer" , signerAddress ) ;
205205
206206 console . log ( "Approving router to spend tokens:" ) ;
207- const tx1 = await collateralToken . connect ( signer ) . approve ( router . address , fixedPtCollateralAmount ) ;
208- await tx1 . wait ( ) ;
209- console . log ( "Tx" , tx1 . hash ) ;
207+ const allowance = await collateralToken . allowance ( signerAddress , router . address ) ;
208+ if ( allowance . lt ( fixedPtCollateralAmount ) ) {
209+ const tx1 = await collateralToken . connect ( signer ) . approve ( router . address , fixedPtCollateralAmount ) ;
210+ await tx1 . wait ( ) ;
211+ console . log ( "Tx" , tx1 . hash ) ;
212+ }
210213
211214 let fee = BigNumber . from ( "0" ) ;
212215 if ( totalMintFee . gt ( "0" ) && feeToken . address !== perp . address ) {
@@ -482,9 +485,12 @@ task("ops:trancheAndRollover")
482485 console . log ( "Signer" , signerAddress ) ;
483486
484487 console . log ( "Approving collateralToken to be spent" ) ;
485- const tx1 = await collateralToken . connect ( signer ) . approve ( router . address , fixedPtCollateralAmount ) ;
486- await tx1 . wait ( ) ;
487- console . log ( "Tx" , tx1 . hash ) ;
488+ const allowance = await collateralToken . allowance ( signerAddress , router . address ) ;
489+ if ( allowance . lt ( fixedPtCollateralAmount ) ) {
490+ const tx1 = await collateralToken . connect ( signer ) . approve ( router . address , fixedPtCollateralAmount ) ;
491+ await tx1 . wait ( ) ;
492+ console . log ( "Tx" , tx1 . hash ) ;
493+ }
488494
489495 let fee = BigNumber . from ( "0" ) ;
490496 if ( totalRolloverFee . gt ( "0" ) ) {
0 commit comments