Deleveraging
Understanding Deleveraging
Deleveraging is the process of reducing your position's leverage by withdrawing collateral and repaying debt. This can be done in two ways:
Partial deleveraging: Reduce leverage while maintaining an active position.
Full deleveraging: Completely unwind the position by repaying all debt.
Preparing for Deleveraging
Before deleveraging, you need to:
Understand your current position: Review your collateral amount, debt amount, and health factor.
Set an appropriate slippage tolerance: Typically 0.5-2% depending on asset volatility.
Calculate the optimal deleveraging amounts: Determine how much collateral to withdraw and debt to repay.
Constructing the DeleverageStruct
Deleveraging requires constructing a DeleverageStruct that specifies how to unwind your position:
Executing the Deleverage Operation
With the DeleverageStruct prepared, execute the deleverage operation:
Important Considerations
Swap Data Configuration:
The
swapData
array can contain multiple swaps for complex routes.Each swap must specify the correct input/output tokens and amounts.
Slippage tolerance should be set appropriately for each swap.
Amount Calculations:
collateralAmount
: The amount of position tokens to withdraw.repayAmount
: The amount of debt to repay in the borrowed asset.Ensure these amounts are properly calculated to maintain desired position size.
Protocol-Specific Features:
Some protocols may require additional data in the
auxData
field.Check protocol documentation for specific requirements.
Consider using protocol-specific optimizations when available.
Last updated