deployable sizes
This commit is contained in:
@@ -5,6 +5,7 @@ import {IERC20} from "../lib/openzeppelin-contracts/contracts/token/ERC20/IERC20
|
|||||||
import {PartyPlanner} from "./PartyPlanner.sol";
|
import {PartyPlanner} from "./PartyPlanner.sol";
|
||||||
import {PartyPool} from "./PartyPool.sol";
|
import {PartyPool} from "./PartyPool.sol";
|
||||||
import {PartyPoolBalancedPair} from "./PartyPoolBalancedPair.sol";
|
import {PartyPoolBalancedPair} from "./PartyPoolBalancedPair.sol";
|
||||||
|
import {PartyPoolDeployer, PartyPoolBalancedPairDeployer} from "./PartyPoolDeployer.sol";
|
||||||
import {PartyPoolMintImpl} from "./PartyPoolMintImpl.sol";
|
import {PartyPoolMintImpl} from "./PartyPoolMintImpl.sol";
|
||||||
import {PartyPoolSwapImpl} from "./PartyPoolSwapImpl.sol";
|
import {PartyPoolSwapImpl} from "./PartyPoolSwapImpl.sol";
|
||||||
import {PartyPoolView} from "./PartyPoolView.sol";
|
import {PartyPoolView} from "./PartyPoolView.sol";
|
||||||
@@ -15,6 +16,8 @@ library Deploy {
|
|||||||
return new PartyPlanner(
|
return new PartyPlanner(
|
||||||
new PartyPoolSwapImpl(),
|
new PartyPoolSwapImpl(),
|
||||||
new PartyPoolMintImpl(),
|
new PartyPoolMintImpl(),
|
||||||
|
new PartyPoolDeployer(),
|
||||||
|
new PartyPoolBalancedPairDeployer(),
|
||||||
0, // protocolFeePpm = 0 for deploy helper
|
0, // protocolFeePpm = 0 for deploy helper
|
||||||
address(0) // protocolFeeAddress = address(0) for deploy helper
|
address(0) // protocolFeeAddress = address(0) for deploy helper
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -6,10 +6,9 @@ import {SafeERC20} from "../lib/openzeppelin-contracts/contracts/token/ERC20/uti
|
|||||||
import {IPartyPlanner} from "./IPartyPlanner.sol";
|
import {IPartyPlanner} from "./IPartyPlanner.sol";
|
||||||
import {LMSRStabilized} from "./LMSRStabilized.sol";
|
import {LMSRStabilized} from "./LMSRStabilized.sol";
|
||||||
import {IPartyPool} from "./IPartyPool.sol";
|
import {IPartyPool} from "./IPartyPool.sol";
|
||||||
import {PartyPool} from "./PartyPool.sol";
|
|
||||||
import {PartyPoolMintImpl} from "./PartyPoolMintImpl.sol";
|
import {PartyPoolMintImpl} from "./PartyPoolMintImpl.sol";
|
||||||
import {PartyPoolSwapImpl} from "./PartyPoolSwapImpl.sol";
|
import {PartyPoolSwapImpl} from "./PartyPoolSwapImpl.sol";
|
||||||
import {PartyPoolBalancedPair} from "./PartyPoolBalancedPair.sol";
|
import {IPartyPoolDeployer} from "./PartyPoolDeployer.sol";
|
||||||
|
|
||||||
/// @title PartyPlanner
|
/// @title PartyPlanner
|
||||||
/// @notice Factory contract for creating and tracking PartyPool instances
|
/// @notice Factory contract for creating and tracking PartyPool instances
|
||||||
@@ -33,6 +32,9 @@ contract PartyPlanner is IPartyPlanner {
|
|||||||
address private immutable PROTOCOL_FEE_ADDRESS;
|
address private immutable PROTOCOL_FEE_ADDRESS;
|
||||||
function protocolFeeAddress() external view returns (address) { return PROTOCOL_FEE_ADDRESS; }
|
function protocolFeeAddress() external view returns (address) { return PROTOCOL_FEE_ADDRESS; }
|
||||||
|
|
||||||
|
IPartyPoolDeployer private immutable NORMAL_POOL_DEPLOYER;
|
||||||
|
IPartyPoolDeployer private immutable BALANCED_PAIR_DEPLOYER;
|
||||||
|
|
||||||
// On-chain pool indexing
|
// On-chain pool indexing
|
||||||
IPartyPool[] private _allPools;
|
IPartyPool[] private _allPools;
|
||||||
IERC20[] private _allTokens;
|
IERC20[] private _allTokens;
|
||||||
@@ -47,6 +49,8 @@ contract PartyPlanner is IPartyPlanner {
|
|||||||
constructor(
|
constructor(
|
||||||
PartyPoolSwapImpl _swapMintImpl,
|
PartyPoolSwapImpl _swapMintImpl,
|
||||||
PartyPoolMintImpl _mintImpl,
|
PartyPoolMintImpl _mintImpl,
|
||||||
|
IPartyPoolDeployer _deployer,
|
||||||
|
IPartyPoolDeployer _balancedPairDeployer,
|
||||||
uint256 _protocolFeePpm,
|
uint256 _protocolFeePpm,
|
||||||
address _protocolFeeAddress
|
address _protocolFeeAddress
|
||||||
) {
|
) {
|
||||||
@@ -54,6 +58,10 @@ contract PartyPlanner is IPartyPlanner {
|
|||||||
SWAP_MINT_IMPL = _swapMintImpl;
|
SWAP_MINT_IMPL = _swapMintImpl;
|
||||||
require(address(_mintImpl) != address(0), "Planner: mintImpl address cannot be zero");
|
require(address(_mintImpl) != address(0), "Planner: mintImpl address cannot be zero");
|
||||||
MINT_IMPL = _mintImpl;
|
MINT_IMPL = _mintImpl;
|
||||||
|
require(address(_deployer) != address(0), "Planner: deployer address cannot be zero");
|
||||||
|
NORMAL_POOL_DEPLOYER = _deployer;
|
||||||
|
require(address(_balancedPairDeployer) != address(0), "Planner: balanced pair deployer address cannot be zero");
|
||||||
|
BALANCED_PAIR_DEPLOYER = _balancedPairDeployer;
|
||||||
|
|
||||||
require(_protocolFeePpm < 1_000_000, "Planner: protocol fee >= ppm");
|
require(_protocolFeePpm < 1_000_000, "Planner: protocol fee >= ppm");
|
||||||
PROTOCOL_FEE_PPM = _protocolFeePpm;
|
PROTOCOL_FEE_PPM = _protocolFeePpm;
|
||||||
@@ -88,21 +96,8 @@ contract PartyPlanner is IPartyPlanner {
|
|||||||
require(_kappa > int128(0), "Planner: kappa must be > 0");
|
require(_kappa > int128(0), "Planner: kappa must be > 0");
|
||||||
|
|
||||||
// Create a new PartyPool instance (kappa-based constructor)
|
// Create a new PartyPool instance (kappa-based constructor)
|
||||||
pool = _stable && _tokens.length == 2 ?
|
IPartyPoolDeployer deployer = _stable && _tokens.length == 2 ? BALANCED_PAIR_DEPLOYER : NORMAL_POOL_DEPLOYER;
|
||||||
new PartyPoolBalancedPair(
|
pool = deployer.deploy(
|
||||||
name_,
|
|
||||||
symbol_,
|
|
||||||
_tokens,
|
|
||||||
_bases,
|
|
||||||
_kappa,
|
|
||||||
_swapFeePpm,
|
|
||||||
_flashFeePpm,
|
|
||||||
PROTOCOL_FEE_PPM,
|
|
||||||
PROTOCOL_FEE_ADDRESS,
|
|
||||||
PartyPoolSwapImpl(SWAP_MINT_IMPL),
|
|
||||||
MINT_IMPL
|
|
||||||
) :
|
|
||||||
new PartyPool(
|
|
||||||
name_,
|
name_,
|
||||||
symbol_,
|
symbol_,
|
||||||
_tokens,
|
_tokens,
|
||||||
|
|||||||
87
src/PartyPoolDeployer.sol
Normal file
87
src/PartyPoolDeployer.sol
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
// SPDX-License-Identifier: UNLICENSED
|
||||||
|
pragma solidity ^0.8.30;
|
||||||
|
|
||||||
|
import "./PartyPoolMintImpl.sol";
|
||||||
|
import "./PartyPoolSwapImpl.sol";
|
||||||
|
import {PartyPool} from "./PartyPool.sol";
|
||||||
|
import {PartyPoolBalancedPair} from "./PartyPoolBalancedPair.sol";
|
||||||
|
|
||||||
|
// This pattern is needed because the PartyPlanner constructs two different types of pools (regular and balanced-pair)
|
||||||
|
// but doesn't have room to store the initialization code of both contracts. Therefore, we delegate pool construction.
|
||||||
|
|
||||||
|
interface IPartyPoolDeployer {
|
||||||
|
function deploy(
|
||||||
|
string memory name_,
|
||||||
|
string memory symbol_,
|
||||||
|
IERC20[] memory tokens_,
|
||||||
|
uint256[] memory bases_,
|
||||||
|
int128 kappa_,
|
||||||
|
uint256 swapFeePpm_,
|
||||||
|
uint256 flashFeePpm_,
|
||||||
|
uint256 protocolFeePpm_,
|
||||||
|
address protocolFeeAddress_,
|
||||||
|
PartyPoolSwapImpl swapImpl_,
|
||||||
|
PartyPoolMintImpl mintImpl_
|
||||||
|
) external returns (IPartyPool pool);
|
||||||
|
}
|
||||||
|
|
||||||
|
contract PartyPoolDeployer is IPartyPoolDeployer {
|
||||||
|
function deploy(
|
||||||
|
string memory name_,
|
||||||
|
string memory symbol_,
|
||||||
|
IERC20[] memory tokens_,
|
||||||
|
uint256[] memory bases_,
|
||||||
|
int128 kappa_,
|
||||||
|
uint256 swapFeePpm_,
|
||||||
|
uint256 flashFeePpm_,
|
||||||
|
uint256 protocolFeePpm_,
|
||||||
|
address protocolFeeAddress_,
|
||||||
|
PartyPoolSwapImpl swapImpl_,
|
||||||
|
PartyPoolMintImpl mintImpl_
|
||||||
|
) external returns (IPartyPool) {
|
||||||
|
return new PartyPool(
|
||||||
|
name_,
|
||||||
|
symbol_,
|
||||||
|
tokens_,
|
||||||
|
bases_,
|
||||||
|
kappa_,
|
||||||
|
swapFeePpm_,
|
||||||
|
flashFeePpm_,
|
||||||
|
protocolFeePpm_,
|
||||||
|
protocolFeeAddress_,
|
||||||
|
swapImpl_,
|
||||||
|
mintImpl_
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
contract PartyPoolBalancedPairDeployer is IPartyPoolDeployer {
|
||||||
|
function deploy(
|
||||||
|
string memory name_,
|
||||||
|
string memory symbol_,
|
||||||
|
IERC20[] memory tokens_,
|
||||||
|
uint256[] memory bases_,
|
||||||
|
int128 kappa_,
|
||||||
|
uint256 swapFeePpm_,
|
||||||
|
uint256 flashFeePpm_,
|
||||||
|
uint256 protocolFeePpm_,
|
||||||
|
address protocolFeeAddress_,
|
||||||
|
PartyPoolSwapImpl swapImpl_,
|
||||||
|
PartyPoolMintImpl mintImpl_
|
||||||
|
) external returns (IPartyPool) {
|
||||||
|
return new PartyPoolBalancedPair(
|
||||||
|
name_,
|
||||||
|
symbol_,
|
||||||
|
tokens_,
|
||||||
|
bases_,
|
||||||
|
kappa_,
|
||||||
|
swapFeePpm_,
|
||||||
|
flashFeePpm_,
|
||||||
|
protocolFeePpm_,
|
||||||
|
protocolFeeAddress_,
|
||||||
|
swapImpl_,
|
||||||
|
mintImpl_
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user