From 743cfa1db1635333baaa95167bb8b8c1c4fd0df0 Mon Sep 17 00:00:00 2001 From: MathisGD Date: Tue, 20 Feb 2024 14:01:56 +0100 Subject: [PATCH 1/4] refactor: reorder functions --- src/PublicAllocator.sol | 73 +++++++++++++++++++++-------------------- 1 file changed, 37 insertions(+), 36 deletions(-) diff --git a/src/PublicAllocator.sol b/src/PublicAllocator.sol index 51e366c..448b84d 100644 --- a/src/PublicAllocator.sol +++ b/src/PublicAllocator.sol @@ -61,6 +61,43 @@ 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 +148,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); - } } From b478ec47be866b1e965c82b9153ba61df78066d9 Mon Sep 17 00:00:00 2001 From: MathisGD Date: Tue, 20 Feb 2024 14:23:54 +0100 Subject: [PATCH 2/4] chore: fmt --- src/PublicAllocator.sol | 1 - src/interfaces/IPublicAllocator.sol | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PublicAllocator.sol b/src/PublicAllocator.sol index 448b84d..f34bc4d 100644 --- a/src/PublicAllocator.sol +++ b/src/PublicAllocator.sol @@ -77,7 +77,6 @@ contract PublicAllocator is IPublicAllocatorStaticTyping { 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++) { 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); } From e849be25293489f283b65622f978af1678639907 Mon Sep 17 00:00:00 2001 From: MathisGD Date: Tue, 20 Feb 2024 14:25:17 +0100 Subject: [PATCH 3/4] chore: fmt in ci --- .github/workflows/fmt.yml | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 .github/workflows/fmt.yml diff --git a/.github/workflows/fmt.yml b/.github/workflows/fmt.yml new file mode 100644 index 0000000..c9796c0 --- /dev/null +++ b/.github/workflows/fmt.yml @@ -0,0 +1,33 @@ +name: test + +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 From 306000462653ef218b9c6e7cfc887634be9b7c8a Mon Sep 17 00:00:00 2001 From: MathisGD <74971347+MathisGD@users.noreply.github.com> Date: Tue, 20 Feb 2024 14:35:46 +0100 Subject: [PATCH 4/4] chore: ci name Co-authored-by: Romain Milon Signed-off-by: MathisGD <74971347+MathisGD@users.noreply.github.com> --- .github/workflows/fmt.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/fmt.yml b/.github/workflows/fmt.yml index c9796c0..b38c255 100644 --- a/.github/workflows/fmt.yml +++ b/.github/workflows/fmt.yml @@ -1,4 +1,4 @@ -name: test +name: forge fmt on: workflow_dispatch: