TWAP Oracles vs. Chainlink Price Feeds: A Comparative Analysis

  • TWAP is a lagging indicator that becomes out of sync with the market-wide price during times of moderate to high volatility, leading to inaccurate data being consumed by smart contracts that put protocols at risk of under-collateralization.
  • Chainlink Price Feeds use a Volume Weighted Average Price (VWAP) to deliver accurate, real-time financial market data regardless of market volatility.
  • TWAP oracles have an inverse relationship between tamper-resistance (security) and freshness (accuracy), meaning users need to optimize for one or the other, but cannot achieve both simultaneously.
  • Chainlink Price Feeds can maximize tamper-resistance (security) and freshness (accuracy) at the same time without an inverse correlation.
  • TWAP oracles only consist of prices from a single exchange, resulting in a significant lack of market coverage that doesn’t account for liquidity fragmentation across trading pairs, CEXs, competing DEXs, differing DEX versions, or DEXs ported to other blockchain networks.
  • Chainlink Price Feeds provide full market coverage by tracking prices on all exchanges (CEXs & DEXs) and weighting them by real volume, serving as a future-proof, set-and-forget oracle mechanism that automatically tracks new liquidity fragmentation.
  • TWAP oracles do not have scalable security, as the only methods of increasing security are either incredibly capital intensive or result in stale/inaccurate data during volatility.
  • Chainlink Price Feeds provide numerous ways for an oracle network to increase its security as it rises in value secured, such as adding more nodes, data sources, and crypto-economic security like higher node payments and implicit/explicit staking.
  • TWAP oracles only provide the exchange rate between two on-chain tokens, meaning it cannot provide financial market data on real-world assets like commodities, forex, stocks, indexes, or tokens priced in fiat currencies.
  • Chainlink oracle networks can connect smart contracts to any external data resource including any type of financial market data, real-world events, off-chain computation, data privacy solutions, and much more.

What is an AMM DEX?

Automated Market Maker Bonding Curves
Different types of AMM curves which determine the exchange rate of tokens based on the relative amount of tokens in each side of the pool (source)

Why TWAP?

Flash Loan DeFi Attack
A theoretical example is shown below of how a flash loan can be used to manipulate and siphon funds from a money market DeFi protocol by manipulating the price of a single DEX; all of these steps happen in a single transaction. (source)
Uniswap V2 TWAP Oracles
The TWAP calculation methodology supported by the Uniswap V2 AMM (source)

The Limitations of TWAP Oracles

Freshness/Accuracy

  • Longer TWAP: higher tamper-resistance (more expensive to manipulate) but less accurate data (becomes stale during volatility).
  • Shorter TWAP: more accurate data (stays fresh during volatility) but reduced tamper-resistance (lowering the cost of manipulation).
Data showing the deviation between Uniswap v2's ETH/USDC 10 minute TWAP oracle and Chainlink’s ETH/USD Price Feed (Source)
Chainlink ETH/USD Price Feed
Chainlink ETH/USD Price Feed with 0.5% deviation threshold and 3hr heartbeat on the Ethereum Mainnet (source)

Market Coverage

Single Source Oracle Failure
Single source oracles cannot account for volume/liquidity shifts across exchanges (source)
  • Competing DEXs: The competition in the AMM space is fierce, with some protocols even deploying vampire attacks to quickly siphon liquidity away from leading DEXs. This results in liquidity fragmentation, as existing and future AMMs compete for liquidity.
  • Same DEX, Different Versions: Some AMMs have opt-in versioning for updates, meaning when a new protocol version is released, such as Uniswap V3, liquidity can be fragmented across two different AMM versions before all LPs have switched over. This results in liquidity fragmentation for a period of time after a new version release.
  • Same DEX, Different Chains: In order to stay competitive, AMMs are launching support for new blockchains, such as Sushiswap’s expansion to Fantom, Polygon, xDai, BSC, and Moonbeam. Uniswap V3 will launch on both Ethereum and the Optimism layer-2 network, further fragmenting its own liquidity.
  • Same DEX, Different Trading Pair: AMMs use isolated trading pools, where a single asset may have liquidity for a specific token across several different pools (e.g. LINK/ETH, LINK/USDT, LINK/USDC, etc.), fragmenting liquidity for an asset within a single AMM.
Chainlink Three Layers of Aggregation
Chainlink Price Feeds achieve full market coverage using Price Data Aggregators (source)

Scalability of Security

  • Increase the number of premium data sources, further decentralizing the data sourcing and aggregation processes.
  • Increase the number of independent node operators, further decentralizing the data delivery and validation processes.
  • Switch to more expensive but higher quality data APIs and node operators who provide superior guarantees.
  • Pay each node operator more LINK fees per request fulfilled, establishing a higher opportunity cost for malicious activity.
  • Aggregate fees with other users who need the same data, creating shared, collectively funded oracle networks that are more secure than what any project could afford on their own.
  • Upon mainnet implementation, utilize additional security methods like DECO for zero-knowledge proofs and Town Crier for trusted hardware.
  • After the explicit staking launch, require nodes to stake more LINK in a service agreement to create greater crypto-economic incentives for honest behavior.
Chainlink Oracle Network Overview
Overview of the Chainlink Network operating at scale with implicit and explicit staking, user fee pool contract, governance contract, and service agreements (source)

Concentrated Liquidity

Uniswap Concentrated Liquidity
Uniform liquidity distribution in Uniswap v2 versus concentrated liquidity in Uniswap v3 (source)
Rari Fuse Pool #23 Oracle Manipulation
The Rari Fuse Pool #23 after it had been drained of assets (source)
  • There are no arbitrage bots: The token may have too low liquidity or trading volume overall for arbitrage bots to track. The token may not conform to the ERC20 standard and therefore may not be recognized by bots. No arbitrage occurred during the VUSD manipulation.
  • There is no other DEX liquidity: The token may only have on-chain liquidity located on a single trading pair on a single DEX, meaning risk-free arbitrage cannot occur between DEXs. Arbitrage between CEXs and DEXs cannot be performed atomically, and therefore bots may choose not to take on this risk.
  • Other DEX trading pairs also manipulated: Every on-chain liquidity pool with the token may have been manipulated in the same manner, meaning no on-chain arbitrage can occur. This situation occurred with the INV token, leading to the exploit of Inverse Finance.
Uniswap v3 out of range liquidity
Concentrated liquidity on Uniswap v3 out of range of current market price (source)

Feed Diversity

Size of Traditional Finance Versus Cryptocurrency and DeFi
The market cap of cryptocurrency is $2T+ and the value secured in DeFi is $50B+, however, off-chain markets are still orders of magnitude larger (source)

Conclusion

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
SmartContent

SmartContent

1.5K Followers

Breaking down the information asymmetry on Chainlink, smart contracts, and the cryptocurrency ecosystem. Founded by The_Crypto_Oracle and ChainLinkGod