{"file_path":"contracts/feeds/CustomAggregatorV3CompatibleFeedDiscounted.sol","creation_status":"success","source_code":"// SPDX-License-Identifier: MIT\npragma solidity 0.8.9;\n\nimport \"@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol\";\n\n/**\n * @title CustomAggregatorV3CompatibleFeedDiscounted\n * @notice AggregatorV3 compatible proxy-feed that discounts the price\n * of an underlying chainlink compatible feed by a given percentage\n * @author RedDuck Software\n */\ncontract CustomAggregatorV3CompatibleFeedDiscounted is AggregatorV3Interface {\n    /**\n     * @notice the underlying chainlink compatible feed\n     */\n    AggregatorV3Interface public immutable underlyingFeed;\n\n    /**\n     * @notice the discount percentage. Expressed in 10 ** decimals() precision\n     * Example: 10 ** decimals() = 1%\n     */\n    uint256 public immutable discountPercentage;\n\n    /**\n     * @notice constructor\n     * @param _underlyingFeed the underlying chainlink compatible feed\n     * @param _discountPercentage the discount percentage. Expressed in 10 ** decimals() precision\n     */\n    constructor(address _underlyingFeed, uint256 _discountPercentage) {\n        require(_underlyingFeed != address(0), \"CAD: !underlying feed\");\n        underlyingFeed = AggregatorV3Interface(_underlyingFeed);\n\n        require(\n            _discountPercentage <= 100 * (10**decimals()),\n            \"CAD: !discount percentage\"\n        );\n\n        discountPercentage = _discountPercentage;\n    }\n\n    /**\n     * @inheritdoc AggregatorV3Interface\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        (\n            roundId,\n            answer,\n            startedAt,\n            updatedAt,\n            answeredInRound\n        ) = underlyingFeed.latestRoundData();\n\n        answer = _calculateDiscountedAnswer(answer);\n    }\n\n    /**\n     * @inheritdoc AggregatorV3Interface\n     */\n    function version() external view returns (uint256) {\n        return underlyingFeed.version();\n    }\n\n    /**\n     * @inheritdoc AggregatorV3Interface\n     */\n    function getRoundData(uint80 _roundId)\n        public\n        view\n        returns (\n            uint80 roundId,\n            int256 answer,\n            uint256 startedAt,\n            uint256 updatedAt,\n            uint80 answeredInRound\n        )\n    {\n        (\n            roundId,\n            answer,\n            startedAt,\n            updatedAt,\n            answeredInRound\n        ) = underlyingFeed.getRoundData(_roundId);\n        answer = _calculateDiscountedAnswer(answer);\n    }\n\n    /**\n     * @inheritdoc AggregatorV3Interface\n     */\n    function decimals() public view returns (uint8) {\n        return underlyingFeed.decimals();\n    }\n\n    /**\n     * @inheritdoc AggregatorV3Interface\n     */\n    function description() public view returns (string memory) {\n        return\n            string(\n                abi.encodePacked(underlyingFeed.description(), \" Discounted\")\n            );\n    }\n\n    /**\n     * @dev calculates the discounted answer\n     * @param _answer the answer to discount\n     * @return the discounted answer\n     */\n    function _calculateDiscountedAnswer(int256 _answer)\n        internal\n        view\n        returns (int256)\n    {\n        require(_answer >= 0, \"CAD: !_answer\");\n\n        int256 discount = (_answer * int256(discountPercentage)) /\n            int256(100 * 10**decimals());\n\n        return _answer - discount;\n    }\n}\n","deployed_bytecode":"0x608060405234801561001057600080fd5b506004361061007d5760003560e01c80637284e4161161005b5780637284e416146100f65780639a6fc8f51461010b578063b3fa9f2414610155578063feaf968c1461017c57600080fd5b8063313ce5671461008257806342867f64146100a157806354fd4d50146100e0575b600080fd5b61008a610184565b60405160ff90911681526020015b60405180910390f35b6100c87f0000000000000000000000008d51dbc85ceef637c97d02bdaabb5e274850e68c81565b6040516001600160a01b039091168152602001610098565b6100e861021c565b604051908152602001610098565b6100fe6102af565b60405161009891906105cc565b61011e61011936600461061a565b61036a565b6040805169ffffffffffffffffffff968716815260208101959095528401929092526060830152909116608082015260a001610098565b6100e87f000000000000000000000000000000000000000000000000000000002de5448081565b61011e610438565b60007f0000000000000000000000008d51dbc85ceef637c97d02bdaabb5e274850e68c6001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b1580156101df57600080fd5b505afa1580156101f3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102179190610637565b905090565b60007f0000000000000000000000008d51dbc85ceef637c97d02bdaabb5e274850e68c6001600160a01b03166354fd4d506040518163ffffffff1660e01b815260040160206040518083038186803b15801561027757600080fd5b505afa15801561028b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610217919061065a565b60607f0000000000000000000000008d51dbc85ceef637c97d02bdaabb5e274850e68c6001600160a01b0316637284e4166040518163ffffffff1660e01b815260040160006040518083038186803b15801561030a57600080fd5b505afa15801561031e573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526103469190810190610689565b6040516020016103569190610736565b604051602081830303815290604052905090565b604051639a6fc8f560e01b815269ffffffffffffffffffff8216600482015260009081908190819081906001600160a01b037f0000000000000000000000008d51dbc85ceef637c97d02bdaabb5e274850e68c1690639a6fc8f59060240160a06040518083038186803b1580156103e057600080fd5b505afa1580156103f4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104189190610765565b93985091965094509250905061042d846104ef565b935091939590929450565b60008060008060007f0000000000000000000000008d51dbc85ceef637c97d02bdaabb5e274850e68c6001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a06040518083038186803b15801561049957600080fd5b505afa1580156104ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104d19190610765565b9398509196509450925090506104e6846104ef565b93509091929394565b6000808212156105355760405162461bcd60e51b815260206004820152600d60248201526c21a0a21d1010afb0b739bbb2b960991b604482015260640160405180910390fd5b600061053f610184565b61054a90600a6108b9565b6105559060646108c8565b61057f7f000000000000000000000000000000000000000000000000000000002de54480856108e7565b610589919061096c565b905061059581846109a8565b9392505050565b60005b838110156105b757818101518382015260200161059f565b838111156105c6576000848401525b50505050565b60208152600082518060208401526105eb81604085016020870161059c565b601f01601f19169190910160400192915050565b69ffffffffffffffffffff8116811461061757600080fd5b50565b60006020828403121561062c57600080fd5b8135610595816105ff565b60006020828403121561064957600080fd5b815160ff8116811461059557600080fd5b60006020828403121561066c57600080fd5b5051919050565b634e487b7160e01b600052604160045260246000fd5b60006020828403121561069b57600080fd5b815167ffffffffffffffff808211156106b357600080fd5b818401915084601f8301126106c757600080fd5b8151818111156106d9576106d9610673565b604051601f8201601f19908116603f0116810190838211818310171561070157610701610673565b8160405282815287602084870101111561071a57600080fd5b61072b83602083016020880161059c565b979650505050505050565b6000825161074881846020870161059c565b6a08111a5cd8dbdd5b9d195960aa1b920191825250600b01919050565b600080600080600060a0868803121561077d57600080fd5b8551610788816105ff565b8095505060208601519350604086015192506060860151915060808601516107af816105ff565b809150509295509295909350565b634e487b7160e01b600052601160045260246000fd5b600181815b8085111561080e5781600019048211156107f4576107f46107bd565b8085161561080157918102915b93841c93908002906107d8565b509250929050565b600082610825575060016108b3565b81610832575060006108b3565b816001811461084857600281146108525761086e565b60019150506108b3565b60ff841115610863576108636107bd565b50506001821b6108b3565b5060208310610133831016604e8410600b8410161715610891575081810a6108b3565b61089b83836107d3565b80600019048211156108af576108af6107bd565b0290505b92915050565b600061059560ff841683610816565b60008160001904831182151516156108e2576108e26107bd565b500290565b60006001600160ff1b038184138284138082168684048611161561090d5761090d6107bd565b600160ff1b600087128281168783058912161561092c5761092c6107bd565b60008712925087820587128484161615610948576109486107bd565b8785058712818416161561095e5761095e6107bd565b505050929093029392505050565b60008261098957634e487b7160e01b600052601260045260246000fd5b600160ff1b8214600019841416156109a3576109a36107bd565b500590565b60008083128015600160ff1b8501841216156109c6576109c66107bd565b6001600160ff1b03840183138116156109e1576109e16107bd565b5050039056fea26469706673582212202b960962e107799ae32356b804ada5ffbbf6c9be7e57c438a709e6a0fcd9f27264736f6c63430008090033","optimization_enabled":true,"verified_twin_address_hash":null,"is_verified":true,"compiler_settings":{"evmVersion":"london","libraries":{},"metadata":{"bytecodeHash":"ipfs","useLiteralContent":true},"optimizer":{"enabled":true,"runs":200},"remappings":[]},"optimization_runs":200,"sourcify_repo_url":"https://repo.sourcify.dev/contracts/full_match/1/0x4386307a07C4de7Ba11B4F4ec3e1f37BBE95dC99/","decoded_constructor_args":[["0x8D51DBC85cEef637c97D02bdaAbb5E274850e68C",{"internalType":"address","name":"_underlyingFeed","type":"address"}],["770000000",{"internalType":"uint256","name":"_discountPercentage","type":"uint256"}]],"compiler_version":"0.8.9+commit.e5eed63a","is_verified_via_verifier_alliance":false,"verified_at":"2026-02-24T10:46:59.092458Z","implementations":[],"proxy_type":null,"external_libraries":[],"creation_bytecode":"0x60c06040523480156200001157600080fd5b5060405162000db638038062000db683398101604081905262000034916200019a565b6001600160a01b038216620000905760405162461bcd60e51b815260206004820152601560248201527f4341443a2021756e6465726c79696e672066656564000000000000000000000060448201526064015b60405180910390fd5b6001600160a01b038216608052620000a76200011c565b620000b490600a620002eb565b620000c190606462000303565b811115620001125760405162461bcd60e51b815260206004820152601960248201527f4341443a2021646973636f756e742070657263656e7461676500000000000000604482015260640162000087565b60a052506200034a565b60006080516001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b1580156200015a57600080fd5b505afa1580156200016f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000195919062000325565b905090565b60008060408385031215620001ae57600080fd5b82516001600160a01b0381168114620001c657600080fd5b6020939093015192949293505050565b634e487b7160e01b600052601160045260246000fd5b600181815b808511156200022d578160001904821115620002115762000211620001d6565b808516156200021f57918102915b93841c9390800290620001f1565b509250929050565b6000826200024657506001620002e5565b816200025557506000620002e5565b81600181146200026e5760028114620002795762000299565b6001915050620002e5565b60ff8411156200028d576200028d620001d6565b50506001821b620002e5565b5060208310610133831016604e8410600b8410161715620002be575081810a620002e5565b620002ca8383620001ec565b8060001904821115620002e157620002e1620001d6565b0290505b92915050565b6000620002fc60ff84168362000235565b9392505050565b6000816000190483118215151615620003205762000320620001d6565b500290565b6000602082840312156200033857600080fd5b815160ff81168114620002fc57600080fd5b60805160a051610a1d620003996000396000818161015a015261055a01526000818160a60152818161018801528181610220015281816102b30152818161039e01526104420152610a1d6000f3fe608060405234801561001057600080fd5b506004361061007d5760003560e01c80637284e4161161005b5780637284e416146100f65780639a6fc8f51461010b578063b3fa9f2414610155578063feaf968c1461017c57600080fd5b8063313ce5671461008257806342867f64146100a157806354fd4d50146100e0575b600080fd5b61008a610184565b60405160ff90911681526020015b60405180910390f35b6100c87f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b039091168152602001610098565b6100e861021c565b604051908152602001610098565b6100fe6102af565b60405161009891906105cc565b61011e61011936600461061a565b61036a565b6040805169ffffffffffffffffffff968716815260208101959095528401929092526060830152909116608082015260a001610098565b6100e87f000000000000000000000000000000000000000000000000000000000000000081565b61011e610438565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b1580156101df57600080fd5b505afa1580156101f3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102179190610637565b905090565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166354fd4d506040518163ffffffff1660e01b815260040160206040518083038186803b15801561027757600080fd5b505afa15801561028b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610217919061065a565b60607f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316637284e4166040518163ffffffff1660e01b815260040160006040518083038186803b15801561030a57600080fd5b505afa15801561031e573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526103469190810190610689565b6040516020016103569190610736565b604051602081830303815290604052905090565b604051639a6fc8f560e01b815269ffffffffffffffffffff8216600482015260009081908190819081906001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690639a6fc8f59060240160a06040518083038186803b1580156103e057600080fd5b505afa1580156103f4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104189190610765565b93985091965094509250905061042d846104ef565b935091939590929450565b60008060008060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a06040518083038186803b15801561049957600080fd5b505afa1580156104ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104d19190610765565b9398509196509450925090506104e6846104ef565b93509091929394565b6000808212156105355760405162461bcd60e51b815260206004820152600d60248201526c21a0a21d1010afb0b739bbb2b960991b604482015260640160405180910390fd5b600061053f610184565b61054a90600a6108b9565b6105559060646108c8565b61057f7f0000000000000000000000000000000000000000000000000000000000000000856108e7565b610589919061096c565b905061059581846109a8565b9392505050565b60005b838110156105b757818101518382015260200161059f565b838111156105c6576000848401525b50505050565b60208152600082518060208401526105eb81604085016020870161059c565b601f01601f19169190910160400192915050565b69ffffffffffffffffffff8116811461061757600080fd5b50565b60006020828403121561062c57600080fd5b8135610595816105ff565b60006020828403121561064957600080fd5b815160ff8116811461059557600080fd5b60006020828403121561066c57600080fd5b5051919050565b634e487b7160e01b600052604160045260246000fd5b60006020828403121561069b57600080fd5b815167ffffffffffffffff808211156106b357600080fd5b818401915084601f8301126106c757600080fd5b8151818111156106d9576106d9610673565b604051601f8201601f19908116603f0116810190838211818310171561070157610701610673565b8160405282815287602084870101111561071a57600080fd5b61072b83602083016020880161059c565b979650505050505050565b6000825161074881846020870161059c565b6a08111a5cd8dbdd5b9d195960aa1b920191825250600b01919050565b600080600080600060a0868803121561077d57600080fd5b8551610788816105ff565b8095505060208601519350604086015192506060860151915060808601516107af816105ff565b809150509295509295909350565b634e487b7160e01b600052601160045260246000fd5b600181815b8085111561080e5781600019048211156107f4576107f46107bd565b8085161561080157918102915b93841c93908002906107d8565b509250929050565b600082610825575060016108b3565b81610832575060006108b3565b816001811461084857600281146108525761086e565b60019150506108b3565b60ff841115610863576108636107bd565b50506001821b6108b3565b5060208310610133831016604e8410600b8410161715610891575081810a6108b3565b61089b83836107d3565b80600019048211156108af576108af6107bd565b0290505b92915050565b600061059560ff841683610816565b60008160001904831182151516156108e2576108e26107bd565b500290565b60006001600160ff1b038184138284138082168684048611161561090d5761090d6107bd565b600160ff1b600087128281168783058912161561092c5761092c6107bd565b60008712925087820587128484161615610948576109486107bd565b8785058712818416161561095e5761095e6107bd565b505050929093029392505050565b60008261098957634e487b7160e01b600052601260045260246000fd5b600160ff1b8214600019841416156109a3576109a36107bd565b500590565b60008083128015600160ff1b8501841216156109c6576109c66107bd565b6001600160ff1b03840183138116156109e1576109e16107bd565b5050039056fea26469706673582212202b960962e107799ae32356b804ada5ffbbf6c9be7e57c438a709e6a0fcd9f27264736f6c634300080900330000000000000000000000008d51dbc85ceef637c97d02bdaabb5e274850e68c000000000000000000000000000000000000000000000000000000002de54480","name":"CustomAggregatorV3CompatibleFeedDiscounted","is_blueprint":false,"license_type":"none","is_fully_verified":true,"is_verified_via_eth_bytecode_db":true,"language":"solidity","evm_version":"london","can_be_visualized_via_sol2uml":true,"is_verified_via_sourcify":true,"additional_sources":[{"file_path":"@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol","source_code":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface AggregatorV3Interface {\n  function decimals() external view returns (uint8);\n\n  function description() external view returns (string memory);\n\n  function version() external view returns (uint256);\n\n  function getRoundData(uint80 _roundId)\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"}],"certified":false,"conflicting_implementations":null,"abi":[{"inputs":[{"internalType":"address","name":"_underlyingFeed","type":"address"},{"internalType":"uint256","name":"_discountPercentage","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"description","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"discountPercentage","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint80","name":"_roundId","type":"uint80"}],"name":"getRoundData","outputs":[{"internalType":"uint80","name":"roundId","type":"uint80"},{"internalType":"int256","name":"answer","type":"int256"},{"internalType":"uint256","name":"startedAt","type":"uint256"},{"internalType":"uint256","name":"updatedAt","type":"uint256"},{"internalType":"uint80","name":"answeredInRound","type":"uint80"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"latestRoundData","outputs":[{"internalType":"uint80","name":"roundId","type":"uint80"},{"internalType":"int256","name":"answer","type":"int256"},{"internalType":"uint256","name":"startedAt","type":"uint256"},{"internalType":"uint256","name":"updatedAt","type":"uint256"},{"internalType":"uint80","name":"answeredInRound","type":"uint80"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"underlyingFeed","outputs":[{"internalType":"contract AggregatorV3Interface","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"version","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}],"is_changed_bytecode":false,"is_partially_verified":false,"constructor_args":"0x0000000000000000000000008d51dbc85ceef637c97d02bdaabb5e274850e68c000000000000000000000000000000000000000000000000000000002de54480"}