Skip to content

Commit

Permalink
Revert "feat(Deposit and Withdraw): Added slippage checks"
Browse files Browse the repository at this point in the history
This reverts commit 93dbc96.
  • Loading branch information
arcantheon committed Dec 5, 2024
1 parent 93dbc96 commit 89600cc
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions contracts/strategies/fluid/FluidStrategy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,10 @@ contract FluidStrategy is InitializableAbstractStrategy {
IERC20(_asset).forceApprove(lpToken, _amount);
uint256 sharesMinted = IFluidToken(lpToken).deposit(_amount, address(this));

// Checking if the deposited value is lesser than expected.
uint256 depositAmt = IFluidToken(lpToken).convertToAssets(sharesMinted);
uint256 minDepositAmt = (_amount * (Helpers.MAX_PERCENTAGE - depositSlippage)) / Helpers.MAX_PERCENTAGE;
if (depositAmt < minDepositAmt) {
revert Helpers.MinSlippageError(depositAmt, minDepositAmt);
uint256 sharesValue = IFluidToken(lpToken).convertToAssets(sharesMinted);
// _amount - 1 because the underlying logic of convertToAssets uses mulDivDown which causes error of 1 wei.
if (sharesValue < (_amount - 1)) {
revert Helpers.MinSlippageError(sharesValue, _amount);
}

emit Deposit(_asset, _amount);
Expand Down Expand Up @@ -173,11 +172,8 @@ contract FluidStrategy is InitializableAbstractStrategy {

// Redeeming the shares.
uint256 received = IFluidToken(lpToken).redeem(shares, _recipient, address(this));

// Checking if the received amount is more than minimum expected.
uint256 minRecvAmt = (_amount * (Helpers.MAX_PERCENTAGE - withdrawSlippage)) / Helpers.MAX_PERCENTAGE;
if (received < minRecvAmt) {
revert Helpers.MinSlippageError(received, minRecvAmt);
if (received < _amount) {
revert Helpers.MinSlippageError(received, _amount);
}

emit Withdrawal(_asset, _amount);
Expand Down

0 comments on commit 89600cc

Please sign in to comment.