Skip to content

Commit 23336df

Browse files
committed
fix
1 parent f784621 commit 23336df

File tree

1 file changed

+43
-41
lines changed

1 file changed

+43
-41
lines changed

packages/client/src/actions/borrow.test.ts

Lines changed: 43 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
} from '../test-utils';
1919
import { sendWith } from '../viem';
2020
import { market } from './markets';
21-
import { borrow, supply } from './transactions';
21+
import { borrow, collateralToggle, supply } from './transactions';
2222
import { userBorrows, userSupplies } from './user';
2323

2424
async function supplyAndCheck(
@@ -73,50 +73,51 @@ describe('Given an Aave Market', () => {
7373
evmAddress(wallet.account!.address),
7474
bigDecimal('0.011'),
7575
);
76-
77-
await supplyAndCheck(wallet, {
78-
market: marketInfo.address,
79-
chainId: marketInfo.chain.chainId,
80-
supplier: evmAddress(wallet.account!.address),
81-
amount: {
82-
erc20: {
83-
currency: WETH_ADDRESS,
84-
value: '0.01',
85-
},
86-
},
87-
});
8876
});
8977

9078
describe('And a user with a supply position', () => {
9179
describe('When user set the supply as collateral', async () => {
9280
it('Then it should be possible to borrow from the reserve', async () => {
93-
// TODO: enable if confirmed that when supplying the isCollateral should be set to false
94-
// Enable collateral
95-
// const result = await collateralToggle(client, {
96-
// market: initialPosition!.market.address,
97-
// underlyingToken: initialPosition!.currency.address,
98-
// chainId: initialPosition!.market.chain.chainId,
99-
// user: evmAddress(wallet.account!.address),
100-
// })
101-
// .andThen(sendWith(wallet))
102-
// .andTee((tx) => console.log(`tx to enable collateral: ${tx}`))
103-
// .andThen(() => {
104-
// return userSupplies(client, {
105-
// markets: [
106-
// {
107-
// address: initialPosition!.market.address,
108-
// chainId: initialPosition!.market.chain.chainId,
109-
// },
110-
// ],
111-
// user: evmAddress(wallet.account!.address),
112-
// });
113-
// });
114-
// assertOk(result);
115-
// expect(result.value).toEqual([
116-
// expect.objectContaining({
117-
// isCollateral: true,
118-
// }),
119-
// ]);
81+
const supplyResult = await supplyAndCheck(wallet, {
82+
market: marketInfo.address,
83+
chainId: marketInfo.chain.chainId,
84+
supplier: evmAddress(wallet.account!.address),
85+
amount: {
86+
erc20: {
87+
currency: WETH_ADDRESS,
88+
value: '0.01',
89+
},
90+
},
91+
});
92+
93+
if (!supplyResult[0]!.isCollateral) {
94+
// Enable collateral
95+
const result = await collateralToggle(client, {
96+
market: marketInfo.address,
97+
underlyingToken: WETH_ADDRESS,
98+
chainId: marketInfo.chain.chainId,
99+
user: evmAddress(wallet.account!.address),
100+
})
101+
.andThen(sendWith(wallet))
102+
.andTee((tx) => console.log(`tx to enable collateral: ${tx}`))
103+
.andThen(() => {
104+
return userSupplies(client, {
105+
markets: [
106+
{
107+
address: marketInfo.address,
108+
chainId: marketInfo.chain.chainId,
109+
},
110+
],
111+
user: evmAddress(wallet.account!.address),
112+
});
113+
});
114+
assertOk(result);
115+
expect(result.value).toEqual([
116+
expect.objectContaining({
117+
isCollateral: true,
118+
}),
119+
]);
120+
}
120121

121122
// Borrow from the reserve
122123
const borrowReserve = await fetchReserve(
@@ -136,7 +137,7 @@ describe('Given an Aave Market', () => {
136137
})
137138
.andThen(sendWith(wallet))
138139
.andTee((tx) => console.log(`tx to borrow: ${tx}`))
139-
.andTee(() => wait(10000))
140+
.andTee(() => wait(5000))
140141
.andThen(() =>
141142
userBorrows(client, {
142143
markets: [
@@ -149,6 +150,7 @@ describe('Given an Aave Market', () => {
149150
}),
150151
);
151152
assertOk(borrowResult);
153+
expect(borrowResult.value.length).toBe(1);
152154
}, 25_000);
153155
});
154156
});

0 commit comments

Comments
 (0)