Files
smom-dbis-138/contracts/reserve/ReserveConversionPriceAdapter.sol

29 lines
1.0 KiB
Solidity
Raw Normal View History

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import {IReserveSystem} from "./IReserveSystem.sol";
/// @notice Live-chain shim: corrects inverted getConversionPrice on deployed ReserveSystem.
/// @dev DODOPMMIntegration only reads getPrice / getConversionPrice from the wired address.
contract ReserveConversionPriceAdapter {
IReserveSystem public immutable underlying;
constructor(address underlying_) {
require(underlying_ != address(0), "ReserveConversionPriceAdapter: zero underlying");
underlying = IReserveSystem(underlying_);
}
function getConversionPrice(
address sourceAsset,
address targetAsset
) external view returns (uint256) {
(uint256 sourcePrice,) = underlying.getPrice(sourceAsset);
(uint256 targetPrice,) = underlying.getPrice(targetAsset);
return (sourcePrice * 1e18) / targetPrice;
}
function getPrice(address asset) external view returns (uint256 price, uint256 timestamp) {
return underlying.getPrice(asset);
}
}