# Problem:
It appears useSuckersCashOutQuote is overstating the amount available for cashout.
https://github.com/Bananapus/juice-sdk-v4/blob/main/packages/react/src/hooks/token/useSuckersCashOutQuote.ts
## AI transcript while debugging:
You’re asking whether useSuckersCashOutQuote is correctly aggregating redemption quotes across multiple “suckers” — and especially if it might be overstating the ETH returned.
Let’s go deep:
⸻
✅ What this hook does
1. Fetches peer chain pairs via useSuckers()
const pairs = suckersQuery.data; // [{ peerChainId, projectId }, ...]
These represent the “sucker” projects/chains tied to the current project.
⸻
2. For each sucker, it fetches a redemption quote:
const quotes = await Promise.all(
pairs?.map(({ peerChainId, projectId }) =>
getTokenRedemptionQuote(config, peerChainId, projectId, tokenAmountWei)
) ?? []
);
This calls readJbTerminalStoreCurrentReclaimableSurplusOf(...) for each one — likely reading a Juicebox V3 contract view method.
⸻
3. Aggregates all quotes:
quotes.reduce((acc, quote) => acc + quote, 0n);
Then applies the Juicebox DAO fee:
const netTotal = applyJbDaoCashOutFee(...);
⸻
🔍 Potential Problem: Overcounting
Yes, there’s a real risk of overstating the cashout if:
1. tokenAmountWei is reused for every sucker project, rather than proportionally allocated across them.
2. readJbTerminalStoreCurrentReclaimableSurplusOf(...) returns per-project surplus value, assuming exclusive token ownership.
3. Juicebox terminals aren’t aware of each other — meaning the same tokenAmountWei passed to multiple peers implies duplicated claims.
⸻
✅ Is the code aggregating correctly?
Mechanically? Yes.
• It aggregates all quote results (one per sucker).
• Then applies a single DAO fee.
Semantically? 🚨 Possibly not.
• If tokenAmountWei is meant to represent a total balance across all suckers, then it should be split proportionally before being passed into each quote call.
⸻
✅ What should probably happen
Instead of this:
// Same amount sent to each peer project
getTokenRedemptionQuote(config, peerChainId, projectId, tokenAmountWei)
You likely want this:
const proportion = peerTokenBalance / totalBalance;
const localAmount = tokenAmountWei * proportion;
getTokenRedemptionQuote(config, peerChainId, projectId, localAmount)
Where peerTokenBalance is the user’s balance on that sucker peer, and totalBalance is sum of all peer balances.
This ensures only the proportional amount is redeemed per peer, avoiding a “double claim” of tokenAmountWei across N peers.
⸻
🧠 TL;DR
| ✅ Mechanically correct? | ✅ Yes — maps, fetches, reduces |
| 🚨 Risk of overstatement? | ✅ Yes — same tokenAmountWei is used for all suckers |
| 🔧 Fix? | Proportionally divide tokenAmountWei by sucker balance share |
| 🔍 Next step? | Confirm how balances are managed per sucker in useSuckers() |
Want help adding the proportional logic to ensure it only cashes out per-peer amounts?