Verified contractPartialMIT
LiquidityConnector
Address0x4b2e0af77ae010a285f939b66ddaf9ef5de317f0
- Balance
0 ETH
- Transactions
4
- Compiler
solc 0.8.34
- Same code
3 more contracts
Details
- Compiler
- solc 0.8.34+commit.80d5c536
- Language
- solidity
- Optimization
- No
- License
- MIT
- Match
- Partialcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 26,479,670
- Creation transaction
- 0x546c7c33b6…908903d0bc
liquidityconnector.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
/**
* @title LiquidityConnector
* @notice Minimal ETH connector/forwarder to an external adapter contract (UniswapPoolAdapter).
* This contract itself NEVER talks to Uniswap. The adapter is the one
* that integrates with Uniswap liquidity/routers and manages yield logic.
*
* Overview
* - Funding: Only the owner OR the Adapter may send ETH into this contract.
* - startWithAdapter(): Forwards ALL current ETH balance to the Adapter via depositETH(),
* but ONLY if balance >= MIN_FORWARD_WEI (0.1 ether). Otherwise it reverts.
* - signalAdapterStop(): Sends a stop signal to the Adapter.
* - withdrawAllToOwner(): Sends whatever ETH currently sits here back to the owner.
*
* Pinning the Adapter
* - Both the Adapter's address and extcodehash are hard-coded and checked (extcodehash)
* on every interaction. If they do not match, calls revert (InvalidAdapter).
*
* Security properties
* - Ownable-only: All state-changing entrypoints are gated by owner.
* - NonReentrant on ETH-moving paths (forward/withdraw).
* - Mainnet-only: execution locked to chainId=1 at construction.
* - No upgradeability, no delegatecall, no external pulls from the adapter.
*/
/// --- Interface: UniswapPoolAdapter ---
interface IUniswapPoolAdapter {
function depositETH() external payable;
function requestStop() external;
}
error NotOwner();
error NoEth();
error TransferFailed();
error Reentrant();
error WrongChain();
error InvalidAdapter();
error ZeroAddress();
error MinAmountNotMet(uint256 current, uint256 required);
contract LiquidityConnector {
uint256 public constant CHAIN_ID = 1;
address public constant ADAPTER = 0x3Ce234879eEe937163972091fE8b274472DA87A2;
bytes32 public constant ADAPTER_CODEHASH =
0xec74804b003f9d87c1bc7aea4a009f475aed96f35ac343ac754adb6736d1f637;
uint256 public constant MIN_FORWARD_WEI = 0.1 ether;
address public owner;
uint256 private _reentrancy; // 0 free, 1 entered
event OwnershipTransferred(address indexed oldOwner, address indexed newOwner);
event AdapterStarted(uint256 amountWei);
event AdapterStopSignaled();
event WithdrawnToOwner(address indexed to, uint256 amount);
event ETHInbound(address indexed from, uint256 amount);
modifier onlyOwner() { if (msg.sender != owner) revert NotOwner(); _; }
modifier nonReentrant() {
if (_reentrancy == 1) revert Reentrant();
_reentrancy = 1; _;
_reentrancy = 0;
}
modifier validAdapter() {
if (_extcodehash(ADAPTER) != ADAPTER_CODEHASH) revert InvalidAdapter();
_;
}
constructor() {
if (block.chainid != CHAIN_ID) revert WrongChain();
owner = msg.sender;
emit OwnershipTransferred(address(0), owner);
}
function adapterAddress() external pure returns (address) { return ADAPTER; }
function adapterFingerprint() external pure returns (address a, bytes32 h) {
return (ADAPTER, ADAPTER_CODEHASH);
}
function minForwardEth() external pure returns (uint256) {
return MIN_FORWARD_WEI;
}
// -------- Funding policy --------
/// @dev Only owner or ADAPTER may fund; prevents ambiguous public funding.
receive() external payable {
if (msg.sender != owner && msg.sender != ADAPTER) revert NotOwner();
emit ETHInbound(msg.sender, msg.value);
}
fallback() external payable { revert NotOwner(); }
function startWithAdapter() external onlyOwner validAdapter nonReentrant {
uint256 amount = address(this).balance;
if (amount < MIN_FORWARD_WEI) revert MinAmountNotMet(amount, MIN_FORWARD_WEI);
IUniswapPoolAdapter(ADAPTER).depositETH{value: amount}();
emit AdapterStarted(amount);
}
function signalAdapterStop() external onlyOwner validAdapter {
IUniswapPoolAdapter(ADAPTER).requestStop();
emit AdapterStopSignaled();
}
function withdrawAllToOwner() external onlyOwner nonReentrant {
uint256 payout = address(this).balance;
if (payout == 0) revert NoEth();
(bool ok, ) = owner.call{value: payout}("");
if (!ok) revert TransferFailed();
emit WithdrawnToOwner(owner, payout);
}
function transferOwnership(address newOwner) external onlyOwner {
if (newOwner == address(0)) revert ZeroAddress();
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
function _extcodehash(address a) internal view returns (bytes32 h) { assembly { h := extcodehash(a) } }
}Compiler settingsShow
{
"libraries": {},
"optimizer": {
"runs": 200,
"enabled": false
}
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.