native currency fixes

This commit is contained in:
tim
2025-10-14 20:54:15 -04:00
parent 308227f251
commit 96535ed005
7 changed files with 66 additions and 60 deletions

View File

@@ -25,7 +25,7 @@ contract PartyPoolMintImpl is PartyPoolBase {
// Initialization Mint
//
function initialMint(address receiver, uint256 lpTokens, int128 KAPPA) external nonReentrant
function initialMint(address receiver, uint256 lpTokens, int128 KAPPA) external payable native nonReentrant
returns (uint256 lpMinted) {
uint256 n = tokens.length;
@@ -65,7 +65,7 @@ contract PartyPoolMintImpl is PartyPoolBase {
// Regular Mint and Burn
//
function mint(address payer, address receiver, uint256 lpTokenAmount, uint256 deadline) external payable nonReentrant
function mint(address payer, address receiver, uint256 lpTokenAmount, uint256 deadline) external payable native nonReentrant
returns (uint256 lpMinted) {
require(deadline == 0 || block.timestamp <= deadline, "mint: deadline exceeded");
uint256 n = tokens.length;
@@ -128,8 +128,6 @@ contract PartyPoolMintImpl is PartyPoolBase {
_mint(receiver, actualLpToMint);
emit IPartyPool.Mint(payer, receiver, depositAmounts, actualLpToMint);
_refund();
return actualLpToMint;
}
@@ -140,7 +138,8 @@ contract PartyPoolMintImpl is PartyPoolBase {
/// @param receiver address that receives the withdrawn tokens
/// @param lpAmount amount of LP tokens to burn (proportional withdrawal)
/// @param deadline timestamp after which the transaction will revert. Pass 0 to ignore.
function burn(address payer, address receiver, uint256 lpAmount, uint256 deadline) external nonReentrant
/// @param unwrap if true and the native token is being withdrawn, it is unwraped and sent as native currency
function burn(address payer, address receiver, uint256 lpAmount, uint256 deadline, bool unwrap) external nonReentrant
returns (uint256[] memory withdrawAmounts) {
require(deadline == 0 || block.timestamp <= deadline, "burn: deadline exceeded");
uint256 n = tokens.length;
@@ -157,7 +156,7 @@ contract PartyPoolMintImpl is PartyPoolBase {
// Transfer underlying tokens out to receiver according to computed proportions
for (uint i = 0; i < n; ) {
if (withdrawAmounts[i] > 0) {
_sendTokenTo(tokens[i], receiver, withdrawAmounts[i]);
_sendTokenTo(tokens[i], receiver, withdrawAmounts[i], unwrap);
}
unchecked { i++; }
}
@@ -346,7 +345,7 @@ contract PartyPoolMintImpl is PartyPoolBase {
uint256 deadline,
uint256 swapFeePpm,
uint256 protocolFeePpm
) external nonReentrant returns (uint256 lpMinted) {
) external payable native nonReentrant returns (uint256 lpMinted) {
uint256 n = tokens.length;
require(inputTokenIndex < n, "swapMint: idx");
require(maxAmountIn > 0, "swapMint: input zero");
@@ -483,6 +482,7 @@ contract PartyPoolMintImpl is PartyPoolBase {
uint256 lpAmount,
uint256 inputTokenIndex,
uint256 deadline,
bool unwrap,
uint256 swapFeePpm,
uint256 protocolFeePpm
) external nonReentrant returns (uint256 amountOutUint) {
@@ -521,7 +521,7 @@ contract PartyPoolMintImpl is PartyPoolBase {
}
// Transfer the payout to receiver via centralized helper
_sendTokenTo(tokens[inputTokenIndex], receiver, amountOutUint);
_sendTokenTo(tokens[inputTokenIndex], receiver, amountOutUint, unwrap);
// Burn LP tokens from payer (authorization via allowance)
if (msg.sender != payer) {