Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/total assets #17

Merged
merged 2 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,11 @@ abstract contract ERC4626StataTokenUpgradeable is ERC4626Upgradeable, IERC4626St
return convertToAssets(maxRedeem(owner));
}

///@inheritdoc IERC4626
function totalAssets() public view override returns (uint256) {
return _convertToAssets(totalSupply(), Math.Rounding.Floor);
}

///@inheritdoc IERC4626
function maxRedeem(address owner) public view override returns (uint256) {
DataTypes.ReserveData memory reserveData = POOL.getReserveDataExtended(asset());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ contract ERC4626StataTokenUpgradeableTest is TestnetProcedures {
assertEq(erc4626Upgradeable.previewRedeem(shares), assets);
}

function test_totalAssets_shouldbeZeroOnZeroSupply() external {
assertEq(erc4626Upgradeable.totalAssets(), 0);
}

// ### DEPOSIT TESTS ###
function test_depositATokens(uint128 assets, address receiver) public {
_validateReceiver(receiver);
Expand All @@ -74,6 +78,7 @@ contract ERC4626StataTokenUpgradeableTest is TestnetProcedures {
assertEq(erc4626Upgradeable.balanceOf(receiver), shares);
assertEq(IERC20(aToken).balanceOf(address(erc4626Upgradeable)), env.amount);
assertEq(IERC20(aToken).balanceOf(user), 0);
assertEq(erc4626Upgradeable.totalAssets(), env.amount);
}

function test_depositATokens_self() external {
Expand Down