Comment on page

Core Design

Under-the-Hood of the Lynx Protocol
In this section, we examine some of the technical design choices of Lynx. For a deeper dive into the mechanics of the platform, see the litepaper here.

Gross Profit and Loss (PnL)

When opening a trade on Lynx, traders indicate their intended position (what they want to do/what type of exposure they are looking for) through a few parameters:
  • Collateral Asset (eg. TKN)
  • Collateral Amount (eg. 10 TKN)
  • Leverage (eg. 50x)
  • Traded Instrument (eg. ETH/USD)
  • Direction (eg. Long)
  • Take Profit/Stop Loss (eg. 300% and 80%)
Upon opening a trade, the price of the traded instrument - denoted as the entryPrice - is retrieved from a price oracle and assigned to the position. As the price of the traded instrument fluctuates over time, the position's gain or loss also fluctuates.
This calculated gain or loss is referred to as the position's Gross Profit and Loss (PnL). Given a referencePrice at any point in time, we can calculate a position's PnL by determining the leveraged price change of the traded instrument (expressed as a percentage) and multiplying it by a trader's collateral.
For a long position's PnL, the formula is:
PnL=collateralleverage((referencePrice/entryPrice)1)PnL = collateral*leverage*((referencePrice/entryPrice) - 1)
And for a short position's PnL, the formula is:
PnL=collateralleverage(1(referencePrice/entryPrice))PnL = collateral*leverage*(1-(referencePrice/entryPrice) )

Example of Gross PnL

Consider a trader who holds 10 TKN as collateral and opens a long position on ETH/USD using 50x leverage. Assume the position's entryPrice on ETH/USD is $1200.
If the price of ETH/USD goes up to $1212 (ie. referencePrice), the leveraged price change for the long position would be 50% (+1% price change multiplied by 50x leverage). The PnL - measured relative to the trader's collateral - would therefore read:
  • PnL = 10 TKN * +50% = +5 TKN: If the position is closed at this moment, this "winning" trader would walk away with 15 TKN, effectively profiting 5 TKN
If the price of ETH/USD went down to $1188, the leveraged price change for the long position would be -50% (-1% price change multiplied by 50x leverage). In this case, the PnL - measured relative to the trader's collateral - would read:
  • PnL = 10 TKN * -50% = -5 TKN: If the position is closed at this moment, this "losing" trader would walk away with 5 TKN, effectively paying 5 TKN from their collateral
Units of Gross PnL
As can be seen in the example above, PnL on Lynx is calculated in terms of the collateral asset selected (TKN) rather than the asset's USD value. To this extent, the price of TKN is never once referenced when calculating the trader's PnL.
As a collateral asset's price has no impact on the position's PnL, it means price fluctuations in the collateral asset can not bring a trader closer to liquidation. As a result, traders don’t need to monitor the price of the asset they use as collateral. This is an important feature of the Lynx platform and a key enabler of our ability to support any collateral asset, with volatile assets creating no additional risk of liquidation for traders. Only the price of the traded instrument impacts a trade’s health.

Isolated Liquidity Pools

Lynx is designed with a unique system of isolated, single-asset liquidity pools. When a trade is closed with a positive PnL, earnings are taken from one of Lynx's single-asset liquidity pools; likewise, if it's closed with a negative PnL, the losses get removed from the trader's collateral and paid to the relevant single-asset pool. Every liquidity pool on Lynx thereby serves as the counterparty to specific traders, effectively absorbing their PnL and a portion of the trading fees they generate.
The specific pool assigned as the counterparty for each trade matches the collateral asset used in that trade (eg. a trader using ETH as collateral would trade against the ETH liquidity pool). As detailed above, the PnL would be settled in terms of the collateral asset (eg. the trader would either receive or pay ETH).
Lynx's unique liquidity pool design enables permissionless listings of collateral assets, allowing anyone to add new tokens to Lynx. Permissionless listings are handled seamlessly behind the scenes by creating a new pool for each listed token, then automatically adding the token as a selectable option on the trading interface. Through permissionless listings, traders no longer need to hold blue-chip assets like BTC, ETH, or DAI to trade perpetuals as trading becomes accessible to thousands of long-tail asset holders across DeFi.

Trigger Bots

Every operation on Lynx - from opening a trade to liquidating a position - relies on an ecosystem of trigger bots to complete the task. These bots are responsible for providing an updated and reliable price to be used when processing the operation.
Most operations are done in two phases: first, a user registers their intention; then, a bot triggers the operation. Trigger bots therefore constantly monitor the state of the platform, looking for requests that can be triggered.
The use of these trigger bots offers two main benefits:
  1. 1.
    Prevent Oracle Front-Running: Prices are pulled on-chain and used in one single transaction, preventing traders from making opportunistic trades based on upcoming price updates
  2. 2.
    Provide Up-to-Date Pricing: Prices are retrieved at the exact moment that they're needed, offering the freshest and most reliable prices at a fraction of the cost of traditional price feeds

Guaranteed Solvency

"[FTX] filed for bankruptcy because it couldn’t fulfill customer withdrawals... Bankruptcy filings reveal that FTX owes money to over 1 million creditors, with a total deficit of $9 billion."
Using a few simple but effective safety mechanisms, Lynx ensures that winning traders will always get paid what they're owed. While Celsius, FTX, and countless other platforms have left users disillusioned through the misappropriation of user funds, Lynx's 'Guaranteed Solvency' approach allows everyone to trade continuously with confidence in light of any black-swan events or extreme market conditions.
Mandatory Take Profit
The first component to achieve Guaranteed Solvency is the mandatory take profit (TP) parameter required for every position. On Lynx, traders set their TP as a percentage which determines the maximum amount their position can earn before it's closed. The gain resulting from the TP is measured against the trader's collateral value.
For example, consider a user who sets a TP of 200% and goes long on BTC/USD with 1000 DAI as collateral. The system first registers the specific price BTC/USD must reach to result in a 200% gain (considering the user's leverage). Should this price be hit, the position would automatically close, resulting in a 200% gain for the trader - an additional 2000 DAI. Upon closing the position, all outstanding fees would be deducted from the 2000 DAI earnings, and the remaining value sent to the trader.
When opening a trade, traders must specify a TP or else the maximum TP offered on the platform will be used by default. By requiring a TP for every trade, the system knows the maximum amount every trader could earn at any given time. In the example above, the system knows the trader has maximum potential earnings of 2000 DAI.

Pool Utilization

Internally, Lynx earmarks the maximum potential earnings of traders and characterizes them as 'virtually borrowed' from their respective liquidity pools.
VirtuallyBorrowed=TPCollateralVirtuallyBorrowed= TP*Collateral
This allows Lynx to track each Pool Utilization: the ratio between the available assets in the liquidity pool and those virtually borrowed from it. Lynx implements measures to make sure that pool utilization isn’t kept too high for too long as demonstrated by the interest rate.

Protocol Safeguards

Finally, the protocol implements two safeguards to ensure that pool utilization will not cross 100% in any liquidity pool:
  • Trades that cause pool utilization to cross 100% are rejected.
  • If the pool utilization reaches 100%, LPs will be temporarily unable to withdraw funds from that given pool (similar to safeguards seen on Compound and Aave); during these times, liquidity providers continue to earn the highest possible interest rate paid by borrowers