Skip to content

Commit

Permalink
fix: correct slippage handling for RebalancerSwap
Browse files Browse the repository at this point in the history
  • Loading branch information
0xtekgrinder committed Aug 27, 2024
1 parent 2c47340 commit e6b9237
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions contracts/helpers/RebalancerFlashloanSwap.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ pragma solidity ^0.8.19;

import "./ARebalancerFlashloan.sol";
import { IERC20Metadata } from "oz/interfaces/IERC20Metadata.sol";
import { ASwapper } from "utils/src/Swapper.sol";
import { RouterSwapper } from "utils/src/RouterSwapper.sol";

/// @title RebalancerFlashloanSwap
/// @author Angle Labs, Inc.
/// @dev Rebalancer contract for a Transmuter with as collaterals a liquid stablecoin and an yield bearing asset
/// using this liquid stablecoin as an asset
contract RebalancerFlashloanSwap is ARebalancerFlashloan, ASwapper {
contract RebalancerFlashloanSwap is ARebalancerFlashloan, RouterSwapper {
using SafeCast for uint256;

uint32 public maxSlippage;
Expand All @@ -24,7 +24,7 @@ contract RebalancerFlashloanSwap is ARebalancerFlashloan, ASwapper {
uint32 _maxSlippage
)
ARebalancerFlashloan(_accessControlManager, _transmuter, _flashloan)
ASwapper(_swapRouter, _tokenTransferAddress)
RouterSwapper(_swapRouter, _tokenTransferAddress)
{
maxSlippage = _maxSlippage;
}
Expand Down Expand Up @@ -81,9 +81,9 @@ contract RebalancerFlashloanSwap is ARebalancerFlashloan, ASwapper {
uint256 decimalsTokenOut = IERC20Metadata(tokenOut).decimals();

if (decimalsTokenIn > decimalsTokenOut) {
amountOut /= 10 ** (decimalsTokenIn - decimalsTokenOut);
amount /= 10 ** (decimalsTokenIn - decimalsTokenOut);
} else if (decimalsTokenIn < decimalsTokenOut) {
amountOut *= 10 ** (decimalsTokenOut - decimalsTokenIn);
amount *= 10 ** (decimalsTokenOut - decimalsTokenIn);
}
if (amountOut < (amount * (BPS - maxSlippage)) / BPS) {
revert SlippageTooHigh();
Expand Down
2 changes: 1 addition & 1 deletion lib/utils
Submodule utils updated 1 files
+16 −6 src/RouterSwapper.sol

0 comments on commit e6b9237

Please sign in to comment.