Skip to content

Latest commit

 

History

History
87 lines (51 loc) · 4.06 KB

README.md

File metadata and controls

87 lines (51 loc) · 4.06 KB

🐝 Apiary

system diagram

🧩 Summary

The Hive and Flower contracts form a modular framework for managing and interacting with tokenized assets and yield-bearing protocols.

Hive acts as a central vault and management hub. It inherits from ERC4626, a standard for tokenized vaults, and Owned, indicating that it has an owner (aka "Queen") with administrative rights. The primary function of the Hive is to manage deposits and withdrawals from users (aka "Beekeepers") of an ERC20 asset (referred to as "Bees") and to interact with various Flowers, which are external yield-generating protocols or contracts.

🍯 Hive

  1. Token Management: Hive allows for the deposit and redemption of tokens, converting them into shares and managing the total assets within the vault.

  2. Flower Integration: Hive manages a list of approved Flowers, which are "bridges" to yield-bearing protocols. These Flowers are added or removed by the owner of the Hive.

  3. Pollination: The pollinate function enables users to transfer their tokens from the Hive to a Flower, effectively staking their assets to generate yield.

  4. Harvesting: The harvest function allows users to collect the yield generated by the Flowers. This involves interacting with the Flower (via the Hive) to reclaim the staked assets and any accrued rewards, which are then deposited back into the Hive for the user.

  5. Security: The Hive includes a modifier, onlyFlower, ensuring that only authorized Flowers can interact with specific functions, adding a layer of security to prevent unauthorized access.

Flower is an abstract contract designed to be inherited by contracts that exposed yield-generating protocols. It is linked to a Hive and manages interactions with these protocols to generate returns on the assets provided by the Hive.

🌷 Flower

  1. Protocol Interface: Flower provides an interface for specific protocols, like Synthetix, to handle the deposited tokens and manage yield generation.

  2. Pollination and Harvesting: The pollinate function handles the initial staking or provision of assets into the yield-generating protocol. The harvest function manages the collection of yields, ensuring that the accrued rewards are returned to the Hive.

  3. Account Management: In the context of protocols like Synthetix, Flower manages account creation and collateral delegation to ensure that the assets are efficiently staked and yield is maximized.

  4. Rewards Management: Some Flowers, like the Synthetix Flower, include functionality for harvesting rewards without concluding the staking period, allowing for continuous yield generation and reward collection.

  5. Compatibility and Flexibility: Flower is designed to be flexible, allowing integration with various protocols and adapting to changes within these protocols.

🎯 Objective

Overall, the Hive and Flower framework provides a structured and secure way to manage and grow assets through interactions with various DeFi protocols, allowing users to deposit, stake, and harvest their tokens seamlessly.

💥 How to Use

🚀 Deployment

See script/Deploy.s.sol for an example of how to deploy the Hive and Flower contracts using Foundry.

🛠️ Foundry

Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.

Foundry consists of:

  • Forge: Ethereum testing framework (like Truffle, Hardhat and DappTools).
  • Cast: Swiss army knife for interacting with EVM smart contracts, sending transactions and getting chain data.
  • Anvil: Local Ethereum node, akin to Ganache, Hardhat Network.
  • Chisel: Fast, utilitarian, and verbose solidity REPL.

docs: https://book.getfoundry.sh/

Usage

Build
$ forge build
Test
$ forge test
$ forge test --match-test TEST_NAME
Format
$ forge fmt
Gas Snapshots
$ forge snapshot