Osmosis Updates from the Lab, ft. Ethan Frey (Confio) — Jan. 26, 2022

Stevie Woofwoof
Osmosis Community Updates
8 min readJan 29, 2022

--

Osmosis Updates from the Lab occurs every Wednesday at 10 AM EST (3 PM UTC) on the Osmosis Zone Twitter Space. Replays are available on the Osmosis YouTube channel or the podcast.

Last week in the lab, we learned that superfluid staking had entered the testing and simulation phase, that the Gravity Bridge launch was imminent, and that we were planning an Osmosis Grants Program (formerly called the Osmosis Ecosystem Fund) to attract outside developers for much-needed apps, tooling, analytics, and education. We were also teased about the mystery project Isotonic being built on Osmosis.

This week, with the Gravity Bridge now live for deposits and withdrawals coming shortly, Ethan Frey came by to talk to us about all things CosmWasm. He reports that the base version of the smart contracting platform will be merged into Osmosis by next Monday, so that work on the custom integrations can proceed. We talked auto-compounding for a while before Sunny made the big reveal. Confio and the core team will be leveraging CosmWasm to build Isotonic, a novel lending protocol that will be built into the Osmosis trading engine. With it, Osmosis LPs will soon be able to use their LP shares as collateral for trading at constant leverage.

Osmosis Upgrades

Before we discuss those in more detail, there are some non-CosmWasm upgrades to cover. An Osmosis chain upgrade is a few weeks out, featuring improved F1 Fee Distribution and the MetaMask integration for the Gravity Bridge. The front-end refactor is also coming along, including some much-needed improvements to the trade-router.

Most of this is finished, but the team has decided to push the next chain upgrade to mid-February because it has state breaking changes that require coordination with our validators and the developers of other front-ends that use Osmosis, like ping.pub, Cosmostation, Mintscan, and Citadel.one. The team would rather keep its head down for the next couple of weeks on superfluid staking, CosmWasm, Isotonic, and the front-end refactor.

F1 Fee Distribution for distributing LP incentives is coming within the next two chain upgrades. Dev developed this along with Chris Goes back in 2019 for the Cosmos SDK, and it is used to distribute staking rewards across Cosmos. It’s called F1 because it improved on the speedy-but-expensive “Lambo” model of fee distribution, leaving the slow, reliable “VW” model in its dust. It was such a big advance that Zaki Manian has called it “one of the defining technologies of the Cosmos.”

Right now, Osmosis LP incentives are distributed very slowly because the chain has to iterate over each bonded LP position every day at epoch. Once F1 is modified to fit LP incentives, it will use an accumulator to compute the rewards earned by a single share between two time periods and then multiply that number by the number of bonded shares. For more details, see GitHub, but the gist is that this is far less computationally expensive and therefore much faster. The one trade-off is that, as with staking rewards, LP incentives will have to be claimed instead of being automatically deposited to an account.

Using F1 to distribute liquidity mining incentives will greatly speed up epoch times. These have already been coming down due to fixing some performance issues in the Cosmos SDK and also in large part thanks to the efforts of validators like Jacob Gadikian and Joe Abbey.

Finally, a note on the trade router: for large trades especially, the auto-routing does not always give optimal price performance. The routing logic optimizes for low price and low numbers of pool hops, but it does not check whether or not it is routing a trade through a low-liquidity/high-slippage pool. For example, to trade UST → ATOM, the best option is typically UST → OSMO → ATOM, but the auto-trade path at one point was UST → JUNO → ATOM because the pool pricing looked better to the router. This lead to high slippage and a worse price. A fix is being prepared, but for now if you are trading in volume, please check that the auto-routing is not sending you through low-liquidity pools, or use the swap functionality on the pools page to route the trade yourself.

Ethan Frey started by thanking the Osmosis community for their vote of confidence in the CosmWasm integration and the Confio team. They are heavily focused on Osmosis for at least the first half of 2022, while still broadly supporting CosmWasm as a whole.

The vanilla CosmWasm integration is just a couple of days away from being merged into the GitHub, and it will include the latest version of wasmd, 0.22, which is compatible with the new SDK release (0.45). Wasmd is the “backbone” of CosmWasm, a fork of cosmos/gaia that includes x/wasm, a module that adds smart contract support. An exciting new feature of wasmd 0.22 is that on-chain governance can be the administrator of a smart contract. This means that, instead of governance merely expressing the wishes of the Osmosis stakers to the developers, governance votes will be able to interact with the contract directly.

Level 2 of the CosmWasm integration is now being actively worked on. This custom part of the integration includes letting contracts query TWAPs, make swaps, bond tokens, and interact with arbitrary features of the AMM. Confio is working on the best way to expose the APIs to the contracts. This deeper integration will also allow for applications like Isotonic, yield aggregation, and auto-compounding to be built.

