refactor PartyPoolSwapMintImpl
This commit is contained in:
@@ -6,6 +6,7 @@ import "./PartyPool.sol";
|
||||
import "./LMSRStabilized.sol";
|
||||
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
||||
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
|
||||
import {PartyPoolSwapMintImpl} from "./PartyPoolSwapMintImpl.sol";
|
||||
|
||||
/// @title PartyPlanner
|
||||
/// @notice Factory contract for creating and tracking PartyPool instances
|
||||
@@ -13,6 +14,9 @@ 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;
|
||||
|
||||
// On-chain pool indexing
|
||||
PartyPool[] private _allPools;
|
||||
IERC20[] private _allTokens;
|
||||
@@ -20,8 +24,14 @@ contract PartyPlanner is IPartyPlanner {
|
||||
mapping(IERC20 => bool) private _tokenSupported;
|
||||
mapping(IERC20 => PartyPool[]) private _poolsByToken;
|
||||
|
||||
/// Main createPool variant: accepts kappa directly (preferred).
|
||||
function createPool(
|
||||
/// @param _swapMintImpl address of the SwapMint implementation contract to be used by all pools
|
||||
constructor(PartyPoolSwapMintImpl _swapMintImpl) {
|
||||
require(address(_swapMintImpl) != address(0), "Planner: impl address cannot be zero");
|
||||
swapMintImpl = address(_swapMintImpl);
|
||||
}
|
||||
|
||||
/// Main newPool variant: accepts kappa directly (preferred).
|
||||
function newPool(
|
||||
// Pool constructor args
|
||||
string memory name_,
|
||||
string memory symbol_,
|
||||
@@ -56,7 +66,8 @@ contract PartyPlanner is IPartyPlanner {
|
||||
_kappa,
|
||||
_swapFeePpm,
|
||||
_flashFeePpm,
|
||||
_stable
|
||||
_stable,
|
||||
PartyPoolSwapMintImpl(swapMintImpl)
|
||||
);
|
||||
|
||||
_allPools.push(pool);
|
||||
@@ -89,8 +100,10 @@ contract PartyPlanner is IPartyPlanner {
|
||||
lpAmount = pool.initialMint(receiver, initialLpAmount);
|
||||
}
|
||||
|
||||
/// Backwards-compatible convenience overload: compute kappa from (tradeFrac, targetSlippage) then call kappa-based createPool.
|
||||
function createPool(
|
||||
// NOTE that the slippage target is only exactly achieved in completely balanced pools where all assets are
|
||||
// priced the same. This target is actually a minimum slippage that the pool imposes on traders, and the actual
|
||||
// slippage cost can be multiples bigger in practice due to pool inventory imbalances.
|
||||
function newPool(
|
||||
// Pool constructor args (old signature)
|
||||
string memory name_,
|
||||
string memory symbol_,
|
||||
@@ -115,8 +128,8 @@ contract PartyPlanner is IPartyPlanner {
|
||||
// Compute kappa from slippage params using LMSR helper (kappa depends only on n, f and s)
|
||||
int128 computedKappa = LMSRStabilized.computeKappaFromSlippage(_tokens.length, _tradeFrac, _targetSlippage);
|
||||
|
||||
// Delegate to the kappa-based createPool variant
|
||||
return createPool(
|
||||
// Delegate to the kappa-based newPool variant
|
||||
return newPool(
|
||||
name_,
|
||||
symbol_,
|
||||
_tokens,
|
||||
|
||||
Reference in New Issue
Block a user