remargin()
During operation of the vault it is possible for the leverage of the strategy's margin account to deviate away from 1x. If the strategy's leverage goes below 1x there is no financial risk, but the vault is not capital efficient as the non-profiting buffer represents a disproportionate amount of the strategy. More dangerously, however, is if the strategy's leverage goes above 1x, as then it is possible for the vault to fall below the margin ratio and for the margin account to get liquidated, which would result in a substantial loss.
The remargin() function solves this problem.
If the position's leverage is greater than 1x then a certain amount of the short and long positions are sold and added to the buffer. This brings the Position Buffer back to its correct value and resets the leverage back to 1x.
If the position's leverage is less than 1x then a certain amount of the buffer position is used to open short and long positions. This brings the Position Buffer back to its correct value and resets the leverage back to 1x.
Position sizes will also increase based on returns accumulated by the strategy. These returns are compounded into positions during remargins.
The remargin() function ensures that the Position Buffer is consistently maintained and that derivative positions remain at 1x leverage.
A description of the remargin() code and the maths behind it are shown below.
The remargin() begins by harvesting the strategy - this updates all positions.
Next the ratio of expected short:buffer, K, is calculated. This is calculated using the following equation:
Then the unwindAmount, Z, is calculated. After remargin(), the value of long and short should be equal, thus we have the following equation - where P is the index price, X is the long or short size and Y is the margin size:
Rearranging for Z:
The proof that this resets leverage is at the bottom of the page.
If Z is greater than 0, the vault is over-leveraged. Z positions are then closed from the short position and Z positions are closed on the long. This combined amount is then deposited to the margin account.
If Z is less than 0, the vault is under-leveraged. Z positions are then opened in the short position and Z positions are opened on the long - the funds to collateralise these positions are taken from the Position Buffer.
Proof that leverage, L is reset, after remargin(), the leverage is as follows:
Replace Z with the remargined Z value:
Last updated