@venusprotocol/chains 0.8.2

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,56 @@
1
+ # Venus Protocol - chains package
2
+
3
+ This package lists all the chain-related metadata for the Venus Protocol.
4
+
5
+ ## Chains
6
+
7
+ Chain IDs are exported via the `ChainId` enum. Chains are exported via the `chains` constant.
8
+
9
+ ```ts
10
+ import { chains, ChainId } from '@venusprotocol/chains';
11
+
12
+ console.log(chains[ChainId.BSC_MAINNET].name); // Outputs "BNB Chain"
13
+ ```
14
+
15
+ ## Tokens
16
+
17
+ ### Retrieving tokens
18
+
19
+ Tokens are exported via the `tokens` constant.
20
+
21
+ ```ts
22
+ import { tokens, ChainId } from '@venusprotocol/chains';
23
+
24
+ console.log(tokens[ChainId.BSC_MAINNET][0].symbol); // Outputs "XVS"
25
+ ```
26
+
27
+ The library also exports a `getToken` function to retrieve a singular token on a given chain using
28
+ its symbol. The `symbol` parameter is not case-sensitive.
29
+
30
+ ```ts
31
+ import { getToken, ChainId } from '@venusprotocol/chains';
32
+
33
+ const xvs = getToken({
34
+ chainId: ChainId.BSC_MAINNET,
35
+ symbol: 'XVS', //
36
+ });
37
+
38
+ console.log(xvs?.symbol); // Outputs "XVS"
39
+ ```
40
+
41
+ The icon source of a vToken can be retrieved using the `getVTokenIconSrc` function:
42
+
43
+ ```ts
44
+ import { getVTokenIconSrc, ChainId } from '@venusprotocol/chains';
45
+
46
+ const vTokenIconSrc = getVTokenIconSrc({
47
+ chainId: ChainId.BSC_MAINNET,
48
+ vTokenAddress: '0x6bCa74586218dB34cdB402295796b79663d816e9', // vWBNB market
49
+ });
50
+ ```
51
+
52
+ ### Adding a token
53
+
54
+ Add the token icon into the [images](./images/tokens) directory, then run the command `yarn
55
+ generate` to update the [token manifest](./src/generated/tokenManifest.json). You can then list the
56
+ token in any of the [token metadata files](./src/tokens).
@@ -0,0 +1,106 @@
1
+ import { Address } from "viem";
2
+
3
+ //#region src/types/index.d.ts
4
+ declare enum ChainId {
5
+ BSC_MAINNET = 56,
6
+ BSC_TESTNET = 97,
7
+ ETHEREUM = 1,
8
+ SEPOLIA = 11155111,
9
+ OPBNB_MAINNET = 204,
10
+ OPBNB_TESTNET = 5611,
11
+ ARBITRUM_ONE = 42161,
12
+ ARBITRUM_SEPOLIA = 421614,
13
+ ZKSYNC_MAINNET = 324,
14
+ ZKSYNC_SEPOLIA = 300,
15
+ OPTIMISM_MAINNET = 10,
16
+ OPTIMISM_SEPOLIA = 11155420,
17
+ BASE_MAINNET = 8453,
18
+ BASE_SEPOLIA = 84532,
19
+ UNICHAIN_MAINNET = 130,
20
+ UNICHAIN_SEPOLIA = 1301,
21
+ }
22
+ declare enum MainnetChainId {
23
+ BSC_MAINNET = 56,
24
+ ETHEREUM = 1,
25
+ OPBNB_MAINNET = 204,
26
+ ARBITRUM_ONE = 42161,
27
+ ZKSYNC_MAINNET = 324,
28
+ OPTIMISM_MAINNET = 10,
29
+ BASE_MAINNET = 8453,
30
+ UNICHAIN_MAINNET = 130,
31
+ }
32
+ declare enum TestnetChainId {
33
+ BSC_TESTNET = 97,
34
+ SEPOLIA = 11155111,
35
+ OPBNB_TESTNET = 5611,
36
+ ARBITRUM_SEPOLIA = 421614,
37
+ ZKSYNC_SEPOLIA = 300,
38
+ OPTIMISM_SEPOLIA = 11155420,
39
+ BASE_SEPOLIA = 84532,
40
+ UNICHIAN_SEPOLIA = 1301,
41
+ }
42
+ interface Chain {
43
+ name: string;
44
+ iconSrc: string;
45
+ explorerUrl: string;
46
+ nativeToken: Token;
47
+ layerZeroScanUrl: string;
48
+ corePoolComptrollerContractAddress: Address;
49
+ safeWalletApiUrl?: string;
50
+ proposalExecutionGracePeriodMs?: number;
51
+ blockTimeMs?: number;
52
+ blocksPerDay?: number;
53
+ }
54
+ interface Token {
55
+ symbol: string;
56
+ decimals: number;
57
+ iconSrc: string;
58
+ address: Address;
59
+ isNative?: boolean;
60
+ tokenWrapped?: Token;
61
+ }
62
+ interface VToken extends Omit<Token, 'isNative' | 'iconSrc' | 'tokenWrapped'> {
63
+ decimals: 8;
64
+ underlyingToken: Token;
65
+ iconSrc?: string;
66
+ }
67
+ type VTokenIconUrlMapping = Record<string, string>;
68
+ //#endregion
69
+ //#region src/constants/index.d.ts
70
+ declare const NATIVE_TOKEN_ADDRESS: "0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB";
71
+ declare const IMAGES_DIR_NAME = "images";
72
+ declare const IMAGES_DIR_PATH = "src/images";
73
+ //#endregion
74
+ //#region src/chains/index.d.ts
75
+ declare const chains: { [chainId in ChainId]: Chain };
76
+ //#endregion
77
+ //#region src/tokens/underlyingTokens/index.d.ts
78
+ declare const tokens: { [chainId in ChainId]: Token[] };
79
+ //#endregion
80
+ //#region src/tokens/vTokenIconSrcs/index.d.ts
81
+ declare const vTokens: Record<ChainId, VTokenIconUrlMapping>;
82
+ //#endregion
83
+ //#region src/tokens/nativeTokens/index.d.ts
84
+ declare const eth: Token;
85
+ declare const bnb: Token;
86
+ //#endregion
87
+ //#region src/utilities/getToken/index.d.ts
88
+ interface GetTokenInput {
89
+ chainId: ChainId;
90
+ symbol: string;
91
+ }
92
+ declare const getToken: ({
93
+ chainId,
94
+ symbol
95
+ }: GetTokenInput) => Token | undefined;
96
+ //#endregion
97
+ //#region src/utilities/getVTokenIconSrc/index.d.ts
98
+ declare const getVTokenIconSrc: ({
99
+ vTokenAddress,
100
+ chainId
101
+ }: {
102
+ vTokenAddress: string;
103
+ chainId: ChainId;
104
+ }) => string | undefined;
105
+ //#endregion
106
+ export { Chain, ChainId, GetTokenInput, IMAGES_DIR_NAME, IMAGES_DIR_PATH, MainnetChainId, NATIVE_TOKEN_ADDRESS, TestnetChainId, Token, VToken, VTokenIconUrlMapping, bnb, chains, eth, getToken, getVTokenIconSrc, tokens, vTokens };