2020-11-18 18:18:02 +00:00
|
|
|
import { MAX_UINT_AMOUNT, ZERO_ADDRESS } from '../helpers/constants';
|
|
|
|
import { BUIDLEREVM_CHAINID } from '../helpers/buidler-constants';
|
|
|
|
import { buildPermitParams, getSignatureFromTypedData } from '../helpers/contracts-helpers';
|
|
|
|
import { expect } from 'chai';
|
|
|
|
import { ethers } from 'ethers';
|
|
|
|
import { eEthereumNetwork, ProtocolErrors } from '../helpers/types';
|
|
|
|
import { makeSuite, TestEnv } from './helpers/make-suite';
|
|
|
|
import { DRE } from '../helpers/misc-utils';
|
2020-11-02 13:44:11 +00:00
|
|
|
import {
|
|
|
|
ConfigNames,
|
|
|
|
getATokenDomainSeparatorPerNetwork,
|
|
|
|
loadPoolConfig,
|
|
|
|
} from '../helpers/configuration';
|
2020-11-18 18:18:02 +00:00
|
|
|
import { waitForTx } from '../helpers/misc-utils';
|
2020-11-02 13:44:11 +00:00
|
|
|
import {
|
|
|
|
deployDelegationAwareAToken,
|
|
|
|
deployMintableDelegationERC20,
|
|
|
|
} from '../helpers/contracts-deployments';
|
2020-11-18 18:18:02 +00:00
|
|
|
import { DelegationAwareATokenFactory } from '../types';
|
|
|
|
import { DelegationAwareAToken } from '../types/DelegationAwareAToken';
|
|
|
|
import { MintableDelegationERC20 } from '../types/MintableDelegationERC20';
|
2020-11-02 13:44:11 +00:00
|
|
|
|
2020-11-18 18:18:02 +00:00
|
|
|
const { parseEther } = ethers.utils;
|
2020-11-02 13:44:11 +00:00
|
|
|
|
|
|
|
makeSuite('AToken: underlying delegation', (testEnv: TestEnv) => {
|
|
|
|
const poolConfig = loadPoolConfig(ConfigNames.Commons);
|
|
|
|
let delegationAToken = <DelegationAwareAToken>{};
|
2020-11-18 18:18:02 +00:00
|
|
|
let delegationERC20 = <MintableDelegationERC20>{};
|
2020-11-02 13:44:11 +00:00
|
|
|
|
|
|
|
it('Deploys a new MintableDelegationERC20 and a DelegationAwareAToken', async () => {
|
2020-11-18 18:18:02 +00:00
|
|
|
const { pool } = testEnv;
|
2020-11-02 13:44:11 +00:00
|
|
|
|
|
|
|
delegationERC20 = await deployMintableDelegationERC20(['DEL', 'DEL', '18']);
|
|
|
|
|
|
|
|
delegationAToken = await deployDelegationAwareAToken(
|
2020-11-27 17:22:23 +00:00
|
|
|
[pool.address, delegationERC20.address, ZERO_ADDRESS, 'aDEL', 'aDEL', ZERO_ADDRESS],
|
2020-11-02 13:44:11 +00:00
|
|
|
false
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('Tries to delegate with the caller not being the Aave admin', async () => {
|
2020-11-18 18:18:02 +00:00
|
|
|
const { users } = testEnv;
|
2020-11-02 13:44:11 +00:00
|
|
|
|
|
|
|
await expect(
|
|
|
|
delegationAToken.connect(users[1].signer).delegateUnderlyingTo(users[2].address)
|
2020-11-05 11:35:50 +00:00
|
|
|
).to.be.revertedWith(ProtocolErrors.CALLER_NOT_POOL_ADMIN);
|
2020-11-02 13:44:11 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('Tries to delegate to user 2', async () => {
|
2020-11-18 18:18:02 +00:00
|
|
|
const { users } = testEnv;
|
2020-11-02 13:44:11 +00:00
|
|
|
|
|
|
|
await delegationAToken.delegateUnderlyingTo(users[2].address);
|
|
|
|
|
|
|
|
const delegateeAddress = await delegationERC20.delegatee();
|
|
|
|
|
|
|
|
expect(delegateeAddress).to.be.equal(users[2].address);
|
|
|
|
});
|
|
|
|
});
|