native currency fixes
This commit is contained in:
@@ -151,7 +151,7 @@ contract PartyPool is PartyPoolBase, ERC20External, IPartyPool {
|
||||
---------------------- */
|
||||
|
||||
/// @inheritdoc IPartyPool
|
||||
function initialMint(address receiver, uint256 lpTokens) external
|
||||
function initialMint(address receiver, uint256 lpTokens) external payable
|
||||
returns (uint256 lpMinted) {
|
||||
bytes memory data = abi.encodeWithSelector(
|
||||
PartyPoolMintImpl.initialMint.selector,
|
||||
@@ -169,7 +169,7 @@ contract PartyPool is PartyPoolBase, ERC20External, IPartyPool {
|
||||
/// @param receiver address that receives the LP tokens
|
||||
/// @param lpTokenAmount desired amount of LP tokens to mint
|
||||
/// @param deadline timestamp after which the transaction will revert. Pass 0 to ignore.
|
||||
function mint(address payer, address receiver, uint256 lpTokenAmount, uint256 deadline) external
|
||||
function mint(address payer, address receiver, uint256 lpTokenAmount, uint256 deadline) external payable
|
||||
returns (uint256 lpMinted) {
|
||||
bytes memory data = abi.encodeWithSelector(
|
||||
PartyPoolMintImpl.mint.selector,
|
||||
@@ -182,20 +182,16 @@ contract PartyPool is PartyPoolBase, ERC20External, IPartyPool {
|
||||
return abi.decode(result, (uint256));
|
||||
}
|
||||
|
||||
/// @notice Burn LP tokens and withdraw the proportional basket to receiver.
|
||||
/// @dev This function forwards the call to the burn implementation via delegatecall
|
||||
/// @param payer address that provides the LP tokens to burn
|
||||
/// @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
|
||||
/// @inheritdoc IPartyPool
|
||||
function burn(address payer, address receiver, uint256 lpAmount, uint256 deadline, bool unwrap) external
|
||||
returns (uint256[] memory withdrawAmounts) {
|
||||
bytes memory data = abi.encodeWithSelector(
|
||||
PartyPoolMintImpl.burn.selector,
|
||||
payer,
|
||||
receiver,
|
||||
lpAmount,
|
||||
deadline
|
||||
deadline,
|
||||
unwrap
|
||||
);
|
||||
bytes memory result = Address.functionDelegateCall(address(MINT_IMPL), data);
|
||||
return abi.decode(result, (uint256[]));
|
||||
@@ -223,8 +219,9 @@ contract PartyPool is PartyPoolBase, ERC20External, IPartyPool {
|
||||
uint256 outputTokenIndex,
|
||||
uint256 maxAmountIn,
|
||||
int128 limitPrice,
|
||||
uint256 deadline
|
||||
) external payable nonReentrant returns (uint256 amountIn, uint256 amountOut, uint256 fee) {
|
||||
uint256 deadline,
|
||||
bool unwrap
|
||||
) external payable native nonReentrant returns (uint256 amountIn, uint256 amountOut, uint256 fee) {
|
||||
require(deadline == 0 || block.timestamp <= deadline, "swap: deadline exceeded");
|
||||
|
||||
// Compute amounts using the same path as views
|
||||
@@ -243,7 +240,7 @@ contract PartyPool is PartyPoolBase, ERC20External, IPartyPool {
|
||||
uint256 balJAfter = cachedUintBalances[outputTokenIndex] + protocolFeesOwed[outputTokenIndex] - amountOutUint;
|
||||
|
||||
// Transfer output to receiver via centralized helper
|
||||
_sendTokenTo(tokenOut, receiver, amountOutUint);
|
||||
_sendTokenTo(tokenOut, receiver, amountOutUint, unwrap);
|
||||
|
||||
// Accrue protocol share (floor) from the fee on input token
|
||||
if (PROTOCOL_FEE_PPM > 0 && feeUint > 0) {
|
||||
@@ -265,8 +262,6 @@ contract PartyPool is PartyPoolBase, ERC20External, IPartyPool {
|
||||
|
||||
emit Swap(payer, receiver, tokenIn, tokenOut, totalTransferAmount, amountOutUint);
|
||||
|
||||
_refund();
|
||||
|
||||
return (totalTransferAmount, amountOutUint, feeUint);
|
||||
}
|
||||
|
||||
@@ -302,6 +297,7 @@ contract PartyPool is PartyPoolBase, ERC20External, IPartyPool {
|
||||
require(deltaInternalI > int128(0), "swap: input too small after fee");
|
||||
|
||||
// Compute internal amounts using LMSR (exact-input with price limit)
|
||||
// use the virtual method call so that the balanced pair optimization can override
|
||||
(amountInInternalUsed, amountOutInternal) = _swapAmountsForExactInput(inputTokenIndex, outputTokenIndex, deltaInternalI, limitPrice);
|
||||
|
||||
// Convert actual used input internal -> uint (ceil)
|
||||
@@ -330,7 +326,8 @@ contract PartyPool is PartyPoolBase, ERC20External, IPartyPool {
|
||||
uint256 inputTokenIndex,
|
||||
uint256 outputTokenIndex,
|
||||
int128 limitPrice,
|
||||
uint256 deadline
|
||||
uint256 deadline,
|
||||
bool unwrap
|
||||
) external payable returns (uint256 amountInUsed, uint256 amountOut, uint256 fee) {
|
||||
bytes memory data = abi.encodeWithSelector(
|
||||
PartyPoolSwapImpl.swapToLimit.selector,
|
||||
@@ -340,6 +337,7 @@ contract PartyPool is PartyPoolBase, ERC20External, IPartyPool {
|
||||
outputTokenIndex,
|
||||
limitPrice,
|
||||
deadline,
|
||||
unwrap,
|
||||
SWAP_FEE_PPM,
|
||||
PROTOCOL_FEE_PPM
|
||||
);
|
||||
@@ -391,7 +389,8 @@ contract PartyPool is PartyPoolBase, ERC20External, IPartyPool {
|
||||
address receiver,
|
||||
uint256 lpAmount,
|
||||
uint256 inputTokenIndex,
|
||||
uint256 deadline
|
||||
uint256 deadline,
|
||||
bool unwrap
|
||||
) external returns (uint256 amountOutUint) {
|
||||
bytes memory data = abi.encodeWithSelector(
|
||||
PartyPoolMintImpl.burnSwap.selector,
|
||||
@@ -400,6 +399,7 @@ contract PartyPool is PartyPoolBase, ERC20External, IPartyPool {
|
||||
lpAmount,
|
||||
inputTokenIndex,
|
||||
deadline,
|
||||
unwrap,
|
||||
SWAP_FEE_PPM,
|
||||
PROTOCOL_FEE_PPM
|
||||
);
|
||||
@@ -438,7 +438,7 @@ contract PartyPool is PartyPoolBase, ERC20External, IPartyPool {
|
||||
}
|
||||
}
|
||||
|
||||
_sendTokenTo(token, address(receiver), amount);
|
||||
_sendTokenTo(token, address(receiver), amount, false);
|
||||
require(receiver.onFlashLoan(msg.sender, address(token), amount, fee, data) == FLASH_CALLBACK_SUCCESS);
|
||||
_receiveTokenFrom(address(receiver), token, amount + fee);
|
||||
|
||||
@@ -466,7 +466,7 @@ contract PartyPool is PartyPoolBase, ERC20External, IPartyPool {
|
||||
require(bal >= owed, "collect: fee > bal");
|
||||
protocolFeesOwed[i] = 0;
|
||||
// transfer owed tokens to protocol destination via centralized helper
|
||||
_sendTokenTo(tokens[i], dest, owed);
|
||||
_sendTokenTo(tokens[i], dest, owed, false);
|
||||
// update cached to effective onchain minus owed
|
||||
cachedUintBalances[i] = bal - owed;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user