deployed to Sepolia; liqp-deployments.json
This commit is contained in:
23
.gitignore
vendored
23
.gitignore
vendored
@@ -1,14 +1,15 @@
|
|||||||
cache/
|
/cache/
|
||||||
out/
|
/out/
|
||||||
|
|
||||||
chain.json
|
/docs/
|
||||||
|
/log/
|
||||||
docs/
|
/.env
|
||||||
log/
|
/.idea/
|
||||||
.env
|
|
||||||
.idea
|
|
||||||
|
|
||||||
# Ignores development broadcast logs
|
# Ignores development broadcast logs
|
||||||
!/broadcast
|
/broadcast
|
||||||
/broadcast/*/31337/
|
|
||||||
/broadcast/**/dry-run/
|
# Sensitive files
|
||||||
|
*secret*
|
||||||
|
bin/sepolia-deploy
|
||||||
|
/liqp-deployments.json
|
||||||
17
deployment/liqp-deployments.json
Normal file
17
deployment/liqp-deployments.json
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"11155111": {
|
||||||
|
"v1": {
|
||||||
|
"PartyPlanner": "0xEc41Df23428700000CEd7d81fB313Ea657EAb92F",
|
||||||
|
"PartyPoolViewer": "0x5FFbD8516a4411a1bB7Ee0d71Aa7A6948826f278",
|
||||||
|
"PartyPoolMintImpl": "0x7d489e8aE971B34357aa7Adef8111DAeD0497b45",
|
||||||
|
"PartyPoolSwapImpl": "0xF44A660E2281F523523114be7633c94E377bbE6F",
|
||||||
|
"PartyPoolDeployer": "0xAc753F480864eb130e3dA0762234dD7E00F06937",
|
||||||
|
"PartyPoolBalancedPairDeployer": "0x760df38C9DE60b809976d67CD9cb1Ec81ab3c293",
|
||||||
|
"USXD": "0xCb2F4B07eFe0F06264AD28590aC7f03D5cdb0729",
|
||||||
|
"FUSD": "0x09b215368a4a4ed16a075716079080b4CEE2e38b",
|
||||||
|
"DIVE": "0xFc3Bfd0D488322f928ac153ce8197A7d26A2237f",
|
||||||
|
"BUTC": "0x19Ba3A189dc3DEbC07ADF7757dc8170702E91696",
|
||||||
|
"WTETH": "0xd406e1a6b028D17b72f826E45bF36BB8Ad4077dB"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,10 +7,10 @@ remappings = [
|
|||||||
'@abdk/=lib/abdk-libraries-solidity/',
|
'@abdk/=lib/abdk-libraries-solidity/',
|
||||||
]
|
]
|
||||||
optimizer=true
|
optimizer=true
|
||||||
optimizer_runs=999999999
|
optimizer_runs=100000000 # maximum value allowed by etherscan's verifier XD. The max value is formally 2^32-1
|
||||||
viaIR=true
|
viaIR=true
|
||||||
gas_reports = ['PartyPool', 'PartyPoolBalancedPair', 'PartyPlanner', 'PartyPoolSwapImpl', 'PartyPoolMintImpl',]
|
gas_reports = ['PartyPool', 'PartyPoolBalancedPair', 'PartyPlanner', 'PartyPoolSwapImpl', 'PartyPoolMintImpl',]
|
||||||
fs_permissions = [{ access = "write", path = "chain.json"}]
|
fs_permissions = [{ access = "write", path = "liqp-deployments.json"}]
|
||||||
|
|
||||||
[lint]
|
[lint]
|
||||||
lint_on_build=false # more annoying than helpful
|
lint_on_build=false # more annoying than helpful
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ contract DeployMock is Script {
|
|||||||
address constant public DEV_ACCOUNT_7 = 0x14dC79964da2C08b23698B3D3cc7Ca32193d9955;
|
address constant public DEV_ACCOUNT_7 = 0x14dC79964da2C08b23698B3D3cc7Ca32193d9955;
|
||||||
|
|
||||||
function run() public {
|
function run() public {
|
||||||
|
require(block.chainid == 31337, 'Not a dev node');
|
||||||
|
|
||||||
vm.startBroadcast();
|
vm.startBroadcast();
|
||||||
|
|
||||||
// create mock _tokens
|
// create mock _tokens
|
||||||
@@ -159,6 +161,7 @@ contract DeployMock is Script {
|
|||||||
0
|
0
|
||||||
);
|
);
|
||||||
|
|
||||||
|
PartyPoolViewer viewer = Deploy.newViewer();
|
||||||
|
|
||||||
// give _tokens to dev7 for later use
|
// give _tokens to dev7 for later use
|
||||||
mintAll(DEV_ACCOUNT_7, 1_000_000);
|
mintAll(DEV_ACCOUNT_7, 1_000_000);
|
||||||
@@ -167,7 +170,9 @@ contract DeployMock is Script {
|
|||||||
|
|
||||||
// Set ENV vars
|
// Set ENV vars
|
||||||
string memory plannerStr = vm.toString(address(planner));
|
string memory plannerStr = vm.toString(address(planner));
|
||||||
|
string memory viewerStr = vm.toString(address(viewer));
|
||||||
vm.setEnv('PLANNER', plannerStr);
|
vm.setEnv('PLANNER', plannerStr);
|
||||||
|
vm.setEnv('VIEWER', viewerStr);
|
||||||
vm.setEnv('USXD', vm.toString(address(usxd)));
|
vm.setEnv('USXD', vm.toString(address(usxd)));
|
||||||
vm.setEnv('FUSD', vm.toString(address(fusd)));
|
vm.setEnv('FUSD', vm.toString(address(fusd)));
|
||||||
vm.setEnv('DIVE', vm.toString(address(dive)));
|
vm.setEnv('DIVE', vm.toString(address(dive)));
|
||||||
@@ -175,13 +180,11 @@ contract DeployMock is Script {
|
|||||||
vm.setEnv('WTETH', vm.toString(address(wteth)));
|
vm.setEnv('WTETH', vm.toString(address(wteth)));
|
||||||
|
|
||||||
// Write JSON config file
|
// Write JSON config file
|
||||||
string memory config = 'config';
|
string memory chainConfigStr = vm.serializeString('config', 'PartyPlanner', plannerStr);
|
||||||
string memory chainConfig = 'chain config';
|
chainConfigStr = vm.serializeString('config', 'PartyPoolViewer', viewerStr);
|
||||||
string memory chainConfigStr = vm.serializeString(chainConfig, 'PartyPlannerV1', plannerStr);
|
string memory v1ConfigStr = vm.serializeString('v1', 'v1', chainConfigStr);
|
||||||
string memory configStr = vm.serializeString(config, vm.toString(block.chainid), chainConfigStr);
|
string memory configStr = vm.serializeString('chain config', vm.toString(block.chainid), v1ConfigStr);
|
||||||
vm.writeJson(configStr, 'chain.json');
|
vm.writeJson(configStr, 'liqp-deployments.json');
|
||||||
|
|
||||||
PartyPoolViewer viewer = Deploy.newViewer();
|
|
||||||
|
|
||||||
console2.log();
|
console2.log();
|
||||||
console2.log(' PartyPlanner', address(planner));
|
console2.log(' PartyPlanner', address(planner));
|
||||||
|
|||||||
229
script/DeploySepolia.sol
Normal file
229
script/DeploySepolia.sol
Normal file
@@ -0,0 +1,229 @@
|
|||||||
|
// SPDX-License-Identifier: UNLICENSED
|
||||||
|
pragma solidity ^0.8.30;
|
||||||
|
|
||||||
|
import "../test/Deploy.sol";
|
||||||
|
import "../src/IPartyPool.sol";
|
||||||
|
import "../src/PartyPlanner.sol";
|
||||||
|
import "../src/PartyPool.sol";
|
||||||
|
import "../test/MockERC20.sol";
|
||||||
|
import "@abdk/ABDKMath64x64.sol";
|
||||||
|
import "forge-std/Script.sol";
|
||||||
|
import "forge-std/console2.sol";
|
||||||
|
|
||||||
|
contract DeploySepolia is Script {
|
||||||
|
|
||||||
|
address constant public PROTOCOL_FEE_ADDRESS = 0x0E280F5eDA58872d7cDaA8AC0A57A55fD6133AEd;
|
||||||
|
uint256 constant public PROTOCOL_FEE_PPM = 10_0000; // 10% of LP fees
|
||||||
|
NativeWrapper constant public WETH = NativeWrapper(0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14);
|
||||||
|
|
||||||
|
function run() public {
|
||||||
|
require(block.chainid == 11155111, 'Not Sepolia');
|
||||||
|
|
||||||
|
vm.startBroadcast();
|
||||||
|
|
||||||
|
// create mock _tokens
|
||||||
|
usxd = new MockERC20('Joke Currency', 'USXD', 6);
|
||||||
|
fusd = new MockERC20('Fake USD', 'FUSD', 6);
|
||||||
|
dive = new MockERC20('DAI Virtually Equal', 'DIVE', 18);
|
||||||
|
butc = new MockERC20('Buttcoin', 'BUTC', 8);
|
||||||
|
wteth = new MockERC20('Wrapped TETH', 'WTETH', 18);
|
||||||
|
|
||||||
|
PartyPoolSwapImpl swapImpl = new PartyPoolSwapImpl(WETH);
|
||||||
|
PartyPoolMintImpl mintImpl = new PartyPoolMintImpl(WETH);
|
||||||
|
PartyPoolDeployer deployer = new PartyPoolDeployer();
|
||||||
|
PartyPoolBalancedPairDeployer balancedPairDeployer = new PartyPoolBalancedPairDeployer();
|
||||||
|
|
||||||
|
// deploy a PartyPlanner factory and create the pool via factory
|
||||||
|
PartyPlanner planner = new PartyPlanner(
|
||||||
|
WETH,
|
||||||
|
swapImpl,
|
||||||
|
mintImpl,
|
||||||
|
deployer,
|
||||||
|
balancedPairDeployer,
|
||||||
|
PROTOCOL_FEE_PPM,
|
||||||
|
PROTOCOL_FEE_ADDRESS
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Deploy 3-asset pool
|
||||||
|
//
|
||||||
|
|
||||||
|
uint256 _feePpm = 25_00; // 25 bps
|
||||||
|
IERC20[] memory tokens = new IERC20[](3);
|
||||||
|
tokens[0] = IERC20(usxd);
|
||||||
|
tokens[1] = IERC20(butc);
|
||||||
|
tokens[2] = IERC20(wteth);
|
||||||
|
uint256[] memory _bases = new uint256[](3);
|
||||||
|
_bases[0] = 10**6;
|
||||||
|
_bases[1] = 10**8;
|
||||||
|
_bases[2] = 10**18;
|
||||||
|
|
||||||
|
// mint _tokens to the deployer so it can fund the initial deposits and approve the factory
|
||||||
|
mintAll(msg.sender, 10_000);
|
||||||
|
// prepare initial deposits (10_000 units of each token, scaled by _bases)
|
||||||
|
uint256[] memory initialDeposits = new uint256[](3);
|
||||||
|
initialDeposits[0] = _bases[0] * 10_000;
|
||||||
|
initialDeposits[1] = _bases[1] * 10_000;
|
||||||
|
initialDeposits[2] = _bases[2] * 10_000;
|
||||||
|
// approve factory to move initial deposits
|
||||||
|
for (uint i = 0; i < tokens.length; i++) {
|
||||||
|
IERC20(tokens[i]).approve(address(planner), initialDeposits[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// call full newPool signature on factory which will take the deposits and mint initial LP
|
||||||
|
planner.newPool(
|
||||||
|
'Token Pool',
|
||||||
|
'TP',
|
||||||
|
tokens,
|
||||||
|
_bases,
|
||||||
|
ABDKMath64x64.divu(1, 10),
|
||||||
|
ABDKMath64x64.divu(1,10000),
|
||||||
|
_feePpm,
|
||||||
|
_feePpm,
|
||||||
|
false,
|
||||||
|
msg.sender, // payer: this script
|
||||||
|
msg.sender, // receiver of initial LP
|
||||||
|
initialDeposits,
|
||||||
|
10000,
|
||||||
|
0
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// Deploy 3-asset stablecoin pool
|
||||||
|
//
|
||||||
|
|
||||||
|
_feePpm = 1_00; // 1 bp
|
||||||
|
tokens = new IERC20[](3);
|
||||||
|
tokens[0] = IERC20(usxd);
|
||||||
|
tokens[1] = IERC20(fusd);
|
||||||
|
tokens[2] = IERC20(dive);
|
||||||
|
_bases = new uint256[](3);
|
||||||
|
_bases[0] = 10**6;
|
||||||
|
_bases[1] = 10**6;
|
||||||
|
_bases[2] = 10**18;
|
||||||
|
|
||||||
|
// mint _tokens to the deployer so it can fund the initial deposits and approve the factory
|
||||||
|
mintAll(msg.sender, 10_000);
|
||||||
|
// prepare initial deposits (10_000 units of each token, scaled by _bases)
|
||||||
|
initialDeposits = new uint256[](3);
|
||||||
|
initialDeposits[0] = _bases[0] * 10_000;
|
||||||
|
initialDeposits[1] = _bases[1] * 10_000;
|
||||||
|
initialDeposits[2] = _bases[2] * 10_000;
|
||||||
|
// approve factory to move initial deposits
|
||||||
|
for (uint i = 0; i < tokens.length; i++) {
|
||||||
|
IERC20(tokens[i]).approve(address(planner), initialDeposits[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// call full newPool signature on factory which will take the deposits and mint initial LP
|
||||||
|
planner.newPool(
|
||||||
|
'Stablecoin Pool',
|
||||||
|
'STAP',
|
||||||
|
tokens,
|
||||||
|
_bases,
|
||||||
|
ABDKMath64x64.divu(1, 10),
|
||||||
|
ABDKMath64x64.divu(1,10000),
|
||||||
|
_feePpm,
|
||||||
|
_feePpm,
|
||||||
|
false,
|
||||||
|
msg.sender, // payer: this script
|
||||||
|
msg.sender, // receiver of initial LP
|
||||||
|
initialDeposits,
|
||||||
|
10000,
|
||||||
|
0
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// Deploy 2-asset balanced pair pool
|
||||||
|
//
|
||||||
|
|
||||||
|
_feePpm = 7; // 0.07 bp
|
||||||
|
tokens = new IERC20[](2);
|
||||||
|
tokens[0] = IERC20(usxd);
|
||||||
|
tokens[1] = IERC20(dive);
|
||||||
|
_bases = new uint256[](2);
|
||||||
|
_bases[0] = 10**6;
|
||||||
|
_bases[1] = 10**18;
|
||||||
|
|
||||||
|
// mint _tokens to the deployer so it can fund the initial deposits and approve the factory
|
||||||
|
mintAll(msg.sender, 10_000);
|
||||||
|
// prepare initial deposits (10_000 units of each token, scaled by _bases)
|
||||||
|
initialDeposits = new uint256[](2);
|
||||||
|
initialDeposits[0] = _bases[0] * 10_000;
|
||||||
|
initialDeposits[1] = _bases[1] * 10_000;
|
||||||
|
// approve factory to move initial deposits
|
||||||
|
for (uint i = 0; i < tokens.length; i++) {
|
||||||
|
IERC20(tokens[i]).approve(address(planner), initialDeposits[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// call full newPool signature on factory which will take the deposits and mint initial LP
|
||||||
|
planner.newPool(
|
||||||
|
'Stable Pair',
|
||||||
|
'SPAIR',
|
||||||
|
tokens,
|
||||||
|
_bases,
|
||||||
|
ABDKMath64x64.divu(8,10), // kappa = 0.8
|
||||||
|
_feePpm,
|
||||||
|
_feePpm,
|
||||||
|
true, // STABLE
|
||||||
|
msg.sender, // payer: this script
|
||||||
|
msg.sender, // receiver of initial LP
|
||||||
|
initialDeposits,
|
||||||
|
10000,
|
||||||
|
0
|
||||||
|
);
|
||||||
|
|
||||||
|
PartyPoolViewer viewer = new PartyPoolViewer(swapImpl, mintImpl);
|
||||||
|
|
||||||
|
// give tokens to msg.sender for later use
|
||||||
|
mintAll(msg.sender, 1_000_000);
|
||||||
|
|
||||||
|
vm.stopBroadcast();
|
||||||
|
|
||||||
|
// Set ENV vars
|
||||||
|
string memory plannerStr = vm.toString(address(planner));
|
||||||
|
vm.setEnv('PLANNER', plannerStr);
|
||||||
|
vm.setEnv('USXD', vm.toString(address(usxd)));
|
||||||
|
vm.setEnv('FUSD', vm.toString(address(fusd)));
|
||||||
|
vm.setEnv('DIVE', vm.toString(address(dive)));
|
||||||
|
vm.setEnv('BUTC', vm.toString(address(butc)));
|
||||||
|
vm.setEnv('WTETH', vm.toString(address(wteth)));
|
||||||
|
|
||||||
|
// Write JSON config file
|
||||||
|
string memory config = 'config';
|
||||||
|
string memory chainConfig = 'chain config';
|
||||||
|
string memory chainConfigStr = vm.serializeString(chainConfig, 'PartyPlannerV1', plannerStr);
|
||||||
|
string memory configStr = vm.serializeString(config, vm.toString(block.chainid), chainConfigStr);
|
||||||
|
vm.writeJson(configStr, 'chain.json');
|
||||||
|
|
||||||
|
console2.log();
|
||||||
|
console2.log(' PartyPlanner', address(planner));
|
||||||
|
console2.log('PartyPoolViewer', address(viewer));
|
||||||
|
console2.log(' SwapImpl', address(swapImpl));
|
||||||
|
console2.log(' MintImpl', address(mintImpl));
|
||||||
|
console2.log(' Deployer', address(deployer));
|
||||||
|
console2.log(' BPair Deployer', address(balancedPairDeployer));
|
||||||
|
console2.log();
|
||||||
|
console2.log(' USXD', address(usxd));
|
||||||
|
console2.log(' FUSD', address(fusd));
|
||||||
|
console2.log(' DIVE', address(dive));
|
||||||
|
console2.log(' BUTC', address(butc));
|
||||||
|
console2.log(' WTETH', address(wteth));
|
||||||
|
}
|
||||||
|
|
||||||
|
MockERC20 private usxd;
|
||||||
|
MockERC20 private fusd;
|
||||||
|
MockERC20 private dive;
|
||||||
|
MockERC20 private butc;
|
||||||
|
MockERC20 private wteth;
|
||||||
|
|
||||||
|
function mintAll(address who, uint256 amount) internal {
|
||||||
|
usxd.mint(who, amount * 1e6);
|
||||||
|
fusd.mint(who, amount * 1e6);
|
||||||
|
dive.mint(who, amount * 1e18);
|
||||||
|
butc.mint(who, amount * 1e8);
|
||||||
|
wteth.mint(who, amount * 1e18);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
pragma solidity ^0.8.30;
|
pragma solidity ^0.8.30;
|
||||||
|
|
||||||
import "../lib/openzeppelin-contracts/contracts/interfaces/IERC3156FlashBorrower.sol";
|
import "../lib/openzeppelin-contracts/contracts/interfaces/IERC3156FlashBorrower.sol";
|
||||||
import "./IWETH9.sol";
|
import "./NativeWrapper.sol";
|
||||||
import "./LMSRStabilized.sol";
|
import "./LMSRStabilized.sol";
|
||||||
import {IERC20Metadata} from "../lib/openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Metadata.sol";
|
import {IERC20Metadata} from "../lib/openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Metadata.sol";
|
||||||
import {IERC20} from "../lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol";
|
import {IERC20} from "../lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol";
|
||||||
@@ -72,7 +72,7 @@ interface IPartyPool is IERC20Metadata {
|
|||||||
function allTokens() external view returns (IERC20[] memory);
|
function allTokens() external view returns (IERC20[] memory);
|
||||||
|
|
||||||
/// @notice Token contract used for wrapping native currency
|
/// @notice Token contract used for wrapping native currency
|
||||||
function wrapperToken() external view returns (IWETH9);
|
function wrapperToken() external view returns (NativeWrapper);
|
||||||
|
|
||||||
/// @notice Per-token uint base denominators used to convert uint token amounts <-> internal Q64.64 representation.
|
/// @notice Per-token uint base denominators used to convert uint token amounts <-> internal Q64.64 representation.
|
||||||
/// @dev denominators()[i] is the base for _tokens[i]. These _bases are chosen by deployer and must match token decimals.
|
/// @dev denominators()[i] is the base for _tokens[i]. These _bases are chosen by deployer and must match token decimals.
|
||||||
|
|||||||
@@ -873,7 +873,7 @@ library LMSRStabilized {
|
|||||||
/// @notice Internal helper to compute kappa from slippage parameters.
|
/// @notice Internal helper to compute kappa from slippage parameters.
|
||||||
/// @dev Returns κ in Q64.64. Implemented as internal so callers within the library can use it
|
/// @dev Returns κ in Q64.64. Implemented as internal so callers within the library can use it
|
||||||
/// without resorting to external calls.
|
/// without resorting to external calls.
|
||||||
function _computeKappaFromSlippage(
|
function computeKappaFromSlippage(
|
||||||
uint256 nAssets,
|
uint256 nAssets,
|
||||||
int128 tradeFrac,
|
int128 tradeFrac,
|
||||||
int128 targetSlippage
|
int128 targetSlippage
|
||||||
@@ -920,16 +920,6 @@ library LMSRStabilized {
|
|||||||
return kappa;
|
return kappa;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @notice Compute kappa from slippage parameters.
|
|
||||||
/// @dev External wrapper that delegates to internal implementation.
|
|
||||||
function computeKappaFromSlippage(
|
|
||||||
uint256 nAssets,
|
|
||||||
int128 tradeFrac,
|
|
||||||
int128 targetSlippage
|
|
||||||
) external pure returns (int128) {
|
|
||||||
return _computeKappaFromSlippage(nAssets, tradeFrac, targetSlippage);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @notice Legacy-compatible init: compute kappa from slippage parameters and delegate to kappa-based init.
|
/// @notice Legacy-compatible init: compute kappa from slippage parameters and delegate to kappa-based init.
|
||||||
/// @dev Provides backward compatibility for callers that still use the (q, tradeFrac, targetSlippage) init signature.
|
/// @dev Provides backward compatibility for callers that still use the (q, tradeFrac, targetSlippage) init signature.
|
||||||
function init(
|
function init(
|
||||||
@@ -939,7 +929,7 @@ library LMSRStabilized {
|
|||||||
int128 targetSlippage
|
int128 targetSlippage
|
||||||
) internal {
|
) internal {
|
||||||
// compute kappa using the internal helper
|
// compute kappa using the internal helper
|
||||||
int128 kappa = _computeKappaFromSlippage(initialQInternal.length, tradeFrac, targetSlippage);
|
int128 kappa = computeKappaFromSlippage(initialQInternal.length, tradeFrac, targetSlippage);
|
||||||
// forward to the new kappa-based init
|
// forward to the new kappa-based init
|
||||||
init(s, initialQInternal, kappa);
|
init(s, initialQInternal, kappa);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ pragma solidity ^0.8.30;
|
|||||||
import {IERC20Metadata} from "../lib/openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Metadata.sol";
|
import {IERC20Metadata} from "../lib/openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Metadata.sol";
|
||||||
|
|
||||||
|
|
||||||
interface IWETH9 is IERC20Metadata {
|
interface NativeWrapper is IERC20Metadata {
|
||||||
function deposit() external payable;
|
function deposit() external payable;
|
||||||
function withdraw(uint wad) external;
|
function withdraw(uint wad) external;
|
||||||
}
|
}
|
||||||
@@ -5,7 +5,7 @@ import {IERC20} from "../lib/openzeppelin-contracts/contracts/token/ERC20/IERC20
|
|||||||
import {SafeERC20} from "../lib/openzeppelin-contracts/contracts/token/ERC20/utils/SafeERC20.sol";
|
import {SafeERC20} from "../lib/openzeppelin-contracts/contracts/token/ERC20/utils/SafeERC20.sol";
|
||||||
import {IPartyPlanner} from "./IPartyPlanner.sol";
|
import {IPartyPlanner} from "./IPartyPlanner.sol";
|
||||||
import {IPartyPool} from "./IPartyPool.sol";
|
import {IPartyPool} from "./IPartyPool.sol";
|
||||||
import {IWETH9} from "./IWETH9.sol";
|
import {NativeWrapper} from "./NativeWrapper.sol";
|
||||||
import {LMSRStabilized} from "./LMSRStabilized.sol";
|
import {LMSRStabilized} from "./LMSRStabilized.sol";
|
||||||
import {IPartyPoolDeployer} from "./PartyPoolDeployer.sol";
|
import {IPartyPoolDeployer} from "./PartyPoolDeployer.sol";
|
||||||
import {PartyPoolMintImpl} from "./PartyPoolMintImpl.sol";
|
import {PartyPoolMintImpl} from "./PartyPoolMintImpl.sol";
|
||||||
@@ -33,8 +33,8 @@ 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; }
|
||||||
|
|
||||||
IWETH9 private immutable WRAPPER;
|
NativeWrapper private immutable WRAPPER;
|
||||||
function wrapper() external view returns (IWETH9) { return WRAPPER; }
|
function wrapper() external view returns (NativeWrapper) { return WRAPPER; }
|
||||||
|
|
||||||
IPartyPoolDeployer private immutable NORMAL_POOL_DEPLOYER;
|
IPartyPoolDeployer private immutable NORMAL_POOL_DEPLOYER;
|
||||||
IPartyPoolDeployer private immutable BALANCED_PAIR_DEPLOYER;
|
IPartyPoolDeployer private immutable BALANCED_PAIR_DEPLOYER;
|
||||||
@@ -51,7 +51,7 @@ contract PartyPlanner is IPartyPlanner {
|
|||||||
/// @param _protocolFeePpm protocol fee share (ppm) to be used for pools created by this planner
|
/// @param _protocolFeePpm protocol fee share (ppm) to be used for pools created by this planner
|
||||||
/// @param _protocolFeeAddress recipient address for protocol fees for pools created by this planner (may be address(0))
|
/// @param _protocolFeeAddress recipient address for protocol fees for pools created by this planner (may be address(0))
|
||||||
constructor(
|
constructor(
|
||||||
IWETH9 _wrapper,
|
NativeWrapper _wrapper,
|
||||||
PartyPoolSwapImpl _swapImpl,
|
PartyPoolSwapImpl _swapImpl,
|
||||||
PartyPoolMintImpl _mintImpl,
|
PartyPoolMintImpl _mintImpl,
|
||||||
IPartyPoolDeployer _deployer,
|
IPartyPoolDeployer _deployer,
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import {Proxy} from "../lib/openzeppelin-contracts/contracts/proxy/Proxy.sol";
|
|||||||
import {ReentrancyGuard} from "../lib/openzeppelin-contracts/contracts/utils/ReentrancyGuard.sol";
|
import {ReentrancyGuard} from "../lib/openzeppelin-contracts/contracts/utils/ReentrancyGuard.sol";
|
||||||
import {SafeERC20} from "../lib/openzeppelin-contracts/contracts/token/ERC20/utils/SafeERC20.sol";
|
import {SafeERC20} from "../lib/openzeppelin-contracts/contracts/token/ERC20/utils/SafeERC20.sol";
|
||||||
import {IERC3156FlashLender} from "../lib/openzeppelin-contracts/contracts/interfaces/IERC3156FlashLender.sol";
|
import {IERC3156FlashLender} from "../lib/openzeppelin-contracts/contracts/interfaces/IERC3156FlashLender.sol";
|
||||||
import {IWETH9} from "./IWETH9.sol";
|
import {NativeWrapper} from "./NativeWrapper.sol";
|
||||||
|
|
||||||
/// @title PartyPool - LMSR-backed multi-asset pool with LP ERC20 token
|
/// @title PartyPool - LMSR-backed multi-asset pool with LP ERC20 token
|
||||||
/// @notice A multi-asset liquidity pool backed by the LMSRStabilized pricing model.
|
/// @notice A multi-asset liquidity pool backed by the LMSRStabilized pricing model.
|
||||||
@@ -39,7 +39,7 @@ contract PartyPool is PartyPoolBase, ERC20External, IPartyPool {
|
|||||||
|
|
||||||
receive() external payable {}
|
receive() external payable {}
|
||||||
|
|
||||||
function wrapperToken() external view returns (IWETH9) { return WRAPPER_TOKEN; }
|
function wrapperToken() external view returns (NativeWrapper) { return WRAPPER_TOKEN; }
|
||||||
|
|
||||||
/// @notice Liquidity parameter κ (Q64.64) used by the LMSR kernel: b = κ * S(q)
|
/// @notice Liquidity parameter κ (Q64.64) used by the LMSR kernel: b = κ * S(q)
|
||||||
/// @dev Pool is constructed with a fixed κ. Clients that previously passed tradeFrac/targetSlippage
|
/// @dev Pool is constructed with a fixed κ. Clients that previously passed tradeFrac/targetSlippage
|
||||||
@@ -109,7 +109,7 @@ contract PartyPool is PartyPoolBase, ERC20External, IPartyPool {
|
|||||||
uint256 flashFeePpm_,
|
uint256 flashFeePpm_,
|
||||||
uint256 protocolFeePpm_,
|
uint256 protocolFeePpm_,
|
||||||
address protocolFeeAddress_,
|
address protocolFeeAddress_,
|
||||||
IWETH9 wrapperToken_,
|
NativeWrapper wrapperToken_,
|
||||||
PartyPoolSwapImpl swapImpl_,
|
PartyPoolSwapImpl swapImpl_,
|
||||||
PartyPoolMintImpl mintImpl_
|
PartyPoolMintImpl mintImpl_
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
pragma solidity ^0.8.30;
|
pragma solidity ^0.8.30;
|
||||||
|
|
||||||
import {IERC20} from "../lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol";
|
import {IERC20} from "../lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol";
|
||||||
import {IWETH9} from "./IWETH9.sol";
|
import {NativeWrapper} from "./NativeWrapper.sol";
|
||||||
import {LMSRStabilizedBalancedPair} from "./LMSRStabilizedBalancedPair.sol";
|
import {LMSRStabilizedBalancedPair} from "./LMSRStabilizedBalancedPair.sol";
|
||||||
import {PartyPool} from "./PartyPool.sol";
|
import {PartyPool} from "./PartyPool.sol";
|
||||||
import {PartyPoolBase} from "./PartyPoolBase.sol";
|
import {PartyPoolBase} from "./PartyPoolBase.sol";
|
||||||
@@ -20,7 +20,7 @@ contract PartyPoolBalancedPair is PartyPool {
|
|||||||
uint256 flashFeePpm_,
|
uint256 flashFeePpm_,
|
||||||
uint256 protocolFeePpm_, // NEW: protocol share of fees (ppm)
|
uint256 protocolFeePpm_, // NEW: protocol share of fees (ppm)
|
||||||
address protocolFeeAddress_, // NEW: recipient for collected protocol tokens
|
address protocolFeeAddress_, // NEW: recipient for collected protocol tokens
|
||||||
IWETH9 wrapperToken_,
|
NativeWrapper wrapperToken_,
|
||||||
PartyPoolSwapImpl swapMintImpl_,
|
PartyPoolSwapImpl swapMintImpl_,
|
||||||
PartyPoolMintImpl mintImpl_
|
PartyPoolMintImpl mintImpl_
|
||||||
) PartyPool(name_, symbol_, tokens_, bases_, kappa_, swapFeePpm_, flashFeePpm_, protocolFeePpm_, protocolFeeAddress_, wrapperToken_, swapMintImpl_, mintImpl_)
|
) PartyPool(name_, symbol_, tokens_, bases_, kappa_, swapFeePpm_, flashFeePpm_, protocolFeePpm_, protocolFeeAddress_, wrapperToken_, swapMintImpl_, mintImpl_)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// SPDX-License-Identifier: UNLICENSED
|
// SPDX-License-Identifier: UNLICENSED
|
||||||
pragma solidity ^0.8.30;
|
pragma solidity ^0.8.30;
|
||||||
|
|
||||||
import "./IWETH9.sol";
|
import "./NativeWrapper.sol";
|
||||||
import {ABDKMath64x64} from "../lib/abdk-libraries-solidity/ABDKMath64x64.sol";
|
import {ABDKMath64x64} from "../lib/abdk-libraries-solidity/ABDKMath64x64.sol";
|
||||||
import {ERC20Internal} from "./ERC20Internal.sol";
|
import {ERC20Internal} from "./ERC20Internal.sol";
|
||||||
import {IERC20} from "../lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol";
|
import {IERC20} from "../lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol";
|
||||||
@@ -17,9 +17,9 @@ abstract contract PartyPoolBase is ERC20Internal, ReentrancyGuard, PartyPoolHelp
|
|||||||
using LMSRStabilized for LMSRStabilized.State;
|
using LMSRStabilized for LMSRStabilized.State;
|
||||||
using SafeERC20 for IERC20;
|
using SafeERC20 for IERC20;
|
||||||
|
|
||||||
IWETH9 internal immutable WRAPPER_TOKEN;
|
NativeWrapper internal immutable WRAPPER_TOKEN;
|
||||||
|
|
||||||
constructor( IWETH9 wrapper_ ) {
|
constructor( NativeWrapper wrapper_ ) {
|
||||||
WRAPPER_TOKEN = wrapper_;
|
WRAPPER_TOKEN = wrapper_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ interface IPartyPoolDeployer {
|
|||||||
uint256 flashFeePpm_,
|
uint256 flashFeePpm_,
|
||||||
uint256 protocolFeePpm_,
|
uint256 protocolFeePpm_,
|
||||||
address protocolFeeAddress_,
|
address protocolFeeAddress_,
|
||||||
IWETH9 wrapper_,
|
NativeWrapper wrapper_,
|
||||||
PartyPoolSwapImpl swapImpl_,
|
PartyPoolSwapImpl swapImpl_,
|
||||||
PartyPoolMintImpl mintImpl_
|
PartyPoolMintImpl mintImpl_
|
||||||
) external returns (IPartyPool pool);
|
) external returns (IPartyPool pool);
|
||||||
@@ -37,7 +37,7 @@ contract PartyPoolDeployer is IPartyPoolDeployer {
|
|||||||
uint256 flashFeePpm_,
|
uint256 flashFeePpm_,
|
||||||
uint256 protocolFeePpm_,
|
uint256 protocolFeePpm_,
|
||||||
address protocolFeeAddress_,
|
address protocolFeeAddress_,
|
||||||
IWETH9 wrapper_,
|
NativeWrapper wrapper_,
|
||||||
PartyPoolSwapImpl swapImpl_,
|
PartyPoolSwapImpl swapImpl_,
|
||||||
PartyPoolMintImpl mintImpl_
|
PartyPoolMintImpl mintImpl_
|
||||||
) external returns (IPartyPool) {
|
) external returns (IPartyPool) {
|
||||||
@@ -69,7 +69,7 @@ contract PartyPoolBalancedPairDeployer is IPartyPoolDeployer {
|
|||||||
uint256 flashFeePpm_,
|
uint256 flashFeePpm_,
|
||||||
uint256 protocolFeePpm_,
|
uint256 protocolFeePpm_,
|
||||||
address protocolFeeAddress_,
|
address protocolFeeAddress_,
|
||||||
IWETH9 wrapper_,
|
NativeWrapper wrapper_,
|
||||||
PartyPoolSwapImpl swapImpl_,
|
PartyPoolSwapImpl swapImpl_,
|
||||||
PartyPoolMintImpl mintImpl_
|
PartyPoolMintImpl mintImpl_
|
||||||
) external returns (IPartyPool) {
|
) external returns (IPartyPool) {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import {SafeERC20} from "../lib/openzeppelin-contracts/contracts/token/ERC20/uti
|
|||||||
import {ReentrancyGuard} from "../lib/openzeppelin-contracts/contracts/utils/ReentrancyGuard.sol";
|
import {ReentrancyGuard} from "../lib/openzeppelin-contracts/contracts/utils/ReentrancyGuard.sol";
|
||||||
import {ERC20Internal} from "./ERC20Internal.sol";
|
import {ERC20Internal} from "./ERC20Internal.sol";
|
||||||
import {IPartyPool} from "./IPartyPool.sol";
|
import {IPartyPool} from "./IPartyPool.sol";
|
||||||
import {IWETH9} from "./IWETH9.sol";
|
import {NativeWrapper} from "./NativeWrapper.sol";
|
||||||
import {LMSRStabilized} from "./LMSRStabilized.sol";
|
import {LMSRStabilized} from "./LMSRStabilized.sol";
|
||||||
import {PartyPoolBase} from "./PartyPoolBase.sol";
|
import {PartyPoolBase} from "./PartyPoolBase.sol";
|
||||||
|
|
||||||
@@ -19,7 +19,7 @@ contract PartyPoolMintImpl is PartyPoolBase {
|
|||||||
using LMSRStabilized for LMSRStabilized.State;
|
using LMSRStabilized for LMSRStabilized.State;
|
||||||
using SafeERC20 for IERC20;
|
using SafeERC20 for IERC20;
|
||||||
|
|
||||||
constructor(IWETH9 wrapper_) PartyPoolBase(wrapper_) {}
|
constructor(NativeWrapper wrapper_) PartyPoolBase(wrapper_) {}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Initialization Mint
|
// Initialization Mint
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import {ABDKMath64x64} from "../lib/abdk-libraries-solidity/ABDKMath64x64.sol";
|
|||||||
import {IERC20} from "../lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol";
|
import {IERC20} from "../lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol";
|
||||||
import {SafeERC20} from "../lib/openzeppelin-contracts/contracts/token/ERC20/utils/SafeERC20.sol";
|
import {SafeERC20} from "../lib/openzeppelin-contracts/contracts/token/ERC20/utils/SafeERC20.sol";
|
||||||
import {IPartyPool} from "./IPartyPool.sol";
|
import {IPartyPool} from "./IPartyPool.sol";
|
||||||
import {IWETH9} from "./IWETH9.sol";
|
import {NativeWrapper} from "./NativeWrapper.sol";
|
||||||
import {LMSRStabilized} from "./LMSRStabilized.sol";
|
import {LMSRStabilized} from "./LMSRStabilized.sol";
|
||||||
import {PartyPoolBase} from "./PartyPoolBase.sol";
|
import {PartyPoolBase} from "./PartyPoolBase.sol";
|
||||||
|
|
||||||
@@ -17,7 +17,7 @@ contract PartyPoolSwapImpl is PartyPoolBase {
|
|||||||
using LMSRStabilized for LMSRStabilized.State;
|
using LMSRStabilized for LMSRStabilized.State;
|
||||||
using SafeERC20 for IERC20;
|
using SafeERC20 for IERC20;
|
||||||
|
|
||||||
constructor(IWETH9 wrapper_) PartyPoolBase(wrapper_) {}
|
constructor(NativeWrapper wrapper_) PartyPoolBase(wrapper_) {}
|
||||||
|
|
||||||
function swapToLimitAmounts(
|
function swapToLimitAmounts(
|
||||||
uint256 inputTokenIndex,
|
uint256 inputTokenIndex,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
pragma solidity ^0.8.30;
|
pragma solidity ^0.8.30;
|
||||||
|
|
||||||
import {IERC20} from "../lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol";
|
import {IERC20} from "../lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol";
|
||||||
import {IWETH9} from "../src/IWETH9.sol";
|
import {NativeWrapper} from "../src/NativeWrapper.sol";
|
||||||
import {PartyPlanner} from "../src/PartyPlanner.sol";
|
import {PartyPlanner} from "../src/PartyPlanner.sol";
|
||||||
import {PartyPool} from "../src/PartyPool.sol";
|
import {PartyPool} from "../src/PartyPool.sol";
|
||||||
import {PartyPoolBalancedPair} from "../src/PartyPoolBalancedPair.sol";
|
import {PartyPoolBalancedPair} from "../src/PartyPoolBalancedPair.sol";
|
||||||
@@ -17,11 +17,11 @@ library Deploy {
|
|||||||
uint256 internal constant PROTOCOL_FEE_PPM = 100_000; // 10%
|
uint256 internal constant PROTOCOL_FEE_PPM = 100_000; // 10%
|
||||||
|
|
||||||
function newPartyPlanner() internal returns (PartyPlanner) {
|
function newPartyPlanner() internal returns (PartyPlanner) {
|
||||||
IWETH9 wrapper = new WETH9();
|
NativeWrapper wrapper = new WETH9();
|
||||||
return newPartyPlanner(wrapper);
|
return newPartyPlanner(wrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
function newPartyPlanner(IWETH9 wrapper) internal returns (PartyPlanner) {
|
function newPartyPlanner(NativeWrapper wrapper) internal returns (PartyPlanner) {
|
||||||
return new PartyPlanner(
|
return new PartyPlanner(
|
||||||
wrapper,
|
wrapper,
|
||||||
new PartyPoolSwapImpl(wrapper),
|
new PartyPoolSwapImpl(wrapper),
|
||||||
@@ -43,7 +43,7 @@ library Deploy {
|
|||||||
uint256 _flashFeePpm,
|
uint256 _flashFeePpm,
|
||||||
bool _stable
|
bool _stable
|
||||||
) internal returns (PartyPool) {
|
) internal returns (PartyPool) {
|
||||||
IWETH9 wrapper = new WETH9();
|
NativeWrapper wrapper = new WETH9();
|
||||||
return newPartyPool(name_, symbol_, tokens_, bases_, _kappa, _swapFeePpm, _flashFeePpm, wrapper, _stable);
|
return newPartyPool(name_, symbol_, tokens_, bases_, _kappa, _swapFeePpm, _flashFeePpm, wrapper, _stable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,7 +55,7 @@ library Deploy {
|
|||||||
int128 _kappa,
|
int128 _kappa,
|
||||||
uint256 _swapFeePpm,
|
uint256 _swapFeePpm,
|
||||||
uint256 _flashFeePpm,
|
uint256 _flashFeePpm,
|
||||||
IWETH9 wrapper,
|
NativeWrapper wrapper,
|
||||||
bool _stable
|
bool _stable
|
||||||
) internal returns (PartyPool) {
|
) internal returns (PartyPool) {
|
||||||
return _stable && tokens_.length == 2 ?
|
return _stable && tokens_.length == 2 ?
|
||||||
@@ -91,7 +91,7 @@ library Deploy {
|
|||||||
|
|
||||||
|
|
||||||
function newViewer() internal returns (PartyPoolViewer) {
|
function newViewer() internal returns (PartyPoolViewer) {
|
||||||
IWETH9 wrapper = new WETH9();
|
NativeWrapper wrapper = new WETH9();
|
||||||
return new PartyPoolViewer(new PartyPoolSwapImpl(wrapper), new PartyPoolMintImpl(wrapper));
|
return new PartyPoolViewer(new PartyPoolSwapImpl(wrapper), new PartyPoolMintImpl(wrapper));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import "@abdk/ABDKMath64x64.sol";
|
|||||||
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
|
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
|
||||||
import "../src/LMSRStabilized.sol";
|
import "../src/LMSRStabilized.sol";
|
||||||
import "../src/PartyPool.sol";
|
import "../src/PartyPool.sol";
|
||||||
import {IWETH9} from "../src/IWETH9.sol";
|
import {NativeWrapper} from "../src/NativeWrapper.sol";
|
||||||
import {PartyPlanner} from "../src/PartyPlanner.sol";
|
import {PartyPlanner} from "../src/PartyPlanner.sol";
|
||||||
import {Deploy} from "./Deploy.sol";
|
import {Deploy} from "./Deploy.sol";
|
||||||
import {PartyPoolViewer} from "../src/PartyPoolViewer.sol";
|
import {PartyPoolViewer} from "../src/PartyPoolViewer.sol";
|
||||||
@@ -272,7 +272,7 @@ contract NativeTest is Test {
|
|||||||
uint256 aliceEthBefore = alice.balance;
|
uint256 aliceEthBefore = alice.balance;
|
||||||
|
|
||||||
// Execute swapToLimit: token0 (index 0) -> WETH (index 2) with unwrap=true
|
// Execute swapToLimit: token0 (index 0) -> WETH (index 2) with unwrap=true
|
||||||
(uint256 amountInUsed, uint256 amountOut, uint256 fee) = pool.swapToLimit(
|
(uint256 amountInUsed, uint256 amountOut, /*uint256 fee*/) = pool.swapToLimit(
|
||||||
alice, // payer
|
alice, // payer
|
||||||
alice, // receiver
|
alice, // receiver
|
||||||
0, // inputTokenIndex (token0)
|
0, // inputTokenIndex (token0)
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
pragma solidity ^0.8.30;
|
pragma solidity ^0.8.30;
|
||||||
|
|
||||||
import {IWETH9} from "../src/IWETH9.sol";
|
import {NativeWrapper} from "../src/NativeWrapper.sol";
|
||||||
|
|
||||||
contract WETH9 is IWETH9 {
|
contract WETH9 is NativeWrapper {
|
||||||
string public name = "Wrapped Ether";
|
string public name = "Wrapped Ether";
|
||||||
string public symbol = "WETH";
|
string public symbol = "WETH";
|
||||||
uint8 public decimals = 18;
|
uint8 public decimals = 18;
|
||||||
|
|||||||
Reference in New Issue
Block a user