diff --git a/src/Blue.sol b/src/Blue.sol index 9099e62d1..9e56b3a53 100644 --- a/src/Blue.sol +++ b/src/Blue.sol @@ -163,7 +163,7 @@ contract Blue is IBlue { emit Supply(id, msg.sender, onBehalf, amount, shares); - if (data.length > 0) IBlueSupplyCallback(msg.sender).onBlueSupply(amount, data); + if (data.length > 0) IBlueSupplyCallback(msg.sender).onBlueSupply(market.borrowableAsset, amount, data); IERC20(market.borrowableAsset).safeTransferFrom(msg.sender, address(this), amount); } @@ -242,7 +242,7 @@ contract Blue is IBlue { emit Repay(id, msg.sender, onBehalf, amount, shares); - if (data.length > 0) IBlueRepayCallback(msg.sender).onBlueRepay(amount, data); + if (data.length > 0) IBlueRepayCallback(msg.sender).onBlueRepay(market.borrowableAsset, amount, data); IERC20(market.borrowableAsset).safeTransferFrom(msg.sender, address(this), amount); } @@ -262,7 +262,9 @@ contract Blue is IBlue { emit SupplyCollateral(id, msg.sender, onBehalf, amount); - if (data.length > 0) IBlueSupplyCollateralCallback(msg.sender).onBlueSupplyCollateral(amount, data); + if (data.length > 0) { + IBlueSupplyCollateralCallback(msg.sender).onBlueSupplyCollateral(market.collateralAsset, amount, data); + } IERC20(market.collateralAsset).safeTransferFrom(msg.sender, address(this), amount); } @@ -326,7 +328,7 @@ contract Blue is IBlue { emit Liquidate(id, msg.sender, borrower, repaid, repaidShares, seized, badDebtShares); - if (data.length > 0) IBlueLiquidateCallback(msg.sender).onBlueLiquidate(seized, repaid, data); + if (data.length > 0) IBlueLiquidateCallback(msg.sender).onBlueLiquidate(market.borrowableAsset, repaid, data); IERC20(market.borrowableAsset).safeTransferFrom(msg.sender, address(this), repaid); } diff --git a/src/interfaces/IBlueCallbacks.sol b/src/interfaces/IBlueCallbacks.sol index 902e2ddad..4d5809561 100644 --- a/src/interfaces/IBlueCallbacks.sol +++ b/src/interfaces/IBlueCallbacks.sol @@ -2,19 +2,19 @@ pragma solidity >=0.5.0; interface IBlueLiquidateCallback { - function onBlueLiquidate(uint256 seized, uint256 repaid, bytes calldata data) external; + function onBlueLiquidate(address token, uint256 amount, bytes calldata data) external; } interface IBlueRepayCallback { - function onBlueRepay(uint256 amount, bytes calldata data) external; + function onBlueRepay(address token, uint256 amount, bytes calldata data) external; } interface IBlueSupplyCallback { - function onBlueSupply(uint256 amount, bytes calldata data) external; + function onBlueSupply(address token, uint256 amount, bytes calldata data) external; } interface IBlueSupplyCollateralCallback { - function onBlueSupplyCollateral(uint256 amount, bytes calldata data) external; + function onBlueSupplyCollateral(address token, uint256 amount, bytes calldata data) external; } interface IBlueFlashLoanCallback { diff --git a/test/forge/Blue.t.sol b/test/forge/Blue.t.sol index 8745ed857..7fdd41dcd 100644 --- a/test/forge/Blue.t.sol +++ b/test/forge/Blue.t.sol @@ -991,21 +991,21 @@ contract BlueTest is // Callback functions. - function onBlueSupply(uint256 amount, bytes memory data) external { + function onBlueSupply(address token, uint256 amount, bytes memory data) external { require(msg.sender == address(blue)); bytes4 selector; (selector, data) = abi.decode(data, (bytes4, bytes)); if (selector == this.testSupplyCallback.selector) { - borrowableAsset.approve(address(blue), amount); + ERC20(token).approve(address(blue), amount); } } - function onBlueSupplyCollateral(uint256 amount, bytes memory data) external { + function onBlueSupplyCollateral(address token, uint256 amount, bytes memory data) external { require(msg.sender == address(blue)); bytes4 selector; (selector, data) = abi.decode(data, (bytes4, bytes)); if (selector == this.testSupplyCollateralCallback.selector) { - collateralAsset.approve(address(blue), amount); + ERC20(token).approve(address(blue), amount); } else if (selector == this.testFlashActions.selector) { uint256 toBorrow = abi.decode(data, (uint256)); collateralAsset.setBalance(address(this), amount); @@ -1014,24 +1014,24 @@ contract BlueTest is } } - function onBlueRepay(uint256 amount, bytes memory data) external { + function onBlueRepay(address token, uint256 amount, bytes memory data) external { require(msg.sender == address(blue)); bytes4 selector; (selector, data) = abi.decode(data, (bytes4, bytes)); if (selector == this.testRepayCallback.selector) { - borrowableAsset.approve(address(blue), amount); + ERC20(token).approve(address(blue), amount); } else if (selector == this.testFlashActions.selector) { uint256 toWithdraw = abi.decode(data, (uint256)); blue.withdrawCollateral(market, toWithdraw, address(this), address(this)); } } - function onBlueLiquidate(uint256, uint256 repaid, bytes memory data) external { + function onBlueLiquidate(address token, uint256 amount, bytes memory data) external { require(msg.sender == address(blue)); bytes4 selector; (selector, data) = abi.decode(data, (bytes4, bytes)); if (selector == this.testLiquidateCallback.selector) { - borrowableAsset.approve(address(blue), repaid); + ERC20(token).approve(address(blue), amount); } }