Skip to content

Commit

Permalink
fix: sherlock fix review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffywu committed Aug 26, 2024
1 parent 431e195 commit 3c5e130
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
3 changes: 1 addition & 2 deletions contracts/oracles/PendlePTOracle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@ contract PendlePTOracle is AggregatorV2V3Interface {

int256 ptRate = _getPTRate();
// ptRate is always returned in 1e18 decimals (rateDecimals)
answer = (ptRate * baseToUSD * rateDecimals) /
(baseToUSDDecimals * rateDecimals);
answer = (ptRate * baseToUSD) / baseToUSDDecimals;
}

function latestRoundData() external view override returns (
Expand Down
5 changes: 3 additions & 2 deletions contracts/vaults/staking/PendlePTKelpVault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { KelpLib, KelpCooldownHolder, rsETH} from "./protocols/Kelp.sol";
contract PendlePTKelpVault is PendlePrincipalToken {
using TypeConvert for int256;
address public HOLDER_IMPLEMENTATION;
uint256 internal constant rsETH_PRECISION = 1e18;

constructor(
address marketAddress,
Expand Down Expand Up @@ -43,10 +44,10 @@ contract PendlePTKelpVault is PendlePrincipalToken {
uint256 requestId, uint256 /* totalVaultShares */, uint256 /* stakeAssetPrice */
) internal override view returns (uint256) {
uint256 tokenOutSY = getTokenOutSYForWithdrawRequest(requestId);
// NOTE: in this vault the tokenOutSy is known to be stETH.
// NOTE: in this vault the tokenOutSy is known to be rsETH.
(int256 ethPrice, /* */) = TRADING_MODULE.getOraclePrice(TOKEN_OUT_SY, BORROW_TOKEN);
return (tokenOutSY * ethPrice.toUint() * BORROW_PRECISION) /
(Constants.EXCHANGE_RATE_PRECISION * Constants.EXCHANGE_RATE_PRECISION);
(rsETH_PRECISION * Constants.EXCHANGE_RATE_PRECISION);
}

function _initiateSYWithdraw(
Expand Down
7 changes: 5 additions & 2 deletions contracts/vaults/staking/protocols/Kelp.sol
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,11 @@ library KelpLib {

function _canFinalizeWithdrawRequest(uint256 requestId) internal view returns (bool) {
address holder = address(uint160(requestId));
(/* */, /* */, /* */, uint256 userWithdrawalRequestNonce) = WithdrawManager.getUserWithdrawalRequest(Deployments.ALT_ETH_ADDRESS, holder, 0);
(/* */, /* */, uint256 userWithdrawalStartBlock, uint256 userWithdrawalRequestNonce) = WithdrawManager.getUserWithdrawalRequest(Deployments.ALT_ETH_ADDRESS, holder, 0);
uint256 nextNonce = WithdrawManager.nextLockedNonce(Deployments.ALT_ETH_ADDRESS);
return userWithdrawalRequestNonce < nextNonce;
return (
userWithdrawalRequestNonce < nextNonce &&
(userWithdrawalStartBlock + WithdrawManager.withdrawalDelayBlocks()) < block.number
);
}
}

0 comments on commit 3c5e130

Please sign in to comment.