mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
test: Add test for excess reward/dust
This commit is contained in:
parent
991a7d424f
commit
ee142e565f
|
@ -1,6 +1,7 @@
|
||||||
import BigNumberJs from 'bignumber.js';
|
import BigNumberJs from 'bignumber.js';
|
||||||
|
import { reverse } from 'dns';
|
||||||
import { BigNumber } from 'ethers';
|
import { BigNumber } from 'ethers';
|
||||||
import { parseEther } from 'ethers/lib/utils';
|
import { formatEther, parseEther } from 'ethers/lib/utils';
|
||||||
import { MAX_UINT_AMOUNT } from '../../helpers/constants';
|
import { MAX_UINT_AMOUNT } from '../../helpers/constants';
|
||||||
import { evmRevert, evmSnapshot, increaseTime } from '../../helpers/misc-utils';
|
import { evmRevert, evmSnapshot, increaseTime } from '../../helpers/misc-utils';
|
||||||
import { makeSuite, SignerWithAddress, TestEnv } from './helpers/make-suite';
|
import { makeSuite, SignerWithAddress, TestEnv } from './helpers/make-suite';
|
||||||
|
@ -230,6 +231,78 @@ makeSuite('Reward Aware AToken', (testEnv: TestEnv) => {
|
||||||
await claim(user4);
|
await claim(user4);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Annoying case. Four users with different portions of REW via the aToken contract (withdraw before last claim)', async () => {
|
||||||
|
const {
|
||||||
|
users: [user1, user2, user3, user4],
|
||||||
|
rew,
|
||||||
|
aRew,
|
||||||
|
pool,
|
||||||
|
} = testEnv;
|
||||||
|
let users = [user1, user2]; //, user3, user4];
|
||||||
|
|
||||||
|
const printState = async () => {
|
||||||
|
let summedClaimable = BigNumber.from(0);
|
||||||
|
for (let i = 0; i < users.length; i++) {
|
||||||
|
let usr = users[i];
|
||||||
|
console.log(
|
||||||
|
`\tUser rewards: ${formatEther(
|
||||||
|
await rew.balanceOf(usr.address)
|
||||||
|
)}. User claimable rewards: ${formatEther(
|
||||||
|
await aRew.getClaimableRewards(rew.address, usr.address)
|
||||||
|
)}. User aRew balance: ${formatEther(await aRew.balanceOf(usr.address))}`
|
||||||
|
);
|
||||||
|
summedClaimable = summedClaimable.add(
|
||||||
|
await aRew.getClaimableRewards(rew.address, usr.address)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
console.log(
|
||||||
|
`\taRew Total supply: ${formatEther(
|
||||||
|
await aRew.totalSupply()
|
||||||
|
)}. Rewards in contract: ${formatEther(
|
||||||
|
await rew.balanceOf(aRew.address)
|
||||||
|
)}. Summed claimable: ${formatEther(summedClaimable)}`
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Deposits
|
||||||
|
console.log(`Mint and deposit`);
|
||||||
|
await mintAndDeposit(user1, false, parseEther('1'));
|
||||||
|
await mintAndDeposit(user2, false, parseEther('2.5'));
|
||||||
|
//await mintAndDeposit(user3, false, parseEther('4.7'));
|
||||||
|
//await mintAndDeposit(user4, false, parseEther('0.31'));
|
||||||
|
|
||||||
|
// Pass time to generate rewards
|
||||||
|
console.log(`IncreaseTime by 1000`);
|
||||||
|
await increaseTime(1000);
|
||||||
|
|
||||||
|
await printState();
|
||||||
|
|
||||||
|
// Claims and check rewards
|
||||||
|
console.log(`Claim`);
|
||||||
|
await claim(user1);
|
||||||
|
|
||||||
|
await printState();
|
||||||
|
|
||||||
|
// Pass time to generate rewards
|
||||||
|
console.log(`Increase time by 2713`);
|
||||||
|
await increaseTime(2713);
|
||||||
|
|
||||||
|
console.log(`Withdraws`);
|
||||||
|
for (let i = 0; i < users.length; i++) {
|
||||||
|
await pool
|
||||||
|
.connect(users[i].signer)
|
||||||
|
.withdraw(rew.address, MAX_UINT_AMOUNT, users[i].address);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Claims and check rewards
|
||||||
|
console.log(`Claim`);
|
||||||
|
for (let i = 0; i < users.length; i++) {
|
||||||
|
await claim(users[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
await printState();
|
||||||
|
});
|
||||||
|
|
||||||
it('Two users with half the portion of REW via the aToken contract, one burns and them claims', async () => {
|
it('Two users with half the portion of REW via the aToken contract, one burns and them claims', async () => {
|
||||||
const {
|
const {
|
||||||
users: [user1, user2],
|
users: [user1, user2],
|
||||||
|
|
Loading…
Reference in New Issue
Block a user