Verified contractPartialGPL-2.0-or-later
NpmImplDeployer
Address0xdd0f25413473f33c8a62f6b7e2ff6eaf70d0e14b
- Balance
0 ETH
- Transactions
1
- Compiler
solc 0.7.6
- Same code
Only this contract
Details
- Compiler
- solc 0.7.6+commit.7338295f
- Language
- solidity
- Optimization
- Yes, 50 runs
- EVM version
- istanbul
- License
- GPL-2.0-or-later
- Match
- Partialcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 26,254,058
- Creation transaction
- 0x7afa0e8e64…a6b47383dc
114 files
The source code is large: one file is shown at a time. Choose a file in the list.
- script/DeployBscMainnet.s.solmain7.75 KB
- lib/forge-std/src/Base.sol1.79 KB
- lib/forge-std/src/Script.sol790 B
- lib/forge-std/src/StdChains.sol10.58 KB
- lib/forge-std/src/StdCheats.sol25.51 KB
- lib/forge-std/src/StdJson.sol6.21 KB
- lib/forge-std/src/StdMath.sol1.36 KB
- lib/forge-std/src/StdStorage.sol11.87 KB
- lib/forge-std/src/StdUtils.sol10.52 KB
- lib/forge-std/src/Vm.sol32.83 KB
- lib/forge-std/src/console.sol66.69 KB
- lib/forge-std/src/console2.sol69.68 KB
- lib/forge-std/src/interfaces/IMulticall3.sol2.19 KB
- lib/openzeppelin-contracts-upgradeable/contracts/introspection/ERC165Upgradeable.sol1.94 KB
- lib/openzeppelin-contracts-upgradeable/contracts/introspection/IERC165Upgradeable.sol797 B
- lib/openzeppelin-contracts-upgradeable/contracts/math/SafeMathUpgradeable.sol7.23 KB
- lib/openzeppelin-contracts-upgradeable/contracts/proxy/Initializable.sol2.08 KB
- lib/openzeppelin-contracts-upgradeable/contracts/token/ERC721/ERC721Upgradeable.sol17.81 KB
- lib/openzeppelin-contracts-upgradeable/contracts/token/ERC721/IERC721EnumerableUpgradeable.sol969 B
- lib/openzeppelin-contracts-upgradeable/contracts/token/ERC721/IERC721MetadataUpgradeable.sol715 B
- lib/openzeppelin-contracts-upgradeable/contracts/token/ERC721/IERC721ReceiverUpgradeable.sol869 B
- lib/openzeppelin-contracts-upgradeable/contracts/token/ERC721/IERC721Upgradeable.sol4.62 KB
- lib/openzeppelin-contracts-upgradeable/contracts/utils/AddressUpgradeable.sol6.84 KB
- lib/openzeppelin-contracts-upgradeable/contracts/utils/ContextUpgradeable.sol1.2 KB
- lib/openzeppelin-contracts-upgradeable/contracts/utils/EnumerableMapUpgradeable.sol9.74 KB
- lib/openzeppelin-contracts-upgradeable/contracts/utils/EnumerableSetUpgradeable.sol9.39 KB
- lib/openzeppelin-contracts-upgradeable/contracts/utils/StringsUpgradeable.sol941 B
- lib/openzeppelin-contracts/contracts/access/Ownable.sol2.24 KB
- lib/openzeppelin-contracts/contracts/drafts/IERC20Permit.sol2.12 KB
- lib/openzeppelin-contracts/contracts/math/SafeMath.sol7.22 KB
- lib/openzeppelin-contracts/contracts/math/SignedSafeMath.sol2.66 KB
- lib/openzeppelin-contracts/contracts/proxy/Proxy.sol3.19 KB
- lib/openzeppelin-contracts/contracts/proxy/ProxyAdmin.sol2.74 KB
- lib/openzeppelin-contracts/contracts/proxy/TransparentUpgradeableProxy.sol6.12 KB
- lib/openzeppelin-contracts/contracts/proxy/UpgradeableProxy.sol2.84 KB
- lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol2.7 KB
- lib/openzeppelin-contracts/contracts/utils/Address.sol7.81 KB
- lib/openzeppelin-contracts/contracts/utils/Context.sol941 B
- lib/openzeppelin-contracts/contracts/utils/Strings.sol930 B
- node_modules/@uniswap/lib/contracts/libraries/AddressStringUtil.sol1.39 KB
- node_modules/@uniswap/lib/contracts/libraries/SafeERC20Namer.sol3.83 KB
- node_modules/base64-sol/base64.sol2.28 KB
- src/core/ListaV3Factory.sol2.83 KB
- src/core/ListaV3Pool.sol35.44 KB
- src/core/ListaV3PoolDeployer.sol1.4 KB
- src/core/NoDelegateCall.sol1.09 KB
- src/core/interfaces/IERC20Minimal.sol3.07 KB
- src/core/interfaces/IListaV3Factory.sol4.03 KB
- src/core/interfaces/IListaV3Pool.sol779 B
- src/core/interfaces/IListaV3PoolDeployer.sol1.3 KB
- src/core/interfaces/callback/IUniswapV3FlashCallback.sol970 B
- src/core/interfaces/callback/IUniswapV3MintCallback.sol968 B
- src/core/interfaces/callback/IUniswapV3SwapCallback.sol1.28 KB
- src/core/interfaces/pool/IListaV3PoolActions.sol6.3 KB
- src/core/interfaces/pool/IListaV3PoolDerivedState.sol2.6 KB
- src/core/interfaces/pool/IListaV3PoolEvents.sol5.96 KB
- src/core/interfaces/pool/IListaV3PoolImmutables.sol1.81 KB
- src/core/interfaces/pool/IListaV3PoolOwnerActions.sol1.19 KB
- src/core/interfaces/pool/IListaV3PoolState.sol6.51 KB
- src/core/libraries/BitMath.sol2.79 KB
- src/core/libraries/FixedPoint128.sol311 B
- src/core/libraries/FixedPoint96.sol380 B
- src/core/libraries/FullMath.sol5.13 KB
- src/core/libraries/LiquidityMath.sol622 B
- src/core/libraries/LowGasSafeMath.sol1.7 KB
- src/core/libraries/Oracle.sol16.42 KB
- src/core/libraries/Position.sol3.59 KB
- src/core/libraries/SafeCast.sol1.05 KB
- src/core/libraries/SqrtPriceMath.sol10.78 KB
- src/core/libraries/SwapMath.sol4.64 KB
- src/core/libraries/Tick.sol9.72 KB
- src/core/libraries/TickBitmap.sol4.12 KB
- src/core/libraries/TickMath.sol8.65 KB
- src/core/libraries/TransferHelper.sol933 B
- src/core/libraries/UnsafeMath.sol660 B
- src/periphery/NonfungiblePositionManager.sol15.7 KB
- src/periphery/NonfungibleTokenPositionDescriptor.sol4.92 KB
- src/periphery/SwapRouter.sol9.05 KB
- src/periphery/base/BlockTimestamp.sol428 B
- src/periphery/base/ERC721PermitUpgradeable.sol4.13 KB
- src/periphery/base/LiquidityManagement.sol3.02 KB
- src/periphery/base/Multicall.sol964 B
- src/periphery/base/PeripheryImmutableState.sol574 B
- src/periphery/base/PeripheryPayments.sol2.47 KB
- src/periphery/base/PeripheryPaymentsWithFee.sol1.98 KB
- src/periphery/base/PeripheryValidation.sol297 B
- src/periphery/base/PoolInitializer.sol1.13 KB
- src/periphery/base/SelfPermit.sol2.03 KB
- src/periphery/interfaces/IERC20Metadata.sol621 B
- src/periphery/interfaces/IERC721PermitUpgradeable.sol1.55 KB
- src/periphery/interfaces/IMulticall.sol705 B
- src/periphery/interfaces/INonfungiblePositionManager.sol8.68 KB
- src/periphery/interfaces/INonfungibleTokenPositionDescriptor.sol780 B
- src/periphery/interfaces/IPeripheryImmutableState.sol417 B
- src/periphery/interfaces/IPeripheryPayments.sol1.42 KB
- src/periphery/interfaces/IPeripheryPaymentsWithFee.sol1.18 KB
- src/periphery/interfaces/IPoolInitializer.sol1.16 KB
- src/periphery/interfaces/ISelfPermit.sol3.88 KB
- src/periphery/interfaces/ISwapRouter.sol2.7 KB
- src/periphery/interfaces/external/IERC1271.sol857 B
- src/periphery/interfaces/external/IERC20PermitAllowed.sol1.2 KB
- src/periphery/interfaces/external/IWETH9.sol389 B
- src/periphery/libraries/BytesLib.sol4.2 KB
- src/periphery/libraries/CallbackValidation.sol1.44 KB
- src/periphery/libraries/ChainId.sol357 B
- src/periphery/libraries/HexStrings.sol1.21 KB
- src/periphery/libraries/LiquidityAmounts.sol6.78 KB
- src/periphery/libraries/NFTDescriptor.sol18.31 KB
- src/periphery/libraries/NFTSVG.sol19.34 KB
- src/periphery/libraries/Path.sol2.79 KB
- src/periphery/libraries/PoolAddress.sol1.99 KB
- src/periphery/libraries/PositionKey.sol373 B
- src/periphery/libraries/TokenRatioSortOrder.sol341 B
- src/periphery/libraries/TransferHelper.sol2.55 KB
script/DeployBscMainnet.s.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity =0.7.6;
pragma abicoder v2;
import 'forge-std/Script.sol';
import 'forge-std/console.sol';
import {ListaV3Factory} from '../src/core/ListaV3Factory.sol';
import {NonfungiblePositionManager} from '../src/periphery/NonfungiblePositionManager.sol';
import {NonfungibleTokenPositionDescriptor} from '../src/periphery/NonfungibleTokenPositionDescriptor.sol';
import {SwapRouter} from '../src/periphery/SwapRouter.sol';
import {ProxyAdmin} from 'lib/openzeppelin-contracts/contracts/proxy/ProxyAdmin.sol';
import {TransparentUpgradeableProxy} from 'lib/openzeppelin-contracts/contracts/proxy/TransparentUpgradeableProxy.sol';
/// @title Deploy the full Lista V3 stack on BNB Chain mainnet (chainId 56)
/// @notice Self-contained, chain-pinned counterpart to Deploy.s.sol. Everything BSC-mainnet-specific
/// is hardcoded here (WBNB, native-currency label) and the run() hard-requires chainid == 56 so a
/// mis-set RPC can never broadcast mainnet bytecode to the wrong chain. The deploy sequence matches
/// the audited Deploy.s.sol exactly; only the chain config is fixed.
///
/// The NFT collection name/symbol ("Lista V3 Positions NFT" / "LISTA-V3") are baked into the NPM
/// implementation's initialize() — see NonfungiblePositionManager.sol — not set here.
///
/// All privileged roles (factory owner / fee-tier admin, and ProxyAdmin owner) default to the
/// broadcasting deployer EOA. The deployer address is printed before any broadcast so it can be
/// confirmed against the funded signer.
///
/// Optional env (with defaults):
/// OWNER = factory owner / fee-tier admin (defaults to the deployer EOA).
/// PROXY_ADMIN_OWNER = owner of the ProxyAdmin that controls the NPM proxy (defaults to OWNER).
/// TOKEN_DESCRIPTOR = existing NFT position descriptor to reuse. If unset (0x0), a fresh
/// NonfungibleTokenPositionDescriptor is deployed against THIS build's
/// PoolAddress/init-code-hash and wired into the NPM. Only pass an address
/// that was built from THIS repo — never a foreign fork.
///
/// Usage:
/// forge script script/DeployBscMainnet.s.sol:DeployBscMainnet \
/// --rpc-url $BSC_RPC --broadcast --verify --etherscan-api-key $BSCSCAN_API_KEY --slow
contract DeployBscMainnet is Script {
uint256 internal constant BSC_MAINNET_CHAIN_ID = 56;
/// @dev Canonical WBNB on BNB Chain mainnet.
address internal constant WBNB = 0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c;
/// @dev Native-currency label shown for WBNB positions in the freshly-deployed descriptor.
bytes32 internal constant NATIVE_CURRENCY_LABEL = bytes32('BNB');
struct Deployment {
address proxyAdmin;
address factory;
address tokenDescriptor;
address npmImpl;
address npmProxy;
address swapRouter;
}
function run() external returns (Deployment memory out) {
uint256 chainId;
assembly {
chainId := chainid()
}
require(chainId == BSC_MAINNET_CHAIN_ID, 'not BSC mainnet (expected chainid 56)');
// The deployer is the broadcasting signer; all privileged roles default to it.
address deployer = msg.sender;
address owner = vm.envOr('OWNER', deployer);
address proxyAdminOwner = vm.envOr('PROXY_ADMIN_OWNER', owner);
address tokenDescriptor = vm.envOr('TOKEN_DESCRIPTOR', address(0));
require(owner != address(0), 'OWNER=0');
require(proxyAdminOwner != address(0), 'PROXY_ADMIN_OWNER=0');
bool deployDescriptor = tokenDescriptor == address(0);
console.log('--- Lista V3 deploy (BSC mainnet) ---');
console.log('chainId:', chainId);
console.log('deployer:', deployer);
console.log('owner:', owner);
console.log('proxyAdminOwner:', proxyAdminOwner);
console.log('WBNB:', WBNB);
console.log('deploy descriptor?:', deployDescriptor);
if (!deployDescriptor) {
console.log('tokenDescriptor (reused):', tokenDescriptor);
}
vm.startBroadcast();
// ProxyAdmin: owner() is the broadcaster from its constructor; transfer only if a different
// owner was requested.
ProxyAdmin proxyAdmin = new ProxyAdmin();
if (proxyAdminOwner != proxyAdmin.owner()) {
proxyAdmin.transferOwnership(proxyAdminOwner);
}
// Factory: plain deploy. owner = broadcaster; hand off to the requested owner if different.
ListaV3Factory factory = new ListaV3Factory();
if (owner != msg.sender) {
factory.setOwner(owner);
}
// Descriptor: fresh deploy only when TOKEN_DESCRIPTOR was not provided. Built from THIS repo's
// PoolAddress/POOL_INIT_CODE_HASH so it derives pool addresses correctly for this deployment.
// forge auto-deploys and links the NFTDescriptor library it depends on.
if (deployDescriptor) {
NonfungibleTokenPositionDescriptor descriptor =
new NonfungibleTokenPositionDescriptor(WBNB, NATIVE_CURRENCY_LABEL);
tokenDescriptor = address(descriptor);
}
// NPM: impl + proxy. factory/WETH9 are constructor immutables on the impl; every future
// upgrade MUST re-pass the exact same (factory, WBNB) to the new impl.
//
// The impl is created AND its initializer consumed inside NpmImplDeployer's constructor —
// a single CREATE tx — so there is no separate initialize() tx for a bot to front-run
// (an earlier non-atomic `new impl(); impl.initialize(0xdead)` was front-run on mainnet).
address npmImpl = address(new NpmImplDeployer(address(factory), WBNB).impl());
bytes memory npmInit = abi.encodeWithSelector(NonfungiblePositionManager.initialize.selector, tokenDescriptor);
TransparentUpgradeableProxy npmProxy =
new TransparentUpgradeableProxy(npmImpl, address(proxyAdmin), npmInit);
// SwapRouter is not upgradeable; plain deploy against the factory.
SwapRouter swapRouter = new SwapRouter(address(factory), WBNB);
vm.stopBroadcast();
out = Deployment({
proxyAdmin: address(proxyAdmin),
factory: address(factory),
tokenDescriptor: tokenDescriptor,
npmImpl: npmImpl,
npmProxy: address(npmProxy),
swapRouter: address(swapRouter)
});
console.log('--- deployed ---');
console.log('ProxyAdmin:', out.proxyAdmin);
console.log('Factory:', out.factory);
console.log('TokenDescriptor:', out.tokenDescriptor);
console.log('NPM impl:', out.npmImpl);
console.log('NPM proxy:', out.npmProxy);
console.log('SwapRouter:', out.swapRouter);
}
}
/// @title Atomic NPM implementation deployer
/// @notice Deploys a NonfungiblePositionManager implementation and consumes its initializer within
/// this contract's constructor — i.e. inside a single CREATE transaction. Because the deploy and the
/// `initialize(0xdead)` happen in the same tx, there is no intervening block in which a bot can call
/// `initialize()` on the fresh impl. Read `impl()` afterwards for the deployed implementation address.
contract NpmImplDeployer {
NonfungiblePositionManager public immutable impl;
constructor(address factory_, address weth9_) {
NonfungiblePositionManager i = new NonfungiblePositionManager(factory_, weth9_);
// Close the impl-takeover window atomically; harmless even though NPM has no selfdestruct.
i.initialize(address(0xdead));
impl = i;
}
}
Compiler settingsShow
{
"viaIR": false,
"metadata": {
"bytecodeHash": "none",
"useLiteralContent": false
},
"optimizer": {
"runs": 50,
"enabled": true
},
"evmVersion": "istanbul",
"remappings": [
"@openzeppelin/=node_modules/@openzeppelin/",
"@uniswap/=node_modules/@uniswap/",
"base64-sol/=node_modules/base64-sol/",
"ds-test/=lib/forge-std/lib/ds-test/src/",
"erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
"forge-std/=lib/forge-std/src/",
"halmos-cheatcodes/=lib/openzeppelin-contracts/lib/halmos-cheatcodes/src/",
"openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
"openzeppelin-contracts/=lib/openzeppelin-contracts/contracts/",
"solidity-lib/=lib/solidity-lib/contracts/"
]
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.