@@ -21,9 +21,10 @@ import {
2121 getTotalMintingCapacityShares ,
2222 getPooledEthBySharesRoundUp ,
2323 getWithdrawValue ,
24+ getStEthBalance ,
2425} from '../../contracts' ;
2526import process from 'node:process' ;
26- import { getBalanceEth } from '../../providers' ;
27+ import { getBalanceEth , getClient } from '../../providers' ;
2728
2829const CONFIRM_EXPIRY = 86400 ;
2930const NO_FEE_RATE = 100 ;
@@ -72,12 +73,17 @@ test.describe.serial('One step process', () => {
7273 test ( 'Create vault connected to vault hub && configure with all roles ' , async ( {
7374 ethereumNodeService,
7475 } ) => {
76+ const vaultCreatorAccount = ethereumNodeService . getAccount (
77+ getPermissionRole ( ROLES . DEFAULT_ADMIN ) . index ,
78+ ) ;
79+ const publicClient = getClient ( ) ;
80+ const vaultCreatorBalanceBeforeCreate = await publicClient . getBalance ( {
81+ address : vaultCreatorAccount . address as Address ,
82+ } ) ;
83+
7584 const vaultData =
7685 await test . step ( 'Create vault connected to VaultHub && grant all VM roles' , async ( ) => {
7786 const additionalRoles = buildAdditionalRoles ( ethereumNodeService ) ;
78- const vaultCreatorPK = ethereumNodeService . getAccount (
79- getPermissionRole ( ROLES . DEFAULT_ADMIN ) . index ,
80- ) . secretKey ;
8187
8288 return await lsvCLI . factory . createVaultConnectedToVh ( {
8389 defaultAdmin : roles . defaultAdmin . address ,
@@ -86,7 +92,7 @@ test.describe.serial('One step process', () => {
8692 confirmExpiry : CONFIRM_EXPIRY ,
8793 nodeOperatorFeeRate : NO_FEE_RATE ,
8894 roles : additionalRoles ,
89- privateKey : vaultCreatorPK ,
95+ privateKey : vaultCreatorAccount . secretKey ,
9096 } ) ;
9197 } ) ;
9298
@@ -105,10 +111,29 @@ test.describe.serial('One step process', () => {
105111 ) . toBe ( expectedVaultConnection ) ;
106112 } ) ;
107113
108- await test . step ( 'Check vault metrics' , async ( ) => {
114+ await test . step ( 'Check collateral' , async ( ) => {
115+ const receipt =
116+ ( await publicClient
117+ . getTransactionReceipt ( { hash : vaultData . txHash } )
118+ . catch ( ( ) => undefined ) ) ||
119+ ( await publicClient . waitForTransactionReceipt ( {
120+ hash : vaultData . txHash ,
121+ } ) ) ;
122+ const vaultCreatorBalanceAfterCreation = await publicClient . getBalance ( {
123+ address : vaultCreatorAccount . address as Address ,
124+ } ) ;
125+ const txFee = receipt . gasUsed * receipt . effectiveGasPrice ;
126+ const vaultCreatorBalanceDifference =
127+ vaultCreatorBalanceBeforeCreate -
128+ vaultCreatorBalanceAfterCreation -
129+ txFee ;
109130 const { totalValueEth, collateralEth } =
110131 await lsvCLI . dashboard . overview ( dashboardAddress ) ;
111132
133+ expect (
134+ vaultCreatorBalanceDifference ,
135+ `Vault creation requires collateral of ${ LIDO_CONNECTION_COLLATERAL } ETH` ,
136+ ) . toBe ( parseEther ( LIDO_CONNECTION_COLLATERAL ) ) ;
112137 expect (
113138 collateralEth ,
114139 `Vault creation requires collateral of ${ LIDO_CONNECTION_COLLATERAL } ETH` ,
@@ -289,6 +314,9 @@ test.describe.serial('One step process', () => {
289314 ethereumNodeService . getAccount ( getPermissionRole ( ROLES . BURN ) . index )
290315 . address ,
291316 ) ;
317+ const recipientStEthBalanceBeforeMint = await getStEthBalance (
318+ recipientRepayRoleAddress ,
319+ ) ;
292320
293321 await lsvCLI . vo . mintStEth (
294322 vaultAddress ,
@@ -304,6 +332,11 @@ test.describe.serial('One step process', () => {
304332 const liabilityShares = await getLiabilityShares ( dashboardAddress ) ;
305333 const contractLiabilityStEth =
306334 await getPooledEthBySharesRoundUp ( liabilityShares ) ;
335+ const calculatedRecipientStEthBalanceAfterMint =
336+ parseFloat ( recipientStEthBalanceBeforeMint ) + parseFloat ( mintAmount ) ;
337+ const recipientStEthBalanceAfterMint = parseFloat (
338+ await getStEthBalance ( recipientRepayRoleAddress ) ,
339+ ) ;
307340
308341 expect (
309342 dashboardLiabilityShares ,
@@ -313,7 +346,10 @@ test.describe.serial('One step process', () => {
313346 dashboardLiabilityStEth ,
314347 'Expect dashboard liability stETH to be correct with contract' ,
315348 ) . toBe ( contractLiabilityStEth ) ;
316- // add check for stETH to be mint to recipient
349+ expect (
350+ recipientStEthBalanceAfterMint ,
351+ 'Expect recipient stEth address receives correct amount' ,
352+ ) . toBe ( calculatedRecipientStEthBalanceAfterMint ) ;
317353 } ) ;
318354
319355 test ( `Burn stETH as ${ ROLES . BURN } ` , async ( { ethereumNodeService } ) => {
@@ -376,10 +412,10 @@ test.describe.serial('One step process', () => {
376412 await lsvCLI . dashboard . overview ( dashboardAddress ) ;
377413
378414 const withdrawRecipientBalanceAfterWithdraw = parseFloat (
379- formatEther ( await getBalanceEth ( withdrawRecipientAddress ) ) ,
415+ await getBalanceEth ( withdrawRecipientAddress ) ,
380416 ) ;
381417 const calculatedWithdrawRecipientBalanceAfter =
382- parseFloat ( formatEther ( withdrawRecipientBalanceBeforeWithdraw ) ) +
418+ parseFloat ( withdrawRecipientBalanceBeforeWithdraw ) +
383419 parseFloat ( availableToWithdrawalEthBefore ) ;
384420
385421 const contractWithdrawableValue = formatEther (
0 commit comments