Fee calculators
TrustedSignerFeeCalculator.sol
TrustedSignerFeeCalculator validates signed swap fees during a pool's trusted window. The findings cover the lifetime of those windows and the trade details omitted from signed authorisations.
Reviewed source: src/calculators/TrustedSignerFeeCalculator.sol at commit 38f14ff.
Findings
| ID | Severity | Finding |
|---|---|---|
| B-05 | Medium | An unbounded trusted window makes the signer a permanent gatekeeper of sells |
| B-18 | Low | Swap authorisations bind neither direction nor amount |
[MEDIUM] B-05 · An unbounded trusted window makes the signer a permanent gatekeeper of sells
B-05 · Medium
A launcher can set a trusted window of any non-overflowing duration. It cannot be shortened, and holders need a fresh signature to sell throughout that window.
The launcher chooses the trusted duration. Neither the zap nor setTrustedUntil caps it, and the calculator refuses any second write for the pool, including a write by its owner.
Inside the window, every swap needs a fresh authorisation. Sells are included, and using an unverified router fails. A window intended to protect the opening of a launch can therefore make trading depend on the signer for an arbitrarily long period.
Impact
If the signer goes offline, is removed, or declines to sign, holders cannot sell while the window remains active. The signer does not take custody, but its availability becomes a condition for exit.
The hook owner can replace the fee calculator to recover, but that removes every pool's trusted windows at once. A compromised signer can also choose fees from zero up to the 10% cap for gated swaps.
Affected code
Locations refer to the reviewed commit, 38f14ff.
src/zaps/TrustedSignerZap.sol:174–192— Launcher-supplied durations become pool windows.src/calculators/TrustedSignerFeeCalculator.sol:71–127— Every gated swap requires an authorisation.src/calculators/TrustedSignerFeeCalculator.sol:219–241— The window is write-once and has no upper bound.
From src/calculators/TrustedSignerFeeCalculator.sol:219–237:
function setTrustedUntil(PoolId _poolId, uint _until) external {
// Validate that the caller is the owner or a trusted launch router
if (msg.sender != owner() && !trustedLaunchRouters[msg.sender]) {
revert CallerNotTrustedLaunchRouter();
}
// Validate that the trusted window is not already set
if (trustedUntil[_poolId] != 0) {
revert TrustedWindowAlreadySet();
}
// Validate that the trusted window is not in the past
// forge-lint: disable-next-line(block-timestamp)
if (_until <= block.timestamp) {
revert InvalidTrustedWindow();
}
// Set the trusted window
trustedUntil[_poolId] = _until;
Proof of concept
ZapsPoC.t.sol::test_Z02_unboundedWindowMakesSignerPermanentGatekeeperOfSells launches with a 100-year window, removes the signer and shows that a holder cannot sell. A zero-duration window, or a window that has expired, requires no signature and provides the control.
The test source is poc/ZapsPoC.t.sol in the Solidity evidence bundle. Follow the reproduction setup, then run:
FOUNDRY_GAS_LIMIT=1000000000000 forge test --match-path 'test/audit/ZapsPoC.t.sol' -vv
Recommended solution
Cap the trusted duration in setTrustedUntil, allow the owner to close a window early, and exempt sells from the signature requirement. Test signer removal and unavailability as explicit exit scenarios.
[LOW] B-18 · Swap authorisations bind neither direction nor amount
B-18 · Low
An authorisation identifies the buyer, pool, fee, nonce and deadline, but it can be used for either trade direction and any size.
The signed SwapAuthorization struct omits trade direction and amount. determineSwapFee verifies the authorisation against its signed fields but does not bind it to the swap parameters. There is also no floor requiring the authorised fee to match or exceed the base fee.
A valid signature issued for a small buy can therefore be consumed for a sell of the holder's entire balance at the same authorised fee. Nonce consumption prevents reusing the signature; it does not constrain what the first use can authorise.
Impact
A signer policy that distinguishes buys from sells, or limits the size of a fee concession, cannot be enforced by this signature format. An authorisation holder chooses a more favorable direction or size. The signature remains bound to its buyer and pool, so it does not grant control of another account.
Affected code
Locations refer to the reviewed commit, 38f14ff.
src/calculators/TrustedSignerFeeCalculator.sol:27–27— The typed data has no direction or amount fields.src/calculators/TrustedSignerFeeCalculator.sol:89–127— Authorisation checks do not compare those swap properties.
From src/calculators/TrustedSignerFeeCalculator.sol:27–27:
bytes32 internal constant SWAP_AUTHORIZATION_TYPEHASH = keccak256('SwapAuthorization(address buyer,bytes32 poolId,uint256 fee,uint256 nonce,uint256 deadline)');
Proof of concept
ZapsPoC.t.sol::test_Z06_authorizationIssuedForASmallBuyAuthorisesAnySizeAndASell issues an authorisation intended for a small buy and uses it for a sell instead. The calculator accepts the signed fee because direction and size were never part of the signed message.
The test source is poc/ZapsPoC.t.sol in the Solidity evidence bundle. Follow the reproduction setup, then run:
FOUNDRY_GAS_LIMIT=1000000000000 forge test --match-path 'test/audit/ZapsPoC.t.sol' -vv
Recommended solution
Add direction and a maximum input amount to the typed data, then compare them with the actual swap. Consider a base-fee floor if the signer is not intended to waive it. Update the signing service and domain/version handling together with the contract change.
Shared findings
- B-03 · Low: The launch-block gate can be bypassed through TrustedSignerZap — Outside a trusted window, the calculator requires no signature to use the zap's public swap path.
- B-24 · Low: Single-step ownership and renunciation can permanently freeze payouts — The calculator retains single-step ownership transfers and inherited renunciation.