11// SPDX-License-Identifier: MIT
22pragma solidity 0.8.27 ;
33
4- import "@api3/contracts/interfaces/IApi3ReaderProxy .sol " ;
4+ import "@api3/contracts/api3-server-v1/proxies/ interfaces/IApi3ReaderProxyV1 .sol " ;
55import "./interfaces/IScaledApi3FeedProxyV1.sol " ;
66
77/// @title An immutable Chainlink AggregatorV2V3Interface feed contract that
8- /// scales the value of an IApi3ReaderProxy data feed to a target number of
8+ /// scales the value of an IApi3ReaderProxyV1 data feed to a target number of
99/// decimals
1010/// @dev This contract reads an `int224` value (assumed to be 18 decimals)
11- /// from the underlying `IApi3ReaderProxy ` and scales it to `targetDecimals`.
11+ /// from the underlying `IApi3ReaderProxyV1 ` and scales it to `targetDecimals`.
1212/// The scaling arithmetic uses `int256` for intermediate results, allowing the
1313/// scaled value to exceed `int224` limits if upscaling significantly; it will
1414/// revert on `int256` overflow.
1515/// When downscaling, integer division (`proxyValue / scalingFactor`) is used,
1616/// which truncates and may lead to precision loss. Integrators must carefully
1717/// consider this potential precision loss for their specific use case.
1818contract ScaledApi3FeedProxyV1 is IScaledApi3FeedProxyV1 {
19- /// @notice IApi3ReaderProxy contract address
19+ /// @notice IApi3ReaderProxyV1 contract address
2020 address public immutable override proxy;
2121
22+ /// @notice dApp ID of the proxy
23+ uint256 public immutable override dappId;
24+
2225 /// @dev Target decimals for the scaled value.
2326 uint8 private immutable targetDecimals;
2427
@@ -30,8 +33,8 @@ contract ScaledApi3FeedProxyV1 is IScaledApi3FeedProxyV1 {
3033 /// downscaling (divide by `scalingFactor`), to scale to `targetDecimals`.
3134 bool public immutable isUpscaling;
3235
33- /// @param proxy_ IApi3ReaderProxy contract address
34- /// @param targetDecimals_ Decimals used to scale the IApi3ReaderProxy value
36+ /// @param proxy_ IApi3ReaderProxyV1 contract address
37+ /// @param targetDecimals_ Decimals to scale the IApi3ReaderProxyV1 value
3538 constructor (address proxy_ , uint8 targetDecimals_ ) {
3639 if (proxy_ == address (0 )) {
3740 revert ZeroProxyAddress ();
@@ -43,6 +46,7 @@ contract ScaledApi3FeedProxyV1 is IScaledApi3FeedProxyV1 {
4346 revert NoScalingNeeded ();
4447 }
4548 proxy = proxy_;
49+ dappId = IApi3ReaderProxyV1 (proxy_).dappId ();
4650 targetDecimals = targetDecimals_;
4751 uint8 delta = targetDecimals_ > 18
4852 ? targetDecimals_ - 18
@@ -88,7 +92,7 @@ contract ScaledApi3FeedProxyV1 is IScaledApi3FeedProxyV1 {
8892 revert FunctionIsNotSupported ();
8993 }
9094
91- /// @dev Decimals used to scale the IApi3ReaderProxy value
95+ /// @dev Decimals used to scale the IApi3ReaderProxyV1 value
9296 function decimals () external view override returns (uint8 ) {
9397 return targetDecimals;
9498 }
@@ -137,7 +141,7 @@ contract ScaledApi3FeedProxyV1 is IScaledApi3FeedProxyV1 {
137141 updatedAt = startedAt;
138142 }
139143
140- /// @notice Reads a value from the underlying `IApi3ReaderProxy ` and
144+ /// @notice Reads a value from the underlying `IApi3ReaderProxyV1 ` and
141145 /// scales it to `targetDecimals`.
142146 /// @dev Reads from the underlying proxy and applies scaling to
143147 /// `targetDecimals`. Upscaling uses multiplication; downscaling uses integer
@@ -146,7 +150,7 @@ contract ScaledApi3FeedProxyV1 is IScaledApi3FeedProxyV1 {
146150 /// @return value The scaled signed fixed-point value with `targetDecimals`.
147151 /// @return timestamp The timestamp from the underlying proxy.
148152 function _read () internal view returns (int256 value , uint32 timestamp ) {
149- (int224 proxyValue , uint32 proxyTimestamp ) = IApi3ReaderProxy (proxy)
153+ (int224 proxyValue , uint32 proxyTimestamp ) = IApi3ReaderProxyV1 (proxy)
150154 .read ();
151155
152156 value = isUpscaling
0 commit comments