diff --git a/contracts/src/deployers/HyperdriveDeployerCoordinator.sol b/contracts/src/deployers/HyperdriveDeployerCoordinator.sol index ffb03f616..e0c055deb 100644 --- a/contracts/src/deployers/HyperdriveDeployerCoordinator.sol +++ b/contracts/src/deployers/HyperdriveDeployerCoordinator.sol @@ -92,7 +92,7 @@ abstract contract HyperdriveDeployerCoordinator is /// @param _deployConfig The deploy configuration of the Hyperdrive pool. /// @param _extraData The extra data that contains the pool and sweep targets. /// @param _salt The create2 salt used to deploy Hyperdrive. - /// @return The address of the newly deployed ERC4626Hyperdrive Instance. + /// @return The address of the newly deployed Hyperdrive instance. function deploy( bytes32 _deploymentId, IHyperdrive.PoolDeployConfig memory _deployConfig, diff --git a/contracts/src/deployers/erc4626/ERC4626HyperdriveCoreDeployer.sol b/contracts/src/deployers/erc4626/ERC4626HyperdriveCoreDeployer.sol index a68a973d9..182f30e10 100644 --- a/contracts/src/deployers/erc4626/ERC4626HyperdriveCoreDeployer.sol +++ b/contracts/src/deployers/erc4626/ERC4626HyperdriveCoreDeployer.sol @@ -16,21 +16,21 @@ contract ERC4626HyperdriveCoreDeployer is IHyperdriveCoreDeployer { /// @notice Deploys a Hyperdrive instance with the given parameters. /// @param _config The configuration of the Hyperdrive pool. /// @param _extraData The extra data that contains the ERC4626 vault. - /// @param target0 The target0 address. - /// @param target1 The target1 address. - /// @param target2 The target2 address. - /// @param target3 The target3 address. - /// @param target4 The target4 address. + /// @param _target0 The target0 address. + /// @param _target1 The target1 address. + /// @param _target2 The target2 address. + /// @param _target3 The target3 address. + /// @param _target4 The target4 address. /// @param _salt The create2 salt used in the deployment. /// @return The address of the newly deployed ERC4626Hyperdrive instance. function deploy( IHyperdrive.PoolConfig memory _config, bytes memory _extraData, - address target0, - address target1, - address target2, - address target3, - address target4, + address _target0, + address _target1, + address _target2, + address _target3, + address _target4, bytes32 _salt ) external returns (address) { address vault = abi.decode(_extraData, (address)); @@ -38,11 +38,11 @@ contract ERC4626HyperdriveCoreDeployer is IHyperdriveCoreDeployer { address( new ERC4626Hyperdrive{ salt: _salt }( _config, - target0, - target1, - target2, - target3, - target4, + _target0, + _target1, + _target2, + _target3, + _target4, IERC4626(vault) ) ) diff --git a/contracts/src/deployers/erc4626/ERC4626Target0Deployer.sol b/contracts/src/deployers/erc4626/ERC4626Target0Deployer.sol index e1747d766..4f89a9805 100644 --- a/contracts/src/deployers/erc4626/ERC4626Target0Deployer.sol +++ b/contracts/src/deployers/erc4626/ERC4626Target0Deployer.sol @@ -17,7 +17,7 @@ contract ERC4626Target0Deployer is IHyperdriveTargetDeployer { /// @param _config The configuration of the Hyperdrive pool. /// @param _extraData The extra data that contains the pool and sweep targets. /// @param _salt The create2 salt used in the deployment. - /// @return The address of the newly deployed ERC4626Target0 Instance. + /// @return The address of the newly deployed ERC4626Target0 instance. function deploy( IHyperdrive.PoolConfig memory _config, bytes memory _extraData, diff --git a/contracts/src/deployers/erc4626/ERC4626Target1Deployer.sol b/contracts/src/deployers/erc4626/ERC4626Target1Deployer.sol index 1a6c1eb09..6fe5dc436 100644 --- a/contracts/src/deployers/erc4626/ERC4626Target1Deployer.sol +++ b/contracts/src/deployers/erc4626/ERC4626Target1Deployer.sol @@ -17,7 +17,7 @@ contract ERC4626Target1Deployer is IHyperdriveTargetDeployer { /// @param _config The configuration of the Hyperdrive pool. /// @param _extraData The extra data that contains the pool and sweep targets. /// @param _salt The create2 salt used in the deployment. - /// @return The address of the newly deployed ERC4626Target1 Instance. + /// @return The address of the newly deployed ERC4626Target1 instance. function deploy( IHyperdrive.PoolConfig memory _config, bytes memory _extraData, diff --git a/contracts/src/deployers/erc4626/ERC4626Target2Deployer.sol b/contracts/src/deployers/erc4626/ERC4626Target2Deployer.sol index a592e1ae7..77bbcbb42 100644 --- a/contracts/src/deployers/erc4626/ERC4626Target2Deployer.sol +++ b/contracts/src/deployers/erc4626/ERC4626Target2Deployer.sol @@ -17,7 +17,7 @@ contract ERC4626Target2Deployer is IHyperdriveTargetDeployer { /// @param _config The configuration of the Hyperdrive pool. /// @param _extraData The extra data that contains the pool and sweep targets. /// @param _salt The create2 salt used in the deployment. - /// @return The address of the newly deployed ERC4626Target2 Instance. + /// @return The address of the newly deployed ERC4626Target2 instance. function deploy( IHyperdrive.PoolConfig memory _config, bytes memory _extraData, diff --git a/contracts/src/deployers/erc4626/ERC4626Target3Deployer.sol b/contracts/src/deployers/erc4626/ERC4626Target3Deployer.sol index 45cbf3b44..40980fa87 100644 --- a/contracts/src/deployers/erc4626/ERC4626Target3Deployer.sol +++ b/contracts/src/deployers/erc4626/ERC4626Target3Deployer.sol @@ -17,7 +17,7 @@ contract ERC4626Target3Deployer is IHyperdriveTargetDeployer { /// @param _config The configuration of the Hyperdrive pool. /// @param _extraData The extra data that contains the pool and sweep targets. /// @param _salt The create2 salt used in the deployment. - /// @return The address of the newly deployed ERC4626Target3 Instance. + /// @return The address of the newly deployed ERC4626Target3 instance. function deploy( IHyperdrive.PoolConfig memory _config, bytes memory _extraData, diff --git a/contracts/src/deployers/erc4626/ERC4626Target4Deployer.sol b/contracts/src/deployers/erc4626/ERC4626Target4Deployer.sol index cbb29a654..87c515c32 100644 --- a/contracts/src/deployers/erc4626/ERC4626Target4Deployer.sol +++ b/contracts/src/deployers/erc4626/ERC4626Target4Deployer.sol @@ -17,7 +17,7 @@ contract ERC4626Target4Deployer is IHyperdriveTargetDeployer { /// @param _config The configuration of the Hyperdrive pool. /// @param _extraData The extra data that contains the pool and sweep targets. /// @param _salt The create2 salt used in the deployment. - /// @return The address of the newly deployed ERC4626Target4 Instance. + /// @return The address of the newly deployed ERC4626Target4 instance. function deploy( IHyperdrive.PoolConfig memory _config, bytes memory _extraData, diff --git a/contracts/src/deployers/steth/StETHHyperdriveCoreDeployer.sol b/contracts/src/deployers/steth/StETHHyperdriveCoreDeployer.sol index 26eb0b534..08ad51255 100644 --- a/contracts/src/deployers/steth/StETHHyperdriveCoreDeployer.sol +++ b/contracts/src/deployers/steth/StETHHyperdriveCoreDeployer.sol @@ -30,7 +30,7 @@ contract StETHHyperdriveCoreDeployer is IHyperdriveCoreDeployer { /// @param target3 The target3 address. /// @param target4 The target4 address. /// @param _salt The create2 salt used in the deployment. - /// @return The address of the newly deployed StETHHyperdrive Instance. + /// @return The address of the newly deployed StETHHyperdrive instance. function deploy( IHyperdrive.PoolConfig memory _config, bytes memory, // unused extra data diff --git a/contracts/src/deployers/steth/StETHTarget0Deployer.sol b/contracts/src/deployers/steth/StETHTarget0Deployer.sol index 08a2d91cd..e6e7b7f8e 100644 --- a/contracts/src/deployers/steth/StETHTarget0Deployer.sol +++ b/contracts/src/deployers/steth/StETHTarget0Deployer.sol @@ -25,7 +25,7 @@ contract StETHTarget0Deployer is IHyperdriveTargetDeployer { /// @notice Deploys a target0 instance with the given parameters. /// @param _config The configuration of the Hyperdrive pool. /// @param _salt The create2 salt used in the deployment. - /// @return The address of the newly deployed StETHTarget0 Instance. + /// @return The address of the newly deployed StETHTarget0 instance. function deploy( IHyperdrive.PoolConfig memory _config, bytes memory, // unused extra data diff --git a/contracts/src/deployers/steth/StETHTarget1Deployer.sol b/contracts/src/deployers/steth/StETHTarget1Deployer.sol index 9270b6a56..5406f2da3 100644 --- a/contracts/src/deployers/steth/StETHTarget1Deployer.sol +++ b/contracts/src/deployers/steth/StETHTarget1Deployer.sol @@ -25,7 +25,7 @@ contract StETHTarget1Deployer is IHyperdriveTargetDeployer { /// @notice Deploys a target1 instance with the given parameters. /// @param _config The configuration of the Hyperdrive pool. /// @param _salt The create2 salt used in the deployment. - /// @return The address of the newly deployed StETHTarget1 Instance. + /// @return The address of the newly deployed StETHTarget1 instance. function deploy( IHyperdrive.PoolConfig memory _config, bytes memory, // unused extra data diff --git a/contracts/src/deployers/steth/StETHTarget2Deployer.sol b/contracts/src/deployers/steth/StETHTarget2Deployer.sol index 46a96b5f8..4a2a1a6ec 100644 --- a/contracts/src/deployers/steth/StETHTarget2Deployer.sol +++ b/contracts/src/deployers/steth/StETHTarget2Deployer.sol @@ -25,7 +25,7 @@ contract StETHTarget2Deployer is IHyperdriveTargetDeployer { /// @notice Deploys a target2 instance with the given parameters. /// @param _config The configuration of the Hyperdrive pool. /// @param _salt The create2 salt used in the deployment. - /// @return The address of the newly deployed StETHTarget2 Instance. + /// @return The address of the newly deployed StETHTarget2 instance. function deploy( IHyperdrive.PoolConfig memory _config, bytes memory, // unused extra data diff --git a/contracts/src/deployers/steth/StETHTarget3Deployer.sol b/contracts/src/deployers/steth/StETHTarget3Deployer.sol index d358339e3..88d37cb6f 100644 --- a/contracts/src/deployers/steth/StETHTarget3Deployer.sol +++ b/contracts/src/deployers/steth/StETHTarget3Deployer.sol @@ -25,7 +25,7 @@ contract StETHTarget3Deployer is IHyperdriveTargetDeployer { /// @notice Deploys a target3 instance with the given parameters. /// @param _config The configuration of the Hyperdrive pool. /// @param _salt The create2 salt used in the deployment. - /// @return The address of the newly deployed StETHTarget3 Instance. + /// @return The address of the newly deployed StETHTarget3 instance. function deploy( IHyperdrive.PoolConfig memory _config, bytes memory, // unused extra data diff --git a/contracts/src/deployers/steth/StETHTarget4Deployer.sol b/contracts/src/deployers/steth/StETHTarget4Deployer.sol index ee41f614a..dec6c4325 100644 --- a/contracts/src/deployers/steth/StETHTarget4Deployer.sol +++ b/contracts/src/deployers/steth/StETHTarget4Deployer.sol @@ -25,7 +25,7 @@ contract StETHTarget4Deployer is IHyperdriveTargetDeployer { /// @notice Deploys a target4 instance with the given parameters. /// @param _config The configuration of the Hyperdrive pool. /// @param _salt The create2 salt used in the deployment. - /// @return The address of the newly deployed StETHTarget4 Instance. + /// @return The address of the newly deployed StETHTarget4 instance. function deploy( IHyperdrive.PoolConfig memory _config, bytes memory, // unused extra data diff --git a/contracts/src/external/Hyperdrive.sol b/contracts/src/external/Hyperdrive.sol index 769a99af2..d0603a385 100644 --- a/contracts/src/external/Hyperdrive.sol +++ b/contracts/src/external/Hyperdrive.sol @@ -4,6 +4,7 @@ pragma solidity 0.8.20; import { HyperdriveTarget0 } from "../external/HyperdriveTarget0.sol"; import { IHyperdrive } from "../interfaces/IHyperdrive.sol"; import { IHyperdriveCore } from "../interfaces/IHyperdriveCore.sol"; +import { IMultiTokenCore } from "../interfaces/IMultiTokenCore.sol"; import { HyperdriveAdmin } from "../internal/HyperdriveAdmin.sol"; import { HyperdriveBase } from "../internal/HyperdriveBase.sol"; import { HyperdriveCheckpoint } from "../internal/HyperdriveCheckpoint.sol"; @@ -167,7 +168,7 @@ abstract contract Hyperdrive is /// Longs /// - /// @notice Opens a long position. + /// @inheritdoc IHyperdriveCore function openLong( uint256, uint256, @@ -177,7 +178,7 @@ abstract contract Hyperdrive is _delegate(target3); } - /// @notice Closes a long position with a specified maturity time. + /// @inheritdoc IHyperdriveCore function closeLong( uint256, uint256, @@ -189,7 +190,7 @@ abstract contract Hyperdrive is /// Shorts /// - /// @notice Opens a short position. + /// @inheritdoc IHyperdriveCore function openShort( uint256, uint256, @@ -199,7 +200,7 @@ abstract contract Hyperdrive is _delegate(target4); } - /// @notice Closes a short position with a specified maturity time. + /// @inheritdoc IHyperdriveCore function closeShort( uint256, uint256, @@ -211,7 +212,7 @@ abstract contract Hyperdrive is /// LPs /// - /// @notice Allows the first LP to initialize the market with a target APR. + /// @inheritdoc IHyperdriveCore function initialize( uint256, uint256, @@ -220,7 +221,7 @@ abstract contract Hyperdrive is _delegate(target1); } - /// @notice Allows LPs to supply liquidity for LP shares. + /// @inheritdoc IHyperdriveCore function addLiquidity( uint256, uint256, @@ -231,7 +232,7 @@ abstract contract Hyperdrive is _delegate(target1); } - /// @notice Allows an LP to burn shares and withdraw from the pool. + /// @inheritdoc IHyperdriveCore function removeLiquidity( uint256, uint256, @@ -240,10 +241,7 @@ abstract contract Hyperdrive is _delegate(target1); } - /// @notice Redeems withdrawal shares by giving the LP a pro-rata amount of - /// the withdrawal pool's proceeds. This function redeems the - /// maximum amount of the specified withdrawal shares given the - /// amount of withdrawal shares ready to withdraw. + /// @inheritdoc IHyperdriveCore function redeemWithdrawalShares( uint256, uint256, @@ -254,45 +252,43 @@ abstract contract Hyperdrive is /// Checkpoints /// - /// @notice Allows anyone to mint a new checkpoint. + /// @inheritdoc IHyperdriveCore function checkpoint(uint256) external { _delegate(target2); } /// Admin /// - /// @notice This function collects the governance fees accrued by the pool. - /// @return proceeds The amount of base collected. + /// @inheritdoc IHyperdriveCore function collectGovernanceFee( IHyperdrive.Options calldata ) external returns (uint256) { _delegate(target0); } - /// @notice Allows an authorized address to pause this contract. + /// @inheritdoc IHyperdriveCore function pause(bool) external { _delegate(target0); } - /// @notice Allows governance to change governance. + /// @inheritdoc IHyperdriveCore function setGovernance(address) external { _delegate(target0); } - /// @notice Allows governance to change the pauser status of an address. + /// @inheritdoc IHyperdriveCore function setPauser(address, bool) external { _delegate(target0); } - /// Token /// + /// MultiToken /// - /// @notice Transfers an amount of assets from the source to the destination. + /// @inheritdoc IMultiTokenCore function transferFrom(uint256, address, address, uint256) external { _delegate(target0); } - /// @notice Permissioned transfer for the bridge to access, only callable by - /// the ERC20 linking bridge. + /// @inheritdoc IMultiTokenCore function transferFromBridge( uint256, address, @@ -303,24 +299,22 @@ abstract contract Hyperdrive is _delegate(target0); } - /// @notice Allows the compatibility linking contract to forward calls to - /// set asset approvals. + /// @inheritdoc IMultiTokenCore function setApprovalBridge(uint256, address, uint256, address) external { _delegate(target0); } - /// @notice Allows a user to approve an operator to use all of their assets. + /// @inheritdoc IMultiTokenCore function setApprovalForAll(address, bool) external { _delegate(target0); } - /// @notice Allows a user to set an approval for an individual asset with - /// specific amount. + /// @inheritdoc IMultiTokenCore function setApproval(uint256, address, uint256) external { _delegate(target0); } - /// @notice Transfers several assets from one account to another + /// @inheritdoc IMultiTokenCore function batchTransferFrom( address, address, @@ -330,8 +324,6 @@ abstract contract Hyperdrive is _delegate(target0); } - /// MultiToken /// - /// @notice Allows a caller who is not the owner of an account to execute the /// functionality of 'approve' for all assets with the owners signature. /// @param owner The owner of the account which is having the new approval set. diff --git a/contracts/src/external/HyperdriveTarget0.sol b/contracts/src/external/HyperdriveTarget0.sol index a97d8556b..c662a076c 100644 --- a/contracts/src/external/HyperdriveTarget0.sol +++ b/contracts/src/external/HyperdriveTarget0.sol @@ -71,8 +71,8 @@ abstract contract HyperdriveTarget0 is /// @notice Transfers an amount of assets from the source to the destination. /// @param tokenID The token identifier. - /// @param from The address who's balance will be reduced. - /// @param to The address who's balance will be increased. + /// @param from The address whose balance will be reduced. + /// @param to The address whose balance will be increased. /// @param amount The amount of token to move. function transferFrom( uint256 tokenID, @@ -87,8 +87,8 @@ abstract contract HyperdriveTarget0 is /// @notice Permissioned transfer for the bridge to access, only callable by /// the ERC20 linking bridge. /// @param tokenID The token identifier. - /// @param from The address who's balance will be reduced. - /// @param to The address who's balance will be increased. + /// @param from The address whose balance will be reduced. + /// @param to The address whose balance will be increased. /// @param amount The amount of token to move. /// @param caller The msg.sender from the bridge. function transferFromBridge( @@ -145,8 +145,8 @@ abstract contract HyperdriveTarget0 is } /// @notice Transfers several assets from one account to another. - /// @param from the source account. - /// @param to the destination account. + /// @param from The source account. + /// @param to The destination account. /// @param ids The array of token ids of the asset to transfer. /// @param values The amount of each token to transfer. function batchTransferFrom( @@ -159,7 +159,8 @@ abstract contract HyperdriveTarget0 is } /// @notice Allows a caller who is not the owner of an account to execute the - /// functionality of 'approve' for all assets with the owners signature. + /// functionality of 'approve' for all assets with the owner's + /// signature. /// @param domainSeparator The EIP712 domain separator of the contract. /// @param permitTypeHash The EIP712 domain separator of the contract. /// @param owner The owner of the account which is having the new approval set. @@ -272,7 +273,7 @@ abstract contract HyperdriveTarget0 is /// @notice Gets info about the pool's reserves and other state that is /// important to evaluate potential trades. - /// @return The PoolInfo struct. + /// @return The pool info. function getPoolInfo() external view returns (IHyperdrive.PoolInfo memory) { uint256 vaultSharePrice = _pricePerVaultShare(); uint256 lpTotalSupply = _totalSupply[AssetId._LP_ASSET_ID] + diff --git a/contracts/src/instances/erc4626/ERC4626Hyperdrive.sol b/contracts/src/instances/erc4626/ERC4626Hyperdrive.sol index fb101b1cd..af89d7827 100644 --- a/contracts/src/instances/erc4626/ERC4626Hyperdrive.sol +++ b/contracts/src/instances/erc4626/ERC4626Hyperdrive.sol @@ -7,7 +7,7 @@ import { Hyperdrive } from "../../external/Hyperdrive.sol"; import { IERC20 } from "../../interfaces/IERC20.sol"; import { IERC4626 } from "../../interfaces/IERC4626.sol"; import { IHyperdrive } from "../../interfaces/IHyperdrive.sol"; -import { IERC4626Hyperdrive } from "../../interfaces/IERC4626Hyperdrive.sol"; +import { IERC4626HyperdriveCore } from "../../interfaces/IERC4626HyperdriveCore.sol"; import { FixedPointMath } from "../../libraries/FixedPointMath.sol"; import { ERC4626Base } from "./ERC4626Base.sol"; @@ -57,7 +57,7 @@ import { ERC4626Base } from "./ERC4626Base.sol"; /// @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. -contract ERC4626Hyperdrive is Hyperdrive, ERC4626Base { +contract ERC4626Hyperdrive is IERC4626HyperdriveCore, Hyperdrive, ERC4626Base { using FixedPointMath for uint256; using SafeERC20 for ERC20; @@ -92,12 +92,7 @@ contract ERC4626Hyperdrive is Hyperdrive, ERC4626Base { ERC20(address(_config.baseToken)).forceApprove(address(_vault), 1); } - /// @notice Some yield sources [eg Morpho] pay rewards directly to this - /// contract but we can't handle distributing them internally so we - /// sweep to the fee collector address to then redistribute to users. - /// @dev WARN: It is unlikely but possible that there is a selector overlap - /// with 'transferFrom'. Any integrating contracts should be checked - /// for that, as it may result in an unexpected call from this address. + /// @inheritdoc IERC4626HyperdriveCore function sweep(IERC20) external { _delegate(target0); } diff --git a/contracts/src/instances/erc4626/ERC4626Target0.sol b/contracts/src/instances/erc4626/ERC4626Target0.sol index cde00b468..be843458f 100644 --- a/contracts/src/instances/erc4626/ERC4626Target0.sol +++ b/contracts/src/instances/erc4626/ERC4626Target0.sol @@ -30,13 +30,16 @@ contract ERC4626Target0 is HyperdriveTarget0, ERC4626Base { /// Extras /// - /// @notice Some yield sources [eg Morpho] pay rewards directly to this - /// contract but we can't handle distributing them internally so we - /// sweep to the fee collector address to then redistribute to users. + /// @notice Transfers the contract's balance of a target token to the fee + /// collector address. + /// @dev Some yield sources (e.g. Morpho) pay rewards directly to this + /// contract, but we can't handle distributing them internally. With + /// this in mind, we sweep the tokens to the fee collector address to + /// then redistribute to users. /// @dev WARN: It is unlikely but possible that there is a selector overlap /// with 'transferFrom'. Any integrating contracts should be checked /// for that, as it may result in an unexpected call from this address. - /// @param _target The token to sweep. + /// @param _target The target token to sweep. function sweep(IERC20 _target) external { // Ensure that the sender is the fee collector or a pauser. if (msg.sender != _feeCollector && !_pausers[msg.sender]) { @@ -71,8 +74,9 @@ contract ERC4626Target0 is HyperdriveTarget0, ERC4626Base { /// Getters /// - /// @notice Gets the ERC4626 compatible vault. - /// @return The ERC4626 compatible vault. + /// @notice Gets the ERC4626 compatible vault used as this pool's yield + /// source. + /// @return The ERC4626 compatible yield source. function vault() external view returns (IERC4626) { _revert(abi.encode(_vault)); } diff --git a/contracts/src/instances/steth/StETHHyperdrive.sol b/contracts/src/instances/steth/StETHHyperdrive.sol index 3e6fabb7a..b39733c8f 100644 --- a/contracts/src/instances/steth/StETHHyperdrive.sol +++ b/contracts/src/instances/steth/StETHHyperdrive.sol @@ -5,6 +5,7 @@ import { Hyperdrive } from "../../external/Hyperdrive.sol"; import { IHyperdrive } from "../../interfaces/IHyperdrive.sol"; import { IERC20 } from "../../interfaces/IERC20.sol"; import { ILido } from "../../interfaces/ILido.sol"; +import { IStETHHyperdriveCore } from "../../interfaces/IStETHHyperdriveCore.sol"; import { StETHBase } from "./StETHBase.sol"; /// ______ __ _________ _____ @@ -53,7 +54,7 @@ import { StETHBase } from "./StETHBase.sol"; /// @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. -contract StETHHyperdrive is Hyperdrive, StETHBase { +contract StETHHyperdrive is IStETHHyperdriveCore, Hyperdrive, StETHBase { address constant ETH = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE; /// @notice Instantiates Hyperdrive with StETH as the yield source. @@ -82,12 +83,7 @@ contract StETHHyperdrive is Hyperdrive, StETHBase { } } - /// @notice Some yield sources [eg Morpho] pay rewards directly to this - /// contract but we can't handle distributing them internally so we - /// sweep to the fee collector address to then redistribute to users. - /// @dev WARN: It is unlikely but possible that there is a selector overlap - /// with 'transferFrom'. Any integrating contracts should be checked - /// for that, as it may result in an unexpected call from this address. + /// @inheritdoc IStETHHyperdriveCore function sweep(IERC20) external { _delegate(target0); } diff --git a/contracts/src/instances/steth/StETHTarget0.sol b/contracts/src/instances/steth/StETHTarget0.sol index 7ce908c30..e9e9b448f 100644 --- a/contracts/src/instances/steth/StETHTarget0.sol +++ b/contracts/src/instances/steth/StETHTarget0.sol @@ -30,13 +30,12 @@ contract StETHTarget0 is HyperdriveTarget0, StETHBase { /// Extras /// - /// @notice Some yield sources [eg Morpho] pay rewards directly to this - /// contract but we can't handle distributing them internally so we - /// sweep to the fee collector address to then redistribute to users. + /// @notice Transfers the contract's balance of a target token to the fee + /// collector address. /// @dev WARN: It is unlikely but possible that there is a selector overlap /// with 'transferFrom'. Any integrating contracts should be checked /// for that, as it may result in an unexpected call from this address. - /// @param _target The token to sweep. + /// @param _target The target token to sweep. function sweep(IERC20 _target) external { // Ensure that the sender is the fee collector or a pauser. if (msg.sender != _feeCollector && !_pausers[msg.sender]) { diff --git a/contracts/src/interfaces/IERC20.sol b/contracts/src/interfaces/IERC20.sol index 11f622639..4d7323518 100644 --- a/contracts/src/interfaces/IERC20.sol +++ b/contracts/src/interfaces/IERC20.sol @@ -2,36 +2,67 @@ pragma solidity 0.8.20; interface IERC20 { + /// @notice Emitted when tokens are transferred from one account to another. event Transfer(address indexed from, address indexed to, uint256 value); + /// @notice Emitted when an owner changes the approval for a spender. event Approval( address indexed owner, address indexed spender, uint256 value ); + /// @notice Updates the allowance of a spender on behalf of the sender. + /// @param spender The account with the allowance. + /// @param amount The new allowance of the spender. + /// @return A flag indicating whether or not the approval succeeded. + function approve(address spender, uint256 amount) external returns (bool); + + /// @notice Transfers tokens from the sender's account to another account. + /// @param to The recipient of the tokens. + /// @param amount The amount of tokens that will be transferred. + /// @return A flag indicating whether or not the transfer succeeded. + function transfer(address to, uint256 amount) external returns (bool); + + /// @notice Transfers tokens from an owner to a recipient. This draws from + /// the sender's allowance. + /// @param from The owner of the tokens. + /// @param to The recipient of the tokens. + /// @param amount The amount of tokens that will be transferred. + /// @return A flag indicating whether or not the transfer succeeded. + function transferFrom( + address from, + address to, + uint256 amount + ) external returns (bool); + + /// @notice Gets the token's name. + /// @return The token's name. function name() external view returns (string memory); + /// @notice Gets the token's symbol. + /// @return The token's symbol. function symbol() external view returns (string memory); + /// @notice Gets the token's decimals. + /// @return The token's decimals. function decimals() external view returns (uint8); + /// @notice Gets the token's total supply. + /// @return The token's total supply. function totalSupply() external view returns (uint256); - function balanceOf(address account) external view returns (uint256); - - function transfer(address to, uint256 amount) external returns (bool); - + /// @notice Gets the allowance of a spender for an owner. + /// @param owner The owner of the tokens. + /// @param spender The spender of the tokens. + /// @return The allowance of the spender for the owner. function allowance( address owner, address spender ) external view returns (uint256); - function approve(address spender, uint256 amount) external returns (bool); - - function transferFrom( - address from, - address to, - uint256 amount - ) external returns (bool); + /// @notice Gets the balance of an account. + /// @param account The owner of the tokens. + /// @return The account's balance. + function balanceOf(address account) external view returns (uint256); } diff --git a/contracts/src/interfaces/IERC20Forwarder.sol b/contracts/src/interfaces/IERC20Forwarder.sol index f52c338c2..07c2739fb 100644 --- a/contracts/src/interfaces/IERC20Forwarder.sol +++ b/contracts/src/interfaces/IERC20Forwarder.sol @@ -7,14 +7,37 @@ import { IMultiToken } from "./IMultiToken.sol"; interface IERC20Forwarder is IERC20 { /// Errors /// + /// @notice Thrown when a permit signature is submitted after its deadline + /// has expired. error ExpiredDeadline(); + /// @notice Thrown when a permit signature doesn't recover to the owner's + /// address. error InvalidSignature(); + /// @notice Thrown when a permit signature recovers to the zero address. error RestrictedZeroAddress(); /// Functions /// + /// @notice This function allows a caller who is not the owner of an account + /// to execute the functionality of 'approve' with the owner's + /// signature. + /// @dev The signature for this function follows EIP712 standard and should + /// be generated with the eth_signTypedData JSON RPC call instead of + /// the eth_sign JSON RPC call. If using out of date parity signing + /// libraries the v component may need to be adjusted. Also it is very + /// rare but possible for v to be other values. Those values are not + /// supported. + /// @param owner The owner of the account which is having the new approval set. + /// @param spender The address which will be allowed to spend owner's tokens. + /// @param value The new allowance value. + /// @param deadline The timestamp which the signature must be submitted by + /// to be valid. + /// @param v Extra ECDSA data which allows public key recovery from + /// signature assumed to be 27 or 28. + /// @param r The r component of the ECDSA signature. + /// @param s The s component of the ECDSA signature. function permit( address owner, address spender, @@ -25,15 +48,26 @@ interface IERC20Forwarder is IERC20 { bytes32 s ) external; + /// @notice Gets a user's nonce for permit. + /// @param user The user's address. + /// @return The nonce. function nonces(address user) external view returns (uint256); + /// @notice Gets the target MultiToken of this forwarder. + /// @return The target MultiToken. function token() external view returns (IMultiToken); + /// @notice Gets the target token ID of this forwarder. + /// @return The target token ID. function tokenId() external view returns (uint256); + /// @notice The EIP712 domain separator for this contract. + /// @return The domain separator. // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); + /// @notice The EIP712 typehash for the permit struct used by this contract. + /// @return The permit typehash. // solhint-disable-next-line func-name-mixedcase function PERMIT_TYPEHASH() external view returns (bytes32); } diff --git a/contracts/src/interfaces/IERC20ForwarderFactory.sol b/contracts/src/interfaces/IERC20ForwarderFactory.sol index 0348e5a35..bd9f0b6f8 100644 --- a/contracts/src/interfaces/IERC20ForwarderFactory.sol +++ b/contracts/src/interfaces/IERC20ForwarderFactory.sol @@ -7,22 +7,38 @@ import { IMultiToken } from "./IMultiToken.sol"; interface IERC20ForwarderFactory { /// Errors /// + /// @notice Thrown when a forwarder is deployed to an unexpected address. error InvalidForwarderAddress(); /// Functions /// + /// @notice Uses create2 to deploy a forwarder at a predictable address as + /// part of our ERC20 multitoken implementation. + /// @param _token The MultiToken targeted by this factory. + /// @param _tokenId The sub-token ID targeted by this factory. + /// @return Returns the address of the deployed forwarder. function create( IMultiToken _token, uint256 _tokenId ) external returns (IERC20Forwarder); + /// @notice Gets the MultiToken and token ID that should be targeted by the + /// calling forwarder. + /// @return The target MultiToken. + /// @return The target token ID. function getDeployDetails() external view returns (IMultiToken, uint256); + /// @notice Helper to calculate expected forwarder contract addresses. + /// @param _token The target MultiToken of the forwarder. + /// @param _tokenId The target token ID of the forwarder. + /// @return The expected address of the forwarder. function getForwarder( IMultiToken _token, uint256 _tokenId ) external view returns (address); + /// @notice Gets the hash of the bytecode of the ERC20 forwarder contract. + /// @return The hash of the bytecode of the ERC20 forwarder contract. // solhint-disable-next-line func-name-mixedcase function ERC20LINK_HASH() external pure returns (bytes32); } diff --git a/contracts/src/interfaces/IERC4626HyperdriveCore.sol b/contracts/src/interfaces/IERC4626HyperdriveCore.sol index 2adf0ee8c..b7702c199 100644 --- a/contracts/src/interfaces/IERC4626HyperdriveCore.sol +++ b/contracts/src/interfaces/IERC4626HyperdriveCore.sol @@ -5,5 +5,15 @@ import { IERC20 } from "./IERC20.sol"; import { IHyperdriveCore } from "./IHyperdriveCore.sol"; interface IERC4626HyperdriveCore is IHyperdriveCore { + /// @notice Transfers the contract's balance of a target token to the fee + /// collector address. + /// @dev Some yield sources (e.g. Morpho) pay rewards directly to this + /// contract, but we can't handle distributing them internally. With + /// this in mind, we sweep the tokens to the fee collector address to + /// then redistribute to users. + /// @dev WARN: It is unlikely but possible that there is a selector overlap + /// with 'transferFrom'. Any integrating contracts should be checked + /// for that, as it may result in an unexpected call from this address. + /// @param _target The target token to sweep. function sweep(IERC20 _target) external; } diff --git a/contracts/src/interfaces/IERC4626HyperdriveRead.sol b/contracts/src/interfaces/IERC4626HyperdriveRead.sol index db8d98784..d8a9d65a6 100644 --- a/contracts/src/interfaces/IERC4626HyperdriveRead.sol +++ b/contracts/src/interfaces/IERC4626HyperdriveRead.sol @@ -5,5 +5,8 @@ import { IERC4626 } from "./IERC4626.sol"; import { IHyperdriveRead } from "./IHyperdriveRead.sol"; interface IERC4626HyperdriveRead is IHyperdriveRead { + /// @notice Gets the ERC4626 compatible vault used as this pool's yield + /// source. + /// @return The ERC4626 compatible yield source. function vault() external view returns (IERC4626); } diff --git a/contracts/src/interfaces/IHyperdrive.sol b/contracts/src/interfaces/IHyperdrive.sol index 43d6bd82d..cf9d1be1a 100644 --- a/contracts/src/interfaces/IHyperdrive.sol +++ b/contracts/src/interfaces/IHyperdrive.sol @@ -339,13 +339,23 @@ interface IHyperdrive is /// Getters /// + /// @notice Gets the target0 address. + /// @return The target0 address. function target0() external view returns (address); + /// @notice Gets the target1 address. + /// @return The target1 address. function target1() external view returns (address); + /// @notice Gets the target2 address. + /// @return The target2 address. function target2() external view returns (address); + /// @notice Gets the target3 address. + /// @return The target3 address. function target3() external view returns (address); + /// @notice Gets the target4 address. + /// @return The target4 address. function target4() external view returns (address); } diff --git a/contracts/src/interfaces/IHyperdriveCore.sol b/contracts/src/interfaces/IHyperdriveCore.sol index ad30ca5fc..b53131b54 100644 --- a/contracts/src/interfaces/IHyperdriveCore.sol +++ b/contracts/src/interfaces/IHyperdriveCore.sol @@ -7,13 +7,29 @@ import { IMultiTokenCore } from "./IMultiTokenCore.sol"; interface IHyperdriveCore is IMultiTokenCore { /// Longs /// + /// @notice Opens a long position. + /// @param _amount The amount to open a long with. + /// @param _minOutput The minimum number of bonds to receive. + /// @param _minVaultSharePrice The minimum vault share price at which to + /// open the long. This allows traders to protect themselves from + /// opening a long in a checkpoint where negative interest has + /// accrued. + /// @param _options The options that configure how the trade is settled. + /// @return maturityTime The maturity time of the bonds. + /// @return bondProceeds The amount of bonds the user received function openLong( - uint256 _baseAmount, + uint256 _amount, uint256 _minOutput, uint256 _minVaultSharePrice, IHyperdrive.Options calldata _options ) external payable returns (uint256 maturityTime, uint256 bondProceeds); + /// @notice Closes a long position with a specified maturity time. + /// @param _maturityTime The maturity time of the short. + /// @param _bondAmount The amount of longs to close. + /// @param _minOutput The minimum amount of base the trader will accept. + /// @param _options The options that configure how the trade is settled. + /// @return The amount of underlying the user receives. function closeLong( uint256 _maturityTime, uint256 _bondAmount, @@ -23,6 +39,15 @@ interface IHyperdriveCore is IMultiTokenCore { /// Shorts /// + /// @notice Opens a short position. + /// @param _bondAmount The amount of bonds to short. + /// @param _maxDeposit The most the user expects to deposit for this trade. + /// @param _minVaultSharePrice The minimum vault share price at which to open + /// the short. This allows traders to protect themselves from opening + /// a short in a checkpoint where negative interest has accrued. + /// @param _options The options that configure how the trade is settled. + /// @return maturityTime The maturity time of the short. + /// @return traderDeposit The amount the user deposited for this trade. function openShort( uint256 _bondAmount, uint256 _maxDeposit, @@ -30,6 +55,12 @@ interface IHyperdriveCore is IMultiTokenCore { IHyperdrive.Options calldata _options ) external payable returns (uint256 maturityTime, uint256 traderDeposit); + /// @notice Closes a short position with a specified maturity time. + /// @param _maturityTime The maturity time of the short. + /// @param _bondAmount The amount of shorts to close. + /// @param _minOutput The minimum output of this trade. + /// @param _options The options that configure how the trade is settled. + /// @return The amount of base tokens produced by closing this short. function closeShort( uint256 _maturityTime, uint256 _bondAmount, @@ -39,12 +70,28 @@ interface IHyperdriveCore is IMultiTokenCore { /// LPs /// + /// @notice Allows the first LP to initialize the market with a target APR. + /// @param _contribution The amount to supply. + /// @param _apr The target APR. + /// @param _options The options that configure how the operation is settled. + /// @return lpShares The initial number of LP shares created. function initialize( uint256 _contribution, uint256 _apr, IHyperdrive.Options calldata _options ) external payable returns (uint256 lpShares); + /// @notice Allows LPs to supply liquidity for LP shares. + /// @param _contribution The amount to supply. + /// @param _minLpSharePrice The minimum LP share price the LP is willing + /// to accept for their shares. LPs incur negative slippage when + /// adding liquidity if there is a net curve position in the market, + /// so this allows LPs to protect themselves from high levels of + /// slippage. + /// @param _minApr The minimum APR at which the LP is willing to supply. + /// @param _maxApr The maximum APR at which the LP is willing to supply. + /// @param _options The options that configure how the operation is settled. + /// @return lpShares The number of LP tokens created. function addLiquidity( uint256 _contribution, uint256 _minLpSharePrice, @@ -53,31 +100,66 @@ interface IHyperdriveCore is IMultiTokenCore { IHyperdrive.Options calldata _options ) external payable returns (uint256 lpShares); + /// @notice Allows an LP to burn shares and withdraw from the pool. + /// @param _lpShares The LP shares to burn. + /// @param _minOutputPerShare The minimum amount of base per LP share that + /// was redeemed. + /// @param _options The options that configure how the operation is settled. + /// @return proceeds The amount the LP removing liquidity receives. The + /// LP receives a proportional amount of the pool's idle capital + /// @return withdrawalShares The base that the LP receives buys out some of + /// their LP shares, but it may not be sufficient to fully buy the + /// LP out. In this case, the LP receives withdrawal shares equal + /// in value to the present value they are owed. As idle capital + /// becomes available, the pool will buy back these shares. function removeLiquidity( - uint256 _shares, - uint256 _minOutput, + uint256 _lpShares, + uint256 _minOutputPerShare, IHyperdrive.Options calldata _options - ) external returns (uint256 baseProceeds, uint256 withdrawalShares); - + ) external returns (uint256 proceeds, uint256 withdrawalShares); + + /// @notice Redeems withdrawal shares by giving the LP a pro-rata amount of the + /// withdrawal pool's proceeds. This function redeems the maximum + /// amount of the specified withdrawal shares given the amount of + /// withdrawal shares ready to withdraw. + /// @param _withdrawalShares The withdrawal shares to redeem. + /// @param _minOutputPerShare The minimum amount of base the LP expects to + /// receive for each withdrawal share that is burned. + /// @param _options The options that configure how the operation is settled. + /// @return proceeds The amount the LP received. + /// @return withdrawalSharesRedeemed The amount of withdrawal shares that + /// were redeemed. function redeemWithdrawalShares( - uint256 _shares, - uint256 _minOutput, + uint256 _withdrawalShares, + uint256 _minOutputPerShare, IHyperdrive.Options calldata _options - ) external returns (uint256 proceeds, uint256 sharesRedeemed); + ) external returns (uint256 proceeds, uint256 withdrawalSharesRedeemed); /// Checkpoints /// + /// @notice Attempts to mint a checkpoint with the specified checkpoint time. + /// @param _checkpointTime The time of the checkpoint to create. function checkpoint(uint256 _checkpointTime) external; /// Admin /// + /// @notice This function collects the governance fees accrued by the pool. + /// @param _options The options that configure how the fees are settled. + /// @return proceeds The amount collected in units specified by _options. function collectGovernanceFee( IHyperdrive.Options calldata _options ) external returns (uint256 proceeds); + /// @notice Allows an authorized address to pause this contract. + /// @param _status True to pause all deposits and false to unpause them. function pause(bool _status) external; + /// @notice Allows governance to transfer the governance role. + /// @param _who The new governance address. function setGovernance(address _who) external; + /// @notice Allows governance to change the pauser status of an address. + /// @param who The address to change. + /// @param status The new pauser status. function setPauser(address who, bool status) external; } diff --git a/contracts/src/interfaces/IHyperdriveCoreDeployer.sol b/contracts/src/interfaces/IHyperdriveCoreDeployer.sol index f0b8c62b2..4d2fbce40 100644 --- a/contracts/src/interfaces/IHyperdriveCoreDeployer.sol +++ b/contracts/src/interfaces/IHyperdriveCoreDeployer.sol @@ -4,6 +4,16 @@ pragma solidity 0.8.20; import { IHyperdrive } from "./IHyperdrive.sol"; interface IHyperdriveCoreDeployer { + /// @notice Deploys a Hyperdrive instance with the given parameters. + /// @param _config The configuration of the Hyperdrive pool. + /// @param _extraData The extra data containing implementation specific data. + /// @param _target0 The target0 address. + /// @param _target1 The target1 address. + /// @param _target2 The target2 address. + /// @param _target3 The target3 address. + /// @param _target4 The target4 address. + /// @param _salt The create2 salt used in the deployment. + /// @return The address of the newly deployed Hyperdrive instance. function deploy( IHyperdrive.PoolConfig memory _config, bytes memory _extraData, diff --git a/contracts/src/interfaces/IHyperdriveDeployerCoordinator.sol b/contracts/src/interfaces/IHyperdriveDeployerCoordinator.sol index caa9e3db1..cb17fc2e3 100644 --- a/contracts/src/interfaces/IHyperdriveDeployerCoordinator.sol +++ b/contracts/src/interfaces/IHyperdriveDeployerCoordinator.sol @@ -62,16 +62,31 @@ interface IHyperdriveDeployerCoordinator { /// Functions /// + /// @notice Deploys a Hyperdrive instance with the given parameters. + /// @param _deploymentId The ID of the deployment. + /// @param _deployConfig The deploy configuration of the Hyperdrive pool. + /// @param _extraData The extra data that contains the pool and sweep targets. + /// @param _salt The create2 salt used to deploy Hyperdrive. + /// @return The address of the newly deployed Hyperdrive instance. function deploy( bytes32 _deploymentId, - IHyperdrive.PoolDeployConfig memory _config, + IHyperdrive.PoolDeployConfig memory _deployConfig, bytes memory _extraData, bytes32 _salt ) external returns (address); + /// @notice Deploys a Hyperdrive target instance with the given parameters. + /// @dev As a convention, target0 must be deployed first. After this, the + /// targets can be deployed in any order. + /// @param _deploymentId The ID of the deployment. + /// @param _deployConfig The deploy configuration of the Hyperdrive pool. + /// @param _extraData The extra data that contains the pool and sweep targets. + /// @param _targetIndex The index of the target to deploy. + /// @param _salt The create2 salt used to deploy the target. + /// @return target The address of the newly deployed target instance. function deployTarget( bytes32 _deploymentId, - IHyperdrive.PoolDeployConfig memory _config, + IHyperdrive.PoolDeployConfig memory _deployConfig, bytes memory _extraData, uint256 _targetIndex, bytes32 _salt diff --git a/contracts/src/interfaces/IHyperdriveEvents.sol b/contracts/src/interfaces/IHyperdriveEvents.sol index e4bd2d1ff..7aabc4e33 100644 --- a/contracts/src/interfaces/IHyperdriveEvents.sol +++ b/contracts/src/interfaces/IHyperdriveEvents.sol @@ -4,6 +4,7 @@ pragma solidity 0.8.20; import { IMultiTokenEvents } from "./IMultiTokenEvents.sol"; interface IHyperdriveEvents is IMultiTokenEvents { + /// @notice Emitted when the Hyperdrive pool is initialized. event Initialize( address indexed provider, uint256 lpAmount, @@ -12,6 +13,7 @@ interface IHyperdriveEvents is IMultiTokenEvents { uint256 apr ); + /// @notice Emitted when an LP adds liquidity to the Hyperdrive pool. event AddLiquidity( address indexed provider, uint256 lpAmount, @@ -20,6 +22,7 @@ interface IHyperdriveEvents is IMultiTokenEvents { uint256 lpSharePrice ); + /// @notice Emitted when an LP removes liquidity from the Hyperdrive pool. event RemoveLiquidity( address indexed provider, uint256 lpAmount, @@ -29,6 +32,7 @@ interface IHyperdriveEvents is IMultiTokenEvents { uint256 lpSharePrice ); + /// @notice Emitted when an LP redeems withdrawal shares. event RedeemWithdrawalShares( address indexed provider, uint256 withdrawalShareAmount, @@ -36,6 +40,7 @@ interface IHyperdriveEvents is IMultiTokenEvents { uint256 vaultSharePrice ); + /// @notice Emitted when a long position is opened. event OpenLong( address indexed trader, uint256 indexed assetId, @@ -45,6 +50,7 @@ interface IHyperdriveEvents is IMultiTokenEvents { uint256 bondAmount ); + /// @notice Emitted when a short position is opened. event OpenShort( address indexed trader, uint256 indexed assetId, @@ -54,6 +60,7 @@ interface IHyperdriveEvents is IMultiTokenEvents { uint256 bondAmount ); + /// @notice Emitted when a long position is closed. event CloseLong( address indexed trader, uint256 indexed assetId, @@ -63,6 +70,7 @@ interface IHyperdriveEvents is IMultiTokenEvents { uint256 bondAmount ); + /// @notice Emitted when a short position is closed. event CloseShort( address indexed trader, uint256 indexed assetId, @@ -72,6 +80,7 @@ interface IHyperdriveEvents is IMultiTokenEvents { uint256 bondAmount ); + /// @notice Emitted when a checkpoint is created. event CreateCheckpoint( uint256 indexed checkpointTime, uint256 vaultSharePrice, @@ -80,11 +89,15 @@ interface IHyperdriveEvents is IMultiTokenEvents { uint256 lpSharePrice ); + /// @notice Emitted when governance fees are collected. event CollectGovernanceFee(address indexed collector, uint256 fees); + /// @notice Emitted when the governance address is updated. event GovernanceUpdated(address indexed newGovernance); + /// @notice Emitted when a pauser is updated. event PauserUpdated(address indexed newPauser); + /// @notice Emitted when the pause status is updated. event PauseStatusUpdated(bool isPaused); } diff --git a/contracts/src/interfaces/IHyperdriveFactory.sol b/contracts/src/interfaces/IHyperdriveFactory.sol index c8a227104..15e1d0e73 100644 --- a/contracts/src/interfaces/IHyperdriveFactory.sol +++ b/contracts/src/interfaces/IHyperdriveFactory.sol @@ -6,6 +6,7 @@ import { IHyperdrive } from "./IHyperdrive.sol"; interface IHyperdriveFactory { /// Events /// + /// @notice Emitted when a Hyperdrive pool is deployed. event Deployed( address indexed deployerCoordinator, address hyperdrive, @@ -13,97 +14,189 @@ interface IHyperdriveFactory { bytes extraData ); + /// @notice Emitted when a deployer coordinator is added. event DeployerCoordinatorAdded(address indexed deployerCoordinator); + /// @notice Emitted when a deployer coordinator is removed. event DeployerCoordinatorRemoved(address indexed deployerCoordinator); + /// @notice Emitted when the list of default pausers is updated. event DefaultPausersUpdated(address[] newDefaultPausers); + /// @notice Emitted when the fee collector used in new deployments is updated. event FeeCollectorUpdated(address indexed newFeeCollector); + /// @notice Emitted when the factory's governance is updated. event GovernanceUpdated(address indexed governance); + /// @notice Emitted when the governance address used in new deployments is + /// updated. event HyperdriveGovernanceUpdated(address indexed hyperdriveGovernance); - event ImplementationUpdated(address indexed newDeployer); - + /// @notice Emitted when the linker factory used in new deployments is + /// updated. event LinkerFactoryUpdated(address indexed newLinkerFactory); + /// @notice Emitted when the linker code hash used in new deployments is + /// updated. event LinkerCodeHashUpdated(bytes32 indexed newLinkerCodeHash); + /// @notice Emitted when the checkpoint duration resolution is updated. event CheckpointDurationResolutionUpdated( uint256 newCheckpointDurationResolution ); + /// @notice Emitted when the maximum checkpoint duration is updated. event MaxCheckpointDurationUpdated(uint256 newMaxCheckpointDuration); + /// @notice Emitted when the minimum checkpoint duration is updated. event MinCheckpointDurationUpdated(uint256 newMinCheckpointDuration); + /// @notice Emitted when the maximum position duration is updated. event MaxPositionDurationUpdated(uint256 newMaxPositionDuration); + /// @notice Emitted when the minimum position duration is updated. event MinPositionDurationUpdated(uint256 newMinPositionDuration); + /// @notice Emitted when the maximum fixed APR is updated. event MaxFixedAPRUpdated(uint256 newMaxFixedAPR); + /// @notice Emitted when the minimum fixed APR is updated. event MinFixedAPRUpdated(uint256 newMinFixedAPR); + /// @notice Emitted when the maximum time stretch APR is updated. event MaxTimeStretchAPRUpdated(uint256 newMaxTimeStretchAPR); + /// @notice Emitted when the minimum time stretch APR is updated. event MinTimeStretchAPRUpdated(uint256 newMinTimeStretchAPR); + /// @notice Emitted when the maximum fees are updated. event MaxFeesUpdated(IHyperdrive.Fees newMaxFees); + /// @notice Emitted when the minimum fees are updated. event MinFeesUpdated(IHyperdrive.Fees newMinFees); /// Errors /// + /// @notice Thrown when governance attempts to add a deployer coordinator + /// that has already been added. error DeployerCoordinatorAlreadyAdded(); + /// @notice Thrown when governance attempts to remove a deployer coordinator + /// that was never added. error DeployerCoordinatorNotAdded(); + /// @notice Thrown when governance attempts to remove a deployer coordinator + /// but specifies the wrong index within the list of deployer + /// coordinators. error DeployerCoordinatorIndexMismatch(); + /// @notice Thrown when the ending index of a range is larger than the + /// underlying list. error EndIndexTooLarge(); + /// @notice Thrown when the checkpoint duration supplied to `deployTarget` + /// or `deployAndInitialize` isn't a multiple of the checkpoint + /// duration resolution or isn't within the range specified by the + /// minimum and maximum checkpoint durations. error InvalidCheckpointDuration(); + /// @notice Thrown when governance attempts to set the checkpoint duration + /// resolution to a value that doesn't evenly divide the minimum + /// checkpoint duration, maximum checkpoint duration, minimum + /// position duration, or maximum position duration. error InvalidCheckpointDurationResolution(); + /// @notice Thrown when the deploy configuration passed to + /// `deployAndInitialize` has fields set that will be overridden by + /// governance. error InvalidDeployConfig(); + /// @notice Thrown when the deployer coordinator passed to + /// `deployAndInitialize` hasn't been added to the factory. error InvalidDeployerCoordinator(); + /// @notice Thrown when the fee parameters passed to `deployAndInitialize` + /// aren't within the range specified by the minimum and maximum + /// fees. error InvalidFees(); + /// @notice Thrown when the starting index of a range is larger than the + /// ending index. error InvalidIndexes(); + /// @notice Thrown when governance attempts to set one of the maximum fee + /// parameters to a smaller value than the corresponding minimum fee + /// parameter. error InvalidMaxFees(); + /// @notice Thrown when governance attempts to set one of the minimum fee + /// parameters to a larger value than the corresponding maximum fee + /// parameter. error InvalidMinFees(); + /// @notice Thrown when governance attempts to set the maximum checkpoint + /// duration to a value that isn't a multiple of the checkpoint + /// duration resolution or is smaller than the minimum checkpoint + /// duration. error InvalidMaxCheckpointDuration(); + /// @notice Thrown when governance attempts to set the minimum checkpoint + /// duration to a value that isn't a multiple of the checkpoint + /// duration resolution or is larger than the maximum checkpoint + /// duration. error InvalidMinCheckpointDuration(); + /// @notice Thrown when governance attempts to set the maximum position + /// duration to a value that isn't a multiple of the checkpoint + /// duration resolution or is smaller than the minimum position + /// duration. error InvalidMaxPositionDuration(); + /// @notice Thrown when governance attempts to set the minimum position + /// duration to a value that isn't a multiple of the checkpoint + /// duration resolution or is larger than the maximum position + /// duration. error InvalidMinPositionDuration(); + /// @notice Thrown when the position duration passed to `deployAndInitialize` + /// doesn't fall within the range specified by the minimum and + /// maximum position durations. error InvalidPositionDuration(); + /// @notice Thrown when governance attempts to set the maximum fixed APR to + /// a value that is smaller than the minimum fixed APR. error InvalidMaxFixedAPR(); + /// @notice Thrown when governance attempts to set the minimum fixed APR to + /// a value that is larger than the maximum fixed APR. error InvalidMinFixedAPR(); + /// @notice Thrown when the fixed APR passed to `deployAndInitialize` isn't + /// within the range specified by the minimum and maximum fixed + /// APRs. error InvalidFixedAPR(); + /// @notice Thrown when governance attempts to set the maximum time stretch + /// APR to a value that is smaller than the minimum time stretch + /// APR. error InvalidMaxTimeStretchAPR(); + /// @notice Thrown when governance attempts to set the minimum time stretch + /// APR to a value that is larger than the maximum time stretch + /// APR. error InvalidMinTimeStretchAPR(); + /// @notice Thrown when a time stretch APR is passed to `deployAndInitialize` + /// that isn't within the range specified by the minimum and maximum + /// time stretch APRs or doesn't satisfy the lower and upper safe + /// bounds implied by the fixed APR. error InvalidTimeStretchAPR(); + /// @notice Thrown when an ether transfer fails. error TransferFailed(); + /// @notice Thrown when an unauthorized caller attempts to update one of the + /// governance administered parameters. error Unauthorized(); } diff --git a/contracts/src/interfaces/IHyperdriveGovernedRegistry.sol b/contracts/src/interfaces/IHyperdriveGovernedRegistry.sol index 6f9573e55..ba737b141 100644 --- a/contracts/src/interfaces/IHyperdriveGovernedRegistry.sol +++ b/contracts/src/interfaces/IHyperdriveGovernedRegistry.sol @@ -15,9 +15,10 @@ interface IHyperdriveGovernedRegistry { /// @param _governance The new governance address. function updateGovernance(address _governance) external; - /// @notice Allows governance set arbitrary info for a hyperdrive instance. - /// @param _hyperdriveInstance The hyperdrive instance address. - /// @param _data The uint256 value to be set to convey information about the instance. + /// @notice Allows governance set arbitrary info for a Hyperdrive instance. + /// @param _hyperdriveInstance The Hyperdrive instance address. + /// @param _data The uint256 value to be set to convey information about the + /// instance. function setHyperdriveInfo( address _hyperdriveInstance, uint256 _data diff --git a/contracts/src/interfaces/IHyperdriveRead.sol b/contracts/src/interfaces/IHyperdriveRead.sol index 8d0064443..2812b796a 100644 --- a/contracts/src/interfaces/IHyperdriveRead.sol +++ b/contracts/src/interfaces/IHyperdriveRead.sol @@ -5,37 +5,67 @@ import { IHyperdrive } from "./IHyperdrive.sol"; import { IMultiTokenRead } from "./IMultiTokenRead.sol"; interface IHyperdriveRead is IMultiTokenRead { + /// @notice Gets the Hyperdrive pool's base token. + /// @return The base token. function baseToken() external view returns (address); + /// @notice Gets one of the pool's checkpoints. + /// @param _checkpointTime The checkpoint time. + /// @return The checkpoint. function getCheckpoint( uint256 _checkpointTime ) external view returns (IHyperdrive.Checkpoint memory); + /// @notice Gets the pool's exposure from a checkpoint. This is the number + /// of non-netted longs in the checkpoint. + /// @param _checkpointTime The checkpoint time. + /// @return The checkpoint exposure. function getCheckpointExposure( uint256 _checkpointTime ) external view returns (int256); - function getWithdrawPool() + /// @notice Gets the pool's state relating to the Hyperdrive market. + /// @return The market state. + function getMarketState() external view - returns (IHyperdrive.WithdrawPool memory); + returns (IHyperdrive.MarketState memory); + /// @notice Gets the pool's configuration parameters. + /// @return The pool configuration. function getPoolConfig() external view returns (IHyperdrive.PoolConfig memory); - function getMarketState() - external - view - returns (IHyperdrive.MarketState memory); + /// @notice Gets info about the pool's reserves and other state that is + /// important to evaluate potential trades. + /// @return The pool info. + function getPoolInfo() external view returns (IHyperdrive.PoolInfo memory); + /// @notice Gets the amount of governance fees that haven't been collected. + /// @return The amount of uncollected governance fees. function getUncollectedGovernanceFees() external view returns (uint256); - function getPoolInfo() external view returns (IHyperdrive.PoolInfo memory); + /// @notice Gets information relating to the pool's withdrawal pool. This + /// includes the total proceeds underlying the withdrawal pool and + /// the number of withdrawal shares ready to be redeemed. + /// @return The withdrawal pool information. + function getWithdrawPool() + external + view + returns (IHyperdrive.WithdrawPool memory); + /// @notice Gets an account's pauser status within the Hyperdrive pool. + /// @param _account The account to check. + /// @return The account's pauser status. function isPauser(address _account) external view returns (bool); + /// @notice Gets the storage values at the specified slots. + /// @dev This serves as a generalized getter that allows consumers to create + /// custom getters to suit their purposes. + /// @param _slots The storage slots to load. + /// @return The values at the specified slots. function load( uint256[] calldata _slots ) external view returns (bytes32[] memory); diff --git a/contracts/src/interfaces/IHyperdriveTargetDeployer.sol b/contracts/src/interfaces/IHyperdriveTargetDeployer.sol index cc6ad0568..5f8326039 100644 --- a/contracts/src/interfaces/IHyperdriveTargetDeployer.sol +++ b/contracts/src/interfaces/IHyperdriveTargetDeployer.sol @@ -4,6 +4,11 @@ pragma solidity 0.8.20; import { IHyperdrive } from "./IHyperdrive.sol"; interface IHyperdriveTargetDeployer { + /// @notice Deploys a target instance with the given parameters. + /// @param _config The configuration of the Hyperdrive pool. + /// @param _extraData The extra data that contains the pool and sweep targets. + /// @param _salt The create2 salt used in the deployment. + /// @return The address of the newly deployed target instance. function deploy( IHyperdrive.PoolConfig memory _config, bytes memory _extraData, diff --git a/contracts/src/interfaces/ILido.sol b/contracts/src/interfaces/ILido.sol index 8b0af3848..a15b87f13 100644 --- a/contracts/src/interfaces/ILido.sol +++ b/contracts/src/interfaces/ILido.sol @@ -4,32 +4,64 @@ pragma solidity 0.8.20; import { IERC20 } from "./IERC20.sol"; interface ILido is IERC20 { + /// @notice Submits ether to stETH to be staked. + /// @param _referral The referral address that should get credit in Lido's + /// referral program. + /// @return The amount of stETH shares that were minted. function submit(address _referral) external payable returns (uint256); + /// @notice Transfers stETH shares from the caller to a recipient. + /// @param _recipient The recipient of the tokens. + /// @param _sharesAmount The amount of stETH shares that will be transferred. + /// @return The amount of stETH tokens that were transferred. function transferShares( address _recipient, uint256 _sharesAmount ) external returns (uint256); + /// @notice Transfers stETH shares from an owner to a recipient. This draws + /// from the spender's allowance. + /// @param _sender The owner of the tokens. + /// @param _recipient The recipient of the tokens. + /// @param _sharesAmount The amount of tokens that will be transferred. + /// @return A flag indicating whether or not the transfer succeeded. function transferSharesFrom( address _sender, address _recipient, uint256 _sharesAmount ) external returns (uint256); + /// @notice Calculates the amount of stETH shares an amount of stETH tokens + /// are currently worth. + /// @param _ethAmount The amount of stETH tokens to convert. + /// @return The amount of stETH shares that the stETH tokens are worth. function getSharesByPooledEth( uint256 _ethAmount ) external view returns (uint256); + /// @notice Calculates the amount of stETH tokens an amount of stETH shares + /// are currently worth. + /// @param _sharesAmount The amount of stETH shares to convert. + /// @return The amount of stETH tokens that the stETH shares are worth. function getPooledEthByShares( uint256 _sharesAmount ) external view returns (uint256); + /// @notice Gets the total amount of ether that is buffered and waiting + /// to be staked underlying stETH. + /// @return The total amount of buffered ether. function getBufferedEther() external view returns (uint256); + /// @notice Gets the total amount of pooled ether underlying stETH. + /// @return The total amount of pooled ether. function getTotalPooledEther() external view returns (uint256); + /// @notice Gets the total amount of stETH shares. + /// @return The total amount of stETH shares. function getTotalShares() external view returns (uint256); + /// @notice Gets the amount of shares owned by an account. + /// @param _account The owner of the shares. + //// @return The amount of shares owned by the account. function sharesOf(address _account) external view returns (uint256); } diff --git a/contracts/src/interfaces/IMultiTokenCore.sol b/contracts/src/interfaces/IMultiTokenCore.sol index 2a2289d3c..9b270e2f6 100644 --- a/contracts/src/interfaces/IMultiTokenCore.sol +++ b/contracts/src/interfaces/IMultiTokenCore.sol @@ -2,8 +2,11 @@ pragma solidity 0.8.20; interface IMultiTokenCore { - /// Functions /// - + /// @notice Transfers an amount of assets from the source to the destination. + /// @param tokenID The token identifier. + /// @param from The address whose balance will be reduced. + /// @param to The address whose balance will be increased. + /// @param amount The amount of token to move. function transferFrom( uint256 tokenID, address from, @@ -11,6 +14,13 @@ interface IMultiTokenCore { uint256 amount ) external; + /// @notice Permissioned transfer for the bridge to access, only callable by + /// the ERC20 linking bridge. + /// @param tokenID The token identifier. + /// @param from The address whose balance will be reduced. + /// @param to The address whose balance will be increased. + /// @param amount The amount of token to move. + /// @param caller The msg.sender or the caller of the ERC20Forwarder. function transferFromBridge( uint256 tokenID, address from, @@ -19,12 +29,22 @@ interface IMultiTokenCore { address caller ) external; + /// @notice Allows a user to set an approval for an individual asset with + /// specific amount. function setApproval( uint256 tokenID, address operator, uint256 amount ) external; + /// @notice Allows the compatibility linking contract to forward calls to + /// set asset approvals. + /// @param tokenID The asset to approve the use of. + /// @param operator The address who will be able to use the tokens. + /// @param amount The max tokens the approved person can use, setting to + /// uint256.max will cause the value to never decrement [saving gas + /// on transfer]. + /// @param caller The eth address which called the linking contract. function setApprovalBridge( uint256 tokenID, address operator, @@ -32,8 +52,16 @@ interface IMultiTokenCore { address caller ) external; + /// @notice Allows a user to approve an operator to use all of their assets. + /// @param operator The eth address which can access the caller's assets. + /// @param approved True to approve, false to remove approval. function setApprovalForAll(address operator, bool approved) external; + /// @notice Transfers several assets from one account to another. + /// @param from The source account. + /// @param to The destination account. + /// @param ids The array of token ids of the asset to transfer. + /// @param values The amount of each token to transfer. function batchTransferFrom( address from, address to, @@ -41,6 +69,24 @@ interface IMultiTokenCore { uint256[] calldata values ) external; + /// @notice Allows a caller who is not the owner of an account to execute the + /// functionality of 'approve' for all assets with the owner's + /// signature. + /// @param owner The owner of the account which is having the new approval set. + /// @param spender The address which will be allowed to spend owner's tokens. + /// @param _approved A boolean of the approval status to set to. + /// @param deadline The timestamp which the signature must be submitted by + /// to be valid. + /// @param v Extra ECDSA data which allows public key recovery from + /// signature assumed to be 27 or 28. + /// @param r The r component of the ECDSA signature. + /// @param s The s component of the ECDSA signature. + /// @dev The signature for this function follows EIP 712 standard and should + /// be generated with the eth_signTypedData JSON RPC call instead of + /// the eth_sign JSON RPC call. If using out of date parity signing + /// libraries the v component may need to be adjusted. Also it is very + /// rare but possible for v to be other values, those values are not + /// supported. function permitForAll( address owner, address spender, diff --git a/contracts/src/interfaces/IMultiTokenEvents.sol b/contracts/src/interfaces/IMultiTokenEvents.sol index a9343219e..9b126de92 100644 --- a/contracts/src/interfaces/IMultiTokenEvents.sol +++ b/contracts/src/interfaces/IMultiTokenEvents.sol @@ -2,6 +2,7 @@ pragma solidity 0.8.20; interface IMultiTokenEvents { + /// @notice Emitted when tokens are transferred from one account to another. event TransferSingle( address indexed operator, address indexed from, @@ -10,12 +11,16 @@ interface IMultiTokenEvents { uint256 value ); + /// @notice Emitted when an account changes the allowance for another + /// account. event Approval( address indexed owner, address indexed spender, uint256 value ); + /// @notice Emitted when an account changes the approval for all of its + /// tokens. event ApprovalForAll( address indexed account, address indexed operator, diff --git a/contracts/src/interfaces/IMultiTokenMetadata.sol b/contracts/src/interfaces/IMultiTokenMetadata.sol index 72f1040ea..45f864556 100644 --- a/contracts/src/interfaces/IMultiTokenMetadata.sol +++ b/contracts/src/interfaces/IMultiTokenMetadata.sol @@ -2,9 +2,13 @@ pragma solidity 0.8.20; interface IMultiTokenMetadata { + /// @notice Gets the EIP712 permit typehash of the MultiToken. + /// @return The EIP712 permit typehash of the MultiToken. // solhint-disable func-name-mixedcase function PERMIT_TYPEHASH() external view returns (bytes32); + /// @notice Gets the EIP712 domain separator of the MultiToken. + /// @return The EIP712 domain separator of the MultiToken. // solhint-disable func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); } diff --git a/contracts/src/interfaces/IMultiTokenRead.sol b/contracts/src/interfaces/IMultiTokenRead.sol index 199053d3c..5e58729ab 100644 --- a/contracts/src/interfaces/IMultiTokenRead.sol +++ b/contracts/src/interfaces/IMultiTokenRead.sol @@ -2,27 +2,50 @@ pragma solidity 0.8.20; interface IMultiTokenRead { + /// @notice Gets the name of the MultiToken. + /// @return The name of the MultiToken. function name(uint256 id) external view returns (string memory); + /// @notice Gets the symbol of the MultiToken. + /// @return The symbol of the MultiToken. function symbol(uint256 id) external view returns (string memory); + /// @notice Gets the total supply of the MultiToken. + /// @return The total supply of the MultiToken. function totalSupply(uint256 id) external view returns (uint256); + /// @notice Gets the approval-for-all status of a spender on behalf of an + /// owner. + /// @param owner The owner of the tokens. + /// @param spender The spender of the tokens. + /// @return The approval-for-all status of the spender for the owner. function isApprovedForAll( address owner, address spender ) external view returns (bool); + /// @notice Gets the allowance of a spender for a sub-token. + /// @param tokenId The sub-token ID. + /// @param owner The owner of the tokens. + /// @param spender The spender of the tokens. + /// @return The allowance of the spender for the owner. function perTokenApprovals( uint256 tokenId, address owner, address spender ) external view returns (uint256); + /// @notice Gets the balance of a spender for a sub-token. + /// @param tokenId The sub-token ID. + /// @param owner The owner of the tokens. + /// @return The balance of the owner. function balanceOf( uint256 tokenId, address owner ) external view returns (uint256); + /// @notice Gets the permit nonce for an account. + /// @param owner The owner of the tokens. + /// @return The permit nonce of the owner. function nonces(address owner) external view returns (uint256); } diff --git a/contracts/src/interfaces/IStETHHyperdriveCore.sol b/contracts/src/interfaces/IStETHHyperdriveCore.sol index e4ecf9f2c..6c45798dc 100644 --- a/contracts/src/interfaces/IStETHHyperdriveCore.sol +++ b/contracts/src/interfaces/IStETHHyperdriveCore.sol @@ -5,5 +5,11 @@ import { IERC20 } from "./IERC20.sol"; import { IHyperdriveCore } from "./IHyperdriveCore.sol"; interface IStETHHyperdriveCore is IHyperdriveCore { + /// @notice Transfers the contract's balance of a target token to the fee + /// collector address. + /// @dev WARN: It is unlikely but possible that there is a selector overlap + /// with 'transferFrom'. Any integrating contracts should be checked + /// for that, as it may result in an unexpected call from this address. + /// @param _target The target token to sweep. function sweep(IERC20 _target) external; } diff --git a/contracts/src/interfaces/IStETHHyperdriveRead.sol b/contracts/src/interfaces/IStETHHyperdriveRead.sol index b6fd6efc8..50163fd24 100644 --- a/contracts/src/interfaces/IStETHHyperdriveRead.sol +++ b/contracts/src/interfaces/IStETHHyperdriveRead.sol @@ -5,5 +5,7 @@ import { IHyperdriveRead } from "./IHyperdriveRead.sol"; import { ILido } from "./ILido.sol"; interface IStETHHyperdriveRead is IHyperdriveRead { + /// @notice Gets the Lido contract used as this pool's yield source. + /// @return The Lido contract. function lido() external view returns (ILido); } diff --git a/contracts/src/internal/HyperdriveAdmin.sol b/contracts/src/internal/HyperdriveAdmin.sol index 09d0133f5..b12acf508 100644 --- a/contracts/src/internal/HyperdriveAdmin.sol +++ b/contracts/src/internal/HyperdriveAdmin.sol @@ -57,7 +57,7 @@ abstract contract HyperdriveAdmin is IHyperdriveEvents, HyperdriveBase { emit PauseStatusUpdated(_status); } - /// @dev Allows governance to change governance. + /// @dev Allows governance to transfer the governance role. /// @param _who The new governance address. function _setGovernance(address _who) internal { // Ensure that the sender is governance. diff --git a/contracts/src/internal/HyperdriveLP.sol b/contracts/src/internal/HyperdriveLP.sol index aa8b19989..0faa845b9 100644 --- a/contracts/src/internal/HyperdriveLP.sol +++ b/contracts/src/internal/HyperdriveLP.sol @@ -117,14 +117,14 @@ abstract contract HyperdriveLP is /// @dev Allows LPs to supply liquidity for LP shares. /// @param _contribution The amount to supply. /// @param _minLpSharePrice The minimum LP share price the LP is willing - /// to accept for their shares. LP's incur negative slippage when + /// to accept for their shares. LPs incur negative slippage when /// adding liquidity if there is a net curve position in the market, /// so this allows LPs to protect themselves from high levels of /// slippage. /// @param _minApr The minimum APR at which the LP is willing to supply. /// @param _maxApr The maximum APR at which the LP is willing to supply. /// @param _options The options that configure how the operation is settled. - /// @return lpShares The number of LP tokens created + /// @return lpShares The number of LP tokens created. function _addLiquidity( uint256 _contribution, uint256 _minLpSharePrice, diff --git a/contracts/src/internal/HyperdriveMultiToken.sol b/contracts/src/internal/HyperdriveMultiToken.sol index fe178eb93..07fc4f53f 100644 --- a/contracts/src/internal/HyperdriveMultiToken.sol +++ b/contracts/src/internal/HyperdriveMultiToken.sol @@ -68,8 +68,8 @@ abstract contract HyperdriveMultiToken is IHyperdriveEvents, HyperdriveBase { /// @dev Performs the actual transfer logic. /// @param tokenID The token identifier. - /// @param from The address who's balance will be reduced. - /// @param to The address who's balance will be increased. + /// @param from The address whose balance will be reduced. + /// @param to The address whose balance will be increased. /// @param amount The amount of token to move. /// @param caller The msg.sender or the caller of the ERC20Forwarder. function _transferFrom( @@ -130,7 +130,7 @@ abstract contract HyperdriveMultiToken is IHyperdriveEvents, HyperdriveBase { /// @notice Minting function to create tokens. /// @param tokenID The asset type to create. - /// @param to The address who's balance to increase. + /// @param to The address whose balance to increase. /// @param amount The number of tokens to create. /// @dev Must be used from inheriting contracts. function _mint( @@ -147,7 +147,7 @@ abstract contract HyperdriveMultiToken is IHyperdriveEvents, HyperdriveBase { /// @notice Burning function to remove tokens. /// @param tokenID The asset type to remove. - /// @param from The address who's balance to decrease. + /// @param from The address whose balance to decrease. /// @param amount The number of tokens to remove. /// @dev Must be used from inheriting contracts. function _burn(uint256 tokenID, address from, uint256 amount) internal { diff --git a/contracts/src/internal/HyperdriveShort.sol b/contracts/src/internal/HyperdriveShort.sol index 4459ba785..440b57eb2 100644 --- a/contracts/src/internal/HyperdriveShort.sol +++ b/contracts/src/internal/HyperdriveShort.sol @@ -25,9 +25,9 @@ abstract contract HyperdriveShort is IHyperdriveEvents, HyperdriveLP { /// @dev Opens a short position. /// @param _bondAmount The amount of bonds to short. /// @param _maxDeposit The most the user expects to deposit for this trade. - /// @param _minVaultSharePrice The minium vault share price at which to open - /// the long. This allows traders to protect themselves from opening - /// a long in a checkpoint where negative interest has accrued. + /// @param _minVaultSharePrice The minimum vault share price at which to open + /// the short. This allows traders to protect themselves from opening + /// a short in a checkpoint where negative interest has accrued. /// @param _options The options that configure how the trade is settled. /// @return The maturity time of the short. /// @return The amount the user deposited for this trade. @@ -129,7 +129,7 @@ abstract contract HyperdriveShort is IHyperdriveEvents, HyperdriveLP { return (maturityTime, traderDeposit); } - /// @notice Closes a short position with a specified maturity time. + /// @dev Closes a short position with a specified maturity time. /// @param _maturityTime The maturity time of the short. /// @param _bondAmount The amount of shorts to close. /// @param _minOutput The minimum output of this trade. diff --git a/contracts/src/token/ERC20Forwarder.sol b/contracts/src/token/ERC20Forwarder.sol index 5c2e8c076..455393b32 100644 --- a/contracts/src/token/ERC20Forwarder.sol +++ b/contracts/src/token/ERC20Forwarder.sol @@ -104,7 +104,7 @@ contract ERC20Forwarder is IERC20Forwarder { /// If spender is approved for all tokens in the main contract /// it will return Max(uint256) otherwise it returns the allowance /// the allowance for just this asset. - /// @param owner The account who's tokens would be spent. + /// @param owner The account whose tokens would be spent. /// @param spender The account who might be able to spend tokens. /// @return The amount of the owner's tokens the spender can spend. function allowance( diff --git a/contracts/src/token/ERC20ForwarderFactory.sol b/contracts/src/token/ERC20ForwarderFactory.sol index c46e3382c..42e4c9bf4 100644 --- a/contracts/src/token/ERC20ForwarderFactory.sol +++ b/contracts/src/token/ERC20ForwarderFactory.sol @@ -61,15 +61,19 @@ contract ERC20ForwarderFactory is IERC20ForwarderFactory { return deployed; } - /// @notice Returns the transient storage of this contract. - /// @return Returns the stored multitoken address and the sub token id. + /// @notice Gets the MultiToken and token ID that should be targeted by the + /// calling forwarder. + /// @dev The target MultiToken and token ID are transient state variables + /// that are set during deployment. + /// @return The target MultiToken. + /// @return The target token ID. function getDeployDetails() external view returns (IMultiToken, uint256) { return (_token, _tokenId); } /// @notice Helper to calculate expected forwarder contract addresses. - /// @param __token The multitoken which the forwarder should link to. - /// @param __tokenId The id of the sub token from the multitoken. + /// @param __token The target MultiToken of the forwarder. + /// @param __tokenId The target token ID of the forwarder. /// @return The expected address of the forwarder. function getForwarder( IMultiToken __token,