started CREATE2 work and abandoned it
This commit is contained in:
32
src/IPartyPoolDeployer.sol
Normal file
32
src/IPartyPoolDeployer.sol
Normal file
@@ -0,0 +1,32 @@
|
||||
// SPDX-License-Identifier: UNLICENSED
|
||||
pragma solidity ^0.8.30;
|
||||
|
||||
import {IERC20} from "../lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol";
|
||||
import {IPartyPool} from "./IPartyPool.sol";
|
||||
import {NativeWrapper} from "./NativeWrapper.sol";
|
||||
import {PartyPoolMintImpl} from "./PartyPoolMintImpl.sol";
|
||||
import {PartyPoolSwapImpl} from "./PartyPoolSwapImpl.sol";
|
||||
|
||||
interface IPartyPoolDeployer {
|
||||
|
||||
struct DeployParams {
|
||||
address owner;
|
||||
string memory name;
|
||||
string memory symbol;
|
||||
IERC20[] memory tokens;
|
||||
int128 kappa;
|
||||
uint256[] memory fees;
|
||||
uint256 flashFeePpm;
|
||||
uint256 protocolFeePpm;
|
||||
address protocolFeeAddress;
|
||||
NativeWrapper wrapper;
|
||||
PartyPoolSwapImpl swapImpl;
|
||||
PartyPoolMintImpl mintImpl;
|
||||
}
|
||||
|
||||
function deploy(DeployParams memory params) external returns (IPartyPool pool);
|
||||
|
||||
function params() external returns (DeployParams memory params);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,91 +1,40 @@
|
||||
// SPDX-License-Identifier: UNLICENSED
|
||||
pragma solidity ^0.8.30;
|
||||
|
||||
import "./PartyPoolMintImpl.sol";
|
||||
import "./PartyPoolSwapImpl.sol";
|
||||
import {IERC20} from "../lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol";
|
||||
import {IPartyPool} from "./IPartyPool.sol";
|
||||
import {IPartyPoolDeployer} from "./IPartyPoolDeployer.sol";
|
||||
import {NativeWrapper} from "./NativeWrapper.sol";
|
||||
import {PartyPool} from "./PartyPool.sol";
|
||||
import {PartyPoolBalancedPair} from "./PartyPoolBalancedPair.sol";
|
||||
import {PartyPoolMintImpl} from "./PartyPoolMintImpl.sol";
|
||||
import {PartyPoolSwapImpl} from "./PartyPoolSwapImpl.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(
|
||||
address owner_,
|
||||
string memory name_,
|
||||
string memory symbol_,
|
||||
IERC20[] memory tokens_,
|
||||
int128 kappa_,
|
||||
uint256[] memory fees_,
|
||||
uint256 flashFeePpm_,
|
||||
uint256 protocolFeePpm_,
|
||||
address protocolFeeAddress_,
|
||||
NativeWrapper wrapper_,
|
||||
PartyPoolSwapImpl swapImpl_,
|
||||
PartyPoolMintImpl mintImpl_
|
||||
) external returns (IPartyPool pool);
|
||||
abstract contract BasePartyPoolDeployer is IPartyPoolDeployer {
|
||||
uint256 private nonce;
|
||||
DeployParams public params;
|
||||
|
||||
function deploy(DeployParams memory params_) external returns (IPartyPool pool) {
|
||||
params = params_;
|
||||
pool = _doDeploy(nonce);
|
||||
nonce += 1;
|
||||
}
|
||||
|
||||
contract PartyPoolDeployer is IPartyPoolDeployer {
|
||||
function deploy(
|
||||
address owner_,
|
||||
string memory name_,
|
||||
string memory symbol_,
|
||||
IERC20[] memory tokens_,
|
||||
int128 kappa_,
|
||||
uint256[] memory fees_,
|
||||
uint256 flashFeePpm_,
|
||||
uint256 protocolFeePpm_,
|
||||
address protocolFeeAddress_,
|
||||
NativeWrapper wrapper_,
|
||||
PartyPoolSwapImpl swapImpl_,
|
||||
PartyPoolMintImpl mintImpl_
|
||||
) external returns (IPartyPool) {
|
||||
return new PartyPool(
|
||||
owner_,
|
||||
name_,
|
||||
symbol_,
|
||||
tokens_,
|
||||
kappa_,
|
||||
fees_,
|
||||
flashFeePpm_,
|
||||
protocolFeePpm_,
|
||||
protocolFeeAddress_,
|
||||
wrapper_,
|
||||
swapImpl_,
|
||||
mintImpl_
|
||||
);
|
||||
function _doDeploy(uint256 nonce) virtual internal returns (IPartyPool pool);
|
||||
}
|
||||
|
||||
|
||||
contract PartyPoolDeployer is BasePartyPoolDeployer {
|
||||
function _doDeploy(uint256 nonce) internal override returns (IPartyPool) {
|
||||
return new PartyPool(nonce);
|
||||
}
|
||||
}
|
||||
|
||||
contract PartyPoolBalancedPairDeployer is IPartyPoolDeployer {
|
||||
function deploy(
|
||||
address owner_,
|
||||
string memory name_,
|
||||
string memory symbol_,
|
||||
IERC20[] memory tokens_,
|
||||
int128 kappa_,
|
||||
uint256[] memory fees_,
|
||||
uint256 flashFeePpm_,
|
||||
uint256 protocolFeePpm_,
|
||||
address protocolFeeAddress_,
|
||||
NativeWrapper wrapper_,
|
||||
PartyPoolSwapImpl swapImpl_,
|
||||
PartyPoolMintImpl mintImpl_
|
||||
) external returns (IPartyPool) {
|
||||
return new PartyPoolBalancedPair(
|
||||
owner_,
|
||||
name_,
|
||||
symbol_,
|
||||
tokens_,
|
||||
kappa_,
|
||||
fees_,
|
||||
flashFeePpm_,
|
||||
protocolFeePpm_,
|
||||
protocolFeeAddress_,
|
||||
wrapper_,
|
||||
swapImpl_,
|
||||
mintImpl_
|
||||
);
|
||||
contract PartyPoolBalancedPairDeployer is BasePartyPoolDeployer {
|
||||
function _doDeploy(uint256 nonce) internal override returns (IPartyPool) {
|
||||
return new PartyPoolBalancedPair(nonce);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user