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
18 changes: 16 additions & 2 deletions contracts/misc/UiPoolDataProviderV3.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {DataTypes} from '@zerolendxyz/core-v3/contracts/protocol/libraries/types
import {IEACAggregatorProxy} from './interfaces/IEACAggregatorProxy.sol';
import {IERC20DetailedBytes} from './interfaces/IERC20DetailedBytes.sol';
import {IUiPoolDataProviderV3} from './interfaces/IUiPoolDataProviderV3.sol';
import { ICornStakingSilo } from "./interfaces/ICornStakingSilo.sol";

contract UiPoolDataProviderV3 is IUiPoolDataProviderV3 {
using WadRayMath for uint256;
Expand All @@ -27,13 +28,16 @@ contract UiPoolDataProviderV3 is IUiPoolDataProviderV3 {
IEACAggregatorProxy public immutable marketReferenceCurrencyPriceInUsdProxyAggregator;
uint256 public constant ETH_CURRENCY_UNIT = 1 ether;
address public constant MKR_ADDRESS = 0x9f8F72aA9304c8B593d555F12eF6589cC3A579A2;
ICornStakingSilo public immutable CORN_STAKING;

constructor(
IEACAggregatorProxy _networkBaseTokenPriceInUsdProxyAggregator,
IEACAggregatorProxy _marketReferenceCurrencyPriceInUsdProxyAggregator
IEACAggregatorProxy _marketReferenceCurrencyPriceInUsdProxyAggregator,
ICornStakingSilo _cornStaking
) {
networkBaseTokenPriceInUsdProxyAggregator = _networkBaseTokenPriceInUsdProxyAggregator;
marketReferenceCurrencyPriceInUsdProxyAggregator = _marketReferenceCurrencyPriceInUsdProxyAggregator;
CORN_STAKING = _cornStaking;
}

function getReservesList(
Expand Down Expand Up @@ -83,7 +87,7 @@ contract UiPoolDataProviderV3 is IUiPoolDataProviderV3 {
reserveData.priceOracle = oracle.getSourceOfAsset(reserveData.underlyingAsset);
reserveData.availableLiquidity = IERC20Detailed(reserveData.underlyingAsset).balanceOf(
reserveData.aTokenAddress
);
) + _getCornStakingBalance(reserveData.underlyingAsset, reserveData.aTokenAddress);
(
reserveData.totalPrincipalStableDebt,
,
Expand Down Expand Up @@ -274,4 +278,14 @@ contract UiPoolDataProviderV3 is IUiPoolDataProviderV3 {
}
return string(bytesArray);
}

/**
* @notice Should return the amount of staked asset in the Corn Staking contract by the corresponding aToken
* @dev Returns the staked amount if corn staking is enabled else returns 0
* @param asset The address of the asset
* @param aToken The address of the aToken
*/
function _getCornStakingBalance(address asset, address aToken) internal view returns (uint256) {
return CORN_STAKING.sharesOf(aToken, asset);
}
}
6 changes: 6 additions & 0 deletions contracts/misc/interfaces/ICornStakingSilo.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;

interface ICornStakingSilo {
function sharesOf(address user, address token) external view returns (uint256);
}