-
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.
- Added allocation functionality that deposits a single asset (tBTC) to an authorized vault - Added and adjusted deployment scripts - Changed unit tests and added an integration test that validates the flow of assets from Acre contract through Dispatcher that deposits assets to an authorized ERC4626 Vault
- Loading branch information
Showing
13 changed files
with
635 additions
and
62 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
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
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,37 @@ | ||
// SPDX-License-Identifier: GPL-3.0-only | ||
pragma solidity ^0.8.21; | ||
|
||
import "@openzeppelin/contracts/interfaces/IERC4626.sol"; | ||
|
||
/// @title Router | ||
/// @notice Router 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. | ||
abstract contract Router { | ||
/// Thrown when amount of shares received is below the min set by caller. | ||
/// @param vault Address of the vault. | ||
/// @param sharesOut Amount of shares received by Acre. | ||
/// @param minSharesOut Minimum amount of shares expected to receive. | ||
error MinSharesError( | ||
address vault, | ||
uint256 sharesOut, | ||
uint256 minSharesOut | ||
); | ||
|
||
/// @notice Routes funds from stBTC (Acre) to a vault. The amount of tBTC to | ||
/// Shares of deposited tBTC are minted to the stBTC contract. | ||
/// @param vault Address of the vault to route the funds to. | ||
/// @param receiver Address of the receiver of the shares. | ||
/// @param amount Amount of tBTC to deposit. | ||
/// @param minSharesOut Minimum amount of shares to receive. | ||
function deposit( | ||
IERC4626 vault, | ||
address receiver, | ||
uint256 amount, | ||
uint256 minSharesOut | ||
) internal returns (uint256 sharesOut) { | ||
if ((sharesOut = vault.deposit(amount, receiver)) < minSharesOut) { | ||
revert MinSharesError(address(vault), sharesOut, minSharesOut); | ||
} | ||
} | ||
} |
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,12 @@ | ||
// SPDX-License-Identifier: GPL-3.0-only | ||
pragma solidity ^0.8.21; | ||
|
||
import "@openzeppelin/contracts/token/ERC20/extensions/ERC4626.sol"; | ||
|
||
contract TestERC4626 is ERC4626 { | ||
constructor( | ||
IERC20 asset, | ||
string memory tokenName, | ||
string memory tokenSymbol | ||
) ERC4626(asset) ERC20(tokenName, tokenSymbol) {} | ||
} |
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,27 @@ | ||
import type { HardhatRuntimeEnvironment } from "hardhat/types" | ||
import type { DeployFunction } from "hardhat-deploy/types" | ||
|
||
const func: DeployFunction = async (hre: HardhatRuntimeEnvironment) => { | ||
const { getNamedAccounts, deployments } = hre | ||
const { log } = deployments | ||
const { deployer } = await getNamedAccounts() | ||
const tBTC = await deployments.get("TBTC") | ||
|
||
log("deploying Mock ERC4626 Vault") | ||
|
||
await deployments.deploy("Vault", { | ||
contract: "TestERC4626", | ||
from: deployer, | ||
args: [tBTC.address, "MockVault", "MV"], | ||
log: true, | ||
waitConfirmations: 1, | ||
}) | ||
} | ||
|
||
export default func | ||
|
||
func.tags = ["TestERC4626"] | ||
func.dependencies = ["TBTC"] | ||
|
||
func.skip = async (hre: HardhatRuntimeEnvironment): Promise<boolean> => | ||
hre.network.name === "mainnet" |
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
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,21 @@ | ||
import type { HardhatRuntimeEnvironment } from "hardhat/types" | ||
import type { DeployFunction } from "hardhat-deploy/types" | ||
|
||
const func: DeployFunction = async (hre: HardhatRuntimeEnvironment) => { | ||
const { getNamedAccounts, deployments } = hre | ||
const { deployer } = await getNamedAccounts() | ||
|
||
const dispatcher = await deployments.get("Dispatcher") | ||
|
||
await deployments.execute( | ||
"Acre", | ||
{ from: deployer, log: true, waitConfirmations: 1 }, | ||
"updateDispatcher", | ||
dispatcher.address, | ||
) | ||
} | ||
|
||
export default func | ||
|
||
func.tags = ["AcreUpdateDispatcher"] | ||
func.dependencies = ["Acre", "Dispatcher"] |
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,19 @@ | ||
import type { HardhatRuntimeEnvironment } from "hardhat/types" | ||
import type { DeployFunction } from "hardhat-deploy/types" | ||
|
||
const func: DeployFunction = async (hre: HardhatRuntimeEnvironment) => { | ||
const { getNamedAccounts, deployments } = hre | ||
const { deployer, maintainer } = await getNamedAccounts() | ||
|
||
await deployments.execute( | ||
"Dispatcher", | ||
{ from: deployer, log: true, waitConfirmations: 1 }, | ||
"updateMaintainer", | ||
maintainer, | ||
) | ||
} | ||
|
||
export default func | ||
|
||
func.tags = ["DispatcherUpdateMaintainer"] | ||
func.dependencies = ["Dispatcher"] |
Oops, something went wrong.