Skip to content

Commit

Permalink
fix: audit issue #60
Browse files Browse the repository at this point in the history
  • Loading branch information
sbuljac authored and jeffywu committed Aug 9, 2024
1 parent 7627b25 commit a94e184
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions contracts/vaults/common/WithdrawRequestBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {Constants} from "@contracts/global/Constants.sol";
import {TypeConvert} from "@contracts/global/TypeConvert.sol";
import {Deployments} from "@deployments/Deployments.sol";
import {VaultStorage, WithdrawRequest, SplitWithdrawRequest} from "./VaultStorage.sol";
import {IERC20} from "@interfaces/IERC20.sol";

/**
* Library to handle potentially illiquid withdraw requests of staking tokens where there
Expand Down Expand Up @@ -76,8 +77,11 @@ abstract contract WithdrawRequestBase {
// Otherwise, apply the proper exchange rate
(int256 rate, /* */) = Deployments.TRADING_MODULE.getOraclePrice(redeemToken, borrowToken);

return (s.totalWithdraw * rate.toUint() * w.vaultShares) /
(s.totalVaultShares * Constants.EXCHANGE_RATE_PRECISION);
uint256 borrowPrecision = 10 ** IERC20(borrowToken).decimals();
uint256 redeemPrecision = 10 ** IERC20(redeemToken).decimals();

return (s.totalWithdraw * rate.toUint() * w.vaultShares * borrowPrecision) /
(s.totalVaultShares * Constants.EXCHANGE_RATE_PRECISION * redeemPrecision);
}
}

Expand Down

0 comments on commit a94e184

Please sign in to comment.