Fair LP Token Oracles

Switchboard now offers fair LP token pricing oracles based on the work of Alpha Finance Lab!

The Concern

A liquidity pool is a collection of funds locked in a smart contract, used to facilitate decentralized trading, lending, and many more functions [1]. With DeFi we are able to deposit assets into an LP pool, receive yield bearing LP tokens, and then borrow against our LP tokens. The price of these LP tokens is typically calculated by summing the total liquidity in the pool and dividing by the number of LP tokens issued. This basic calculation works well when the total liquidity in the pool is balanced between each asset but starts to fall apart when the pool liquidity is imbalanced.

Consider the WarpFinance incident where an attacker was able to use a flash loan to manipulate the price of an LP token by taking advantage of the imbalance, for which they used as collateral to borrow a greater amount of capital than was sufficiently allowed [2]. This type of hack takes advantage of the LP token price oracle in order to over-borrow from a lending provider.

The Solution

Thanks to Alpha Finance Lab we have a solution: Fair LP Token Pricing [3].

Where, r is the amount of reserves, and p is the given price, for each pool member.

The fair LP formula takes into account the weight of each pool member’s liquidity to determine a fair price. What that means is as a pool imbalance grows, the price of the LP token decreases in order to lower the risk of flash loan attacks being able to over-borrow against them.

Switchboard oracles now give you the option to calculate the fair price of an LP token using the LpTokenPriceTask. Switchboard’s solution requires an existing aggregator for each pool member so that the formula is always using the previous aggregator result for each pool member’s price to prevent additional manipulation.

These feeds are live now so check out our feed explorer for an example of what these on-chain jobs look like:

References

--

--

--

switchboard.xyz

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

How many people really use DeFi?

A safe token sale mechanism

Safe Haven Trust Alliance Network (TAN) — Bridging one of the most important gaps in…

Resonate Finance: Partake in Pre-sale and ICO Launch of Its Innovative Project with…

AMA with the CEO of travala.com — Matthew Luczynski! — September 26th

INTRODUCING METASTAKE: MAIAR DEX INNOVATION SETS 3 TIER POOLS IN MOTION

Aleo. Important answers to key questions

Bonus NFT’s & Smart NFT, Wait, What ?!?!

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
Switchboard

Switchboard

switchboard.xyz

More from Medium

Overview of the Aurora Ecosystem

Drift Protocol — Alpha Mainnet Trading Stats & Open Launch

Balancer liquidity is coming to DeFi Baskets!

Introducing NativeSwap