Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arbitrum/atlas v1.1 #445

Open
wants to merge 103 commits into
base: arbitrum/atlas-v1.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
103 commits
Select commit Hold shift + click to select a range
a0dc8ff
fix: conditionally forward `returnData` to solvers
BenSparksCode Sep 4, 2024
b46981c
fix: enforce `userOp.gas` as userOp's gas limit
BenSparksCode Sep 4, 2024
5e05707
fix: use smaller of `userOp.gas` and `gasleft()` as limit
BenSparksCode Sep 4, 2024
4c9c5e3
chore: update Atlas license
BenSparksCode Sep 5, 2024
a448c98
chore: update Atlas license
BenSparksCode Sep 5, 2024
cf271a6
base L2 gas calculator contract
jj1980a Sep 7, 2024
f5e9dd1
contract ownable
jj1980a Sep 10, 2024
f8dbebc
introduce a customizable offset value to be added to passed call data…
jj1980a Sep 10, 2024
fd33c38
deploy script
jj1980a Sep 10, 2024
2448be0
forge update
jj1980a Sep 10, 2024
8fcf58f
back-end approach
thogard785 Sep 10, 2024
58fa483
Merge pull request #421 from FastLane-Labs/license-fix
BenSparksCode Sep 11, 2024
237be45
Merge branch 'main' into atlas-v1.1
BenSparksCode Sep 11, 2024
6da7e88
Merge branch 'atlas-v1.1' into solver-surcharge-tracking
BenSparksCode Sep 11, 2024
47bcfd8
fmt: forge fmt
BenSparksCode Sep 11, 2024
44eb8e0
fix: TrebleSwap tests to handle new surcharge rules
BenSparksCode Sep 11, 2024
392ba0e
fix: record accurate `solverSurcharge` figure
BenSparksCode Sep 12, 2024
0f749da
fix: 2 Escrow tests - metacall no longer reverts
BenSparksCode Sep 12, 2024
6f1f469
fix: FLOnline breaking tests for surcharge rule change
BenSparksCode Sep 12, 2024
c4de266
chore: Base L2 Gas Calculator deploy script tweaks
BenSparksCode Sep 13, 2024
20ac0af
Apply suggestions from code review
jj1980a Sep 13, 2024
04493e7
forge fmt
jj1980a Sep 13, 2024
bc6f32a
fix deploy script
jj1980a Sep 13, 2024
547588b
feat: add easier way to control hook failure for tests
BenSparksCode Sep 13, 2024
5605e76
test: add `forwardReturnData` config tests
BenSparksCode Sep 13, 2024
4aa7646
test: use hookShouldRevert pattern in `Escrow.t.sol`
BenSparksCode Sep 16, 2024
6109348
chore: rel import paths in DAppControl and parents
BenSparksCode Sep 16, 2024
39394d9
chore: switch to relative imports
BenSparksCode Sep 16, 2024
705e15e
chore: use relative imports in BaseTest
BenSparksCode Sep 16, 2024
5a25060
chore: use relative imports in TestAtlas
BenSparksCode Sep 16, 2024
ffba055
test: improve DummyDAppControl, Escrow tests
BenSparksCode Sep 18, 2024
9cc763f
chore: use relative imports in scripts
BenSparksCode Sep 18, 2024
ef45b27
chore: use relative imports in examples
BenSparksCode Sep 18, 2024
1c476d9
chore: remove TODO
BenSparksCode Sep 18, 2024
cca606d
Merge pull request #430 from FastLane-Labs/escrow-test-refactor
BenSparksCode Sep 18, 2024
0ba846d
chore: use relative imports in tests
BenSparksCode Sep 18, 2024
8be2960
added more specific fee tracking for the scenario in which multiple s…
thogard785 Sep 20, 2024
7ed34b9
Merge pull request #419 from FastLane-Labs/solver-returndata-fix
BenSparksCode Sep 20, 2024
966c0cf
simplified formula to balance per ben suggestion
thogard785 Sep 24, 2024
c560ce5
lower calldata premium value
jj1980a Sep 25, 2024
1dd15ac
refactor: set surcharge rates in constructor
BenSparksCode Oct 9, 2024
52cfec4
Merge pull request #440 from FastLane-Labs/set-surcharge-rates
BenSparksCode Oct 11, 2024
1744cef
Merge pull request #424 from FastLane-Labs/l2-gas-calc
BenSparksCode Oct 14, 2024
9aca697
Merge branch 'atlas-v1.1' into userOp-gas-limit
BenSparksCode Oct 15, 2024
6541891
chore: update libs
BenSparksCode Oct 15, 2024
8a4d49a
test: add userOp gas limit enforced test
BenSparksCode Oct 15, 2024
89d6554
fmt: forge fmt
BenSparksCode Oct 16, 2024
d0add4e
chore: update libs
BenSparksCode Oct 16, 2024
1f17b9d
Merge pull request #437 from FastLane-Labs/solver-surcharge-tracking-2
BenSparksCode Oct 16, 2024
a9b4cbf
feat: add `maxBundlerRefund()` helper
BenSparksCode Oct 16, 2024
74cf073
feat: apply max bundler refund if no winning solvers
BenSparksCode Oct 16, 2024
23eeb37
test: fix FLO tests for surcharge rule changes
BenSparksCode Oct 17, 2024
ae20f83
Merge pull request #420 from FastLane-Labs/userOp-gas-limit
BenSparksCode Oct 17, 2024
1fd0f79
Merge pull request #441 from FastLane-Labs/bundler-surcharge-cap
BenSparksCode Oct 17, 2024
f6f4188
Merge branch 'atlas-v1.1' into solver-surcharge-tracking
BenSparksCode Oct 17, 2024
771f801
chore: clearer syntax for AccountingMath calc
BenSparksCode Oct 17, 2024
54a6c98
Merge pull request #427 from FastLane-Labs/solver-surcharge-tracking
BenSparksCode Oct 17, 2024
c72d44c
Merge branch 'atlas-v1.1' into gh-package
BenSparksCode Oct 17, 2024
09a2ef3
chore: update libs
BenSparksCode Oct 17, 2024
f622236
Merge pull request #431 from FastLane-Labs/gh-package
BenSparksCode Oct 17, 2024
af39e04
Merge branch 'main' into atlas-v1.1
BenSparksCode Oct 17, 2024
a4f3571
chore: adjust gas check logs
BenSparksCode Oct 18, 2024
5962eee
feat: split logic out to FactoryLib contract
BenSparksCode Oct 18, 2024
1307e30
feat: bump to solc 0.8.28 for `transient` keyword
BenSparksCode Oct 18, 2024
c37e7a8
rm: FactoryLib file from different PR
BenSparksCode Oct 19, 2024
fdcdba5
refactor: `transient` keyword for Accounting vars
BenSparksCode Oct 19, 2024
0950125
refactor: make transient vars internal + `t_` prefixed
BenSparksCode Oct 19, 2024
a90b1ad
refactor: convert lock slot to `transient` syntax
BenSparksCode Oct 19, 2024
a8030e2
chore: remove unused constants
BenSparksCode Oct 19, 2024
a7cce59
test: fix Factory tests
BenSparksCode Oct 21, 2024
df97164
fix: delegatecalled create2 fn must be payable
BenSparksCode Oct 21, 2024
1227ba6
Merge pull request #443 from FastLane-Labs/factory-lib-deployed
BenSparksCode Oct 21, 2024
c7ece49
Merge branch 'size-cuts' into transient-keyword
BenSparksCode Oct 21, 2024
148049f
chore: bump Solidity version to `0.8.28`
BenSparksCode Oct 21, 2024
776fb93
ci: disable lint check as pre-req for test check
BenSparksCode Oct 21, 2024
da20385
Merge pull request #442 from FastLane-Labs/transient-keyword
BenSparksCode Oct 21, 2024
50e3fb2
Merge branch 'size-cuts' into arbitrum/atlas-v1.1
BenSparksCode Oct 24, 2024
96dfe56
chore: update libs
BenSparksCode Oct 24, 2024
0d7c705
fix: compiler errors
BenSparksCode Oct 24, 2024
afd9230
refactor: L2 Gas Calc deploy logic and helpers
BenSparksCode Oct 24, 2024
f1bd3d4
fix: order of Atlas deployment txs
BenSparksCode Oct 24, 2024
bb34561
refactor: detect Arbitrum Nova in constructor
BenSparksCode Oct 24, 2024
d1d614d
chore: add Arbitrum to deployments.json
BenSparksCode Oct 25, 2024
f1d2f80
fix: JSON addr reads when empty string
BenSparksCode Oct 25, 2024
561ad64
chore: deploy Atlas v1.1 on Arbitrum
BenSparksCode Oct 25, 2024
d24c7ae
Merge pull request #444 from FastLane-Labs/size-cuts
BenSparksCode Oct 28, 2024
47c3b17
fix: apply graceful return gas offset to userOp call
BenSparksCode Oct 28, 2024
17340c8
test: userOp out-of-gas graceful return case
BenSparksCode Oct 28, 2024
385ae48
Merge pull request #446 from FastLane-Labs/userOp-gas-limit-fix
BenSparksCode Nov 4, 2024
3a4972d
docs: version is Atlas v1.1 in natspec
BenSparksCode Nov 5, 2024
7fd3119
Merge branch 'atlas-v1.1' into arbitrum/atlas-v1.1
BenSparksCode Nov 5, 2024
17e81f2
feat: add `bidAmount` to `SolverTxResult` event
BenSparksCode Nov 6, 2024
8a475a1
feat: add `bidToken` to `SolverTxResult` event
BenSparksCode Nov 7, 2024
64be23c
Merge pull request #450 from FastLane-Labs/solver-event-analytics
BenSparksCode Nov 7, 2024
0ae966f
Merge branch 'atlas-v1.1' into arbitrum/atlas-v1.1
BenSparksCode Nov 7, 2024
6df621f
add indexed dapp control address in solver tx result event
jj1980a Nov 12, 2024
617e8e6
fix: rearrange event item order - solves stack too deep
BenSparksCode Nov 12, 2024
f837859
Merge pull request #451 from FastLane-Labs/solver-event
BenSparksCode Nov 12, 2024
6642910
Merge branch 'atlas-v1.1' into arbitrum/atlas-v1.1
BenSparksCode Nov 12, 2024
4807453
feat: add surcharge settings to deploy script
BenSparksCode Nov 12, 2024
60a70b3
chore: deploy Atlas v1.1 on Polygon
BenSparksCode Nov 13, 2024
e6b1718
Merge pull request #452 from FastLane-Labs/surcharge-settings-deploy
BenSparksCode Nov 13, 2024
5a7baa8
Merge branch 'atlas-v1.1' into arbitrum/atlas-v1.1
BenSparksCode Nov 13, 2024
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
3 changes: 2 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ BASE_RPC_URL=https://base-mainnet.g.alchemy.com/v2/XXXXXXXX

