This commit is contained in:
tim
2025-09-30 15:42:52 -04:00
parent 91e6a916ac
commit 5ce14ab2e1
10 changed files with 100 additions and 86 deletions

View File

@@ -13,13 +13,15 @@ import {PartyPoolMintImpl} from "./PartyPoolMintImpl.sol";
/// @notice Factory contract for creating and tracking PartyPool instances
contract PartyPlanner is IPartyPlanner {
using SafeERC20 for IERC20;
int128 private constant FIXED_ONE_64x64 = int128(1) << 64;
/// @notice Address of the SwapMint implementation contract used by all pools created by this factory
address public immutable swapMintImpl;
int128 private constant ONE = int128(1) << 64;
/// @notice Address of the Mint implementation contract used by all pools created by this factory
address public immutable mintImpl;
PartyPoolMintImpl private immutable MINT_IMPL;
function mintImpl() external view returns (PartyPoolMintImpl) { return MINT_IMPL; }
/// @notice Address of the SwapMint implementation contract used by all pools created by this factory
PartyPoolSwapMintImpl private immutable SWAP_MINT_IMPL;
function swapMintImpl() external view returns (PartyPoolSwapMintImpl) { return SWAP_MINT_IMPL; }
// On-chain pool indexing
PartyPool[] private _allPools;
@@ -32,9 +34,9 @@ contract PartyPlanner is IPartyPlanner {
/// @param _mintImpl address of the Mint implementation contract to be used by all pools
constructor(PartyPoolSwapMintImpl _swapMintImpl, PartyPoolMintImpl _mintImpl) {
require(address(_swapMintImpl) != address(0), "Planner: swapMintImpl address cannot be zero");
swapMintImpl = address(_swapMintImpl);
SWAP_MINT_IMPL = _swapMintImpl;
require(address(_mintImpl) != address(0), "Planner: mintImpl address cannot be zero");
mintImpl = address(_mintImpl);
MINT_IMPL = _mintImpl;
}
/// Main newPool variant: accepts kappa directly (preferred).
@@ -74,8 +76,8 @@ contract PartyPlanner is IPartyPlanner {
_swapFeePpm,
_flashFeePpm,
_stable,
PartyPoolSwapMintImpl(swapMintImpl),
mintImpl
PartyPoolSwapMintImpl(SWAP_MINT_IMPL),
MINT_IMPL
);
_allPools.push(pool);
@@ -130,8 +132,8 @@ contract PartyPlanner is IPartyPlanner {
uint256 deadline
) external returns (PartyPool pool, uint256 lpAmount) {
// Validate fixed-point fractions: must be less than 1.0 in 64.64 fixed-point
require(_tradeFrac < FIXED_ONE_64x64, "Planner: tradeFrac must be < 1 (64.64)");
require(_targetSlippage < FIXED_ONE_64x64, "Planner: targetSlippage must be < 1 (64.64)");
require(_tradeFrac < ONE, "Planner: tradeFrac must be < 1 (64.64)");
require(_targetSlippage < ONE, "Planner: targetSlippage must be < 1 (64.64)");
// Compute kappa from slippage params using LMSR helper (kappa depends only on n, f and s)
int128 computedKappa = LMSRStabilized.computeKappaFromSlippage(_tokens.length, _tradeFrac, _targetSlippage);