Skip to content

Commit 07ea0e6

Browse files
committed
pulled from master, and solved conflicts
2 parents 6319733 + 53b2723 commit 07ea0e6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+4366
-3608
lines changed

.github/workflows/node.js.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
branches: [master]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
matrix:
15+
node-version: [14.x]
16+
17+
steps:
18+
- uses: actions/checkout@v2
19+
- name: Use Node.js ${{ matrix.node-version }}
20+
uses: actions/setup-node@v2
21+
with:
22+
node-version: ${{ matrix.node-version }}
23+
- uses: actions/cache@v2
24+
with:
25+
path: ~/.npm
26+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
27+
restore-keys: |
28+
${{ runner.os }}-node-
29+
- name: Install dependencies
30+
run: npm ci
31+
- name: Test
32+
run: npm run ci:test
33+
- name: Dev deployment
34+
run: npm run aave:evm:dev:migration
35+
- name: Mainnet deployment at Mainnet fork
36+
run: npm run aave:fork:main
37+
env:
38+
ALCHEMY_KEY: ${{ secrets.ALCHEMY_KEY }}
39+
- name: Amm deployment at Mainnet fork
40+
run: npm run amm:fork:main
41+
env:
42+
ALCHEMY_KEY: ${{ secrets.ALCHEMY_KEY }}
43+
- name: Aave deployment at Kovan fork
44+
run: npm run aave:fork:kovan
45+
env:
46+
ALCHEMY_KEY: ${{ secrets.ALCHEMY_KEY }}
47+
# - name: Coverage
48+
# run: npm run coverage
49+
# - uses: codecov/codecov-action@v1
50+
# with:
51+
# fail_ci_if_error: true

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
[![License: AGPL v3](https://img.shields.io/badge/License-AGPL%20v3-blue.svg)](https://www.gnu.org/licenses/agpl-3.0)
2+
[![Build pass](https://github.com/AAVE/protocol-v2/actions/workflows/node.js.yml/badge.svg)](https://github.com/aave/protocol-v2/actions/workflows/node.js.yml)
13
```
24
.///. .///. //. .// `/////////////-
35
`++:++` .++:++` :++` `++: `++:......---.`
@@ -53,8 +55,8 @@ import {ILendingPool} from "@aave/protocol-v2/contracts/interfaces/ILendingPool.
5355
5456
contract Misc {
5557
56-
function deposit(address pool, address token, address user, uint256 amount) {
57-
ILendingPool(pool).deposit(token, amount, user, '0');
58+
function deposit(address pool, address token, address user, uint256 amount) public {
59+
ILendingPool(pool).deposit(token, amount, user, 0);
5860
{...}
5961
}
6062
}

aave-v2-whitepaper.pdf

-1 Bytes
Binary file not shown.

contracts/deployments/ATokensAndRatesHelper.sol

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ contract ATokensAndRatesHelper is Ownable {
3232
uint256 liquidationBonus;
3333
uint256 reserveFactor;
3434
bool stableBorrowingEnabled;
35+
bool borrowingEnabled;
3536
}
3637

3738
constructor(
@@ -73,10 +74,12 @@ contract ATokensAndRatesHelper is Ownable {
7374
inputParams[i].liquidationBonus
7475
);
7576

76-
configurator.enableBorrowingOnReserve(
77-
inputParams[i].asset,
78-
inputParams[i].stableBorrowingEnabled
79-
);
77+
if (inputParams[i].borrowingEnabled) {
78+
configurator.enableBorrowingOnReserve(
79+
inputParams[i].asset,
80+
inputParams[i].stableBorrowingEnabled
81+
);
82+
}
8083
configurator.setReserveFactor(inputParams[i].asset, inputParams[i].reserveFactor);
8184
}
8285
}

contracts/interfaces/IAToken.sol

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,9 @@ interface IAToken is IERC20, IScaledBalanceToken, IInitializableAToken {
9999
* @dev Returns the address of the incentives controller contract
100100
**/
101101
function getIncentivesController() external view returns (IAaveIncentivesController);
102+
103+
/**
104+
* @dev Returns the address of the underlying asset of this aToken (E.g. WETH for aWETH)
105+
**/
106+
function UNDERLYING_ASSET_ADDRESS() external view returns (address);
102107
}

contracts/interfaces/IAaveIncentivesController.sol

Lines changed: 110 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,131 @@ pragma solidity 0.6.12;
33
pragma experimental ABIEncoderV2;
44

55
interface IAaveIncentivesController {
6-
struct AssetData {
7-
uint128 emissionPerSecond;
8-
uint128 lastUpdateTimestamp;
9-
uint256 index;
10-
}
6+
event RewardsAccrued(address indexed user, uint256 amount);
117

12-
function REWARD_TOKEN() external view returns (address rewardToken);
8+
event RewardsClaimed(address indexed user, address indexed to, uint256 amount);
139

14-
function PRECISION() external view returns (uint8);
10+
event RewardsClaimed(
11+
address indexed user,
12+
address indexed to,
13+
address indexed claimer,
14+
uint256 amount
15+
);
1516

16-
function DISTRIBUTION_END() external view returns (uint256);
17+
event ClaimerSet(address indexed user, address indexed claimer);
18+
19+
/*
20+
* @dev Returns the configuration of the distribution for a certain asset
21+
* @param asset The address of the reference asset of the distribution
22+
* @return The asset index, the emission per second and the last updated timestamp
23+
**/
24+
function getAssetData(address asset)
25+
external
26+
view
27+
returns (
28+
uint256,
29+
uint256,
30+
uint256
31+
);
32+
33+
/**
34+
* @dev Whitelists an address to claim the rewards on behalf of another address
35+
* @param user The address of the user
36+
* @param claimer The address of the claimer
37+
*/
38+
function setClaimer(address user, address claimer) external;
1739

18-
function assets(address underlying) external view returns (AssetData memory assets);
40+
/**
41+
* @dev Returns the whitelisted claimer for a certain address (0x0 if not set)
42+
* @param user The address of the user
43+
* @return The claimer address
44+
*/
45+
function getClaimer(address user) external view returns (address);
1946

47+
/**
48+
* @dev Configure assets for a certain rewards emission
49+
* @param assets The assets to incentivize
50+
* @param emissionsPerSecond The emission for each asset
51+
*/
52+
function configureAssets(address[] calldata assets, uint256[] calldata emissionsPerSecond)
53+
external;
54+
55+
/**
56+
* @dev Called by the corresponding asset on any update that affects the rewards distribution
57+
* @param asset The address of the user
58+
* @param userBalance The balance of the user of the asset in the lending pool
59+
* @param totalSupply The total supply of the asset in the lending pool
60+
**/
2061
function handleAction(
21-
address user,
62+
address asset,
2263
uint256 userBalance,
2364
uint256 totalSupply
2465
) external;
2566

67+
/**
68+
* @dev Returns the total of rewards of an user, already accrued + not yet accrued
69+
* @param user The address of the user
70+
* @return The rewards
71+
**/
2672
function getRewardsBalance(address[] calldata assets, address user)
2773
external
2874
view
2975
returns (uint256);
3076

31-
function getUserUnclaimedRewards(address _user) external view returns (uint256);
77+
/**
78+
* @dev Claims reward for an user, on all the assets of the lending pool, accumulating the pending rewards
79+
* @param amount Amount of rewards to claim
80+
* @param to Address that will be receiving the rewards
81+
* @return Rewards claimed
82+
**/
83+
function claimRewards(
84+
address[] calldata assets,
85+
uint256 amount,
86+
address to
87+
) external returns (uint256);
3288

89+
/**
90+
* @dev Claims reward for an user on behalf, on all the assets of the lending pool, accumulating the pending rewards. The caller must
91+
* be whitelisted via "allowClaimOnBehalf" function by the RewardsAdmin role manager
92+
* @param amount Amount of rewards to claim
93+
* @param user Address to check and claim rewards
94+
* @param to Address that will be receiving the rewards
95+
* @return Rewards claimed
96+
**/
97+
function claimRewardsOnBehalf(
98+
address[] calldata assets,
99+
uint256 amount,
100+
address user,
101+
address to
102+
) external returns (uint256);
103+
104+
/**
105+
* @dev returns the unclaimed rewards of the user
106+
* @param user the address of the user
107+
* @return the unclaimed user rewards
108+
*/
109+
function getUserUnclaimedRewards(address user) external view returns (uint256);
110+
111+
/**
112+
* @dev returns the unclaimed rewards of the user
113+
* @param user the address of the user
114+
* @param asset The asset to incentivize
115+
* @return the user index for the asset
116+
*/
33117
function getUserAssetData(address user, address asset) external view returns (uint256);
118+
119+
/**
120+
* @dev for backward compatibility with previous implementation of the Incentives controller
121+
*/
122+
function REWARD_TOKEN() external view returns (address);
123+
124+
/**
125+
* @dev for backward compatibility with previous implementation of the Incentives controller
126+
*/
127+
function PRECISION() external view returns (uint8);
128+
129+
/**
130+
* @dev for backward compatibility with previous implementation of the Incentives controller
131+
*/
132+
function DISTRIBUTION_END() external view returns (uint256);
34133
}

contracts/misc/UiPoolDataProvider.sol

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -131,39 +131,41 @@ contract UiPoolDataProvider is IUiPoolDataProvider {
131131
);
132132

133133
// incentives
134-
if (address(incentivesController) != address(0)) {
135-
IAaveIncentivesController.AssetData memory tokenIncentivesInfo =
136-
incentivesController.assets(reserveData.aTokenAddress);
137-
reserveData.aEmissionPerSecond = tokenIncentivesInfo.emissionPerSecond;
138-
reserveData.aIncentivesLastUpdateTimestamp = tokenIncentivesInfo.lastUpdateTimestamp;
139-
reserveData.aTokenIncentivesIndex = tokenIncentivesInfo.index;
140-
141-
tokenIncentivesInfo = incentivesController.assets(reserveData.stableDebtTokenAddress);
142-
reserveData.sEmissionPerSecond = tokenIncentivesInfo.emissionPerSecond;
143-
reserveData.sIncentivesLastUpdateTimestamp = tokenIncentivesInfo.lastUpdateTimestamp;
144-
reserveData.sTokenIncentivesIndex = tokenIncentivesInfo.index;
145-
146-
tokenIncentivesInfo = incentivesController.assets(reserveData.variableDebtTokenAddress);
147-
reserveData.vEmissionPerSecond = tokenIncentivesInfo.emissionPerSecond;
148-
reserveData.vIncentivesLastUpdateTimestamp = tokenIncentivesInfo.lastUpdateTimestamp;
149-
reserveData.vTokenIncentivesIndex = tokenIncentivesInfo.index;
134+
if (address(0) != address(incentivesController)) {
135+
(
136+
reserveData.aEmissionPerSecond,
137+
reserveData.aIncentivesLastUpdateTimestamp,
138+
reserveData.aTokenIncentivesIndex
139+
) = incentivesController.getAssetData(reserveData.aTokenAddress);
140+
141+
(
142+
reserveData.sEmissionPerSecond,
143+
reserveData.sIncentivesLastUpdateTimestamp,
144+
reserveData.sTokenIncentivesIndex
145+
) = incentivesController.getAssetData(reserveData.stableDebtTokenAddress);
146+
147+
(
148+
reserveData.vEmissionPerSecond,
149+
reserveData.vIncentivesLastUpdateTimestamp,
150+
reserveData.vTokenIncentivesIndex
151+
) = incentivesController.getAssetData(reserveData.variableDebtTokenAddress);
150152
}
153+
151154
if (user != address(0)) {
152155
// incentives
153-
154-
if (address(incentivesController) != address(0)) {
156+
if (address(0) != address(incentivesController)) {
155157
userReservesData[i].aTokenincentivesUserIndex = incentivesController.getUserAssetData(
156158
user,
157159
reserveData.aTokenAddress
158160
);
159-
userReservesData[i].sTokenincentivesUserIndex = incentivesController.getUserAssetData(
160-
user,
161-
reserveData.stableDebtTokenAddress
162-
);
163161
userReservesData[i].vTokenincentivesUserIndex = incentivesController.getUserAssetData(
164162
user,
165163
reserveData.variableDebtTokenAddress
166164
);
165+
userReservesData[i].sTokenincentivesUserIndex = incentivesController.getUserAssetData(
166+
user,
167+
reserveData.stableDebtTokenAddress
168+
);
167169
}
168170
// user reserve data
169171
userReservesData[i].underlyingAsset = reserveData.underlyingAsset;
@@ -201,15 +203,11 @@ contract UiPoolDataProvider is IUiPoolDataProvider {
201203

202204
IncentivesControllerData memory incentivesControllerData;
203205

204-
if (address(incentivesController) != address(0)) {
206+
if (address(0) != address(incentivesController)) {
205207
incentivesControllerData.userUnclaimedRewards = incentivesController.getUserUnclaimedRewards(user);
206-
// incentivesControllerData.rewardToken = incentivesController.REWARD_TOKEN();
207-
// incentivesControllerData.rewardTokenDecimals = IERC20Detailed(incentivesControllerData.rewardToken).decimals();
208-
// incentivesControllerData.rewardTokenSymbol = IERC20Detailed(incentivesControllerData.rewardToken).symbol();
209-
// incentivesControllerData.precision = incentivesController.PRECISION();
210208
incentivesControllerData.emissionEndTimestamp = incentivesController.DISTRIBUTION_END();
211209
}
212-
210+
213211
return (
214212
reservesData,
215213
userReservesData,

contracts/misc/interfaces/IUiPoolDataProvider.sol

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ interface IUiPoolDataProvider {
4343
uint256 stableRateSlope1;
4444
uint256 stableRateSlope2;
4545
// incentives
46-
uint128 aEmissionPerSecond;
47-
uint128 vEmissionPerSecond;
48-
uint128 sEmissionPerSecond;
46+
uint256 aEmissionPerSecond;
47+
uint256 vEmissionPerSecond;
48+
uint256 sEmissionPerSecond;
4949
uint256 aIncentivesLastUpdateTimestamp;
5050
uint256 vIncentivesLastUpdateTimestamp;
5151
uint256 sIncentivesLastUpdateTimestamp;
@@ -70,10 +70,6 @@ interface IUiPoolDataProvider {
7070

7171
struct IncentivesControllerData {
7272
uint256 userUnclaimedRewards;
73-
// address rewardToken;
74-
// uint256 rewardTokenDecimals;
75-
// string rewardTokenSymbol;
76-
// uint8 precision;
7773
uint256 emissionEndTimestamp;
7874
}
7975

contracts/protocol/lendingpool/DefaultReserveInterestRateStrategy.sol

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {PercentageMath} from '../libraries/math/PercentageMath.sol';
88
import {ILendingPoolAddressesProvider} from '../../interfaces/ILendingPoolAddressesProvider.sol';
99
import {ILendingRateOracle} from '../../interfaces/ILendingRateOracle.sol';
1010
import {IERC20} from '../../dependencies/openzeppelin/contracts/IERC20.sol';
11-
import 'hardhat/console.sol';
1211

1312
/**
1413
* @title DefaultReserveInterestRateStrategy contract

contracts/protocol/tokenization/AToken.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ contract AToken is
273273
/**
274274
* @dev Returns the address of the underlying asset of this aToken (E.g. WETH for aWETH)
275275
**/
276-
function UNDERLYING_ASSET_ADDRESS() public view returns (address) {
276+
function UNDERLYING_ASSET_ADDRESS() public override view returns (address) {
277277
return _underlyingAsset;
278278
}
279279

0 commit comments

Comments
 (0)