Skip to content

Commit c63ed6f

Browse files
committed
fix: pr comments; interface for param registry
1 parent 61294e0 commit c63ed6f

File tree

4 files changed

+59
-30
lines changed

4 files changed

+59
-30
lines changed

lib/aave-address-book

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit 6cb3a0f32db8c85115c2c7434c0e5644f18e11ff

tests/horizon/OracleDynamicBounds.t.sol

Lines changed: 15 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import {AggregatorInterface} from '../../src/contracts/dependencies/chainlink/Ag
1010

1111
import {AaveV3HorizonEthereum} from './utils/AaveV3HorizonEthereum.sol';
1212

13+
import {IParameterRegistry} from './dependencies/IParameterRegistry.sol';
14+
1315
abstract contract OracleDynamicBoundsTestBase is Test {
1416
address constant USTB_NEW_AGGREGATOR = 0x267D0DD05fbc989565C521e0B8882f61027FF32A;
1517
address constant USCC_NEW_AGGREGATOR = 0x2d7Cd12f24bD28684847bF3e4317899a4Db53c58;
@@ -37,6 +39,10 @@ abstract contract OracleDynamicBoundsTestBase is Test {
3739
mapping(address => NewAggregator) internal newAggregators; // asset => new aggregator
3840

3941
IAaveOracle internal aaveOracle;
42+
IParameterRegistry internal parameterRegistry;
43+
function setUp() public virtual {
44+
parameterRegistry = IParameterRegistry(AaveV3HorizonEthereum.RWA_ORACLE_PARAMS_REGISTRY);
45+
}
4046

4147
function test_asset(address asset, address oracleSource, bool isAdapter) internal {
4248
oracleSource = test_horizon_adapter(asset, oracleSource, isAdapter);
@@ -63,14 +69,14 @@ abstract contract OracleDynamicBoundsTestBase is Test {
6369
bool success;
6470
bytes memory data;
6571

66-
(success, data) = AaveV3HorizonEthereum.PARAM_REGISTRY.call(
72+
(success, data) = AaveV3HorizonEthereum.RWA_ORACLE_PARAMS_REGISTRY.call(
6773
abi.encodeWithSignature('assetExists(address)', asset)
6874
);
6975
require(success, 'Failed to call assetExists()');
7076
bool exists = abi.decode(data, (bool));
7177
assertEq(exists, true, 'assetExists');
7278

73-
(success, data) = AaveV3HorizonEthereum.PARAM_REGISTRY.call(
79+
(success, data) = AaveV3HorizonEthereum.RWA_ORACLE_PARAMS_REGISTRY.call(
7480
abi.encodeWithSignature('getParametersForAsset(address)', asset)
7581
);
7682
require(success, 'Failed to call getParametersForAsset()');
@@ -120,22 +126,13 @@ abstract contract OracleDynamicBoundsTestBase is Test {
120126

121127
// test look back data from param registry is valid
122128
function test_lookback_data(address asset) internal {
123-
bool success;
124-
bytes memory data;
125-
126-
(success, data) = AaveV3HorizonEthereum.PARAM_REGISTRY.call(
127-
abi.encodeWithSignature('getLookbackData(address)', asset)
128-
);
129-
require(success, 'Failed to call getLookbackData()');
130-
131-
// reads from old aggregator data
132129
(
133130
uint80 roundId,
134131
int256 answer,
135132
uint256 startedAt,
136133
uint256 updatedAt,
137134
uint80 answeredInRound
138-
) = abi.decode(data, (uint80, int256, uint256, uint256, uint80));
135+
) = parameterRegistry.getLookbackData(asset);
139136

140137
assertGt(roundId, 0, 'lookback roundId');
141138
assertGt(answer, 0, 'lookback answer');
@@ -178,17 +175,14 @@ abstract contract OracleDynamicBoundsTestBase is Test {
178175

179176
// read oracle address from param registry
180177
function _getParamRegistryOracle(address asset) internal returns (address) {
181-
(bool success, bytes memory data) = AaveV3HorizonEthereum.PARAM_REGISTRY.call(
182-
abi.encodeWithSignature('getOracle(address)', asset)
183-
);
184-
require(success, 'Failed to call getOracle()');
185-
return abi.decode(data, (address));
178+
return parameterRegistry.getOracle(asset);
186179
}
187180
}
188181

189182
/// forge-config: default.evm_version = "cancun"
190183
contract OracleDynamicBoundsTest is OracleDynamicBoundsTestBase {
191-
function setUp() public virtual {
184+
function setUp() public virtual override {
185+
super.setUp();
192186
vm.createSelectFork('mainnet', 23478406);
193187
_initEnvironment();
194188
}
@@ -294,18 +288,9 @@ contract OracleDynamicBoundsTest is OracleDynamicBoundsTestBase {
294288

295289
// check that param registry admin are set properly
296290
function test_registry_admin() external {
297-
(bool success, bytes memory data) = AaveV3HorizonEthereum.PARAM_REGISTRY.call(
298-
abi.encodeWithSignature('owner()')
299-
);
300-
require(success, 'Failed to call owner()');
301-
address owner = abi.decode(data, (address));
291+
address owner = parameterRegistry.owner();
302292
assertEq(owner, AaveV3HorizonEthereum.HORIZON_OPS, 'owner');
303-
304-
(success, data) = AaveV3HorizonEthereum.PARAM_REGISTRY.call(
305-
abi.encodeWithSignature('updater()')
306-
);
307-
require(success, 'Failed to call owner()');
308-
address updater = abi.decode(data, (address));
293+
address updater = parameterRegistry.owner();
309294
assertEq(updater, AaveV3HorizonEthereum.HORIZON_OPS, 'updater');
310295
}
311296

@@ -343,6 +328,7 @@ contract OracleDynamicBoundsTest is OracleDynamicBoundsTestBase {
343328
/// forge-config: default.evm_version = "cancun"
344329
contract OracleDynamicBoundsPostMigrationTest is OracleDynamicBoundsTest {
345330
function setUp() public virtual override {
331+
super.setUp();
346332
vm.createSelectFork('mainnet', 23483206);
347333
_initEnvironment();
348334
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// SPDX-License-Identifier: UNLICENSED
2+
pragma solidity ^0.8.0;
3+
4+
/// @dev minimal interface for the Llama Risk RWA Oracle parameter registry
5+
interface IParameterRegistry {
6+
function assetExists(address asset) external view returns (bool);
7+
8+
function getParametersForAsset(
9+
address asset
10+
)
11+
external
12+
view
13+
returns (
14+
uint64 maxExpectedApy,
15+
uint32 upperBoundTolerance,
16+
uint32 lowerBoundTolerance,
17+
uint32 maxDiscount,
18+
uint80 lookbackWindowSize,
19+
bool isUpperBoundEnabled,
20+
bool isLowerBoundEnabled,
21+
bool isActionTakingEnabled
22+
);
23+
24+
function getLookbackData(
25+
address asset
26+
)
27+
external
28+
view
29+
returns (
30+
uint80 roundId,
31+
int256 answer,
32+
uint256 startedAt,
33+
uint256 updatedAt,
34+
uint80 answeredInRound
35+
);
36+
37+
function getOracle(address asset) external view returns (address);
38+
39+
function owner() external view returns (address);
40+
41+
function updater() external view returns (address);
42+
}

tests/horizon/utils/AaveV3HorizonEthereum.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,5 @@ library AaveV3HorizonEthereum {
4242
address public constant VBILL_PRICE_FEED = 0x5ed77a9D9b7cc80E9d0D7711024AF38C2643C1c4;
4343

4444
// oracle param registry
45-
address public constant PARAM_REGISTRY = 0x69D55D504BC9556E377b340D19818E736bbB318b;
45+
address public constant RWA_ORACLE_PARAMS_REGISTRY = 0x69D55D504BC9556E377b340D19818E736bbB318b;
4646
}

0 commit comments

Comments
 (0)