Skip to content

Commit

Permalink
update natspec to include what role can call a requiresAuth function
Browse files Browse the repository at this point in the history
  • Loading branch information
crispymangoes committed Apr 8, 2024
1 parent e05fa92 commit 506e197
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/base/BoringVault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ contract BoringVault is ERC20, Auth, ERC721Holder, ERC1155Holder {

/**
* @notice Allows manager to make an arbitrary function call from this contract.
* @dev Callable by MANAGER_ROLE.
*/
function manage(address target, bytes calldata data, uint256 value)
external
Expand All @@ -49,6 +50,7 @@ contract BoringVault is ERC20, Auth, ERC721Holder, ERC1155Holder {

/**
* @notice Allows manager to make arbitrary function calls from this contract.
* @dev Callable by MANAGER_ROLE.
*/
function manage(address[] calldata targets, bytes[] calldata data, uint256[] calldata values)
external
Expand All @@ -67,6 +69,7 @@ contract BoringVault is ERC20, Auth, ERC721Holder, ERC1155Holder {
/**
* @notice Allows minter to mint shares, in exchange for assets.
* @dev If assetAmount is zero, no assets are transferred in.
* @dev Callable by MINTER_ROLE.
*/
function enter(address from, ERC20 asset, uint256 assetAmount, address to, uint256 shareAmount)
external
Expand All @@ -86,6 +89,7 @@ contract BoringVault is ERC20, Auth, ERC721Holder, ERC1155Holder {
/**
* @notice Allows burner to burn shares, in exchange for assets.
* @dev If assetAmount is zero, no assets are transferred out.
* @dev Callable by BURNER_ROLE.
*/
function exit(address to, ERC20 asset, uint256 assetAmount, address from, uint256 shareAmount)
external
Expand All @@ -104,6 +108,7 @@ contract BoringVault is ERC20, Auth, ERC721Holder, ERC1155Holder {
/**
* @notice Sets the share locker.
* @notice If set to zero address, the share locker logic is disabled.
* @dev Callable by OWNER_ROLE.
*/
function setBeforeTransferHook(address _hook) external requiresAuth {
hook = BeforeTransferHook(_hook);
Expand Down
9 changes: 9 additions & 0 deletions src/base/Roles/AccountantWithRateProviders.sol
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ contract AccountantWithRateProviders is Auth, IRateProvider {
/**
* @notice Pause this contract, which prevents future calls to `updateExchangeRate`, and any safe rate
* calls will revert.
* @dev Callable by MULTISIG_ROLE.
*/
function pause() external requiresAuth {
accountantState.isPaused = true;
Expand All @@ -147,6 +148,7 @@ contract AccountantWithRateProviders is Auth, IRateProvider {
/**
* @notice Unpause this contract, which allows future calls to `updateExchangeRate`, and any safe rate
* calls will stop reverting.
* @dev Callable by MULTISIG_ROLE.
*/
function unpause() external requiresAuth {
accountantState.isPaused = false;
Expand All @@ -157,6 +159,7 @@ contract AccountantWithRateProviders is Auth, IRateProvider {
* @notice Update the minimum time delay between `updateExchangeRate` calls.
* @dev There are no input requirements, as it is possible the admin would want
* the exchange rate updated as frequently as needed.
* @dev Callable by OWNER_ROLE.
*/
function updateDelay(uint32 minimumUpdateDelayInSeconds) external requiresAuth {
uint32 oldDelay = accountantState.minimumUpdateDelayInSeconds;
Expand All @@ -166,6 +169,7 @@ contract AccountantWithRateProviders is Auth, IRateProvider {

/**
* @notice Update the allowed upper bound change of exchange rate between `updateExchangeRateCalls`.
* @dev Callable by OWNER_ROLE.
*/
function updateUpper(uint16 allowedExchangeRateChangeUpper) external requiresAuth {
if (allowedExchangeRateChangeUpper < 1e4) revert AccountantWithRateProviders__UpperBoundTooSmall();
Expand All @@ -176,6 +180,7 @@ contract AccountantWithRateProviders is Auth, IRateProvider {

/**
* @notice Update the allowed lower bound change of exchange rate between `updateExchangeRateCalls`.
* @dev Callable by OWNER_ROLE.
*/
function updateLower(uint16 allowedExchangeRateChangeLower) external requiresAuth {
if (allowedExchangeRateChangeLower > 1e4) revert AccountantWithRateProviders__LowerBoundTooLarge();
Expand All @@ -186,6 +191,7 @@ contract AccountantWithRateProviders is Auth, IRateProvider {

/**
* @notice Update the management fee to a new value.
* @dev Callable by OWNER_ROLE.
*/
function updateManagementFee(uint16 managementFee) external requiresAuth {
if (managementFee > 0.2e4) revert AccountantWithRateProviders__ManagementFeeTooLarge();
Expand All @@ -196,6 +202,7 @@ contract AccountantWithRateProviders is Auth, IRateProvider {

/**
* @notice Update the payout address fees are sent to.
* @dev Callable by OWNER_ROLE.
*/
function updatePayoutAddress(address payoutAddress) external requiresAuth {
address oldPayout = accountantState.payoutAddress;
Expand All @@ -207,6 +214,7 @@ contract AccountantWithRateProviders is Auth, IRateProvider {
* @notice Update the rate provider data for a specific `asset`.
* @dev Rate providers must return rates in terms of `base` and
* they must use the same decimals as `base`.
* @dev Callable by OWNER_ROLE.
*/
function setRateProviderData(ERC20 asset, bool isPeggedToBase, address rateProvider) external requiresAuth {
rateProviderData[asset] =
Expand All @@ -220,6 +228,7 @@ contract AccountantWithRateProviders is Auth, IRateProvider {
* @notice Updates this contract exchangeRate.
* @dev If new exchange rate is outside of accepted bounds, or if not enough time has passed, this
* will pause the contract, and this function will NOT calculate fees owed.
* @dev Callable by UPDATE_EXCHANGE_RATE_ROLE.
*/
function updateExchangeRate(uint96 newExchangeRate) external requiresAuth {
AccountantState storage state = accountantState;
Expand Down
6 changes: 6 additions & 0 deletions src/base/Roles/ManagerWithMerkleVerification.sol
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ contract ManagerWithMerkleVerification is Auth {

/**
* @notice Sets the manageRoot.
* @dev Callable by OWNER_ROLE.
*/
function setManageRoot(address strategist, bytes32 _manageRoot) external requiresAuth {
bytes32 oldRoot = manageRoot[strategist];
Expand All @@ -97,6 +98,7 @@ contract ManagerWithMerkleVerification is Auth {

/**
* @notice Pause this contract, which prevents future calls to `manageVaultWithMerkleVerification`.
* @dev Callable by MULTISIG_ROLE.
*/
function pause() external requiresAuth {
isPaused = true;
Expand All @@ -105,6 +107,7 @@ contract ManagerWithMerkleVerification is Auth {

/**
* @notice Unpause this contract, which allows future calls to `manageVaultWithMerkleVerification`.
* @dev Callable by MULTISIG_ROLE.
*/
function unpause() external requiresAuth {
isPaused = false;
Expand All @@ -116,6 +119,9 @@ contract ManagerWithMerkleVerification is Auth {
/**
* @notice Allows strategist to manage the BoringVault.
* @dev The strategist must provide a merkle proof for every call that verifiees they are allowed to make that call.
* @dev Callable by MANAGER_INTERNAL_ROLE.
* @dev Callable by STRATEGIST_ROLE.
* @dev Callable by MICRO_MANAGER_ROLE.
*/
function manageVaultWithMerkleVerification(
bytes32[][] calldata manageProofs,
Expand Down
10 changes: 10 additions & 0 deletions src/base/Roles/TellerWithMultiAssetSupport.sol
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ contract TellerWithMultiAssetSupport is Auth, BeforeTransferHook, ReentrancyGuar

/**
* @notice Pause this contract, which prevents future calls to `deposit` and `depositWithPermit`.
* @dev Callable by MULTISIG_ROLE.
*/
function pause() external requiresAuth {
isPaused = true;
Expand All @@ -137,6 +138,7 @@ contract TellerWithMultiAssetSupport is Auth, BeforeTransferHook, ReentrancyGuar

/**
* @notice Unpause this contract, which allows future calls to `deposit` and `depositWithPermit`.
* @dev Callable by MULTISIG_ROLE.
*/
function unpause() external requiresAuth {
isPaused = false;
Expand All @@ -146,6 +148,7 @@ contract TellerWithMultiAssetSupport is Auth, BeforeTransferHook, ReentrancyGuar
/**
* @notice Adds this asset as a deposit asset.
* @dev The accountant must also support pricing this asset, else the `deposit` call will revert.
* @dev Callable by OWNER_ROLE.
*/
function addAsset(ERC20 asset) external requiresAuth {
isSupported[asset] = true;
Expand All @@ -154,6 +157,7 @@ contract TellerWithMultiAssetSupport is Auth, BeforeTransferHook, ReentrancyGuar

/**
* @notice Removes this asset as a deposit asset.
* @dev Callable by OWNER_ROLE.
*/
function removeAsset(ERC20 asset) external requiresAuth {
isSupported[asset] = false;
Expand All @@ -163,6 +167,7 @@ contract TellerWithMultiAssetSupport is Auth, BeforeTransferHook, ReentrancyGuar
/**
* @notice Sets the share lock period.
* @dev This not only locks shares to the user address, but also serves as the pending deposit period, where deposits can be reverted.
* @dev Callable by OWNER_ROLE.
*/
function setShareLockPeriod(uint64 _shareLockPeriod) external requiresAuth {
if (_shareLockPeriod > MAX_SHARE_LOCK_PERIOD) revert TellerWithMultiAssetSupport__ShareLockPeriodTooLong();
Expand All @@ -187,6 +192,7 @@ contract TellerWithMultiAssetSupport is Auth, BeforeTransferHook, ReentrancyGuar
* but this contract can still be saving share lock state. In the event this happens
* deposits are still refundable if the user has not transferred their shares.
* But there is no guarantee that the user has not transferred their shares.
* @dev Callable by STRATEGIST_MULTISIG_ROLE.
*/
function refundDeposit(
uint256 nonce,
Expand Down Expand Up @@ -223,6 +229,7 @@ contract TellerWithMultiAssetSupport is Auth, BeforeTransferHook, ReentrancyGuar

/**
* @notice Allows users to deposit into the BoringVault, if this contract is not paused.
* @dev Publicly callable.
*/
function deposit(ERC20 depositAsset, uint256 depositAmount, uint256 minimumMint)
external
Expand Down Expand Up @@ -253,6 +260,7 @@ contract TellerWithMultiAssetSupport is Auth, BeforeTransferHook, ReentrancyGuar

/**
* @notice Allows users to deposit into BoringVault using permit.
* @dev Publicly callable.
*/
function depositWithPermit(
ERC20 depositAsset,
Expand Down Expand Up @@ -280,6 +288,7 @@ contract TellerWithMultiAssetSupport is Auth, BeforeTransferHook, ReentrancyGuar
/**
* @notice Allows on ramp role to deposit into this contract.
* @dev Does NOT support native deposits.
* @dev Callable by SOLVER_ROLE.
*/
function bulkDeposit(ERC20 depositAsset, uint256 depositAmount, uint256 minimumMint, address to)
external
Expand All @@ -295,6 +304,7 @@ contract TellerWithMultiAssetSupport is Auth, BeforeTransferHook, ReentrancyGuar

/**
* @notice Allows off ramp role to withdraw from this contract.
* @dev Callable by SOLVER_ROLE.
*/
function bulkWithdraw(ERC20 withdrawAsset, uint256 shareAmount, uint256 minimumAssets, address to)
external
Expand Down
2 changes: 2 additions & 0 deletions src/micro-managers/DexAggregatorUManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ contract DexAggregatorUManager is UManager {

/**
* @notice Sets the maximum allowed slippage during a swap.
* @dev Callable by MULTISIG_ROLE.
*/
function setAllowedSlippage(uint16 _allowedSlippage) external requiresAuth {
if (_allowedSlippage > MAX_SLIPPAGE) revert DexAggregatorUManager__NewSlippageTooLarge();
Expand All @@ -69,6 +70,7 @@ contract DexAggregatorUManager is UManager {
* for the router swap call
* @param decodersAndSanitizers 2 DecodersAndSanitizers one that implements ERC20 approve, and one that
* implements AggregationRouterV5.swap
* @dev Callable by STRATEGIST_ROLE.
*/
function swapWith1Inch(
bytes32[][] calldata manageProofs,
Expand Down
4 changes: 4 additions & 0 deletions src/micro-managers/DexSwapperUManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ contract DexSwapperUManager is UManager {

/**
* @notice Sets the maximum allowed slippage during a swap.
* @dev Callable by MULTISIG_ROLE.
*/
function setAllowedSlippage(uint16 _allowedSlippage) external requiresAuth {
if (_allowedSlippage > MAX_SLIPPAGE) revert DexSwapperUManager__NewSlippageTooLarge();
Expand All @@ -100,6 +101,7 @@ contract DexSwapperUManager is UManager {
* @param amountIn the amount of path[0] to swap
* @param amountOutMinimum the minimum amount of path[path.length - 1] to get out from the swap
* @param deadline the swap deadline
* @dev Callable by STRATEGIST_ROLE.
*/
function swapWithUniswapV3(
bytes32[][] calldata manageProofs,
Expand Down Expand Up @@ -178,6 +180,7 @@ contract DexSwapperUManager is UManager {
* @param funds the fund management data
* @param limit the maximum amount of assetIn to swap, or the minimum amount of assets out to receive
* @param deadline the swap deadline
* @dev Callable by STRATEGIST_ROLE.
*/
function swapWithBalancerV2(
bytes32[][] calldata manageProofs,
Expand Down Expand Up @@ -250,6 +253,7 @@ contract DexSwapperUManager is UManager {
* @param j the index of the token to swap to
* @param dx the amount of token i to swap
* @param min_dy the minimum amount of token j to receive
* @dev Callable by STRATEGIST_ROLE.
*/
function swapWithCurve(
bytes32[][] memory manageProofs,
Expand Down
3 changes: 3 additions & 0 deletions src/micro-managers/UManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ abstract contract UManager is Auth {

/**
* @notice Sets the duration of the period.
* @dev Callable by MULTISIG_ROLE.
*/
function setPeriod(uint16 _period) external requiresAuth {
emit PeriodUpdated(period, _period);
Expand All @@ -79,6 +80,7 @@ abstract contract UManager is Auth {

/**
* @notice Sets the number of calls allowed per period.
* @dev Callable by MULTISIG_ROLE.
*/
function setAllowedCallsPerPeriod(uint16 _allowedCallsPerPeriod) external requiresAuth {
emit AllowedCallsPeriodUpdated(allowedCallsPerPeriod, _allowedCallsPerPeriod);
Expand All @@ -87,6 +89,7 @@ abstract contract UManager is Auth {

/**
* @notice Allows auth to set token approvals to zero.
* @dev Callable by STRATEGIST_ROLE.
*/
function revokeTokenApproval(
bytes32[][] calldata manageProofs,
Expand Down

0 comments on commit 506e197

Please sign in to comment.