TL;DR. Here's what V2 will support:
- Multi assets lending and borrowing (with huge leverage for stablecoin farming!)
- More farming pools beyond just Uniswap (think Balancer, Curve, etc)
- Can keep the farming assets and not just dumping
- No more EOA only = more composability
- You can bring your own LP tokens too = more flexibility
- Native flashloan support
Alpha Homora v2 is an upgrade from Alpha Homora v1, a leveraged yield-farming product. Here are some key features:
- In v2, other assets are borrow-able (not only ETH like in v1), including stablecoins like USDT, USDC, DAI.
- In v2, users may also borrow supported LP tokens to farm more.
- Users can also bring their own LP tokens and add on to their positions.
- Each "spell" defines how the protocol interacts with farming pools, e.g. Uniswap spell, Sushiswap spell, Curve spell.
- Spell functions include e.g.
addLiquidity
,removeLiquidity
. - This is different from v1, where each pool has its own spell (goblin).
- Spell functions include e.g.
- Reward tokens e.g. UNI, SUSHI were sold and reinvested to users' positions in v1. Instead, users can now claim reward tokens.
- Adjustable positions - users can adjust their existing positions by supply more assets, borrow more assets, or repay some debts.
- As long as the collateral credit >= borrow credit. Otherwise, the position is at liquidation risk.
- HomoraBank
- Store each position's collateral tokens (in the form of wrapped LP tokens)
- Users can execute "spells", e.g. opening a new position, closing/adjusting existing position.
- Caster
- Intermediate contract that just calls another contract function (low-level call) with provided data (instead of bank), to prevent attack.
- Doesn't store any funds
- Spells (e.g. Uniswap/Sushiswap/Curve/...)
- Define how to interact with each pool
- Execute
borrow
/repay
assets by interacting with the bank, which will then interact with the lending protocol.
- User -> HomoraBank.
User calls
execute
to HomoraBank, specifying which spell and function to use, e.g.addLiquidity
using Uniswap spell. - HomoraBank -> Caster. Forward low-level spell call to Caster (doesn't hold funds), to prevent attacks.
- Caster -> Spell. Caster does low-level call to Spell.
- Spell may call HomoraBank to e.g.
doBorrow
funds,doTransmit
funds from users (so users can approve only the bank, not each spell),doRepay
debt. Funds are then sent to Spell, to execute pool interaction. - Spells -> Pools. Spells interact with Pools (e.g. optimally swap before supplying to Uniswap, or removing liquidity from the pool and pay back some debts).
- (Optional) Stake LP tokens in wrapper contracts (e.g. WMasterChef for Sushi, WLiquidityGauge for Curve, WStakingRewards for Uniswap + Balancer).
- Spell may put collateral back to HomoraBank. If the spell funtion called is e.g. to open a new position, then the LP tokens will be stored in HomoraBank.
- User calls
execute(0, USDT, WETH, data)
on HomoraBank contract.data
encodes UniswapSpell function call with arguments (including how much of each asset to supply, to borrow, and slippage control settings). - HomoraBank forwards data call to Caster.
- Caster does low-level call (with
data
, which encodesaddLiquidity
function call with arguments) to UniswapSpell. - UniswapSpell executes
addLiquidityWERC20
doTransmit
desired amount of assets the user wants to supplydoBorrow
from the lending protocol- Optimally swap assets and add liquidity to Uniswap pool
- Wrap LP tokens to wrapper WERC20 (to get ERC1155)
doPutCollateral
wrapped tokens back to HomoraBank- Refund leftover assets to the user.
For Uniswap pools with staking rewards, use
addLiquidityWStakingRewards
function. For Sushiswap pools with staking in masterchef, useaddLiqudityWMasterChef
function. For Balancer pools with staking rewards, useaddLiquidityWStakingRewards
function. For all Curve pools, useaddLiquidity[N]
(whereN
is the number of underlying tokens). The spell will auto put in Curve's liquidity gauge.
Prices are determined in ETH.
- For regular assets, asset prices can be derived from Uniswap pool (with WETH), or Keep3r.
- For LP tokens, asset prices will determine the optimal reserve proportion of the underlying assets, which are then used to compute the value of LP tokens. See
UniswapV2Oracle.sol
for example implementation.