From a8196293785b12eabbc180a37fd3050ff0f51366 Mon Sep 17 00:00:00 2001 From: mkflow27 Date: Mon, 25 Nov 2024 12:02:49 +0100 Subject: [PATCH 1/2] feat: add etherfi rp adaptors --- contracts/EtherfiRateProviderWrapper.sol | 33 ++++++++++++++++ .../EtherfiRateProviderWrapperFactory.sol | 38 +++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 contracts/EtherfiRateProviderWrapper.sol create mode 100644 contracts/EtherfiRateProviderWrapperFactory.sol diff --git a/contracts/EtherfiRateProviderWrapper.sol b/contracts/EtherfiRateProviderWrapper.sol new file mode 100644 index 0000000..e09b4f8 --- /dev/null +++ b/contracts/EtherfiRateProviderWrapper.sol @@ -0,0 +1,33 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +pragma solidity ^0.8.0; + +import "./interfaces/IRateProvider.sol"; + +interface IEtherfiRateProvider { + function getRateSafe() external view returns (uint256); +} + +contract EtherfiRateProviderWrapper is IRateProvider { + IEtherfiRateProvider public immutable rateProvider; + + constructor(IEtherfiRateProvider _rateProvider) { + rateProvider = _rateProvider; + } + + function getRate() external view override returns (uint256) { + return rateProvider.getRateSafe(); + } +} \ No newline at end of file diff --git a/contracts/EtherfiRateProviderWrapperFactory.sol b/contracts/EtherfiRateProviderWrapperFactory.sol new file mode 100644 index 0000000..cb7a95d --- /dev/null +++ b/contracts/EtherfiRateProviderWrapperFactory.sol @@ -0,0 +1,38 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +pragma solidity ^0.8.24; + +import "./BaseRateProviderFactory.sol"; + +import "./EtherfiRateProviderWrapper.sol"; + +/** + * @title Etherfi Rate Provider Wrapper Factory + * @notice Factory for creating EtherfiRateProviderWrappers + * @dev This contract is used to create EtherfiRateProviderWrapper contracts which wraps the + * `getRateSafe` call into a `getRate` call. + */ + +contract EtherfiRateProviderWrapperFactory is BaseRateProviderFactory { + /** + * @notice Deploys a new EtherfiRateProviderWrapper contract using an EtherfiRateProvider contract. + * @param rateProvider - The EtherfiRateProvider contract. + */ + function create(IEtherfiRateProvider rateProvider) external returns (EtherfiRateProviderWrapper) { + EtherfiRateProviderWrapper rateProviderWrapper = new EtherfiRateProviderWrapper(rateProvider); + _onCreate(address(rateProviderWrapper)); + return rateProviderWrapper; + } +} \ No newline at end of file From 775ee40dfb081fb8c10bdf7ecd777dbd6beeeb24 Mon Sep 17 00:00:00 2001 From: mkflow27 Date: Mon, 25 Nov 2024 12:08:38 +0100 Subject: [PATCH 2/2] lint & build --- contracts/EtherfiRateProviderWrapper.sol | 2 +- contracts/EtherfiRateProviderWrapperFactory.sol | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/contracts/EtherfiRateProviderWrapper.sol b/contracts/EtherfiRateProviderWrapper.sol index e09b4f8..783dde2 100644 --- a/contracts/EtherfiRateProviderWrapper.sol +++ b/contracts/EtherfiRateProviderWrapper.sol @@ -30,4 +30,4 @@ contract EtherfiRateProviderWrapper is IRateProvider { function getRate() external view override returns (uint256) { return rateProvider.getRateSafe(); } -} \ No newline at end of file +} diff --git a/contracts/EtherfiRateProviderWrapperFactory.sol b/contracts/EtherfiRateProviderWrapperFactory.sol index cb7a95d..650ccc3 100644 --- a/contracts/EtherfiRateProviderWrapperFactory.sol +++ b/contracts/EtherfiRateProviderWrapperFactory.sol @@ -12,7 +12,7 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -pragma solidity ^0.8.24; +pragma solidity ^0.8.0; import "./BaseRateProviderFactory.sol"; @@ -35,4 +35,4 @@ contract EtherfiRateProviderWrapperFactory is BaseRateProviderFactory { _onCreate(address(rateProviderWrapper)); return rateProviderWrapper; } -} \ No newline at end of file +}