{"file_path":"src/contracts/extensions/price-adapters/ScaledPriceAdapter.sol","creation_status":"success","source_code":"// SPDX-License-Identifier: BUSL-1.1\npragma solidity ^0.8.10;\n\nimport {AggregatorInterface} from '../../dependencies/chainlink/AggregatorInterface.sol';\nimport {IScaledPriceAdapter} from '../../interfaces/IScaledPriceAdapter.sol';\n\n/**\n * @title ScaledPriceAdapter\n * @author Aave Labs\n * @dev Price Adapter for Chainlink price feeds to scale price to standard USD unit of 8 decimals.\n */\ncontract ScaledPriceAdapter is IScaledPriceAdapter {\n  AggregatorInterface internal immutable _SOURCE;\n\n  uint8 internal constant _BASE_DECIMALS = 8;\n  bool internal immutable _SCALE_UP;\n  uint256 internal immutable _SCALE_FACTOR;\n\n  constructor(address source_) {\n    _SOURCE = AggregatorInterface(source_);\n    uint8 sourceDecimals = _SOURCE.decimals();\n    _SCALE_UP = sourceDecimals < _BASE_DECIMALS;\n    _SCALE_FACTOR =\n      10 ** (_SCALE_UP ? _BASE_DECIMALS - sourceDecimals : sourceDecimals - _BASE_DECIMALS);\n  }\n\n  /// @inheritdoc IScaledPriceAdapter\n  function latestAnswer() external view returns (int256) {\n    return\n      _SCALE_UP\n        ? _SOURCE.latestAnswer() * int256(_SCALE_FACTOR)\n        : _SOURCE.latestAnswer() / int256(_SCALE_FACTOR);\n  }\n\n  /// @inheritdoc IScaledPriceAdapter\n  function description() external view returns (string memory) {\n    return string.concat(_SOURCE.description(), ' (USD Scaled)');\n  }\n\n  /// @inheritdoc IScaledPriceAdapter\n  function decimals() external pure returns (uint8) {\n    return _BASE_DECIMALS;\n  }\n\n  /// @inheritdoc IScaledPriceAdapter\n  function scale() external view returns (bool, uint256) {\n    return (_SCALE_UP, _SCALE_FACTOR);\n  }\n\n  /// @inheritdoc IScaledPriceAdapter\n  function source() external view returns (address) {\n    return address(_SOURCE);\n  }\n}\n","deployed_bytecode":"0x608060405234801561000f575f80fd5b5060043610610055575f3560e01c8063313ce5671461005957806350d25bcd1461006d57806367e828bf146100835780637284e416146100ba578063f51e181a146100cf575b5f80fd5b604051600881526020015b60405180910390f35b610075610124565b604051908152602001610064565b6040516001600160a01b037f000000000000000000000000de49c7b5c0e54b1624ed21c7d88ba6593d444aa0168152602001610064565b6100c26102a5565b604051610064919061036f565b604080517f0000000000000000000000000000000000000000000000000000000000000001151581527f0000000000000000000000000000000000000000000000000000000000000064602082015201610064565b5f7f00000000000000000000000000000000000000000000000000000000000000016101fa577f00000000000000000000000000000000000000000000000000000000000000647f000000000000000000000000de49c7b5c0e54b1624ed21c7d88ba6593d444aa06001600160a01b03166350d25bcd6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156101c7573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906101eb91906103a1565b6101f591906103cc565b905090565b7f00000000000000000000000000000000000000000000000000000000000000647f000000000000000000000000de49c7b5c0e54b1624ed21c7d88ba6593d444aa06001600160a01b03166350d25bcd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610277573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061029b91906103a1565b6101f59190610404565b60607f000000000000000000000000de49c7b5c0e54b1624ed21c7d88ba6593d444aa06001600160a01b0316637284e4166040518163ffffffff1660e01b81526004015f60405180830381865afa158015610302573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f19168201604052610329919081019061044d565b60405160200161033991906104f5565b604051602081830303815290604052905090565b5f5b8381101561036757818101518382015260200161034f565b50505f910152565b602081525f825180602084015261038d81604085016020870161034d565b601f01601f19169190910160400192915050565b5f602082840312156103b1575f80fd5b5051919050565b634e487b7160e01b5f52601160045260245ffd5b5f826103e657634e487b7160e01b5f52601260045260245ffd5b600160ff1b82145f19841416156103ff576103ff6103b8565b500590565b8082025f8212600160ff1b8414161561041f5761041f6103b8565b8181058314821517610433576104336103b8565b92915050565b634e487b7160e01b5f52604160045260245ffd5b5f6020828403121561045d575f80fd5b815167ffffffffffffffff80821115610474575f80fd5b818401915084601f830112610487575f80fd5b81518181111561049957610499610439565b604051601f8201601f19908116603f011681019083821181831017156104c1576104c1610439565b816040528281528760208487010111156104d9575f80fd5b6104ea83602083016020880161034d565b979650505050505050565b5f825161050681846020870161034d565b6c2028555344205363616c65642960981b920191825250600d0191905056fea164736f6c6343000816000a","optimization_enabled":true,"verified_twin_address_hash":null,"is_verified":true,"compiler_settings":{"evmVersion":"shanghai","libraries":{"src/contracts/protocol/libraries/logic/BorrowLogic.sol":{"BorrowLogic":"0x62325c94E1c49dcDb5937726aB5D8A4c37bCAd36"},"src/contracts/protocol/libraries/logic/BridgeLogic.sol":{"BridgeLogic":"0x621Ef86D8A5C693a06295BC288B95C12D4CE4994"},"src/contracts/protocol/libraries/logic/ConfiguratorLogic.sol":{"ConfiguratorLogic":"0x09e88e877B39D883BAFd46b65E7B06CC56963041"},"src/contracts/protocol/libraries/logic/EModeLogic.sol":{"EModeLogic":"0xC31d2362fAeD85dF79d0bec99693D0EB0Abd3f74"},"src/contracts/protocol/libraries/logic/FlashLoanLogic.sol":{"FlashLoanLogic":"0x34039100cc9584Ae5D741d322e16d0d18CEE8770"},"src/contracts/protocol/libraries/logic/LiquidationLogic.sol":{"LiquidationLogic":"0x4731bF01583F991278692E8727d0700a00A1fBBf"},"src/contracts/protocol/libraries/logic/PoolLogic.sol":{"PoolLogic":"0xf8C97539934ee66a67C26010e8e027D77E821B0C"},"src/contracts/protocol/libraries/logic/SupplyLogic.sol":{"SupplyLogic":"0x185477906B46D9b8DE0DEB73A1bBfb87b5b51BC3"}},"metadata":{"appendCBOR":true,"bytecodeHash":"none","useLiteralContent":false},"optimizer":{"enabled":true,"runs":200},"outputSelection":{"*":{"":["*"],"*":["*"]}},"remappings":["solidity-utils/=lib/solidity-utils/src/","forge-std/=lib/forge-std/src/","ds-test/=lib/forge-std/lib/ds-test/src/","openzeppelin-contracts-upgradeable/=lib/solidity-utils/lib/openzeppelin-contracts-upgradeable/","openzeppelin-contracts/=lib/solidity-utils/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/","@openzeppelin/contracts-upgradeable/=lib/solidity-utils/lib/openzeppelin-contracts-upgradeable/contracts/","@openzeppelin/contracts/=lib/solidity-utils/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/contracts/","erc4626-tests/=lib/solidity-utils/lib/openzeppelin-contracts-upgradeable/lib/erc4626-tests/","halmos-cheatcodes/=lib/solidity-utils/lib/openzeppelin-contracts-upgradeable/lib/halmos-cheatcodes/src/"],"viaIR":false},"optimization_runs":200,"sourcify_repo_url":null,"decoded_constructor_args":[["0xde49c7B5C0E54b1624ED21C7D88bA6593d444Aa0",{"internalType":"address","name":"source_","type":"address"}]],"compiler_version":"v0.8.22+commit.4fc1097e","is_verified_via_verifier_alliance":false,"verified_at":"2026-05-03T14:58:21.844038Z","implementations":[],"proxy_type":null,"external_libraries":[{"name":"BorrowLogic","address_hash":"0x62325c94E1c49dcDb5937726aB5D8A4c37bCAd36"},{"name":"BridgeLogic","address_hash":"0x621Ef86D8A5C693a06295BC288B95C12D4CE4994"},{"name":"ConfiguratorLogic","address_hash":"0x09e88e877B39D883BAFd46b65E7B06CC56963041"},{"name":"EModeLogic","address_hash":"0xC31d2362fAeD85dF79d0bec99693D0EB0Abd3f74"},{"name":"FlashLoanLogic","address_hash":"0x34039100cc9584Ae5D741d322e16d0d18CEE8770"},{"name":"LiquidationLogic","address_hash":"0x4731bF01583F991278692E8727d0700a00A1fBBf"},{"name":"PoolLogic","address_hash":"0xf8C97539934ee66a67C26010e8e027D77E821B0C"},{"name":"SupplyLogic","address_hash":"0x185477906B46D9b8DE0DEB73A1bBfb87b5b51BC3"}],"creation_bytecode":"0x60e060405234801561000f575f80fd5b50604051620007d4380380620007d4833981016040819052610030916100e2565b6001600160a01b03811660808190526040805163313ce56760e01b815290515f929163313ce5679160048083019260209291908290030181865afa15801561007a573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061009e919061010f565b600860ff82161060a08190529091506100c1576100bc600882610143565b6100cc565b6100cc816008610143565b6100d790600a610242565b60c052506102509050565b5f602082840312156100f2575f80fd5b81516001600160a01b0381168114610108575f80fd5b9392505050565b5f6020828403121561011f575f80fd5b815160ff81168114610108575f80fd5b634e487b7160e01b5f52601160045260245ffd5b60ff828116828216039081111561015c5761015c61012f565b92915050565b600181815b8085111561019c57815f19048211156101825761018261012f565b8085161561018f57918102915b93841c9390800290610167565b509250929050565b5f826101b25750600161015c565b816101be57505f61015c565b81600181146101d457600281146101de576101fa565b600191505061015c565b60ff8411156101ef576101ef61012f565b50506001821b61015c565b5060208310610133831016604e8410600b841016171561021d575081810a61015c565b6102278383610162565b805f190482111561023a5761023a61012f565b029392505050565b5f61010860ff8416836101a4565b60805160a05160c051610532620002a25f395f818160fa0152818161014c01526101fc01525f818160d5015261012701525f818160900152818161016d0152818161021d01526102a901526105325ff3fe608060405234801561000f575f80fd5b5060043610610055575f3560e01c8063313ce5671461005957806350d25bcd1461006d57806367e828bf146100835780637284e416146100ba578063f51e181a146100cf575b5f80fd5b604051600881526020015b60405180910390f35b610075610124565b604051908152602001610064565b6040516001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168152602001610064565b6100c26102a5565b604051610064919061036f565b604080517f0000000000000000000000000000000000000000000000000000000000000000151581527f0000000000000000000000000000000000000000000000000000000000000000602082015201610064565b5f7f00000000000000000000000000000000000000000000000000000000000000006101fa577f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166350d25bcd6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156101c7573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906101eb91906103a1565b6101f591906103cc565b905090565b7f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166350d25bcd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610277573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061029b91906103a1565b6101f59190610404565b60607f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316637284e4166040518163ffffffff1660e01b81526004015f60405180830381865afa158015610302573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f19168201604052610329919081019061044d565b60405160200161033991906104f5565b604051602081830303815290604052905090565b5f5b8381101561036757818101518382015260200161034f565b50505f910152565b602081525f825180602084015261038d81604085016020870161034d565b601f01601f19169190910160400192915050565b5f602082840312156103b1575f80fd5b5051919050565b634e487b7160e01b5f52601160045260245ffd5b5f826103e657634e487b7160e01b5f52601260045260245ffd5b600160ff1b82145f19841416156103ff576103ff6103b8565b500590565b8082025f8212600160ff1b8414161561041f5761041f6103b8565b8181058314821517610433576104336103b8565b92915050565b634e487b7160e01b5f52604160045260245ffd5b5f6020828403121561045d575f80fd5b815167ffffffffffffffff80821115610474575f80fd5b818401915084601f830112610487575f80fd5b81518181111561049957610499610439565b604051601f8201601f19908116603f011681019083821181831017156104c1576104c1610439565b816040528281528760208487010111156104d9575f80fd5b6104ea83602083016020880161034d565b979650505050505050565b5f825161050681846020870161034d565b6c2028555344205363616c65642960981b920191825250600d0191905056fea164736f6c6343000816000a000000000000000000000000de49c7b5c0e54b1624ed21c7d88ba6593d444aa0","name":"ScaledPriceAdapter","is_blueprint":false,"license_type":"none","is_fully_verified":false,"is_verified_via_eth_bytecode_db":true,"language":"solidity","evm_version":"shanghai","can_be_visualized_via_sol2uml":true,"is_verified_via_sourcify":false,"additional_sources":[{"file_path":"src/contracts/dependencies/chainlink/AggregatorInterface.sol","source_code":"// SPDX-License-Identifier: MIT\n// Chainlink Contracts v0.8\npragma solidity ^0.8.0;\n\ninterface AggregatorInterface {\n  function decimals() external view returns (uint8);\n\n  function description() external view returns (string memory);\n\n  function getRoundData(\n    uint80 _roundId\n  )\n    external\n    view\n    returns (\n      uint80 roundId,\n      int256 answer,\n      uint256 startedAt,\n      uint256 updatedAt,\n      uint80 answeredInRound\n    );\n\n  function latestRoundData()\n    external\n    view\n    returns (\n      uint80 roundId,\n      int256 answer,\n      uint256 startedAt,\n      uint256 updatedAt,\n      uint80 answeredInRound\n    );\n\n  function latestAnswer() external view returns (int256);\n\n  function latestTimestamp() external view returns (uint256);\n\n  function latestRound() external view returns (uint256);\n\n  function getAnswer(uint256 roundId) external view returns (int256);\n\n  function getTimestamp(uint256 roundId) external view returns (uint256);\n\n  event AnswerUpdated(int256 indexed current, uint256 indexed roundId, uint256 updatedAt);\n\n  event NewRound(uint256 indexed roundId, address indexed startedBy, uint256 startedAt);\n}\n"},{"file_path":"src/contracts/interfaces/IScaledPriceAdapter.sol","source_code":"// SPDX-License-Identifier: BUSL-1.1\npragma solidity ^0.8.10;\n\ninterface IScaledPriceAdapter {\n  /**\n   * @dev Returns the feed decimals.\n   */\n  function decimals() external view returns (uint8);\n\n  /**\n   * @dev Returns the description of the feed.\n   */\n  function description() external view returns (string memory);\n\n  /**\n   * @dev Scaled `latestAnswer` from chainlink price feed.\n   * @dev Loses price precision by log10(scaleFactor) when scaling down.\n   */\n  function latestAnswer() external view returns (int256);\n\n  /**\n   * @dev Direction and units used to scale latestAnswer to base decimals of 8.\n   * @dev Loses price precision by log10(scaleFactor) when scaling down.\n   * @return scaleUp Whether to scale up or down.\n   * @return scaleFactor The units to scale by.\n   */\n  function scale() external view returns (bool scaleUp, uint256 scaleFactor);\n\n  /**\n   * @dev Underlying chainlink price feed.\n   */\n  function source() external view returns (address);\n}\n"}],"certified":false,"conflicting_implementations":null,"abi":[{"inputs":[{"internalType":"address","name":"source_","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"description","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"latestAnswer","outputs":[{"internalType":"int256","name":"","type":"int256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"scale","outputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"source","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}],"is_changed_bytecode":false,"is_partially_verified":true,"constructor_args":"000000000000000000000000de49c7b5c0e54b1624ed21c7d88ba6593d444aa0"}