Skip to content

WIP: Feat/permissioned market goerli #313

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 30 commits into
base: feat/permissioned-market
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
2b883e4
fix: Adapt code to support >128 reserves
LHerskind Nov 24, 2021
68d5980
test: Add test with >128 reserves
LHerskind Nov 24, 2021
e558db4
Merge pull request #251 from aave/fix/249-markets-with-more-assets
kartojal Nov 29, 2021
67aefa8
feat: added UiPoolDataProvider V2 with eth markets oracle case
sendra Dec 6, 2021
0895e6f
feat: added all helper versions
sendra Dec 17, 2021
d998c2f
Merge pull request #254 from aave/feat/UiPoolDataProviderV2-ethbased
kartojal Dec 17, 2021
138446b
fix: Revert reserves cap change due breaking change at ILendingPool i…
kartojal Jan 10, 2022
61c2273
Merge pull request #264 from aave/revert/reserves-cap
LHerskind Jan 10, 2022
049c84e
feat: added new fields needed for client calculations
sendra Feb 3, 2022
3f9ab86
fix: added newline
sendra Feb 3, 2022
f0fe26e
feat: added new rates fields
sendra Feb 4, 2022
2bbccd4
Merge branch 'master' of github.com:aave/protocol-v2 into feat/UiPool…
kartojal Feb 10, 2022
84fa41e
fix: return name on uipooldataprovider
sakulstra Jul 15, 2022
5df59ec
Merge pull request #300 from sakulstra/fix/return-name
kartojal Jul 18, 2022
637cd80
Merge pull request #272 from aave/feat/UiPoolDataProvider-optimalUtil…
kartojal Aug 9, 2022
742a826
feat: improve deploy scripts
kartojal Aug 9, 2022
f907950
fix: support deploy of ui helpers in fork mode
kartojal Aug 9, 2022
b172dbe
Merge pull request #305 from aave/fix/deploy-fork-ci
kartojal Aug 9, 2022
c26d157
Merge branch 'master' into feat/deploy-improvement
kartojal Aug 9, 2022
75d75e4
feat: add goerli constants for ui helpers
kartojal Aug 9, 2022
0799fbf
chore: use same package-lock
kartojal Aug 9, 2022
a48933b
feat: remove npm cache, adapt tests
kartojal Aug 9, 2022
365b039
fix: uncommented dev deployment and fix typpings
kartojal Aug 10, 2022
228c0bb
fix: use emergency admin for unpausing in prod deployment
kartojal Aug 10, 2022
0829f97
Merge pull request #306 from aave/feat/deploy-improvement
kartojal Aug 10, 2022
de0d8eb
initial setup
foodaka Aug 24, 2022
407eadf
debug goerli arc
foodaka Aug 24, 2022
b951c51
debug deployment
foodaka Sep 4, 2022
38bbbda
market configs for goerli permissioned market
foodaka Sep 6, 2022
4c4d949
remove debug
foodaka Sep 21, 2022
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
6 changes: 0 additions & 6 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@ jobs:
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install dependencies
run: npm ci
- name: Test
Expand Down
2 changes: 2 additions & 0 deletions contracts/interfaces/IChainlinkAggregator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
pragma solidity 0.6.12;

