diff --git a/.github/workflows/fmt.yml b/.github/workflows/fmt.yml new file mode 100644 index 0000000..b38c255 --- /dev/null +++ b/.github/workflows/fmt.yml @@ -0,0 +1,33 @@ +name: forge fmt + +on: + workflow_dispatch: + pull_request: + push: + branches: + - master + +env: + FOUNDRY_PROFILE: ci + +jobs: + check: + strategy: + fail-fast: true + + name: Foundry project + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Install Foundry + uses: foundry-rs/foundry-toolchain@v1 + with: + version: nightly + + - name: Run formatter + run: | + forge fmt --check + id: fmt diff --git a/src/PublicAllocator.sol b/src/PublicAllocator.sol index 51e366c..f34bc4d 100644 --- a/src/PublicAllocator.sol +++ b/src/PublicAllocator.sol @@ -61,6 +61,42 @@ contract PublicAllocator is IPublicAllocatorStaticTyping { MORPHO = IMorpho(morpho); } + /* OWNER ONLY */ + + /// @inheritdoc IPublicAllocatorBase + function setOwner(address vault, address newOwner) external onlyOwner(vault) { + if (owner[vault] == newOwner) revert ErrorsLib.AlreadySet(); + owner[vault] = newOwner; + emit EventsLib.SetOwner(vault, newOwner); + } + + /// @inheritdoc IPublicAllocatorBase + function setFee(address vault, uint256 newFee) external onlyOwner(vault) { + if (fee[vault] == newFee) revert ErrorsLib.AlreadySet(); + fee[vault] = newFee; + emit EventsLib.SetFee(vault, newFee); + } + + /// @inheritdoc IPublicAllocatorBase + function setFlowCaps(address vault, FlowCapsConfig[] calldata config) external onlyOwner(vault) { + for (uint256 i = 0; i < config.length; i++) { + if (config[i].caps.maxIn > MAX_SETTABLE_FLOW_CAP || config[i].caps.maxOut > MAX_SETTABLE_FLOW_CAP) { + revert ErrorsLib.MaxSettableFlowCapExceeded(); + } + flowCaps[vault][config[i].id] = config[i].caps; + } + + emit EventsLib.SetFlowCaps(vault, config); + } + + /// @inheritdoc IPublicAllocatorBase + function transferFee(address vault, address payable feeRecipient) external onlyOwner(vault) { + uint256 claimed = accruedFee[vault]; + accruedFee[vault] = 0; + feeRecipient.transfer(claimed); + emit EventsLib.TransferFee(vault, claimed, feeRecipient); + } + /* PUBLIC */ /// @inheritdoc IPublicAllocatorBase @@ -111,40 +147,4 @@ contract PublicAllocator is IPublicAllocatorStaticTyping { emit EventsLib.PublicReallocateTo(msg.sender, vault, supplyMarketId, totalWithdrawn); } - - /* OWNER ONLY */ - - /// @inheritdoc IPublicAllocatorBase - function setOwner(address vault, address newOwner) external onlyOwner(vault) { - if (owner[vault] == newOwner) revert ErrorsLib.AlreadySet(); - owner[vault] = newOwner; - emit EventsLib.SetOwner(vault, newOwner); - } - - /// @inheritdoc IPublicAllocatorBase - function setFee(address vault, uint256 newFee) external onlyOwner(vault) { - if (fee[vault] == newFee) revert ErrorsLib.AlreadySet(); - fee[vault] = newFee; - emit EventsLib.SetFee(vault, newFee); - } - - /// @inheritdoc IPublicAllocatorBase - function transferFee(address vault, address payable feeRecipient) external onlyOwner(vault) { - uint256 claimed = accruedFee[vault]; - accruedFee[vault] = 0; - feeRecipient.transfer(claimed); - emit EventsLib.TransferFee(vault, claimed, feeRecipient); - } - - /// @inheritdoc IPublicAllocatorBase - function setFlowCaps(address vault, FlowCapsConfig[] calldata config) external onlyOwner(vault) { - for (uint256 i = 0; i < config.length; i++) { - if (config[i].caps.maxIn > MAX_SETTABLE_FLOW_CAP || config[i].caps.maxOut > MAX_SETTABLE_FLOW_CAP) { - revert ErrorsLib.MaxSettableFlowCapExceeded(); - } - flowCaps[vault][config[i].id] = config[i].caps; - } - - emit EventsLib.SetFlowCaps(vault, config); - } } diff --git a/src/interfaces/IPublicAllocator.sol b/src/interfaces/IPublicAllocator.sol index f1f441f..275062c 100644 --- a/src/interfaces/IPublicAllocator.sol +++ b/src/interfaces/IPublicAllocator.sol @@ -100,6 +100,7 @@ interface IPublicAllocatorStaticTyping is IPublicAllocatorBase { /// @dev Use this interface for PublicAllocator to have access to all the functions with the appropriate function /// signatures. interface IPublicAllocator is IPublicAllocatorBase { - /// @notice Returns the maximum inflow and maximum outflow through public allocation of a given market for a given vault. + /// @notice Returns the maximum inflow and maximum outflow through public allocation of a given market for a given + /// vault. function flowCaps(address vault, Id) external view returns (FlowCaps memory); }