# Delegate architecture forces users to set zero slippage

Juicebox JBXBuybackDelegate returns zero weight on swap path, forcing users to set _minReturnedTokens to zero and disabling slippage protection on the mint path.

- Payout: Audit contest
- Severity: medium
- Program: Juicebox
- Found by: adriro
- Disclosed: 2023-07-26
- Write-up quality: 6/10
- Original: https://code4rena.com/reports/2023-05-juicebox#m-01
- Library page: https://bugbountylibrary.com/r/c4%3A2023-05-juicebox%3AM-01
- Tags: area:web3 domain:web3 impact:funds-loss kind:contest platform:code4rena sev:medium tech:evm tech:solidity vuln:business-logic

**Target:** JBXBuybackDelegate.payParams / JBPayoutRedemptionPaymentTerminal3_1.pay
**Root cause:** payParams returns weight=0 when choosing the swap path so the terminal mints nothing, making beneficiaryTokenCount zero; since the path is resolved at tx time, any nonzero _minReturnedTokens reverts the swap path, forcing users to set it to zero and lose the mint-path slippage check.
**Steps:**
1. User calls terminal pay() with metadata encoding quote and slippage, and _minReturnedTokens.
2. payParams computes _tokenCount = amount*weight/1e18 and decodes (_quote, _slippage) from metadata.
3. If _tokenCount < _quote - (_quote*_slippage/DENOM), delegate returns weight 0 and a delegateAllocation (swap path).
4. Terminal computes tokenCount=0, mints nothing, beneficiaryTokenCount=0, then checks `if (beneficiaryTokenCount < _minReturnedTokens) revert INADEQUATE_TOKEN_COUNT()`.
5. Any nonzero _minReturnedTokens reverts the swap path; setting it to zero disables the check on the vanilla mint path.
**How found:** Code review of payParams return values and tracing weight=0 through recordPaymentFrom into the terminal's beneficiaryTokenCount check, noticing the two paths conflict on _minReturnedTokens.
**Insight:** When a delegate can return weight=0 to suppress minting, trace how downstream min-output checks consume the resulting zero tokenCount; any shared slippage parameter across mutually exclusive paths becomes unusable.

