https://github.com/OpenEdenHQ/openeden.usdoexpress.audit/tree/f3f31d2ac15e3253cba342229f9d05495f95d6fd
In contract LiquidityController there is '''solidity function setUserQuota(address user, uint256 quota) external onlyOwner { uint256 oldQuota = userQuotas[user]; uint256 usedQuota = usedQuotas[user];
// Update total allocated accounting
if (oldQuota > 0) {
totalAllocated = totalAllocated - oldQuota;
}
if (quota > 0) {
// Check that new quota isn't less than already used amount
if (quota < usedQuota) {
revert QuotaExceedsUsed(quota, usedQuota);
}
// Check if new allocation fits within total liquidity
if (totalAllocated + quota > totalLiquidity) {
revert QuotaExceedsTotal(quota, totalLiquidity - totalAllocated);
}
totalAllocated = totalAllocated + quota;
// Add to users array if new user
if (!authorizedUsers[user]) {
users.push(user);
authorizedUsers[user] = true;
}
} else {
// Removing quota - also clear used quota
authorizedUsers[user] = false;
if (usedQuota > 0) {
totalUsed = totalUsed - usedQuota;
usedQuotas[user] = 0;
}
}
userQuotas[user] = quota;
emit QuotaSet(user, quota);
}
''' // Removing quota - also clear used quota Root Cause: When the owner sets a user's quota to zero (effectively removing them), the function incorrectly:
This breaks the fundamental accounting invariant that totalUsed must always represent actual consumed liquidity from the pool. The consumed liquidity doesn't magically return to the pool when a quota is removed—it's already been spent/redeemed.
Impact:
Recommended Fix: '''solidity function setUserQuota(address user, uint256 quota) external onlyOwner { uint256 oldQuota = userQuotas[user]; uint256 usedQuota = usedQuotas[user];
// Update total allocated accounting
if (oldQuota > 0) {
totalAllocated = totalAllocated - oldQuota;
}
if (quota > 0) {
// Check that new quota isn't less than already used amount
if (quota < usedQuota) {
revert QuotaExceedsUsed(quota, usedQuota);
}
// Check if new allocation fits within total liquidity
if (totalAllocated + quota > totalLiquidity) {
revert QuotaExceedsTotal(quota, totalLiquidity - totalAllocated);
}
totalAllocated = totalAllocated + quota;
// Add to users array if new user
if (!authorizedUsers[user]) {
users.push(user);
authorizedUsers[user] = true;
}
} else {
// ✅ FIX: Removing quota - require no outstanding consumption
if (usedQuota > 0) {
revert CannotRemoveQuotaWithActiveConsumption(user, usedQuota);
}
authorizedUsers[user] = false;
// DO NOT modify totalUsed - it represents actual consumption
// DO NOT modify usedQuotas[user] - keep consumption record
}
userQuotas[user] = quota;
emit QuotaSet(user, quota);
} '''
Attachments are hidden
This information is not publicly available.
Comments are hidden
This information is not publicly available.