Description:
Smart contract deployed on Ethereum with Oracle features.
Blockchain: Ethereum
Source Code: View Code On The Blockchain
Solidity Source Code:
{"IRocketTokenRETH.sol":{"content":"// SPDX-License-Identifier: GPL-2.0-or-later\r
pragma solidity ^0.8.21;\r
\r
interface IRocketTokenRETH {\r
function getExchangeRate() external view returns (uint256);\r
}\r
"},"MinimalAggregatorV3Interface.sol":{"content":"// SPDX-License-Identifier: GPL-2.0-or-later\r
pragma solidity ^0.8.21;\r
\r
interface MinimalAggregatorV3Interface {\r
function decimals() external view returns (uint8);\r
function description() external view returns (string memory);\r
function version() external view returns (uint256);\r
function latestRoundData()\r
external\r
view\r
returns (\r
uint80 roundId,\r
int256 answer,\r
uint256 startedAt,\r
uint256 updatedAt,\r
uint80 answeredInRound\r
);\r
}"},"RethExchangeRateAdapter.sol":{"content":"// SPDX-License-Identifier: GPL-2.0-or-later\r
pragma solidity ^0.8.21;\r
\r
import {IRocketTokenRETH} from "./IRocketTokenRETH.sol";\r
import {MinimalAggregatorV3Interface} from "./MinimalAggregatorV3Interface.sol";\r
\r
/// @title rETH Exchange Rate Adapter\r
/// @notice rETH/ETH exchange rate Chainlink-compatible adapter\r
/// @dev Adapter for Rocket Pool rETH getExchangeRate() to Chainlink format\r
contract RethExchangeRateAdapter is MinimalAggregatorV3Interface {\r
uint8 public constant override decimals = 18;\r
string public constant override description = "rETH/ETH exchange rate adapter";\r
uint256 public constant override version = 1;\r
\r
IRocketTokenRETH public immutable rETH;\r
\r
constructor() {\r
rETH = IRocketTokenRETH(0xae78736Cd615f374D3085123A210448E74Fc6393);\r
}\r
\r
function latestRoundData()\r
external\r
view\r
override\r
returns (\r
uint80 roundId,\r
int256 answer,\r
uint256 startedAt,\r
uint256 updatedAt,\r
uint80 answeredInRound\r
)\r
{\r
uint256 exchangeRate = rETH.getExchangeRate();\r
\r
// Ensure the rate is valid and within reasonable bounds\r
require(exchangeRate \u003e 0, "Invalid exchange rate");\r
require(exchangeRate \u003c= type(uint192).max, "Exchange rate too large");\r
\r
return (\r
0, // roundId - not applicable for this oracle\r
int256(exchangeRate), // answer - rETH/ETH rate in 18 decimals\r
0, // startedAt - not applicable\r
block.timestamp, // updatedAt - current block time\r
0 // answeredInRound - not applicable\r
);\r
}\r
}\r
"}}
Submitted on: 2025-09-30 19:53:53
Comments
Log in to comment.
No comments yet.