@avaprotocol/protocols 0.4.0 → 0.4.1
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/CHANGELOG.md +10 -0
- package/dist/index.cjs +21 -0
- package/dist/index.js +21 -0
- package/dist/tokens/index.d.ts +27 -11
- package/dist/tokens/index.d.ts.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @avaprotocol/protocols
|
|
2
2
|
|
|
3
|
+
## 0.4.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 9460f61: `lookupToken` now walks per-protocol `tokens` tables (`Protocols.aaveV3.tokens.LINK`, `Protocols.uniswapV3.tokens.WETH`, etc.) as a third resolution pass after the top-level `Tokens` catalog scan. Covers token addresses that ship alongside a specific protocol but don't appear in the top-level catalog — most notably the AAVE-V3 Sepolia faucet LINK (`0xf8Fb37…0EBE5`), which is the address AAVE templates actually use on Sepolia even though the canonical Chainlink LINK (`0x779877…4789`) lives elsewhere.
|
|
8
|
+
|
|
9
|
+
When the symbol resolved from a per-protocol map also appears in `Tokens` on some chain, decimals/name are lifted from there; otherwise decimals default to 18 (true for every per-protocol token currently shipped).
|
|
10
|
+
|
|
11
|
+
Fixes a regression introduced by 0.4.0's Studio seed where `Tokens.LINK[Sepolia]` switched to the canonical Chainlink address, leaving consumers unable to recover the symbol for the AAVE template's faucet address.
|
|
12
|
+
|
|
3
13
|
## 0.4.0
|
|
4
14
|
|
|
5
15
|
### Minor Changes
|
package/dist/index.cjs
CHANGED
|
@@ -1636,6 +1636,7 @@ function buildTokensFromData() {
|
|
|
1636
1636
|
return merged;
|
|
1637
1637
|
}
|
|
1638
1638
|
var Tokens = Object.freeze(buildTokensFromData());
|
|
1639
|
+
var PROTOCOL_TOKEN_DEFAULT_DECIMALS = 18;
|
|
1639
1640
|
function lookupToken(chainId, address) {
|
|
1640
1641
|
if (!address) return void 0;
|
|
1641
1642
|
const target = address.toLowerCase();
|
|
@@ -1654,6 +1655,26 @@ function lookupToken(chainId, address) {
|
|
|
1654
1655
|
}
|
|
1655
1656
|
}
|
|
1656
1657
|
}
|
|
1658
|
+
for (const protocolModule of Object.values(Protocols)) {
|
|
1659
|
+
const tokens3 = protocolModule.tokens;
|
|
1660
|
+
if (!tokens3 || typeof tokens3 !== "object") continue;
|
|
1661
|
+
for (const [symbol, addressMap] of Object.entries(tokens3)) {
|
|
1662
|
+
if (!addressMap || typeof addressMap !== "object") continue;
|
|
1663
|
+
for (const [rawChainId, addr] of Object.entries(addressMap)) {
|
|
1664
|
+
if (typeof addr !== "string") continue;
|
|
1665
|
+
if (addr.toLowerCase() !== target) continue;
|
|
1666
|
+
const resolvedChainId = Number(rawChainId);
|
|
1667
|
+
const canonicalSymbolByChain = Tokens[symbol];
|
|
1668
|
+
const metadataSource = canonicalSymbolByChain?.[resolvedChainId] ?? (canonicalSymbolByChain ? Object.values(canonicalSymbolByChain).find((e) => e) : void 0);
|
|
1669
|
+
return {
|
|
1670
|
+
symbol,
|
|
1671
|
+
address: addr,
|
|
1672
|
+
decimals: metadataSource?.decimals ?? PROTOCOL_TOKEN_DEFAULT_DECIMALS,
|
|
1673
|
+
...metadataSource?.name ? { name: metadataSource.name } : {}
|
|
1674
|
+
};
|
|
1675
|
+
}
|
|
1676
|
+
}
|
|
1677
|
+
}
|
|
1657
1678
|
return void 0;
|
|
1658
1679
|
}
|
|
1659
1680
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/index.js
CHANGED
|
@@ -1590,6 +1590,7 @@ function buildTokensFromData() {
|
|
|
1590
1590
|
return merged;
|
|
1591
1591
|
}
|
|
1592
1592
|
var Tokens = Object.freeze(buildTokensFromData());
|
|
1593
|
+
var PROTOCOL_TOKEN_DEFAULT_DECIMALS = 18;
|
|
1593
1594
|
function lookupToken(chainId, address) {
|
|
1594
1595
|
if (!address) return void 0;
|
|
1595
1596
|
const target = address.toLowerCase();
|
|
@@ -1608,6 +1609,26 @@ function lookupToken(chainId, address) {
|
|
|
1608
1609
|
}
|
|
1609
1610
|
}
|
|
1610
1611
|
}
|
|
1612
|
+
for (const protocolModule of Object.values(Protocols)) {
|
|
1613
|
+
const tokens3 = protocolModule.tokens;
|
|
1614
|
+
if (!tokens3 || typeof tokens3 !== "object") continue;
|
|
1615
|
+
for (const [symbol, addressMap] of Object.entries(tokens3)) {
|
|
1616
|
+
if (!addressMap || typeof addressMap !== "object") continue;
|
|
1617
|
+
for (const [rawChainId, addr] of Object.entries(addressMap)) {
|
|
1618
|
+
if (typeof addr !== "string") continue;
|
|
1619
|
+
if (addr.toLowerCase() !== target) continue;
|
|
1620
|
+
const resolvedChainId = Number(rawChainId);
|
|
1621
|
+
const canonicalSymbolByChain = Tokens[symbol];
|
|
1622
|
+
const metadataSource = canonicalSymbolByChain?.[resolvedChainId] ?? (canonicalSymbolByChain ? Object.values(canonicalSymbolByChain).find((e) => e) : void 0);
|
|
1623
|
+
return {
|
|
1624
|
+
symbol,
|
|
1625
|
+
address: addr,
|
|
1626
|
+
decimals: metadataSource?.decimals ?? PROTOCOL_TOKEN_DEFAULT_DECIMALS,
|
|
1627
|
+
...metadataSource?.name ? { name: metadataSource.name } : {}
|
|
1628
|
+
};
|
|
1629
|
+
}
|
|
1630
|
+
}
|
|
1631
|
+
}
|
|
1611
1632
|
return void 0;
|
|
1612
1633
|
}
|
|
1613
1634
|
export {
|
package/dist/tokens/index.d.ts
CHANGED
|
@@ -28,18 +28,34 @@ export declare const Tokens: Readonly<Record<string, TokenByChain>>;
|
|
|
28
28
|
*
|
|
29
29
|
* Resolution strategy:
|
|
30
30
|
* 1. When `chainId` is provided, prefer a match registered for that
|
|
31
|
-
* chain.
|
|
31
|
+
* chain in the top-level `Tokens` catalog.
|
|
32
32
|
* 2. If no chain-specific match (or no chainId), scan every chain
|
|
33
|
-
* for the address. Necessary when the caller's chain
|
|
34
|
-
* diverges from where the address actually lives —
|
|
35
|
-
* multi-chain dev gateways where the workflow targets
|
|
36
|
-
* but the runtime is bound to a different one. The
|
|
37
|
-
* best-effort: the same 20-byte address is
|
|
38
|
-
* EVM chain, so the scan only happens to be
|
|
39
|
-
* catalog only ships well-known canonical
|
|
40
|
-
* addresses (mainnet USDC, OP-stack WETH
|
|
41
|
-
* collide across chains in practice.
|
|
42
|
-
* the right chainId when they have it.
|
|
33
|
+
* in `Tokens` for the address. Necessary when the caller's chain
|
|
34
|
+
* context diverges from where the address actually lives —
|
|
35
|
+
* happens in multi-chain dev gateways where the workflow targets
|
|
36
|
+
* one chain but the runtime is bound to a different one. The
|
|
37
|
+
* fallback is best-effort: the same 20-byte address is
|
|
38
|
+
* reachable on every EVM chain, so the scan only happens to be
|
|
39
|
+
* correct because the catalog only ships well-known canonical
|
|
40
|
+
* tokens whose contract addresses (mainnet USDC, OP-stack WETH
|
|
41
|
+
* predeploys, etc.) don't collide across chains in practice.
|
|
42
|
+
* Callers should still pass the right chainId when they have it.
|
|
43
|
+
* 3. If still no match, walk every per-protocol `tokens` table
|
|
44
|
+
* (`Protocols.aaveV3.tokens.LINK`, `Protocols.uniswapV3.tokens.WETH`,
|
|
45
|
+
* ...) for the address. Catches token addresses that ship
|
|
46
|
+
* alongside a specific protocol — most notably the AAVE-V3
|
|
47
|
+
* Sepolia faucet LINK (`0xf8Fb37…0EBE5`), which is the address
|
|
48
|
+
* AAVE templates actually use on Sepolia even though the
|
|
49
|
+
* canonical Chainlink LINK lives elsewhere. When the symbol
|
|
50
|
+
* resolved from a per-protocol map also appears in `Tokens`,
|
|
51
|
+
* `decimals` and `name` are lifted from the same-chain catalog
|
|
52
|
+
* entry when one exists, else from any other catalog entry
|
|
53
|
+
* under that symbol; `decimals` defaults to 18 when no catalog
|
|
54
|
+
* entry exists at all (true for every per-protocol token the
|
|
55
|
+
* catalog currently ships). The catalog's URL-shaped fields
|
|
56
|
+
* (`website`, `explorer`, `logoUrl`, `links`) are intentionally
|
|
57
|
+
* NOT lifted — they're per-deployment metadata that a faucet
|
|
58
|
+
* variant would render incorrectly.
|
|
43
59
|
*
|
|
44
60
|
* Returns `undefined` when no chain in the catalog carries the
|
|
45
61
|
* address, or when the address is missing/falsy.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tokens/index.ts"],"names":[],"mappings":"
|
|
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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@avaprotocol/protocols",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
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",
|