Skip to content

Commit

Permalink
Merge branch 'main' into redstone_oev_dapp_control
Browse files Browse the repository at this point in the history
  • Loading branch information
jj1980a committed Sep 24, 2024
2 parents 782489e + fde788b commit e33ed47
Show file tree
Hide file tree
Showing 95 changed files with 5,695 additions and 623 deletions.
9 changes: 5 additions & 4 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ MAINNET_RPC_URL=https://eth-mainnet.g.alchemy.com/v2/XXXXXXXX
SEPOLIA_RPC_URL=https://eth-sepolia.g.alchemy.com/v2/XXXXXXXX
AMOY_RPC_URL=https://polygon-amoy.g.alchemy.com/v2/XXXXXXXX
POLYGON_RPC_URL=https://polygon-mainnet.g.alchemy.com/v2/XXXXXXXX
ETHERSCAN_API_KEY=XXXXXXXX
BSC_RPC_URL=https://bsc-rpc.publicnode.com
BASE_RPC_URL=https://base-mainnet.g.alchemy.com/v2/XXXXXXXX

# NOTE: Set chain pref here AND in the --rpc-url flag in the forge command
# Options: SEPOLIA, MAINNET, AMOY, POLYGON, LOCAL, HOSTED_ANVIL
DEPLOY_TO=POLYGON
ETHERSCAN_API_KEY=XXXXXXXX
POLYGONSCAN_API_KEY=XXXXXXXX
BSCSCAN_API_KEY=XXXXXXXX
7 changes: 7 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ jobs:

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly-0d8302880b79fa9c3c4aa52ab446583dece19a34 # 2024-08-29 release

- name: Check formatting
run: forge fmt --check
Expand All @@ -33,6 +35,8 @@ jobs:

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly-0d8302880b79fa9c3c4aa52ab446583dece19a34 # 2024-08-29 release

- name: Install dependencies
run: forge install
Expand Down Expand Up @@ -76,6 +80,8 @@ jobs:

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly-0d8302880b79fa9c3c4aa52ab446583dece19a34 # 2024-08-29 release

- name: Install dependencies
run: forge install
Expand All @@ -87,6 +93,7 @@ jobs:
run: forge test
env:
MAINNET_RPC_URL: ${{ secrets.MAINNET_RPC_URL }}
BASE_RPC_URL: ${{ secrets.BASE_RPC_URL }}

- name: Add test summary
run: |
Expand Down
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[submodule "lib/openzeppelin-contracts"]
path = lib/openzeppelin-contracts
url = https://github.com/OpenZeppelin/openzeppelin-contracts
branch = release-v4.8
branch = release-v5.0
[submodule "lib/solady"]
path = lib/solady
url = https://github.com/vectorized/solady
Expand Down
38 changes: 29 additions & 9 deletions DEPLOY.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ This is a guide to getting the Atlas smart contracts deployed on an EVM chain.
git checkout dca0b9946e8f59347610cd24a0bca5e84ddea00e
```

2. Set up your `.env` file with the variables relevant to the chain to which you are trying to deploy. Note: the `GOV_PRIVATE_KEY` is the private key to the public address from which the contracts will be deployed. You must also set the `DEPLOY_TO` variable to a valid chain option: `SEPOLIA`, `MAINNET`, `AMOY`, `POLYGON`, or `LOCAL`. In this example we would be deploying to Polygon mainnet. Check out the [Wallet List docs](https://github.com/FastLane-Labs/knowledge-base/blob/main/playbooks/wallets/wallet_list.md) if in doubt about which address to deploy from.
2. Set up your `.env` file with the variables relevant to the chain to which you are trying to deploy. Note: the `GOV_PRIVATE_KEY` is the private key to the public address from which the contracts will be deployed. Check out the [Wallet List docs](https://github.com/FastLane-Labs/knowledge-base/blob/main/playbooks/wallets/wallet_list.md) if in doubt about which address to deploy from.

```bash
MAINNET_RPC_URL=https://eth-mainnet.g.alchemy.com/v2/XXXXXXXXXXXXXXXXXXXX
Expand All @@ -21,8 +21,6 @@ ETHERSCAN_API_KEY=XXXXXXXXXXXXXXXXXXXX
POLYGONSCAN_API_KEY=XXXXXXXXXXXXXXXXXXXX

GOV_PRIVATE_KEY=0x123456789...

DEPLOY_TO=POLYGON
```

3. Run the deployment script in simulation mode to verify everything works. Note: exclude the `--broadcast` flag to run the script in simulation mode. See Foundry's [script command options](https://book.getfoundry.sh/reference/cli/forge/script).
Expand All @@ -37,14 +35,15 @@ source .env && forge script script/deploy-atlas.s.sol:DeployAtlasScript --rpc-ur
source .env && forge script script/deploy-atlas.s.sol:DeployAtlasScript --rpc-url ${POLYGON_RPC_URL} --legacy --broadcast --etherscan-api-key ${POLYGONSCAN_API_KEY} --verify
```

