Skip to content

Commit

Permalink
Add another getPastTotalDeposits test
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlaprade committed Dec 14, 2022
1 parent d1170d5 commit be17a37
Showing 1 changed file with 48 additions and 1 deletion.
49 changes: 48 additions & 1 deletion test/ATokenCheckpointed.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -1879,9 +1879,56 @@ contract GetPastTotalDepositsTest is AaveAtokenForkTest {
);
}

function test_GetPastTotalDepositsIsUnaffectedByTransfer() public {
_initiateRebasing();

address _userA = address(0xBEEF);
address _userB = address(0xBAD1E);
uint256 _amountA = 4242 ether;

// Deposit.
_mintGovAndSupplyToAave(_userA, _amountA);
uint256 _rawBalanceA = aToken.exposedRawBalanceOf(_userA);

// Advance the clock so that we checkpoint and let some rebasing happen.
vm.roll(block.number + 100);
vm.warp(block.timestamp + 100 days);

uint256 _totalDeposits = aToken.getPastTotalDeposits(block.number - 1);

vm.startPrank(_userA);
aToken.transfer(_userB, aToken.balanceOf(_userA) / 2);
vm.stopPrank();

// Advance the clock so that we checkpoint and let some rebasing happen.
vm.roll(block.number + 100);
vm.warp(block.timestamp + 100 days);

assertEq(
aToken.getPastTotalDeposits(block.number - 1),
_totalDeposits // No change because of the transfer;
);

// Repeat.
vm.startPrank(_userA);
aToken.transfer(_userB, aToken.balanceOf(_userA));
vm.stopPrank();

assertEq(aToken.balanceOf(_userA), 0);

// Advance the clock so that we checkpoint and let some rebasing happen.
vm.roll(block.number + 100);
vm.warp(block.timestamp + 100 days);

assertEq(
aToken.getPastTotalDeposits(block.number - 1),
_totalDeposits // Still no change caused by transfer.
);
}

// TODO do each of the tests below with and without rebasing
// TODO confirm that the totalDeposits doesn't change on transfer
// TODO confirm that the totalDeposits doesn't change on borrow
// TODO confirm that the totalDeposits doesn't change on transferUnderlying
// TODO confirm that after rebasing occurs, if all funds are withdrawn from
// Aave, that the pool's totalDepositCheckpoint would end up 0
}
Expand Down

0 comments on commit be17a37

Please sign in to comment.