@1delta/data-sdk 0.0.41 → 0.0.43
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 +116 -0
- package/dist/index.js +479 -380
- package/dist/index.mjs +475 -383
- package/dist/lending/aave.d.ts +44 -0
- package/dist/lending/aaveV4.d.ts +168 -0
- package/dist/lending/common.d.ts +16 -0
- package/dist/lending/compoundV2.d.ts +38 -0
- package/dist/lending/compoundV3.d.ts +35 -0
- package/dist/lending/curvance.d.ts +112 -0
- package/dist/lending/dolomite.d.ts +54 -0
- package/dist/lending/dss.d.ts +139 -0
- package/dist/lending/euler.d.ts +26 -0
- package/dist/lending/exactly.d.ts +53 -0
- package/dist/lending/fluid.d.ts +53 -0
- package/dist/lending/frankencoin.d.ts +76 -0
- package/dist/lending/fraxlend.d.ts +85 -0
- package/dist/lending/gearbox.d.ts +74 -0
- package/dist/lending/index.d.ts +40 -0
- package/dist/lending/initProtocol.d.ts +11 -0
- package/dist/lending/inverse.d.ts +63 -0
- package/dist/lending/liquity.d.ts +120 -0
- package/dist/lending/lista.d.ts +6 -0
- package/dist/lending/llamalend.d.ts +208 -0
- package/dist/lending/midnight.d.ts +72 -0
- package/dist/lending/morpho.d.ts +72 -0
- package/dist/lending/registry.d.ts +140 -0
- package/dist/lending/resupply.d.ts +77 -0
- package/dist/lending/river.d.ts +61 -0
- package/dist/lending/silo.d.ts +129 -0
- package/dist/lending/teller.d.ts +68 -0
- package/dist/lending/term.d.ts +82 -0
- package/dist/lending/termMax.d.ts +65 -0
- package/package.json +1 -1
- package/dist/lending.d.ts +0 -1978
package/README.md
CHANGED
|
@@ -20,6 +20,57 @@ The SDK is a **read-only data layer** organized into three modules:
|
|
|
20
20
|
|
|
21
21
|
All data is stored in a global registry (`globalThis`) so it's shared across module instances. Data is populated once via `initializeLenderData()` / `initializeChainData()` (typically called by `@1delta/initializer-sdk`) and then accessed through getter functions.
|
|
22
22
|
|
|
23
|
+
### What belongs here — and what does not
|
|
24
|
+
|
|
25
|
+
This package is the **address book and shape registry** for every lending deployment the stack knows about. It is deliberately tiny and dependency-free.
|
|
26
|
+
|
|
27
|
+
**Belongs here**
|
|
28
|
+
|
|
29
|
+
- The TypeScript **shape** of a lender's deployment metadata (config + market roster).
|
|
30
|
+
- **Synchronous getters** over that data, plus cheap pure lookups on it (find market by address/id, "which lender keys exist on this chain", per-market lender-key synthesis and parsing).
|
|
31
|
+
- Rare, justified **built-in seeds** for protocols whose entire roster is discovered on-chain (`RESUPPLY_ETHEREUM_CONFIG`, `CURVANCE_MONAD_CONFIG`) — published metadata always wins over them.
|
|
32
|
+
|
|
33
|
+
**Does not belong here**
|
|
34
|
+
|
|
35
|
+
- Network access, RPC calls, viem — fetching lives in `@1delta/margin-fetcher` and `@1delta/initializer-sdk`.
|
|
36
|
+
- Rate math (`@1delta/irm-sdk`), calldata (`@1delta/calldata-sdk`), lender enums (`@1delta/lender-registry` — this package deliberately does **not** depend on it, so key-brand tests like `isSkyKey` are duplicated locally and must be kept in step).
|
|
37
|
+
- Hardcoded deployment rosters. Data comes from `1delta-DAO/lender-metadata` at runtime.
|
|
38
|
+
|
|
39
|
+
### Source layout
|
|
40
|
+
|
|
41
|
+
`src/lending/` holds **one module per lender family**, so a change to one protocol touches one file:
|
|
42
|
+
|
|
43
|
+
| File | Covers |
|
|
44
|
+
|------|--------|
|
|
45
|
+
| `registry.ts` | The global state: slot list, defaults, `getGlobalData()`, `initializeLenderData()`. **No runtime imports** — every other module imports from it. |
|
|
46
|
+
| `common.ts` | Shapes shared by several families (`GeneralReservesMap`, `OracleMap`). |
|
|
47
|
+
| `aave.ts` / `aaveV4.ts` | Aave V2/V3 + 70 forks; Aave V4 (per-spoke keys, gateways, position managers). |
|
|
48
|
+
| `compoundV2.ts` / `compoundV3.ts` | cToken forks; Comet forks + bulkers. |
|
|
49
|
+
| `morpho.ts` | Morpho Blue forks, oracles, MetaMorpho-shaped vault roster, Bundler3. |
|
|
50
|
+
| `euler.ts`, `silo.ts`, `fluid.ts`, `gearbox.ts`, `dolomite.ts` | Euler V2; Silo v2 + v3; Fluid resolvers/vaults; Gearbox V3.1 (per-CreditManager keys); Dolomite (+ e-mode). |
|
|
51
|
+
| `initProtocol.ts`, `lista.ts` | Init Capital; Lista native provider. |
|
|
52
|
+
| `midnight.ts`, `term.ts`, `termMax.ts`, `exactly.ts`, `teller.ts` | Fixed-rate / fixed-term lenders. |
|
|
53
|
+
| `liquity.ts`, `river.ts`, `inverse.ts`, `frankencoin.ts`, `dss.ts`, `llamalend.ts`, `resupply.ts`, `curvance.ts` | CDP-shaped lenders. `dss.ts` serves **both** USDD 2.0 and Sky from one set of types. |
|
|
54
|
+
| `index.ts` | Barrel. Re-exports every module; `getGlobalData` is intentionally kept internal. |
|
|
55
|
+
|
|
56
|
+
`src/chains.ts` and `src/tokens.ts` are the other two modules, unchanged by lender work.
|
|
57
|
+
|
|
58
|
+
### How the registry works
|
|
59
|
+
|
|
60
|
+
- One slot per data file, listed in `GlobalLenderDataRegistry` (`registry.ts`).
|
|
61
|
+
- State lives on `globalThis` under a single key, so several copies of the package still share one registry.
|
|
62
|
+
- Every getter reads through `getGlobalData()?.<slot>` — **never** a captured module constant. Workers re-run `initializeLenderData` per request, so a captured value goes stale. The same reasoning is why API base URLs are resolved through `resolveMidnightApiBase` / `resolveTermApiBase` / `termMaxApiBaseUrl` rather than read once.
|
|
63
|
+
- Every override **replaces** its slot wholesale; omitted overrides leave the slot untouched, so partial re-initialization is safe.
|
|
64
|
+
|
|
65
|
+
### Adding a lender
|
|
66
|
+
|
|
67
|
+
1. Create `src/lending/<lender>.ts`: the config/market types, then the getters (`import { getGlobalData } from './registry'`).
|
|
68
|
+
2. Add one line per data file to `GlobalLenderDataRegistry` **and** the matching `{}` line to `LENDER_DATA_DEFAULTS` in `registry.ts`. The `initializeLenderData` argument (`<slot>Override`) and its assignment are derived from those — nothing else to wire.
|
|
69
|
+
3. Export the module from `src/lending/index.ts`.
|
|
70
|
+
4. Publish the metadata files to `lender-metadata` and load them in `@1delta/initializer-sdk`.
|
|
71
|
+
|
|
72
|
+
Conventions worth following: document *why* a field exists (mutability, traps, units) next to it — most fields here are snapshots of governance-mutable on-chain state; numeric fields sourced from JSON stay `string` and callers convert with `BigInt(...)`; per-market lender keys are `LENDER_<ADDRESS_HEX_UPPER>` with a matching `parse…LenderKey`; and "is this lender live on this chain" helpers gate on the one address the provider bootstraps from.
|
|
73
|
+
|
|
23
74
|
---
|
|
24
75
|
|
|
25
76
|
## Initialization
|
|
@@ -55,6 +106,40 @@ initializeChainData({
|
|
|
55
106
|
|
|
56
107
|
All lending getters are synchronous and return data from the global registry.
|
|
57
108
|
|
|
109
|
+
### Getter index
|
|
110
|
+
|
|
111
|
+
Every family, with its module and its entry-point getters. The sections below document the older families in detail; for the rest, the module file is the reference — each type and field is commented there.
|
|
112
|
+
|
|
113
|
+
| Family | Module | Getters |
|
|
114
|
+
|--------|--------|---------|
|
|
115
|
+
| Aave V2/V3 + forks | `aave.ts` | `aavePools` · `aaveTokens` · `aaveReserves` · `aaveOracles` · `aaveOraclesConfig` · `aaveWethGateway` |
|
|
116
|
+
| Aave V4 | `aaveV4.ts` | `aaveV4Spokes` · `aaveV4Oracles` · `aaveV4Peripherals` · `getAaveV4SpokeEntry` · `getAaveV4GatewayAddresses` · `getAaveV4PositionManagers` · `aaveV4SpokeLenderKey` / `parseAaveV4SpokeLenderKey` |
|
|
117
|
+
| Compound V2 + forks | `compoundV2.ts` | `compoundV2Pools` · `compoundV2Tokens` · `compoundV2TokenArray` · `compoundV2Reserves` · `compoundV2Oracles` · `compoundV2OraclesConfig` |
|
|
118
|
+
| Compound V3 (Comet) | `compoundV3.ts` | `compoundV3Pools` · `compoundV3BaseData` · `compoundV3Reserves` · `compoundV3OraclesData` · `compoundV3Bulker` |
|
|
119
|
+
| Morpho Blue + forks | `morpho.ts` | `morphoPools` · `morphoOracles` · `morphoTypeOracles` · `morphoTypeMarkets` · `morphoTypeVaults` · `morphoBundler3` |
|
|
120
|
+
| Euler V2 | `euler.ts` | `eulerConfigs` · `eulerVaults` |
|
|
121
|
+
| Silo v2 / v3 | `silo.ts` | `siloMarkets` · `siloPeripherals` · `siloMarketsV3` · `siloPeripheralsV3` · `getSiloV2MarketEntry` / `getSiloV3MarketEntry` · `siloV2LenderKey` / `siloV3LenderKey` (+ parsers) |
|
|
122
|
+
| Fluid | `fluid.ts` | `fluidResolvers` · `fluidVaults` · `fluidChains` · `fluidVaultEntries` |
|
|
123
|
+
| Gearbox V3.1 | `gearbox.ts` | `gearboxResolvers` · `gearboxChains` · `gearboxMarketCompressor` · `gearboxAddressProviderV310` · `gearboxAccountCompressor` · `gearboxBotListV3` · `gearboxMarketConfigurators` · `gearboxV3LenderKey` (+ parser) |
|
|
124
|
+
| Dolomite | `dolomite.ts` | `dolomiteConfigs` · `dolomiteChains` · `dolomiteEmode` · `dolomiteMarketIdByToken` |
|
|
125
|
+
| Init Capital | `initProtocol.ts` | `initConfig` |
|
|
126
|
+
| Lista DAO | `lista.ts` | `listaNativeProvider` |
|
|
127
|
+
| Morpho Midnight | `midnight.ts` | `midnightConfig` · `midnightMarkets(ByChain)` · `midnightMarketById` · `setMidnightApiBase` / `resolveMidnightApiBase` |
|
|
128
|
+
| Term Finance | `term.ts` | `termConfig` · `termMarkets(ByChain)` · `termMarketById` · `setTermApiBase` / `resolveTermApiBase` |
|
|
129
|
+
| TermMax | `termMax.ts` | `termMaxConfig(ByChain)` · `termMaxChainIds` · `termMaxApiBaseUrl` · `termMaxLenderKey` (+ parser) |
|
|
130
|
+
| Exactly | `exactly.ts` | `exactlyConfig` · `exactlyMarkets(ByChain)` · `exactlyMarketByAddress` / `…ByAsset` |
|
|
131
|
+
| Teller V2 | `teller.ts` | `tellerConfig(ByChain)` · `tellerPools(ByChain)` · `tellerPoolByAddress` |
|
|
132
|
+
| Liquity V2 family | `liquity.ts` | `liquityConfig(For)` · `liquityMarkets` · `liquityBranchesByChain` · `liquityBranchByIndex` / `…ByTroveManager` · `liquityLendersByChain` |
|
|
133
|
+
| River / Satoshi | `river.ts` | `riverConfig(For)` · `riverMarkets` · `riverChainData` · `riverMarketByIndex` · `riverLendersByChain` |
|
|
134
|
+
| Inverse FiRM | `inverse.ts` | `inverseConfig(For)` · `inverseMarkets` · `inverseChainData` · `inverseMarketByAddress` · `inverseLendersByChain` |
|
|
135
|
+
| Frankencoin | `frankencoin.ts` | `frankencoinConfig(For)` · `frankencoinMarkets` · `frankencoinChainData` · `frankencoinMarketByPosition` · `frankencoinLendersByChain` |
|
|
136
|
+
| USDD 2.0 / Sky (dss) | `dss.ts` | `usdd*` and `sky*` getters, plus the brand-agnostic `dssConfigFor` · `dssChainData` · `dssMarketByIlk` · `dssDebtToken` · `dssDebtJoin` |
|
|
137
|
+
| Curve LlamaLend | `llamalend.ts` | `llamaLendConfig(For)` · `llamaLendChainData` · `llamaLendMarketByController` / `…ByVault` · `llamaLendSupportsDelegation` / `…SupportsLeverage` · `llamaLendLeverageZap` · `llamaLendLenderKey` (+ parser) |
|
|
138
|
+
| Resupply | `resupply.ts` | `resupplyConfig(For)` · `resupplyLendersByChain` · `RESUPPLY_ETHEREUM_CONFIG` |
|
|
139
|
+
| Curvance | `curvance.ts` | `curvanceConfig(For)` · `curvanceLendersByChain` · `curvancePositionManager(sFor)` · `CURVANCE_MONAD_CONFIG` |
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
58
143
|
### Aave (V2 / V3 / all forks)
|
|
59
144
|
|
|
60
145
|
Covers: AAVE_V3, SPARK, LENDLE, ZEROLEND, AVALON, RADIANT_V2, KINZA, YLDR, and 70+ other forks.
|
|
@@ -691,3 +776,34 @@ All deployment data originates from the `1delta-DAO/lender-metadata` GitHub repo
|
|
|
691
776
|
| `data/euler-vaults.json` | `eulerVaults()` |
|
|
692
777
|
| `config/midnight.json` | `midnightConfig()` |
|
|
693
778
|
| `data/midnight-markets.json` | `midnightMarkets()` |
|
|
779
|
+
| `config/aave-oracles-config.json` | `aaveOraclesConfig()` |
|
|
780
|
+
| `config/compound-v2-oracles-config.json` | `compoundV2OraclesConfig()` |
|
|
781
|
+
| `config/aave-weth-gateway.json` | `aaveWethGateway()` |
|
|
782
|
+
| `data/aave-oracles.json` / `data/compound-v2-oracles.json` | `aaveOracles()` / `compoundV2Oracles()` |
|
|
783
|
+
| `data/compound-v3-oracles-data.json` | `compoundV3OraclesData()` |
|
|
784
|
+
| `data/compound-v3-bulkers.json` | `compoundV3Bulker()` |
|
|
785
|
+
| `config/morpho-type-markets.json` | `morphoTypeMarkets()` |
|
|
786
|
+
| `data/morpho-oracles.json` / `data/morpho-type-oracles.json` | `morphoOracles()` / `morphoTypeOracles()` |
|
|
787
|
+
| `data/morpho-type-vaults.json` | `morphoTypeVaults()` |
|
|
788
|
+
| `data/morpho-bundler3.json` | `morphoBundler3()` |
|
|
789
|
+
| `data/init-config.json` | `initConfig()` |
|
|
790
|
+
| `data/lista-providers.json` | `listaNativeProvider()` |
|
|
791
|
+
| `data/aave-v4-spokes.json` / `data/aave-v4-oracles.json` / `config/aave-v4-peripherals.json` | `aaveV4Spokes()` / `aaveV4Oracles()` / `aaveV4Peripherals()` |
|
|
792
|
+
| `config/silo-v2-peripherals.json` / `data/silo-v2-markets.json` | `siloPeripherals()` / `siloMarkets()` |
|
|
793
|
+
| `config/silo-v3-peripherals.json` / `data/silo-v3-markets.json` | `siloPeripheralsV3()` / `siloMarketsV3()` |
|
|
794
|
+
| `config/fluid-resolvers.json` / `data/fluid-vaults.json` | `fluidResolvers()` / `fluidVaults()` |
|
|
795
|
+
| `config/gearbox-resolvers.json` | `gearboxResolvers()` |
|
|
796
|
+
| `config/dolomite-margin.json` / `config/dolomite-emode.json` | `dolomiteConfigs()` / `dolomiteEmode()` |
|
|
797
|
+
| `config/term-finance.json` / `data/term-finance-markets.json` | `termConfig()` / `termMarkets()` |
|
|
798
|
+
| `config/termmax.json` | `termMaxConfig()` |
|
|
799
|
+
| `config/exactly.json` / `data/exactly-markets.json` | `exactlyConfig()` / `exactlyMarkets()` |
|
|
800
|
+
| `config/teller.json` / `data/teller-pools.json` | `tellerConfig()` / `tellerPools()` |
|
|
801
|
+
| `config/liquity.json` / `data/liquity-markets.json` | `liquityConfig()` / `liquityMarkets()` |
|
|
802
|
+
| `config/river.json` / `data/river-markets.json` | `riverConfig()` / `riverMarkets()` |
|
|
803
|
+
| `config/inverse.json` / `data/inverse-markets.json` | `inverseConfig()` / `inverseMarkets()` |
|
|
804
|
+
| `config/frankencoin.json` / `data/frankencoin-markets.json` | `frankencoinConfig()` / `frankencoinMarkets()` |
|
|
805
|
+
| `config/usdd.json` / `data/usdd-markets.json` | `usddConfig()` / `usddMarkets()` |
|
|
806
|
+
| `config/sky.json` / `data/sky-markets.json` | `skyConfig()` / `skyMarkets()` |
|
|
807
|
+
| `config/llamalend.json` / `data/llamalend-markets.json` | `llamaLendConfig()` / `llamaLendMarkets()` |
|
|
808
|
+
| `config/resupply.json` | `resupplyConfig()` — built-in Ethereum seed if unpublished |
|
|
809
|
+
| `config/curvance.json` | `curvanceConfig()` — built-in Monad seed if unpublished |
|