Description:
Smart contract deployed on Ethereum with Factory, Oracle features.
Blockchain: Ethereum
Source Code: View Code On The Blockchain
Solidity Source Code:
{{
"language": "Solidity",
"sources": {
"src/oracles/SimpleYTOracle.sol": {
"content": "// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
import "../interfaces/AggregatorV3Interface.sol";
contract SimpleYTOracle {
address immutable feed1;
uint256 public targetDecimals = 18;
uint256 public feedDecimals;
constructor(address _ptFeed) {
feed1 = _ptFeed;
feedDecimals = AggregatorV3Interface(feed1).decimals();
}
function getPrice() public view returns (uint256) {
uint256 _price = (10 ** feedDecimals) - price(feed1);
if (feedDecimals > targetDecimals) {
_price = _price / (10 ** (feedDecimals - targetDecimals));
} else if (targetDecimals > feedDecimals) {
_price = _price * (10 ** (targetDecimals - feedDecimals));
}
return _price;
}
function price(address feed) public view returns (uint256) {
(, int256 answer,,,) = AggregatorV3Interface(feed).latestRoundData();
require(answer >= 0, "amount should be positive");
return uint256(answer);
}
}
"
},
"src/interfaces/AggregatorV3Interface.sol": {
"content": "// SPDX-License-Identifier: MIT
pragma solidity >=0.5.0;
/// @dev From
/// https://github.com/smartcontractkit/chainlink/blob/master/contracts/src/v0.8/shared/interfaces/AggregatorV3Interface.sol
interface AggregatorV3Interface {
function decimals() external view returns (uint8);
function description() external view returns (string memory);
function version() external view returns (uint256);
function getRoundData(uint80 _roundId)
external
view
returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound);
function latestRoundData()
external
view
returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound);
}
"
}
},
"settings": {
"remappings": [
"@openzeppelin/=lib/openzeppelin-contracts/",
"@morpho/=lib/morpho-blue/src/",
"@pendle/=lib/pendle-core-v2-public/contracts/",
"@openzeppelin-upgradeable/=lib/openzeppelin-contracts-upgradeable/",
"ds-test/=lib/morpho-blue/lib/forge-std/lib/ds-test/src/",
"erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
"forge-std/=lib/forge-std/src/",
"halmos-cheatcodes/=lib/openzeppelin-contracts/lib/halmos-cheatcodes/src/",
"morpho-blue/=lib/morpho-blue/",
"openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/",
"openzeppelin-contracts/=lib/openzeppelin-contracts/",
"pendle-core-v2-public/=lib/pendle-core-v2-public/contracts/"
],
"optimizer": {
"enabled": true,
"runs": 200
},
"metadata": {
"useLiteralContent": false,
"bytecodeHash": "ipfs",
"appendCBOR": true
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "prague",
"viaIR": false
}
}}
Submitted on: 2025-10-16 12:06:11
Comments
Log in to comment.
No comments yet.