@@ -28,7 +28,7 @@ task("ops:perp:info")
2828 console . log ( "BondIssuer:" , bondIssuer . target ) ;
2929 console . log ( "bondFactory:" , await bondIssuer . bondFactory ( ) ) ;
3030 console . log ( "collateral:" , await bondIssuer . collateral ( ) ) ;
31- console . log ( "issuedCount:" , hre . ethers . formatUnits ( await bondIssuer . issuedCount ( ) ) , 0 ) ;
31+ console . log ( "issuedCount:" , hre . ethers . formatUnits ( await bondIssuer . issuedCount ( ) , 0 ) ) ;
3232 console . log ( "maxMaturityDuration:" , hre . ethers . formatUnits ( await bondIssuer . maxMaturityDuration ( ) , 0 ) ) ;
3333 console . log ( "minIssueTimeIntervalSec:" , hre . ethers . formatUnits ( await bondIssuer . minIssueTimeIntervalSec ( ) , 0 ) ) ;
3434 console . log ( "issueWindowOffsetSec:" , hre . ethers . formatUnits ( await bondIssuer . issueWindowOffsetSec ( ) , 0 ) ) ;
@@ -47,13 +47,6 @@ task("ops:perp:info")
4747 console . log ( "---------------------------------------------------------------" ) ;
4848 console . log ( "feePolicy:" , feePolicy . target ) ;
4949 console . log ( "owner" , await feePolicy . owner ( ) ) ;
50- console . log ( "perpMintFeePerc:" , hre . ethers . formatUnits ( await feePolicy . perpMintFeePerc ( ) , percDecimals ) ) ;
51- console . log ( "perpBurnFeePerc:" , hre . ethers . formatUnits ( await feePolicy . perpBurnFeePerc ( ) , percDecimals ) ) ;
52- const r = await feePolicy . perpRolloverFee ( ) ;
53- console . log ( "minRolloverFeePerc:" , hre . ethers . formatUnits ( r . minRolloverFeePerc , percDecimals ) ) ;
54- console . log ( "perpDebasementSlope:" , hre . ethers . formatUnits ( r . perpDebasementSlope , percDecimals ) ) ;
55- console . log ( "perpEnrichmentSlope:" , hre . ethers . formatUnits ( r . perpEnrichmentSlope , percDecimals ) ) ;
56-
5750 console . log ( "---------------------------------------------------------------" ) ;
5851 console . log ( "PerpetualTranche:" , perp . target ) ;
5952 console . log ( "proxyAdmin:" , proxyAdminAddress ) ;
@@ -84,7 +77,7 @@ task("ops:perp:info")
8477 const tokenAddress = await perp . getReserveAt . staticCall ( i ) ;
8578 const balance = await perp . getReserveTokenBalance . staticCall ( tokenAddress ) ;
8679 const value = await perp . getReserveTokenValue . staticCall ( tokenAddress ) ;
87- const price = balance > 0n ? ( value * balance * 1000 ) / 10n ** perpDecimals / 10n ** percDecimals : 0n ;
80+ const price = balance > 0n ? ( value * 1000n ) / balance : 0n ;
8881 data . push ( {
8982 token : tokenAddress ,
9083 balance : hre . ethers . formatUnits ( balance , await perp . decimals ( ) ) ,
@@ -213,7 +206,7 @@ task("ops:perp:trancheAndDeposit")
213206 console . log ( "Preview mint:" , collateralAmount ) ;
214207 const totalMintAmt = await perp . computeMintAmt . staticCall ( depositTranches [ 0 ] . token , depositTranches [ 0 ] . amount ) ;
215208 console . log ( "mintAmt" , hre . ethers . formatUnits ( totalMintAmt , await perp . decimals ( ) ) ) ;
216- if ( totalMintAmt . eq ( "0" ) ) {
209+ if ( totalMintAmt <= 0n ) {
217210 throw Error ( "No perp minted" ) ;
218211 }
219212
@@ -225,7 +218,7 @@ task("ops:perp:trancheAndDeposit")
225218
226219 console . log ( "Approving router to spend tokens:" ) ;
227220 const allowance = await collateralToken . allowance ( signerAddress , router . target ) ;
228- if ( allowance . lt ( fixedPtCollateralAmount ) ) {
221+ if ( allowance < fixedPtCollateralAmount ) {
229222 const tx1 = await collateralToken . connect ( signer ) . approve ( router . target , fixedPtCollateralAmount ) ;
230223 await tx1 . wait ( ) ;
231224 console . log ( "Tx" , tx1 . hash ) ;
@@ -243,13 +236,11 @@ task("ops:perp:trancheAndDeposit")
243236
244237task ( "ops:perp:redeem" )
245238 . addParam ( "perpAddress" , "the address of the perp contract" , undefined , types . string , false )
246- . addParam ( "routerAddress" , "the address of the router contract" , undefined , types . string , false )
247239 . addParam ( "amount" , "the total amount of perp tokens (in float) to redeem" , undefined , types . string , false )
248240 . addParam ( "fromIdx" , "the index of sender" , 0 , types . int )
249241 . setAction ( async function ( args : TaskArguments , hre ) {
250- const { perpAddress, routerAddress , amount } = args ;
242+ const { perpAddress, amount } = args ;
251243
252- const router = await hre . ethers . getContractAt ( "RouterV2" , routerAddress ) ;
253244 const perp = await hre . ethers . getContractAt ( "PerpetualTranche" , perpAddress ) ;
254245 const fixedPtAmount = hre . ethers . parseUnits ( amount , await perp . decimals ( ) ) ;
255246
@@ -272,17 +263,10 @@ task("ops:perp:redeem")
272263 const signerAddress = await signer . getAddress ( ) ;
273264 console . log ( "Signer" , signerAddress ) ;
274265
275- console . log ( "Approving router to spend tokens:" ) ;
276- if ( ( await perp . allowance ( signerAddress , router . target ) ) . lt ( fixedPtAmount ) ) {
277- const tx1 = await perp . connect ( signer ) . approve ( router . target , fixedPtAmount ) ;
278- await tx1 . wait ( ) ;
279- console . log ( "Tx" , tx1 . hash ) ;
280- }
281-
282266 console . log ( "Redeem:" ) ;
283- const tx2 = await perp . connect ( signer ) . redeem ( fixedPtAmount ) ;
284- await tx2 . wait ( ) ;
285- console . log ( "Tx" , tx2 . hash ) ;
267+ const tx = await perp . connect ( signer ) . redeem ( fixedPtAmount ) ;
268+ await tx . wait ( ) ;
269+ console . log ( "Tx" , tx . hash ) ;
286270
287271 console . log ( "Signer balance" , hre . ethers . formatUnits ( await perp . balanceOf ( signerAddress ) , await perp . decimals ( ) ) ) ;
288272 } ) ;
0 commit comments