Skip to content

Commit 78ddcac

Browse files
committed
test: supply disabling collateral
1 parent 2483fd6 commit 78ddcac

File tree

1 file changed

+64
-5
lines changed

1 file changed

+64
-5
lines changed

packages/spec/supply/business.spec.ts

Lines changed: 64 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
import { assertOk, bigDecimal, chainId, evmAddress } from '@aave/client-next';
1+
import {
2+
assertOk,
3+
bigDecimal,
4+
chainId,
5+
evmAddress,
6+
type Reserve,
7+
} from '@aave/client-next';
28
import { supply, userSupplies } from '@aave/client-next/actions';
39
import {
410
client,
@@ -8,7 +14,7 @@ import {
814
} from '@aave/client-next/test-utils';
915
import { sendWith } from '@aave/client-next/viem';
1016
import { beforeAll, describe, expect, it } from 'vitest';
11-
import { findReserveToSupply } from '../borrow/helper';
17+
import { findReserveToSupply, supplyToReserve } from '../borrow/helper';
1218
import { assertSingleElementArray } from '../test-utils';
1319

1420
describe('Aave V4 Supply Scenarios', () => {
@@ -79,9 +85,62 @@ describe('Aave V4 Supply Scenarios', () => {
7985
});
8086

8187
describe('When the user supplies tokens with collateral disabled', () => {
82-
it.todo(
83-
`Then the user's supply positions are updated without collateral`,
84-
);
88+
const user = createNewWallet();
89+
let reserve: Reserve;
90+
91+
beforeAll(async () => {
92+
const setup = await fundErc20Address(
93+
evmAddress(user.account!.address),
94+
{
95+
address: ETHEREUM_USDC_ADDRESS,
96+
amount: bigDecimal('100'),
97+
decimals: 6,
98+
},
99+
).andThen(() => findReserveToSupply(client, ETHEREUM_USDC_ADDRESS));
100+
101+
assertOk(setup);
102+
reserve = setup.value;
103+
});
104+
105+
it(`Then the user's supply positions are updated without collateral`, async () => {
106+
const result = await supplyToReserve(
107+
client,
108+
{
109+
reserve: {
110+
spoke: reserve.spoke.address,
111+
reserveId: reserve.id,
112+
chainId: reserve.chain.chainId,
113+
},
114+
amount: {
115+
erc20: {
116+
value: bigDecimal('50'),
117+
},
118+
},
119+
sender: evmAddress(user.account!.address),
120+
enableCollateral: false,
121+
},
122+
user,
123+
).andThen(() =>
124+
userSupplies(client, {
125+
query: {
126+
userSpoke: {
127+
spoke: {
128+
address: reserve.spoke.address,
129+
chainId: reserve.chain.chainId,
130+
},
131+
user: evmAddress(user.account!.address),
132+
},
133+
},
134+
}),
135+
);
136+
assertOk(result);
137+
assertSingleElementArray(result.value);
138+
expect(result.value[0].isCollateral).toBe(false);
139+
expect(result.value[0].amount.value.formatted).toBeBigDecimalCloseTo(
140+
bigDecimal('50'),
141+
2,
142+
);
143+
});
85144
});
86145

87146
describe('When the user supplies tokens on behalf of another address', () => {

0 commit comments

Comments
 (0)