Message: AddMargin
The AddMargin
handler is responsible for adding collateral to an existing position to increase the margin ratio.
The parameters that are controllable by the user are
pair
— This is the pair of the open position to add collateral to; it is checked to ensure that it is valid, that there is an open position, and there is a market and an AMM for it.marginToAdd
— This is the amount of coins to add to the position; it is checked to ensure that the amount is positive and that the denom is the same as the specified pair.
When adding margin, any outstanding funding payment is realized and the position LatestCumulativePremiumFraction
is updated to match the market's value.