If all goes well, the script will output the addresses of the deployed contracts, and handle verification through Etherscan or Polygonscan automatically. These addresses will also be saved in the `deployments.json` file.
If all goes well, the script will output the addresses of the deployed contracts, and handle verification through Etherscan or Polygonscan automatically. These addresses will also be saved in the `deployments.json` file. NOTE: the chain in `deployments.json` is detected using `block.chainid`, and is thus dependent on specifying the correct `--rpc-url` when running the deployment script.

## DAppControl Deployment Process

Coming soon...

## Latest Deployments


### Polygon Amoy Testnet

Commit hash of deployment: [dca0b99](https://github.com/FastLane-Labs/atlas/commit/dca0b9946e8f59347610cd24a0bca5e84ddea00e)
Expand All @@ -56,13 +55,34 @@ Commit hash of deployment: [dca0b99](https://github.com/FastLane-Labs/atlas/comm
| Simulator | [0x3efbaBE0ee916A4677D281c417E895a3e7411Ac2](https://amoy.polygonscan.com/address/0x3efbaBE0ee916A4677D281c417E895a3e7411Ac2) |
| Sorter | [0xa55051bd82eFeA1dD487875C84fE9c016859659B](https://amoy.polygonscan.com/address/0xa55051bd82eFeA1dD487875C84fE9c016859659B) |

| DAppControl | Address |
|--------------------|-------------------------------------------------------------------------------------------------------------------------------|
| FastLane Online | [0xf0E388C7DFfE14a61280a4E5b84d77be3d2875e3](https://amoy.polygonscan.com/address/0xf0E388C7DFfE14a61280a4E5b84d77be3d2875e3) |


### Polygon Mainnet

Commit hash of deployment: [dca0b99](https://github.com/FastLane-Labs/atlas/commit/dca0b9946e8f59347610cd24a0bca5e84ddea00e)
Commit hash of deployment: [e99082f](https://github.com/FastLane-Labs/atlas/pull/401/commits/e99082faf649927408072769a68e6b815cc20b63)

| Contract | Address |
|--------------------|-------------------------------------------------------------------------------------------------------------------------------|
| Atlas | [0x912AceADa1b9c9B378894D0610C5684167710FDD](https://polygonscan.com/address/0x912AceADa1b9c9B378894D0610C5684167710FDD) |
| AtlasVerification | [0x2fBF38a38D753E4ce398000CCC552Efa50702e1e](https://polygonscan.com/address/0x2fBF38a38D753E4ce398000CCC552Efa50702e1e) |
| Simulator | [0x1244E4B8D93D2A72692Bf3600f7f5a494e24895a](https://polygonscan.com/address/0x1244E4B8D93D2A72692Bf3600f7f5a494e24895a) |
| Sorter | [0xFac7bf300E7eb17A2eD0Be67b60f5FeDd2E28E90](https://polygonscan.com/address/0xFac7bf300E7eb17A2eD0Be67b60f5FeDd2E28E90) |

| DAppControl | Address |
|--------------------|-------------------------------------------------------------------------------------------------------------------------------|
| FastLane Online | [0x498aC70345AD6b161eEf4AFBEA8F010401cfa780](https://polygonscan.com/address/0x498aC70345AD6b161eEf4AFBEA8F010401cfa780) |


### Binance Smart Chain Mainnet

Commit hash of deployment: [3416300](https://github.com/FastLane-Labs/atlas/commit/3416300be0576f558b5f06c4aad095b9e76d1f3d)

| Contract | Address |
|--------------------|-------------------------------------------------------------------------------------------------------------------------------|
| Atlas | [0x892F8f6779ca6927c1A6Cc74319e03d2abEf18D5](https://polygonscan.com/address/0x892F8f6779ca6927c1A6Cc74319e03d2abEf18D5) |
| AtlasVerification | [0xc05DDBe9745ce9DB45C32F5e4C1DA7a3c4FDa220](https://polygonscan.com/address/0xc05DDBe9745ce9DB45C32F5e4C1DA7a3c4FDa220) |
| Simulator | [0xfBc81A39459E0D82EC31B4e585f7A318AFAdB49B](https://polygonscan.com/address/0xfBc81A39459E0D82EC31B4e585f7A318AFAdB49B) |
| Sorter | [0x81f1E70A11A9E10Fa314cC093D149E5ec56EE97f](https://polygonscan.com/address/0x81f1E70A11A9E10Fa314cC093D149E5ec56EE97f) |
| Atlas | [0xD72D821dA82964c0546a5501347a3959808E072f](https://bscscan.com/address/0xD72D821dA82964c0546a5501347a3959808E072f) |
| AtlasVerification | [0xae631aCDC436b9Dfd75C5629F825330d91459445](https://bscscan.com/address/0xae631aCDC436b9Dfd75C5629F825330d91459445) |
| Simulator | [0xAb665f032e6A20Ef7D43FfD4E92a2f4fd6d5771e](https://bscscan.com/address/0xAb665f032e6A20Ef7D43FfD4E92a2f4fd6d5771e) |
| Sorter | [0xb47387995e866908B25b49e8BaC7e499170461A6](https://bscscan.com/address/0xb47387995e866908B25b49e8BaC7e499170461A6) |
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
diagrams:
plantuml -tpng docs/diagrams/*.puml
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,10 @@ The _borrow() function makes flash loans available from the Atlas Escrow balance
### Notes:

Note that the auctioneer (typically the frontend) and/or the Operations relay may want to use a reputation system for solver bids to efficiently use the space in the solverOps[]. This isnt necessarily required - it's not an economic issue - it's just that it's important to be a good member of the ecosystem and not waste too much precious blockspace by filling it with probabalistic solver txs that have a low success rate but a high profit-to-cost ratio.

### Development:

Conflicts between `foundry`'s formatter versions can lead to CI/CD failure. Developers are advised to lock in their local `foundry` version to match the one used by this repository workflows, by running the following command:
```
foundryup -v nightly-0d8302880b79fa9c3c4aa52ab446583dece19a34
```
37 changes: 24 additions & 13 deletions deployments.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,49 @@
"ATLAS": "0x4653251486a57f90Ee89F9f34E098b9218659b83",
"ATLAS_VERIFICATION": "0x72662E4da74278430123cE51405c1e7A1B87C294",
"SIMULATOR": "0x20Dc424c5fa468CbB1c702308F0cC9c14DA2825C",
"SWAP_INTENT_DAPP_CONTROL": "0x1B25157F05B25438441bF7CDe38A95A55ccf8E50",
"V2_REWARD_DAPP_CONTROL": "",
"SORTER": "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512",
"TX_BUILDER": "",
"FL_ONLINE_DAPP_CONTROL": "",
"SWAP_INTENT_DAPP_CONTROL": "0x1B25157F05B25438441bF7CDe38A95A55ccf8E50",
"V2_REWARD_DAPP_CONTROL": "",
"SIMPLE_RFQ_SOLVER": "0xEb63D671653489B91E653c52a018B63D5095223B"
},
"AMOY": {
"ATLAS": "0x282BdDFF5e58793AcAb65438b257Dbd15A8745C9",
"ATLAS_VERIFICATION": "0x3b7B38362bB7E2F000Cd2432343F3483F785F435",
"SIMULATOR": "0x3efbaBE0ee916A4677D281c417E895a3e7411Ac2",
"SORTER": "0xa55051bd82eFeA1dD487875C84fE9c016859659B"
"SORTER": "0xa55051bd82eFeA1dD487875C84fE9c016859659B",
"FL_ONLINE_DAPP_CONTROL": "0xf0E388C7DFfE14a61280a4E5b84d77be3d2875e3"
},
"POLYGON": {
"ATLAS": "0x892F8f6779ca6927c1A6Cc74319e03d2abEf18D5",
"ATLAS_VERIFICATION": "0xc05DDBe9745ce9DB45C32F5e4C1DA7a3c4FDa220",
"SIMULATOR": "0xfBc81A39459E0D82EC31B4e585f7A318AFAdB49B",
"SORTER": "0x81f1E70A11A9E10Fa314cC093D149E5ec56EE97f"
"ATLAS": "0x912AceADa1b9c9B378894D0610C5684167710FDD",
"ATLAS_VERIFICATION": "0x2fBF38a38D753E4ce398000CCC552Efa50702e1e",
"SIMULATOR": "0x1244E4B8D93D2A72692Bf3600f7f5a494e24895a",
"SORTER": "0xFac7bf300E7eb17A2eD0Be67b60f5FeDd2E28E90",
"FL_ONLINE_DAPP_CONTROL": "0x498aC70345AD6b161eEf4AFBEA8F010401cfa780"
},
"BSC": {
"ATLAS": "0xD72D821dA82964c0546a5501347a3959808E072f",
"ATLAS_VERIFICATION": "0xae631aCDC436b9Dfd75C5629F825330d91459445",
"SIMULATOR": "0xAb665f032e6A20Ef7D43FfD4E92a2f4fd6d5771e",
"SORTER": "0xb47387995e866908B25b49e8BaC7e499170461A6"
},
"SEPOLIA": {
"ATLAS": "0xb90B75C2e84cEFeB237266b1cd46E9E5eEdc2dA5",
"ATLAS_VERIFICATION": "0xa4D727dF141e2e8b0001242e54E33DBACA860fb8",
"SIMULATOR": "0x45C7432ca6dc674Dcc9e387cF523D438572A8ac2",
"SORTER": "0x4F7F8e6E53E995935De0Cd72199690A56B5AdB00",
"ATLAS": "0x9EE12d2fed4B43F4Be37F69930CcaD9B65133482",
"ATLAS_VERIFICATION": "0xB6F66a1b7cec02324D83c8DEA192818cA23A08B3",
"SIMULATOR": "0xc3ab39ebd49D80bc36208545021224BAF6d2Bdb0",
"SORTER": "0xFE3c655d4D305Ac7f1c2F6306C79397560Afea0C",
"TX_BUILDER": "0x2677053483dfDEd72bE63543D9B1E85Bcf20E839",
"FL_ONLINE_DAPP_CONTROL": "",
"SWAP_INTENT_DAPP_CONTROL": "0x0DE2256dF50bd8Bceefb353c1a5520bc0fEcdA97",
"V2_REWARD_DAPP_CONTROL": "0x954Ae509d43C414C1156bD159853D4e53aBE5774",
"V2_REWARD_DAPP_CONTROL": "0x67CD65070BDEa945BDF75D5CD9d3cEbf3F8FB965",
"SIMPLE_RFQ_SOLVER": "0x08A7776F199932F8287Fd85B05447Cc8225D1b4C"
},
"MAINNET": {
"ATLAS": "",
"ATLAS_VERIFICATION": "",
"SIMULATOR": "",
"SORTER": ""
"SORTER": "",
"FL_ONLINE_DAPP_CONTROL": ""
}
}
Binary file added docs/diagrams/atlas-control-flow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
75 changes: 75 additions & 0 deletions docs/diagrams/atlas-control-flow.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
@startuml atlas-control-flow

Participant Caller
Participant Atlas
Participant ExecutionEnv
Participant Control
Participant DApp
Participant Solver

autonumber

Caller -> Atlas: call metacall(userOp, solverOps, DAppOp)

alt if callConfig.needsPreOpsCall
Atlas -> ExecutionEnv: call preOpsCall(userOp)
ExecutionEnv -> Control: delegatecall preOpsCall(userOp)
alt if callConfig.trackPreOpsReturnData
Control --> ExecutionEnv: returnData
ExecutionEnv --> Atlas: returnData
end
end

Atlas -> ExecutionEnv: call userWrapper(userOp, returnData)

alt if callConfig.delegateUser
autonumber 6
ExecutionEnv -> DApp: delegatecall userOp.data(returnData)
else else
autonumber 6
ExecutionEnv -> DApp: call userOp.data(returnData)
end

alt if callConfig.trackUserReturnData
DApp --> ExecutionEnv: return userReturnData
ExecutionEnv --> Atlas: return userReturnData
end

alt if callConfig.exPostBids
Atlas -> Atlas: bidFindingIteration
else else
Atlas -> Atlas: bidKnownIteration
end

loop until solver successful

alt if callConfig.requirePreSolver
Atlas -> ExecutionEnv: call solverPreTryCatch(solverOp, returnData)
ExecutionEnv -> Control: delegatecall preSolverCall(solverOp, returnData)
Control --> ExecutionEnv: return ok
ExecutionEnv --> Atlas: return ok
end

Atlas -> Solver: call atlasSolverCall(solverOp)

alt if callConfig.requirePostSolver
Atlas -> ExecutionEnv: call solverPostTryCatch(solverOp, returnData)
ExecutionEnv -> Control: delegatecall postSolverCall(solverOp, returnData)
Control --> ExecutionEnv: return ok
ExecutionEnv --> Atlas: return ok
end
end

Atlas -> ExecutionEnv: call allocateValue(bidAmount, returnData)
ExecutionEnv -> Control: delegatecall allocateValueCall(bidToken, bidAmount, data)

alt if callConfig.requirePostOps
Atlas -> ExecutionEnv: call postOpsWrapper(solved, returnData)
ExecutionEnv -> Control: delegatecall postOpsCall(solved, data)
Control --> ExecutionEnv: return ok
ExecutionEnv --> Atlas: return ok
end

Atlas -> Caller: return ok

@enduml
Binary file added docs/diagrams/fastlane-online-offchain.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/diagrams/fastlane-online-onchain.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit e33ed47

Please sign in to comment.