interface IChainlinkAggregator {
function decimals() external view returns (uint8);

function latestAnswer() external view returns (int256);

function latestTimestamp() external view returns (uint256);
Expand Down
308 changes: 308 additions & 0 deletions contracts/misc/UiIncentiveDataProviderV2.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,308 @@
// SPDX-License-Identifier: agpl-3.0
pragma solidity 0.6.12;
pragma experimental ABIEncoderV2;

import {ILendingPoolAddressesProvider} from '../interfaces/ILendingPoolAddressesProvider.sol';
import {IAaveIncentivesController} from '../interfaces/IAaveIncentivesController.sol';
import {IUiIncentiveDataProviderV2} from './interfaces/IUiIncentiveDataProviderV2.sol';
import {ILendingPool} from '../interfaces/ILendingPool.sol';
import {IAToken} from '../interfaces/IAToken.sol';
import {IVariableDebtToken} from '../interfaces/IVariableDebtToken.sol';
import {IStableDebtToken} from '../interfaces/IStableDebtToken.sol';
import {UserConfiguration} from '../protocol/libraries/configuration/UserConfiguration.sol';
import {DataTypes} from '../protocol/libraries/types/DataTypes.sol';
import {IERC20Detailed} from '../dependencies/openzeppelin/contracts/IERC20Detailed.sol';

contract UiIncentiveDataProviderV2 is IUiIncentiveDataProviderV2 {
using UserConfiguration for DataTypes.UserConfigurationMap;

constructor() public {}

function getFullReservesIncentiveData(ILendingPoolAddressesProvider provider, address user)
external
view
override
returns (AggregatedReserveIncentiveData[] memory, UserReserveIncentiveData[] memory)
{
return (_getReservesIncentivesData(provider), _getUserReservesIncentivesData(provider, user));
}

function getReservesIncentivesData(ILendingPoolAddressesProvider provider)
external
view
override
returns (AggregatedReserveIncentiveData[] memory)
{
return _getReservesIncentivesData(provider);
}

function _getReservesIncentivesData(ILendingPoolAddressesProvider provider)
private
view
returns (AggregatedReserveIncentiveData[] memory)
{
ILendingPool lendingPool = ILendingPool(provider.getLendingPool());
address[] memory reserves = lendingPool.getReservesList();
AggregatedReserveIncentiveData[] memory reservesIncentiveData =
new AggregatedReserveIncentiveData[](reserves.length);

for (uint256 i = 0; i < reserves.length; i++) {
AggregatedReserveIncentiveData memory reserveIncentiveData = reservesIncentiveData[i];
reserveIncentiveData.underlyingAsset = reserves[i];

DataTypes.ReserveData memory baseData = lendingPool.getReserveData(reserves[i]);

try IStableDebtToken(baseData.aTokenAddress).getIncentivesController() returns (
IAaveIncentivesController aTokenIncentiveController
) {
if (address(aTokenIncentiveController) != address(0)) {
address aRewardToken = aTokenIncentiveController.REWARD_TOKEN();

try aTokenIncentiveController.getAssetData(baseData.aTokenAddress) returns (
uint256 aTokenIncentivesIndex,
uint256 aEmissionPerSecond,
uint256 aIncentivesLastUpdateTimestamp
) {
reserveIncentiveData.aIncentiveData = IncentiveData(
aEmissionPerSecond,
aIncentivesLastUpdateTimestamp,
aTokenIncentivesIndex,
aTokenIncentiveController.DISTRIBUTION_END(),
baseData.aTokenAddress,
aRewardToken,
address(aTokenIncentiveController),
IERC20Detailed(aRewardToken).decimals(),
aTokenIncentiveController.PRECISION()
);
} catch (
bytes memory /*lowLevelData*/
) {
(
uint256 aEmissionPerSecond,
uint256 aIncentivesLastUpdateTimestamp,
uint256 aTokenIncentivesIndex
) = aTokenIncentiveController.assets(baseData.aTokenAddress);

reserveIncentiveData.aIncentiveData = IncentiveData(
aEmissionPerSecond,
aIncentivesLastUpdateTimestamp,
aTokenIncentivesIndex,
aTokenIncentiveController.DISTRIBUTION_END(),
baseData.aTokenAddress,
aRewardToken,
address(aTokenIncentiveController),
IERC20Detailed(aRewardToken).decimals(),
aTokenIncentiveController.PRECISION()
);
}
}
} catch (
bytes memory /*lowLevelData*/
) {
// Will not get here
}

try IStableDebtToken(baseData.stableDebtTokenAddress).getIncentivesController() returns (
IAaveIncentivesController sTokenIncentiveController
) {
if (address(sTokenIncentiveController) != address(0)) {
address sRewardToken = sTokenIncentiveController.REWARD_TOKEN();
try sTokenIncentiveController.getAssetData(baseData.stableDebtTokenAddress) returns (
uint256 sTokenIncentivesIndex,
uint256 sEmissionPerSecond,
uint256 sIncentivesLastUpdateTimestamp
) {
reserveIncentiveData.sIncentiveData = IncentiveData(
sEmissionPerSecond,
sIncentivesLastUpdateTimestamp,
sTokenIncentivesIndex,
sTokenIncentiveController.DISTRIBUTION_END(),
baseData.stableDebtTokenAddress,
sRewardToken,
address(sTokenIncentiveController),
IERC20Detailed(sRewardToken).decimals(),
sTokenIncentiveController.PRECISION()
);
} catch (
bytes memory /*lowLevelData*/
) {
(
uint256 sEmissionPerSecond,
uint256 sIncentivesLastUpdateTimestamp,
uint256 sTokenIncentivesIndex
) = sTokenIncentiveController.assets(baseData.stableDebtTokenAddress);

reserveIncentiveData.sIncentiveData = IncentiveData(
sEmissionPerSecond,
sIncentivesLastUpdateTimestamp,
sTokenIncentivesIndex,
sTokenIncentiveController.DISTRIBUTION_END(),
baseData.stableDebtTokenAddress,
sRewardToken,
address(sTokenIncentiveController),
IERC20Detailed(sRewardToken).decimals(),
sTokenIncentiveController.PRECISION()
);
}
}
} catch (
bytes memory /*lowLevelData*/
) {
// Will not get here
}

try IStableDebtToken(baseData.variableDebtTokenAddress).getIncentivesController() returns (
IAaveIncentivesController vTokenIncentiveController
) {
if (address(vTokenIncentiveController) != address(0)) {
address vRewardToken = vTokenIncentiveController.REWARD_TOKEN();

try vTokenIncentiveController.getAssetData(baseData.variableDebtTokenAddress) returns (
uint256 vTokenIncentivesIndex,
uint256 vEmissionPerSecond,
uint256 vIncentivesLastUpdateTimestamp
) {
reserveIncentiveData.vIncentiveData = IncentiveData(
vEmissionPerSecond,
vIncentivesLastUpdateTimestamp,
vTokenIncentivesIndex,
vTokenIncentiveController.DISTRIBUTION_END(),
baseData.variableDebtTokenAddress,
vRewardToken,
address(vTokenIncentiveController),
IERC20Detailed(vRewardToken).decimals(),
vTokenIncentiveController.PRECISION()
);
} catch (
bytes memory /*lowLevelData*/
) {
(
uint256 vEmissionPerSecond,
uint256 vIncentivesLastUpdateTimestamp,
uint256 vTokenIncentivesIndex
) = vTokenIncentiveController.assets(baseData.variableDebtTokenAddress);

reserveIncentiveData.vIncentiveData = IncentiveData(
vEmissionPerSecond,
vIncentivesLastUpdateTimestamp,
vTokenIncentivesIndex,
vTokenIncentiveController.DISTRIBUTION_END(),
baseData.variableDebtTokenAddress,
vRewardToken,
address(vTokenIncentiveController),
IERC20Detailed(vRewardToken).decimals(),
vTokenIncentiveController.PRECISION()
);
}
}
} catch (
bytes memory /*lowLevelData*/
) {
// Will not get here
}
}
return (reservesIncentiveData);
}

function getUserReservesIncentivesData(ILendingPoolAddressesProvider provider, address user)
external
view
override
returns (UserReserveIncentiveData[] memory)
{
return _getUserReservesIncentivesData(provider, user);
}

function _getUserReservesIncentivesData(ILendingPoolAddressesProvider provider, address user)
private
view
returns (UserReserveIncentiveData[] memory)
{
ILendingPool lendingPool = ILendingPool(provider.getLendingPool());
address[] memory reserves = lendingPool.getReservesList();

UserReserveIncentiveData[] memory userReservesIncentivesData =
new UserReserveIncentiveData[](user != address(0) ? reserves.length : 0);

for (uint256 i = 0; i < reserves.length; i++) {
DataTypes.ReserveData memory baseData = lendingPool.getReserveData(reserves[i]);

// user reserve data
userReservesIncentivesData[i].underlyingAsset = reserves[i];

IUiIncentiveDataProviderV2.UserIncentiveData memory aUserIncentiveData;

try IAToken(baseData.aTokenAddress).getIncentivesController() returns (
IAaveIncentivesController aTokenIncentiveController
) {
if (address(aTokenIncentiveController) != address(0)) {
address aRewardToken = aTokenIncentiveController.REWARD_TOKEN();
aUserIncentiveData.tokenincentivesUserIndex = aTokenIncentiveController.getUserAssetData(
user,
baseData.aTokenAddress
);
aUserIncentiveData.userUnclaimedRewards = aTokenIncentiveController
.getUserUnclaimedRewards(user);
aUserIncentiveData.tokenAddress = baseData.aTokenAddress;
aUserIncentiveData.rewardTokenAddress = aRewardToken;
aUserIncentiveData.incentiveControllerAddress = address(aTokenIncentiveController);
aUserIncentiveData.rewardTokenDecimals = IERC20Detailed(aRewardToken).decimals();
}
} catch (
bytes memory /*lowLevelData*/
) {}

userReservesIncentivesData[i].aTokenIncentivesUserData = aUserIncentiveData;

UserIncentiveData memory vUserIncentiveData;

try IVariableDebtToken(baseData.variableDebtTokenAddress).getIncentivesController() returns (
IAaveIncentivesController vTokenIncentiveController
) {
if (address(vTokenIncentiveController) != address(0)) {
address vRewardToken = vTokenIncentiveController.REWARD_TOKEN();
vUserIncentiveData.tokenincentivesUserIndex = vTokenIncentiveController.getUserAssetData(
user,
baseData.variableDebtTokenAddress
);
vUserIncentiveData.userUnclaimedRewards = vTokenIncentiveController
.getUserUnclaimedRewards(user);
vUserIncentiveData.tokenAddress = baseData.variableDebtTokenAddress;
vUserIncentiveData.rewardTokenAddress = vRewardToken;
vUserIncentiveData.incentiveControllerAddress = address(vTokenIncentiveController);
vUserIncentiveData.rewardTokenDecimals = IERC20Detailed(vRewardToken).decimals();
}
} catch (
bytes memory /*lowLevelData*/
) {}

userReservesIncentivesData[i].vTokenIncentivesUserData = vUserIncentiveData;

UserIncentiveData memory sUserIncentiveData;

try IStableDebtToken(baseData.stableDebtTokenAddress).getIncentivesController() returns (
IAaveIncentivesController sTokenIncentiveController
) {
if (address(sTokenIncentiveController) != address(0)) {
address sRewardToken = sTokenIncentiveController.REWARD_TOKEN();
sUserIncentiveData.tokenincentivesUserIndex = sTokenIncentiveController.getUserAssetData(
user,
baseData.stableDebtTokenAddress
);
sUserIncentiveData.userUnclaimedRewards = sTokenIncentiveController
.getUserUnclaimedRewards(user);
sUserIncentiveData.tokenAddress = baseData.stableDebtTokenAddress;
sUserIncentiveData.rewardTokenAddress = sRewardToken;
sUserIncentiveData.incentiveControllerAddress = address(sTokenIncentiveController);
sUserIncentiveData.rewardTokenDecimals = IERC20Detailed(sRewardToken).decimals();
}
} catch (
bytes memory /*lowLevelData*/
) {}

userReservesIncentivesData[i].sTokenIncentivesUserData = sUserIncentiveData;
}

return (userReservesIncentivesData);
}
}
Loading