event changes: SwapMint/BurnSwap replace rather than augment the regular Mint/Burn events; All swapping events have lpFee and protocolFee

This commit is contained in:
tim
2025-10-21 14:42:40 -04:00
parent 11ae6f2a4b
commit 538f778f51
4 changed files with 54 additions and 31 deletions

View File

@@ -74,18 +74,21 @@ contract PartyPoolSwapImpl is PartyPoolBase {
_quoteSwapToLimit(inputTokenIndex, outputTokenIndex, limitPrice, swapFeePpm);
// Transfer the exact amount needed from payer and require exact receipt (revert on fee-on-transfer)
_receiveTokenFrom(payer, _tokens[inputTokenIndex], totalTransferAmount);
uint256 balIAfter = IERC20(_tokens[inputTokenIndex]).balanceOf(address(this));
IERC20 tokenIn = _tokens[inputTokenIndex];
_receiveTokenFrom(payer, tokenIn, totalTransferAmount);
uint256 balIAfter = tokenIn.balanceOf(address(this));
require(balIAfter == prevBalI + totalTransferAmount, "swapToLimit: non-standard tokenIn");
// Transfer output to receiver and verify exact decrease
_sendTokenTo(_tokens[outputTokenIndex], receiver, amountOutUint, unwrap);
uint256 balJAfter = IERC20(_tokens[outputTokenIndex]).balanceOf(address(this));
IERC20 tokenOut = _tokens[outputTokenIndex];
_sendTokenTo(tokenOut, receiver, amountOutUint, unwrap);
uint256 balJAfter = IERC20(tokenOut).balanceOf(address(this));
require(balJAfter == prevBalJ - amountOutUint, "swapToLimit: non-standard tokenOut");
// Accrue protocol share (floor) from the fee on input token
uint256 protoShare = 0;
if (protocolFeePpm > 0 && feeUint > 0 ) {
uint256 protoShare = (feeUint * protocolFeePpm) / 1_000_000; // floor
protoShare = (feeUint * protocolFeePpm) / 1_000_000; // floor
if (protoShare > 0) {
_protocolFeesOwed[inputTokenIndex] += protoShare;
}
@@ -102,7 +105,8 @@ contract PartyPoolSwapImpl is PartyPoolBase {
_lmsr.applySwap(inputTokenIndex, outputTokenIndex, amountInInternalMax, amountOutInternal);
// Maintain original event semantics (logs input without fee)
emit IPartyPool.Swap(payer, receiver, _tokens[inputTokenIndex], _tokens[outputTokenIndex], amountInUsedUint, amountOutUint);
emit IPartyPool.Swap(payer, receiver, tokenIn, tokenOut,
amountInUsedUint, amountOutUint, feeUint-protoShare, protoShare);
return (amountInUsedUint, amountOutUint, feeUint);
}
@@ -164,6 +168,7 @@ contract PartyPoolSwapImpl is PartyPoolBase {
// transfer owed _tokens to protocol destination via centralized helper
_sendTokenTo(_tokens[i], dest, owed, false);
}
emit IPartyPool.ProtocolFeesCollected();
}
}