DexSwapperUManager

Git Source

Inherits: UManager

Required Merkle Root Leaves

  • ERC20 approves with router spender.

  • IUniswapV3Router.exactInput(params), with all desired paths.

State Variables

MAX_SLIPPAGE

uint256 internal constant MAX_SLIPPAGE = 0.1e4;

allowedSlippage

Slippage check enforced after swaps.

uint16 public allowedSlippage = 0.0005e4;

router

The UniswapV3 Router.

IUniswapV3Router internal immutable router;

balancerVault

The BalancerVault this uManager works with.

BalancerVault internal immutable balancerVault;

priceRouter

The PriceRouter contract used to check slippage.

PriceRouter internal immutable priceRouter;

Functions

constructor

constructor(
    address _owner,
    address _manager,
    address _boringVault,
    address _router,
    address _balancerVault,
    address _priceRouter
)
    UManager(_owner, _manager, _boringVault);

setAllowedSlippage

Sets the maximum allowed slippage during a swap.

Callable by MULTISIG_ROLE.

function setAllowedSlippage(uint16 _allowedSlippage) external requiresAuth;

swapWithUniswapV3

Performs a swap using the UniswapV3 Router, and enforces a slippage check.

Callable by STRATEGIST_ROLE.

function swapWithUniswapV3(
    bytes32[][] calldata manageProofs,
    address[] calldata decodersAndSanitizers,
    ERC20[] memory path,
    uint24[] memory fees,
    uint256 amountIn,
    uint256 amountOutMinimum,
    uint256 deadline
)
    external
    requiresAuth
    enforceRateLimit;

Parameters

swapWithBalancerV2

Performs a swap using the BalancerV2 Vault, and enforces a slippage check.

Callable by STRATEGIST_ROLE.

function swapWithBalancerV2(
    bytes32[][] calldata manageProofs,
    address[] calldata decodersAndSanitizers,
    DecoderCustomTypes.SingleSwap calldata singleSwap,
    DecoderCustomTypes.FundManagement calldata funds,
    uint256 limit,
    uint256 deadline
)
    external
    requiresAuth
    enforceRateLimit;

Parameters

swapWithCurve

Performs a swap using a Curve pool, and enforces a slippage check.

Callable by STRATEGIST_ROLE.

function swapWithCurve(
    bytes32[][] memory manageProofs,
    address[] memory decodersAndSanitizers,
    CurveInfo memory info,
    uint256 i,
    uint256 j,
    uint256 dx,
    uint256 min_dy
)
    external
    requiresAuth
    enforceRateLimit;

Parameters

Events

SlippageUpdated

event SlippageUpdated(uint16 oldSlippage, uint16 newSlippage);

Errors

DexSwapperUManager__Slippage

error DexSwapperUManager__Slippage();

DexSwapperUManager__NewSlippageTooLarge

error DexSwapperUManager__NewSlippageTooLarge();

DexSwapperUManager__UniswapV3BadPathOrFees

error DexSwapperUManager__UniswapV3BadPathOrFees();

Structs

CurveInfo

Data needed to swap in a Curve pool

This was made into a struct to prevent stack too deep errors.

struct CurveInfo {
    address pool;
    ERC20 assetIn;
    ERC20 assetOut;
    bytes4 selector;
}