mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
Merge branch 'feat-atoken-wrapper-liquidity-mining' of https://github.com/aave/protocol-v2 into feat-atoken-wrapper-liquidity-mining
This commit is contained in:
commit
209bd6b2de
|
@ -12,7 +12,7 @@ import {
|
||||||
WETH9,
|
WETH9,
|
||||||
AToken,
|
AToken,
|
||||||
StaticATokenLM,
|
StaticATokenLM,
|
||||||
} from '../../../../types';
|
} from '../../../types';
|
||||||
import {
|
import {
|
||||||
impersonateAccountsHardhat,
|
impersonateAccountsHardhat,
|
||||||
DRE,
|
DRE,
|
||||||
|
@ -21,17 +21,17 @@ import {
|
||||||
evmSnapshot,
|
evmSnapshot,
|
||||||
timeLatest,
|
timeLatest,
|
||||||
advanceTimeAndBlock,
|
advanceTimeAndBlock,
|
||||||
} from '../../../../helpers/misc-utils';
|
} from '../../../helpers/misc-utils';
|
||||||
import { BigNumber, providers, Signer, utils } from 'ethers';
|
import { BigNumber, providers, Signer, utils } from 'ethers';
|
||||||
import { MAX_UINT_AMOUNT } from '../../../../helpers/constants';
|
import { MAX_UINT_AMOUNT } from '../../../helpers/constants';
|
||||||
import { tEthereumAddress } from '../../../../helpers/types';
|
import { tEthereumAddress } from '../../../helpers/types';
|
||||||
import { AbiCoder, formatEther, verifyTypedData } from 'ethers/lib/utils';
|
import { AbiCoder, formatEther, verifyTypedData } from 'ethers/lib/utils';
|
||||||
|
|
||||||
import { _TypedDataEncoder } from 'ethers/lib/utils';
|
import { _TypedDataEncoder } from 'ethers/lib/utils';
|
||||||
|
|
||||||
import { expect, use } from 'chai';
|
import { expect, use } from 'chai';
|
||||||
import { stat } from 'fs';
|
import { stat } from 'fs';
|
||||||
import { getCurrentBlock } from '../../../../helpers/contracts-helpers';
|
import { getCurrentBlock } from '../../../helpers/contracts-helpers';
|
||||||
|
|
||||||
//use(solidity);
|
//use(solidity);
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ import {
|
||||||
AToken,
|
AToken,
|
||||||
StaticAToken,
|
StaticAToken,
|
||||||
StaticATokenLM,
|
StaticATokenLM,
|
||||||
} from '../../../../types';
|
} from '../../../types';
|
||||||
import {
|
import {
|
||||||
impersonateAccountsHardhat,
|
impersonateAccountsHardhat,
|
||||||
DRE,
|
DRE,
|
||||||
|
@ -23,11 +23,11 @@ import {
|
||||||
evmSnapshot,
|
evmSnapshot,
|
||||||
timeLatest,
|
timeLatest,
|
||||||
advanceTimeAndBlock,
|
advanceTimeAndBlock,
|
||||||
} from '../../../../helpers/misc-utils';
|
} from '../../../helpers/misc-utils';
|
||||||
import { BigNumber, providers, Signer, utils } from 'ethers';
|
import { BigNumber, providers, Signer, utils } from 'ethers';
|
||||||
import { rayMul } from '../../../../helpers/ray-math';
|
import { rayMul } from '../../../helpers/ray-math';
|
||||||
import { MAX_UINT_AMOUNT, ZERO_ADDRESS } from '../../../../helpers/constants';
|
import { MAX_UINT_AMOUNT, ZERO_ADDRESS } from '../../../helpers/constants';
|
||||||
import { tEthereumAddress } from '../../../../helpers/types';
|
import { tEthereumAddress } from '../../../helpers/types';
|
||||||
import { AbiCoder, formatEther, verifyTypedData } from 'ethers/lib/utils';
|
import { AbiCoder, formatEther, verifyTypedData } from 'ethers/lib/utils';
|
||||||
import { stat } from 'fs';
|
import { stat } from 'fs';
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ import {
|
||||||
buildMetaWithdrawParams,
|
buildMetaWithdrawParams,
|
||||||
buildPermitParams,
|
buildPermitParams,
|
||||||
getSignatureFromTypedData,
|
getSignatureFromTypedData,
|
||||||
} from '../../../../helpers/contracts-helpers';
|
} from '../../../helpers/contracts-helpers';
|
||||||
import { TypedDataUtils, typedSignatureHash, TYPED_MESSAGE_SCHEMA } from 'eth-sig-util';
|
import { TypedDataUtils, typedSignatureHash, TYPED_MESSAGE_SCHEMA } from 'eth-sig-util';
|
||||||
import { zeroAddress } from 'ethereumjs-util';
|
import { zeroAddress } from 'ethereumjs-util';
|
||||||
|
|
||||||
|
@ -398,7 +398,7 @@ describe('StaticATokenLM: aToken wrapper with static balances and liquidity mini
|
||||||
await staticAToken.deposit(userSigner._address, amountToDeposit, 0, true, defaultTxParams)
|
await staticAToken.deposit(userSigner._address, amountToDeposit, 0, true, defaultTxParams)
|
||||||
);
|
);
|
||||||
|
|
||||||
const ownerPrivateKey = require('../../../../test-wallets.js').accounts[0].secretKey;
|
const ownerPrivateKey = require('../../../test-wallets.js').accounts[0].secretKey;
|
||||||
if (!ownerPrivateKey) {
|
if (!ownerPrivateKey) {
|
||||||
throw new Error('INVALID_OWNER_PK');
|
throw new Error('INVALID_OWNER_PK');
|
||||||
}
|
}
|
||||||
|
@ -462,7 +462,7 @@ describe('StaticATokenLM: aToken wrapper with static balances and liquidity mini
|
||||||
await staticAToken.deposit(userSigner._address, amountToDeposit, 0, true, defaultTxParams)
|
await staticAToken.deposit(userSigner._address, amountToDeposit, 0, true, defaultTxParams)
|
||||||
);
|
);
|
||||||
|
|
||||||
const ownerPrivateKey = require('../../../../test-wallets.js').accounts[0].secretKey;
|
const ownerPrivateKey = require('../../../test-wallets.js').accounts[0].secretKey;
|
||||||
if (!ownerPrivateKey) {
|
if (!ownerPrivateKey) {
|
||||||
throw new Error('INVALID_OWNER_PK');
|
throw new Error('INVALID_OWNER_PK');
|
||||||
}
|
}
|
||||||
|
@ -528,7 +528,7 @@ describe('StaticATokenLM: aToken wrapper with static balances and liquidity mini
|
||||||
const seperator = await staticAToken.getDomainSeparator(chainId);
|
const seperator = await staticAToken.getDomainSeparator(chainId);
|
||||||
expect(seperator).to.be.eq(domainSeperator);
|
expect(seperator).to.be.eq(domainSeperator);
|
||||||
|
|
||||||
const userPrivateKey = require('../../../../test-wallets.js').accounts[0].secretKey;
|
const userPrivateKey = require('../../../test-wallets.js').accounts[0].secretKey;
|
||||||
if (!userPrivateKey) {
|
if (!userPrivateKey) {
|
||||||
throw new Error('INVALID_OWNER_PK');
|
throw new Error('INVALID_OWNER_PK');
|
||||||
}
|
}
|
||||||
|
@ -684,7 +684,7 @@ describe('StaticATokenLM: aToken wrapper with static balances and liquidity mini
|
||||||
const seperator = await staticAToken.getDomainSeparator(chainId);
|
const seperator = await staticAToken.getDomainSeparator(chainId);
|
||||||
expect(seperator).to.be.eq(domainSeperator);
|
expect(seperator).to.be.eq(domainSeperator);
|
||||||
|
|
||||||
const userPrivateKey = require('../../../../test-wallets.js').accounts[0].secretKey;
|
const userPrivateKey = require('../../../test-wallets.js').accounts[0].secretKey;
|
||||||
if (!userPrivateKey) {
|
if (!userPrivateKey) {
|
||||||
throw new Error('INVALID_OWNER_PK');
|
throw new Error('INVALID_OWNER_PK');
|
||||||
}
|
}
|
||||||
|
@ -811,7 +811,7 @@ describe('StaticATokenLM: aToken wrapper with static balances and liquidity mini
|
||||||
const seperator = await staticAToken.getDomainSeparator(chainId);
|
const seperator = await staticAToken.getDomainSeparator(chainId);
|
||||||
expect(seperator).to.be.eq(domainSeperator);
|
expect(seperator).to.be.eq(domainSeperator);
|
||||||
|
|
||||||
const userPrivateKey = require('../../../../test-wallets.js').accounts[0].secretKey;
|
const userPrivateKey = require('../../../test-wallets.js').accounts[0].secretKey;
|
||||||
if (!userPrivateKey) {
|
if (!userPrivateKey) {
|
||||||
throw new Error('INVALID_OWNER_PK');
|
throw new Error('INVALID_OWNER_PK');
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,12 +7,12 @@ import {
|
||||||
ATokenFactory,
|
ATokenFactory,
|
||||||
ERC20,
|
ERC20,
|
||||||
LendingPool,
|
LendingPool,
|
||||||
} from '../../../types';
|
} from '../../types';
|
||||||
import { impersonateAccountsHardhat, DRE, waitForTx } from '../../../helpers/misc-utils';
|
import { impersonateAccountsHardhat, DRE, waitForTx } from '../../helpers/misc-utils';
|
||||||
import { utils } from 'ethers';
|
import { utils } from 'ethers';
|
||||||
import { rayMul } from '../../../helpers/ray-math';
|
import { rayMul } from '../../helpers/ray-math';
|
||||||
import { MAX_UINT_AMOUNT } from '../../../helpers/constants';
|
import { MAX_UINT_AMOUNT } from '../../helpers/constants';
|
||||||
import { tEthereumAddress } from '../../../helpers/types';
|
import { tEthereumAddress } from '../../helpers/types';
|
||||||
|
|
||||||
const { expect } = require('chai');
|
const { expect } = require('chai');
|
||||||
|
|
||||||
|
|
|
@ -12,17 +12,19 @@ import {
|
||||||
AToken,
|
AToken,
|
||||||
WETH9,
|
WETH9,
|
||||||
ERC20Factory,
|
ERC20Factory,
|
||||||
} from '../../../types';
|
} from '../../types';
|
||||||
import {
|
import {
|
||||||
impersonateAccountsHardhat,
|
impersonateAccountsHardhat,
|
||||||
DRE,
|
DRE,
|
||||||
waitForTx,
|
waitForTx,
|
||||||
advanceTimeAndBlock,
|
advanceTimeAndBlock,
|
||||||
} from '../../../helpers/misc-utils';
|
} from '../../helpers/misc-utils';
|
||||||
import { utils } from 'ethers';
|
import { utils } from 'ethers';
|
||||||
import { MAX_UINT_AMOUNT } from '../../../helpers/constants';
|
import { rayMul } from '../../helpers/ray-math';
|
||||||
import { tEthereumAddress } from '../../../helpers/types';
|
import { MAX_UINT_AMOUNT } from '../../helpers/constants';
|
||||||
|
import { tEthereumAddress } from '../../helpers/types';
|
||||||
import { formatEther, parseEther } from 'ethers/lib/utils';
|
import { formatEther, parseEther } from 'ethers/lib/utils';
|
||||||
|
import { mint } from '../helpers/actions';
|
||||||
|
|
||||||
const { expect } = require('chai');
|
const { expect } = require('chai');
|
||||||
|
|
||||||
|
@ -155,7 +157,7 @@ describe('Attack', () => {
|
||||||
console.log(`Total supply vamToken: ${formatEther(await vamToken.totalSupply())}`);
|
console.log(`Total supply vamToken: ${formatEther(await vamToken.totalSupply())}`);
|
||||||
|
|
||||||
// Step 4, Alice withdraws and claims
|
// Step 4, Alice withdraws and claims
|
||||||
console.log('Step 4. Alice Withdraws and claim rewards');
|
console.log('Step 4. Alice Withdraws');
|
||||||
const aliceBalance = await vamToken.balanceOf(userSigner._address);
|
const aliceBalance = await vamToken.balanceOf(userSigner._address);
|
||||||
await waitForTx(await vamToken.connect(userSigner).burn(aliceBalance));
|
await waitForTx(await vamToken.connect(userSigner).burn(aliceBalance));
|
||||||
|
|
||||||
|
@ -167,7 +169,7 @@ describe('Attack', () => {
|
||||||
);
|
);
|
||||||
|
|
||||||
// Bob also withdraws
|
// Bob also withdraws
|
||||||
console.log(`Step 5. Bob withdraws and claim rewards`);
|
console.log(`Bob also withdraws`);
|
||||||
const bobBalance = await vamToken.balanceOf(attackerSigner._address);
|
const bobBalance = await vamToken.balanceOf(attackerSigner._address);
|
||||||
await waitForTx(await vamToken.connect(attackerSigner).burn(bobBalance));
|
await waitForTx(await vamToken.connect(attackerSigner).burn(bobBalance));
|
||||||
await waitForTx(await vamToken.connect(userSigner).claimRewards(userSigner._address, STKAAVE));
|
await waitForTx(await vamToken.connect(userSigner).claimRewards(userSigner._address, STKAAVE));
|
||||||
|
|
Loading…
Reference in New Issue
Block a user