Architecture
Last updated
Last updated
Unagii Vaults V1 is an Ethereum-based protocol that enables users to passively earn from automated yield farming by depositing single crypto assets into the Vaults executing a specific Strategy in a gas-efficient environment. Unagii integrates with third-party DeFi protocols (i.e. AMMs and lending platforms), enabling support for a wide selection of strategies that are deemed safe and valuable to users.
Name
Description
admin
Admin refers to the Unagii team, managed by a 2 out of 3 team member Gnosis multisig. Admin members are able to set and approve strategies, and execute the deposit
invest
harvest
skim
withdraw
exit
functions.
bots
These are Externally Owned Accounts (EOA) that are set to automate transactions at specific time periods to the Controller contract.
controller
The main Unagii governance contract. Only the Admin and Bots are authorized to trigger transactions on the Controller.
defi
DeFi is the acronym for Decentralized Finance, a term describing a variety of blockchain-based financial protocols and applications.
deposit
The function to transfer user funds into Strategy.
exit
The function to claim and sell down rewards, then return all funds in the associated Strategy back into the Vault.
gas token
This is the contract that allows Unagii to tokenize gas on Ethereum. Unagii will store gas when it is cheap to do so, and spend the Gas Token when deployment and transaction costs are high.
gas relayer
This enables the Bots to spend the Gas Token on a transaction that cuts transaction fees.
harvest
The function to claim and sell down rewards into the most premium deposit token, then re-investing the token back into the vault, thereby compounding rewards.
invest
Calls the Deposit function to transfer tokens from the Vault into the Strategy.
skim
The function to update user balances according to the asset balance in the Strategy. It can only be called when the asset balance is more than the debt balance within the Strategy.
strategy
Strategy determines how yield is generated and accrued. Each DeFi protocol has different sets of strategies. Unagii has curated a bank of whitelisted strategies handpicked by the team that will give users the best performing yields on their tokens.
time lock
All new strategy contracts to be launched will be deployed behind a 24 hour time lock. It is currently managed by admin. The time lock will need to be called in order for new strategies to be approved. Users will be able to verify all of such events on-chain.
withdraw
The function to withdraw tokens from the Strategy back into the Vault.
Unagii Vaults V2 is the next iteration of the protocol with a slightly different architecture:
Vaults are upgradable by default as the Unagii Token contracts and the Vault contracts are separated, making it similar in design with Curve token and Curve pool contract
Smart contracts can interact (deposit/withdraw) from the vaults, which allows any developer to integrate with Unagii Vaults V2 (there is a block delay)
Vaults are protected from flash loan attacks as Unagii token tracks the lastest block number of the caller
Protected from sandwich attack on harvest as profit is vested over a period of time (6 hours for now)
Vaults are able to invest in multiple strategies, allowing the protocol to maximize returns by optimizing the allocation of funds to each strategy
Name
Description
mint
mint Unagii shares when user deposits.
burn
burn Unagii shares when user withdraws.
setMinter
set minter to Vault. this makes Unagii V2 upgradable. (only called by TimeLock).
Name
Description
deposit
user deposit token (DAI, USDC, USDT, ETH, WBTC), receives Unagii token in return.
withdraw
user withdraws token (DAI, USDC, USDT, ETH, WBTC), Unagii token is burnt.
setFundManager
set FundManager used to upgrade FundManager contract (only called by TimeLock).
borrow
borrow user funds from Vault (only FundManager can call).
repay
repay borrowed funds (only FundManager can call).
report
report profit back to Vault.
Name
Description
setVault
set Vault used to upgrade Vault contract (only TimeLock can call).
approveStrategy
approve new strategy (only TimeLock can call).
addStrategyToQueue
activate strategy (only approved strategy can be activated).
removeStrategyFromQueue
deactivate strategy.
setQueue
reorder activate strategies (order determines which strategy to withdraw from first).
borrowFromVault
borrow user funds from Vault.
repayVault
repay user funds to Vault.
reportToVault
call report on Vault.
withdraw
withdraw user funds from FundManager and activate strategies, back into Vault.
Name
Description
borrow
borrow user funds from FundManager.
repay
repay user funds to FundManager.
report
report profit back to FundManager.
withdraw
withdraw user funds back into FundManager.
deposit
borrow from FundManager and invest into external DeFi.
claimRewards / skim / harvest
claim profit.
Unagii Vaults V3 further iterate upon the protocol with the following changes:
Implements the ERC-4626 standard for compatibility with other DeFi protocols
Gas cost optimizations for users and operators
Upgradable Swap contract allows us to choose the best AMM exchange rates for yield -> vault tokens in response to changing market conditions
deposit / mint
deposit asset token (USDC, ETH, etc) in exchange for Unagii vault tokens
withdraw / redeem
exchange Unagii vault tokens for asset token (USDC, ETH, etc)
addStrategy
adds a new strategy to strategy queue
removeStrategy
withdraws all assets from strategy to Vault and removes it from strategy queue
harvest / harvestAll
claim profit from strategies
report / reportAll
re-balance assets within strategies
collectFromStrategy
manually withdraws assets from strategy
harvest
claim profit from DeFi
invest
deposit assets into DeFi
withdraw
sends assets back to vault
setSwap
set swap contract used (if necessary)
setRoute
choose AMM to swap token pair with (e.g. Uniswap, Sushiswap)
swapTokens
swap tokens along the assigned best route