Skip to content

Commit 104c128

Browse files
committed
Implement dynamic fetching of SVR feed addresses
1 parent 3e01440 commit 104c128

File tree

1 file changed

+65
-5
lines changed

1 file changed

+65
-5
lines changed

src/content/data-feeds/svr-feeds/index.mdx

Lines changed: 65 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,47 @@ whatsnext:
1313

1414
import { Aside, ClickToZoom, CodeSample } from "@components"
1515
import { Tabs } from "@components/Tabs"
16+
import { CHAINS } from "@features/data/chains"
17+
18+
export async function getFeeds() {
19+
const ethereumMainnet = CHAINS.find((chain) => chain.page === "ethereum")?.networks.find(
20+
(network) => network.networkType === "mainnet"
21+
)
22+
23+
const rddUrl = ethereumMainnet?.rddUrl
24+
25+
if (!rddUrl) {
26+
return []
27+
}
28+
29+
try {
30+
const response = await fetch(rddUrl)
31+
const data = await response.json()
32+
33+
const targetFeeds = [
34+
"AAVE/USD-RefPrice-DF-Ethereum-001",
35+
"BTC/USD-RefPrice-DF-Ethereum-001",
36+
"LINK/USD-RefPrice-DF-Ethereum-001",
37+
]
38+
39+
const svrFeeds = data.filter(
40+
(feed) =>
41+
feed.secondaryProxyAddress && feed.docs?.clicProductName && targetFeeds.includes(feed.docs.clicProductName)
42+
)
43+
44+
return svrFeeds
45+
.map((feed) => ({
46+
name: feed.name.replace(" / ", "/"),
47+
address: feed.contractAddress,
48+
}))
49+
.sort((a, b) => a.name.localeCompare(b.name))
50+
51+
} catch (error) {
52+
return []
53+
}
54+
}
55+
56+
export const feeds = await getFeeds()
1657

1758
[Chainlink Smart Value Recapture](https://blog.chain.link/chainlink-smart-value-recapture-svr/) (SVR) Feeds introduce a novel and secure way to recapture Oracle Extractable Value (OEV)—a subset of non-toxic Maximal Extractable Value (MEV) associated with oracle updates that is most commonly observed during the liquidation process of lending protocols. The value recaptured by SVR provides DeFi protocols with an additional revenue stream while also supporting the economic sustainability of Chainlink oracle. SVR Feeds are read in the same manner as standard Chainlink Data Feeds (see [Using Data Feeds](/data-feeds/using-data-feeds)), and simply require that users specify an SVR-enabled feed address.
1859

@@ -242,11 +283,30 @@ The following code samples demonstrate the complete decoding process, including
242283

243284
When processing forward calls, verify that the `to` address (the destination of the forward call) matches one of these feed addresses:
244285

245-
| Feed name | Address |
246-
| --------- | -------------------------------------------- |
247-
| AAVE/USD | `0xcd07B31D85756098334eDdC92DE755dEae8FE62f` |
248-
| BTC/USD | `0xdc715c751f1cc129A6b47fEDC87D9918a4580502` |
249-
| LINK/USD | `0x64c67984A458513C6BAb23a815916B1b1075cf3a` |
286+
<table>
287+
<thead>
288+
<tr>
289+
<th>Feed name</th>
290+
<th>Address</th>
291+
</tr>
292+
</thead>
293+
<tbody>
294+
{feeds &&
295+
feeds.map((feed) => (
296+
<tr key={feed.address}>
297+
<td>{feed.name}</td>
298+
<td>
299+
<code>{feed.address}</code>
300+
</td>
301+
</tr>
302+
))}
303+
{(!feeds || feeds.length === 0) && (
304+
<tr>
305+
<td colSpan="2">No SVR feeds found.</td>
306+
</tr>
307+
)}
308+
</tbody>
309+
</table>
250310

251311
### 5. Calculate Updated Price
252312

0 commit comments

Comments
 (0)