Skip to content

Commit

Permalink
docs: fix errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Rubilmax committed Oct 25, 2023
1 parent ba159f7 commit 86c9464
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 34 deletions.
36 changes: 16 additions & 20 deletions src/ERC4626Bundler.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,15 @@ abstract contract ERC4626Bundler is BaseBundler {
/* ACTIONS */

/// @notice Mints the given amount of `shares` on the given ERC4626 `vault`, on behalf of `owner`.
/// @dev Pass `type(uint256).max` as `shares` to mint max.
/// @dev Assumes the given `vault` implements EIP-4626.
/// @param vault The address of the vault.
/// @param shares The amount of shares to mint.
/// @param owner The address to which shares will be minted.
function erc4626Mint(address vault, uint256 shares, address owner) external payable {
require(owner != address(0), ErrorsLib.ZERO_ADDRESS);
/// Do not check `owner != address(this)` to allow the bundler to receive the vault's shares.
/// @param shares The amount of shares to mint. Pass `type(uint256).max` to mint max.
/// @param receiver The address to which shares will be minted.
function erc4626Mint(address vault, uint256 shares, address receiver) external payable {
require(receiver != address(0), ErrorsLib.ZERO_ADDRESS);
/// Do not check `receiver != address(this)` to allow the bundler to receive the vault's shares.

shares = Math.min(shares, IERC4626(vault).maxMint(owner));
shares = Math.min(shares, IERC4626(vault).maxMint(receiver));

address asset = IERC4626(vault).asset();
uint256 assets = Math.min(IERC4626(vault).previewMint(shares), ERC20(asset).balanceOf(address(this)));
Expand All @@ -38,39 +37,37 @@ abstract contract ERC4626Bundler is BaseBundler {
// Approve 0 first to comply with tokens that implement the anti frontrunning approval fix.
ERC20(asset).safeApprove(vault, 0);
ERC20(asset).safeApprove(vault, assets);
IERC4626(vault).mint(shares, owner);
IERC4626(vault).mint(shares, receiver);
}

/// @notice Deposits the given amount of `assets` on the given ERC4626 `vault`, on behalf of `owner`.
/// @dev Pass `type(uint256).max` as `assets` to deposit max.
/// @dev Assumes the given `vault` implements EIP-4626.
/// @param vault The address of the vault.
/// @param assets The amount of assets to deposit.
/// @param owner The address to which shares will be minted.
function erc4626Deposit(address vault, uint256 assets, address owner) external payable {
require(owner != address(0), ErrorsLib.ZERO_ADDRESS);
/// Do not check `owner != address(this)` to allow the bundler to receive the vault's shares.
/// @param assets The amount of assets to deposit. Pass `type(uint256).max` to deposit max.
/// @param receiver The address to which shares will be minted.
function erc4626Deposit(address vault, uint256 assets, address receiver) external payable {
require(receiver != address(0), ErrorsLib.ZERO_ADDRESS);
/// Do not check `receiver != address(this)` to allow the bundler to receive the vault's shares.

address asset = IERC4626(vault).asset();

assets = Math.min(assets, IERC4626(vault).maxDeposit(owner));
assets = Math.min(assets, IERC4626(vault).maxDeposit(receiver));
assets = Math.min(assets, ERC20(asset).balanceOf(address(this)));

require(assets != 0, ErrorsLib.ZERO_AMOUNT);

// Approve 0 first to comply with tokens that implement the anti frontrunning approval fix.
ERC20(asset).safeApprove(vault, 0);
ERC20(asset).safeApprove(vault, assets);
IERC4626(vault).deposit(assets, owner);
IERC4626(vault).deposit(assets, receiver);
}

/// @notice Withdraws the given amount of `assets` from the given ERC4626 `vault`, transferring assets to
/// `receiver`.
/// @notice Warning: should only be called via the bundler's `multicall` function.
/// @dev Pass `type(uint256).max` as `assets` to withdraw max.
/// @dev Assumes the given `vault` implements EIP-4626.
/// @param vault The address of the vault.
/// @param assets The amount of assets to withdraw.
/// @param assets The amount of assets to withdraw. Pass `type(uint256).max` to withdraw max.
/// @param receiver The address that will receive the withdrawn assets.
function erc4626Withdraw(address vault, uint256 assets, address receiver) external payable {
require(receiver != address(0), ErrorsLib.ZERO_ADDRESS);
Expand All @@ -87,10 +84,9 @@ abstract contract ERC4626Bundler is BaseBundler {

/// @notice Redeems the given amount of `shares` from the given ERC4626 `vault`, transferring assets to `receiver`.
/// @notice Warning: should only be called via the bundler's `multicall` function.
/// @dev Pass `type(uint256).max` as `shares` to redeem max.
/// @dev Assumes the given `vault` implements EIP-4626.
/// @param vault The address of the vault.
/// @param shares The amount of shares to burn.
/// @param shares The amount of shares to burn. Pass `type(uint256).max` to redeem max.
/// @param receiver The address that will receive the withdrawn assets.
function erc4626Redeem(address vault, uint256 shares, address receiver) external payable {
require(receiver != address(0), ErrorsLib.ZERO_ADDRESS);
Expand Down
10 changes: 5 additions & 5 deletions src/MorphoBundler.sol
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ abstract contract MorphoBundler is BaseBundler, IMorphoBundler {
/* ACTIONS */

/// @notice Approves this contract to manage the `authorization.authorizer`'s position via EIP712 `signature`.
/// @dev Pass `skipRevert = true` to avoid reverting the whole bundle in case the signature expired.
/// @param authorization The `Authorization` struct.
/// @param signature The signature.
/// @param skipRevert Whether to avoid reverting the call in case the signature is frontrunned.
function morphoSetAuthorizationWithSig(
Authorization calldata authorization,
Signature calldata signature,
Expand All @@ -70,7 +70,7 @@ abstract contract MorphoBundler is BaseBundler, IMorphoBundler {
}
}

/// @notice Supplies `amount` of `asset` of `onBehalf` using permit2 in a single tx.
/// @notice Supplies `amount` of the loan asset on behalf of `onBehalf`.
/// @notice The supplied amount cannot be used as collateral but is eligible to earn interest.
/// @dev Pass `amount = type(uint256).max` to supply the bundler's loan asset balance.
/// @param marketParams The Morpho market to supply assets to.
Expand All @@ -97,7 +97,7 @@ abstract contract MorphoBundler is BaseBundler, IMorphoBundler {
MORPHO.supply(marketParams, amount, shares, onBehalf, data);
}

/// @notice Supplies `amount` of `asset` collateral to the pool on behalf of `onBehalf`.
/// @notice Supplies `amount` of the collateral asset on behalf of `onBehalf`.
/// @dev Pass `amount = type(uint256).max` to supply the bundler's collateral asset balance.
/// @param marketParams The Morpho market to supply collateral to.
/// @param amount The amount of collateral to supply.
Expand All @@ -121,7 +121,7 @@ abstract contract MorphoBundler is BaseBundler, IMorphoBundler {
MORPHO.supplyCollateral(marketParams, amount, onBehalf, data);
}

/// @notice Borrows `amount` of `asset` on behalf of the sender.
/// @notice Borrows `amount` of the loan asset on behalf of the sender.
/// @notice Warning: should only be called via the bundler's `multicall` function.
/// @dev Initiator must have previously authorized the bundler to act on their behalf on Morpho.
/// @param marketParams The Morpho market to borrow assets from.
Expand All @@ -135,7 +135,7 @@ abstract contract MorphoBundler is BaseBundler, IMorphoBundler {
MORPHO.borrow(marketParams, amount, shares, initiator(), receiver);
}

/// @notice Repays `amount` of `asset` on behalf of `onBehalf`.
/// @notice Repays `amount` of the loan asset on behalf of `onBehalf`.
/// @dev Pass `amount = type(uint256).max` to repay the bundler's loan asset balance.
/// @param marketParams The Morpho market to repay assets to.
/// @param amount The amount of assets to repay.
Expand Down
2 changes: 1 addition & 1 deletion src/PermitBundler.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ abstract contract PermitBundler is BaseBundler {
/// @notice Permits the given `amount` of `asset` from sender to be spent by the bundler via EIP-2612 Permit with
/// the given `deadline` & EIP-712 signature's `v`, `r` & `s`.
/// @notice Warning: should only be called via the bundler's `multicall` function.
/// @dev Pass `skipRevert = true` to avoid reverting the whole bundle in case the signature expired.
/// @param asset The address of the token to be permitted.
/// @param amount The amount of `asset` to be permitted.
/// @param deadline The deadline of the approval.
/// @param v The `v` component of a signature.
/// @param r The `r` component of a signature.
/// @param s The `s` component of a signature.
/// @param skipRevert Whether to avoid reverting the call in case the signature is frontrunned.
function permit(address asset, uint256 amount, uint256 deadline, uint8 v, bytes32 r, bytes32 s, bool skipRevert)
external
payable
Expand Down
2 changes: 1 addition & 1 deletion src/UrdBundler.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ import {BaseBundler} from "./BaseBundler.sol";
abstract contract UrdBundler is BaseBundler {
/// @notice Claims `amount` of `reward` on behalf of `account` on the given rewards distributor, using `proof`.
/// @dev Assumes the given distributor implements IUniversalRewardsDistributor.
/// @dev Pass `skipRevert = true` to avoid reverting the whole bundle in case the proof expired.
/// @param distributor The address of the reward distributor contract.
/// @param account The address of the owner of the rewards (also the address that will receive the rewards).
/// @param reward The address of the token reward.
/// @param amount The amount of the reward token to claim.
/// @param proof The proof.
/// @param skipRevert Whether to avoid reverting the call in case the proof is frontrunned.
function urdClaim(
address distributor,
address account,
Expand Down
2 changes: 1 addition & 1 deletion src/ethereum/EthereumPermitBundler.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ abstract contract EthereumPermitBundler is PermitBundler {
/// @notice Permits DAI from sender to be spent by the bundler with the given `nonce`, `expiry` & EIP-712
/// signature's `v`, `r` & `s`.
/// @notice Warning: should only be called via the bundler's `multicall` function.
/// @dev Pass `skipRevert = true` to avoid reverting the whole bundle in case the signature expired.
/// @param nonce The nonce of the signed message.
/// @param expiry The expiry of the signed message.
/// @param allowed Whether the initiator gives the bundler infinite Dai approval or not.
/// @param v The `v` component of a signature.
/// @param r The `r` component of a signature.
/// @param s The `s` component of a signature.
/// @param skipRevert Whether to avoid reverting the call in case the signature is frontrunned.
function permitDai(uint256 nonce, uint256 expiry, bool allowed, uint8 v, bytes32 r, bytes32 s, bool skipRevert)
external
payable
Expand Down
2 changes: 2 additions & 0 deletions src/interfaces/IMulticall.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@ pragma solidity >=0.5.0;
/// @custom:contact security@morpho.org
/// @notice Interface of Multicall.
interface IMulticall {
/// @notice Executes an ordered batch of delegatecalls to this contract.
/// @param data The ordered array of calldata to execute.
function multicall(bytes[] calldata data) external payable;
}
13 changes: 7 additions & 6 deletions src/migration/AaveV3OptimizerMigrationBundler.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@ import {MigrationBundler, ERC20} from "./MigrationBundler.sol";
contract AaveV3OptimizerMigrationBundler is MigrationBundler {
/* IMMUTABLES */

/// @dev The AaveV3 optmizer contract address.
/// @dev The AaveV3 optimizer contract address.
IAaveV3Optimizer public immutable AAVE_V3_OPTIMIZER;

/* CONSTRUCTOR */

/// @param morpho The Morpho contract Address.
/// @param aaveV3Optimizer The AaveV3 optmizer contract address. Assumes it is non-zero (not expected to be an input
/// @param aaveV3Optimizer The AaveV3 optimizer contract address. Assumes it is non-zero (not expected to be an
/// input
/// at deployment).
constructor(address morpho, address aaveV3Optimizer) MigrationBundler(morpho) {
AAVE_V3_OPTIMIZER = IAaveV3Optimizer(aaveV3Optimizer);
Expand All @@ -44,8 +45,8 @@ contract AaveV3OptimizerMigrationBundler is MigrationBundler {
AAVE_V3_OPTIMIZER.repay(underlying, amount, initiator());
}

/// @notice Repays `amount` of `underlying` on the AaveV3 Optimizer, on behalf of the initiator, transferring funds
/// to `receiver`.
/// @notice Withdraws `amount` of `underlying` on the AaveV3 Optimizer, on behalf of the initiator, transferring
/// funds to `receiver`.
/// @notice Warning: should only be called via the bundler's `multicall` function.
/// @dev Initiator must have previously approved the bundler to manage their AaveV3 Optimizer position.
/// @dev Pass `amount = type(uint256).max` to withdraw all.
Expand All @@ -61,8 +62,8 @@ contract AaveV3OptimizerMigrationBundler is MigrationBundler {
AAVE_V3_OPTIMIZER.withdraw(underlying, amount, initiator(), receiver, maxIterations);
}

/// @notice Repays `amount` of `underlying` on the AaveV3 Optimizer, on behalf of the initiator, transferring funds
/// to `receiver`.
/// @notice Withdraws `amount` of `underlying` used as collateral on the AaveV3 Optimizer, on behalf of the
/// initiator, transferring funds to `receiver`.
/// @notice Warning: should only be called via the bundler's `multicall` function.
/// @dev Initiator must have previously approved the bundler to manage their AaveV3 Optimizer position.
/// @dev Pass `amount = type(uint256).max` to withdraw all.
Expand Down

0 comments on commit 86c9464

Please sign in to comment.