Skip to content

Commit

Permalink
added outstanding allowance
Browse files Browse the repository at this point in the history
  • Loading branch information
RedVeil committed Oct 21, 2024
1 parent 5187e02 commit 81cd155
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/strategies/any/v2/AnyConverterV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,13 @@ abstract contract AnyConverterV2 is BaseStrategy {
using Math for uint256;
using SafeERC20 for IERC20;
using BytesLib for bytes;

address public yieldToken;
address[] public tokens;

IPriceOracle public oracle;

uint256 public outstandingAllowance;

bytes4 public constant APPROVE_SELECTOR =
bytes4(keccak256("approve(address,uint256)"));

Expand Down Expand Up @@ -90,7 +92,7 @@ abstract contract AnyConverterV2 is BaseStrategy {
IERC20(yieldToken).balanceOf(address(this)),
yieldToken,
asset()
);
) - outstandingAllowance;
}

function convertToUnderlyingShares(
Expand Down Expand Up @@ -229,19 +231,20 @@ abstract contract AnyConverterV2 is BaseStrategy {
if (!success) revert("Call failed");
}

uint256 outstandingAllowance;
uint256 _outstandingAllowance;
for (uint256 i; i < allowanceCalls.length; i++) {
if (allowanceCalls[i].target != address(0)) {
(bool success, bytes memory result) = allowanceCalls[i]
.target
.call(allowanceCalls[i].data);
if (!success) revert("Call failed");

outstandingAllowance += abi.decode(result, (uint256));
_outstandingAllowance += abi.decode(result, (uint256));
}
}

uint256 postTotalAssets = totalAssets() - outstandingAllowance;
uint256 outstandingAllowance = _outstandingAllowance;
uint256 postTotalAssets = totalAssets() - _outstandingAllowance;
uint256 postAssetBalance = IERC20(_asset).balanceOf(address(this));
uint256 postYieldTokenBalance = IERC20(_yieldToken).balanceOf(
address(this)
Expand Down

0 comments on commit 81cd155

Please sign in to comment.