@1delta/initializer-sdk 0.0.5 → 0.0.6
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/README.md +228 -0
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
# @1delta/initializer-sdk
|
|
2
|
+
|
|
3
|
+
Fetches lending protocol deployment metadata from GitHub and populates the global registries used by `@1delta/data-sdk`.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @1delta/initializer-sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## How It Works
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
GitHub (lender-metadata repo) ──fetch──► initializer-sdk ──populate──► data-sdk global registry
|
|
15
|
+
│
|
|
16
|
+
aavePools(), morphoPools(), ...
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
The initializer fetches JSON files from `1delta-DAO/lender-metadata` (pool configs, reserves, oracles, tokens) and `1delta-DAO/chains` (chain metadata), then calls `initializeLenderData()` / `initializeChainData()` from `@1delta/data-sdk` to populate the global registry. After initialization, all data is accessible via the data-sdk getter functions.
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Quick Start
|
|
24
|
+
|
|
25
|
+
### Initialize everything
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
import { fetchLenderMetaFromDirAndInitializeAll } from '@1delta/initializer-sdk'
|
|
29
|
+
|
|
30
|
+
await fetchLenderMetaFromDirAndInitializeAll()
|
|
31
|
+
|
|
32
|
+
// Now data-sdk getters work:
|
|
33
|
+
import { aavePools, compoundV2Pools, morphoPools, chains } from '@1delta/data-sdk'
|
|
34
|
+
console.log(Object.keys(aavePools())) // ['AAVE_V3', 'SPARK', 'LENDLE', ...]
|
|
35
|
+
console.log(Object.keys(chains())) // ['1', '56', '42161', ...]
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Initialize selectively
|
|
39
|
+
|
|
40
|
+
Only load what you need — reduces fetch time and memory:
|
|
41
|
+
|
|
42
|
+
```ts
|
|
43
|
+
import { fetchLenderMetaFromDirAndInitialize } from '@1delta/initializer-sdk'
|
|
44
|
+
|
|
45
|
+
await fetchLenderMetaFromDirAndInitialize({
|
|
46
|
+
aavePools: true,
|
|
47
|
+
aaveReserves: true,
|
|
48
|
+
compoundV2Pools: true,
|
|
49
|
+
compoundV2TokenArray: true,
|
|
50
|
+
chains: true,
|
|
51
|
+
})
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## API
|
|
57
|
+
|
|
58
|
+
### `fetchLenderMetaFromDirAndInitializeAll()`
|
|
59
|
+
|
|
60
|
+
Fetches **all** metadata files and initializes the global registry. Equivalent to calling `fetchLenderMetaFromDirAndInitialize` with every flag set to `true`.
|
|
61
|
+
|
|
62
|
+
```ts
|
|
63
|
+
await fetchLenderMetaFromDirAndInitializeAll()
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### `fetchLenderMetaFromDirAndInitialize(flags)`
|
|
67
|
+
|
|
68
|
+
Fetches only the metadata specified by `flags` and initializes the registry.
|
|
69
|
+
|
|
70
|
+
```ts
|
|
71
|
+
await fetchLenderMetaFromDirAndInitialize({
|
|
72
|
+
aavePools: true, // fetch aave pool configs
|
|
73
|
+
aaveReserves: true, // fetch aave reserve lists
|
|
74
|
+
morphoPools: true, // fetch morpho singleton addresses
|
|
75
|
+
chains: true, // fetch chain metadata
|
|
76
|
+
// all other flags default to false
|
|
77
|
+
})
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### `fetchLenderMetaFromDir(flags)`
|
|
81
|
+
|
|
82
|
+
Fetches metadata without initializing. Returns an object of overrides you can pass to `inititalizeAllData()` manually.
|
|
83
|
+
|
|
84
|
+
```ts
|
|
85
|
+
const params = await fetchLenderMetaFromDir({ aavePools: true, aaveReserves: true })
|
|
86
|
+
// params.aavePoolsOverride = { AAVE_V3: { '1': { pool, protocolDataProvider } }, ... }
|
|
87
|
+
// params.aaveReservesOverride = { AAVE_V3: { '1': ['0x...', ...] }, ... }
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### `inititalizeAllData(params)`
|
|
91
|
+
|
|
92
|
+
Populates the global registry from a params object (as returned by `fetchLenderMetaFromDir`).
|
|
93
|
+
|
|
94
|
+
```ts
|
|
95
|
+
const params = await fetchLenderMetaFromDir({ aavePools: true })
|
|
96
|
+
inititalizeAllData(params)
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### `getDeltaTokenList(chainId)`
|
|
100
|
+
|
|
101
|
+
Fetches the token list for a chain from the `1delta-DAO/token-lists` repo.
|
|
102
|
+
|
|
103
|
+
```ts
|
|
104
|
+
import { getDeltaTokenList } from '@1delta/initializer-sdk'
|
|
105
|
+
|
|
106
|
+
const tokens = await getDeltaTokenList('1')
|
|
107
|
+
// {
|
|
108
|
+
// '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2': {
|
|
109
|
+
// chainId: '1', name: 'Wrapped Ether', symbol: 'WETH',
|
|
110
|
+
// address: '0xc02a...', decimals: 18, logoURI: '...',
|
|
111
|
+
// },
|
|
112
|
+
// ...
|
|
113
|
+
// }
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
## Fetch Flags
|
|
119
|
+
|
|
120
|
+
All flags default to `false`. Set to `true` to fetch the corresponding data.
|
|
121
|
+
|
|
122
|
+
### Aave (V2 / V3 / all forks)
|
|
123
|
+
|
|
124
|
+
| Flag | Remote file | data-sdk getter |
|
|
125
|
+
|------|------------|-----------------|
|
|
126
|
+
| `aavePools` | `config/aave-pools.json` | `aavePools()` |
|
|
127
|
+
| `aaveReserves` | `data/aave-reserves.json` | `aaveReserves()` |
|
|
128
|
+
| `aaveTokens` | `data/aave-tokens.json` | `aaveTokens()` |
|
|
129
|
+
| `aaveOracles` | `data/aave-oracles.json` | `aaveOracles()` |
|
|
130
|
+
| `aaveWethGateway` | `config/aave-weth-gateway.json` | `aaveWethGateway()` |
|
|
131
|
+
|
|
132
|
+
### Compound V2 (all forks)
|
|
133
|
+
|
|
134
|
+
| Flag | Remote file | data-sdk getter |
|
|
135
|
+
|------|------------|-----------------|
|
|
136
|
+
| `compoundV2Pools` | `config/compound-v2-pools.json` | `compoundV2Pools()` |
|
|
137
|
+
| `compoundV2Reserves` | `data/compound-v2-reserves.json` | `compoundV2Reserves()` |
|
|
138
|
+
| `compoundV2Tokens` | `data/compound-v2-c-tokens.json` | `compoundV2Tokens()` |
|
|
139
|
+
| `compoundV2TokenArray` | `data/compound-v2-tokens.json` | `compoundV2TokenArray()` |
|
|
140
|
+
| `compoundV2Oracles` | `data/compound-v2-oracles.json` | `compoundV2Oracles()` |
|
|
141
|
+
|
|
142
|
+
### Compound V3
|
|
143
|
+
|
|
144
|
+
| Flag | Remote file | data-sdk getter |
|
|
145
|
+
|------|------------|-----------------|
|
|
146
|
+
| `compoundV3Pools` | `config/compound-v3-pools.json` | `compoundV3Pools()` |
|
|
147
|
+
| `compoundV3Reserves` | `data/compound-v3-reserves.json` | `compoundV3Reserves()` |
|
|
148
|
+
| `compoundV3BaseData` | `data/compound-v3-base-data.json` | `compoundV3BaseData()` |
|
|
149
|
+
| `compoundV3Oracles` | `data/compound-v3-oracles.json` | `compoundV3Oracles()` |
|
|
150
|
+
| `compoundV3Bulker` | `data/compound-v3-bulkers.json` | `compoundV3Bulker()` |
|
|
151
|
+
|
|
152
|
+
### Morpho
|
|
153
|
+
|
|
154
|
+
| Flag | Remote file | data-sdk getter |
|
|
155
|
+
|------|------------|-----------------|
|
|
156
|
+
| `morphoPools` | `config/morpho-pools.json` | `morphoPools()` |
|
|
157
|
+
| `morphoOracles` | `data/morpho-oracles.json` | `morphoOracles()` |
|
|
158
|
+
| `morphoTypeOracles` | `data/morpho-type-oracles.json` | `morphoTypeOracles()` |
|
|
159
|
+
| `morphoTypeMarkets` | `data/morpho-type-markets.json` | `morphoTypeMarkets()` |
|
|
160
|
+
| `morphoBundler3` | `data/morpho-bundler3.json` | `morphoBundler3()` |
|
|
161
|
+
|
|
162
|
+
### Euler
|
|
163
|
+
|
|
164
|
+
| Flag | Remote file | data-sdk getter |
|
|
165
|
+
|------|------------|-----------------|
|
|
166
|
+
| `eulerConfigs` | `config/euler-configs.json` | `eulerConfigs()` |
|
|
167
|
+
| `eulerVaults` | `data/euler-vaults.json` | `eulerVaults()` |
|
|
168
|
+
|
|
169
|
+
### Other
|
|
170
|
+
|
|
171
|
+
| Flag | Remote file | data-sdk getter |
|
|
172
|
+
|------|------------|-----------------|
|
|
173
|
+
| `initPools` | `config/init-pools.json` | `initConfig()` |
|
|
174
|
+
| `initConfig` | `data/init-config.json` | `initConfig()` |
|
|
175
|
+
| `listaNativeProvider` | `data/lista-providers.json` | `listaNativeProvider()` |
|
|
176
|
+
| `chains` | `data.json` (from chains repo) | `chains()` |
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
## Data Sources
|
|
181
|
+
|
|
182
|
+
| Repository | Content |
|
|
183
|
+
|-----------|---------|
|
|
184
|
+
| `github.com/1delta-DAO/lender-metadata` | Pool configs, reserves, oracles, tokens for all protocols |
|
|
185
|
+
| `github.com/1delta-DAO/chains` | Chain metadata (RPC, explorers, native currency) |
|
|
186
|
+
| `github.com/1delta-DAO/token-lists` | Per-chain token lists |
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
## Usage with irm-sdk
|
|
191
|
+
|
|
192
|
+
The typical flow for fetching IRM data across all protocols:
|
|
193
|
+
|
|
194
|
+
```ts
|
|
195
|
+
import { fetchLenderMetaFromDirAndInitialize } from '@1delta/initializer-sdk'
|
|
196
|
+
import { aavePools, compoundV2Pools, compoundV3Pools, morphoPools, eulerConfigs } from '@1delta/data-sdk'
|
|
197
|
+
import { prepareFetch, batchPrepared } from '@1delta/irm-sdk'
|
|
198
|
+
import { multicallRetryUniversal } from '@1delta/providers'
|
|
199
|
+
|
|
200
|
+
// 1. Initialize the registry (only pool + reserve data needed for IRM)
|
|
201
|
+
await fetchLenderMetaFromDirAndInitialize({
|
|
202
|
+
aavePools: true,
|
|
203
|
+
aaveReserves: true,
|
|
204
|
+
compoundV2Pools: true,
|
|
205
|
+
compoundV2TokenArray: true,
|
|
206
|
+
compoundV3Pools: true,
|
|
207
|
+
compoundV3BaseData: true,
|
|
208
|
+
morphoPools: true,
|
|
209
|
+
morphoTypeMarkets: true,
|
|
210
|
+
eulerConfigs: true,
|
|
211
|
+
eulerVaults: true,
|
|
212
|
+
})
|
|
213
|
+
|
|
214
|
+
// 2. Enumerate all deployments
|
|
215
|
+
const targets = []
|
|
216
|
+
for (const [lender, chains] of Object.entries(aavePools() ?? {}))
|
|
217
|
+
for (const chainId of Object.keys(chains))
|
|
218
|
+
targets.push({ lender, chainId })
|
|
219
|
+
// ... repeat for compoundV2Pools, compoundV3Pools, morphoPools, eulerConfigs
|
|
220
|
+
|
|
221
|
+
// 3. Fetch IRM data per chain
|
|
222
|
+
for (const [chainId, lenders] of Object.entries(groupByChain(targets))) {
|
|
223
|
+
const prepared = lenders
|
|
224
|
+
.map(({ lender }) => prepareFetch({ chainId, lender }))
|
|
225
|
+
.filter(Boolean)
|
|
226
|
+
const results = await batchPrepared(chainId, prepared, multicallRetryUniversal)
|
|
227
|
+
}
|
|
228
|
+
```
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.0.
|
|
7
|
+
"version": "0.0.6",
|
|
8
8
|
"description": "Deterministic initializer for lending protocol data across the stack",
|
|
9
9
|
"files": [
|
|
10
10
|
"dist"
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"typescript": "^5.9.3"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@1delta/data-sdk": "0.0.
|
|
24
|
+
"@1delta/data-sdk": "0.0.17"
|
|
25
25
|
},
|
|
26
26
|
"engines": {
|
|
27
27
|
"node": ">=20"
|