mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
fix: Update paths in tests and contract.
This commit is contained in:
parent
9f3a48b5d6
commit
26f6dc8472
|
@ -4,31 +4,15 @@ pragma experimental ABIEncoderV2;
|
|||
|
||||
import {ILendingPool} from '../../interfaces/ILendingPool.sol';
|
||||
import {IERC20} from '../../dependencies/openzeppelin/contracts/IERC20.sol';
|
||||
import {IAToken} from '../../interfaces/IAToken.sol';
|
||||
import {IAaveIncentivesController} from '../../interfaces/IAaveIncentivesController.sol';
|
||||
|
||||
import {ERC20} from '../../dependencies/openzeppelin/contracts/ERC20.sol';
|
||||
import {SafeERC20} from '../../dependencies/openzeppelin/contracts/SafeERC20.sol';
|
||||
import {WadRayMath} from '../../protocol/libraries/math/WadRayMath.sol';
|
||||
import {RayMathNoRounding} from '../../protocol/libraries/math/RayMathNoRounding.sol';
|
||||
|
||||
import {SafeMath} from '../../dependencies/openzeppelin/contracts/SafeMath.sol';
|
||||
|
||||
interface IAaveIncentivesController {
|
||||
function claimRewards(
|
||||
address[] calldata assets,
|
||||
uint256 amount,
|
||||
address to
|
||||
) external returns (uint256);
|
||||
|
||||
function REWARD_TOKEN() external view returns (address);
|
||||
}
|
||||
|
||||
interface IAToken is IERC20 {
|
||||
function POOL() external view returns (ILendingPool);
|
||||
|
||||
function UNDERLYING_ASSET_ADDRESS() external view returns (address);
|
||||
|
||||
function getIncentivesController() external view returns (IAaveIncentivesController);
|
||||
}
|
||||
|
||||
contract StaticATokenLM is ERC20 {
|
||||
using SafeERC20 for IERC20;
|
||||
using SafeMath for uint256;
|
||||
|
|
2220
package-lock.json
generated
2220
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
|
@ -7,9 +7,9 @@
|
|||
"artifacts"
|
||||
],
|
||||
"scripts": {
|
||||
"test:main:lmtoken": "MAINNET_FORK=true TS_NODE_TRANSPILE_ONLY=1 hardhat test test/mainnet/static-atoken-lm/*.spec.ts",
|
||||
"coverage:lmtoken": "npm run compile && npx hardhat coverage --testfiles 'test/emptyrun.coverage.ts' && rm -rf coverage.json coverage/ && MAINNET_FORK=true TS_NODE_TRANSPILE_ONLY=1 hardhat coverage --testfiles 'test/mainnet/static-atoken-lm/*.ts'",
|
||||
"test:main:attack": "MAINNET_FORK=true TS_NODE_TRANSPILE_ONLY=1 hardhat test test/mainnet/vamtoken-attack.spec.ts",
|
||||
"test:main:lmtoken": "MAINNET_FORK=true TS_NODE_TRANSPILE_ONLY=1 hardhat test test-suites/test-aave/mainnet/static-atoken-lm/*.ts",
|
||||
"coverage:lmtoken": "npm run compile && npx hardhat coverage --testfiles 'test-suites/test-aave/emptyrun.coverage.ts' && rm -rf coverage.json coverage/ && MAINNET_FORK=true TS_NODE_TRANSPILE_ONLY=1 hardhat coverage --testfiles 'test-suites/test-aave/mainnet/static-atoken-lm/*.ts'",
|
||||
"test:main:attack": "MAINNET_FORK=true TS_NODE_TRANSPILE_ONLY=1 hardhat test test-suites/test-aave/mainnet/vamtoken-attack.spec.ts",
|
||||
"run-env": "npm i && tail -f /dev/null",
|
||||
"hardhat": "hardhat",
|
||||
"hardhat:kovan": "hardhat --network kovan",
|
||||
|
|
|
@ -12,7 +12,7 @@ import {
|
|||
WETH9,
|
||||
AToken,
|
||||
StaticATokenLM,
|
||||
} from '../../../types';
|
||||
} from '../../../../types';
|
||||
import {
|
||||
impersonateAccountsHardhat,
|
||||
DRE,
|
||||
|
@ -21,17 +21,17 @@ import {
|
|||
evmSnapshot,
|
||||
timeLatest,
|
||||
advanceTimeAndBlock,
|
||||
} from '../../../helpers/misc-utils';
|
||||
} from '../../../../helpers/misc-utils';
|
||||
import { BigNumber, providers, Signer, utils } from 'ethers';
|
||||
import { MAX_UINT_AMOUNT } from '../../../helpers/constants';
|
||||
import { tEthereumAddress } from '../../../helpers/types';
|
||||
import { MAX_UINT_AMOUNT } from '../../../../helpers/constants';
|
||||
import { tEthereumAddress } from '../../../../helpers/types';
|
||||
import { AbiCoder, formatEther, verifyTypedData } from 'ethers/lib/utils';
|
||||
|
||||
import { _TypedDataEncoder } from 'ethers/lib/utils';
|
||||
|
||||
import { expect, use } from 'chai';
|
||||
import { stat } from 'fs';
|
||||
import { getCurrentBlock } from '../../../helpers/contracts-helpers';
|
||||
import { getCurrentBlock } from '../../../../helpers/contracts-helpers';
|
||||
|
||||
//use(solidity);
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ import {
|
|||
AToken,
|
||||
StaticAToken,
|
||||
StaticATokenLM,
|
||||
} from '../../../types';
|
||||
} from '../../../../types';
|
||||
import {
|
||||
impersonateAccountsHardhat,
|
||||
DRE,
|
||||
|
@ -23,11 +23,11 @@ import {
|
|||
evmSnapshot,
|
||||
timeLatest,
|
||||
advanceTimeAndBlock,
|
||||
} from '../../../helpers/misc-utils';
|
||||
} from '../../../../helpers/misc-utils';
|
||||
import { BigNumber, providers, Signer, utils } from 'ethers';
|
||||
import { rayMul } from '../../../helpers/ray-math';
|
||||
import { MAX_UINT_AMOUNT, ZERO_ADDRESS } from '../../../helpers/constants';
|
||||
import { tEthereumAddress } from '../../../helpers/types';
|
||||
import { rayMul } from '../../../../helpers/ray-math';
|
||||
import { MAX_UINT_AMOUNT, ZERO_ADDRESS } from '../../../../helpers/constants';
|
||||
import { tEthereumAddress } from '../../../../helpers/types';
|
||||
import { AbiCoder, formatEther, verifyTypedData } from 'ethers/lib/utils';
|
||||
import { stat } from 'fs';
|
||||
|
||||
|
@ -37,7 +37,7 @@ import {
|
|||
buildMetaWithdrawParams,
|
||||
buildPermitParams,
|
||||
getSignatureFromTypedData,
|
||||
} from '../../../helpers/contracts-helpers';
|
||||
} from '../../../../helpers/contracts-helpers';
|
||||
import { TypedDataUtils, typedSignatureHash, TYPED_MESSAGE_SCHEMA } from 'eth-sig-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)
|
||||
);
|
||||
|
||||
const ownerPrivateKey = require('../../../test-wallets.js').accounts[0].secretKey;
|
||||
const ownerPrivateKey = require('../../../../test-wallets.js').accounts[0].secretKey;
|
||||
if (!ownerPrivateKey) {
|
||||
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)
|
||||
);
|
||||
|
||||
const ownerPrivateKey = require('../../../test-wallets.js').accounts[0].secretKey;
|
||||
const ownerPrivateKey = require('../../../../test-wallets.js').accounts[0].secretKey;
|
||||
if (!ownerPrivateKey) {
|
||||
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);
|
||||
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) {
|
||||
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);
|
||||
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) {
|
||||
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);
|
||||
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) {
|
||||
throw new Error('INVALID_OWNER_PK');
|
||||
}
|
||||
|
|
|
@ -7,12 +7,12 @@ import {
|
|||
ATokenFactory,
|
||||
ERC20,
|
||||
LendingPool,
|
||||
} from '../../types';
|
||||
import { impersonateAccountsHardhat, DRE, waitForTx } from '../../helpers/misc-utils';
|
||||
} from '../../../types';
|
||||
import { impersonateAccountsHardhat, DRE, waitForTx } from '../../../helpers/misc-utils';
|
||||
import { utils } from 'ethers';
|
||||
import { rayMul } from '../../helpers/ray-math';
|
||||
import { MAX_UINT_AMOUNT } from '../../helpers/constants';
|
||||
import { tEthereumAddress } from '../../helpers/types';
|
||||
import { rayMul } from '../../../helpers/ray-math';
|
||||
import { MAX_UINT_AMOUNT } from '../../../helpers/constants';
|
||||
import { tEthereumAddress } from '../../../helpers/types';
|
||||
|
||||
const { expect } = require('chai');
|
||||
|
||||
|
|
|
@ -12,19 +12,17 @@ import {
|
|||
AToken,
|
||||
WETH9,
|
||||
ERC20Factory,
|
||||
} from '../../types';
|
||||
} from '../../../types';
|
||||
import {
|
||||
impersonateAccountsHardhat,
|
||||
DRE,
|
||||
waitForTx,
|
||||
advanceTimeAndBlock,
|
||||
} from '../../helpers/misc-utils';
|
||||
} from '../../../helpers/misc-utils';
|
||||
import { utils } from 'ethers';
|
||||
import { rayMul } from '../../helpers/ray-math';
|
||||
import { MAX_UINT_AMOUNT } from '../../helpers/constants';
|
||||
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 { mint } from '../helpers/actions';
|
||||
|
||||
const { expect } = require('chai');
|
||||
|
||||
|
@ -157,7 +155,7 @@ describe('Attack', () => {
|
|||
console.log(`Total supply vamToken: ${formatEther(await vamToken.totalSupply())}`);
|
||||
|
||||
// Step 4, Alice withdraws and claims
|
||||
console.log('Step 4. Alice Withdraws');
|
||||
console.log('Step 4. Alice Withdraws and claim rewards');
|
||||
const aliceBalance = await vamToken.balanceOf(userSigner._address);
|
||||
await waitForTx(await vamToken.connect(userSigner).burn(aliceBalance));
|
||||
|
||||
|
@ -169,7 +167,7 @@ describe('Attack', () => {
|
|||
);
|
||||
|
||||
// Bob also withdraws
|
||||
console.log(`Bob also withdraws`);
|
||||
console.log(`Step 5. Bob withdraws and claim rewards`);
|
||||
const bobBalance = await vamToken.balanceOf(attackerSigner._address);
|
||||
await waitForTx(await vamToken.connect(attackerSigner).burn(bobBalance));
|
||||
await waitForTx(await vamToken.connect(userSigner).claimRewards(userSigner._address, STKAAVE));
|
||||
|
|
Loading…
Reference in New Issue
Block a user