Skip to content

Commit 82bc629

Browse files
committed
consider non-deposited underlying when calculating surplus
1 parent f217e28 commit 82bc629

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

packages/ethereum-contracts/contracts/superfluid/AaveYieldBackend.sol

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ contract AaveYieldBackend is IYieldBackend {
100100
(uint256 normalizedTotalSupply,) = ISuperToken(address(this)).toUnderlyingAmount(totalSupply);
101101
// decrement by 100 in order to give ample of margin for offsetting Aave's potential rounding error
102102
// If there's no surplus, this will simply revert due to arithmetic underflow.
103-
uint256 surplusAmount = A_TOKEN.balanceOf(address(this)) - normalizedTotalSupply - 100;
103+
uint256 surplusAmount = A_TOKEN.balanceOf(address(this)) + ASSET_TOKEN.balanceOf(address(this))
104+
- normalizedTotalSupply - 100;
104105
AAVE_POOL.withdraw(address(ASSET_TOKEN), surplusAmount, SURPLUS_RECEIVER);
105106
}
106107

0 commit comments

Comments
 (0)