@1delta/data-sdk 0.0.20 → 0.0.22

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/index.js CHANGED
@@ -40,8 +40,12 @@ globalThis[GLOBAL_LENDER_DATA_KEY] = {
40
40
  eulerConfigs: {},
41
41
  eulerVaults: {},
42
42
  aaveV4Spokes: {},
43
- aaveV4Reserves: {},
44
- aaveV4Oracles: {}
43
+ aaveV4Oracles: {},
44
+ aaveV4Peripherals: {},
45
+ siloMarkets: {},
46
+ siloPeripherals: {},
47
+ siloMarketsV3: {},
48
+ siloPeripheralsV3: {}
45
49
  };
46
50
  function getGlobalData2() {
47
51
  return globalThis[GLOBAL_LENDER_DATA_KEY];
@@ -73,8 +77,12 @@ function initializeLenderData({
73
77
  eulerConfigsOverride,
74
78
  eulerVaultsOverride,
75
79
  aaveV4SpokesOverride,
76
- aaveV4ReservesOverride,
77
- aaveV4OraclesOverride
80
+ aaveV4OraclesOverride,
81
+ aaveV4PeripheralsOverride,
82
+ siloMarketsOverride,
83
+ siloPeripheralsOverride,
84
+ siloMarketsV3Override,
85
+ siloPeripheralsV3Override
78
86
  }) {
79
87
  const data = getGlobalData2();
80
88
  if (aaveTokensOverride) data.aaveTokens = aaveTokensOverride;
@@ -103,8 +111,14 @@ function initializeLenderData({
103
111
  if (eulerConfigsOverride) data.eulerConfigs = eulerConfigsOverride;
104
112
  if (eulerVaultsOverride) data.eulerVaults = eulerVaultsOverride;
105
113
  if (aaveV4SpokesOverride) data.aaveV4Spokes = aaveV4SpokesOverride;
106
- if (aaveV4ReservesOverride) data.aaveV4Reserves = aaveV4ReservesOverride;
107
114
  if (aaveV4OraclesOverride) data.aaveV4Oracles = aaveV4OraclesOverride;
115
+ if (aaveV4PeripheralsOverride)
116
+ data.aaveV4Peripherals = aaveV4PeripheralsOverride;
117
+ if (siloMarketsOverride) data.siloMarkets = siloMarketsOverride;
118
+ if (siloPeripheralsOverride) data.siloPeripherals = siloPeripheralsOverride;
119
+ if (siloMarketsV3Override) data.siloMarketsV3 = siloMarketsV3Override;
120
+ if (siloPeripheralsV3Override)
121
+ data.siloPeripheralsV3 = siloPeripheralsV3Override;
108
122
  }
109
123
  var aaveTokens = () => getGlobalData2()?.aaveTokens;
110
124
  var aavePools = () => getGlobalData2()?.aavePools;
@@ -132,8 +146,101 @@ var compoundV3Bulker = () => getGlobalData2()?.compoundV3Bulker;
132
146
  var eulerConfigs = () => getGlobalData2()?.eulerConfigs;
133
147
  var eulerVaults = () => getGlobalData2()?.eulerVaults;
134
148
  var aaveV4Spokes = () => getGlobalData2()?.aaveV4Spokes;
135
- var aaveV4Reserves = () => getGlobalData2()?.aaveV4Reserves;
136
149
  var aaveV4Oracles = () => getGlobalData2()?.aaveV4Oracles;
150
+ var aaveV4Peripherals = () => getGlobalData2()?.aaveV4Peripherals;
151
+ var siloMarkets = () => getGlobalData2()?.siloMarkets;
152
+ var siloPeripherals = () => getGlobalData2()?.siloPeripherals;
153
+ var siloMarketsV3 = () => getGlobalData2()?.siloMarketsV3;
154
+ var siloPeripheralsV3 = () => getGlobalData2()?.siloPeripheralsV3;
155
+ function getAaveV4SpokeEntry(chainId, lenderKey) {
156
+ const parsed = parseAaveV4SpokeLenderKey(lenderKey);
157
+ if (!parsed) return void 0;
158
+ return getGlobalData2()?.aaveV4Spokes?.[chainId]?.[parsed.spokeAddrLower];
159
+ }
160
+ function getAaveV4GatewayAddresses(chainId, lender, hubOverride) {
161
+ const c = getGlobalData2()?.aaveV4Peripherals?.[chainId];
162
+ if (!c) return {};
163
+ let hubAddr = hubOverride?.toLowerCase();
164
+ if (!hubAddr) {
165
+ const spokeEntry = getAaveV4SpokeEntry(chainId, lender);
166
+ hubAddr = spokeEntry?.reserves?.[0]?.hub?.toLowerCase();
167
+ }
168
+ const perHub = hubAddr && c.perHub?.[hubAddr] || void 0;
169
+ return {
170
+ nativeGateway: perHub?.nativeGateway ?? c.nativeGateway,
171
+ signatureGateway: perHub?.signatureGateway ?? c.signatureGateway
172
+ };
173
+ }
174
+ function getAaveV4SpokePeripherals(chainId, lenderKey) {
175
+ const parsed = parseAaveV4SpokeLenderKey(lenderKey);
176
+ if (!parsed) return void 0;
177
+ return getGlobalData2()?.aaveV4Peripherals?.[chainId]?.perSpoke?.[parsed.spokeAddrLower];
178
+ }
179
+ function getAaveV4PositionManagers(chainId, lenderKey) {
180
+ const meta = getAaveV4SpokePeripherals(chainId, lenderKey);
181
+ if (!meta?.positionManagers) return [];
182
+ return meta.positionManagers.filter((pm) => pm.active !== false && pm.address).map((pm) => pm.address.toLowerCase());
183
+ }
184
+ function findAaveV4PositionManager(chainId, lenderKey, nameQuery) {
185
+ const meta = getAaveV4SpokePeripherals(chainId, lenderKey);
186
+ if (!meta?.positionManagers) return void 0;
187
+ const q = nameQuery.toLowerCase();
188
+ const hit = meta.positionManagers.find(
189
+ (pm) => pm.active !== false && pm.address && (pm.name ?? "").toLowerCase().includes(q)
190
+ );
191
+ return hit?.address?.toLowerCase();
192
+ }
193
+ function aaveV4SpokeLenderKey(spoke) {
194
+ if (!spoke || !spoke.startsWith("0x") || spoke.length !== 42) {
195
+ throw new Error(`aaveV4SpokeLenderKey: invalid spoke address ${spoke}`);
196
+ }
197
+ return `AAVE_V4_${spoke.slice(2).toUpperCase()}`;
198
+ }
199
+ function parseAaveV4SpokeLenderKey(lenderKey) {
200
+ const match = lenderKey.match(/^AAVE_V4_([0-9A-F]{40})$/);
201
+ if (!match) return void 0;
202
+ return { spokeAddrLower: "0x" + match[1].toLowerCase() };
203
+ }
204
+ function siloV2LenderKey(siloConfig) {
205
+ if (!siloConfig || !siloConfig.startsWith("0x") || siloConfig.length !== 42) {
206
+ throw new Error(`siloV2LenderKey: invalid siloConfig address ${siloConfig}`);
207
+ }
208
+ return `SILO_V2_${siloConfig.slice(2).toUpperCase()}`;
209
+ }
210
+ function parseSiloV2LenderKey(lenderKey) {
211
+ const match = lenderKey.match(/^SILO_V2_([0-9A-F]{40})$/);
212
+ if (!match) return void 0;
213
+ return { siloConfigAddrLower: "0x" + match[1].toLowerCase() };
214
+ }
215
+ function getSiloV2MarketEntry(chainId, lenderKey) {
216
+ const parsed = parseSiloV2LenderKey(lenderKey);
217
+ if (!parsed) return void 0;
218
+ const list = getGlobalData2()?.siloMarkets?.[chainId];
219
+ if (!list) return void 0;
220
+ return list.find(
221
+ (m) => m.siloConfig.toLowerCase() === parsed.siloConfigAddrLower
222
+ );
223
+ }
224
+ function siloV3LenderKey(siloConfig) {
225
+ if (!siloConfig || !siloConfig.startsWith("0x") || siloConfig.length !== 42) {
226
+ throw new Error(`siloV3LenderKey: invalid siloConfig address ${siloConfig}`);
227
+ }
228
+ return `SILO_V3_${siloConfig.slice(2).toUpperCase()}`;
229
+ }
230
+ function parseSiloV3LenderKey(lenderKey) {
231
+ const match = lenderKey.match(/^SILO_V3_([0-9A-F]{40})$/);
232
+ if (!match) return void 0;
233
+ return { siloConfigAddrLower: "0x" + match[1].toLowerCase() };
234
+ }
235
+ function getSiloV3MarketEntry(chainId, lenderKey) {
236
+ const parsed = parseSiloV3LenderKey(lenderKey);
237
+ if (!parsed) return void 0;
238
+ const list = getGlobalData2()?.siloMarketsV3?.[chainId];
239
+ if (!list) return void 0;
240
+ return list.find(
241
+ (m) => m.siloConfig.toLowerCase() === parsed.siloConfigAddrLower
242
+ );
243
+ }
137
244
 
138
245
  // src/tokens.ts
139
246
  var getListUrl = (chainId) => `https://raw.githubusercontent.com/1delta-DAO/token-lists/main/${chainId}.json`;
@@ -157,7 +264,8 @@ exports.aavePools = aavePools;
157
264
  exports.aaveReserves = aaveReserves;
158
265
  exports.aaveTokens = aaveTokens;
159
266
  exports.aaveV4Oracles = aaveV4Oracles;
160
- exports.aaveV4Reserves = aaveV4Reserves;
267
+ exports.aaveV4Peripherals = aaveV4Peripherals;
268
+ exports.aaveV4SpokeLenderKey = aaveV4SpokeLenderKey;
161
269
  exports.aaveV4Spokes = aaveV4Spokes;
162
270
  exports.aaveWethGateway = aaveWethGateway;
163
271
  exports.chains = chains;
@@ -175,6 +283,13 @@ exports.eulerConfigs = eulerConfigs;
175
283
  exports.eulerVaults = eulerVaults;
176
284
  exports.fetchTokenList = fetchTokenList;
177
285
  exports.fetchTokenLists = fetchTokenLists;
286
+ exports.findAaveV4PositionManager = findAaveV4PositionManager;
287
+ exports.getAaveV4GatewayAddresses = getAaveV4GatewayAddresses;
288
+ exports.getAaveV4PositionManagers = getAaveV4PositionManagers;
289
+ exports.getAaveV4SpokeEntry = getAaveV4SpokeEntry;
290
+ exports.getAaveV4SpokePeripherals = getAaveV4SpokePeripherals;
291
+ exports.getSiloV2MarketEntry = getSiloV2MarketEntry;
292
+ exports.getSiloV3MarketEntry = getSiloV3MarketEntry;
178
293
  exports.initConfig = initConfig;
179
294
  exports.initializeChainData = initializeChainData;
180
295
  exports.initializeLenderData = initializeLenderData;
@@ -184,3 +299,12 @@ exports.morphoOracles = morphoOracles;
184
299
  exports.morphoPools = morphoPools;
185
300
  exports.morphoTypeMarkets = morphoTypeMarkets;
186
301
  exports.morphoTypeOracles = morphoTypeOracles;
302
+ exports.parseAaveV4SpokeLenderKey = parseAaveV4SpokeLenderKey;
303
+ exports.parseSiloV2LenderKey = parseSiloV2LenderKey;
304
+ exports.parseSiloV3LenderKey = parseSiloV3LenderKey;
305
+ exports.siloMarkets = siloMarkets;
306
+ exports.siloMarketsV3 = siloMarketsV3;
307
+ exports.siloPeripherals = siloPeripherals;
308
+ exports.siloPeripheralsV3 = siloPeripheralsV3;
309
+ exports.siloV2LenderKey = siloV2LenderKey;
310
+ exports.siloV3LenderKey = siloV3LenderKey;
package/dist/index.mjs CHANGED
@@ -38,8 +38,12 @@ globalThis[GLOBAL_LENDER_DATA_KEY] = {
38
38
  eulerConfigs: {},
39
39
  eulerVaults: {},
40
40
  aaveV4Spokes: {},
41
- aaveV4Reserves: {},
42
- aaveV4Oracles: {}
41
+ aaveV4Oracles: {},
42
+ aaveV4Peripherals: {},
43
+ siloMarkets: {},
44
+ siloPeripherals: {},
45
+ siloMarketsV3: {},
46
+ siloPeripheralsV3: {}
43
47
  };
44
48
  function getGlobalData2() {
45
49
  return globalThis[GLOBAL_LENDER_DATA_KEY];
@@ -71,8 +75,12 @@ function initializeLenderData({
71
75
  eulerConfigsOverride,
72
76
  eulerVaultsOverride,
73
77
  aaveV4SpokesOverride,
74
- aaveV4ReservesOverride,
75
- aaveV4OraclesOverride
78
+ aaveV4OraclesOverride,
79
+ aaveV4PeripheralsOverride,
80
+ siloMarketsOverride,
81
+ siloPeripheralsOverride,
82
+ siloMarketsV3Override,
83
+ siloPeripheralsV3Override
76
84
  }) {
77
85
  const data = getGlobalData2();
78
86
  if (aaveTokensOverride) data.aaveTokens = aaveTokensOverride;
@@ -101,8 +109,14 @@ function initializeLenderData({
101
109
  if (eulerConfigsOverride) data.eulerConfigs = eulerConfigsOverride;
102
110
  if (eulerVaultsOverride) data.eulerVaults = eulerVaultsOverride;
103
111
  if (aaveV4SpokesOverride) data.aaveV4Spokes = aaveV4SpokesOverride;
104
- if (aaveV4ReservesOverride) data.aaveV4Reserves = aaveV4ReservesOverride;
105
112
  if (aaveV4OraclesOverride) data.aaveV4Oracles = aaveV4OraclesOverride;
113
+ if (aaveV4PeripheralsOverride)
114
+ data.aaveV4Peripherals = aaveV4PeripheralsOverride;
115
+ if (siloMarketsOverride) data.siloMarkets = siloMarketsOverride;
116
+ if (siloPeripheralsOverride) data.siloPeripherals = siloPeripheralsOverride;
117
+ if (siloMarketsV3Override) data.siloMarketsV3 = siloMarketsV3Override;
118
+ if (siloPeripheralsV3Override)
119
+ data.siloPeripheralsV3 = siloPeripheralsV3Override;
106
120
  }
107
121
  var aaveTokens = () => getGlobalData2()?.aaveTokens;
108
122
  var aavePools = () => getGlobalData2()?.aavePools;
@@ -130,8 +144,101 @@ var compoundV3Bulker = () => getGlobalData2()?.compoundV3Bulker;
130
144
  var eulerConfigs = () => getGlobalData2()?.eulerConfigs;
131
145
  var eulerVaults = () => getGlobalData2()?.eulerVaults;
132
146
  var aaveV4Spokes = () => getGlobalData2()?.aaveV4Spokes;
133
- var aaveV4Reserves = () => getGlobalData2()?.aaveV4Reserves;
134
147
  var aaveV4Oracles = () => getGlobalData2()?.aaveV4Oracles;
148
+ var aaveV4Peripherals = () => getGlobalData2()?.aaveV4Peripherals;
149
+ var siloMarkets = () => getGlobalData2()?.siloMarkets;
150
+ var siloPeripherals = () => getGlobalData2()?.siloPeripherals;
151
+ var siloMarketsV3 = () => getGlobalData2()?.siloMarketsV3;
152
+ var siloPeripheralsV3 = () => getGlobalData2()?.siloPeripheralsV3;
153
+ function getAaveV4SpokeEntry(chainId, lenderKey) {
154
+ const parsed = parseAaveV4SpokeLenderKey(lenderKey);
155
+ if (!parsed) return void 0;
156
+ return getGlobalData2()?.aaveV4Spokes?.[chainId]?.[parsed.spokeAddrLower];
157
+ }
158
+ function getAaveV4GatewayAddresses(chainId, lender, hubOverride) {
159
+ const c = getGlobalData2()?.aaveV4Peripherals?.[chainId];
160
+ if (!c) return {};
161
+ let hubAddr = hubOverride?.toLowerCase();
162
+ if (!hubAddr) {
163
+ const spokeEntry = getAaveV4SpokeEntry(chainId, lender);
164
+ hubAddr = spokeEntry?.reserves?.[0]?.hub?.toLowerCase();
165
+ }
166
+ const perHub = hubAddr && c.perHub?.[hubAddr] || void 0;
167
+ return {
168
+ nativeGateway: perHub?.nativeGateway ?? c.nativeGateway,
169
+ signatureGateway: perHub?.signatureGateway ?? c.signatureGateway
170
+ };
171
+ }
172
+ function getAaveV4SpokePeripherals(chainId, lenderKey) {
173
+ const parsed = parseAaveV4SpokeLenderKey(lenderKey);
174
+ if (!parsed) return void 0;
175
+ return getGlobalData2()?.aaveV4Peripherals?.[chainId]?.perSpoke?.[parsed.spokeAddrLower];
176
+ }
177
+ function getAaveV4PositionManagers(chainId, lenderKey) {
178
+ const meta = getAaveV4SpokePeripherals(chainId, lenderKey);
179
+ if (!meta?.positionManagers) return [];
180
+ return meta.positionManagers.filter((pm) => pm.active !== false && pm.address).map((pm) => pm.address.toLowerCase());
181
+ }
182
+ function findAaveV4PositionManager(chainId, lenderKey, nameQuery) {
183
+ const meta = getAaveV4SpokePeripherals(chainId, lenderKey);
184
+ if (!meta?.positionManagers) return void 0;
185
+ const q = nameQuery.toLowerCase();
186
+ const hit = meta.positionManagers.find(
187
+ (pm) => pm.active !== false && pm.address && (pm.name ?? "").toLowerCase().includes(q)
188
+ );
189
+ return hit?.address?.toLowerCase();
190
+ }
191
+ function aaveV4SpokeLenderKey(spoke) {
192
+ if (!spoke || !spoke.startsWith("0x") || spoke.length !== 42) {
193
+ throw new Error(`aaveV4SpokeLenderKey: invalid spoke address ${spoke}`);
194
+ }
195
+ return `AAVE_V4_${spoke.slice(2).toUpperCase()}`;
196
+ }
197
+ function parseAaveV4SpokeLenderKey(lenderKey) {
198
+ const match = lenderKey.match(/^AAVE_V4_([0-9A-F]{40})$/);
199
+ if (!match) return void 0;
200
+ return { spokeAddrLower: "0x" + match[1].toLowerCase() };
201
+ }
202
+ function siloV2LenderKey(siloConfig) {
203
+ if (!siloConfig || !siloConfig.startsWith("0x") || siloConfig.length !== 42) {
204
+ throw new Error(`siloV2LenderKey: invalid siloConfig address ${siloConfig}`);
205
+ }
206
+ return `SILO_V2_${siloConfig.slice(2).toUpperCase()}`;
207
+ }
208
+ function parseSiloV2LenderKey(lenderKey) {
209
+ const match = lenderKey.match(/^SILO_V2_([0-9A-F]{40})$/);
210
+ if (!match) return void 0;
211
+ return { siloConfigAddrLower: "0x" + match[1].toLowerCase() };
212
+ }
213
+ function getSiloV2MarketEntry(chainId, lenderKey) {
214
+ const parsed = parseSiloV2LenderKey(lenderKey);
215
+ if (!parsed) return void 0;
216
+ const list = getGlobalData2()?.siloMarkets?.[chainId];
217
+ if (!list) return void 0;
218
+ return list.find(
219
+ (m) => m.siloConfig.toLowerCase() === parsed.siloConfigAddrLower
220
+ );
221
+ }
222
+ function siloV3LenderKey(siloConfig) {
223
+ if (!siloConfig || !siloConfig.startsWith("0x") || siloConfig.length !== 42) {
224
+ throw new Error(`siloV3LenderKey: invalid siloConfig address ${siloConfig}`);
225
+ }
226
+ return `SILO_V3_${siloConfig.slice(2).toUpperCase()}`;
227
+ }
228
+ function parseSiloV3LenderKey(lenderKey) {
229
+ const match = lenderKey.match(/^SILO_V3_([0-9A-F]{40})$/);
230
+ if (!match) return void 0;
231
+ return { siloConfigAddrLower: "0x" + match[1].toLowerCase() };
232
+ }
233
+ function getSiloV3MarketEntry(chainId, lenderKey) {
234
+ const parsed = parseSiloV3LenderKey(lenderKey);
235
+ if (!parsed) return void 0;
236
+ const list = getGlobalData2()?.siloMarketsV3?.[chainId];
237
+ if (!list) return void 0;
238
+ return list.find(
239
+ (m) => m.siloConfig.toLowerCase() === parsed.siloConfigAddrLower
240
+ );
241
+ }
135
242
 
136
243
  // src/tokens.ts
137
244
  var getListUrl = (chainId) => `https://raw.githubusercontent.com/1delta-DAO/token-lists/main/${chainId}.json`;
@@ -149,4 +256,4 @@ async function fetchTokenLists(chainIds) {
149
256
  return Object.fromEntries(results);
150
257
  }
151
258
 
152
- export { aaveOracles, aaveOraclesConfig, aavePools, aaveReserves, aaveTokens, aaveV4Oracles, aaveV4Reserves, aaveV4Spokes, aaveWethGateway, chains, compoundV2Oracles, compoundV2Pools, compoundV2Reserves, compoundV2TokenArray, compoundV2Tokens, compoundV3BaseData, compoundV3Bulker, compoundV3OraclesData, compoundV3Pools, compoundV3Reserves, eulerConfigs, eulerVaults, fetchTokenList, fetchTokenLists, initConfig, initializeChainData, initializeLenderData, listaNativeProvider, morphoBundler3, morphoOracles, morphoPools, morphoTypeMarkets, morphoTypeOracles };
259
+ export { aaveOracles, aaveOraclesConfig, aavePools, aaveReserves, aaveTokens, aaveV4Oracles, aaveV4Peripherals, aaveV4SpokeLenderKey, aaveV4Spokes, aaveWethGateway, chains, compoundV2Oracles, compoundV2Pools, compoundV2Reserves, compoundV2TokenArray, compoundV2Tokens, compoundV3BaseData, compoundV3Bulker, compoundV3OraclesData, compoundV3Pools, compoundV3Reserves, eulerConfigs, eulerVaults, fetchTokenList, fetchTokenLists, findAaveV4PositionManager, getAaveV4GatewayAddresses, getAaveV4PositionManagers, getAaveV4SpokeEntry, getAaveV4SpokePeripherals, getSiloV2MarketEntry, getSiloV3MarketEntry, initConfig, initializeChainData, initializeLenderData, listaNativeProvider, morphoBundler3, morphoOracles, morphoPools, morphoTypeMarkets, morphoTypeOracles, parseAaveV4SpokeLenderKey, parseSiloV2LenderKey, parseSiloV3LenderKey, siloMarkets, siloMarketsV3, siloPeripherals, siloPeripheralsV3, siloV2LenderKey, siloV3LenderKey };
package/dist/lending.d.ts CHANGED
@@ -174,18 +174,113 @@ type EulerVaultsType = {
174
174
  [chainId: string]: EulerVaultEntry[];
175
175
  };
176
176
  };
177
- type AaveV4SpokeEntry = {
177
+ export type SiloHalfStatic = {
178
+ /** silo (vault) address */
179
+ silo: string;
180
+ /** underlying borrowable asset for this side */
181
+ token: string;
182
+ /** ERC-20 decimals for `token`, cached to avoid an extra RPC */
183
+ decimals: number;
184
+ /** Optional symbol cache for UI; not consumed by the fetcher */
185
+ symbol?: string;
186
+ /** Share-token addresses (for user-data fetchers / liquidations) */
187
+ protectedShareToken: string;
188
+ collateralShareToken: string;
189
+ debtShareToken: string;
190
+ /** Per-side oracles (1e18-scaled price quoting) */
191
+ solvencyOracle: string;
192
+ maxLtvOracle: string;
193
+ /** Interest rate model contract */
194
+ interestRateModel: string;
195
+ /** LTV at 1e18 scale */
196
+ maxLtv: string;
197
+ /** Liquidation threshold (LLTV) at 1e18 scale */
198
+ lt: string;
199
+ /** Target LTV after liquidation (1e18) */
200
+ liquidationTargetLtv: string;
201
+ /** Fee parameters (1e18) */
202
+ liquidationFee: string;
203
+ flashloanFee: string;
204
+ daoFee: string;
205
+ deployerFee: string;
206
+ /** Optional hook receiver / quote-before flag */
207
+ hookReceiver?: string;
208
+ callBeforeQuote?: boolean;
209
+ };
210
+ export type SiloMarketEntry = {
211
+ /** Shared SiloConfig address (one per pair) */
212
+ siloConfig: string;
213
+ /** Optional human-readable name from the factory event / curated list */
214
+ name?: string;
215
+ silo0: SiloHalfStatic;
216
+ silo1: SiloHalfStatic;
217
+ };
218
+ /**
219
+ * chainId → list of (silo0, silo1) pairs.
220
+ *
221
+ * Stored as an array to match the on-disk `silo-v2-markets.json` shape.
222
+ * Per-chain pair counts are small (~100 max), so the linear lookup in
223
+ * `getSiloV2MarketEntry` is fine. If that ever changes, build an index
224
+ * lazily here.
225
+ */
226
+ export type SiloMarketsType = {
227
+ [chainId: string]: SiloMarketEntry[];
228
+ };
229
+ /**
230
+ * Per-chain Silo v2 peripheral / singleton addresses.
231
+ *
232
+ * Both `lens` and `factory` are deployed once per chain and shared by every
233
+ * Silo v2 market on that chain, so they live together in one map instead of
234
+ * being split across `siloLens` / `siloFactory`. Add new chain-wide
235
+ * singletons (e.g. `siloRouter`, `siloIncentivesController`) here.
236
+ */
237
+ export type SiloPeripheralsEntry = {
238
+ /** SiloLens (v2) — exposes getDepositAPR / getBorrowAPR / getUtilization */
239
+ lens: string;
240
+ /** SiloFactory — used by the initializer to discover deployed silo pairs */
241
+ factory: string;
242
+ /** Optional: router / wrapped-native gateway, populated when needed */
243
+ router?: string;
244
+ /** Optional: incentives controller for reward APR */
245
+ incentivesController?: string;
246
+ };
247
+ /** chainId → Silo v2 peripheral addresses */
248
+ export type SiloPeripheralsType = {
249
+ [chainId: string]: SiloPeripheralsEntry;
250
+ };
251
+ export type AaveV4ReserveEntry = {
252
+ reserveId: number;
253
+ /** Hub-side asset id (scoped to the entry's `hub`) */
254
+ assetId: number;
255
+ underlying: string;
256
+ /**
257
+ * Per-reserve hub address. Set at reserve init on-chain — different
258
+ * reserves on the same spoke can have different hubs.
259
+ */
260
+ hub: string;
261
+ /** Optional per-reserve oracle override (defaults to spoke.oracle) */
262
+ oracle?: string;
263
+ oracleDecimals?: number;
264
+ };
265
+ export type AaveV4SpokeEntry = {
178
266
  spoke: string;
179
267
  oracle: string;
180
268
  label: string;
181
- hub?: string;
182
- };
183
- type AaveV4SpokesType = {
184
- [fork: string]: {
185
- [chainId: string]: AaveV4SpokeEntry[];
269
+ dynamicConfigKeyMax?: number;
270
+ /**
271
+ * UI/grouping hint only (`AAVE_V4_CORE` / `AAVE_V4_PLUS` / `AAVE_V4_PRIME`).
272
+ * NOT used for routing or lender keying.
273
+ */
274
+ baseHubAttribution?: string;
275
+ reserves: AaveV4ReserveEntry[];
276
+ };
277
+ /** Top-level: chainId → spokeAddrLower → entry */
278
+ export type AaveV4SpokesType = {
279
+ [chainId: string]: {
280
+ [spokeAddrLower: string]: AaveV4SpokeEntry;
186
281
  };
187
282
  };
188
- type AaveV4OracleEntry = {
283
+ export type AaveV4OracleEntry = {
189
284
  underlying: string;
190
285
  spoke: string;
191
286
  reserveId: number;
@@ -193,25 +288,48 @@ type AaveV4OracleEntry = {
193
288
  decimals?: number;
194
289
  source?: string;
195
290
  };
196
- type AaveV4OraclesType = {
197
- [fork: string]: {
198
- [chainId: string]: AaveV4OracleEntry[];
291
+ /** Top-level chainId only — no fork dimension. */
292
+ export type AaveV4OraclesType = {
293
+ [chainId: string]: AaveV4OracleEntry[];
294
+ };
295
+ export type AaveV4PerHubGateways = {
296
+ nativeGateway?: string;
297
+ signatureGateway?: string;
298
+ };
299
+ /**
300
+ * Per-spoke peripherals — extra metadata the lender-metadata repo carries
301
+ * for spoke-scoped concerns (curated names, position manager registry, …).
302
+ * Opaque to the data-sdk; surfaced as `any` so consumers (worker-api,
303
+ * frontend) can read it without dragging the schema into this package.
304
+ */
305
+ export type AaveV4PerSpokeMeta = {
306
+ spokeName?: string;
307
+ spokeId?: string;
308
+ positionManagers?: Array<{
309
+ name?: string;
310
+ address: string;
311
+ active?: boolean;
312
+ }>;
313
+ [k: string]: unknown;
314
+ };
315
+ export type AaveV4ChainPeripherals = {
316
+ /** Chain-wide fallback gateway addresses */
317
+ nativeGateway?: string;
318
+ signatureGateway?: string;
319
+ /** Per-hub gateway overrides (keyed by lowercase hub address) */
320
+ perHub?: {
321
+ [hubAddrLower: string]: AaveV4PerHubGateways;
199
322
  };
200
- };
201
- type AaveV4ReserveEntry = {
202
- reserveId: number;
203
- assetId: number;
204
- underlying: string;
205
- };
206
- type AaveV4ReservesType = {
207
- [fork: string]: {
208
- [chainId: string]: {
209
- [spokeAddress: string]: AaveV4ReserveEntry[];
210
- };
323
+ /** Per-spoke metadata (curated names, position managers, …) */
324
+ perSpoke?: {
325
+ [spokeAddrLower: string]: AaveV4PerSpokeMeta;
211
326
  };
212
327
  };
328
+ export type AaveV4PeripheralsType = {
329
+ [chainId: string]: AaveV4ChainPeripherals;
330
+ };
213
331
  /** Override datas used in the SDK - works across all module instances */
214
- export declare function initializeLenderData({ aaveTokensOverride, aavePoolsOverride, aaveOraclesOverride, compoundV2OraclesOverride, compoundV3OraclesDataOverride, compoundV3PoolsOverride, compoundV3BaseDataOverride, morphoPoolsOverride, compoundV2TokensOverride, compoundV2TokenArrayOverride, compoundV2PoolsOverride, initConfigOverride, aaveReservesOverride, compoundV3ReservesOverride, compoundV2ReservesOverride, morphoOraclesOverride, morphoTypeOraclesOverride, morphoTypeMarketsOverride, aaveOraclesConfigOverride, aaveWethGatewayOverride, morphoBundler3Override, listaNativeProviderOverride, compoundV3BulkerOverride, eulerConfigsOverride, eulerVaultsOverride, aaveV4SpokesOverride, aaveV4ReservesOverride, aaveV4OraclesOverride, }: {
332
+ export declare function initializeLenderData({ aaveTokensOverride, aavePoolsOverride, aaveOraclesOverride, compoundV2OraclesOverride, compoundV3OraclesDataOverride, compoundV3PoolsOverride, compoundV3BaseDataOverride, morphoPoolsOverride, compoundV2TokensOverride, compoundV2TokenArrayOverride, compoundV2PoolsOverride, initConfigOverride, aaveReservesOverride, compoundV3ReservesOverride, compoundV2ReservesOverride, morphoOraclesOverride, morphoTypeOraclesOverride, morphoTypeMarketsOverride, aaveOraclesConfigOverride, aaveWethGatewayOverride, morphoBundler3Override, listaNativeProviderOverride, compoundV3BulkerOverride, eulerConfigsOverride, eulerVaultsOverride, aaveV4SpokesOverride, aaveV4OraclesOverride, aaveV4PeripheralsOverride, siloMarketsOverride, siloPeripheralsOverride, siloMarketsV3Override, siloPeripheralsV3Override, }: {
215
333
  aaveTokensOverride?: AaveTokensType;
216
334
  aavePoolsOverride?: AavePoolsType;
217
335
  aaveOraclesOverride?: OracleMap;
@@ -238,8 +356,12 @@ export declare function initializeLenderData({ aaveTokensOverride, aavePoolsOver
238
356
  eulerConfigsOverride?: EulerConfigsType;
239
357
  eulerVaultsOverride?: EulerVaultsType;
240
358
  aaveV4SpokesOverride?: AaveV4SpokesType;
241
- aaveV4ReservesOverride?: AaveV4ReservesType;
242
359
  aaveV4OraclesOverride?: AaveV4OraclesType;
360
+ aaveV4PeripheralsOverride?: AaveV4PeripheralsType;
361
+ siloMarketsOverride?: SiloMarketsType;
362
+ siloPeripheralsOverride?: SiloPeripheralsType;
363
+ siloMarketsV3Override?: SiloMarketsType;
364
+ siloPeripheralsV3Override?: SiloPeripheralsType;
243
365
  }): void;
244
366
  export declare const aaveTokens: () => AaveTokensType;
245
367
  export declare const aavePools: () => AavePoolsType;
@@ -267,6 +389,146 @@ export declare const compoundV3Bulker: () => CompoundV3BulkerType;
267
389
  export declare const eulerConfigs: () => EulerConfigsType;
268
390
  export declare const eulerVaults: () => EulerVaultsType;
269
391
  export declare const aaveV4Spokes: () => AaveV4SpokesType;
270
- export declare const aaveV4Reserves: () => AaveV4ReservesType;
271
392
  export declare const aaveV4Oracles: () => AaveV4OraclesType;
393
+ export declare const aaveV4Peripherals: () => AaveV4PeripheralsType;
394
+ export declare const siloMarkets: () => SiloMarketsType;
395
+ export declare const siloPeripherals: () => SiloPeripheralsType;
396
+ export declare const siloMarketsV3: () => SiloMarketsType;
397
+ export declare const siloPeripheralsV3: () => SiloPeripheralsType;
398
+ /**
399
+ * Look up the spoke entry for a per-spoke V4 lender key (`AAVE_V4_<HEX>`).
400
+ * Returns `undefined` if no entry exists for that chain/spoke.
401
+ */
402
+ export declare function getAaveV4SpokeEntry(chainId: string, lenderKey: string): AaveV4SpokeEntry | undefined;
403
+ /**
404
+ * Native / signature gateway addresses for Aave V4.
405
+ *
406
+ * Resolves the spoke from the per-spoke lender key (`AAVE_V4_<HEX>`),
407
+ * picks the spoke's first reserve to learn its hub, and looks up
408
+ * `peripherals[chainId].perHub[hub]`. Falls back to the chain-level
409
+ * default gateways if no per-hub override is set.
410
+ *
411
+ * If the caller passes a hub address directly via `hubOverride`, that
412
+ * takes precedence.
413
+ */
414
+ export declare function getAaveV4GatewayAddresses(chainId: string, lender: string, hubOverride?: string): {
415
+ nativeGateway?: string;
416
+ signatureGateway?: string;
417
+ };
418
+ /**
419
+ * Look up the per-spoke peripherals metadata for a V4 spoke.
420
+ *
421
+ * Sourced from `aave-v4-peripherals.json` `perSpoke[<spokeAddrLower>]`.
422
+ * Carries curated extras the metadata team maintains alongside the core
423
+ * registry — most usefully the position-manager registry. Returns
424
+ * `undefined` if no entry exists for the spoke or if the lender key is
425
+ * not a per-spoke V4 key.
426
+ *
427
+ * Note: the spoke's `label` (curated UI name) lives directly on the
428
+ * `AaveV4SpokeEntry` from `aaveV4Spokes()` — `perSpoke.spokeName` is a
429
+ * duplicate of that and is intentionally not surfaced through the public-
430
+ * data normalizer. Read it through this helper if a consumer needs the
431
+ * exact value from the peripherals file.
432
+ */
433
+ export declare function getAaveV4SpokePeripherals(chainId: string, lenderKey: string): AaveV4PerSpokeMeta | undefined;
434
+ /**
435
+ * Active position-manager addresses for an Aave V4 spoke.
436
+ *
437
+ * Returns the lowercase addresses of every entry in
438
+ * `perSpoke[<spoke>].positionManagers` whose `active` flag is truthy.
439
+ * Empty array if the spoke has no peripherals entry or no active PMs.
440
+ *
441
+ * Use the `byName` lookup form when you need a specific PM (e.g. the
442
+ * native gateway). Names are matched case-insensitively against the
443
+ * curated `name` field; partial matches are accepted.
444
+ */
445
+ export declare function getAaveV4PositionManagers(chainId: string, lenderKey: string): string[];
446
+ /**
447
+ * Look up a single position-manager address by curated name (partial,
448
+ * case-insensitive). Returns `undefined` if no match. Useful for
449
+ * targeting specific PMs like `"native gateway"` or `"signature gateway"`
450
+ * without hardcoding the addresses.
451
+ */
452
+ export declare function findAaveV4PositionManager(chainId: string, lenderKey: string, nameQuery: string): string | undefined;
453
+ /**
454
+ * Synthesize the per-spoke lender key for an Aave V4 spoke.
455
+ *
456
+ * Mirrors the Morpho `MORPHO_BLUE_<HEX_NO_0X_UPPER>` convention so the rest
457
+ * of the codebase can treat each spoke as an isolated market — exactly like a
458
+ * Morpho Blue market or a Compound V3 Comet — without any V4-specific logic.
459
+ *
460
+ * Format: `AAVE_V4_${spokeAddr.slice(2).toUpperCase()}`
461
+ *
462
+ * Example:
463
+ * spoke = "0x94e7a5dcbe816e498b89ab752661904e2f56c485"
464
+ * → = "AAVE_V4_94E7A5DCBE816E498B89AB752661904E2F56C485"
465
+ *
466
+ * The full spoke address is preserved (no truncation) so the key is globally
467
+ * unique and stable across spoke implementation upgrades (proxy address).
468
+ * Note: chainId is intentionally NOT in the lender token — the same spoke
469
+ * address can in principle exist on multiple chains via deterministic
470
+ * deploys, and chain scoping happens at the marketUid level instead.
471
+ *
472
+ * `isAaveV4Type()` continues to work because it uses `startsWith('AAVE_V4')`.
473
+ */
474
+ export declare function aaveV4SpokeLenderKey(spoke: string): string;
475
+ /**
476
+ * Inverse of `aaveV4SpokeLenderKey`: given a per-spoke lender key, return
477
+ * `{ spokeAddrLower }`. Returns `undefined` if the key isn't a per-spoke V4
478
+ * key (e.g. someone passed the bare prefix `AAVE_V4`).
479
+ */
480
+ export declare function parseAaveV4SpokeLenderKey(lenderKey: string): {
481
+ spokeAddrLower: string;
482
+ } | undefined;
483
+ /**
484
+ * Synthesize the per-pair lender key for a Silo v2 market.
485
+ *
486
+ * Mirrors `aaveV4SpokeLenderKey` and the Morpho `MORPHO_BLUE_<HEX>`
487
+ * convention so each Silo pair shows up as its own isolated lender —
488
+ * exactly like an Aave V4 spoke or a Morpho Blue market — without any
489
+ * Silo-specific routing logic in the rest of the codebase.
490
+ *
491
+ * Format: `SILO_V2_${siloConfigAddr.slice(2).toUpperCase()}`
492
+ *
493
+ * Keyed by `SiloConfig` rather than either silo because the config is the
494
+ * stable, shared identity of the pair (silo0/silo1 are derived from it).
495
+ *
496
+ * `isSiloV2Type()` works on this because it matches `startsWith('SILO_V2')`.
497
+ */
498
+ export declare function siloV2LenderKey(siloConfig: string): string;
499
+ /**
500
+ * Inverse of `siloV2LenderKey`: given a per-pair lender key, return
501
+ * `{ siloConfigAddrLower }`. Returns `undefined` if the key isn't a per-pair
502
+ * Silo v2 key (e.g. someone passed the bare prefix `SILO_V2`).
503
+ */
504
+ export declare function parseSiloV2LenderKey(lenderKey: string): {
505
+ siloConfigAddrLower: string;
506
+ } | undefined;
507
+ /**
508
+ * Look up a Silo v2 market entry by per-pair lender key.
509
+ * Returns `undefined` if no entry exists for that chain/config.
510
+ */
511
+ export declare function getSiloV2MarketEntry(chainId: string, lenderKey: string): SiloMarketEntry | undefined;
512
+ /**
513
+ * Silo v3 per-pair lender key helpers.
514
+ *
515
+ * Silo v3 uses the exact same on-chain data model and metadata shape as v2
516
+ * (`SiloMarketEntry`/`SiloHalfStatic`) — only the deployment set, factory
517
+ * and indexer protocol tag differ — so v3 pairs get their own isolated
518
+ * lender token namespace (`SILO_V3_<HEX>`) and live in a separate
519
+ * `siloMarketsV3` registry slot. Keeping the two separate means a v2 and
520
+ * v3 pair with the same `SiloConfig` address could in principle coexist
521
+ * without clashing, and downstream consumers can filter by prefix.
522
+ *
523
+ * Format: `SILO_V3_${siloConfigAddr.slice(2).toUpperCase()}`
524
+ */
525
+ export declare function siloV3LenderKey(siloConfig: string): string;
526
+ export declare function parseSiloV3LenderKey(lenderKey: string): {
527
+ siloConfigAddrLower: string;
528
+ } | undefined;
529
+ /**
530
+ * Look up a Silo v3 market entry by per-pair lender key.
531
+ * Returns `undefined` if no entry exists for that chain/config.
532
+ */
533
+ export declare function getSiloV3MarketEntry(chainId: string, lenderKey: string): SiloMarketEntry | undefined;
272
534
  export {};
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.0.20",
7
+ "version": "0.0.22",
8
8
  "description": "Hold and initialize lending protocol data across a stack",
9
9
  "files": [
10
10
  "dist"