@1delta/margin-fetcher 0.0.27 → 0.0.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lending/user-data/aave-v3-type/userCallParse.d.ts +2 -2
- package/dist/lending/user-data/aave-v3-type/userCallParse.d.ts.map +1 -1
- package/dist/lending/user-data/aave-v3-type/userCallParse.js +13 -12
- package/dist/lending/user-data/fetchUserData.d.ts +5 -2
- package/dist/lending/user-data/fetchUserData.d.ts.map +1 -1
- package/dist/lending/user-data/fetchUserData.js +7 -4
- package/dist/utils/multicall.d.ts +2 -1
- package/dist/utils/multicall.d.ts.map +1 -1
- package/dist/utils/multicall.js +12 -6
- package/package.json +1 -1
- package/src/lending/user-data/aave-v3-type/userCallParse.ts +45 -31
- package/src/lending/user-data/fetchUserData.ts +18 -4
- package/src/utils/multicall.ts +15 -4
- package/test/dataMainnet.ts +45256 -0
- package/test/userDataAave.test.ts +2 -7
- package/test/userDataAaveMainnet.test.ts +102 -0
|
@@ -1,17 +1,12 @@
|
|
|
1
|
-
import { describe, it, expect
|
|
1
|
+
import { describe, it, expect } from 'vitest'
|
|
2
2
|
import {
|
|
3
3
|
getLenderUserDataResult,
|
|
4
4
|
convertLenderUserDataResult,
|
|
5
5
|
} from '../src/lending/user-data/fetchUserData'
|
|
6
|
-
import { fetchGeneralYields, fetchMainPrices } from '../src'
|
|
7
6
|
import { getEvmClient } from '@1delta/providers'
|
|
8
|
-
import { Chain
|
|
9
|
-
import { LenderUserQuery } from '../src/lending/user-data/types'
|
|
10
|
-
import { fetchMorphoPublicData } from '../src/lending/morpho/publicCallBuild'
|
|
7
|
+
import { Chain } from '@1delta/asset-registry'
|
|
11
8
|
import { prettyPrint } from './utils'
|
|
12
9
|
import { TestData } from './data'
|
|
13
|
-
// random user with ETH
|
|
14
|
-
const TEST_ADDRESS = '0xbadA9c382165b31419F4CC0eDf0Fa84f80A3C8E5'
|
|
15
10
|
|
|
16
11
|
async function getUserData(chainIds: string[]) {
|
|
17
12
|
let promises: any[] = []
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest'
|
|
2
|
+
import {
|
|
3
|
+
getLenderUserDataResult,
|
|
4
|
+
convertLenderUserDataResult,
|
|
5
|
+
} from '../src/lending/user-data/fetchUserData'
|
|
6
|
+
import { getEvmClient } from '@1delta/providers'
|
|
7
|
+
import { Chain } from '@1delta/asset-registry'
|
|
8
|
+
import { prettyPrint } from './utils'
|
|
9
|
+
import { TestDataMainnet } from './dataMainnet'
|
|
10
|
+
|
|
11
|
+
export const queries = {
|
|
12
|
+
'1': [
|
|
13
|
+
{
|
|
14
|
+
account: '0xbadA9c382165b31419F4CC0eDf0Fa84f80A3C8E5',
|
|
15
|
+
lender: 'AAVE_V3',
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
account: '0xbadA9c382165b31419F4CC0eDf0Fa84f80A3C8E5',
|
|
19
|
+
lender: 'GRANARY',
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
account: '0xbadA9c382165b31419F4CC0eDf0Fa84f80A3C8E5',
|
|
23
|
+
lender: 'COMPOUND_V3_USDC',
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
account: '0xbadA9c382165b31419F4CC0eDf0Fa84f80A3C8E5',
|
|
27
|
+
lender: 'COMPOUND_V3_WETH',
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
account: '0xbadA9c382165b31419F4CC0eDf0Fa84f80A3C8E5',
|
|
31
|
+
lender: 'COMPOUND_V3_USDT',
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async function getUserData(chainIds: string[]) {
|
|
37
|
+
let promises: any[] = []
|
|
38
|
+
for (const chainId of chainIds) {
|
|
39
|
+
const chainQueries = queries[chainId]
|
|
40
|
+
if (!chainQueries?.length) continue
|
|
41
|
+
promises.push(
|
|
42
|
+
getLenderUserDataResult(
|
|
43
|
+
chainId,
|
|
44
|
+
chainQueries,
|
|
45
|
+
getEvmClient,
|
|
46
|
+
false,
|
|
47
|
+
undefined,
|
|
48
|
+
3,
|
|
49
|
+
false,
|
|
50
|
+
),
|
|
51
|
+
)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const res = await Promise.all(promises)
|
|
55
|
+
const results: Record<string, any[]> = {}
|
|
56
|
+
chainIds.forEach((chainId, i) => {
|
|
57
|
+
results[chainId] = res[i]
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
const userData: { [chainId: string]: any } = {}
|
|
61
|
+
|
|
62
|
+
for (const chainId of chainIds) {
|
|
63
|
+
const raw = results[chainId]
|
|
64
|
+
if (!raw) continue
|
|
65
|
+
// convert data
|
|
66
|
+
const converted = convertLenderUserDataResult(
|
|
67
|
+
chainId,
|
|
68
|
+
queries[chainId],
|
|
69
|
+
raw,
|
|
70
|
+
TestDataMainnet.allData.prices,
|
|
71
|
+
{},
|
|
72
|
+
TestDataMainnet.allData.data,
|
|
73
|
+
)
|
|
74
|
+
userData[chainId] = converted
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return { userData }
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
describe(
|
|
81
|
+
'user data fetching',
|
|
82
|
+
() => {
|
|
83
|
+
it.only(
|
|
84
|
+
'should fetch user data for Morpho on Base',
|
|
85
|
+
async () => {
|
|
86
|
+
try {
|
|
87
|
+
const { userData } = await getUserData([Chain.ETHEREUM_MAINNET])
|
|
88
|
+
|
|
89
|
+
prettyPrint(userData)
|
|
90
|
+
|
|
91
|
+
// Basic validation
|
|
92
|
+
expect(userData).toBeDefined()
|
|
93
|
+
expect(typeof userData).toBe('object')
|
|
94
|
+
} catch (error) {
|
|
95
|
+
console.log('Error fetching Morpho Base data:', error)
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
{ timeout: 30000 },
|
|
99
|
+
)
|
|
100
|
+
},
|
|
101
|
+
{ timeout: 90000 },
|
|
102
|
+
)
|