Blueberry Core v1 is an upgrade and fork from Alpha Homora v2, a leveraged yield-farming product. Here are some key features:
The protocol is integrated with existing lending protocol (Blueberry Money Market). Whenever a user wants to borrow funds (on leverage) to yield farm additionally, Blueberry Bank will borrow from the lending protocol (Blueberry Money Market).
- A wide varitey of assets are borrow-able, including stables like USDC, USDT, DAI.
- Each "spell" defines how the protocol interacts with the end deployment. Such as concentrated liquidity vaults, e.g. Ichi vault.
- Spell functions include e.g.
_deposit,_withdraw.
- Spell functions include e.g.
- Adjustable positions - users can adjust their existing positions by supply more assets (Isolated collateral), borrow more assets, or repay some debts.
- As long as the collateral credit (Deployment + Isolated Collateral value) >= borrow credit. Otherwise, the position is at liquidiation risk.
- BlueberryBank
- Store each position's collateral tokens (in the form of wrapped NFT tokens)
- Users can execute "spells", e.g. opening a new position, closing/adjusting existing position.
- Spells (e.g. Ichi,Uniswap/Sushiswap/Curve/...)
- Define how to interact with each external protocol
- Execute
borrow/repayassets by intereacting with the bank, which will then interact with the lending protocol (Blueberry Money Market).
- User -> BlueberryBank.
User calls
executeto BlueberryBank, specifying which spell and function to use, e.g. `_deposit using IchiSpell. - BlueberryBank -> Spell
- Spell may call BlueberryBank to e.g.
_doBorrowfunds and_doRepaydebt. Funders 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. WStakingRewards for Uniswap + Balancer).
- Spell may put collateral back to BlueberryBank. If the spell function called is e.g. to open a new position, then the LP tokens will be stored in BlueberryBank.
- User calls
execute(0, USDT, WETH, data)on BlueberryBank contract.dataencodes IchiSpell function call with arguments (including how much of each asset to supply, to borrow, and slippage control settings). - BlueberryBank uses data call to encoded
putCollateralfunction call with arguments) to IchiSpell. - IchiSpell executes
putCollateralWERC20
_doBorrowfrom the lending protocol- Deposit Single asset into ICHI vault and recieve LP Token
- Wrap LP tokens to wrapper WERC20 (toget ERC 1155)
_doPutCollateralwrapped tokens back to BlueberryBank- Refund leftover assets to the user.
Prices are determined in USD.
- For regular assets, asset prices can be derived from Chainlink, Band, or Uniswap feeds.
- For LP tokens, asset prices will determine the optimal reserve proportion of the underlying assets, which are then used to compoute the value of LP tokens. See
Uniswapv3AdpaterOracle.solfor example implementation.
Steps to run the tests: Hardhat version 2.12.4 Block height 16283930 Eth mainnet fork
Copies all the files
Clone the repo
yarn install
Create .env file with env var DEPLOY_ACCOUNT_KEY= , ALCHEMY_API_KEY= , ETHERSCAN_API_KEY= (use http://alchemy.com)
yarn hardhat compile
yarn hardhat test
yarn hardhat coverage