ETHERSCAN_API_KEY=XXXXXXXX
POLYGONSCAN_API_KEY=XXXXXXXX
BSCSCAN_API_KEY=XXXXXXXX
BSCSCAN_API_KEY=XXXXXXXX
ARBISCAN_API_KEY=XXXXXXXX
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ jobs:
echo "✅ Passed" >> $GITHUB_STEP_SUMMARY

tests:
needs: ["lint", "build"]
needs: ["build"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand Down
10 changes: 3 additions & 7 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,10 @@ Parameters

Licensor: Fastlane Labs

Licensed Work: FastLane Protocol
The Licensed Work is (c) 2023 Fastlane Labs
Licensed Work: Atlas Protocol
The Licensed Work is (c) 2024 Fastlane Labs

Additional Use Grant: Any uses listed and defined at
fastlane-protocol-license.fastlane.finance

Change Date: The earlier of 2025-07-01 or a date specified at
fastlane-protocol-license.fastlane.finance
Change Date: 2026-07-01

Change License: GNU General Public License v2.0 or later

Expand Down
15 changes: 11 additions & 4 deletions deployments.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
"FL_ONLINE_DAPP_CONTROL": "0xf0E388C7DFfE14a61280a4E5b84d77be3d2875e3"
},
"POLYGON": {
"ATLAS": "0x912AceADa1b9c9B378894D0610C5684167710FDD",
"ATLAS_VERIFICATION": "0x2fBF38a38D753E4ce398000CCC552Efa50702e1e",
"SIMULATOR": "0x1244E4B8D93D2A72692Bf3600f7f5a494e24895a",
"SORTER": "0xFac7bf300E7eb17A2eD0Be67b60f5FeDd2E28E90",
"ATLAS": "0xB363f4D32DdB0b43622eA07Ae9145726941272B4",
"ATLAS_VERIFICATION": "0x621c6970fD9F124230feE35117d318069056819a",
"SIMULATOR": "0x82A3460920582968688FD887F21c5F3155A3BBd4",
"SORTER": "0xf8Bd19064A77297A691a29d9a40dF76F32fc86ad",
"FL_ONLINE_DAPP_CONTROL": "0x498aC70345AD6b161eEf4AFBEA8F010401cfa780"
},
"BSC": {
Expand Down Expand Up @@ -54,6 +54,13 @@
"SORTER": "0x81b2a2eD250fFF6808C54B46d519C9491E822F09",
"L2_GAS_CALCULATOR": "0x7AcE2aC844F4104f86a2A04010C1b1e3f5d43196"
},
"ARBITRUM": {
"ATLAS": "0xf0E388C7DFfE14a61280a4E5b84d77be3d2875e3",
"ATLAS_VERIFICATION": "0xD72D821dA82964c0546a5501347a3959808E072f",
"SIMULATOR": "0xae631aCDC436b9Dfd75C5629F825330d91459445",
"SORTER": "0xb47387995e866908B25b49e8BaC7e499170461A6",
"L2_GAS_CALCULATOR": "0xAb665f032e6A20Ef7D43FfD4E92a2f4fd6d5771e"
},
"MAINNET": {
"ATLAS": "",
"ATLAS_VERIFICATION": "",
Expand Down
2 changes: 1 addition & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
block_gas_limit = 300000000
gas_limit = 3000000000
gas_price = 1500000000
solc_version = "0.8.25"
solc_version = "0.8.28"
evm_version = "cancun"
isolate = false
gas_reports = ["Atlas", "AtlasVerification", "Simulator", "Sorter", "ExecutionEnvironment"]
Expand Down
2 changes: 1 addition & 1 deletion lib/forge-std
Submodule forge-std updated 2 files
+104 −0 src/StdJson.sol
+104 −0 src/StdToml.sol
2 changes: 1 addition & 1 deletion lib/nitro-contracts
Submodule nitro-contracts updated 0 files
2 changes: 1 addition & 1 deletion lib/solady
Submodule solady updated 42 files
+11 −10 .github/workflows/ci-all-via-ir.yml
+49 −22 .github/workflows/ci.yml
+4 −1 README.md
+1 −1 foundry.toml
+1 −1 package.json
+58 −0 prep/gen-globalized-libs.js
+2 −0 src/Milady.sol
+2 −2 src/accounts/Pod.sol
+292 −0 src/auth/EnumerableRoles.sol
+164 −40 src/tokens/ERC20.sol
+458 −0 src/tokens/ERC20Votes.sol
+497 −150 src/utils/DynamicArrayLib.sol
+6 −2 src/utils/EnumerableSetLib.sol
+156 −40 src/utils/LibClone.sol
+112 −1 src/utils/LibSort.sol
+350 −355 src/utils/LibString.sol
+3 −3 src/utils/SSTORE2.sol
+58 −70 src/utils/SafeTransferLib.sol
+990 −0 src/utils/g/DynamicArrayLib.sol
+1,317 −0 src/utils/g/DynamicBufferLib.sol
+739 −0 src/utils/g/EnumerableSetLib.sol
+819 −0 src/utils/g/JSONParserLib.sol
+240 −0 src/utils/g/LibBitmap.sol
+318 −0 src/utils/g/LibMap.sol
+505 −0 src/utils/g/LibPRNG.sol
+387 −0 src/utils/g/LibRLP.sol
+572 −0 src/utils/g/MinHeapLib.sol
+721 −0 src/utils/g/RedBlackTreeLib.sol
+254 −2 test/DynamicArrayLib.t.sol
+80 −0 test/ERC20.t.sol
+584 −0 test/ERC20Votes.t.sol
+304 −0 test/EnumerableRoles.t.sol
+50 −0 test/EnumerableSetLib.t.sol
+88 −5 test/LibClone.t.sol
+3 −0 test/LibSort.t.sol
+178 −0 test/LibString.t.sol
+87 −21 test/SafeTransferLib.t.sol
+15 −0 test/utils/TestPlus.sol
+16 −0 test/utils/mocks/MockERC20ForPermit2.sol
+41 −0 test/utils/mocks/MockERC20Votes.sol
+67 −0 test/utils/mocks/MockEnumerableRoles.sol
+4 −0 test/utils/mocks/MockPod.sol
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"deploy-atlas-polygon": "source .env && forge script script/deploy-atlas.s.sol:DeployAtlasScript --rpc-url ${POLYGON_RPC_URL} --legacy --broadcast --etherscan-api-key ${POLYGONSCAN_API_KEY} --verify --delay 30",

"deploy-atlas-arbitrum-sepolia": "source .env && forge script script/deploy-atlas.s.sol:DeployAtlasScript --rpc-url ${ARBITRUM_SEPOLIA_RPC_URL} --broadcast --etherscan-api-key ${ARBISCAN_API_KEY} --verify --delay 30",
"deploy-atlas-arbitrum": "source .env && forge script script/deploy-atlas.s.sol:DeployAtlasScript --rpc-url ${ARBITRUM_RPC_URL} --broadcast --etherscan-api-key ${ARBISCAN_API_KEY} --verify --delay 30",

"deploy-fl-online-amoy": "source .env && forge script script/deploy-fl-online-control.s.sol:DeployFLOnlineControlScript --rpc-url ${AMOY_RPC_URL} --broadcast --etherscan-api-key ${POLYGONSCAN_API_KEY} --verify",
"deploy-fl-online-polygon": "source .env && forge script script/deploy-fl-online-control.s.sol:DeployFLOnlineControlScript --rpc-url ${POLYGON_RPC_URL} --broadcast --etherscan-api-key ${POLYGONSCAN_API_KEY} --verify",
Expand Down Expand Up @@ -62,6 +63,8 @@
"solver-deposit": "source .env && forge script script/solver-deposit.s.sol:SolverAtlasDepositScript --fork-url http://localhost:8545 --broadcast --non-interactive",
"setup-demo": "npm run deploy-atlas-swap-intent-tx-builder && npm run deploy-solver && npm run solver-deposit",

"deploy-gas-calculator-base": "source .env && forge script script/deploy-gas-calculator.s.sol:DeployGasCalculatorScript --rpc-url ${BASE_RPC_URL} --broadcast --etherscan-api-key ${ETHERSCAN_API_KEY} --verify",

"atlas-addr": "echo 'ATLAS:' && jq -r '.ATLAS' deployments.json",
"swap-intent-addr": "echo 'SWAP INTENT DAPP CONTROL:' && jq -r '.SWAP_INTENT_DAPP_CONTROL' deployments.json",
"tx-builder-addr": "echo 'TX BUILDER:' && jq -r '.TX_BUILDER' deployments.json",
Expand Down
40 changes: 30 additions & 10 deletions script/base/deploy-base.s.sol
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.25;
pragma solidity 0.8.28;

import "forge-std/Script.sol";
import "forge-std/Test.sol";
import "forge-std/StdJson.sol";

import { IERC20 } from "openzeppelin-contracts/contracts/token/ERC20/IERC20.sol";

import { Atlas } from "src/contracts/atlas/Atlas.sol";
import { AtlasVerification } from "src/contracts/atlas/AtlasVerification.sol";
import { SwapIntentDAppControl } from "src/contracts/examples/intents-example/SwapIntentDAppControl.sol";
import { TxBuilder } from "src/contracts/helpers/TxBuilder.sol";
import { Simulator } from "src/contracts/helpers/Simulator.sol";
import { Sorter } from "src/contracts/helpers/Sorter.sol";
import { SimpleRFQSolver } from "test/SwapIntent.t.sol";
import { Atlas } from "../../src/contracts/atlas/Atlas.sol";
import { AtlasVerification } from "../../src/contracts/atlas/AtlasVerification.sol";
import { SwapIntentDAppControl } from "../../src/contracts/examples/intents-example/SwapIntentDAppControl.sol";
import { TxBuilder } from "../../src/contracts/helpers/TxBuilder.sol";
import { Simulator } from "../../src/contracts/helpers/Simulator.sol";
import { Sorter } from "../../src/contracts/helpers/Sorter.sol";
import { SimpleRFQSolver } from "../../test/SwapIntent.t.sol";

import { Utilities } from "src/contracts/helpers/Utilities.sol";
import { Utilities } from "../../src/contracts/helpers/Utilities.sol";

contract DeployBaseScript is Script {
using stdJson for string;
Expand Down Expand Up @@ -72,6 +72,19 @@ contract DeployBaseScript is Script {
}
}

function _getSurchargeRates() internal view returns (uint256 atlasSurchargeRate, uint256 bundlerSurchargeRate) {
uint256 chainId = block.chainid;
if (chainId == 137 || chainId == 80_002) {
// POLYGON and AMOY
atlasSurchargeRate = 5_000_000; // 50%
bundlerSurchargeRate = 5_000_000; // 50%
} else {
// Default - for all other chains
atlasSurchargeRate = 1_000_000; // 10%
bundlerSurchargeRate = 1_000_000; // 10%
}
}

// NOTE: When handling JSON with StdJson, prefix keys with '.' e.g. '.ATLAS'
// These 2 functions abstract away the '.' thing though.
// Pass in a key like 'ATLAS', and the current chain will be detected via `block.chainid` in `_getDeployChain()`
Expand All @@ -85,7 +98,14 @@ contract DeployBaseScript is Script {

// console.log("Getting", fullKey, "from deployments.json");

// NOTE: Use fullKey method above for safety
// Revert if key doesn't exist in JSON.
if (!json.keyExists(fullKey)) revert(string.concat(fullKey, " not found in deployments.json"));

// If key exists but is empty, return address(0)
address decodedAddr = abi.decode(json.parseRaw(fullKey), (address));
if (decodedAddr == address(0x20) || decodedAddr == address(0)) return address(0);

// Otherwise, return the address
return json.readAddress(fullKey);
}

Expand Down
10 changes: 5 additions & 5 deletions script/create-oev-demo-positions.s.sol
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.25;
pragma solidity 0.8.28;

import "forge-std/Script.sol";
import "forge-std/Test.sol";

import { DeployBaseScript } from "script/base/deploy-base.s.sol";

import { ChainlinkDAppControl } from "src/contracts/examples/oev-example/ChainlinkDAppControl.sol";
import { ChainlinkAtlasWrapper } from "src/contracts/examples/oev-example/ChainlinkAtlasWrapper.sol";
import { ChainlinkDAppControl } from "../src/contracts/examples/oev-example/ChainlinkDAppControl.sol";
import { ChainlinkAtlasWrapper } from "../src/contracts/examples/oev-example/ChainlinkAtlasWrapper.sol";

import { Token } from "src/contracts/helpers/DemoToken.sol";
import { DemoLendingProtocol } from "src/contracts/helpers/DemoLendingProtocol.sol";
import { Token } from "../src/contracts/helpers/DemoToken.sol";
import { DemoLendingProtocol } from "../src/contracts/helpers/DemoLendingProtocol.sol";

// Sets up a few liquidatable positions in the Lending Protocol. ETH for gas fees distributed by Lending Gov.
contract CreateOEVDemoPositionsScript is DeployBaseScript {
Expand Down
96 changes: 60 additions & 36 deletions script/deploy-atlas.s.sol
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.25;
pragma solidity 0.8.28;

import "forge-std/Script.sol";
import "forge-std/Test.sol";

import { DeployBaseScript } from "script/base/deploy-base.s.sol";
import { DeployGasCalculatorScript } from "script/deploy-gas-calculator.s.sol";
import { DeployBaseScript } from "./base/deploy-base.s.sol";
import { GasCalculatorDeployHelper } from "./deploy-gas-calculator.s.sol";

import { Atlas } from "src/contracts/atlas/Atlas.sol";
import { AtlasVerification } from "src/contracts/atlas/AtlasVerification.sol";
import { TxBuilder } from "src/contracts/helpers/TxBuilder.sol";
import { Simulator } from "src/contracts/helpers/Simulator.sol";
import { Sorter } from "src/contracts/helpers/Sorter.sol";
import { ExecutionEnvironment } from "src/contracts/common/ExecutionEnvironment.sol";
import { FactoryLib } from "../src/contracts/atlas/FactoryLib.sol";
import { Atlas } from "../src/contracts/atlas/Atlas.sol";
import { AtlasVerification } from "../src/contracts/atlas/AtlasVerification.sol";
import { TxBuilder } from "../src/contracts/helpers/TxBuilder.sol";
import { Simulator } from "../src/contracts/helpers/Simulator.sol";
import { Sorter } from "../src/contracts/helpers/Sorter.sol";
import { ExecutionEnvironment } from "../src/contracts/common/ExecutionEnvironment.sol";

contract DeployAtlasScript is DeployBaseScript, GasCalculatorDeployHelper {
uint256 ESCROW_DURATION = 64;
uint256 ATLAS_SURCHARGE_RATE; // Set below
uint256 BUNDLER_SURCHARGE_RATE; // Set below

contract DeployAtlasScript is DeployBaseScript {
function run() external {
console.log("\n=== DEPLOYING Atlas ===\n");

Expand All @@ -23,19 +28,16 @@ contract DeployAtlasScript is DeployBaseScript {
uint256 deployerPrivateKey = vm.envUint("GOV_PRIVATE_KEY");
address deployer = vm.addr(deployerPrivateKey);

// Computes the addresses at which contracts will be deployed
address expectedAtlasAddr = vm.computeCreateAddress(deployer, vm.getNonce(deployer) + 1);
address expectedAtlasVerificationAddr = vm.computeCreateAddress(deployer, vm.getNonce(deployer) + 2);
address expectedSimulatorAddr = vm.computeCreateAddress(deployer, vm.getNonce(deployer) + 3);
(ATLAS_SURCHARGE_RATE, BUNDLER_SURCHARGE_RATE) = _getSurchargeRates();

// Deploy gas calculator for Arbitrum chains after other deployments
address l2GasCalculatorAddr = address(0);
uint256 chainId = block.chainid;
// Computes the addresses at which AtlasVerification will be deployed
address expectedAtlasAddr = vm.computeCreateAddress(deployer, vm.getNonce(deployer) + 2);
address expectedAtlasVerificationAddr = vm.computeCreateAddress(deployer, vm.getNonce(deployer) + 3);
address expectedSimulatorAddr = vm.computeCreateAddress(deployer, vm.getNonce(deployer) + 4);

if (chainId == 42_161 || chainId == 42_170 || chainId == 421_614) {
// Deploy gas calculator for Arbitrum chains
l2GasCalculatorAddr = vm.computeCreateAddress(deployer, vm.getNonce(deployer) + 4);
}
// Deploy L2 Gas Calculator after other deployments
address expectedL2GasCalculatorAddr = _predictGasCalculatorAddress(deployer, vm.getNonce(deployer) + 5);
address actualL2GasCalculatorAddr; // Set below during deployment if chain is an L2

address prevSimAddr = _getAddressFromDeploymentsJson("SIMULATOR");
uint256 prevSimBalance = (prevSimAddr == address(0)) ? 0 : prevSimAddr.balance;
Expand All @@ -47,33 +49,36 @@ contract DeployAtlasScript is DeployBaseScript {
vm.startBroadcast(deployerPrivateKey);

ExecutionEnvironment execEnvTemplate = new ExecutionEnvironment(expectedAtlasAddr);
FactoryLib factoryLib = new FactoryLib(address(execEnvTemplate));
atlas = new Atlas({
escrowDuration: 64,
escrowDuration: ESCROW_DURATION,
atlasSurchargeRate: ATLAS_SURCHARGE_RATE,
bundlerSurchargeRate: BUNDLER_SURCHARGE_RATE,
verification: expectedAtlasVerificationAddr,
simulator: expectedSimulatorAddr,
executionTemplate: address(execEnvTemplate),
factoryLib: address(factoryLib),
initialSurchargeRecipient: deployer,
l2GasCalculator: l2GasCalculatorAddr // is 0 if not on Arbitrum
l2GasCalculator: expectedL2GasCalculatorAddr // address(0) if chain not an L2
});
atlasVerification = new AtlasVerification(address(atlas));

simulator = new Simulator();

// If chain is an L2, expectedL2GasCalculatorAddr will be non-zero
if (expectedL2GasCalculatorAddr != address(0)) {
actualL2GasCalculatorAddr = _newGasCalculator();
}

// After predicted address deployments done, do other setup txs:
simulator.setAtlas(address(atlas));

// If prev Simulator deployment has native assets, withdraw them to new Simulator
if (prevSimBalance > 0) {
Simulator(payable(prevSimAddr)).withdrawETH(address(simulator));
}

// Sorter address not predicted or required in the other contracts, so deployed last.
sorter = new Sorter(address(atlas));

if (chainId == 42_161 || chainId == 42_170 || chainId == 421_614) {
// Deploy gas calculator for Arbitrum chains
console.log("Deploying L2 Gas Calculator at: ", l2GasCalculatorAddr);
DeployGasCalculatorScript gasCalculatorDeployer = new DeployGasCalculatorScript();
l2GasCalculatorAddr = gasCalculatorDeployer.deployL2GasCalculator();
}

vm.stopBroadcast();

bool error = false;
Expand Down Expand Up @@ -122,6 +127,25 @@ contract DeployAtlasScript is DeployBaseScript {
console.log("ERROR: Sorter deployment address is 0x0");
error = true;
}
// Check FactoryLib address set correctly in Atlas
if (address(factoryLib) != atlas.FACTORY_LIB()) {
console.log("ERROR: FactoryLib address not set correctly in Atlas");
error = true;
}
// Check ExecutionEnvironment address set correctly in FactoryLib
if (address(execEnvTemplate) != factoryLib.EXECUTION_ENV_TEMPLATE()) {
console.log("ERROR: ExecutionEnvironment address not set correctly in FactoryLib");
error = true;
}
// Check L2 Gas Calculator address set correctly
if (actualL2GasCalculatorAddr != atlas.L2_GAS_CALCULATOR()) {
console.log("ERROR: L2 Gas Calculator address not set correctly in Atlas");
error = true;
}
if (actualL2GasCalculatorAddr != expectedL2GasCalculatorAddr) {
console.log("ERROR: L2 Gas Calculator deployment address not as expected");
error = true;
}
// Check ESCROW_DURATION was not set to 0
if (atlas.ESCROW_DURATION() == 0) {
console.log("ERROR: ESCROW_DURATION was set to 0");
Expand All @@ -137,8 +161,8 @@ contract DeployAtlasScript is DeployBaseScript {
_writeAddressToDeploymentsJson("ATLAS_VERIFICATION", address(atlasVerification));
_writeAddressToDeploymentsJson("SIMULATOR", address(simulator));
_writeAddressToDeploymentsJson("SORTER", address(sorter));
if (l2GasCalculatorAddr != address(0)) {
_writeAddressToDeploymentsJson("L2_GAS_CALCULATOR", l2GasCalculatorAddr);
if (actualL2GasCalculatorAddr != address(0)) {
_writeAddressToDeploymentsJson("L2_GAS_CALCULATOR", actualL2GasCalculatorAddr);
}

// Print the table header
Expand All @@ -150,8 +174,8 @@ contract DeployAtlasScript is DeployBaseScript {
console.log("| AtlasVerification | ", address(atlasVerification), " |");
console.log("| Simulator | ", address(simulator), " |");
console.log("| Sorter | ", address(sorter), " |");
if (l2GasCalculatorAddr != address(0)) {
console.log("| L2 Gas Calculator | ", l2GasCalculatorAddr, " |");
if (actualL2GasCalculatorAddr != address(0)) {
console.log("| L2 Gas Calculator | ", actualL2GasCalculatorAddr, " |");
}
console.log("------------------------------------------------------------------------");
console.log("\n");
Expand Down
12 changes: 6 additions & 6 deletions script/deploy-demo-tokens.s.sol
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.25;
pragma solidity 0.8.28;

import "forge-std/Script.sol";
import "forge-std/Test.sol";

import { DeployBaseScript } from "script/base/deploy-base.s.sol";

import { Atlas } from "src/contracts/atlas/Atlas.sol";
import { AtlasVerification } from "src/contracts/atlas/AtlasVerification.sol";
import { V2RewardDAppControl } from "src/contracts/examples/v2-example-router/V2RewardDAppControl.sol";
import { IUniswapV2Router02 } from "src/contracts/examples/v2-example-router/interfaces/IUniswapV2Router.sol";
import { Atlas } from "../src/contracts/atlas/Atlas.sol";
import { AtlasVerification } from "../src/contracts/atlas/AtlasVerification.sol";
import { V2RewardDAppControl } from "../src/contracts/examples/v2-example-router/V2RewardDAppControl.sol";
import { IUniswapV2Router02 } from "../src/contracts/examples/v2-example-router/interfaces/IUniswapV2Router.sol";

import { Token } from "src/contracts/helpers/DemoToken.sol";
import { Token } from "../src/contracts/helpers/DemoToken.sol";
import { WETH } from "solady/tokens/WETH.sol";

// Deploy 3 stablecoin tokens (DAI, USDA, USDB) - all 18 decimals
Expand Down
6 changes: 3 additions & 3 deletions script/deploy-exec-env.s.sol
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.25;
pragma solidity 0.8.28;

import "forge-std/Script.sol";
import "forge-std/Test.sol";

import { DeployBaseScript } from "script/base/deploy-base.s.sol";
import { DeployBaseScript } from "./base/deploy-base.s.sol";

import { ExecutionEnvironment } from "src/contracts/common/ExecutionEnvironment.sol";
import { ExecutionEnvironment } from "../src/contracts/common/ExecutionEnvironment.sol";

contract DeployExecEnvScript is DeployBaseScript {
ExecutionEnvironment public execEnv;
Expand Down
Loading
Loading