The first structured product on StarkNet: earn JediSwap liquidity fees in 1-click

Peteris Erins
Yagi Finance
Published in
4 min readJul 26, 2022

--

Yagi is a yield aggregator and keeper network on StarkNet. After announcing our first vault and being humbled by the interest from early depositors, the focus shifted to build more and better vaults on top of foundational yield opportunities in the StarkNet ecosystem.

After building a vault on top of a lending protocol, the next goal was to build on top of an AMM (automated market maker). I had the pleasure of meeting Rohit from JediSwap in the Amsterdam hackathon and we started to explore what we can do together. It became clear that the JediSwap community represented a healthy combination of grassroots energy and a deep understanding of DeFi as we brainstormed the needs of different market participants. It also became clear that we could start addressing those needs by developing a joint liquidity product.

Today, I'm pleased to announce that the DAI-ETH vault is available for testing on StarkNet Goerli.

The naive joint liquidity vault

JediSwap is an automated market maker that allows liquidity providers to provide liquidity for traders who can use different pools to trade between pairs of assets. Liquidity providers need to provide both assets in a pool in a specific ratio in exchange for liquidity fees (0.3% on trades distributed in proportion to liquidity provided).

To provide liquidity, a user must obtain and provide liquidity in both assets. For example, a user with only ETH needs to first trade to get DAI and then provide both ETH and DAI to provide liquidity in the pool. Our joint liquidity vaults simplify this process by only requiring one asset (either ETH or DAI) to start earning fees on JediSwap.

We are launching two different vaults, an ETH vault and a DAI vault whose positions are combined to provide liquidity on JediSwap.

ETH Vault
DAI Vault

You can go ahead and interact with these vaults right now at https://www.yagi.fi/vaults.

Are the vaults fair?

The magic of the vaults lies in their ability to account for how much of the liquidity share is owned by the ETH depositors and DAI depositors. In practice, this is done by simply returning the corresponding ETH and DAI in the liquidity share with no additional trading.

This works because JediSwap is a constant product market maker with a 50–50% weight distribution. This means that the reserves of both assets are valued equally in the pool.

To illustrate, consider that the current ETH price is $1500 and depositors are depositing 1 ETH and 1500 DAI in the vault respectively. The value of both parts is equal to $1500. Now consider an ETH price movement to $2000. In this case, the vault now holds 1732 DAI and 0.866 ETH after arbitrage. Why?

Note that the product is retained: 1732 x 0.866 ~ 1500 x 1.

And the spot price is now: 1732 / 0.866 = 2000.

The dollar value of both positions, however, is still equal to $1732.

In short, this means that each depositor is effectively holding an instrument that behaves like a liquidity share and follows the general equation of returns equals fees less impermanent loss as discussed here. Note: this is only true if the pool is effectively arbitraged. If the pool spot price deviates from the market price, then one side could be more valuable than the other.

Issues with the experimental vault

The current vault has a known griefing issue. In particular, vault shares are minted on every deposit meaning that users could trigger deposits maliciously when the spot price is not in agreement with the market price. Furthermore, they could do this while directly manipulating the spot price themselves.

We will address this vulnerability in upcoming versions but feel like an intermediate release on testnet is useful to improve our understanding of how to safely integrate with JediSwap and begin to educate our community on liquidity provision.

Future iterations of the vault will involve an exciting use of the Empiric oracle, Yagi keepers and other aspects we discussed at length in the StarkNet House talk.

Dive into L2 yield with us

Interested in L2-native and trustless yield opportunities on StarkNet whether as a developer, investor or user? Join our Discord.

Thanks

This launch would not have been possible without the following individuals:

  • Thanks to Rohit Goyal from JediSwap for help in developing the vault concept
  • Thanks to Prince Arora from JediSwap for help in reviewing the vault implementation and providing detailed technical information.

--

--

Peteris Erins
Yagi Finance

Founder @auditless Prev @mckinsey @twitter @google · @p_e · peteriserins.com