@avaprotocol/protocols 0.5.0 → 0.6.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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tokens/index.ts"],"names":[],"mappings":"AA8BA,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,eAAe,EAAE,MAAM,SAAS,CAAC;AAQlE,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAqDzE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAwC,CAAC;AAcnG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,wBAAgB,WAAW,CACzB,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,OAAO,EAAE,MAAM,GAAG,SAAS,GAC1B,CAAC,eAAe,GAAG;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,GAAG,SAAS,CA6DpD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tokens/index.ts"],"names":[],"mappings":"AA8BA,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,eAAe,EAAE,MAAM,SAAS,CAAC;AAQlE,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AA6DzE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAwC,CAAC;AAcnG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,wBAAgB,WAAW,CACzB,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,OAAO,EAAE,MAAM,GAAG,SAAS,GAC1B,CAAC,eAAe,GAAG;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,GAAG,SAAS,CA6DpD"}
@@ -0,0 +1,30 @@
1
+ import type { TokenChainEntry } from "./types";
2
+ /**
3
+ * Source-data row shape. Each per-chain JSON file is an array of
4
+ * these — `symbol` carries the lookup key; the rest is the per-chain
5
+ * entry surfaced to consumers.
6
+ */
7
+ export interface TokenDataRow extends TokenChainEntry {
8
+ readonly symbol: string;
9
+ }
10
+ /**
11
+ * Build the symbol → TokenChainEntry map for a single chain's data
12
+ * file. Throws on duplicate symbols so data-entry mistakes fail at
13
+ * module load rather than silently overwriting.
14
+ *
15
+ * `sourceLabel` shows up in the duplicate-symbol error so callers can
16
+ * point at the exact JSON file that needs cleaning up.
17
+ *
18
+ * Implementation notes:
19
+ * - Backing map uses `Object.create(null)` so `Object.prototype`
20
+ * keys (`toString`, `hasOwnProperty`, etc.) can't be mistaken for
21
+ * existing entries when checking for duplicates.
22
+ * - Duplicate detection goes through `Object.prototype.hasOwnProperty.call`
23
+ * for the same reason — `in` would still match inherited keys
24
+ * even if our map happened to acquire a prototype.
25
+ * - Together these neutralize the `__proto__` prototype-pollution
26
+ * vector that a curated catalog file shouldn't have anyway, but
27
+ * the defense is free and the data is parsed externally.
28
+ */
29
+ export declare function buildChainTokenMap(rows: ReadonlyArray<TokenDataRow>, sourceLabel: string): Readonly<Record<string, TokenChainEntry>>;
30
+ //# sourceMappingURL=per-chain.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"per-chain.d.ts","sourceRoot":"","sources":["../../src/tokens/per-chain.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C;;;;GAIG;AACH,MAAM,WAAW,YAAa,SAAQ,eAAe;IACnD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,aAAa,CAAC,YAAY,CAAC,EACjC,WAAW,EAAE,MAAM,GAClB,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC,CAa3C"}
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/tokens/sepolia.ts
21
+ var sepolia_exports = {};
22
+ __export(sepolia_exports, {
23
+ chainId: () => chainId,
24
+ default: () => sepolia_default2,
25
+ tokens: () => tokens
26
+ });
27
+ module.exports = __toCommonJS(sepolia_exports);
28
+
29
+ // src/tokens/data/sepolia.json
30
+ var sepolia_default = [
31
+ {
32
+ symbol: "DAI",
33
+ address: "0x3e622317f8C93f7328350cF0B56d9eD4C620C5d6",
34
+ decimals: 18,
35
+ name: "Dai Stablecoin"
36
+ },
37
+ {
38
+ symbol: "LINK",
39
+ address: "0x779877A7B0D9E8603169DdbD7836e478b4624789",
40
+ decimals: 18,
41
+ name: "ChainLink Token"
42
+ },
43
+ {
44
+ symbol: "UNI",
45
+ address: "0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984",
46
+ decimals: 18,
47
+ name: "Uniswap"
48
+ },
49
+ {
50
+ symbol: "USDC",
51
+ address: "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238",
52
+ decimals: 6,
53
+ name: "USD Coin"
54
+ },
55
+ {
56
+ symbol: "USDT",
57
+ address: "0xaA8E23Fb1079EA71e0a56F48a2aA51851D8433D0",
58
+ decimals: 6,
59
+ name: "Tether USD"
60
+ },
61
+ {
62
+ symbol: "WETH",
63
+ address: "0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14",
64
+ decimals: 18,
65
+ name: "Wrapped Ether"
66
+ }
67
+ ];
68
+
69
+ // src/chains.ts
70
+ var Chains = Object.freeze({
71
+ EthereumMainnet: 1,
72
+ Sepolia: 11155111,
73
+ Holesky: 17e3,
74
+ BaseMainnet: 8453,
75
+ BaseSepolia: 84532,
76
+ BnbMainnet: 56
77
+ });
78
+
79
+ // src/tokens/per-chain.ts
80
+ function buildChainTokenMap(rows, sourceLabel) {
81
+ const out = /* @__PURE__ */ Object.create(null);
82
+ for (const row of rows) {
83
+ const { symbol, ...entry } = row;
84
+ if (Object.prototype.hasOwnProperty.call(out, symbol)) {
85
+ throw new Error(
86
+ `[@avaprotocol/protocols] duplicate symbol "${symbol}" in ${sourceLabel} \u2014 each symbol must appear once per chain file.`
87
+ );
88
+ }
89
+ out[symbol] = Object.freeze(entry);
90
+ }
91
+ return Object.freeze(out);
92
+ }
93
+
94
+ // src/tokens/sepolia.ts
95
+ var chainId = Chains.Sepolia;
96
+ var tokens = buildChainTokenMap(
97
+ sepolia_default,
98
+ "src/tokens/data/sepolia.json"
99
+ );
100
+ var sepolia_default2 = tokens;
101
+ // Annotate the CommonJS export names for ESM import in node:
102
+ 0 && (module.exports = {
103
+ chainId,
104
+ tokens
105
+ });
@@ -0,0 +1,5 @@
1
+ import type { TokenChainEntry } from "./types";
2
+ export declare const chainId: 11155111;
3
+ export declare const tokens: Readonly<Record<string, TokenChainEntry>>;
4
+ export default tokens;
5
+ //# sourceMappingURL=sepolia.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sepolia.d.ts","sourceRoot":"","sources":["../../src/tokens/sepolia.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C,eAAO,MAAM,OAAO,UAAiB,CAAC;AAEtC,eAAO,MAAM,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAG5D,CAAC;AAEF,eAAe,MAAM,CAAC"}
@@ -0,0 +1,77 @@
1
+ // src/tokens/data/sepolia.json
2
+ var sepolia_default = [
3
+ {
4
+ symbol: "DAI",
5
+ address: "0x3e622317f8C93f7328350cF0B56d9eD4C620C5d6",
6
+ decimals: 18,
7
+ name: "Dai Stablecoin"
8
+ },
9
+ {
10
+ symbol: "LINK",
11
+ address: "0x779877A7B0D9E8603169DdbD7836e478b4624789",
12
+ decimals: 18,
13
+ name: "ChainLink Token"
14
+ },
15
+ {
16
+ symbol: "UNI",
17
+ address: "0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984",
18
+ decimals: 18,
19
+ name: "Uniswap"
20
+ },
21
+ {
22
+ symbol: "USDC",
23
+ address: "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238",
24
+ decimals: 6,
25
+ name: "USD Coin"
26
+ },
27
+ {
28
+ symbol: "USDT",
29
+ address: "0xaA8E23Fb1079EA71e0a56F48a2aA51851D8433D0",
30
+ decimals: 6,
31
+ name: "Tether USD"
32
+ },
33
+ {
34
+ symbol: "WETH",
35
+ address: "0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14",
36
+ decimals: 18,
37
+ name: "Wrapped Ether"
38
+ }
39
+ ];
40
+
41
+ // src/chains.ts
42
+ var Chains = Object.freeze({
43
+ EthereumMainnet: 1,
44
+ Sepolia: 11155111,
45
+ Holesky: 17e3,
46
+ BaseMainnet: 8453,
47
+ BaseSepolia: 84532,
48
+ BnbMainnet: 56
49
+ });
50
+
51
+ // src/tokens/per-chain.ts
52
+ function buildChainTokenMap(rows, sourceLabel) {
53
+ const out = /* @__PURE__ */ Object.create(null);
54
+ for (const row of rows) {
55
+ const { symbol, ...entry } = row;
56
+ if (Object.prototype.hasOwnProperty.call(out, symbol)) {
57
+ throw new Error(
58
+ `[@avaprotocol/protocols] duplicate symbol "${symbol}" in ${sourceLabel} \u2014 each symbol must appear once per chain file.`
59
+ );
60
+ }
61
+ out[symbol] = Object.freeze(entry);
62
+ }
63
+ return Object.freeze(out);
64
+ }
65
+
66
+ // src/tokens/sepolia.ts
67
+ var chainId = Chains.Sepolia;
68
+ var tokens = buildChainTokenMap(
69
+ sepolia_default,
70
+ "src/tokens/data/sepolia.json"
71
+ );
72
+ var sepolia_default2 = tokens;
73
+ export {
74
+ chainId,
75
+ sepolia_default2 as default,
76
+ tokens
77
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@avaprotocol/protocols",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "Multi-chain catalog of DeFi protocol contract addresses, ABI fragments, and event topic hashes — covers AAVE V3, Uniswap V3, Chainlink, Lido, Morpho, and more.",
5
5
  "keywords": [
6
6
  "defi",
@@ -27,6 +27,7 @@
27
27
  "license": "MIT",
28
28
  "author": "Ava Protocol",
29
29
  "type": "module",
30
+ "sideEffects": false,
30
31
  "main": "./dist/index.cjs",
31
32
  "module": "./dist/index.js",
32
33
  "types": "./dist/index.d.ts",
@@ -36,6 +37,31 @@
36
37
  "import": "./dist/index.js",
37
38
  "require": "./dist/index.cjs"
38
39
  },
40
+ "./tokens/ethereum": {
41
+ "types": "./dist/tokens/ethereum.d.ts",
42
+ "import": "./dist/tokens/ethereum.js",
43
+ "require": "./dist/tokens/ethereum.cjs"
44
+ },
45
+ "./tokens/sepolia": {
46
+ "types": "./dist/tokens/sepolia.d.ts",
47
+ "import": "./dist/tokens/sepolia.js",
48
+ "require": "./dist/tokens/sepolia.cjs"
49
+ },
50
+ "./tokens/base": {
51
+ "types": "./dist/tokens/base.d.ts",
52
+ "import": "./dist/tokens/base.js",
53
+ "require": "./dist/tokens/base.cjs"
54
+ },
55
+ "./tokens/base-sepolia": {
56
+ "types": "./dist/tokens/base-sepolia.d.ts",
57
+ "import": "./dist/tokens/base-sepolia.js",
58
+ "require": "./dist/tokens/base-sepolia.cjs"
59
+ },
60
+ "./tokens/bnb-mainnet": {
61
+ "types": "./dist/tokens/bnb-mainnet.d.ts",
62
+ "import": "./dist/tokens/bnb-mainnet.js",
63
+ "require": "./dist/tokens/bnb-mainnet.cjs"
64
+ },
39
65
  "./package.json": "./package.json"
40
66
  },
41
67
  "files": [
@@ -49,7 +75,7 @@
49
75
  },
50
76
  "scripts": {
51
77
  "build:declarations": "tsc -p tsconfig.build.json",
52
- "build:js": "tsup src/index.ts --format cjs,esm --target es2020",
78
+ "build:js": "tsup",
53
79
  "build:tokens-sidecar": "tsx scripts/build-tokens-sidecar.ts",
54
80
  "build": "yarn clean:dist && yarn build:declarations && yarn build:js && yarn build:tokens-sidecar",
55
81
  "port:studio": "tsx scripts/port-from-studio.ts",