-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handling ERC4626 vaults in AcreRouter
AcreRouter contract should manage ERC4626 vaults within the Acre system. Owner of the contract should be able to add or remove vaults.
- Loading branch information
Showing
2 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// SPDX-License-Identifier: GPL-3.0-only | ||
pragma solidity ^0.8.21; | ||
|
||
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; | ||
|
||
/// @title AcreRouter | ||
/// @notice AcreRouter is a contract that routes TBTC from stBTC (Acre) to | ||
/// a given vault and back. Vaults supply yield strategies with TBTC that | ||
/// generate yield for Bitcoin holders. | ||
contract AcreRouter is OwnableUpgradeable { | ||
struct Vault { | ||
bool approved; | ||
} | ||
|
||
/// @notice Approved vaults within the Yiern Modules that implement ERC4626 | ||
/// standard. These vaults deposit assets to yield strategies, e.g. | ||
/// Uniswap V3 WBTC/TBTC pool. Vault can be a part of Acre ecosystem | ||
/// or can be implemented externally. As long as it complies with | ||
/// ERC4626 standard and is approved by the owner it can be | ||
/// plugged into Acre. | ||
address[] public vaults; | ||
mapping(address => Vault) public vaultsInfo; | ||
|
||
event VaultAdded(address indexed vault); | ||
event VaultRemoved(address indexed vault); | ||
|
||
/// @notice Adds a vault to the list of approved vaults. | ||
/// @param vault Address of the vault to add. | ||
function addVault(address vault) external onlyOwner { | ||
require(!vaultsInfo[vault].approved, "Vault already approved"); | ||
|
||
vaults.push(vault); | ||
vaultsInfo[vault].approved = true; | ||
|
||
emit VaultAdded(vault); | ||
} | ||
|
||
/// @notice Removes a vault from the list of approved vaults. | ||
/// @param vault Address of the vault to remove. | ||
function removeVault(address vault) external onlyOwner { | ||
require(vaultsInfo[vault].approved, "Not a vault"); | ||
|
||
delete vaultsInfo[vault]; | ||
|
||
for (uint256 i = 0; i < vaults.length; i++) { | ||
if (vaults[i] == vault) { | ||
vaults[i] = vaults[vaults.length - 1]; | ||
vaults.pop(); | ||
break; | ||
} | ||
} | ||
|
||
emit VaultRemoved(vault); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters