Skip to content

Commit

Permalink
fix: Use mock incentives controller instead of none
Browse files Browse the repository at this point in the history
  • Loading branch information
LHerskind committed Aug 24, 2021
1 parent 9fc80ca commit 9ffce12
Show file tree
Hide file tree
Showing 9 changed files with 114 additions and 14 deletions.
80 changes: 80 additions & 0 deletions contracts/mocks/helpers/MockIncentivesController.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
// SPDX-License-Identifier: agpl-3.0
pragma solidity 0.8.6;

import {IAaveIncentivesController} from './../../interfaces/IAaveIncentivesController.sol';

import 'hardhat/console.sol';

contract MockIncentivesController is IAaveIncentivesController {
function getAssetData(address asset)
external
view
override
returns (
uint256,
uint256,
uint256
)
{
return (0, 0, 0);
}

function setClaimer(address user, address claimer) external override {}

function getClaimer(address user) external view override returns (address) {
return address(1);
}

function configureAssets(address[] calldata assets, uint256[] calldata emissionsPerSecond)
external
override
{}

function handleAction(
address asset,
uint256 userBalance,
uint256 totalSupply
) external override {}

function getRewardsBalance(address[] calldata assets, address user)
external
view
override
returns (uint256)
{
return 0;
}

function claimRewards(
address[] calldata assets,
uint256 amount,
address user
) external view override returns (uint256) {
return 0;
}

function claimRewardsOnBehalf(
address[] calldata assets,
uint256 amount,
address user,
address to
) external view override returns (uint256) {
return 0;
}

function getUserUnclaimedRewards(address user) external view override returns (uint256) {
return 0;
}

function getUserAssetData(address user, address asset) external view override returns (uint256) {
return 0;
}

function REWARD_TOKEN() external view override returns (address) {
return address(0);
}

function PRECISION() external view override returns (uint8) {
return 0;
}
}
8 changes: 8 additions & 0 deletions helpers/contracts-deployments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ import {
VariableDebtTokenFactory,
WETH9MockedFactory,
ConfiguratorLogicFactory,
IncentivesControllerMockFactory,
MockIncentivesControllerFactory,
} from '../types';
import {
withSave,
Expand Down Expand Up @@ -373,3 +375,9 @@ export const deployMockUniswapRouter = async () =>
await new MockUniswapV2Router02Factory(await getFirstSigner()).deploy(),
eContractid.MockUniswapV2Router02
);

export const deployMockIncentivesController = async () =>
withSave(
await new MockIncentivesControllerFactory(await getFirstSigner()).deploy(),
eContractid.MockIncentivesController
);
1 change: 1 addition & 0 deletions helpers/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export enum eContractid {
PoolImpl = 'PoolImpl',
PoolConfiguratorImpl = 'PoolConfiguratorImpl',
MockUniswapV2Router02 = 'MockUniswapV2Router02',
MockIncentivesController = 'MockIncentivesController',
}

/*
Expand Down
23 changes: 15 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
],
"scripts": {
"size": "npm run compile && npm run hardhat size-contracts",
"small:test": "npm run compile && TS_NODE_TRANSPILE_ONLY=1 hardhat test ./test-suites/test-aave/__setup.spec.ts ./test-suites/test-aave/flashloan.spec.ts",
"small:test": "npm run compile && TS_NODE_TRANSPILE_ONLY=1 hardhat test ./test-suites/__setup.spec.ts ./test-suites/pool-edge.spec.ts ./test-suites/atoken-edge.spec.ts",
"run-env": "npm i && tail -f /dev/null",
"hardhat": "hardhat",
"compile": "SKIP_LOAD=true hardhat compile",
Expand Down Expand Up @@ -46,7 +46,7 @@
"ethereumjs-util": "7.0.2",
"ethers": "^5.0.19",
"globby": "^11.0.1",
"hardhat": "^2.5.0",
"hardhat": "^2.6.0",
"hardhat-contract-sizer": "^2.0.3",
"hardhat-gas-reporter": "^1.0.0",
"hardhat-typechain": "^0.3.3",
Expand Down
6 changes: 5 additions & 1 deletion test-suites/__setup.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
deployATokensAndRatesHelper,
deployWETHMocked,
deployMockUniswapRouter,
deployMockIncentivesController,
} from '../helpers/contracts-deployments';
import { ethers, Signer } from 'ethers';
import { TokenContractId, eContractid, tEthereumAddress } from '../helpers/types';
Expand Down Expand Up @@ -233,6 +234,9 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
config;
const treasuryAddress = config.ReserveFactorTreasuryAddress;

// TODO: We are adding an incentives controller
const mockIncentivesController = await deployMockIncentivesController();

await initReservesByHelper(
reservesParams,
allReservesAddresses,
Expand All @@ -242,7 +246,7 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
SymbolPrefix,
admin,
treasuryAddress,
ZERO_ADDRESS
mockIncentivesController.address // ZERO_ADDRESS
);

await configureReservesByHelper(reservesParams, allReservesAddresses, testHelpers, admin);
Expand Down
2 changes: 1 addition & 1 deletion test-suites/atoken-edge.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ makeSuite('Atoken-logic: edge cases', (testEnv: TestEnv) => {
expect(await aDai.decimals()).to.be.eq(await dai.decimals());
expect(await aDai.UNDERLYING_ASSET_ADDRESS()).to.be.eq(dai.address);
expect(await aDai.POOL()).to.be.eq(pool.address);
expect(await aDai.getIncentivesController()).to.be.eq(ZERO_ADDRESS);
expect(await aDai.getIncentivesController()).to.not.be.eq(ZERO_ADDRESS);

const scaledUserBalanceAndSupplyBefore = await aDai.getScaledUserBalanceAndSupply(
users[0].address
Expand Down
2 changes: 1 addition & 1 deletion test-suites/stable-token.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ makeSuite('Stable debt token tests', (testEnv: TestEnv) => {

expect(await stableDebtContract.UNDERLYING_ASSET_ADDRESS()).to.be.eq(dai.address);
expect(await stableDebtContract.POOL()).to.be.eq(pool.address);
expect(await stableDebtContract.getIncentivesController()).to.be.eq(ZERO_ADDRESS);
expect(await stableDebtContract.getIncentivesController()).to.not.be.eq(ZERO_ADDRESS);

const totSupplyAndRateBefore = await stableDebtContract.getTotalSupplyAndAvgRate();
expect(totSupplyAndRateBefore[0].toString()).to.be.eq('0');
Expand Down
2 changes: 1 addition & 1 deletion test-suites/variable-debt-token.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ makeSuite('Variable debt token tests', (testEnv: TestEnv) => {

expect(await variableDebtContract.UNDERLYING_ASSET_ADDRESS()).to.be.eq(dai.address);
expect(await variableDebtContract.POOL()).to.be.eq(pool.address);
expect(await variableDebtContract.getIncentivesController()).to.be.eq(ZERO_ADDRESS);
expect(await variableDebtContract.getIncentivesController()).to.not.be.eq(ZERO_ADDRESS);

const scaledUserBalanceAndSupplyUser0Before =
await variableDebtContract.getScaledUserBalanceAndSupply(users[0].address);
Expand Down

0 comments on commit 9ffce12

Please sign in to comment.