Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export LOCALHOST_RPC_URL=http://127.0.0.1:8545

# Mainnet RPC URLs
export MAINNET_RPC_URL=
export LINEA_RPC_URL=

# Testnet RPC URLs
export SEPOLIA_RPC_URL=
Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ deploy-swap-facility-mainnet: deploy-swap-facility
deploy-swap-facility-sepolia: RPC_URL=$(SEPOLIA_RPC_URL)
deploy-swap-facility-sepolia: deploy-swap-facility

deploy-swap-facility-linea: RPC_URL=$(LINEA_RPC_URL)
deploy-swap-facility-linea: deploy-swap-facility

upgrade-swap-facility:
FOUNDRY_PROFILE=production PRIVATE_KEY=$(PRIVATE_KEY) \
forge script script/upgrade/UpgradeSwapFacility.s.sol:UpgradeSwapFacility \
Expand Down
70 changes: 70 additions & 0 deletions broadcast/DeploySwapFacility.s.sol/59144/run-1754962087.json

Large diffs are not rendered by default.

218 changes: 218 additions & 0 deletions broadcast/DeploySwapFacility.s.sol/59144/run-latest.json

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions deployments/59144.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extensionAddresses": [],
"extensionNames": [],
"swapAdapter": "0x0000000000000000000000000000000000000000",
"swapFacility": "0xB6807116b3B1B321a390594e31ECD6e0076f6278"
}
1 change: 1 addition & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ depth = 250
localhost = "${LOCALHOST_RPC_URL}"
mainnet = "${MAINNET_RPC_URL}"
sepolia = "${SEPOLIA_RPC_URL}"
linea = "${LINEA_RPC_URL}"

[etherscan]
mainnet = { key = "${ETHERSCAN_API_KEY}", url = "https://api.etherscan.io/api" }
Expand Down
10 changes: 10 additions & 0 deletions script/Config.sol
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ contract Config {
uint256 public constant ETHEREUM_CHAIN_ID = 1;
uint256 public constant ARBITRUM_CHAIN_ID = 42161;
uint256 public constant OPTIMISM_CHAIN_ID = 10;
uint256 public constant LINEA_CHAIN_ID = 59144;

// Testnet chain IDs
uint256 public constant LOCAL_CHAIN_ID = 31337;
Expand Down Expand Up @@ -90,6 +91,15 @@ contract Config {
return config;
}

if (chainId_ == LINEA_CHAIN_ID) {
config.mToken = M_TOKEN;
config.wrappedMToken = address(0);
config.registrar = REGISTRAR;
config.uniswapV3Router = address(0);
config.admin = address(0xF2f1ACbe0BA726fEE8d75f3E32900526874740BB);
return config;
}

// Testnet configs
if (chainId_ == LOCAL_CHAIN_ID) {
config.mToken = M_TOKEN;
Expand Down
6 changes: 5 additions & 1 deletion script/ScriptBase.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@ contract ScriptBase is Script, Config {
function _writeDeployment(uint256 chainId_, string memory key_, address value_) internal {
string memory root = "";

Deployments memory deployments_ = _readDeployment(chainId_);
Deployments memory deployments_;

if (vm.isFile(_deployOutputPath(chainId_))) {
deployments_ = _readDeployment(chainId_);
}

if (
keccak256(bytes(key_)) != keccak256(bytes("swapAdapter")) &&
Expand Down
2 changes: 1 addition & 1 deletion src/swap/ReentrancyLock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

pragma solidity 0.8.26;

import { Locker } from "../../lib/uniswap-v4-periphery/src/libraries/Locker.sol";
import { Locker } from "./libs/Locker.sol";

import {
AccessControlUpgradeable
Expand Down
3 changes: 1 addition & 2 deletions src/swap/UniswapV3SwapAdapter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ import {
AccessControl
} from "../../lib/common/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/contracts/access/AccessControl.sol";

import { ReentrancyLock } from "../../lib/uniswap-v4-periphery/src/base/ReentrancyLock.sol";

import { ReentrancyLock } from "./libs/ReentrancyLock.sol";
import { IUniswapV3SwapAdapter } from "./interfaces/IUniswapV3SwapAdapter.sol";
import { ISwapFacility } from "./interfaces/ISwapFacility.sol";
import { IV3SwapRouter } from "./interfaces/uniswap/IV3SwapRouter.sol";
Expand Down
24 changes: 24 additions & 0 deletions src/swap/libs/Locker.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;

/**
* @author Uniswap Labs.
* Adapted from https://github.com/Uniswap/v4-periphery/blob/main/src/libraries/Locker.sol for Linea deployment.
* @dev Use Uniswap version of the contract when Linea supports transient storage.
*/
library Locker {
// The slot holding the locker state. bytes32(uint256(keccak256("LockedBy")) - 1)
bytes32 constant LOCKED_BY_SLOT = 0x0aedd6bde10e3aa2adec092b02a3e3e805795516cda41f27aa145b8f300af87a;

function set(address locker) internal {
assembly {
sstore(LOCKED_BY_SLOT, locker)
}
}

function get() internal view returns (address locker) {
assembly {
locker := sload(LOCKED_BY_SLOT)
}
}
}
24 changes: 24 additions & 0 deletions src/swap/libs/ReentrancyLock.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;

import { Locker } from "./Locker.sol";

/**
* @author Uniswap Labs.
* Copied from https://github.com/Uniswap/v4-periphery/blob/main/src/base/ReentrancyLock.sol.
* @dev Use Uniswap version of the contract when Linea supports transient storage.
*/
contract ReentrancyLock {
error ContractLocked();

modifier isNotLocked() {
if (Locker.get() != address(0)) revert ContractLocked();
Locker.set(msg.sender);
_;
Locker.set(address(0));
}

function _getLocker() internal view returns (address) {
return Locker.get();
}
}