more gas optimization; protocol fee enabled by default in tests

This commit is contained in:
tim
2025-10-14 14:53:22 -04:00
parent dd009cb561
commit eab01554e1
5 changed files with 53 additions and 48 deletions

View File

@@ -87,9 +87,12 @@ contract PartyPoolSwapImpl is PartyPoolBase {
}
}
// Update caches to effective balances
_recordCachedBalance(inputTokenIndex, balIAfter);
_recordCachedBalance(outputTokenIndex, balJAfter);
// Update caches to effective balances (inline _recordCachedBalance)
require(balIAfter >= protocolFeesOwed[inputTokenIndex], "balance < protocol owed");
cachedUintBalances[inputTokenIndex] = balIAfter - protocolFeesOwed[inputTokenIndex];
require(balJAfter >= protocolFeesOwed[outputTokenIndex], "balance < protocol owed");
cachedUintBalances[outputTokenIndex] = balJAfter - protocolFeesOwed[outputTokenIndex];
// Apply swap to LMSR state with the internal amounts
lmsr.applySwap(inputTokenIndex, outputTokenIndex, amountInInternalMax, amountOutInternal);