In addition to the many unique features in Alpha Homora V2 that we have shared before, Alpha Homora V2 also tokenizes farming positions into ERC-1155 tokens. The tokenizing position concept is not new, but tokenizing positions into ERC-1155 is definitely not a common practice. This article presents a short introduction to how positions can be efficiently tokenized into ERC-1155 tokens.

Before we dive into the details, let us give a short recap for Alpha Homora V2 features.

-  Leverage your yield farming, up to ~9x. The higher the leverage, the higher the yield farming and trading fee rewards.
-  Can borrow multiple assets, including ETH, USDT, USDC, DAI, and others supported tokens.
-  Yield farm in supported pools, including Uniswap, Sushiswap, Balancer, and Curve.
-  Bring-your-own-LP (BYOLP).
-  Freely adjustable position (Partial Refill and Partial Remove).
-  Users can now claim yield farmed reward tokens.

Alpha Homora V2 is a leverage yield farming product where users can leverage their farming positions by borrowing multiple assets from lenders to further increase their potential rewards.

From a technical perspective, the main flow of Alpha Homora V2 is as follows:

  1. Users interact with HomoraBank contract.
  2. HomoraBank calls Spell contract (UniswapSpell, SushiswapSpell, etc.) to perform actions e.g. addLiquidity, removeLiquidity.
  3. Spell interacts with Wrapper contract ( WMasterChef, WERC20, etc.) to perform staking to/unstaking from the target staking contract.
  4. Spell may put back or withdraw collateral in HomoraBank.

As HomoraBank contract is separated from Spell and Wrapper contracts, HomoraBank needs a way to measure the collateral value of a position, which can be done by tokenizing the position.


Tokenizing Farming Positions

Alpha Homora V2 tokenizes farming positions into ERC-1155 tokens to efficiently and accurately calculate the rewards. Why not ERC-20?

ERC-1155 is a multi-token standard. In other words, ERC-1155 is one type of NFT tokens. It can be treated as a class of ERC-20 tokens, grouped by ids. For example, token A with id 1 will behave mostly like an ERC-20 token and will have its logic separated from token B with id 2 (while both token A and token B are both inside a single ERC-1155 contract). This provides a gas-efficient way to have a class of ERC-20 tokens without having to deploy a separate contract for each new one.
NOTE: https://etherscan.io/ now displays ERC-1155 token transfers!

In Alpha Homora V2, rewards are no longer sold and reinvested into your position.

The reward amounts for farming positions actually depend on 2 factors:

  1. LP Shares – How much LP is staked by the user. The more staked, the more the rewards.
  2. Stake Time – The earlier the user stakes, the higher the reward.

This means that the amount of yield farmed tokens user A and B receive will be different even though they have the same LP shares (as rewards are distributed based on LP shares). This scenario occurs when user A and B open their leveraged yield farming position at different times, resulting in users starting to stake LP tokens to accrue farmed tokens at different times. Because of this, we cannot simply tokenize positions into regular ERC-20 tokens.

If two users stake at the exact same time, their reward split will simply be proportional to their LP shares. Thus, positions with the same stake-time are the same and are fungible (up to LP share amount, which can be reflected in token balance).

Alpha Homora V2's ERC-1155 Wrappers

Alpha Homora V2 wraps ERC-20 LP tokens and mints ERC-1155 tokens for putting as collateral in the HomoraBank, while the actual LP tokens can be staked at the corresponding staking contracts to earn yield farming rewards.

Each wrapper encodes LP tokens and other necessary data (e.g. pool id) into the ERC-1155 token id, so that tokens with the same id implies the same amount of reward. As an example, let's look at WMasterChef, a Sushiswap LP token wrapper for staking to Sushiswap's MasterChef.

WMasterChef's id encodes:

  • pid – MasterChef pool id for the LP token. This determines which pool and ERC-20 LP token you're actually wrapping.
  • rewardPerShare – An accumulated SUSHI reward amount per share (at the time of position adjustment).

The number of tokens a user holds corresponds to how many LP tokens are wrapped. When the user closes the position, the total amount of reward can then be calculated from:

shareBalance * (WMasterChef'scurrentRewardPerShare - token's rewardPerShare)

This calculation is similar to how Sushiswap implements SUSHI token distribution logic by leveraging the difference between the initial rewardPerShare and the currentRewardPerShare, which is only updated globally at every action to MasterChef.

Other Alpha Homora V2 token wrappers include:

  • WERC20 –  simple wrap for Uniswap and Balancer ERC-20 LP tokens without staking logic
  • WLiquidityGauge – wrapper for Curve ERC-20 LP tokens for staking to Curve's Liquidity Gauge
  • WStakingRewards – wrapper for LP tokens that can be stake to staking contracts with Synthetix's IStakingRewards interface.
NOTE: Each of these wrappers may have different encodings due to different interactions with different protocols.

Looking Forward

Alpha Homora V2 utilizes ERC-1155 tokens to tokenize farming positions to use as collateral in the HomoraBank contract and to handle yield farmed reward token calculations.

As the DeFi space grows, DeFi products can get more complex. Fungible tokenization may not be the go-to solution anymore. One good example is the recently launched Uniswap V3. Positions can no longer be tokenized as ERC-20 LP tokens, but would rather require non-fungible tokens e.g. ERC-721 or ERC-1155.


About Alpha Finance Lab

Alpha Finance Lab is a DeFi Lab and on a mission to build an ecosystem of DeFi products (the Alpha ecosystem), consisting of innovative building blocks that capture unaddressed demand in key pillars of the financial system. These building blocks will interoperate, creating the Alpha ecosystem that will be an innovative and more capital efficient way to banking in DeFi.

Alpha Homora is Alpha Finance Lab’s first product and DeFi’s first leveraged yield farming product that captures the market gap in lending, one of the key pillars of the financial system.

Join our Telegram/Discord for the latest updates, follow us on Twitter, or read more about us on our Blog and Document!