编译器
0.8.15+commit.e14f2714
文件 1 的 10:AddressAliasHelper.sol
pragma solidity ^0.8.0;
library AddressAliasHelper {
uint160 internal constant OFFSET = uint160(0x1111000000000000000000000000000000001111);
function applyL1ToL2Alias(address l1Address) internal pure returns (address l2Address) {
unchecked {
l2Address = address(uint160(l1Address) + OFFSET);
}
}
function undoL1ToL2Alias(address l2Address) internal pure returns (address l1Address) {
unchecked {
l1Address = address(uint160(l2Address) - OFFSET);
}
}
}
文件 2 的 10:IBridge.sol
pragma solidity >=0.6.9 <0.9.0;
interface IBridge {
event MessageDelivered(
uint256 indexed messageIndex,
bytes32 indexed beforeInboxAcc,
address inbox,
uint8 kind,
address sender,
bytes32 messageDataHash
);
event BridgeCallTriggered(
address indexed outbox,
address indexed destAddr,
uint256 amount,
bytes data
);
event InboxToggle(address indexed inbox, bool enabled);
event OutboxToggle(address indexed outbox, bool enabled);
function deliverMessageToInbox(
uint8 kind,
address sender,
bytes32 messageDataHash
) external payable returns (uint256);
function executeCall(
address destAddr,
uint256 amount,
bytes calldata data
) external returns (bool success, bytes memory returnData);
function setInbox(address inbox, bool enabled) external;
function setOutbox(address inbox, bool enabled) external;
function activeOutbox() external view returns (address);
function allowedInboxes(address inbox) external view returns (bool);
function allowedOutboxes(address outbox) external view returns (bool);
function inboxAccs(uint256 index) external view returns (bytes32);
function messageCount() external view returns (uint256);
function isNitroReady() external view returns (uint256);
}
文件 3 的 10:IInbox.sol
pragma solidity >=0.6.9 <0.9.0;
import "./IBridge.sol";
import "./IMessageProvider.sol";
interface IInbox is IMessageProvider {
function sendL2Message(bytes calldata messageData) external returns (uint256);
function sendUnsignedTransaction(
uint256 maxGas,
uint256 gasPriceBid,
uint256 nonce,
address destAddr,
uint256 amount,
bytes calldata data
) external returns (uint256);
function sendContractTransaction(
uint256 maxGas,
uint256 gasPriceBid,
address destAddr,
uint256 amount,
bytes calldata data
) external returns (uint256);
function sendL1FundedUnsignedTransaction(
uint256 maxGas,
uint256 gasPriceBid,
uint256 nonce,
address destAddr,
bytes calldata data
) external payable returns (uint256);
function sendL1FundedContractTransaction(
uint256 maxGas,
uint256 gasPriceBid,
address destAddr,
bytes calldata data
) external payable returns (uint256);
function createRetryableTicket(
address destAddr,
uint256 arbTxCallValue,
uint256 maxSubmissionCost,
address submissionRefundAddress,
address valueRefundAddress,
uint256 maxGas,
uint256 gasPriceBid,
bytes calldata data
) external payable returns (uint256);
function unsafeCreateRetryableTicket(
address destAddr,
uint256 arbTxCallValue,
uint256 maxSubmissionCost,
address submissionRefundAddress,
address valueRefundAddress,
uint256 maxGas,
uint256 gasPriceBid,
bytes calldata data
) external payable returns (uint256);
function depositEth(uint256 maxSubmissionCost) external payable returns (uint256);
function bridge() external view returns (IBridge);
function pauseCreateRetryables() external;
function unpauseCreateRetryables() external;
function startRewriteAddress() external;
function stopRewriteAddress() external;
}
文件 4 的 10:IMessageProvider.sol
pragma solidity >=0.6.9 <0.9.0;
interface IMessageProvider {
event InboxMessageDelivered(uint256 indexed messageNum, bytes data);
event InboxMessageDeliveredFromOrigin(uint256 indexed messageNum);
}
文件 5 的 10:IRateProvider.sol
pragma solidity ^0.8.0;
interface IRateProvider {
function getRate() external view returns (uint256);
}
文件 6 的 10:RocketArbitrumPriceMessenger.sol
pragma solidity ^0.8.13;
import "@arb-bridge-eth/contracts/bridge/interfaces/IInbox.sol";
import "rocketpool/contracts/interface/network/RocketNetworkBalancesInterface.sol";
import "rocketpool/contracts/interface/RocketStorageInterface.sol";
contract RocketArbitrumPriceMessenger {
RocketStorageInterface immutable rocketStorage;
bytes32 immutable rocketNetworkBalancesKey;
IInbox immutable public inbox;
uint256 lastRate;
address public l2Target;
constructor(RocketStorageInterface _rocketStorage, address _inbox) {
rocketStorage = _rocketStorage;
inbox = IInbox(_inbox);
rocketNetworkBalancesKey = keccak256(abi.encodePacked("contract.address", "rocketNetworkBalances"));
}
function updateL2Target(address _l2Target) public {
require(l2Target == address(0));
l2Target = _l2Target;
}
function rateStale() external view returns (bool) {
return rate() != lastRate;
}
function rate() public view returns (uint256) {
RocketNetworkBalancesInterface rocketNetworkBalances = RocketNetworkBalancesInterface(rocketStorage.getAddress(rocketNetworkBalancesKey));
uint256 supply = rocketNetworkBalances.getTotalRETHSupply();
if (supply == 0) {
return 0;
}
return 1 ether * rocketNetworkBalances.getTotalETHBalance() / supply;
}
function submitRate(uint256 _maxSubmissionCost, uint256 _gasLimit, uint256 _gasPriceBid) external payable {
lastRate = rate();
bytes memory data = abi.encodeWithSignature('updateRate(uint256)', lastRate);
inbox.createRetryableTicket{value: msg.value}(
l2Target,
0,
_maxSubmissionCost,
msg.sender,
msg.sender,
_gasLimit,
_gasPriceBid,
data
);
}
}
文件 7 的 10:RocketArbitrumPriceOracle.sol
pragma solidity ^0.8.13;
import "@arbitrum/nitro-contracts/src/libraries/AddressAliasHelper.sol";
contract RocketArbitrumPriceOracle {
event RateUpdated(uint256 rate);
uint256 public rate;
uint256 public lastUpdated;
address public owner;
constructor() {
owner = msg.sender;
}
function setOwner(address _newOwner) external {
require(msg.sender == owner, "Not owner");
owner = _newOwner;
}
function updateRate(uint256 _newRate) external {
require(msg.sender == AddressAliasHelper.applyL1ToL2Alias(owner));
rate = _newRate;
lastUpdated = block.timestamp;
emit RateUpdated(_newRate);
}
}
文件 8 的 10:RocketBalancerRateProvider.sol
pragma solidity ^0.8.13;
import "./RocketArbitrumPriceOracle.sol";
import "./interfaces/balancer/IRateProvider.sol";
contract RocketBalancerRateProvider is IRateProvider {
RocketArbitrumPriceOracle immutable oracle;
constructor(RocketArbitrumPriceOracle _oracle) {
oracle = _oracle;
}
function getRate() external override view returns (uint256) {
return oracle.rate();
}
}
文件 9 的 10:RocketNetworkBalancesInterface.sol
pragma solidity >0.5.0 <0.9.0;
interface RocketNetworkBalancesInterface {
function getBalancesBlock() external view returns (uint256);
function getLatestReportableBlock() external view returns (uint256);
function getTotalETHBalance() external view returns (uint256);
function getStakingETHBalance() external view returns (uint256);
function getTotalRETHSupply() external view returns (uint256);
function getETHUtilizationRate() external view returns (uint256);
function submitBalances(uint256 _block, uint256 _total, uint256 _staking, uint256 _rethSupply) external;
function executeUpdateBalances(uint256 _block, uint256 _totalEth, uint256 _stakingEth, uint256 _rethSupply) external;
}
文件 10 的 10:RocketStorageInterface.sol
pragma solidity >0.5.0 <0.9.0;
interface RocketStorageInterface {
function getDeployedStatus() external view returns (bool);
function getGuardian() external view returns(address);
function setGuardian(address _newAddress) external;
function confirmGuardian() external;
function getAddress(bytes32 _key) external view returns (address);
function getUint(bytes32 _key) external view returns (uint);
function getString(bytes32 _key) external view returns (string memory);
function getBytes(bytes32 _key) external view returns (bytes memory);
function getBool(bytes32 _key) external view returns (bool);
function getInt(bytes32 _key) external view returns (int);
function getBytes32(bytes32 _key) external view returns (bytes32);
function setAddress(bytes32 _key, address _value) external;
function setUint(bytes32 _key, uint _value) external;
function setString(bytes32 _key, string calldata _value) external;
function setBytes(bytes32 _key, bytes calldata _value) external;
function setBool(bytes32 _key, bool _value) external;
function setInt(bytes32 _key, int _value) external;
function setBytes32(bytes32 _key, bytes32 _value) external;
function deleteAddress(bytes32 _key) external;
function deleteUint(bytes32 _key) external;
function deleteString(bytes32 _key) external;
function deleteBytes(bytes32 _key) external;
function deleteBool(bytes32 _key) external;
function deleteInt(bytes32 _key) external;
function deleteBytes32(bytes32 _key) external;
function addUint(bytes32 _key, uint256 _amount) external;
function subUint(bytes32 _key, uint256 _amount) external;
function getNodeWithdrawalAddress(address _nodeAddress) external view returns (address);
function getNodePendingWithdrawalAddress(address _nodeAddress) external view returns (address);
function setWithdrawalAddress(address _nodeAddress, address _newWithdrawalAddress, bool _confirm) external;
function confirmWithdrawalAddress(address _nodeAddress) external;
}
{
"compilationTarget": {
"src/RocketArbitrumPriceMessenger.sol": "RocketArbitrumPriceMessenger"
},
"evmVersion": "london",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 10000
},
"remappings": [
":@arb-bridge-eth/=lib/arbitrum/packages/arb-bridge-eth/",
":@arbitrum/nitro-contracts/=lib/nitro/contracts/",
":@openzeppelin/=lib/openzeppelin-contracts/",
":@rocketpool/=lib/rocketpool/contracts/",
":arbitrum/=lib/arbitrum/",
":ds-test/=lib/forge-std/lib/ds-test/src/",
":erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
":forge-std/=lib/forge-std/src/",
":fx-portal/=lib/fx-portal/contracts/",
":nitro/=lib/nitro/",
":openzeppelin-contracts/=lib/openzeppelin-contracts/contracts/",
":rocketpool/=lib/rocketpool/",
":script/=script/",
":src/=src/",
":test/=test/"
]
}
[{"inputs":[{"internalType":"contract RocketStorageInterface","name":"_rocketStorage","type":"address"},{"internalType":"address","name":"_inbox","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"inbox","outputs":[{"internalType":"contract IInbox","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"l2Target","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rateStale","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_maxSubmissionCost","type":"uint256"},{"internalType":"uint256","name":"_gasLimit","type":"uint256"},{"internalType":"uint256","name":"_gasPriceBid","type":"uint256"}],"name":"submitRate","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_l2Target","type":"address"}],"name":"updateL2Target","outputs":[],"stateMutability":"nonpayable","type":"function"}]