Verified contractPartialMIT
Current
Address0xec30c7b52b7b6811288249ee2ddaf77d3ec4880f
- Balance
0 ETH
- Transactions
1
- Compiler
solc 0.8.26
- Same code
Only this contract
Details
- Compiler
- solc 0.8.26+commit.8a97fa7a
- Language
- solidity
- Optimization
- Yes, 200 runs
- EVM version
- cancun
- Via IR
- yes
- License
- MIT
- Match
- Partialcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 26,336,719
- Creation transaction
- 0x01c331c386…af710bf2f7
src/Current.sol
// SPDX-License-Identifier: MIT
// Lubstr ($LUBSTR) · https://lubstr.xyz · https://x.com/MultiLUBSTR
pragma solidity ^0.8.26;
import {Ownable, Ownable2Step} from "@openzeppelin/contracts/access/Ownable2Step.sol";
/// @dev The two Arbitrum Inbox calls the Current needs (nitro-contracts IInbox).
interface IArbInbox {
function calculateRetryableSubmissionFee(uint256 dataLength, uint256 baseFee) external view returns (uint256);
function unsafeCreateRetryableTicket(
address to,
uint256 l2CallValue,
uint256 maxSubmissionCost,
address excessFeeRefundAddress,
address callValueRefundAddress,
uint256 gasLimit,
uint256 maxFeePerGas,
bytes calldata data
) external payable returns (uint256);
}
interface IReefIntake {
function receiveCurrent() external payable;
}
/// @notice The Current: the one thing that moves between the two chains. $LUBSTR lives at the same
/// addresses on Ethereum and on Robinhood Chain, and so does this contract.
///
/// Upstream (Ethereum, `inbox` set): the Reef drifts part of its Burrow share here, and
/// `flow()` sends it down Robinhood Chain's own Arbitrum bridge as a retryable ticket whose
/// recipient is THIS address on the other chain. No third-party bridge, no custodian.
/// Downstream (Robinhood Chain, `inbox` zero): ETH arrives from the bridge, and `flow()` hands
/// it to the Reef, which adds it to the Burrow: Ethereum's trading becomes locked liquidity
/// on Robinhood Chain. Rivers run one way.
///
/// @dev Every refund address on the ticket is this contract, which exists on the other chain because
/// it was deployed at the same nonce there; the "unsafe" variant is what skips the alias that
/// would otherwise strand refunds. Anyone may call `flow`; the owner only tunes the passage.
contract Current is Ownable2Step {
string public constant VERSION = "1";
/// @notice The Reef (hook) address; the same on every chain.
address public immutable reef;
/// @notice Robinhood Chain's delayed Inbox on Ethereum. Zero downstream.
IArbInbox public immutable inbox;
/// @notice L2 gas given to the ticket's automatic redeem (a plain ETH receive) and the most it
/// may pay per gas. Unused gas money is refunded to this contract on the other side.
uint64 public passageGas = 60_000;
uint64 public passageMaxFeePerGas = 1 gwei;
/// @notice Below this the water waits: an Ethereum ticket costs gas, so dust is not worth sending.
uint256 public minFlow = 0.005 ether;
uint256 public totalSentDownstream;
uint256 public totalFedToReef;
error NotEnoughWater(uint256 have, uint256 need);
error InvalidConfiguration();
event Flowed(uint256 amount, uint256 l2CallValue, uint256 indexed ticket);
event FedToReef(uint256 amount);
event PassageSet(uint64 passageGas, uint64 passageMaxFeePerGas, uint256 minFlow);
constructor(address reef_, address inbox_, address owner_) Ownable(owner_) {
if (reef_.code.length == 0 || (inbox_ != address(0) && inbox_.code.length == 0)) revert InvalidConfiguration();
reef = reef_;
inbox = IArbInbox(inbox_);
}
/// @dev ETH arrives from the Reef (upstream) or from the bridge (downstream).
receive() external payable {}
/// @notice Whether this is the Ethereum side (sends) or the Robinhood Chain side (feeds the Reef).
function upstream() public view returns (bool) {
return address(inbox) != address(0);
}
/// @notice ETH waiting to flow.
function headwater() external view returns (uint256) {
return address(this).balance;
}
/// @notice Moves everything here one step downstream. Anyone may call.
function flow() external returns (uint256 amount) {
amount = address(this).balance;
if (amount < minFlow || amount == 0) revert NotEnoughWater(amount, minFlow);
if (!upstream()) {
IReefIntake(reef).receiveCurrent{value: amount}();
totalFedToReef += amount;
emit FedToReef(amount);
return amount;
}
uint256 submission = inbox.calculateRetryableSubmissionFee(0, block.basefee);
uint256 passage = uint256(passageGas) * passageMaxFeePerGas;
if (amount <= submission + passage) revert NotEnoughWater(amount, submission + passage + 1);
uint256 callValue = amount - submission - passage;
uint256 ticket = inbox.unsafeCreateRetryableTicket{value: amount}(
address(this), callValue, submission, address(this), address(this), passageGas, passageMaxFeePerGas, ""
);
totalSentDownstream += callValue;
emit Flowed(amount, callValue, ticket);
}
function setPassage(uint64 passageGas_, uint64 passageMaxFeePerGas_, uint256 minFlow_) external onlyOwner {
if (passageGas_ < 21_000 || passageGas_ > 2_000_000 || passageMaxFeePerGas_ == 0 || minFlow_ > 10 ether) {
revert InvalidConfiguration();
}
passageGas = passageGas_;
passageMaxFeePerGas = passageMaxFeePerGas_;
minFlow = minFlow_;
emit PassageSet(passageGas_, passageMaxFeePerGas_, minFlow_);
}
}
lib/openzeppelin-contracts/contracts/access/Ownable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)
pragma solidity ^0.8.20;
import {Context} from "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* The initial owner is set to the address provided by the deployer. This can
* later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
/**
* @dev The caller account is not authorized to perform an operation.
*/
error OwnableUnauthorizedAccount(address account);
/**
* @dev The owner is not a valid owner account. (eg. `address(0)`)
*/
error OwnableInvalidOwner(address owner);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the address provided by the deployer as the initial owner.
*/
constructor(address initialOwner) {
if (initialOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(initialOwner);
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
if (owner() != _msgSender()) {
revert OwnableUnauthorizedAccount(_msgSender());
}
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
if (newOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
lib/openzeppelin-contracts/contracts/access/Ownable2Step.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (access/Ownable2Step.sol)
pragma solidity ^0.8.20;
import {Ownable} from "./Ownable.sol";
/**
* @dev Contract module which provides access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* This extension of the {Ownable} contract includes a two-step mechanism to transfer
* ownership, where the new owner must call {acceptOwnership} in order to replace the
* old one. This can help prevent common mistakes, such as transfers of ownership to
* incorrect accounts, or to contracts that are unable to interact with the
* permission system.
*
* The initial owner is specified at deployment time in the constructor for `Ownable`. This
* can later be changed with {transferOwnership} and {acceptOwnership}.
*
* This module is used through inheritance. It will make available all functions
* from parent (Ownable).
*/
abstract contract Ownable2Step is Ownable {
address private _pendingOwner;
event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);
/**
* @dev Returns the address of the pending owner.
*/
function pendingOwner() public view virtual returns (address) {
return _pendingOwner;
}
/**
* @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.
* Can only be called by the current owner.
*
* Setting `newOwner` to the zero address is allowed; this can be used to cancel an initiated ownership transfer.
*/
function transferOwnership(address newOwner) public virtual override onlyOwner {
_pendingOwner = newOwner;
emit OwnershipTransferStarted(owner(), newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual override {
delete _pendingOwner;
super._transferOwnership(newOwner);
}
/**
* @dev The new owner accepts the ownership transfer.
*/
function acceptOwnership() public virtual {
address sender = _msgSender();
if (pendingOwner() != sender) {
revert OwnableUnauthorizedAccount(sender);
}
_transferOwnership(sender);
}
}
lib/openzeppelin-contracts/contracts/utils/Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
pragma solidity ^0.8.20;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}
Compiler settingsShow
{
"viaIR": true,
"metadata": {
"appendCBOR": true,
"bytecodeHash": "ipfs",
"useLiteralContent": false
},
"libraries": {},
"optimizer": {
"runs": 200,
"enabled": true
},
"evmVersion": "cancun",
"remappings": [
"@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
"@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
"@uniswap/v4-core/=lib/v4-periphery/lib/v4-core/",
"@uniswap/v4-periphery/=lib/v4-periphery/",
"permit2/=lib/v4-periphery/lib/permit2/",
"solmate/=lib/v4-periphery/lib/v4-core/lib/solmate/",
"forge-std/=lib/forge-std/src/",
"lib/v4-periphery/lib/permit2/lib/forge-gas-snapshot/lib/forge-std/:ds-test/=lib/v4-periphery/lib/permit2/lib/forge-gas-snapshot/lib/forge-std/lib/ds-test/src/",
"lib/v4-periphery/lib/permit2/lib/forge-gas-snapshot/lib/forge-std/:ds-test/=lib/v4-periphery/lib/permit2/lib/forge-gas-snapshot/lib/forge-std/lib/ds-test/src/",
"lib/v4-periphery/lib/v4-core/lib/openzeppelin-contracts/lib/forge-std/:ds-test/=lib/v4-periphery/lib/v4-core/lib/openzeppelin-contracts/lib/forge-std/lib/ds-test/src/",
"lib/v4-periphery/lib/v4-core/lib/openzeppelin-contracts/lib/forge-std/:ds-test/=lib/v4-periphery/lib/v4-core/lib/openzeppelin-contracts/lib/forge-std/lib/ds-test/src/",
"lib/v4-periphery/lib/permit2/lib/forge-std/:ds-test/=lib/v4-periphery/lib/permit2/lib/forge-std/lib/ds-test/src/",
"lib/v4-periphery/lib/permit2/lib/forge-std/:ds-test/=lib/v4-periphery/lib/permit2/lib/forge-std/lib/ds-test/src/",
"lib/v4-periphery/lib/permit2/lib/solmate/:ds-test/=lib/v4-periphery/lib/permit2/lib/solmate/lib/ds-test/src/",
"lib/v4-periphery/lib/permit2/lib/solmate/:ds-test/=lib/v4-periphery/lib/permit2/lib/solmate/lib/ds-test/src/",
"lib/v4-periphery/lib/v4-core/lib/solmate/:ds-test/=lib/v4-periphery/lib/v4-core/lib/solmate/lib/ds-test/src/",
"lib/v4-periphery/lib/v4-core/lib/solmate/:ds-test/=lib/v4-periphery/lib/v4-core/lib/solmate/lib/ds-test/src/",
"lib/v4-periphery/lib/permit2/:openzeppelin-contracts/=lib/v4-periphery/lib/permit2/lib/openzeppelin-contracts/",
"lib/v4-periphery/lib/permit2/:openzeppelin-contracts/=lib/v4-periphery/lib/permit2/lib/openzeppelin-contracts/",
"lib/v4-periphery/lib/v4-core/:openzeppelin-contracts/=lib/v4-periphery/lib/v4-core/lib/openzeppelin-contracts/",
"lib/v4-periphery/lib/v4-core/:openzeppelin-contracts/=lib/v4-periphery/lib/v4-core/lib/openzeppelin-contracts/",
"@ensdomains/=lib/v4-periphery/lib/v4-core/node_modules/@ensdomains/",
"@openzeppelin/=lib/v4-periphery/lib/v4-core/lib/openzeppelin-contracts/",
"ds-test/=lib/v4-periphery/lib/permit2/lib/forge-std/lib/ds-test/src/",
"erc4626-tests/=lib/v4-periphery/lib/v4-core/lib/openzeppelin-contracts/lib/erc4626-tests/",
"forge-gas-snapshot/=lib/v4-periphery/lib/permit2/lib/forge-gas-snapshot/src/",
"hardhat/=lib/v4-periphery/lib/v4-core/node_modules/hardhat/",
"openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/",
"openzeppelin-contracts/=lib/openzeppelin-contracts/",
"v4-core/=lib/v4-periphery/lib/v4-core/src/",
"v4-periphery/=lib/v4-periphery/"
]
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.