Skip to content

Commit c274716

Browse files
committed
Removes dappId
1 parent 9b77496 commit c274716

16 files changed

+66
-164
lines changed

contracts/InverseApi3ReaderProxyV1.sol

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,29 @@
11
// SPDX-License-Identifier: MIT
22
pragma solidity 0.8.27;
33

4-
import "./interfaces/IApi3ReaderProxyWithDappId.sol";
4+
import "@api3/contracts/interfaces/IApi3ReaderProxy.sol";
55
import "./interfaces/IInverseApi3ReaderProxyV1.sol";
66

77
/// @title An immutable proxy contract that inverts the value returned by an
8-
/// IApi3ReaderProxyWithDappId data feed
8+
/// IApi3ReaderProxy data feed
99
/// @dev This contract implements the AggregatorV2V3Interface to be compatible
1010
/// with Chainlink aggregators. This allows the contract to be used as a drop-in
1111
/// replacement for Chainlink aggregators in existing dApps.
1212
/// Refer to https://github.com/api3dao/migrate-from-chainlink-to-api3 for more
1313
/// information about the Chainlink interface implementation.
1414
contract InverseApi3ReaderProxyV1 is IInverseApi3ReaderProxyV1 {
15-
/// @notice IApi3ReaderProxyWithDappId contract address
15+
/// @notice IApi3ReaderProxy contract address
1616
address public immutable override proxy;
1717

18-
/// @notice dApp ID of the proxy
19-
uint256 public immutable override dappId;
20-
21-
/// @param proxy_ IApi3ReaderProxyWithDappId contract address
18+
/// @param proxy_ IApi3ReaderProxy contract address
2219
constructor(address proxy_) {
2320
if (proxy_ == address(0)) {
2421
revert ZeroProxyAddress();
2522
}
2623
proxy = proxy_;
27-
dappId = IApi3ReaderProxyWithDappId(proxy_).dappId();
2824
}
2925

30-
/// @notice Returns the inverted value of the underlying
31-
/// IApi3ReaderProxyWithDappId
26+
/// @notice Returns the inverted value of the underlying IApi3ReaderProxy
3227
/// @dev Calculates `int224(1e36) / baseValue`. The operation will revert if
3328
/// `baseValue` is zero. If `baseValue` is non-zero but its absolute value is
3429
/// greater than `1e36`, the result of the integer division will be `0`.
@@ -40,9 +35,8 @@ contract InverseApi3ReaderProxyV1 is IInverseApi3ReaderProxyV1 {
4035
override
4136
returns (int224 value, uint32 timestamp)
4237
{
43-
(int224 baseValue, uint32 baseTimestamp) = IApi3ReaderProxyWithDappId(
44-
proxy
45-
).read();
38+
(int224 baseValue, uint32 baseTimestamp) = IApi3ReaderProxy(proxy)
39+
.read();
4640

4741
if (baseValue == 0) {
4842
revert DivisionByZero();

contracts/NormalizedApi3ReaderProxyV1.sol

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ contract NormalizedApi3ReaderProxyV1 is INormalizedApi3ReaderProxyV1 {
1515
/// @notice Chainlink AggregatorV2V3Interface contract address
1616
address public immutable override feed;
1717

18-
/// @notice dApp ID of the proxy
19-
uint256 public immutable override dappId;
20-
2118
/// @notice Pre-calculated factor for scaling the feed's value to 18
2219
/// decimals.
2320
int256 public immutable scalingFactor;
@@ -27,8 +24,7 @@ contract NormalizedApi3ReaderProxyV1 is INormalizedApi3ReaderProxyV1 {
2724
bool public immutable isUpscaling;
2825

2926
/// @param feed_ The address of the Chainlink AggregatorV2V3Interface feed
30-
/// @param dappId_ dApp ID of the proxy
31-
constructor(address feed_, uint256 dappId_) {
27+
constructor(address feed_) {
3228
if (feed_ == address(0)) {
3329
revert ZeroProxyAddress();
3430
}
@@ -40,7 +36,6 @@ contract NormalizedApi3ReaderProxyV1 is INormalizedApi3ReaderProxyV1 {
4036
revert NoNormalizationNeeded();
4137
}
4238
feed = feed_;
43-
dappId = dappId_;
4439
uint8 delta = feedDecimals_ > 18
4540
? feedDecimals_ - 18
4641
: 18 - feedDecimals_;

contracts/PriceCappedApi3ReaderProxyV1.sol

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// SPDX-License-Identifier: MIT
22
pragma solidity 0.8.27;
33

4-
import "./interfaces/IApi3ReaderProxyWithDappId.sol";
4+
import "@api3/contracts/interfaces/IApi3ReaderProxy.sol";
55
import "./interfaces/IPriceCappedApi3ReaderProxyV1.sol";
66

77
/**
@@ -21,19 +21,16 @@ import "./interfaces/IPriceCappedApi3ReaderProxyV1.sol";
2121
* floored at 0 if `lowerBound_` is 0.
2222
*/
2323
contract PriceCappedApi3ReaderProxyV1 is IPriceCappedApi3ReaderProxyV1 {
24-
/// @notice IApi3ReaderProxyWithDappId contract address
24+
/// @notice IApi3ReaderProxy contract address
2525
address public immutable override proxy;
2626

27-
/// @notice dApp ID of the proxy
28-
uint256 public immutable override dappId;
29-
3027
/// @notice The minimum price (inclusive) that this proxy will report.
3128
int224 public immutable override lowerBound;
3229

3330
/// @notice The maximum price (inclusive) that this proxy will report.
3431
int224 public immutable override upperBound;
3532

36-
/// @param proxy_ IApi3ReaderProxyWithDappId contract address
33+
/// @param proxy_ IApi3ReaderProxy contract address
3734
/// @param lowerBound_ The minimum price (inclusive) this proxy will report
3835
/// @param upperBound_ The maximum price (inclusive) this proxy will report
3936
constructor(address proxy_, int224 lowerBound_, int224 upperBound_) {
@@ -47,13 +44,12 @@ contract PriceCappedApi3ReaderProxyV1 is IPriceCappedApi3ReaderProxyV1 {
4744
revert UpperBoundMustBeGreaterOrEqualToLowerBound();
4845
}
4946
proxy = proxy_;
50-
dappId = IApi3ReaderProxyWithDappId(proxy_).dappId();
5147
lowerBound = lowerBound_;
5248
upperBound = upperBound_;
5349
}
5450

5551
/// @notice Reads the current value and timestamp from the underlying
56-
/// `IApi3ReaderProxyWithDappId` and applies the price bounds.
52+
/// `IApi3ReaderProxy` and applies the price bounds.
5753
/// @dev If the `baseValue` from the underlying proxy is less than
5854
/// `lowerBound`, then `lowerBound` is returned as the `value`. If
5955
/// `baseValue` is greater than `upperBound`, then `upperBound` is returned.
@@ -67,9 +63,8 @@ contract PriceCappedApi3ReaderProxyV1 is IPriceCappedApi3ReaderProxyV1 {
6763
override
6864
returns (int224 value, uint32 timestamp)
6965
{
70-
(int224 baseValue, uint32 baseTimestamp) = IApi3ReaderProxyWithDappId(
71-
proxy
72-
).read();
66+
(int224 baseValue, uint32 baseTimestamp) = IApi3ReaderProxy(proxy)
67+
.read();
7368

7469
timestamp = baseTimestamp;
7570

@@ -87,7 +82,7 @@ contract PriceCappedApi3ReaderProxyV1 is IPriceCappedApi3ReaderProxyV1 {
8782
/// @return True if the base value is less than `lowerBound` or greater
8883
/// than `upperBound`, false otherwise.
8984
function isCapped() external view returns (bool) {
90-
(int224 baseValue, ) = IApi3ReaderProxyWithDappId(proxy).read();
85+
(int224 baseValue, ) = IApi3ReaderProxy(proxy).read();
9186
return baseValue < lowerBound || baseValue > upperBound;
9287
}
9388

contracts/ProductApi3ReaderProxyV1.sol

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,38 @@
11
// SPDX-License-Identifier: MIT
22
pragma solidity 0.8.27;
33

4-
import "./interfaces/IApi3ReaderProxyWithDappId.sol";
4+
import "@api3/contracts/interfaces/IApi3ReaderProxy.sol";
55
import "./interfaces/IProductApi3ReaderProxyV1.sol";
66

77
/// @title An immutable proxy contract that is used to read a composition of two
8-
/// IApi3ReaderProxyWithDappId data feeds by multiplying their values
8+
/// IApi3ReaderProxy data feeds by multiplying their values
99
/// @dev This contract implements the AggregatorV2V3Interface to be compatible
1010
/// with Chainlink aggregators. This allows the contract to be used as a drop-in
1111
/// replacement for Chainlink aggregators in existing dApps.
1212
/// Refer to https://github.com/api3dao/migrate-from-chainlink-to-api3 for more
1313
/// information about the Chainlink interface implementation.
1414
contract ProductApi3ReaderProxyV1 is IProductApi3ReaderProxyV1 {
15-
/// @notice First IApi3ReaderProxyWithDappId contract address
15+
/// @notice First IApi3ReaderProxy contract address
1616
address public immutable override proxy1;
1717

18-
/// @notice Second IApi3ReaderProxyWithDappId contract address
18+
/// @notice Second IApi3ReaderProxy contract address
1919
address public immutable override proxy2;
2020

21-
/// @notice The dApp ID of the two proxies
22-
uint256 public immutable override dappId;
23-
24-
/// @param proxy1_ First IApi3ReaderProxyWithDappId contract address
25-
/// @param proxy2_ Second IApi3ReaderProxyWithDappId contract address
21+
/// @param proxy1_ First IApi3ReaderProxy contract address
22+
/// @param proxy2_ Second IApi3ReaderProxy contract address
2623
constructor(address proxy1_, address proxy2_) {
2724
if (proxy1_ == address(0) || proxy2_ == address(0)) {
2825
revert ZeroProxyAddress();
2926
}
3027
if (proxy1_ == proxy2_) {
3128
revert SameProxyAddress();
3229
}
33-
uint256 dappId1 = IApi3ReaderProxyWithDappId(proxy1_).dappId();
34-
uint256 dappId2 = IApi3ReaderProxyWithDappId(proxy2_).dappId();
35-
if (dappId1 != dappId2) {
36-
revert DappIdMismatch();
37-
}
3830
proxy1 = proxy1_;
3931
proxy2 = proxy2_;
40-
dappId = dappId1;
4132
}
4233

4334
/// @notice Returns the current value and timestamp of the rate composition
44-
/// between two IApi3ReaderProxyWithDappId proxies by multiplying their
45-
/// values
35+
/// between two IApi3ReaderProxy proxies by multiplying their values
4636
/// @dev Calculates product as `(int256(value1) * int256(value2)) / 1e18`.
4737
/// The initial multiplication `int256(value1) * int256(value2)` may revert
4838
/// on `int256` overflow. The final `int256` result of the full expression
@@ -59,8 +49,8 @@ contract ProductApi3ReaderProxyV1 is IProductApi3ReaderProxyV1 {
5949
override
6050
returns (int224 value, uint32 timestamp)
6151
{
62-
(int224 value1, ) = IApi3ReaderProxyWithDappId(proxy1).read();
63-
(int224 value2, ) = IApi3ReaderProxyWithDappId(proxy2).read();
52+
(int224 value1, ) = IApi3ReaderProxy(proxy1).read();
53+
(int224 value2, ) = IApi3ReaderProxy(proxy2).read();
6454

6555
value = int224((int256(value1) * int256(value2)) / 1e18);
6656
timestamp = uint32(block.timestamp);

contracts/adapters/ScaledApi3FeedProxyV1.sol

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,24 @@
11
// SPDX-License-Identifier: MIT
22
pragma solidity 0.8.27;
33

4-
import "../interfaces/IApi3ReaderProxyWithDappId.sol";
4+
import "@api3/contracts/interfaces/IApi3ReaderProxy.sol";
55
import "./interfaces/IScaledApi3FeedProxyV1.sol";
66

77
/// @title An immutable Chainlink AggregatorV2V3Interface feed contract that
8-
/// scales the value of an IApi3ReaderProxyWithDappId data feed to a target
9-
/// number of decimals
8+
/// scales the value of an IApi3ReaderProxy data feed to a target number of
9+
/// decimals
1010
/// @dev This contract reads an `int224` value (assumed to be 18 decimals)
11-
/// from the underlying `IApi3ReaderProxyWithDappId` and scales it to
12-
///`targetDecimals`.
11+
/// from the underlying `IApi3ReaderProxy` and scales it to `targetDecimals`.
1312
/// The scaling arithmetic uses `int256` for intermediate results, allowing the
1413
/// scaled value to exceed `int224` limits if upscaling significantly; it will
1514
/// revert on `int256` overflow.
1615
/// When downscaling, integer division (`proxyValue / scalingFactor`) is used,
1716
/// which truncates and may lead to precision loss. Integrators must carefully
1817
/// consider this potential precision loss for their specific use case.
1918
contract ScaledApi3FeedProxyV1 is IScaledApi3FeedProxyV1 {
20-
/// @notice IApi3ReaderProxyWithDappId contract address
19+
/// @notice IApi3ReaderProxy contract address
2120
address public immutable override proxy;
2221

23-
/// @notice dApp ID of the proxy
24-
uint256 public immutable override dappId;
25-
2622
/// @notice Pre-calculated factor for scaling the proxy's 18-decimal value
2723
/// to `targetDecimals`.
2824
int256 public immutable override scalingFactor;
@@ -34,9 +30,8 @@ contract ScaledApi3FeedProxyV1 is IScaledApi3FeedProxyV1 {
3430
/// @dev Target decimals for the scaled value.
3531
uint8 private immutable targetDecimals;
3632

37-
/// @param proxy_ IApi3ReaderProxyWithDappId contract address
38-
/// @param targetDecimals_ Decimals to scale the IApi3ReaderProxyWithDappId
39-
/// value
33+
/// @param proxy_ IApi3ReaderProxy contract address
34+
/// @param targetDecimals_ Decimals to scale the IApi3ReaderProxy value
4035
constructor(address proxy_, uint8 targetDecimals_) {
4136
if (proxy_ == address(0)) {
4237
revert ZeroProxyAddress();
@@ -48,7 +43,6 @@ contract ScaledApi3FeedProxyV1 is IScaledApi3FeedProxyV1 {
4843
revert NoScalingNeeded();
4944
}
5045
proxy = proxy_;
51-
dappId = IApi3ReaderProxyWithDappId(proxy_).dappId();
5246
targetDecimals = targetDecimals_;
5347
uint8 delta = targetDecimals_ > 18
5448
? targetDecimals_ - 18
@@ -94,7 +88,7 @@ contract ScaledApi3FeedProxyV1 is IScaledApi3FeedProxyV1 {
9488
revert FunctionIsNotSupported();
9589
}
9690

97-
/// @dev Decimals used to scale the IApi3ReaderProxyWithDappId value
91+
/// @dev Decimals used to scale the IApi3ReaderProxy value
9892
function decimals() external view override returns (uint8) {
9993
return targetDecimals;
10094
}
@@ -143,7 +137,7 @@ contract ScaledApi3FeedProxyV1 is IScaledApi3FeedProxyV1 {
143137
updatedAt = startedAt;
144138
}
145139

146-
/// @notice Reads a value from the underlying `IApi3ReaderProxyWithDappId`
140+
/// @notice Reads a value from the underlying `IApi3ReaderProxy`
147141
/// and scales it to `targetDecimals`.
148142
/// @dev Reads from the underlying proxy and applies scaling to
149143
/// `targetDecimals`. Upscaling uses multiplication; downscaling uses integer
@@ -152,9 +146,8 @@ contract ScaledApi3FeedProxyV1 is IScaledApi3FeedProxyV1 {
152146
/// @return value The scaled signed fixed-point value with `targetDecimals`.
153147
/// @return timestamp The timestamp from the underlying proxy.
154148
function _read() internal view returns (int256 value, uint32 timestamp) {
155-
(int224 proxyValue, uint32 proxyTimestamp) = IApi3ReaderProxyWithDappId(
156-
proxy
157-
).read();
149+
(int224 proxyValue, uint32 proxyTimestamp) = IApi3ReaderProxy(proxy)
150+
.read();
158151

159152
value = isUpscaling
160153
? proxyValue * scalingFactor

contracts/adapters/interfaces/IScaledApi3FeedProxyV1.sol

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,4 @@ interface IScaledApi3FeedProxyV1 is AggregatorV2V3Interface {
1717
function scalingFactor() external view returns (int256);
1818

1919
function isUpscaling() external view returns (bool);
20-
21-
function dappId() external view returns (uint256);
2220
}

contracts/interfaces/IApi3ReaderProxyWithDappId.sol

Lines changed: 0 additions & 8 deletions
This file was deleted.

contracts/interfaces/IInverseApi3ReaderProxyV1.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// SPDX-License-Identifier: MIT
22
pragma solidity ^0.8.4;
33

4+
import "@api3/contracts/interfaces/IApi3ReaderProxy.sol";
45
import "../vendor/@chainlink/[email protected]/src/v0.8/shared/interfaces/AggregatorV2V3Interface.sol";
5-
import "./IApi3ReaderProxyWithDappId.sol";
66

77
interface IInverseApi3ReaderProxyV1 is
8-
IApi3ReaderProxyWithDappId,
8+
IApi3ReaderProxy,
99
AggregatorV2V3Interface
1010
{
1111
error ZeroProxyAddress();

contracts/interfaces/INormalizedApi3ReaderProxyV1.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// SPDX-License-Identifier: MIT
22
pragma solidity ^0.8.4;
33

4+
import "@api3/contracts/interfaces/IApi3ReaderProxy.sol";
45
import "../vendor/@chainlink/[email protected]/src/v0.8/shared/interfaces/AggregatorV2V3Interface.sol";
5-
import "./IApi3ReaderProxyWithDappId.sol";
66

77
interface INormalizedApi3ReaderProxyV1 is
8-
IApi3ReaderProxyWithDappId,
8+
IApi3ReaderProxy,
99
AggregatorV2V3Interface
1010
{
1111
error ZeroProxyAddress();

contracts/interfaces/IPriceCappedApi3ReaderProxyV1.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// SPDX-License-Identifier: MIT
22
pragma solidity ^0.8.4;
33

4+
import "@api3/contracts/interfaces/IApi3ReaderProxy.sol";
45
import "../vendor/@chainlink/[email protected]/src/v0.8/shared/interfaces/AggregatorV2V3Interface.sol";
5-
import "./IApi3ReaderProxyWithDappId.sol";
66

77
interface IPriceCappedApi3ReaderProxyV1 is
8-
IApi3ReaderProxyWithDappId,
8+
IApi3ReaderProxy,
99
AggregatorV2V3Interface
1010
{
1111
error ZeroProxyAddress();

0 commit comments

Comments
 (0)