Function: executeAdl(EventTypes.Adl adl, uint64 eventId)
This executes auto-deleveraging action. Can be called only by the OperatorManager contract over the eventUpload
function, which is available only for Operator
.
userPosition.positionQty
should not be zero.positionQtyTransfer.abs
should not be more thanuserPosition.positionQty
.
Inputs
adl
Control: Full control by operator.
Constraints: Only one check that abs(absolute value) of
positionQtyTransfer
should not be more than abs ofuserPosition.positionQty
.Impact: N/A.
eventId
Control: Full control by operator.
Constraints: There are not any checks.
Impact: The unique ID of action.
Function call analysis
userPosition.chargeFundingFee(adl.sumUnitaryFundings);
External/Internal? Internal.
Argument control?
adl.sumUnitaryFundings
is controlled by caller.Impact: Charge funding fee for
userPosition
.
insurancePosition.chargeFundingFee(adl.sumUnitaryFundings);
External/Internal? Internal.
Argument control?
adl.sumUnitaryFundings
is controlled by caller.Impact: Charge funding fee for
insurancePosition
.
userPosition.calAverageEntryPrice(adl.positionQtyTransfer, adl.adlPrice.toInt128(), -adl.costPositionTransfer)
External/Internal? Internal.
Argument control?
positionQtyTransfer
,adlPrice
, andcostPositionTransfer
are controlled.Impact: Change
averageEntryPrice
andopeningCost
.