Skip to content

Commit

Permalink
fix test_collateralCheckOnHypervisorRemoval test
Browse files Browse the repository at this point in the history
  • Loading branch information
ewansheldon committed Oct 21, 2024
1 parent c7966fc commit c270dda
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 4 additions & 0 deletions contracts/SmartVaultV4.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import "contracts/interfaces/ITokenManager.sol";
import "contracts/interfaces/IUSDs.sol";
import "contracts/interfaces/IWETH.sol";

import {console} from "forge-std/Test.sol";

contract SmartVaultV4 is ISmartVault {
using SafeERC20 for IERC20;

Expand Down Expand Up @@ -356,11 +358,13 @@ contract SmartVaultV4 is ISmartVault {
if (_balance == 0) revert InvalidToken();
IERC20(_token).safeIncreaseAllowance(ISmartVaultManagerV3(manager).yieldManager(), _balance);
uint256 _preDepositCollateral = usdCollateral();
console.log(_preDepositCollateral);
(address _hypervisor1, address _hypervisor2) =
ISmartVaultYieldManager(ISmartVaultManagerV3(manager).yieldManager()).deposit(_token, _stablePercentage);
addUniqueHypervisor(_hypervisor1);
if (_hypervisor2 != address(0)) addUniqueHypervisor(_hypervisor2);
uint256 _postDepositCollateral = usdCollateral();
console.log(_postDepositCollateral);
if (
_undercollateralised(_postDepositCollateral)
|| significantCollateralDrop(_preDepositCollateral, _postDepositCollateral, _minCollateralPercentage)
Expand Down
6 changes: 4 additions & 2 deletions test/foundry/SmartVault.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -478,8 +478,10 @@ contract SmartVaultTest is SmartVaultFixture, Test {
vm.startPrank(VAULT_OWNER);
address(smartVault).call{value: 1 ether}("");
SmartVaultV4.Status memory status = smartVault.status();
smartVault.mint(VAULT_OWNER, status.maxMintable * 90 / 100);
smartVault.depositYield(NATIVE, 1e5, 5e4, block.timestamp + 60);
// mint 45% of max mintable amount
// 100% of collateral is going to usd stable, so 50% of collateral will be lost
smartVault.mint(VAULT_OWNER, status.maxMintable * 45 / 100);
smartVault.depositYield(NATIVE, 1e5, 45e3, block.timestamp + 60);
SmartVaultV4.YieldPair[] memory yieldPairs = smartVault.yieldAssets();
assertEq(yieldPairs.length, 1);
address hypervisor = yieldPairs[0].hypervisor;
Expand Down

0 comments on commit c270dda

Please sign in to comment.