Kunlun Yang
2023/02/28
In a previous post, “Credmark’s DEX Pricing Model | The DEX Pricing Problem” we referred to tokens in Ring 1 and Ring 2 of the pricing strategy. This post describes how we selected the tokens to be included in these baskets.
To recap the core ideas from the previous post:
The composition of rings 1-3 tokens are illustrated in the figure below. In this blog, we will discuss how we selected the tokens for Ring 1 and Ring 2.
Figure 1: Ring 1, 2, and 3 tokens in Credmark’s pricing model
Ring 1 is made up of only stablecoins that’s linked to the fiat dollar value.
Ring 1 stablecoins are selected using the following criteria:
Among the rest of tokens, we choose those tokens with the largest connections to the other tokens to be in Ring 2. Ring 2 tokens are selected using the following criteria:
In previous blog post, we had the liquidity-weighted pricing formula as following
If we only have two stablecoins in Ring 1, we can only determine the relative value between the two. For example::
For two stablecoins Ta and Tb, there is a pool with 1000 Ta and 1 Tb.
Apply (1), Price of Ta = 0.001 * 1000 = 1, Price of Tb = 1000 * 1 = 1000. However, it could also be the case that Ta = 0.001 and Tb = 1.
In Ring 1 we need at least three stablecoins and they must meet the following criteria:
Let’s consider the case when Token 0 is depegged and we need to price token n.
The numerator in (1) can be split for the term for Token 0
and the term for other tokens
In order for Token 0 to have no material impact, the term for Token 0
needs to be insignificant relative to the term for other tokens
Let’s try some real numbers. The table below shows three pools for three tokens, Ta, Tb, and Tc, with Tc depegged.
Table 1: Example liquidity.
To calculate the price of Tb, we take the input of ratio and liquidity from pool no. 1 and 2.
The price of Tb = (1*1000+1000*0.01)/(1000+0.01) = 1.009989. Tb is overpriced by 1%.
When the liquidity for Tb in pool no.2 further decrease to 0.001, the price of Tb = (1*1000+1000*0.001)/(1000+0.001) = 1.000998999. Tb is overpriced by 0.1%.
In reality, traders will continue swapping Tc for Tb until the liquidity of Tb is close to zero, so the input from pool no. 2 becomes insignificant to the price of Tb. The price of Tb = (1*1000+1000*0)/(1000+0) = 1.0.
Note that if the majority depeg, our pricing algorithm will fail. When depegged event happens to the stablecoins in Ring 1, we will remove the depegged to keep the assumptions valid.
To keep our selection of the Ring 1 stablecoins stable, as we have learnt many lessons from the market (e.g. Luna/UST), we only chose those over-collateralized or fully-fiat-backed stablecoins.
For Ethereum mainnet, DAI/USDC/USDT are selected.
In the figure below, we plotted the 1-tick liquidity (available amount to move price 0.01%) for DAI/USDC/USDT in Uniswap V2/V3 and Sushiswap pools.
We have included USDT in Ring 1 tokens for two reasons:
The collapse of TerraClassicUSD (UST) in May 2022 was a monumental event for algorithmic stablecoins. Thanks to this event we can validate our equations.
V2-style pools
At block 15314735 (2022-08-10), we found two pools with UST-WETH as shown in table 2 below. The liquidity of WETH is tiny in both pools. The liquidity of UST in 0x9a0c… is larger but its price is lower than that other pool. It could be in the aftermath of an oversized dump of UST to the pool from a trade
Table 2: UST pools on V2-style pools on block 15314735
V3-style pools
Liquidity is usually not distributed uniformly in V3 pools. The price in the concentrated-liquidity pool would move to the boundary of the concentrated liquidity’s range, where LP’s supplied liquidity on the more valuable token is exhausted .
We found USDC-UST, and UST-WETH pools in V3 with different fees, as shown in table 3 below.
In general, these pools report a higher price for UST but with zero liquidity as the pool’s tick has moved to the tick spacing boundary. In our liquidity-weighted pricing formula, the product of ratio and liquidity becomes zero, resulting in no impact to the price of USDC and WETH.
The selection for Ring 2 tokens is much easier than Ring 1. Ring 2 is a “connection” between the Ring 1 tokens and the Ring 3 tokens. Ring 2 tokens is directly priced by Ring 1 stablecoins and it forms trading pools with other tokens.
For Ethereum mainnet, ETH is the obvious choice for Ring 2 because it can be priced with stablecoins only, and it has been often chosen by DeFi protocols to form trading pairs to their issued tokens. This has been illustrated in Figure 1 earlier.
Ring 2 currently only has a single token, but this could change. We recently found that some tokens (e.g. BTC2x-FLI) are only priced against WBTC. There is a case for including WBTS in Ring 2.
When Ring 2 contains more than 1 token, it will have to be extended into what we are calling Ring 2+. This implementation works as follows:
In summary, we expand the allowed number of tokens in Ring 2 from 1 to multiple with a new name, Ring 2+. The price of the tokens in Ring 2+ are determined one-by-one, in the order of liquidity dependencies. The first token in Ring2+ needs to be priced using only the Ring 1 stablecoins. The other Ring 2+ token can be priced using the Ring 1 stablecoins and the other Ring 2+ tokens. With more Ring 2+ tokens, we expand the number of tokens which can be priced as long as they form liquidity pool(s) with any Ring 2+ tokens. This idea is illustrated in the figure 2 below. Because there is only one token known to be priced with WBTC pricing, we have not yet implemented this idea.
Figure 2: Ring 1, 2+, and 3 tokens as an possible update to Credmark’s pricing model
We discussed how we selected the tokens for Rings 1 and 2 in order to make our DEX-based pricing algorithm work.
We also discussed how Ring 1 was resilient in the face of a depegging event.
The pricing models with 400+ tokens’ prices is as part of our token API offering
The source code of the model is part of our open source repository of models
Credmark runs a financial modeling platform powered by reliable on-chain data. We curate and manages DeFi data making it available via API and the Snowflake Marketplace around the globe and across industries.
Our community of quants, developers, and modelers actively build models for the DeFi community by leveraging our data API and tools. Join the growing community and together we will advance the next-generation financial system.
Sign up for our newsletter for the latest product updates, partnerships, and more.