Skip to content

Commit 2b37148

Browse files
committed
Merge branch 'main' into feat/market-example
2 parents 5aea395 + cf9c593 commit 2b37148

File tree

13 files changed

+686
-120
lines changed

13 files changed

+686
-120
lines changed

.github/actions/tests/action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ inputs:
66
description: 'Environment to run tests against'
77
required: true
88
default: 'staging'
9+
private_key:
10+
description: 'EVM private key of a wallet'
11+
required: true
912

1013
runs:
1114
using: 'composite'
@@ -22,8 +25,10 @@ runs:
2225
- name: Setup Environment Variables
2326
shell: bash
2427
run: |
28+
echo "PRIVATE_KEY=${{ inputs.private_key }}" >> .env
2529
echo "ENVIRONMENT=${{ inputs.environment }}" >> .env
2630
31+
2732
- name: Run Tests
2833
shell: bash
2934
run: pnpm test

.github/workflows/verify.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,4 @@ jobs:
2929
uses: ./.github/actions/tests
3030
with:
3131
environment: 'staging'
32+
private_key: ${{ secrets.PRIVATE_KEY }}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"prepublish": "pnpm run build",
2222
"test:client": "vitest --project client",
2323
"test:react": "vitest --project react",
24-
"test": "test:react"
24+
"test": "vitest"
2525
},
2626
"license": "MIT",
2727
"devDependencies": {

packages/client/README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ import { supply, userSupplies } from '@aave/client/actions';
1616
import { sendWith } from '@aave/client/viem';
1717

1818
// Create client
19-
const client = new AaveClient({
20-
environment: mainnet,
21-
});
19+
const client = AaveClient.create();
2220

2321
// Query user positions
2422
const positions = await userSupplies(client, {
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2+
3+
exports[`Given the Aave client > When using the 'chains(client)' action > Then it should return the supported chains 1`] = `
4+
[
5+
{
6+
"__typename": "Chain",
7+
"chainId": 1,
8+
"icon": "https://statics.aave.com/ethereum.svg",
9+
"name": "Ethereum",
10+
},
11+
{
12+
"__typename": "Chain",
13+
"chainId": 42161,
14+
"icon": "https://statics.aave.com/arbitrum.svg",
15+
"name": "Arbitrum",
16+
},
17+
{
18+
"__typename": "Chain",
19+
"chainId": 43114,
20+
"icon": "https://statics.aave.com/avalanche.svg",
21+
"name": "Avalanche",
22+
},
23+
{
24+
"__typename": "Chain",
25+
"chainId": 8453,
26+
"icon": "https://statics.aave.com/base.svg",
27+
"name": "Base",
28+
},
29+
{
30+
"__typename": "Chain",
31+
"chainId": 56,
32+
"icon": "https://statics.aave.com/bnbchain.svg",
33+
"name": "BSC",
34+
},
35+
{
36+
"__typename": "Chain",
37+
"chainId": 42220,
38+
"icon": "https://statics.aave.com/celo.svg",
39+
"name": "Celo",
40+
},
41+
{
42+
"__typename": "Chain",
43+
"chainId": 100,
44+
"icon": "https://statics.aave.com/Gnosis.svg",
45+
"name": "Gnosis",
46+
},
47+
{
48+
"__typename": "Chain",
49+
"chainId": 59144,
50+
"icon": "https://statics.aave.com/linea.svg",
51+
"name": "Linea",
52+
},
53+
{
54+
"__typename": "Chain",
55+
"chainId": 1088,
56+
"icon": "https://statics.aave.com/Metis.svg",
57+
"name": "Metis",
58+
},
59+
{
60+
"__typename": "Chain",
61+
"chainId": 10,
62+
"icon": "https://statics.aave.com/optimism.svg",
63+
"name": "Optimism",
64+
},
65+
{
66+
"__typename": "Chain",
67+
"chainId": 137,
68+
"icon": "https://statics.aave.com/polygon.svg",
69+
"name": "Polygon",
70+
},
71+
{
72+
"__typename": "Chain",
73+
"chainId": 534352,
74+
"icon": "https://statics.aave.com/scroll-network.svg",
75+
"name": "Scroll",
76+
},
77+
{
78+
"__typename": "Chain",
79+
"chainId": 1946,
80+
"icon": "https://statics.aave.com/soneium.svg",
81+
"name": "Soneium",
82+
},
83+
{
84+
"__typename": "Chain",
85+
"chainId": 146,
86+
"icon": "https://statics.aave.com/sonic.svg",
87+
"name": "Sonic",
88+
},
89+
{
90+
"__typename": "Chain",
91+
"chainId": 324,
92+
"icon": "https://statics.aave.com/zksync-era-light.svg",
93+
"name": "zkSync",
94+
},
95+
{
96+
"__typename": "Chain",
97+
"chainId": 324,
98+
"icon": "https://statics.aave.com/zksync-era-light.svg",
99+
"name": "zkSync",
100+
},
101+
{
102+
"__typename": "Chain",
103+
"chainId": 5000,
104+
"icon": "https://statics.aave.com/mantle.svg",
105+
"name": "Mantle",
106+
},
107+
]
108+
`;
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2+
3+
exports[`Given the Aave Protocol v3 > When fetching markets data > Then it should be possible to fetch markets for a given chain ID 1`] = `
4+
{
5+
"__typename": "Market",
6+
"address": "0x0AA97c284e98396202b6A04024F5E2c65026F3c0",
7+
"borrowReserves": Any<Array>,
8+
"chain": {
9+
"__typename": "Chain",
10+
"chainId": 99999999,
11+
"icon": "https://statics.aave.com/ethereum.svg",
12+
"name": "ForkedEthereum",
13+
},
14+
"eModeCategories": Any<Array>,
15+
"icon": "https://statics.aave.com/ethereum.svg",
16+
"name": "AaveV3EthereumForkedEtherFi",
17+
"supplyReserves": Any<Array>,
18+
"totalAvailableLiquidity": "583285.41725508467783710208869",
19+
"totalMarketSize": Any<String>,
20+
"userState": null,
21+
}
22+
`;
23+
24+
exports[`Given the Aave Protocol v3 > When fetching markets data > Then it should be possible to fetch markets for a given chain ID 2`] = `
25+
{
26+
"__typename": "Market",
27+
"address": "0x4e033931ad43597d96D6bcc25c280717730B58B1",
28+
"borrowReserves": Any<Array>,
29+
"chain": {
30+
"__typename": "Chain",
31+
"chainId": 99999999,
32+
"icon": "https://statics.aave.com/ethereum.svg",
33+
"name": "ForkedEthereum",
34+
},
35+
"eModeCategories": Any<Array>,
36+
"icon": "https://statics.aave.com/ethereum.svg",
37+
"name": "AaveV3EthereumForkedLido",
38+
"supplyReserves": Any<Array>,
39+
"totalAvailableLiquidity": "801504840.4207857115463943922",
40+
"totalMarketSize": Any<String>,
41+
"userState": null,
42+
}
43+
`;
44+
45+
exports[`Given the Aave Protocol v3 > When fetching markets data > Then it should be possible to fetch markets for a given chain ID 3`] = `
46+
{
47+
"__typename": "Market",
48+
"address": "0x87870Bca3F3fD6335C3F4ce8392D69350B4fA4E2",
49+
"borrowReserves": Any<Array>,
50+
"chain": {
51+
"__typename": "Chain",
52+
"chainId": 99999999,
53+
"icon": "https://statics.aave.com/ethereum.svg",
54+
"name": "ForkedEthereum",
55+
},
56+
"eModeCategories": Any<Array>,
57+
"icon": "https://statics.aave.com/ethereum.svg",
58+
"name": "AaveV3ForkedEthereum",
59+
"supplyReserves": Any<Array>,
60+
"totalAvailableLiquidity": "21235993152.103032104308741052",
61+
"totalMarketSize": Any<String>,
62+
"userState": null,
63+
}
64+
`;

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

Lines changed: 3 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -4,104 +4,11 @@ import { client } from '@aave/client/test-utils';
44
import { describe, expect, it } from 'vitest';
55

66
describe('Given the Aave client', () => {
7-
describe(`when using the 'chains(client)' action`, () => {
8-
it('then it should return the supported chains', async () => {
7+
describe(`When using the 'chains(client)' action`, () => {
8+
it('Then it should return the supported chains', async () => {
99
const result = await chains(client);
1010
assertOk(result);
11-
expect(result.value).toMatchInlineSnapshot(`
12-
[
13-
{
14-
"__typename": "Chain",
15-
"chainId": 1,
16-
"icon": "https://statics.aave.com/ethereum.svg",
17-
"name": "Ethereum",
18-
},
19-
{
20-
"__typename": "Chain",
21-
"chainId": 42161,
22-
"icon": "https://statics.aave.com/arbitrum.svg",
23-
"name": "Arbitrum",
24-
},
25-
{
26-
"__typename": "Chain",
27-
"chainId": 43114,
28-
"icon": "https://statics.aave.com/avalanche.svg",
29-
"name": "Avalanche",
30-
},
31-
{
32-
"__typename": "Chain",
33-
"chainId": 8453,
34-
"icon": "https://statics.aave.com/base.svg",
35-
"name": "Base",
36-
},
37-
{
38-
"__typename": "Chain",
39-
"chainId": 56,
40-
"icon": "https://statics.aave.com/bnbchain.svg",
41-
"name": "BSC",
42-
},
43-
{
44-
"__typename": "Chain",
45-
"chainId": 42220,
46-
"icon": "https://statics.aave.com/celo.svg",
47-
"name": "Celo",
48-
},
49-
{
50-
"__typename": "Chain",
51-
"chainId": 100,
52-
"icon": "https://statics.aave.com/Gnosis.svg",
53-
"name": "Gnosis",
54-
},
55-
{
56-
"__typename": "Chain",
57-
"chainId": 59144,
58-
"icon": "https://statics.aave.com/linea.svg",
59-
"name": "Linea",
60-
},
61-
{
62-
"__typename": "Chain",
63-
"chainId": 1088,
64-
"icon": "https://statics.aave.com/Metis.svg",
65-
"name": "Metis",
66-
},
67-
{
68-
"__typename": "Chain",
69-
"chainId": 10,
70-
"icon": "https://statics.aave.com/optimism.svg",
71-
"name": "Optimism",
72-
},
73-
{
74-
"__typename": "Chain",
75-
"chainId": 137,
76-
"icon": "https://statics.aave.com/polygon.svg",
77-
"name": "Polygon",
78-
},
79-
{
80-
"__typename": "Chain",
81-
"chainId": 534352,
82-
"icon": "https://statics.aave.com/scroll-network.svg",
83-
"name": "Scroll",
84-
},
85-
{
86-
"__typename": "Chain",
87-
"chainId": 1946,
88-
"icon": "https://statics.aave.com/soneium.svg",
89-
"name": "Soneium",
90-
},
91-
{
92-
"__typename": "Chain",
93-
"chainId": 146,
94-
"icon": "https://statics.aave.com/sonic.svg",
95-
"name": "Sonic",
96-
},
97-
{
98-
"__typename": "Chain",
99-
"chainId": 324,
100-
"icon": "https://statics.aave.com/zksync-era-light.svg",
101-
"name": "zkSync",
102-
},
103-
]
104-
`);
11+
expect(result.value).toMatchSnapshot();
10512
});
10613
});
10714
});
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { assertOk } from '@aave/types';
2+
import { describe, expect, it } from 'vitest';
3+
import { client, ETHEREUM_FORK_ID } from '../test-utils';
4+
import { markets } from './markets';
5+
6+
describe('Given the Aave Protocol v3', () => {
7+
describe('When fetching markets data', () => {
8+
it('Then it should be possible to fetch markets for a given chain ID', async () => {
9+
const result = await markets(client, {
10+
chainIds: [ETHEREUM_FORK_ID],
11+
});
12+
13+
assertOk(result);
14+
15+
result.value.forEach((market) => {
16+
expect(market).toMatchSnapshot({
17+
totalMarketSize: expect.any(String),
18+
borrowReserves: expect.any(Array),
19+
supplyReserves: expect.any(Array),
20+
eModeCategories: expect.any(Array),
21+
});
22+
});
23+
});
24+
});
25+
});

packages/client/src/actions/markets.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export type MarketsRequest = {
4646
*
4747
* ```ts
4848
* const result = await markets(client, {
49-
* chainIds: [chainId(1), chainId(137)],
49+
* chainIds: [chainId(1), chainId(8453)],
5050
* });
5151
* ```
5252
*

packages/client/src/viem.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ async function sendTransaction(
2727
data: request.data,
2828
to: request.to,
2929
value: BigInt(request.value),
30-
chain: request.chainId,
30+
chain: walletClient.chain,
3131
});
3232
}
3333

0 commit comments

Comments
 (0)