Skip to content

Commit

Permalink
fix: comments from baileyspraggins
Browse files Browse the repository at this point in the history
  • Loading branch information
sogipec committed Oct 26, 2023
1 parent f1a4709 commit bd2818c
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions contracts/ERC4626RateProvider.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,31 @@

pragma solidity ^0.8.0;

import "./interfaces/IRateProvider.sol";
import "@openzeppelin/contracts/interfaces/IERC4626.sol";

import "./interfaces/IRateProvider.sol";

/**
* @title ERC4626 Rate Provider
* @notice Returns an 18 decimal fixed point number that is the exchange rate of the
* shares of an ERC4626 to the underlying asset
*/
contract ERC4626RateProvider is IRateProvider {
IERC4626 public immutable erc4626;
uint256 public immutable base;
uint256 public immutable fixedPointOne;

constructor(IERC4626 _erc4626) {
erc4626 = _erc4626;
uint256 underlyingDecimals = IERC4626(_erc4626.asset()).decimals();
// Balancer does not support tokens with more than 18 decimals so this will never underflow
base = 10**(18 + _erc4626.decimals() - IERC4626(address(_erc4626.asset())).decimals());
fixedPointOne = 10**(18 + _erc4626.decimals() - underlyingDecimals);
}

/**
* @return An 18 decimal fixed point number that is the exchange rate of the
* shares of an ERC4626 to the underlying asset
*/
function getRate() external view override returns (uint256) {
return erc4626.convertToAssets(base);
return erc4626.convertToAssets(fixedPointOne);
}
}

0 comments on commit bd2818c

Please sign in to comment.