burnSwap fees

This commit is contained in:
tim
2025-09-29 16:10:30 -04:00
parent 28b9474363
commit 91e6a916ac

View File

@@ -45,8 +45,6 @@ contract PartyPoolSwapMintImpl is PartyPoolBase {
require(inputTokenIndex < n, "swapMint: idx"); require(inputTokenIndex < n, "swapMint: idx");
require(maxAmountIn > 0, "swapMint: input zero"); require(maxAmountIn > 0, "swapMint: input zero");
require(deadline == 0 || block.timestamp <= deadline, "swapMint: deadline"); require(deadline == 0 || block.timestamp <= deadline, "swapMint: deadline");
// Ensure pool initialized
require(lmsr.nAssets > 0, "swapMint: uninit pool"); require(lmsr.nAssets > 0, "swapMint: uninit pool");
// compute fee on gross maxAmountIn to get an initial net estimate (we'll recompute based on actual used) // compute fee on gross maxAmountIn to get an initial net estimate (we'll recompute based on actual used)
@@ -136,7 +134,6 @@ contract PartyPoolSwapMintImpl is PartyPoolBase {
/// @param deadline optional deadline /// @param deadline optional deadline
/// @param swapFeePpm fee in parts-per-million for this pool (may be used for future fee logic) /// @param swapFeePpm fee in parts-per-million for this pool (may be used for future fee logic)
/// @return amountOutUint uint amount of asset i sent to receiver /// @return amountOutUint uint amount of asset i sent to receiver
// todo fee!?
function burnSwap( function burnSwap(
address payer, address payer,
address receiver, address receiver,
@@ -155,7 +152,8 @@ contract PartyPoolSwapMintImpl is PartyPoolBase {
require(balanceOf(payer) >= lpAmount, "burnSwap: insufficient LP"); require(balanceOf(payer) >= lpAmount, "burnSwap: insufficient LP");
// alpha = lpAmount / supply as Q64.64 // alpha = lpAmount / supply as Q64.64
int128 alpha = ABDKMath64x64.divu(lpAmount, supply); int128 alpha = ABDKMath64x64.divu(lpAmount, supply) // fraction of total supply to burn
.mul(ABDKMath64x64.divu(1000000-swapFeePpm, 1000000)); // adjusted for fee
// Use LMSR view to compute single-asset payout and burned size-metric // Use LMSR view to compute single-asset payout and burned size-metric
(int128 payoutInternal, ) = lmsr.swapAmountsForBurn(inputTokenIndex, alpha); (int128 payoutInternal, ) = lmsr.swapAmountsForBurn(inputTokenIndex, alpha);