@@ -23,20 +23,17 @@ import { beforeAll, describe, expect, it } from 'vitest';
2323import { supplyToRandomERC20Reserve , supplyToReserve } from '../borrow/helper' ;
2424import { supplyAndBorrow } from '../repay/helper' ;
2525
26+ const user = await createNewWallet ( ) ;
27+
2628describe ( 'Aave V4 Health Factor Positions Scenarios' , ( ) => {
2729 describe ( 'Given a user with a one supply position as collateral' , ( ) => {
2830 describe ( 'When the user checks the health factor' , ( ) => {
29- const user = createNewWallet ( ) ;
30-
3131 beforeAll ( async ( ) => {
32- const setup = await fundErc20Address (
33- evmAddress ( user . account ! . address ) ,
34- {
35- address : ETHEREUM_USDC_ADDRESS ,
36- amount : bigDecimal ( '200' ) ,
37- decimals : 6 ,
38- } ,
39- ) . andThen ( ( ) =>
32+ const setup = await fundErc20Address ( evmAddress ( user . account . address ) , {
33+ address : ETHEREUM_USDC_ADDRESS ,
34+ amount : bigDecimal ( '200' ) ,
35+ decimals : 6 ,
36+ } ) . andThen ( ( ) =>
4037 supplyToRandomERC20Reserve ( client , user , ETHEREUM_USDC_ADDRESS ) ,
4138 ) ;
4239
@@ -45,7 +42,7 @@ describe('Aave V4 Health Factor Positions Scenarios', () => {
4542
4643 it ( 'Then the health factor should be null' , async ( ) => {
4744 const summary = await userSummary ( client , {
48- user : evmAddress ( user . account ! . address ) ,
45+ user : evmAddress ( user . account . address ) ,
4946 filter : {
5047 chainIds : [ ETHEREUM_FORK_ID ] ,
5148 } ,
@@ -56,18 +53,14 @@ describe('Aave V4 Health Factor Positions Scenarios', () => {
5653 } ) ;
5754
5855 describe ( 'And the user has a one borrow position' , ( ) => {
59- const user = createNewWallet ( ) ;
6056 let reserve : Reserve ;
6157
6258 beforeAll ( async ( ) => {
63- const setup = await fundErc20Address (
64- evmAddress ( user . account ! . address ) ,
65- {
66- address : ETHEREUM_USDC_ADDRESS ,
67- amount : bigDecimal ( '300' ) ,
68- decimals : 6 ,
69- } ,
70- ) . andThen ( ( ) => supplyAndBorrow ( client , user , ETHEREUM_USDC_ADDRESS ) ) ;
59+ const setup = await fundErc20Address ( evmAddress ( user . account . address ) , {
60+ address : ETHEREUM_USDC_ADDRESS ,
61+ amount : bigDecimal ( '300' ) ,
62+ decimals : 6 ,
63+ } ) . andThen ( ( ) => supplyAndBorrow ( client , user , ETHEREUM_USDC_ADDRESS ) ) ;
7164
7265 assertOk ( setup ) ;
7366 reserve = setup . value ;
@@ -76,7 +69,7 @@ describe('Aave V4 Health Factor Positions Scenarios', () => {
7669 describe ( 'When the user checks the health factor' , ( ) => {
7770 it ( 'Then the health factor should be a number greater than 1' , async ( ) => {
7871 const summary = await userSummary ( client , {
79- user : evmAddress ( user . account ! . address ) ,
72+ user : evmAddress ( user . account . address ) ,
8073 filter : {
8174 chainIds : [ ETHEREUM_FORK_ID ] ,
8275 } ,
@@ -91,7 +84,7 @@ describe('Aave V4 Health Factor Positions Scenarios', () => {
9184
9285 beforeAll ( async ( ) => {
9386 const summary = await userSummary ( client , {
94- user : evmAddress ( user . account ! . address ) ,
87+ user : evmAddress ( user . account . address ) ,
9588 filter : {
9689 chainIds : [ ETHEREUM_FORK_ID ] ,
9790 } ,
@@ -109,7 +102,7 @@ describe('Aave V4 Health Factor Positions Scenarios', () => {
109102 chainId : reserve . chain . chainId ,
110103 } ,
111104 enableCollateral : true ,
112- sender : evmAddress ( user . account ! . address ) ,
105+ sender : evmAddress ( user . account . address ) ,
113106 } ,
114107 user ,
115108 ) ;
@@ -119,7 +112,7 @@ describe('Aave V4 Health Factor Positions Scenarios', () => {
119112
120113 it ( 'Then the health factor should be greater than before supplying more collateral' , async ( ) => {
121114 const summary = await userSummary ( client , {
122- user : evmAddress ( user . account ! . address ) ,
115+ user : evmAddress ( user . account . address ) ,
123116 filter : {
124117 chainIds : [ ETHEREUM_FORK_ID ] ,
125118 } ,
@@ -136,7 +129,7 @@ describe('Aave V4 Health Factor Positions Scenarios', () => {
136129
137130 beforeAll ( async ( ) => {
138131 const summary = await userSummary ( client , {
139- user : evmAddress ( user . account ! . address ) ,
132+ user : evmAddress ( user . account . address ) ,
140133 filter : {
141134 chainIds : [ ETHEREUM_FORK_ID ] ,
142135 } ,
@@ -150,7 +143,7 @@ describe('Aave V4 Health Factor Positions Scenarios', () => {
150143 reserveId : reserve . id ,
151144 chainId : reserve . chain . chainId ,
152145 } ,
153- sender : evmAddress ( user . account ! . address ) ,
146+ sender : evmAddress ( user . account . address ) ,
154147 amount : {
155148 erc20 : {
156149 value : {
@@ -167,7 +160,7 @@ describe('Aave V4 Health Factor Positions Scenarios', () => {
167160
168161 it ( 'Then the health factor should be greater than before repaying partially' , async ( ) => {
169162 const summary = await userSummary ( client , {
170- user : evmAddress ( user . account ! . address ) ,
163+ user : evmAddress ( user . account . address ) ,
171164 filter : {
172165 chainIds : [ ETHEREUM_FORK_ID ] ,
173166 } ,
@@ -184,7 +177,7 @@ describe('Aave V4 Health Factor Positions Scenarios', () => {
184177
185178 beforeAll ( async ( ) => {
186179 const summary = await userSummary ( client , {
187- user : evmAddress ( user . account ! . address ) ,
180+ user : evmAddress ( user . account . address ) ,
188181 filter : {
189182 chainIds : [ ETHEREUM_FORK_ID ] ,
190183 } ,
@@ -193,7 +186,7 @@ describe('Aave V4 Health Factor Positions Scenarios', () => {
193186 HFBeforeBorrow = summary . value . lowestHealthFactor ! ;
194187
195188 const setup = await borrow ( client , {
196- sender : evmAddress ( user . account ! . address ) ,
189+ sender : evmAddress ( user . account . address ) ,
197190 reserve : {
198191 spoke : reserve . spoke . address ,
199192 reserveId : reserve . id ,
@@ -213,7 +206,7 @@ describe('Aave V4 Health Factor Positions Scenarios', () => {
213206
214207 it ( 'Then the health factor should be less than before borrowing more money' , async ( ) => {
215208 const summary = await userSummary ( client , {
216- user : evmAddress ( user . account ! . address ) ,
209+ user : evmAddress ( user . account . address ) ,
217210 filter : {
218211 chainIds : [ ETHEREUM_FORK_ID ] ,
219212 } ,
@@ -230,7 +223,7 @@ describe('Aave V4 Health Factor Positions Scenarios', () => {
230223
231224 beforeAll ( async ( ) => {
232225 const summary = await userSummary ( client , {
233- user : evmAddress ( user . account ! . address ) ,
226+ user : evmAddress ( user . account . address ) ,
234227 filter : {
235228 chainIds : [ ETHEREUM_FORK_ID ] ,
236229 } ,
@@ -244,7 +237,7 @@ describe('Aave V4 Health Factor Positions Scenarios', () => {
244237 reserveId : reserve . id ,
245238 chainId : reserve . chain . chainId ,
246239 } ,
247- sender : evmAddress ( user . account ! . address ) ,
240+ sender : evmAddress ( user . account . address ) ,
248241 amount : {
249242 erc20 : {
250243 exact : bigDecimal ( '25' ) ,
@@ -259,7 +252,7 @@ describe('Aave V4 Health Factor Positions Scenarios', () => {
259252
260253 it ( 'Then the health factor should be less than before withdrawing collateral' , async ( ) => {
261254 const summary = await userSummary ( client , {
262- user : evmAddress ( user . account ! . address ) ,
255+ user : evmAddress ( user . account . address ) ,
263256 filter : {
264257 chainIds : [ ETHEREUM_FORK_ID ] ,
265258 } ,
@@ -279,7 +272,7 @@ describe('Aave V4 Health Factor Positions Scenarios', () => {
279272 reserveId : reserve . id ,
280273 chainId : reserve . chain . chainId ,
281274 } ,
282- sender : evmAddress ( user . account ! . address ) ,
275+ sender : evmAddress ( user . account . address ) ,
283276 amount : {
284277 erc20 : {
285278 value : {
@@ -298,7 +291,7 @@ describe('Aave V4 Health Factor Positions Scenarios', () => {
298291
299292 it ( 'Then the health factor should be null' , async ( ) => {
300293 const summary = await userSummary ( client , {
301- user : evmAddress ( user . account ! . address ) ,
294+ user : evmAddress ( user . account . address ) ,
302295 filter : {
303296 chainIds : [ ETHEREUM_FORK_ID ] ,
304297 } ,
0 commit comments