Auto-compounding for staking and LP positions is a common request on Osmosis social media. We have a couple reservations: enabling it would perhaps eat into the joy of Osmosis epoch time, and will potentially make it easier to auto-dump OSMO. However, auto-compounding is such a time-saver and money-maker that it’s arrival on Osmosis is inevitable, so we should build the most collaborative version of auto-compounding.

Auto-staking is an obvious first choice. Once we have superfluid and interfluid staking, it will be possible to auto-compound both sides of an LP position without dumping either token (assuming both sides of the pool are earning similar amounts of staking rewards). In other words, your ATOM/OSMO position would earn ATOM staking rewards (we’ll leave out the other tokens you might earn through interchain security) and OSMO staking rewards. These could be auto-compounded into the LP, and then the OSMO LP incentives could be auto-staked or used to further top off the LP.

Isotonic plant cells

Isotonic

What if your dual-staked, autocompounding LP position could also be used as collateral? That’s the premise of Isotonic, the novel lending application being built by Confio in conjunction with the core team. Isotonic will provide on-chain leveraged trading on Osmosis, using LP shares as collateral.

Why leverage? Simply put, DEXs must offer leverage because our competition does. CEXs offer it, and it would be difficult for DeFi to supplant TradFi without catering to hard-core traders.

Currently, few DEXs offer leverage, but those that do generally work by letting you put down ETH (for example) as collateral to get DAI, which allows you to purchase more ETH, which you can use as collateral to get more DAI, and so on in a loop. The loop is not infinite because DeFi loans must be over-collateralized, often heavily. This differs from, say, FTX margin trading, where your loan from the CEX does not depend on smart contracts and can therefore be under-collateralized.

Isotonic’s leverage is driven by a novel mechanism that delivers constant 2x leverage at all prices. It functions like a spot version of a leveraged perpetual derivative like Squeeth (ETH²), developed by Paradigm mechanism-wizard Dave White and the team at Opyn. Isotonic leverage thus differs greatly from standard leverage, which decreases as your position improves because as you make more money, you are borrowing less. The reverse is also true, as your position worsens, you are borrowing more and more, exponentially increasing your leverage until you get liquidated. See here for more about types of leverage and some examples of the math.

Isotonic leverage also borrows gradual liquidation from the much-praised FTX liquidation engine, where deteriorating positions are partially sold on the way down in order to improve the margin and forestall total liquidation. Conversely, Isotonic buys more of the asset on the way up in order to keep the margin constant.

This constant leverage is possible on-chain because it is perfectly hedged by the user’s LP shares. Constant leverage and LPing have equal and opposite mechanisms. LP positions sell the better-performing asset for the worse-performing asset, whereas Isotonic leverage slowly liquidates out of a badly performing asset on the way down.

Since trading and lending are two sides of the same coin, Isotonic must be tightly integrated within the Osmosis suite. For example, for liquidations to be efficient, we cannot rely on an interchain lending protocol. While managing liquidations over IBC is not theoretically impossible, there are too many MEV attack vectors to make it practical. Even when we get threshold decryption working over IBC, running the system cross-chain will likely be inefficient, simply because of the delays involved in relaying and the difficulties of asynchronous transacting.

The team will put out a technical explainer on Isotonic in due course. Frey and the Confio team have been excited to work on Isotonic since Lisbon, particularly because it is not just an Ethereum clone, but a novel design that, with CosmWasm, will enable all sorts of interesting features even beyond what I’ve detailed above, such as automatic shorts, perpetual futures, and other more exotic trading options. Soon enough, this system will also be able to integrate synthetics from the ION DAO, if governance approves using Sunny’s generalization of the UST/LUNA mint and burn model.

The Isotonic name continues in the model of Osmosis. Biological osmosis is a physical AMM: roughly speaking, liquidity moves through a membrane as volumes change. Similarly, lending protocols strive to be isotonic, having equal osmotic pressure on both sides of a membrane. As interest rates go higher, capital flows in (hypertonic). As they go lower, capital flows out (hypotonic). The goal of a lending protocol is to adjust its rates to get to an equilibrium of borrowing and lending: the state of being Isotonic.

That wraps up another exciting Updates from the Lab! Next week we’ll be talking to Justin Kilpatrick from Althea about the Gravity Bridge.

Hope to see you there!

Enter the laboratory at Osmosis.zone, the first decentralized exchange powered by the Cosmos SDK and IBC. See our published lab reports at the Osmosis blog, our bench notes at GitHub, and help plan future experiments in our Commonwealth

Connect with other DeFi Scientists by following us on Telegram, Twitter, Discord, Reddit, and the new Facebook and Instagram pages

Reach out to the Osmosis Ministry of Marketing by Email or Twitter and the Osmosis Support Lab by Email or Twitter

--

--