Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions contracts/EtherfiRateProviderWrapper.sol
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.

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();
}
}
38 changes: 38 additions & 0 deletions contracts/EtherfiRateProviderWrapperFactory.sol
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.

pragma solidity ^0.8.0;

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;
}
}