Skip to content

Commit

Permalink
fix: Rename arguments for backUnbacked in library
Browse files Browse the repository at this point in the history
  • Loading branch information
LHerskind committed Oct 13, 2021
1 parent 94eaf83 commit 6ca57a1
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions contracts/protocol/libraries/logic/BridgeLogic.sol
Original file line number Diff line number Diff line change
Expand Up @@ -90,28 +90,27 @@ library BridgeLogic {
* @param asset The address of the underlying asset to repay
* @param amount The amount to back
* @param fee The amount paid in fees
* @param premiumToProtocol The fraction of fees in basis points paid to the protocol
**/
function backUnbacked(
DataTypes.ReserveData storage reserve,
address asset,
uint256 amount,
uint256 fee,
uint256 premiumToProtocolBPs
uint256 premiumToProtocol
) external {
DataTypes.ReserveCache memory reserveCache = reserve.cache();

reserve.updateState(reserveCache);

uint256 backingAmount = (amount < reserve.unbacked) ? amount : reserve.unbacked;

uint256 premiumToProtocol = fee.percentMul(premiumToProtocolBPs);
uint256 premiumToLP = fee - premiumToProtocol;
uint256 feeToProtocol = fee.percentMul(premiumToProtocol);
uint256 feeToLP = fee - feeToProtocol;

reserve.cumulateToLiquidityIndex(IERC20(reserve.aTokenAddress).totalSupply(), premiumToLP);
reserve.cumulateToLiquidityIndex(IERC20(reserve.aTokenAddress).totalSupply(), feeToLP);

reserve.accruedToTreasury =
reserve.accruedToTreasury +
Helpers.castUint128(premiumToProtocol.rayDiv(reserve.liquidityIndex));
reserve.accruedToTreasury += Helpers.castUint128(feeToProtocol.rayDiv(reserve.liquidityIndex));

reserve.unbacked = reserve.unbacked - Helpers.castUint128(backingAmount);
reserve.updateInterestRates(reserveCache, asset, backingAmount + fee, 0);
Expand Down

0 comments on commit 6ca57a1

Please sign in to comment.