@@ -14,6 +14,7 @@ import {
1414 createNewWallet ,
1515 ETHEREUM_FORK_ID ,
1616 ETHEREUM_USDC_ADDRESS ,
17+ ETHEREUM_WETH_ADDRESS ,
1718 fundErc20Address ,
1819} from '@aave/client-next/test-utils' ;
1920import { sendWith , signERC20PermitWith } from '@aave/client-next/viem' ;
@@ -25,19 +26,21 @@ const user = await createNewWallet();
2526
2627describe ( 'Aave V4 Supply Scenarios' , ( ) => {
2728 describe ( 'Given a user and a Reserve' , ( ) => {
28- describe ( 'When the user supplies tokens' , ( ) => {
29- const amountToSupply = bigDecimal ( '94' ) ;
30-
31- beforeAll ( async ( ) => {
32- const setup = await fundErc20Address ( evmAddress ( user . account . address ) , {
33- address : ETHEREUM_USDC_ADDRESS ,
34- amount : bigDecimal ( '100' ) ,
35- decimals : 6 ,
36- } ) ;
37-
38- assertOk ( setup ) ;
39- } ) ;
29+ let reserveUSDC : Reserve ;
30+ const amountToSupply = bigDecimal ( '5' ) ;
31+
32+ beforeAll ( async ( ) => {
33+ const setup = await fundErc20Address ( evmAddress ( user . account . address ) , {
34+ address : ETHEREUM_USDC_ADDRESS ,
35+ amount : bigDecimal ( '300' ) ,
36+ decimals : 6 ,
37+ } ) . andThen ( ( ) => findReserveToSupply ( client , ETHEREUM_USDC_ADDRESS ) ) ;
38+
39+ assertOk ( setup ) ;
40+ reserveUSDC = setup . value ;
41+ } ) ;
4042
43+ describe ( 'When the user supplies tokens' , ( ) => {
4144 describe ( "Then the user's supply positions are updated" , async ( ) => {
4245 it ( 'And the supplied tokens are set as collateral by default' , async ( ) => {
4346 const reserveToSupply = await findReserveToSupply (
@@ -87,31 +90,31 @@ describe('Aave V4 Supply Scenarios', () => {
8790 } ) ;
8891
8992 describe ( 'When the user supplies tokens with collateral disabled' , ( ) => {
90- let reserve : Reserve ;
93+ let reserveWETH : Reserve ;
9194
9295 beforeAll ( async ( ) => {
9396 const setup = await fundErc20Address ( evmAddress ( user . account . address ) , {
94- address : ETHEREUM_USDC_ADDRESS ,
95- amount : bigDecimal ( '100 ' ) ,
97+ address : ETHEREUM_WETH_ADDRESS ,
98+ amount : bigDecimal ( '1.0 ' ) ,
9699 decimals : 6 ,
97- } ) . andThen ( ( ) => findReserveToSupply ( client , ETHEREUM_USDC_ADDRESS ) ) ;
100+ } ) . andThen ( ( ) => findReserveToSupply ( client , ETHEREUM_WETH_ADDRESS ) ) ;
98101
99102 assertOk ( setup ) ;
100- reserve = setup . value ;
103+ reserveWETH = setup . value ;
101104 } ) ;
102105
103106 it ( `Then the user's supply positions are updated without collateral` , async ( ) => {
104107 const result = await supplyToReserve (
105108 client ,
106109 {
107110 reserve : {
108- spoke : reserve . spoke . address ,
109- reserveId : reserve . id ,
110- chainId : reserve . chain . chainId ,
111+ spoke : reserveWETH . spoke . address ,
112+ reserveId : reserveWETH . id ,
113+ chainId : reserveWETH . chain . chainId ,
111114 } ,
112115 amount : {
113116 erc20 : {
114- value : bigDecimal ( '50 ' ) ,
117+ value : bigDecimal ( '0.1 ' ) ,
115118 } ,
116119 } ,
117120 sender : evmAddress ( user . account . address ) ,
@@ -123,8 +126,8 @@ describe('Aave V4 Supply Scenarios', () => {
123126 query : {
124127 userSpoke : {
125128 spoke : {
126- address : reserve . spoke . address ,
127- chainId : reserve . chain . chainId ,
129+ address : reserveWETH . spoke . address ,
130+ chainId : reserveWETH . chain . chainId ,
128131 } ,
129132 user : evmAddress ( user . account . address ) ,
130133 } ,
@@ -133,28 +136,15 @@ describe('Aave V4 Supply Scenarios', () => {
133136 ) ;
134137 assertOk ( result ) ;
135138 assertSingleElementArray ( result . value ) ;
136- expect ( result . value [ 0 ] . isCollateral ) . toBe ( false ) ;
139+ expect ( result . value [ 0 ] . isCollateral ) . toEqual ( false ) ;
137140 expect ( result . value [ 0 ] . amount . value . formatted ) . toBeBigDecimalCloseTo (
138- bigDecimal ( '50 ' ) ,
139- 2 ,
141+ bigDecimal ( '0.1 ' ) ,
142+ 3 ,
140143 ) ;
141144 } ) ;
142145 } ) ;
143146
144147 describe ( 'When the user supplies tokens using a permit signature' , ( ) => {
145- const amountToSupply = bigDecimal ( '94' ) ;
146- let reserve : Reserve ;
147-
148- beforeAll ( async ( ) => {
149- const setup = await fundErc20Address ( evmAddress ( user . account . address ) , {
150- address : ETHEREUM_USDC_ADDRESS ,
151- amount : bigDecimal ( '100' ) ,
152- decimals : 6 ,
153- } ) . andThen ( ( ) => findReserveToSupply ( client , ETHEREUM_USDC_ADDRESS ) ) ;
154-
155- assertOk ( setup ) ;
156- reserve = setup . value ;
157- } ) ;
158148 it ( 'Then the supply succeeds without requiring ERC20 approval' , async ( {
159149 annotate,
160150 } ) => {
@@ -164,9 +154,9 @@ describe('Aave V4 Supply Scenarios', () => {
164154 value : amountToSupply ,
165155 } ,
166156 reserve : {
167- reserveId : reserve . id ,
168- chainId : reserve . chain . chainId ,
169- spoke : reserve . spoke . address ,
157+ reserveId : reserveUSDC . id ,
158+ chainId : reserveUSDC . chain . chainId ,
159+ spoke : reserveUSDC . spoke . address ,
170160 } ,
171161 sender : evmAddress ( user . account . address ) ,
172162 } ,
@@ -175,9 +165,9 @@ describe('Aave V4 Supply Scenarios', () => {
175165
176166 const result = await supply ( client , {
177167 reserve : {
178- reserveId : reserve . id ,
168+ reserveId : reserveUSDC . id ,
179169 chainId : ETHEREUM_FORK_ID ,
180- spoke : reserve . spoke . address ,
170+ spoke : reserveUSDC . spoke . address ,
181171 } ,
182172 amount : {
183173 erc20 : {
@@ -198,7 +188,7 @@ describe('Aave V4 Supply Scenarios', () => {
198188 query : {
199189 userSpoke : {
200190 spoke : {
201- address : reserve . spoke . address ,
191+ address : reserveUSDC . spoke . address ,
202192 chainId : ETHEREUM_FORK_ID ,
203193 } ,
204194 user : evmAddress ( user . account . address ) ,
@@ -211,7 +201,7 @@ describe('Aave V4 Supply Scenarios', () => {
211201 assertSingleElementArray ( result . value ) ;
212202 expect ( result . value [ 0 ] . isCollateral ) . toBe ( true ) ;
213203 expect ( result . value [ 0 ] . amount . value . formatted ) . toBeBigDecimalCloseTo (
214- amountToSupply ,
204+ 10 ,
215205 2 ,
216206 ) ;
217207 } ) ;
0 commit comments