Voltz vAMM Contract
The Virtual Automated Market Maker is a Voltz Protocol smart contract used for price discovery only. It helps with setting the fixed rate of interest rate swaps while the management of the underlying positions and their margin accounts alongside liquidations are handled by the Margin Engine.
The vAMM uses the constant product formula
represents 1% of fixed tokens and
represents variable tokens.
The concept behind fixed tokens is relatively straightforward; if an actor is entitled to 100 of the 1% virtual fixed tokens then, at maturity of the IRS pool, they can claim exactly 1 token of the underlying. Note, this assumes the term of the IRS pool is precisely one year. On the other hand, 1 virtual variable token gives an actor exposure to the variable cash-flows that can be generated with 1 token worth of deposits in the underlying yield-bearing pool (e.g. aDAI), over the term of the IRS pool.
Thus, the vAMM defines the rate at which a trader can exchange fixed-for-variable or variable-for-fixed cash-flows. Given the axes of the vAMM, the relationship between the vAMM price and the annualized fixed rate is of the following form:
Voltz vAMM uses the concept of concentrated liquidity inspired by Uniswap v3. This allows Liquidity Providers to deposit variable tokens and 1% fixed tokens into the vAMM at pre-determined, custom fixed rate ranges. When the fixed rate is out of an LP’s position (fixed rate range), the liquidity is inactive, meaning the liquidity won’t be used to enter IRS contracts and earn fees.
The vAMM the has two key responsibilities:
- It enables traders to enter into Interest Rate Swaps
- It enables liquidity providers to add liquidity to the vAMM in custom fixed rate ranges
The mint function adds liquidity to a given position, uniquely identifiable by its owner address, upper and lower ticks.
The mint will not succeed if the position margin balance in underlying tokens is below the initial margin requirement of the position following a mint.
Additionally, the mint will revert if the address of the position owner does not match that of the
msg.senderis not approved by the position owner.
function mint(address recipient, int24 tickLower, int24 tickUpper, uint128 amount) external nonpayable returns (int256 positionMarginRequirement)
The burn function removes liquidity from a given position, uniquely identifiable by its owner address, upper and lower ticks.
function burn(address recipient, int24 tickLower, int24 tickUpper, uint128 amount) external nonpayable returns (int256 positionMarginRequirement)
The swap function engages a given position into an interest rate swap where the counterparty is the pool of Liquidity Providers active in the tick range crossed by the swap. The swap will not succeed if the position margin balance in underlying tokens is below the initial margin requirement of the position following a swap.
Each Interest Rate Swap initiated on Voltz Protocol will convey a fee which the position owner needs to pay to the liquidity providers (in the active tick range) in underlying tokens. Refer to Section 3 of the litepaper for more information on how fees are calculated.
function swap(SwapParams params) external nonpayable returns (int256 _fixedTokenDelta, int256 _variableTokenDelta, uint256 _cumulativeFeeIncurred, int256 _fixedTokenDeltaUnbalanced, int256 _marginRequirement)
The function updatePosition allows a user who entered an Interest Rate Swap position to update the position by providing more margin, effectively increasing their collaterlisation, or withdrawing their as much margin as possible without undercollateralising their position. It returns the position margin requirement.
function updatePosition(ModifyPositionParams memory params) private returns(int256 positionMarginRequirement)
The function computeGrowthInside calculates the change in the fixed and variable yield tokens as well as the increase in the fees being collected.
returns (int256 fixedTokenGrowthInsideX128, int256 variableTokenGrowthInsideX128, uint256 feeGrowthInsideX128)