Denaria Protocol Whitepaper
Protocol overview
Perpetual futures are derivative contracts that allow users to speculate on the future price of an underlying asset without an expiry date. In our protocol, every perpetual contract revolves around two virtual assets. The first, vAsset, mirrors the underlying asset whose price the trader intends to predict, while the second, vStable, is a dollar‑pegged stablecoin employed solely for accounting and quotation. Users never purchase or sell the real underlying asset; their positions exist only in these virtual tokens, which they exchange through our dynamic virtual automated market maker (dynAMM).
The protocol's architecture intertwines several modules. A multi‑collateral vault secures user deposits; the dynAMM provides price computation and trade execution; an in‑house share‑tracking algorithm keeps precise records of each liquidity provider's contributions and fee earnings; a dedicated funding fee mechanism limits market exposure; a carefully designed schedule of trader and LP fees stabilizes the pool; and, finally, a liquidation process safeguards solvency whenever positions become under‑collateralised. Together these components create a seamless environment where traders can take leveraged positions and liquidity providers (LPs) can earn fees while managing risk.
Interaction with the system begins with depositing collateral. The vault accepts several approved assets and does not impose rigid, hard‑coded ratios between them, so users may deposit any blend of the allowed tokens, subject only to mild limits that prevent extreme changes in the vault's composition. When a position is opened, the collateral is locked and any profit‑and‑loss (PnL) payments are, under ordinary circumstances, returned in the same proportions as the original deposit. If the vault's overall mix differs sharply from a new user's deposit -imagine the vault holds mostly Asset A, but the user provides Asset B- the protocol dynamically adjusts withdrawals so that payouts reflect both the vault's global ratios and the user's preferred mix. The first version of our protocol restricts collateral to USD‑pegged stablecoins, valued initially at one dollar each.
Each underlying asset has its own dedicated vault. After funding their account, users may borrow vAsset or vStable up to the leverage cap. vAsset is valued through an external oracle, while vStable is fixed at one dollar. These vTokens remain internal bookkeeping entries; they never leave the protocol. To open a long position the trader borrows vStable and swaps it for vAsset in the dynAMM; to close, the trader performs the inverse swap, and the difference between vStable repaid and vStable received---adjusted for funding payments---constitutes the final profit or loss.
The dynAMM itself continuously recentres its pricing curve on the oracle price, following mathematics akin to Curve's StableSwap and CryptoSwap [1], [2] formulas but re‑implemented from scratch for gas efficiency. As a result, trades are executed at the prevailing market price with minimal slippage, and the funding rate is no longer tied to AMM slippage. Liquidity providers may supply balanced, imbalanced, or even single‑sided liquidity, enabling precise control over exposure---depositing only vAsset, for example, is equivalent to taking a passive short. Because every trade shifts the pool's composition, we maintain each LP's claim with a single global accumulator plus periodic per‑LP snapshots, an approach that keeps gas costs low without sacrificing accuracy.
Trading fees are charged on every swap and collected in vStable, while additional composition fees steer LP deposits toward a healthy pool balance. Funding payments counteract prolonged market trends: traders on the popular side pay, and traders on the less‑popular side receive, a fee proportional to position size and a novel funding rate computed from LP exposure rather than a mark‑index price gap. The same accumulator‑and‑snapshot technique that tracks LP shares also measures each account's funding liability or entitlement.
Positions must maintain a minimum margin ratio, defined as collateral value after PnL were applied divided by the notional position value. If this ratio falls below the liquidation threshold, anyone may liquidate the position by purchasing it at a discount. The discount is chosen so that slippage cannot erode the liquidator's expected profit, ensuring strong incentives to keep the system solvent.
Multi stable-asset collateral vault
In the initial release of the protocol, collateral is restricted to USD‑pegged stablecoins. Users may deposit any combination of the approved coins in whatever proportions suit them, and -under ordinary conditions- their PnL is settled in those same proportions. This symmetry cannot always be satisfied, though. Suppose a vault contains funds from only two users, one who contributed exclusively stablecoin A and another who supplied only stablecoin B. The vault clearly cannot satisfy each payout in the exact coin mix originally deposited. To handle such situations the protocol employs an adaptive settlement algorithm, outlined in this next section, that redistributes assets fairly whenever the vault's composition diverges from a user's preferred mix.
The user is permitted to deposit collateral in any of stablecoins, denoted by Stable_1 to Stable_n . Let the amount of each coin he deposits respectively as collateral. Some can be 0. We define:
All the stable coins are assumed to hold their peg. The sum in the denominator (let's denote it by ) is the total value in USD deposited as collateral by the user.
If these ratios were the same for each user we could force the users to pay for their PnL in these same ratios and then the system would have the desired properties. But this would be too restrictive, so we will describe a more flexible approach.
We denote by the same ratios for the whole system/vault before the new collateral deposit i.e if the total amount of Stable_1 to Stable_n tokens in the vault before this new collateral deposit:
and by the total ratios after the new deposit i.e.:
-
The user is free to deposit collateral in any ratio provided that:
The thresholds will be determined before deployment.
-
When the user wants to close his position: Let's say that his total PnL are USD (negative PnL means that the user should be paid and positive that he should pay). The total USD value of the collateral he can withdraw is . We compute , as described below, and give him back Stable_1 , ... Stable_n .
Computation of the ratios:If everyone was depositing collateral in the exact same ratios , then should also be equal to , meaning the user pays their PnL proportionally to their initial deposit. However, since not everyone deposits collateral at the same ratio, will depend on the user's initial ratio (), as long as the total ratios of the pool immediately before () their collateral withdrawal.
We first compute and then the total ratios after the withdrawal:
Observe that the denominator equals and therefore does not depend on the splitting.
If
holds for every , we set for every . The withdrawal threshold could be the same or smaller than .
If the above condition is not satisfied, or if some of the as copmputed above exceed the available in the vault, we set for every .
Note: We are aware that the user can bypass the restrictions (3) and (4) by splitting his deposit or withdrawal to smaller ones that will gradually shift the total ratios of the vault. A mitigation against it is to use instead of the actual ratios time averages.
Dynamic AMM
Every perpetual protocol needs a pricing mechanism -a way to decide how much vAsset a trader receives for their vStable when opening a long position and vice verse for short- while keeping that quoted price aligned with the underlying market price.
Traditionally, protocols either use oracle pricing, which takes the live market price of the underlying from an oracle, or virtual AMM (vAMM) pricing, which lets a constant‑product AMM determine the price and relies on arbitrage to pull it back toward the market. Our design blends the strengths of both. We start with an AMM that has very low slippage and then continuously re‑center its curve around the oracle price instead of waiting for external arbitrage. We call this mechanism a dynamic virtual AMM, or dynAMM.
The dynAMM fairly compensates LPs because trades clear close to the true market value. Capital efficiency is preserved: minimal slippage protects the pool from being drained yet still lets trading pressure show up in prices. For traders, execution remains near the market price without needing outside market makers.
Dynamic AMMs have been discussed in prior academic works [3], but not in the context of perpetual futures and only for simpler AMM models. Our dynAMM extends the concept to a more sophisticated perpetual‑trading environment.
In this section we denote by and the amounts of the two assets in the pool (vAsset and vStable respectively for our dynAMM case) right before thd right after a trade, respectively, and is the market price (provided by an external oracle) of the first asset with respect to the second one. We will introduce an invariant . From this equation one variable can be expressed in terms of the other -solving for yields and vice versa. Plotting in the -plane produces a continuous curve. We choose the invariant so that this curve passes through the point and its spot price at that point, i.e. equals . As a result, trades clear close to the prevailing market price (small orders incur only minimal slippage; significant slippage appears only when the trade size becomes large). We construct the invariant by starting with the graph of a constant function, then applying suitable shifts and scalings so that it meets both conditions.
The graphs for all the formulas discussed in this section can be found here.
The formula of the dynAMM
Our invariant is a dynamic extension of the Curve Finance invariant. For the sake of completeness -and because the resulting formulas may be useful beyond our protocol- we present a detailed derivation below.
We begin by introducing two simpler invariants, whose combination will produce the final invariant.
The first one is a dynamic version of the constant sum formula:
Using this invariant, all trades are executed exactly at the market price , with zero slippage. Note also that this and all subsequent invariants are normalized and dimensionless.
The second is a dynamic version of the constant product formula [4]. For this invariant there are two possible choices, as the shift can be applied either in the or the variable:
Although both shifted versions of the constant product formula exhibit qualitatively similar behavior, they define two distinct AMMs -meaning that, for the same input, they produce entirely different outputs. We use the first version for short positions and the second for long positions. Here's why:
Consider the first formula. A key distinction arises between the cases and (the special case corresponds to the standard -non dynamic- constant product formula). When , the graph intersects the y-axis, making it suitable only for short positions, which only increase . However, for long positions (which increase and thus decrease ), this formula can yield negative values of , which are invalid.On the other hand, when , the graph can be used for both longs and shorts. But for long positions in particular, the graph becomes asymptotic to the line . This implies that the amount of the x-asset cannot decrease below this threshold, which limits the efficiency of the AMM -it prevents full utilization of the x-asset in the pool. This inefficiency becomes especially pronounced when .
For the second formula, this behavior is reversed: it is more suitable for long positions and less effective for shorts.
We would prefer a dynAMM that combines the best properties of both the constant sum and constant product formulas. Specifically, we would like its graph to approximate the constant sum curve for values of close to . This approach minimizes slippage for swaps that do not significantly move the pool, ensuring such trades are executed near the market price . However, for larger swaps that shift the pool far from , significant slippage should apply, as with the constant product rule, to prevent the pool from being depleted.
This behavior can be achieved by defining a new invariant that is a linear combination of the constant sum and constant product invariants:
for short positions and
for long. should be a positive function. Observe that for we get the (shifted) constant product formula and for the constant sum. The graph of this new AMM will lie between the graphs of the constant sum and that of the constant product.
We will use a function inspired from Curve:
We can then can write the invariant as a polynomial equation of degree 3:
where:
For longs we can use:
and the corresponding polynomial equation is:
where:
We will also need the "inverse" formulas of the above. To compute the amount of vAsset required to receive a specified amount of vStable, the following equation should be used:
where:
If the state of the pool before the trade was and someone wants to get exactly vStable (), he should add to the pool vAsset (), and this can be found by solving equation (13). Also, we can use this equation to compute the amount of vAsset a user should add to the pool to get the amount of vStabe he needs to close his long position.\
On the contrary, to calculate the amount of vStable required to obtain a specific amount of vAsset, we use the following equation:
where: