@parallel-protocol/chains 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.
package/README.md ADDED
@@ -0,0 +1,82 @@
1
+ # @parallel-protocol/chains
2
+
3
+ On-chain catalogue for the Parallel Protocol — `viem` chain objects, Parallel-specific contract addresses, and viem-typed ABIs.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @parallel-protocol/chains viem
9
+ ```
10
+
11
+ `viem` is a peer dependency.
12
+
13
+ ## Design
14
+
15
+ Each entry in `CHAINS_STATIC` is a Parallel overlay on top of a canonical
16
+ `viem` `Chain` object:
17
+
18
+ ```ts
19
+ interface ChainStaticConfig {
20
+ viem: ViemChain; // id, name, native currency, RPCs, explorers, multicall3 — from viem/chains
21
+ status: ChainStatus; // "active" | "paused" | "sunset"
22
+ lzEid: number; // LayerZero V2 endpoint id
23
+ contracts: ChainContracts; // Parallel-specific: usdp, parallelizer, susdp, bridgeableUsdp, …
24
+ }
25
+ ```
26
+
27
+ `viem` stays the source of truth for chain id, name, native currency, default RPCs, block explorers, and multicall3. The two chains that don't ship multicall3 in viem (`hyperEvm`, `hemi`) get the canonical address injected.
28
+
29
+ ## Usage
30
+
31
+ ```ts
32
+ import {
33
+ CHAINS_STATIC,
34
+ ACTIVE_CHAINS,
35
+ PARALLELIZER_CHAINS,
36
+ getUSDpAddress,
37
+ isParallelizerChain,
38
+ } from "@parallel-protocol/chains";
39
+
40
+ CHAINS_STATIC.ethereum.viem.id; // 1
41
+ CHAINS_STATIC.ethereum.viem.name; // "Ethereum"
42
+ CHAINS_STATIC.ethereum.contracts.parallelizer;
43
+ // → "0x6efeDDF9269c3683Ba516cb0e2124FE335F262a2"
44
+
45
+ ACTIVE_CHAINS;
46
+ // → ["ethereum", "base", "arbitrum", …] (status: "active")
47
+
48
+ isParallelizerChain("ethereum"); // true
49
+ getUSDpAddress("base"); // "0x76A9A0062ec…"
50
+ ```
51
+
52
+ ABIs are exposed under the `/abi` subpath:
53
+
54
+ ```ts
55
+ import { PARALLELIZER_ABI, ERC20_ABI } from "@parallel-protocol/chains/abi";
56
+ ```
57
+
58
+ ## Composing your RPC layer
59
+
60
+ Pass `.viem` straight to `createPublicClient` — RPC URLs are intentionally
61
+ not bundled so consumers stay free to pick Alchemy, Infura, public RPCs, or
62
+ any combination:
63
+
64
+ ```ts
65
+ import { createPublicClient, http } from "viem";
66
+ import { CHAINS_STATIC, PARALLELIZER_ABI } from "@parallel-protocol/chains";
67
+
68
+ const eth = createPublicClient({
69
+ chain: CHAINS_STATIC.ethereum.viem,
70
+ transport: http(`https://eth-mainnet.g.alchemy.com/v2/${process.env.ALCHEMY_KEY}`),
71
+ });
72
+
73
+ const fees = await eth.readContract({
74
+ address: CHAINS_STATIC.ethereum.contracts.parallelizer!,
75
+ abi: PARALLELIZER_ABI,
76
+ functionName: "getCollateralRatio",
77
+ });
78
+ ```
79
+
80
+ ## License
81
+
82
+ MIT