Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/fmt.yml
Original file line number Diff line number Diff line change
@@ -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
72 changes: 36 additions & 36 deletions src/PublicAllocator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
}
3 changes: 2 additions & 1 deletion src/interfaces/IPublicAllocator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}