Skip to content

Commit

Permalink
refactor: remove BlueLib and dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
MathisGD committed Aug 8, 2023
1 parent 1f8df02 commit 476d033
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 109 deletions.
38 changes: 0 additions & 38 deletions src/libraries/BlueLib.sol

This file was deleted.

28 changes: 0 additions & 28 deletions src/libraries/SharesMath.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,32 +34,4 @@ library SharesMath {
function toAssetsUp(uint256 shares, uint256 totalAssets, uint256 totalShares) internal pure returns (uint256) {
return shares.mulDivUp(totalAssets + VIRTUAL_ASSETS, totalShares + VIRTUAL_SHARES);
}

/// @dev Calculates the amount of shares corresponding to an exact amount of supply to withdraw.
/// Note: only works as long as totalSupplyShares + VIRTUAL_SHARES >= totalSupply + VIRTUAL_ASSETS.
function toWithdrawShares(uint256 amount, uint256 totalSupply, uint256 totalSupplyShares)
internal
pure
returns (uint256)
{
uint256 sharesMin = toSharesDown(amount, totalSupply, totalSupplyShares);
uint256 sharesMax = toSharesUp(amount + 1, totalSupply, totalSupplyShares);

return (sharesMin + sharesMax) / 2;
}

/// @dev Calculates the amount of shares corresponding to an exact amount of debt to repay.
/// Note: only works as long as totalBorrowShares + VIRTUAL_SHARES >= totalBorrow + VIRTUAL_ASSETS.
function toRepayShares(uint256 amount, uint256 totalBorrow, uint256 totalBorrowShares)
internal
pure
returns (uint256)
{
if (amount == 0) return 0;

uint256 sharesMin = toSharesDown(amount - 1, totalBorrow, totalBorrowShares);
uint256 sharesMax = toSharesUp(amount, totalBorrow, totalBorrowShares);

return (sharesMin + sharesMax) / 2;
}
}
2 changes: 0 additions & 2 deletions test/forge/Blue.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {SigUtils} from "./helpers/SigUtils.sol";

import "src/Blue.sol";
import {SharesMath} from "src/libraries/SharesMath.sol";
import {BlueLib} from "src/libraries/BlueLib.sol";
import {
IBlueLiquidateCallback,
IBlueRepayCallback,
Expand All @@ -26,7 +25,6 @@ contract BlueTest is
IBlueRepayCallback,
IBlueLiquidateCallback
{
using BlueLib for IBlue;
using MarketLib for Market;
using SharesMath for uint256;
using stdStorage for StdStorage;
Expand Down
41 changes: 0 additions & 41 deletions test/forge/SharesMath.t.sol

This file was deleted.

0 comments on commit 476d033

Please sign in to comment.