Skip to content

Commit

Permalink
Changing access of _feeOnRaw and _feeOnTotal to internal
Browse files Browse the repository at this point in the history
We need to calculate fees that are associated with withdrawal assets
upon withdrawing when calculating how much assets should be withdarawn
from the dispatcher contract. Instead of calling a preview and
conversion functions we can modify access modifiers of _feeOnRaw and
_feeOnTotal to internal and use it in stBTC. That would simplify
calculations.
  • Loading branch information
dimpar committed Apr 15, 2024
1 parent 49b4be9 commit 01ccc4a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions solidity/contracts/lib/ERC4626Fees.sol
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ abstract contract ERC4626Fees is ERC4626Upgradeable {
function _feeOnRaw(
uint256 assets,
uint256 feeBasisPoints
) private pure returns (uint256) {
) internal pure returns (uint256) {
return
assets.mulDiv(
feeBasisPoints,
Expand All @@ -117,7 +117,7 @@ abstract contract ERC4626Fees is ERC4626Upgradeable {
function _feeOnTotal(
uint256 assets,
uint256 feeBasisPoints
) private pure returns (uint256) {
) internal pure returns (uint256) {
return
assets.mulDiv(
feeBasisPoints,
Expand Down
3 changes: 2 additions & 1 deletion solidity/contracts/stBTC.sol
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,8 @@ contract stBTC is ERC4626Fees, PausableOwnable {
uint256 currentAssetsBalance = IERC20(asset()).balanceOf(address(this));
// If there is not enough assets in stBTC to cover user withdrawals and
// withdrawal fees then pull the assets from the dispatcher.
uint256 assetsWithFees = convertToAssets(previewWithdraw(assets));
uint256 assetsWithFees = assets +
_feeOnRaw(assets, _exitFeeBasisPoints());
if (assetsWithFees > currentAssetsBalance) {
dispatcher.withdraw(assetsWithFees - currentAssetsBalance);
}
Expand Down

0 comments on commit 01ccc4a

Please sign in to comment.