Skip to content

Commit

Permalink
Merge branch 'main' into bitcoin-depositor-min-deposit-update
Browse files Browse the repository at this point in the history
  • Loading branch information
nkuba authored Apr 23, 2024
2 parents 237cb60 + 9902f4c commit d8f71df
Show file tree
Hide file tree
Showing 3 changed files with 670 additions and 202 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
7 changes: 5 additions & 2 deletions solidity/contracts/stBTC.sol
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,11 @@ contract stBTC is ERC4626Fees, PausableOwnable {
address owner
) public override whenNotPaused returns (uint256) {
uint256 currentAssetsBalance = IERC20(asset()).balanceOf(address(this));
if (assets > currentAssetsBalance) {
dispatcher.withdraw(assets - currentAssetsBalance);
// If there is not enough assets in stBTC to cover user withdrawals and
// withdrawal fees then pull the assets from the dispatcher.
uint256 assetsWithFees = assets + _feeOnRaw(assets, exitFeeBasisPoints);
if (assetsWithFees > currentAssetsBalance) {
dispatcher.withdraw(assetsWithFees - currentAssetsBalance);
}

return super.withdraw(assets, receiver, owner);
Expand Down
Loading

0 comments on commit d8f71df

Please sign in to comment.