Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions contracts/src/deployers/HyperdriveDeployerCoordinator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity 0.8.19;

import { IHyperdrive } from "../interfaces/IHyperdrive.sol";
import { IHyperdriveCoreDeployer } from "../interfaces/IHyperdriveCoreDeployer.sol";
import { IHyperdriveDeployer } from "../interfaces/IHyperdriveDeployer.sol";
import { IDeployerCoordinator } from "../interfaces/IDeployerCoordinator.sol";
import { IHyperdriveTargetDeployer } from "../interfaces/IHyperdriveTargetDeployer.sol";

/// @author DELV
Expand All @@ -14,7 +14,7 @@ import { IHyperdriveTargetDeployer } from "../interfaces/IHyperdriveTargetDeploy
/// @custom:disclaimer The language used in this code is for coding convenience
/// only, and is not intended to, and does not, have any
/// particular legal or regulatory significance.
abstract contract HyperdriveDeployerCoordinator is IHyperdriveDeployer {
abstract contract HyperdriveDeployerCoordinator is IDeployerCoordinator {
/// @notice The contract used to deploy new instances of Hyperdrive.
address public immutable coreDeployer;

Expand Down
559 changes: 442 additions & 117 deletions contracts/src/factory/HyperdriveFactory.sol

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity 0.8.19;

import { IHyperdrive } from "./IHyperdrive.sol";

interface IHyperdriveDeployer {
interface IDeployerCoordinator {
function deploy(
IHyperdrive.PoolDeployConfig memory _config,
bytes memory _extraData
Expand Down
19 changes: 13 additions & 6 deletions contracts/src/interfaces/IHyperdrive.sol
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,6 @@ interface IHyperdrive is IHyperdriveRead, IHyperdriveCore, IMultiToken {
error InvalidBaseToken();
error InvalidCheckpointTime();
error InvalidCheckpointDuration();
error InvalidDeployer();
error InvalidEffectiveShareReserves();
error InvalidFeeAmounts();
error InvalidFeeDestination();
Expand Down Expand Up @@ -307,14 +306,22 @@ interface IHyperdrive is IHyperdriveRead, IHyperdriveCore, IMultiToken {
/// ### Factory ###
/// ###############
error Unauthorized();
error InvalidCheckpointDurationResolution();
error InvalidContribution();
error InvalidDeployConfig();
error InvalidDeployerCoordinator();
error InvalidFees();
error InvalidMaxFees();
error InvalidMinFees();
error InvalidMaxCheckpointDuration();
error InvalidMinCheckpointDuration();
error InvalidMaxPositionDuration();
error InvalidMinPositionDuration();
error InvalidToken();
error MaxFeeTooHigh();
error FeeTooHigh();
error NonPayableInitialization();
error HyperdriveDeployerAlreadyAdded();
error HyperdriveDeployerNotAdded();
error HyperdriveDeployerIndexMismatch();
error DeployerCoordinatorAlreadyAdded();
error DeployerCoordinatorNotAdded();
error DeployerCoordinatorIndexMismatch();

/// ######################
/// ### ERC20Forwarder ###
Expand Down
4 changes: 2 additions & 2 deletions contracts/test/MockHyperdriveDeployer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
pragma solidity 0.8.19;

import { IHyperdrive } from "contracts/src/interfaces/IHyperdrive.sol";
import { IHyperdriveDeployer } from "contracts/src/interfaces/IHyperdriveDeployer.sol";
import { IDeployerCoordinator } from "contracts/src/interfaces/IDeployerCoordinator.sol";
import { IHyperdriveTargetDeployer } from "contracts/src/interfaces/IHyperdriveTargetDeployer.sol";
import { MockHyperdrive } from "./MockHyperdrive.sol";

contract MockHyperdriveDeployer is IHyperdriveDeployer {
contract MockHyperdriveDeployer is IDeployerCoordinator {
function deploy(
IHyperdrive.PoolDeployConfig memory _deployConfig,
bytes memory
Expand Down
143 changes: 111 additions & 32 deletions script/DevnetMigration.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,15 @@ contract DevnetMigration is Script {
// lido configuration
uint256 lidoStartingRate;
// factory configuration
uint256 factoryCurveFee;
uint256 factoryFlatFee;
uint256 factoryGovernanceLPFee;
uint256 factoryGovernanceZombieFee;
uint256 factoryCheckpointDurationResolution;
uint256 factoryMinCheckpointDuration;
uint256 factoryMaxCheckpointDuration;
uint256 factoryMinPositionDuration;
uint256 factoryMaxPositionDuration;
uint256 factoryMinCurveFee;
uint256 factoryMinFlatFee;
uint256 factoryMinGovernanceLPFee;
uint256 factoryMinGovernanceZombieFee;
uint256 factoryMaxCurveFee;
uint256 factoryMaxFlatFee;
uint256 factoryMaxGovernanceLPFee;
Expand All @@ -74,6 +79,10 @@ contract DevnetMigration is Script {
uint256 erc4626HyperdrivePositionDuration;
uint256 erc4626HyperdriveCheckpointDuration;
uint256 erc4626HyperdriveTimeStretchApr;
uint256 erc4626HyperdriveCurveFee;
uint256 erc4626HyperdriveFlatFee;
uint256 erc4626HyperdriveGovernanceLPFee;
uint256 erc4626HyperdriveGovernanceZombieFee;
// steth hyperdrive configuration
uint256 stethHyperdriveContribution;
uint256 stethHyperdriveFixedRate;
Expand All @@ -82,6 +91,10 @@ contract DevnetMigration is Script {
uint256 stethHyperdrivePositionDuration;
uint256 stethHyperdriveCheckpointDuration;
uint256 stethHyperdriveTimeStretchApr;
uint256 stethHyperdriveCurveFee;
uint256 stethHyperdriveFlatFee;
uint256 stethHyperdriveGovernanceLPFee;
uint256 stethHyperdriveGovernanceZombieFee;
}

function run() external {
Expand Down Expand Up @@ -113,31 +126,57 @@ contract DevnetMigration is Script {
// lido configuration
lidoStartingRate: vm.envOr("LIDO_STARTING_RATE", uint256(0.035e18)),
// factory configuration
factoryCurveFee: vm.envOr("FACTORY_CURVE_FEE", uint256(0.01e18)),
factoryFlatFee: vm.envOr("FACTORY_FLAT_FEE", uint256(0.0005e18)),
factoryGovernanceLPFee: vm.envOr(
"FACTORY_GOVERNANCE_LP_FEE",
uint256(0.01e18)
factoryCheckpointDurationResolution: vm.envOr(
"FACTORY_CHECKPOINT_DURATION_RESOLUTION",
uint256(1 hours)
),
factoryGovernanceZombieFee: vm.envOr(
"FACTORY_GOVERNANCE_ZOMBIE_FEE",
uint256(0.1e18)
factoryMinCheckpointDuration: vm.envOr(
"FACTORY_MIN_CHECKPOINT_DURATION",
uint256(8 hours)
),
factoryMaxCheckpointDuration: vm.envOr(
"FACTORY_MAX_CHECKPOINT_DURATION",
uint256(1 days)
),
factoryMinPositionDuration: vm.envOr(
"FACTORY_MIN_POSITION_DURATION",
uint256(7 days)
),
factoryMaxPositionDuration: vm.envOr(
"FACTORY_MAX_POSITION_DURATION",
uint256(10 * 365 days)
),
factoryMinCurveFee: vm.envOr(
"FACTORY_MIN_CURVE_FEE",
uint256(0.001e18)
),
factoryMinFlatFee: vm.envOr(
"FACTORY_MIN_FLAT_FEE",
uint256(0.0001e18)
),
factoryMinGovernanceLPFee: vm.envOr(
"FACTORY_MIN_GOVERNANCE_LP_FEE",
uint256(0.15e18)
),
factoryMinGovernanceZombieFee: vm.envOr(
"FACTORY_MIN_GOVERNANCE_ZOMBIE_FEE",
uint256(0.03e18)
),
factoryMaxCurveFee: vm.envOr(
"FACTORY_MAX_CURVE_FEE",
uint256(0.03e18)
uint256(0.1e18)
),
factoryMaxFlatFee: vm.envOr(
"FACTORY_MAX_FLAT_FEE",
uint256(0.0015e18)
uint256(0.001e18)
),
factoryMaxGovernanceLPFee: vm.envOr(
"FACTORY_MAX_GOVERNANCE_LP_FEE",
uint256(0.3e18)
uint256(0.15e18)
),
factoryMaxGovernanceZombieFee: vm.envOr(
"FACTORY_MAX_GOVERNANCE_ZOMBIE_FEE",
uint256(0.3e18)
uint256(0.03e18)
),
// erc4626 hyperdrive configuration
erc4626HyperdriveContribution: vm.envOr(
Expand Down Expand Up @@ -168,6 +207,22 @@ contract DevnetMigration is Script {
"ERC4626_HYPERDRIVE_TIME_STRETCH_APR",
uint256(0.05e18)
),
erc4626HyperdriveCurveFee: vm.envOr(
"ERC4626_HYPERDRIVE_CURVE_FEE",
uint256(0.01e18)
),
erc4626HyperdriveFlatFee: vm.envOr(
"ERC4626_HYPERDRIVE_FLAT_FEE",
uint256(0.0005e18)
),
erc4626HyperdriveGovernanceLPFee: vm.envOr(
"ERC4626_HYPERDRIVE_GOVERNANCE_LP_FEE",
uint256(0.15e18)
),
erc4626HyperdriveGovernanceZombieFee: vm.envOr(
"ERC4626_HYPERDRIVE_GOVERNANCE_ZOMBIE_FEE",
uint256(0.03e18)
),
// steth hyperdrive configuration
stethHyperdriveContribution: vm.envOr(
"STETH_HYPERDRIVE_CONTRIBUTION",
Expand Down Expand Up @@ -196,6 +251,22 @@ contract DevnetMigration is Script {
stethHyperdriveTimeStretchApr: vm.envOr(
"STETH_HYPERDRIVE_TIME_STRETCH_APR",
uint256(0.035e18)
),
stethHyperdriveCurveFee: vm.envOr(
"STETH_HYPERDRIVE_CURVE_FEE",
uint256(0.01e18)
),
stethHyperdriveFlatFee: vm.envOr(
"STETH_HYPERDRIVE_FLAT_FEE",
uint256(0.0005e18)
),
stethHyperdriveGovernanceLPFee: vm.envOr(
"STETH_HYPERDRIVE_GOVERNANCE_LP_FEE",
uint256(0.15e18)
),
stethHyperdriveGovernanceZombieFee: vm.envOr(
"STETH_HYPERDRIVE_GOVERNANCE_ZOMBIE_FEE",
uint256(0.03e18)
)
});

Expand Down Expand Up @@ -250,19 +321,25 @@ contract DevnetMigration is Script {
governance: msg.sender,
hyperdriveGovernance: config.admin,
feeCollector: config.admin,
fees: IHyperdrive.Fees({
curve: config.factoryCurveFee,
flat: config.factoryFlatFee,
governanceLP: config.factoryGovernanceLPFee,
governanceZombie: config.factoryGovernanceZombieFee
defaultPausers: defaultPausers,
checkpointDurationResolution: config
.factoryCheckpointDurationResolution,
minCheckpointDuration: config.factoryMinCheckpointDuration,
maxCheckpointDuration: config.factoryMaxCheckpointDuration,
minPositionDuration: config.factoryMinPositionDuration,
maxPositionDuration: config.factoryMaxPositionDuration,
minFees: IHyperdrive.Fees({
curve: config.factoryMinCurveFee,
flat: config.factoryMinFlatFee,
governanceLP: config.factoryMinGovernanceLPFee,
governanceZombie: config.factoryMinGovernanceZombieFee
}),
maxFees: IHyperdrive.Fees({
curve: config.factoryMaxCurveFee,
flat: config.factoryMaxFlatFee,
governanceLP: config.factoryMaxGovernanceLPFee,
governanceZombie: config.factoryMaxGovernanceZombieFee
}),
defaultPausers: defaultPausers,
linkerFactory: address(forwarderFactory),
linkerCodeHash: forwarderFactory.ERC20LINK_HASH()
});
Expand All @@ -279,7 +356,7 @@ contract DevnetMigration is Script {
address(new ERC4626Target3Deployer())
)
);
factory.addHyperdriveDeployer(erc4626DeployerCoordinator);
factory.addDeployerCoordinator(erc4626DeployerCoordinator);

// Deploy and initialize an initial ERC4626Hyperdrive instance.
IHyperdrive erc4626Hyperdrive;
Expand Down Expand Up @@ -308,10 +385,11 @@ contract DevnetMigration is Script {
governance: config.admin,
feeCollector: config.admin,
fees: IHyperdrive.Fees({
curve: config.factoryCurveFee,
flat: config.factoryFlatFee,
governanceLP: config.factoryGovernanceLPFee,
governanceZombie: config.factoryGovernanceZombieFee
curve: config.erc4626HyperdriveCurveFee,
flat: config.erc4626HyperdriveFlatFee,
governanceLP: config.erc4626HyperdriveGovernanceLPFee,
governanceZombie: config
.erc4626HyperdriveGovernanceZombieFee
})
});
erc4626Hyperdrive = factory.deployAndInitialize(
Expand All @@ -335,7 +413,7 @@ contract DevnetMigration is Script {
ILido(address(lido))
)
);
factory.addHyperdriveDeployer(stethDeployerCoordinator);
factory.addDeployerCoordinator(stethDeployerCoordinator);

// Deploy and initialize an initial StETHHyperdrive instance.
IHyperdrive stethHyperdrive;
Expand Down Expand Up @@ -363,10 +441,11 @@ contract DevnetMigration is Script {
governance: config.admin,
feeCollector: config.admin,
fees: IHyperdrive.Fees({
curve: config.factoryCurveFee,
flat: config.factoryFlatFee,
governanceLP: config.factoryGovernanceLPFee,
governanceZombie: config.factoryGovernanceZombieFee
curve: config.stethHyperdriveCurveFee,
flat: config.stethHyperdriveFlatFee,
governanceLP: config.stethHyperdriveGovernanceLPFee,
governanceZombie: config
.stethHyperdriveGovernanceZombieFee
})
});
stethHyperdrive = factory.deployAndInitialize{
Expand Down
33 changes: 24 additions & 9 deletions test/instances/erc4626/ERC4626Hyperdrive.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { IERC20 } from "contracts/src/interfaces/IERC20.sol";
import { IERC4626 } from "contracts/src/interfaces/IERC4626.sol";
import { IERC4626Hyperdrive } from "contracts/src/interfaces/IERC4626Hyperdrive.sol";
import { IHyperdrive } from "contracts/src/interfaces/IHyperdrive.sol";
import { IHyperdriveDeployer } from "contracts/src/interfaces/IHyperdriveDeployer.sol";
import { IDeployerCoordinator } from "contracts/src/interfaces/IDeployerCoordinator.sol";
import { AssetId } from "contracts/src/libraries/AssetId.sol";
import { FixedPointMath, ONE } from "contracts/src/libraries/FixedPointMath.sol";
import { ForwarderFactory } from "contracts/src/token/ForwarderFactory.sol";
Expand Down Expand Up @@ -83,10 +83,25 @@ contract ERC4626HyperdriveTest is HyperdriveTest {
HyperdriveFactory.FactoryConfig({
governance: alice,
hyperdriveGovernance: bob,
feeCollector: bob,
feeCollector: celine,
defaultPausers: defaults,
fees: IHyperdrive.Fees(0, 0, 0, 0),
maxFees: IHyperdrive.Fees(0, 0, 0, 0),
checkpointDurationResolution: 1 hours,
minCheckpointDuration: 8 hours,
maxCheckpointDuration: 1 days,
minPositionDuration: 7 days,
maxPositionDuration: 10 * 365 days,
minFees: IHyperdrive.Fees({
curve: 0,
flat: 0,
governanceLP: 0,
governanceZombie: 0
}),
maxFees: IHyperdrive.Fees({
curve: ONE,
flat: ONE,
governanceLP: ONE,
governanceZombie: ONE
}),
linkerFactory: address(forwarderFactory),
linkerCodeHash: forwarderFactory.ERC20LINK_HASH()
})
Expand Down Expand Up @@ -126,7 +141,7 @@ contract ERC4626HyperdriveTest is HyperdriveTest {

vm.stopPrank();
vm.startPrank(alice);
factory.addHyperdriveDeployer(deployerCoordinator);
factory.addDeployerCoordinator(deployerCoordinator);
dai.approve(address(factory), type(uint256).max);
dai.approve(address(hyperdrive), type(uint256).max);
dai.approve(address(mockHyperdrive), type(uint256).max);
Expand Down Expand Up @@ -268,8 +283,8 @@ contract ERC4626HyperdriveTest is HyperdriveTest {
apr,
365 days
),
governance: alice,
feeCollector: bob,
governance: address(0),
feeCollector: address(0),
fees: IHyperdrive.Fees(0, 0, 0, 0)
});
dai.approve(address(factory), type(uint256).max);
Expand Down Expand Up @@ -322,8 +337,8 @@ contract ERC4626HyperdriveTest is HyperdriveTest {
apr,
365 days
),
governance: alice,
feeCollector: bob,
governance: address(0),
feeCollector: address(0),
fees: IHyperdrive.Fees(0, 0, 0, 0)
});
dai.approve(address(factory), type(uint256).max);
Expand Down
Loading