@avaprotocol/protocols 0.1.0

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.
Files changed (45) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +164 -0
  3. package/dist/chains.d.ts +9 -0
  4. package/dist/chains.d.ts.map +1 -0
  5. package/dist/index.cjs +848 -0
  6. package/dist/index.d.ts +3 -0
  7. package/dist/index.d.ts.map +1 -0
  8. package/dist/index.js +803 -0
  9. package/dist/protocols/aave-v3.d.ts +21 -0
  10. package/dist/protocols/aave-v3.d.ts.map +1 -0
  11. package/dist/protocols/aerodrome.d.ts +4 -0
  12. package/dist/protocols/aerodrome.d.ts.map +1 -0
  13. package/dist/protocols/chainlink.d.ts +7 -0
  14. package/dist/protocols/chainlink.d.ts.map +1 -0
  15. package/dist/protocols/common.d.ts +16 -0
  16. package/dist/protocols/common.d.ts.map +1 -0
  17. package/dist/protocols/compound-v3.d.ts +4 -0
  18. package/dist/protocols/compound-v3.d.ts.map +1 -0
  19. package/dist/protocols/erc20.d.ts +5 -0
  20. package/dist/protocols/erc20.d.ts.map +1 -0
  21. package/dist/protocols/ethena.d.ts +7 -0
  22. package/dist/protocols/ethena.d.ts.map +1 -0
  23. package/dist/protocols/frax-ether.d.ts +7 -0
  24. package/dist/protocols/frax-ether.d.ts.map +1 -0
  25. package/dist/protocols/index.d.ts +133 -0
  26. package/dist/protocols/index.d.ts.map +1 -0
  27. package/dist/protocols/lido.d.ts +7 -0
  28. package/dist/protocols/lido.d.ts.map +1 -0
  29. package/dist/protocols/morpho.d.ts +6 -0
  30. package/dist/protocols/morpho.d.ts.map +1 -0
  31. package/dist/protocols/rocket-pool.d.ts +6 -0
  32. package/dist/protocols/rocket-pool.d.ts.map +1 -0
  33. package/dist/protocols/sky.d.ts +6 -0
  34. package/dist/protocols/sky.d.ts.map +1 -0
  35. package/dist/protocols/spark.d.ts +4 -0
  36. package/dist/protocols/spark.d.ts.map +1 -0
  37. package/dist/protocols/superfluid.d.ts +6 -0
  38. package/dist/protocols/superfluid.d.ts.map +1 -0
  39. package/dist/protocols/types.d.ts +17 -0
  40. package/dist/protocols/types.d.ts.map +1 -0
  41. package/dist/protocols/uniswap-v3.d.ts +27 -0
  42. package/dist/protocols/uniswap-v3.d.ts.map +1 -0
  43. package/dist/protocols/wrapped.d.ts +6 -0
  44. package/dist/protocols/wrapped.d.ts.map +1 -0
  45. package/package.json +71 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ava Protocol
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,164 @@
1
+ # @avaprotocol/protocols
2
+
3
+ [![npm](https://img.shields.io/npm/v/@avaprotocol/protocols?color=blue)](https://www.npmjs.com/package/@avaprotocol/protocols)
4
+ [![CI](https://github.com/AvaProtocol/protocols/actions/workflows/ci.yml/badge.svg)](https://github.com/AvaProtocol/protocols/actions/workflows/ci.yml)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
6
+
7
+ Multi-chain catalog of DeFi protocol contract addresses, ABI fragments, and event topic hashes. Curated for callers who need a canonical reference without re-deriving constants or re-vendoring protocol SDKs.
8
+
9
+ ```ts
10
+ import { Protocols, Chains } from "@avaprotocol/protocols";
11
+
12
+ const pool = Protocols.aaveV3.pool[Chains.Sepolia];
13
+ // → "0x6Ae43d3271ff6888e7Fc43Fd7321a503ff738951"
14
+
15
+ const abi = Protocols.uniswapV3.swapRouter02Abi;
16
+ // → readonly AbiFragment[] with exactInputSingle + exactOutputSingle
17
+
18
+ const sig = Protocols.aaveV3.eventTopics.Borrow;
19
+ // → keccak256("Borrow(address,address,address,uint256,uint8,uint256,uint16)")
20
+ ```
21
+
22
+ ## What's covered
23
+
24
+ | Protocol | Contracts | Chains |
25
+ |---|---|---|
26
+ | **AAVE V3** | Pool, Oracle, WETH Gateway + Pool methods/events ABI + topics | Mainnet, Sepolia, Base, Base Sepolia |
27
+ | **Aerodrome** | Router | Base |
28
+ | **Chainlink** | ETH/USD + BTC/USD feeds + AggregatorV3 ABI | Mainnet, Sepolia |
29
+ | **Compound V3** | USDC Comet market | Mainnet, Base |
30
+ | **Ethena** | USDe, sUSDe vault + custom (cooldown-aware) ABI | Mainnet |
31
+ | **Frax Ether** | frxETH, sfrxETH vault + standard ERC-4626 ABI | Mainnet |
32
+ | **Lido** | stETH, wstETH + L1 wrap/unwrap/rate ABI | Mainnet, Base (wstETH bridged) |
33
+ | **Morpho Blue** | Singleton + MarketParams-tuple supply/borrow/position ABI | Mainnet, Base |
34
+ | **Rocket Pool** | rETH + L1 burn/rate/value ABI | Mainnet, Base (bridged) |
35
+ | **Sky (sDAI)** | sDAI vault + standard ERC-4626 ABI | Mainnet |
36
+ | **Spark** | SparkLend Pool (AAVE V3 fork — reuse AAVE Pool ABI) | Mainnet |
37
+ | **Superfluid** | CFAv1Forwarder + setFlowrate/createFlow ABI | Mainnet, Base |
38
+ | **Uniswap V3** | SwapRouter02, QuoterV2, Permit2, Factory, NFT Position Manager, Universal Router + ABIs | Mainnet, Sepolia, Base, Base Sepolia |
39
+ | **Wrapped Ether** | WETH per chain + WETH9 ABI | Mainnet, Sepolia, Base, Base Sepolia |
40
+ | **ERC-20** | Standard `approve` ABI fragment | n/a |
41
+
42
+ Shared ABIs (consumed by multiple protocol modules):
43
+
44
+ - `aggregatorV3Abi` — any Chainlink-compatible price feed
45
+ - `erc4626VaultAbi` — standard ERC-4626 vault (used by Frax Ether sfrxETH, Sky sDAI)
46
+
47
+ ## Install
48
+
49
+ ```sh
50
+ yarn add @avaprotocol/protocols
51
+ # or
52
+ npm install @avaprotocol/protocols
53
+ # or
54
+ pnpm add @avaprotocol/protocols
55
+ ```
56
+
57
+ Works with Node 18+, modern bundlers, and any TypeScript 4.7+ consumer. Ships dual CJS + ESM with full `.d.ts`.
58
+
59
+ ## Usage patterns
60
+
61
+ ### Pin an address by chain
62
+
63
+ ```ts
64
+ import { Protocols, Chains } from "@avaprotocol/protocols";
65
+
66
+ const linkOnSepolia = Protocols.aaveV3.tokens.LINK[Chains.Sepolia]!;
67
+ // "0xf8Fb3713D459D7C1018BD0A49D19b4C44290EBE5"
68
+ ```
69
+
70
+ `Partial<Record<ChainId, …>>` is the catalog's keying convention — every protocol declares which chains it covers. Use the non-null assertion (`!`) only when you're sure the chain is covered, or guard with `if`.
71
+
72
+ ### Compose a contract write
73
+
74
+ ```ts
75
+ import { Protocols, Chains } from "@avaprotocol/protocols";
76
+
77
+ await wallet.contractWrite({
78
+ contractAddress: Protocols.aaveV3.pool[Chains.Sepolia]!,
79
+ contractAbi: Protocols.aaveV3.poolMethodsAbi,
80
+ methodCalls: [
81
+ {
82
+ methodName: "supply",
83
+ methodParams: [
84
+ Protocols.aaveV3.tokens.LINK[Chains.Sepolia]!,
85
+ "100000000000000000", // 0.1 LINK
86
+ wallet.address,
87
+ "0", // referralCode
88
+ ],
89
+ },
90
+ ],
91
+ });
92
+ ```
93
+
94
+ ### Filter on an event topic
95
+
96
+ ```ts
97
+ import { Protocols } from "@avaprotocol/protocols";
98
+
99
+ const filter = {
100
+ address: Protocols.aaveV3.pool[Chains.Sepolia],
101
+ topics: [
102
+ Protocols.aaveV3.eventTopics.Borrow,
103
+ null, // any reserve
104
+ padAddress(eoa), // onBehalfOf = my EOA
105
+ ],
106
+ };
107
+ ```
108
+
109
+ ### Address lookups by `(chainId, address)`
110
+
111
+ For consumers that need to *recognize* an address rather than look it up by name (e.g. transaction interpreters), iterate the registry directly:
112
+
113
+ ```ts
114
+ import { Protocols, Chains } from "@avaprotocol/protocols";
115
+
116
+ function isAaveV3Pool(chainId: number, address: string): boolean {
117
+ const expected = Protocols.aaveV3.pool[chainId];
118
+ return !!expected && expected.toLowerCase() === address.toLowerCase();
119
+ }
120
+ ```
121
+
122
+ (A first-class reverse-lookup helper may ship later; the data shape already supports it.)
123
+
124
+ ## Design
125
+
126
+ Three principles drive what's in vs. what's out:
127
+
128
+ 1. **Static, on-chain-public data only.** Addresses, ABI fragments, event topic hashes, well-known token references. No private/embargoed protocol addresses; no RPC URLs, API keys, or credentials.
129
+ 2. **No UI metadata.** Per-action labels, descriptions, slugs, capability tags belong to each consumer's UX layer. This keeps the package tree-shakeable, language-agnostic, and reusable across web UIs, server-side indexers, partner SDKs, and CLI tooling.
130
+ 3. **Curated ABI fragments, not full ABIs.** Each protocol module ships only the methods + events callers routinely touch (e.g., AAVE Pool's `supply`/`borrow`/`repay`/`withdraw` + the 5 monitorable events, not the full ~80-method ABI). Keeps the bundle small and the API surface reviewable. Need a method not in the catalog? Open a PR — adding one fragment is a small diff.
131
+
132
+ ## Comparison with adjacent projects
133
+
134
+ | Project | Scope | This catalog's delta |
135
+ |---|---|---|
136
+ | [`@bgd-labs/aave-address-book`](https://github.com/bgd-labs/aave-address-book) | AAVE-only, exhaustive | Spans 14+ protocols. Borrows the shape + governance model. |
137
+ | [`@uniswap/sdk-core`](https://github.com/Uniswap/sdk-core) | Uniswap-only, addresses + math primitives | We ship Uniswap as one entry; don't duplicate the math. |
138
+ | [`blockchain-addressbook`](https://github.com/beefyfinance/address-book) | Multi-protocol, Beefy-opinionated | Includes ABI fragments + event topics; not Beefy-vault-shaped. |
139
+ | [Uniswap TokenLists](https://tokenlists.org/) | Tokens only, standardized schema | Complementary — we ship protocol contracts; you bring your own token list. |
140
+
141
+ There's no equivalent multi-protocol + multi-chain + addresses + ABIs + topics package in the npm ecosystem today, so this fills a gap. See `tests/catalog.test.ts` for shape guarantees.
142
+
143
+ ## Adding a new protocol
144
+
145
+ 1. Create `src/protocols/<protocol>.ts` with the per-chain address maps, ABI fragments, and event topics following the existing modules as templates (`aave-v3.ts` is the most complete example).
146
+ 2. Wire it through `src/protocols/index.ts` — add the import, the re-export, and the entry in the `Protocols.*` namespace.
147
+ 3. Add the entry to the supported-protocols table in this README + to the `it("exports every shipped protocol", ...)` test.
148
+ 4. Open a PR — CI runs typecheck + tests + build + tarball verification across Node 18/20/22.
149
+
150
+ Address verification: link to the canonical source (Etherscan-verified deployment, protocol docs, official address book). PRs that don't cite a source for the addresses won't merge.
151
+
152
+ ## Versioning
153
+
154
+ Semver. Until `1.0.0`, breaking changes can land in minor versions (`0.x`), but address corrections are always patches.
155
+
156
+ - **Patch (`0.1.x`)** — address corrections, bug fixes, doc-only changes.
157
+ - **Minor (`0.x.0`)** — new protocols, new chains, additive ABI fragments.
158
+ - **Major (`x.0.0`)** — renames, restructures, breaking removals.
159
+
160
+ The `dev` npm tag tracks the latest pre-release; `latest` stays on stable.
161
+
162
+ ## License
163
+
164
+ MIT — see [LICENSE](LICENSE).
@@ -0,0 +1,9 @@
1
+ export declare const Chains: Readonly<{
2
+ EthereumMainnet: 1;
3
+ Sepolia: 11155111;
4
+ Holesky: 17000;
5
+ BaseMainnet: 8453;
6
+ BaseSepolia: 84532;
7
+ }>;
8
+ export type ChainId = (typeof Chains)[keyof typeof Chains] | number;
9
+ //# sourceMappingURL=chains.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chains.d.ts","sourceRoot":"","sources":["../src/chains.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,MAAM;;;;;;EAMjB,CAAC;AAEH,MAAM,MAAM,OAAO,GAAG,CAAC,OAAO,MAAM,CAAC,CAAC,MAAM,OAAO,MAAM,CAAC,GAAG,MAAM,CAAC"}