Skip to content

Commit 76f9baa

Browse files
committed
fix: events and docs
1 parent 1cdcee8 commit 76f9baa

File tree

4 files changed

+23
-20
lines changed

4 files changed

+23
-20
lines changed

src/PublicAllocator.sol

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,14 @@ contract PublicAllocator is IPublicAllocatorStaticTyping {
6666
function setOwner(address vault, address newOwner) external onlyOwner(vault) {
6767
if (owner[vault] == newOwner) revert ErrorsLib.AlreadySet();
6868
owner[vault] = newOwner;
69-
emit EventsLib.SetOwner(vault, newOwner);
69+
emit EventsLib.SetOwner(msg.sender, vault, newOwner);
7070
}
7171

7272
/// @inheritdoc IPublicAllocatorBase
7373
function setFee(address vault, uint256 newFee) external onlyOwner(vault) {
7474
if (fee[vault] == newFee) revert ErrorsLib.AlreadySet();
7575
fee[vault] = newFee;
76-
emit EventsLib.SetFee(vault, newFee);
76+
emit EventsLib.SetFee(msg.sender, vault, newFee);
7777
}
7878

7979
/// @inheritdoc IPublicAllocatorBase
@@ -85,15 +85,15 @@ contract PublicAllocator is IPublicAllocatorStaticTyping {
8585
flowCaps[vault][config[i].id] = config[i].caps;
8686
}
8787

88-
emit EventsLib.SetFlowCaps(vault, config);
88+
emit EventsLib.SetFlowCaps(msg.sender, vault, config);
8989
}
9090

9191
/// @inheritdoc IPublicAllocatorBase
9292
function transferFee(address vault, address payable feeRecipient) external onlyOwner(vault) {
9393
uint256 claimed = accruedFee[vault];
9494
accruedFee[vault] = 0;
9595
feeRecipient.transfer(claimed);
96-
emit EventsLib.TransferFee(vault, claimed, feeRecipient);
96+
emit EventsLib.TransferFee(msg.sender, vault, claimed, feeRecipient);
9797
}
9898

9999
/* PUBLIC */
@@ -132,7 +132,7 @@ contract PublicAllocator is IPublicAllocatorStaticTyping {
132132

133133
totalWithdrawn += withdrawnAssets;
134134

135-
emit EventsLib.PublicWithdrawal(vault, id, withdrawnAssets);
135+
emit EventsLib.PublicWithdrawal(msg.sender, vault, id, withdrawnAssets);
136136
}
137137

138138
if (flowCaps[vault][supplyMarketId].maxIn < totalWithdrawn) revert ErrorsLib.MaxInflowExceeded(supplyMarketId);

src/interfaces/IPublicAllocator.sol

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ import {
99
MarketParams
1010
} from "../../lib/metamorpho/src/interfaces/IMetaMorpho.sol";
1111

12-
/// @dev Equal to type(uint128).max/2, so flow caps can always be stored on 128 bits.
12+
/// @dev Max settable flow cap, such that they can always be stored on 128 bits.
1313
/// @dev The actual max possible flow cap is type(uint128).max-1.
14-
uint128 constant MAX_SETTABLE_FLOW_CAP = 170141183460469231731687303715884105727;
14+
/// @dev Equals to 170141183460469231731687303715884105727;
15+
uint128 constant MAX_SETTABLE_FLOW_CAP = type(uint128).max / 2;
1516

