removed tax coin support
This commit is contained in:
@@ -134,6 +134,7 @@ contract PartyPlanner is IPartyPlanner {
|
||||
for (uint256 i = 0; i < _tokens.length; i++) {
|
||||
if (initialDeposits[i] > 0) {
|
||||
IERC20(_tokens[i]).safeTransferFrom(payer, address(pool), initialDeposits[i]);
|
||||
require(IERC20(_tokens[i]).balanceOf(address(pool)) == initialDeposits[i], 'fee-on-transfer tokens not supported');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -87,12 +87,12 @@ contract PartyPoolMintImpl is PartyPoolBase {
|
||||
unchecked { i++; }
|
||||
}
|
||||
|
||||
// Update cached balances for all assets
|
||||
// Update cached balances and internal q for all assets using depositAmounts
|
||||
int128[] memory newQInternal = new int128[](n);
|
||||
for (uint i = 0; i < n; ) {
|
||||
uint256 bal = IERC20(tokens[i]).balanceOf(address(this));
|
||||
cachedUintBalances[i] = bal;
|
||||
newQInternal[i] = _uintToInternalFloor(bal, bases[i]);
|
||||
uint256 newBal = cachedUintBalances[i] + depositAmounts[i];
|
||||
cachedUintBalances[i] = newBal;
|
||||
newQInternal[i] = _uintToInternalFloor(newBal, bases[i]);
|
||||
unchecked { i++; }
|
||||
}
|
||||
|
||||
@@ -105,7 +105,6 @@ contract PartyPoolMintImpl is PartyPoolBase {
|
||||
uint256 newScaled = ABDKMath64x64.mulu(newTotal, LP_SCALE);
|
||||
uint256 actualLpToMint;
|
||||
|
||||
require(oldScaled > 0, "mint: oldScaled zero");
|
||||
uint256 delta = (newScaled > oldScaled) ? (newScaled - oldScaled) : 0;
|
||||
// Proportional issuance: totalSupply * delta / oldScaled
|
||||
if (delta > 0) {
|
||||
@@ -143,15 +142,8 @@ contract PartyPoolMintImpl is PartyPoolBase {
|
||||
|
||||
uint256 supply = _totalSupply;
|
||||
require(supply > 0, "burn: empty supply");
|
||||
require(lmsr.nAssets > 0, "burn: uninit pool");
|
||||
require(_balances[payer] >= lpAmount, "burn: insufficient LP");
|
||||
|
||||
// Refresh cached balances to reflect current on-chain balances before computing withdrawal amounts
|
||||
for (uint i = 0; i < n; ) {
|
||||
uint256 bal = IERC20(tokens[i]).balanceOf(address(this));
|
||||
cachedUintBalances[i] = bal;
|
||||
unchecked { i++; }
|
||||
}
|
||||
// Use cached balances; assume standard ERC20 transfers without external interference
|
||||
|
||||
// Compute proportional withdrawal amounts for the requested LP amount (rounded down)
|
||||
withdrawAmounts = burnAmounts(lpAmount, lmsr.nAssets, _totalSupply, cachedUintBalances);
|
||||
@@ -164,12 +156,12 @@ contract PartyPoolMintImpl is PartyPoolBase {
|
||||
unchecked { i++; }
|
||||
}
|
||||
|
||||
// Update cached balances and internal q for all assets
|
||||
// Update cached balances and internal q for all assets using computed withdrawals
|
||||
int128[] memory newQInternal = new int128[](n);
|
||||
for (uint i = 0; i < n; ) {
|
||||
uint256 bal = IERC20(tokens[i]).balanceOf(address(this));
|
||||
cachedUintBalances[i] = bal;
|
||||
newQInternal[i] = _uintToInternalFloor(bal, bases[i]);
|
||||
uint256 newBal = cachedUintBalances[i] - withdrawAmounts[i];
|
||||
cachedUintBalances[i] = newBal;
|
||||
newQInternal[i] = _uintToInternalFloor(newBal, bases[i]);
|
||||
unchecked { i++; }
|
||||
}
|
||||
|
||||
@@ -192,7 +184,7 @@ contract PartyPoolMintImpl is PartyPoolBase {
|
||||
// Burn exactly the requested LP amount from payer (authorization via allowance)
|
||||
if (msg.sender != payer) {
|
||||
uint256 allowed = _allowances[payer][msg.sender];
|
||||
require(allowed >= lpAmount, "burn: allowance insufficient");
|
||||
// Rely on Solidity's checked arithmetic to revert on underflow if allowance is insufficient
|
||||
_approve(payer, msg.sender, allowed - lpAmount);
|
||||
}
|
||||
_burn(payer, lpAmount);
|
||||
@@ -374,25 +366,22 @@ contract PartyPoolMintImpl is PartyPoolBase {
|
||||
uint256 totalTransfer = amountInUint + feeUintActual;
|
||||
require(totalTransfer > 0 && totalTransfer <= maxAmountIn, "swapMint: transfer exceeds max");
|
||||
|
||||
// Record pre-balance and transfer tokens from payer, require exact receipt (revert on fee-on-transfer)
|
||||
uint256 prevBalI = IERC20(tokens[inputTokenIndex]).balanceOf(address(this));
|
||||
// Transfer tokens from payer (assume standard ERC20 without transfer fees)
|
||||
tokens[inputTokenIndex].safeTransferFrom(payer, address(this), totalTransfer);
|
||||
uint256 balIAfter = IERC20(tokens[inputTokenIndex]).balanceOf(address(this));
|
||||
require(balIAfter == prevBalI + totalTransfer, "swapMint: non-standard tokenIn");
|
||||
|
||||
// Accrue protocol share (floor) from the fee on the input token
|
||||
uint256 protoShare = 0;
|
||||
if (protocolFeePpm > 0 && feeUintActual > 0) {
|
||||
uint256 protoShare = (feeUintActual * protocolFeePpm) / 1_000_000;
|
||||
protoShare = (feeUintActual * protocolFeePpm) / 1_000_000;
|
||||
if (protoShare > 0) {
|
||||
protocolFeesOwed[inputTokenIndex] += protoShare;
|
||||
}
|
||||
}
|
||||
// Update cached balance for the input token to effective onchain - owed
|
||||
_recordCachedBalance(inputTokenIndex, balIAfter);
|
||||
// Update cached effective balance directly: add totalTransfer minus protocol share
|
||||
cachedUintBalances[inputTokenIndex] += (totalTransfer - protoShare);
|
||||
|
||||
// Compute old and new scaled size metrics to determine LP minted
|
||||
int128 oldTotal = _computeSizeMetric(lmsr.qInternal);
|
||||
require(oldTotal > int128(0), "swapMint: zero total");
|
||||
uint256 oldScaled = ABDKMath64x64.mulu(oldTotal, LP_SCALE);
|
||||
|
||||
int128 newTotal = oldTotal.add(sizeIncreaseInternal);
|
||||
@@ -405,7 +394,6 @@ contract PartyPoolMintImpl is PartyPoolBase {
|
||||
// If somehow supply zero (shouldn't happen as lmsr.nAssets>0), mint newScaled
|
||||
actualLpToMint = newScaled;
|
||||
} else {
|
||||
require(oldScaled > 0, "swapMint: oldScaled zero");
|
||||
uint256 delta = (newScaled > oldScaled) ? (newScaled - oldScaled) : 0;
|
||||
if (delta > 0) {
|
||||
// floor truncation rounds in favor of pool
|
||||
@@ -499,7 +487,6 @@ contract PartyPoolMintImpl is PartyPoolBase {
|
||||
|
||||
uint256 supply = _totalSupply;
|
||||
require(supply > 0, "burnSwap: empty supply");
|
||||
require(_balances[payer] >= lpAmount, "burnSwap: insufficient LP");
|
||||
|
||||
// alpha = lpAmount / supply as Q64.64 (adjusted for fee)
|
||||
int128 alpha = ABDKMath64x64.divu(lpAmount, supply) // fraction of total supply to burn
|
||||
@@ -519,8 +506,9 @@ contract PartyPoolMintImpl is PartyPoolBase {
|
||||
uint256 feeTokenUint = (payoutGrossUint > amountOutUint) ? (payoutGrossUint - amountOutUint) : 0;
|
||||
|
||||
// Accrue protocol share (floor) from the token-side fee
|
||||
uint256 protoShare = 0;
|
||||
if (protocolFeePpm > 0 && feeTokenUint > 0) {
|
||||
uint256 protoShare = (feeTokenUint * protocolFeePpm) / 1_000_000;
|
||||
protoShare = (feeTokenUint * protocolFeePpm) / 1_000_000;
|
||||
if (protoShare > 0) {
|
||||
protocolFeesOwed[inputTokenIndex] += protoShare;
|
||||
}
|
||||
@@ -532,18 +520,20 @@ contract PartyPoolMintImpl is PartyPoolBase {
|
||||
// Burn LP tokens from payer (authorization via allowance)
|
||||
if (msg.sender != payer) {
|
||||
uint256 allowed = _allowances[payer][msg.sender];
|
||||
require(allowed >= lpAmount, "burnSwap: allowance insufficient");
|
||||
_approve(payer, msg.sender, allowed - lpAmount);
|
||||
}
|
||||
_burn(payer, lpAmount);
|
||||
|
||||
// Update cached balances by reading on-chain balances for all tokens
|
||||
// Update cached balances using computed payout and protocol fee; no on-chain reads
|
||||
int128[] memory newQInternal = new int128[](n);
|
||||
for (uint256 idx = 0; idx < n; idx++) {
|
||||
uint256 bal = IERC20(tokens[idx]).balanceOf(address(this));
|
||||
cachedUintBalances[idx] = bal;
|
||||
_recordCachedBalance(inputTokenIndex, bal);
|
||||
newQInternal[idx] = _uintToInternalFloor(bal, bases[idx]);
|
||||
uint256 newBal = cachedUintBalances[idx];
|
||||
if (idx == inputTokenIndex) {
|
||||
// Effective LP balance decreases by net payout and increased protocol owed
|
||||
newBal = newBal - amountOutUint - protoShare;
|
||||
}
|
||||
cachedUintBalances[idx] = newBal;
|
||||
newQInternal[idx] = _uintToInternalFloor(newBal, bases[idx]);
|
||||
}
|
||||
|
||||
// Emit BurnSwap with public-facing info only (do not expose ΔS or LP burned)
|
||||
|
||||
Reference in New Issue
Block a user