LeverageRouterBase
Inherits: FlashLoanBase, Ownable2Step, Pausable, ReentrancyGuard
Title: LeverageRouterBase
Abstract base for leverage routers with shared validation and admin logic.
Common infrastructure for LeverageRouter (plDXY-BEAR) and BullLeverageRouter (plDXY-BULL).
State Variables
MAX_SLIPPAGE_BPS
Maximum slippage in basis points (1% = 100 bps).
uint256 public constant MAX_SLIPPAGE_BPS = 100
USDC_INDEX
USDC index in Curve USDC/plDXY-BEAR pool.
uint256 public constant USDC_INDEX = 0
PLDXY_BEAR_INDEX
plDXY-BEAR index in Curve USDC/plDXY-BEAR pool.
uint256 public constant PLDXY_BEAR_INDEX = 1
OP_OPEN
Operation type: open leverage position.
uint8 internal constant OP_OPEN = 1
OP_CLOSE
Operation type: close leverage position.
uint8 internal constant OP_CLOSE = 2
MORPHO
Morpho Blue lending protocol.
IMorpho public immutable MORPHO
CURVE_POOL
Curve pool for USDC/plDXY-BEAR swaps.
ICurvePool public immutable CURVE_POOL
USDC
USDC stablecoin.
IERC20 public immutable USDC
PLDXY_BEAR
plDXY-BEAR token.
IERC20 public immutable PLDXY_BEAR
marketParams
Morpho market configuration.
MarketParams public marketParams
Functions
constructor
Initializes base router with core dependencies.
constructor(
address _morpho,
address _curvePool,
address _usdc,
address _plDxyBear
) Ownable(msg.sender);
Parameters
| Name | Type | Description |
|---|---|---|
_morpho | address | Morpho Blue protocol address. |
_curvePool | address | Curve USDC/plDXY-BEAR pool address. |
_usdc | address | USDC token address. |
_plDxyBear | address | plDXY-BEAR token address. |
pause
Pause the router. Blocks openLeverage and closeLeverage.
function pause() external onlyOwner;
unpause
Unpause the router.
function unpause() external onlyOwner;
Errors
LeverageRouterBase__ZeroAddress
Thrown when zero address provided.
error LeverageRouterBase__ZeroAddress();
LeverageRouterBase__ZeroPrincipal
Thrown when principal is zero.
error LeverageRouterBase__ZeroPrincipal();
LeverageRouterBase__ZeroCollateral
Thrown when collateral is zero.
error LeverageRouterBase__ZeroCollateral();
LeverageRouterBase__Expired
Thrown when deadline has passed.
error LeverageRouterBase__Expired();
LeverageRouterBase__LeverageTooLow
Thrown when leverage multiplier <= 1x.
error LeverageRouterBase__LeverageTooLow();
LeverageRouterBase__SlippageExceedsMax
Thrown when slippage exceeds MAX_SLIPPAGE_BPS.
error LeverageRouterBase__SlippageExceedsMax();
LeverageRouterBase__NotAuthorized
Thrown when user hasn’t authorized router in Morpho.
error LeverageRouterBase__NotAuthorized();
LeverageRouterBase__InsufficientOutput
Thrown when swap output is insufficient.
error LeverageRouterBase__InsufficientOutput();
LeverageRouterBase__InvalidCurvePrice
Thrown when Curve price query returns zero.
error LeverageRouterBase__InvalidCurvePrice();
LeverageRouterBase__SplitterNotActive
Thrown when Splitter is not active.
error LeverageRouterBase__SplitterNotActive();