1617
struct FlowCaps {
1718
/// @notice The maximum allowed inflow in a market.
@@ -21,7 +22,9 @@ struct FlowCaps {
2122
}
2223

2324
struct FlowCapsConfig {
25+
/// @notice Market for which to change flow caps.
2426
Id id;
27+
/// @notice New flow caps for this market.
2528
FlowCaps caps;
2629
}
2730

@@ -53,7 +56,7 @@ interface IPublicAllocatorBase {
5356
/// @param withdrawals The markets to withdraw from,and the amounts to withdraw.
5457
/// @param supplyMarketParams The market receiving total withdrawn to.
5558
/// @dev Will call MetaMorpho's `reallocate`.
56-
/// @dev Checks that the public allocator constraints (flows, caps) are respected.
59+
/// @dev Checks that the flow caps are respected.
5760
/// @dev Will revert when `withdrawals` contains a duplicate or is not sorted.
5861
/// @dev Will revert if `withdrawals` contains the supply market.
5962
/// @dev Will revert if a withdrawal amount is larger than available liquidity.

src/libraries/EventsLib.sol

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,20 @@ import {FlowCapsConfig, Id} from "../interfaces/IPublicAllocator.sol";
99
/// @notice Library exposing events.
1010
library EventsLib {
1111
/// @notice Emitted during a public reallocation for each withdrawn-from market.
12-
event PublicWithdrawal(address indexed vault, Id id, uint256 withdrawnAssets);
12+
event PublicWithdrawal(address indexed sender, address indexed vault, Id id, uint256 withdrawnAssets);
1313

1414
/// @notice Emitted at the end of a public reallocation.
15-
event PublicReallocateTo(address indexed vault, address sender, Id supplyMarketId, uint256 suppliedAssets);
15+
event PublicReallocateTo(address indexed sender, address indexed vault, Id supplyMarketId, uint256 suppliedAssets);
1616

1717
/// @notice Emitted when the owner is set for a vault.
18-
event SetOwner(address indexed vault, address owner);
18+
event SetOwner(address indexed sender, address indexed vault, address indexed owner);
1919

2020
/// @notice Emitted when the owner changes the `fee` for a vault.
21-
event SetFee(address indexed vault, uint256 fee);
21+
event SetFee(address indexed sender, address indexed vault, uint256 fee);
2222

2323
/// @notice Emitted when the owner transfers the fee for a vault.
24-
event TransferFee(address indexed vault, uint256 amount, address indexed feeRecipient);
24+
event TransferFee(address indexed sender, address indexed vault, uint256 amount, address indexed feeRecipient);
2525

2626
/// @notice Emitted when the owner updates some flow caps for a vault.
27-
event SetFlowCaps(address indexed vault, FlowCapsConfig[] config);
27+
event SetFlowCaps(address indexed sender, address indexed vault, FlowCapsConfig[] config);
2828
}

test/PublicAllocatorTest.sol

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ contract PublicAllocatorTest is IntegrationTest {
141141
vm.assume(fee != publicAllocator.fee(address(vault)));
142142
vm.prank(OWNER);
143143
vm.expectEmit(address(publicAllocator));
144-
emit EventsLib.SetFee(address(vault), fee);
144+
emit EventsLib.SetFee(OWNER, address(vault), fee);
145145
publicAllocator.setFee(address(vault), fee);
146146
assertEq(publicAllocator.fee(address(vault)), fee);
147147
}
@@ -165,7 +165,7 @@ contract PublicAllocatorTest is IntegrationTest {
165165
flowCaps.push(FlowCapsConfig(allMarkets[0].id(), FlowCaps(in1, out1)));
166166

167167
vm.expectEmit(address(publicAllocator));
168-
emit EventsLib.SetFlowCaps(address(vault), flowCaps);
168+
emit EventsLib.SetFlowCaps(OWNER, address(vault), flowCaps);
169169

170170
vm.prank(OWNER);
171171
publicAllocator.setFlowCaps(address(vault), flowCaps);
@@ -202,9 +202,9 @@ contract PublicAllocatorTest is IntegrationTest {
202202
withdrawals.push(Withdrawal(allMarkets[1], flow));
203203

204204
vm.expectEmit(address(publicAllocator));
205-
emit EventsLib.PublicWithdrawal(address(vault), idleParams.id(), flow);
206-
emit EventsLib.PublicWithdrawal(address(vault), allMarkets[1].id(), flow);
207-
emit EventsLib.PublicReallocateTo(address(vault), sender, allMarkets[0].id(), 2 * flow);
205+
emit EventsLib.PublicWithdrawal(sender, address(vault), idleParams.id(), flow);
206+
emit EventsLib.PublicWithdrawal(sender, address(vault), allMarkets[1].id(), flow);
207+
emit EventsLib.PublicReallocateTo(sender, address(vault), allMarkets[0].id(), 2 * flow);
208208

209209
vm.prank(sender);
210210
publicAllocator.reallocateTo(address(vault), withdrawals.sort(), allMarkets[0]);
@@ -380,7 +380,7 @@ contract PublicAllocatorTest is IntegrationTest {
380380
}
381381

382382
function testMaxFlowCapValue() public {
383-
assertEq(MAX_SETTABLE_FLOW_CAP, type(uint128).max / 2);
383+
assertEq(MAX_SETTABLE_FLOW_CAP, 170141183460469231731687303715884105727);
384384
}
385385

386386
function testMaxFlowCapLimit(uint128 cap) public {

0 commit comments

Comments
 (0)