2021-02-07 03:10:29 +00:00
|
|
|
import { expect } from 'chai';
|
|
|
|
import { makeSuite, TestEnv } from './helpers/make-suite';
|
|
|
|
import { ProtocolErrors, eContractid } from '../../helpers/types';
|
|
|
|
import { deployContract, getContract } from '../../helpers/contracts-helpers';
|
|
|
|
import { MockAToken } from '../../types/MockAToken';
|
|
|
|
import { MockStableDebtToken } from '../../types/MockStableDebtToken';
|
|
|
|
import { MockVariableDebtToken } from '../../types/MockVariableDebtToken';
|
|
|
|
import { ZERO_ADDRESS } from '../../helpers/constants';
|
|
|
|
import {
|
|
|
|
getAToken,
|
|
|
|
getMockStableDebtToken,
|
|
|
|
getMockVariableDebtToken,
|
|
|
|
getStableDebtToken,
|
|
|
|
getVariableDebtToken,
|
|
|
|
} from '../../helpers/contracts-getters';
|
|
|
|
import {
|
|
|
|
deployMockAToken,
|
|
|
|
deployMockStableDebtToken,
|
|
|
|
deployMockVariableDebtToken,
|
|
|
|
} from '../../helpers/contracts-deployments';
|
|
|
|
|
|
|
|
makeSuite('Upgradeability', (testEnv: TestEnv) => {
|
|
|
|
const { CALLER_NOT_POOL_ADMIN } = ProtocolErrors;
|
|
|
|
let newATokenAddress: string;
|
|
|
|
let newStableTokenAddress: string;
|
|
|
|
let newVariableTokenAddress: string;
|
|
|
|
|
|
|
|
before('deploying instances', async () => {
|
|
|
|
const { dai, pool } = testEnv;
|
|
|
|
const aTokenInstance = await deployMockAToken([
|
|
|
|
pool.address,
|
|
|
|
dai.address,
|
|
|
|
ZERO_ADDRESS,
|
|
|
|
ZERO_ADDRESS,
|
2021-02-19 20:50:13 +00:00
|
|
|
'Aave AMM Market DAI updated',
|
|
|
|
'aAmmDAI',
|
2021-02-07 03:10:29 +00:00
|
|
|
]);
|
|
|
|
|
|
|
|
const stableDebtTokenInstance = await deployMockStableDebtToken([
|
|
|
|
pool.address,
|
|
|
|
dai.address,
|
|
|
|
ZERO_ADDRESS,
|
2021-02-19 20:50:13 +00:00
|
|
|
'Aave AMM Market stable debt DAI updated',
|
|
|
|
'stableDebtAmmDAI',
|
2021-02-07 03:10:29 +00:00
|
|
|
]);
|
|
|
|
|
|
|
|
const variableDebtTokenInstance = await deployMockVariableDebtToken([
|
|
|
|
pool.address,
|
|
|
|
dai.address,
|
|
|
|
ZERO_ADDRESS,
|
2021-02-19 20:50:13 +00:00
|
|
|
'Aave AMM Market variable debt DAI updated',
|
|
|
|
'variableDebtAmmDAI',
|
2021-02-07 03:10:29 +00:00
|
|
|
]);
|
|
|
|
|
|
|
|
newATokenAddress = aTokenInstance.address;
|
|
|
|
newVariableTokenAddress = variableDebtTokenInstance.address;
|
|
|
|
newStableTokenAddress = stableDebtTokenInstance.address;
|
|
|
|
});
|
|
|
|
|
|
|
|
it('Tries to update the DAI Atoken implementation with a different address than the lendingPoolManager', async () => {
|
|
|
|
const { dai, configurator, users } = testEnv;
|
|
|
|
|
|
|
|
const name = await (await getAToken(newATokenAddress)).name();
|
|
|
|
const symbol = await (await getAToken(newATokenAddress)).symbol();
|
|
|
|
|
|
|
|
const updateATokenInputParams: {
|
|
|
|
asset: string;
|
|
|
|
treasury: string;
|
|
|
|
incentivesController: string;
|
|
|
|
name: string;
|
|
|
|
symbol: string;
|
|
|
|
implementation: string;
|
|
|
|
} = {
|
|
|
|
asset: dai.address,
|
|
|
|
treasury: ZERO_ADDRESS,
|
|
|
|
incentivesController: ZERO_ADDRESS,
|
|
|
|
name: name,
|
|
|
|
symbol: symbol,
|
|
|
|
implementation: newATokenAddress,
|
|
|
|
};
|
|
|
|
await expect(
|
|
|
|
configurator.connect(users[1].signer).updateAToken(updateATokenInputParams)
|
|
|
|
).to.be.revertedWith(CALLER_NOT_POOL_ADMIN);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('Upgrades the DAI Atoken implementation ', async () => {
|
|
|
|
const { dai, configurator, aDai } = testEnv;
|
|
|
|
|
|
|
|
const name = await (await getAToken(newATokenAddress)).name();
|
|
|
|
const symbol = await (await getAToken(newATokenAddress)).symbol();
|
|
|
|
|
|
|
|
const updateATokenInputParams: {
|
|
|
|
asset: string;
|
|
|
|
treasury: string;
|
|
|
|
incentivesController: string;
|
|
|
|
name: string;
|
|
|
|
symbol: string;
|
|
|
|
implementation: string;
|
|
|
|
} = {
|
|
|
|
asset: dai.address,
|
|
|
|
treasury: ZERO_ADDRESS,
|
|
|
|
incentivesController: ZERO_ADDRESS,
|
|
|
|
name: name,
|
|
|
|
symbol: symbol,
|
|
|
|
implementation: newATokenAddress,
|
|
|
|
};
|
|
|
|
await configurator.updateAToken(updateATokenInputParams);
|
|
|
|
|
|
|
|
const tokenName = await aDai.name();
|
|
|
|
|
2021-02-19 20:50:13 +00:00
|
|
|
expect(tokenName).to.be.eq('Aave AMM Market DAI updated', 'Invalid token name');
|
2021-02-07 03:10:29 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('Tries to update the DAI Stable debt token implementation with a different address than the lendingPoolManager', async () => {
|
|
|
|
const { dai, configurator, users } = testEnv;
|
|
|
|
|
|
|
|
const name = await (await getStableDebtToken(newStableTokenAddress)).name();
|
|
|
|
const symbol = await (await getStableDebtToken(newStableTokenAddress)).symbol();
|
|
|
|
|
|
|
|
|
|
|
|
const updateDebtTokenInput: {
|
|
|
|
asset: string;
|
|
|
|
incentivesController: string;
|
|
|
|
name: string;
|
|
|
|
symbol: string;
|
|
|
|
implementation: string;
|
|
|
|
} = {
|
|
|
|
asset: dai.address,
|
|
|
|
incentivesController: ZERO_ADDRESS,
|
|
|
|
name: name,
|
|
|
|
symbol: symbol,
|
|
|
|
implementation: newStableTokenAddress,
|
|
|
|
}
|
|
|
|
|
|
|
|
await expect(
|
|
|
|
configurator
|
|
|
|
.connect(users[1].signer)
|
|
|
|
.updateStableDebtToken(updateDebtTokenInput)
|
|
|
|
).to.be.revertedWith(CALLER_NOT_POOL_ADMIN);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('Upgrades the DAI stable debt token implementation ', async () => {
|
|
|
|
const { dai, configurator, pool, helpersContract } = testEnv;
|
|
|
|
|
|
|
|
const name = await (await getStableDebtToken(newStableTokenAddress)).name();
|
|
|
|
const symbol = await (await getStableDebtToken(newStableTokenAddress)).symbol();
|
|
|
|
|
|
|
|
|
|
|
|
const updateDebtTokenInput: {
|
|
|
|
asset: string;
|
|
|
|
incentivesController: string;
|
|
|
|
name: string;
|
|
|
|
symbol: string;
|
|
|
|
implementation: string;
|
|
|
|
} = {
|
|
|
|
asset: dai.address,
|
|
|
|
incentivesController: ZERO_ADDRESS,
|
|
|
|
name: name,
|
|
|
|
symbol: symbol,
|
|
|
|
implementation: newStableTokenAddress,
|
|
|
|
}
|
|
|
|
|
|
|
|
await configurator.updateStableDebtToken(updateDebtTokenInput);
|
|
|
|
|
|
|
|
const { stableDebtTokenAddress } = await helpersContract.getReserveTokensAddresses(dai.address);
|
|
|
|
|
|
|
|
const debtToken = await getMockStableDebtToken(stableDebtTokenAddress);
|
|
|
|
|
|
|
|
const tokenName = await debtToken.name();
|
|
|
|
|
2021-02-19 20:50:13 +00:00
|
|
|
expect(tokenName).to.be.eq('Aave AMM Market stable debt DAI updated', 'Invalid token name');
|
2021-02-07 03:10:29 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('Tries to update the DAI variable debt token implementation with a different address than the lendingPoolManager', async () => {
|
|
|
|
const {dai, configurator, users} = testEnv;
|
|
|
|
|
|
|
|
const name = await (await getVariableDebtToken(newVariableTokenAddress)).name();
|
|
|
|
const symbol = await (await getVariableDebtToken(newVariableTokenAddress)).symbol();
|
|
|
|
|
|
|
|
const updateDebtTokenInput: {
|
|
|
|
asset: string;
|
|
|
|
incentivesController: string;
|
|
|
|
name: string;
|
|
|
|
symbol: string;
|
|
|
|
implementation: string;
|
|
|
|
} = {
|
|
|
|
asset: dai.address,
|
|
|
|
incentivesController: ZERO_ADDRESS,
|
|
|
|
name: name,
|
|
|
|
symbol: symbol,
|
|
|
|
implementation: newVariableTokenAddress,
|
|
|
|
}
|
|
|
|
|
|
|
|
await expect(
|
|
|
|
configurator
|
|
|
|
.connect(users[1].signer)
|
|
|
|
.updateVariableDebtToken(updateDebtTokenInput)
|
|
|
|
).to.be.revertedWith(CALLER_NOT_POOL_ADMIN);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('Upgrades the DAI variable debt token implementation ', async () => {
|
|
|
|
const {dai, configurator, pool, helpersContract} = testEnv;
|
|
|
|
|
|
|
|
const name = await (await getVariableDebtToken(newVariableTokenAddress)).name();
|
|
|
|
const symbol = await (await getVariableDebtToken(newVariableTokenAddress)).symbol();
|
|
|
|
|
|
|
|
const updateDebtTokenInput: {
|
|
|
|
asset: string;
|
|
|
|
incentivesController: string;
|
|
|
|
name: string;
|
|
|
|
symbol: string;
|
|
|
|
implementation: string;
|
|
|
|
} = {
|
|
|
|
asset: dai.address,
|
|
|
|
incentivesController: ZERO_ADDRESS,
|
|
|
|
name: name,
|
|
|
|
symbol: symbol,
|
|
|
|
implementation: newVariableTokenAddress,
|
|
|
|
}
|
|
|
|
//const name = await (await getAToken(newATokenAddress)).name();
|
|
|
|
|
|
|
|
await configurator.updateVariableDebtToken(updateDebtTokenInput);
|
|
|
|
|
|
|
|
const { variableDebtTokenAddress } = await helpersContract.getReserveTokensAddresses(
|
|
|
|
dai.address
|
|
|
|
);
|
|
|
|
|
|
|
|
const debtToken = await getMockVariableDebtToken(variableDebtTokenAddress);
|
|
|
|
|
|
|
|
const tokenName = await debtToken.name();
|
|
|
|
|
2021-02-19 20:50:13 +00:00
|
|
|
expect(tokenName).to.be.eq('Aave AMM Market variable debt DAI updated', 'Invalid token name');
|
2021-02-07 03:10:29 +00:00
|
|
|
});
|
|
|
|
});
|