├── .gitignore ├── src ├── aws_utils │ ├── mod.rs │ └── cloudwatch_utils.rs ├── collectors │ ├── mod.rs │ └── block_collector.rs ├── lib.rs ├── strategies │ ├── mod.rs │ ├── types.rs │ ├── shared.rs │ └── keystore.rs ├── executors │ ├── mod.rs │ ├── queued_executor.rs │ ├── bundle_client.rs │ ├── reactor_error_code.rs │ └── transaction_utils.rs └── shared.rs ├── crates ├── uniswapx-rs │ ├── src │ │ ├── lib.rs │ │ └── sol_math.rs │ ├── README.md │ └── Cargo.toml └── bindings-uniswapx │ ├── Cargo.toml │ └── src │ ├── lib.rs │ ├── reentrancyguard.rs │ ├── path.rs │ ├── math.rs │ ├── ecdsa.rs │ ├── mathext.rs │ ├── safecast.rs │ ├── strings.rs │ ├── byteslib.rs │ ├── solarray.rs │ ├── signedmath.rs │ ├── arraybuilder.rs │ ├── permit2lib.rs │ └── storageslot.rs ├── .github └── workflows │ ├── test.yml │ ├── claude-code-review.yml │ └── claude-pr-metadata-update.yml ├── .gitmodules ├── .dockerignore ├── README.Docker.md ├── LICENSE ├── Cargo.toml ├── compose.yaml ├── Dockerfile ├── README.md └── .claude └── prompts └── claude-pr-review.md /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | 3 | logs* 4 | -------------------------------------------------------------------------------- /src/aws_utils/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod cloudwatch_utils; 2 | -------------------------------------------------------------------------------- /crates/uniswapx-rs/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod order; 2 | pub mod sol_math; 3 | -------------------------------------------------------------------------------- /crates/uniswapx-rs/README.md: -------------------------------------------------------------------------------- 1 | # uniswapx-rs 2 | 3 | Library to encode, decode, and resolve UniswapX dutch orders. 4 | -------------------------------------------------------------------------------- /src/collectors/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod block_collector; 2 | pub mod uniswapx_order_collector; 3 | pub mod uniswapx_route_collector; 4 | -------------------------------------------------------------------------------- /src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod aws_utils; 2 | pub mod collectors; 3 | pub mod executors; 4 | pub mod shared; 5 | pub mod strategies; 6 | -------------------------------------------------------------------------------- /src/strategies/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod dutchv3_strategy; 2 | pub mod keystore; 3 | pub mod priority_strategy; 4 | pub mod shared; 5 | pub mod types; 6 | pub mod uniswapx_strategy; 7 | -------------------------------------------------------------------------------- /src/executors/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod dutch_executor; 2 | pub mod priority_executor; 3 | pub mod queued_executor; 4 | pub mod reactor_error_code; 5 | pub mod bundle_client; 6 | pub mod transaction_utils; 7 | -------------------------------------------------------------------------------- /crates/bindings-uniswapx/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "bindings-uniswapx" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | alloy = { version = "0.11.1", features = ["sol-types", "contract"] } -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: test suite 2 | on: 3 | push: 4 | branches: 5 | - main 6 | pull_request: 7 | 8 | jobs: 9 | test: 10 | name: cargo test 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: actions/checkout@v4 14 | - uses: dtolnay/rust-toolchain@stable 15 | - run: cargo test --all-features 16 | -------------------------------------------------------------------------------- /crates/uniswapx-rs/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "uniswapx-rs" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | alloy-primitives = "0.8.20" 10 | alloy-sol-types = "0.8.20" 11 | alloy-dyn-abi = "0.8.20" 12 | anyhow = "1.0.70" 13 | hex = "0.4.3" 14 | serde = "1.0.168" -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "contracts/lib/forge-std"] 2 | path = contracts/lib/forge-std 3 | url = https://github.com/foundry-rs/forge-std 4 | [submodule "contracts/lib/uniswapx"] 5 | path = contracts/lib/uniswapx 6 | url = https://github.com/uniswap/uniswapx 7 | [submodule "contracts/lib/solmate"] 8 | path = contracts/lib/solmate 9 | url = https://github.com/transmissions11/solmate 10 | [submodule "contracts/lib/permit2"] 11 | path = contracts/lib/permit2 12 | url = https://github.com/uniswap/permit2 13 | [submodule "contracts/lib/openzeppelin-contracts"] 14 | path = contracts/lib/openzeppelin-contracts 15 | url = https://github.com/openzeppelin/openzeppelin-contracts 16 | -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | # Include any files or directories that you don't want to be copied to your 2 | # container here (e.g., local build artifacts, temporary files, etc.). 3 | # 4 | # For more help, visit the .dockerignore file reference guide at 5 | # https://docs.docker.com/go/build-context-dockerignore/ 6 | 7 | **/.DS_Store 8 | **/.classpath 9 | **/.dockerignore 10 | **/.env 11 | **/.git 12 | **/.gitignore 13 | **/.project 14 | **/.settings 15 | **/.toolstarget 16 | **/.vs 17 | **/.vscode 18 | **/*.*proj.user 19 | **/*.dbmdl 20 | **/*.jfm 21 | **/charts 22 | **/docker-compose* 23 | **/compose.y*ml 24 | **/Dockerfile* 25 | **/node_modules 26 | **/npm-debug.log 27 | **/secrets.dev.yaml 28 | **/values.dev.yaml 29 | /bin 30 | /target 31 | LICENSE 32 | README.md 33 | -------------------------------------------------------------------------------- /README.Docker.md: -------------------------------------------------------------------------------- 1 | ### Building and running your application 2 | 3 | When you're ready, start your application by running: 4 | `docker compose up --build`. 5 | 6 | Your application will be available at http://localhost:1559. 7 | 8 | ### Deploying your application to the cloud 9 | 10 | First, build your image, e.g.: `docker build -t myapp .`. 11 | If your cloud uses a different CPU architecture than your development 12 | machine (e.g., you are on a Mac M1 and your cloud provider is amd64), 13 | you'll want to build the image for that platform, e.g.: 14 | `docker build --platform=linux/amd64 -t myapp .`. 15 | 16 | Then, push it to your registry, e.g. `docker push myregistry.com/myapp`. 17 | 18 | Consult Docker's [getting started](https://docs.docker.com/go/get-started-sharing/) 19 | docs for more detail on building and pushing. 20 | 21 | ### References 22 | * [Docker's Rust guide](https://docs.docker.com/language/rust/) -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2023 Mark Toda 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "uniswapx-artemis" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | uniswapx-rs = { path = "./crates/uniswapx-rs" } 10 | bindings-uniswapx = { path = "./crates/bindings-uniswapx" } 11 | 12 | artemis-core = { git = "https://github.com/ConjunctiveNormalForm/minimal-artemis-alloy", version = "0.2.0"} 13 | tokio = { version = "1.18", features = ["full"] } 14 | dotenv = "0.15.0" 15 | async-trait = "0.1.64" 16 | futures = "0.3.27" 17 | anyhow = "1.0.70" 18 | tracing = "0.1.37" 19 | tracing-subscriber = "0.3.16" 20 | clap = { version = "4.2.5", features = ["derive"] } 21 | phyllo = "0.3.0" 22 | serde = "1.0.168" 23 | crossbeam = "0.8.2" 24 | crossbeam-channel = "0.5.8" 25 | tokio-stream = "0.1.14" 26 | reqwest = { version = "0.11.18", features = ["json"] } 27 | alloy = "0.11.1" 28 | alloy-primitives = "0.8.21" 29 | serde_qs = "0.12.0" 30 | async-stream = "0.3.5" 31 | mockito = "1.1.0" 32 | 33 | # aws 34 | aws-config = { version = "1.1.7", features = ["behavior-version-latest"] } 35 | aws-sdk-cloudwatch = "1.47.0" 36 | aws-sdk-secretsmanager = "1.43.0" 37 | serde_json = "1.0.127" 38 | dashmap = "6.1.0" 39 | rand = "0.8.5" 40 | ethabi = "18.0.0" 41 | backoff = "0.4.0" 42 | -------------------------------------------------------------------------------- /.github/workflows/claude-code-review.yml: -------------------------------------------------------------------------------- 1 | name: "[claude] Claude Code Review" 2 | 3 | concurrency: 4 | group: ${{ github.workflow }}-pr-${{ github.event.pull_request.number }} 5 | cancel-in-progress: true 6 | 7 | on: 8 | pull_request: 9 | types: [opened, synchronize, ready_for_review, labeled, unlabeled] 10 | 11 | jobs: 12 | claude-review-auto: 13 | if: | 14 | github.event_name == 'pull_request' && 15 | github.event.action != 'review_requested' && 16 | !contains(github.head_ref, 'gh-readonly-queue/') && 17 | !startsWith(github.head_ref, 'release/') && 18 | ( 19 | github.event.pull_request.draft == false || 20 | github.event.action == 'ready_for_review' 21 | ) 22 | 23 | uses: Uniswap/ai-toolkit/.github/workflows/_claude-code-review.yml@9aa3cf98744a2b4e1aac51cd2d26144ea337ab3b 24 | with: 25 | pr_number: ${{ github.event.pull_request.number }} 26 | base_ref: ${{ github.base_ref }} 27 | force_review: false 28 | toolkit_ref: 9aa3cf98744a2b4e1aac51cd2d26144ea337ab3b 29 | custom_prompt_path: ".claude/prompts/claude-pr-review.md" 30 | 31 | model: "claude-opus-4-5" 32 | 33 | # Standard timeout for most PRs 34 | timeout_minutes: 20 35 | 36 | secrets: 37 | ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} 38 | -------------------------------------------------------------------------------- /src/strategies/types.rs: -------------------------------------------------------------------------------- 1 | use crate::collectors::{ 2 | block_collector::NewBlock, uniswapx_order_collector::UniswapXOrder, 3 | uniswapx_route_collector::RoutedOrder, 4 | }; 5 | use artemis_core::executors::mempool_executor::SubmitTxToMempool; 6 | use uniswapx_rs::order::ResolvedOrder; 7 | 8 | use super::priority_strategy::ExecutionMetadata; 9 | 10 | /// Core Event enum for the current strategy. 11 | #[derive(Debug, Clone)] 12 | pub enum Event { 13 | NewBlock(NewBlock), 14 | UniswapXOrder(Box), 15 | UniswapXRoute(Box), 16 | } 17 | 18 | #[derive(Debug, Clone)] 19 | pub struct SubmitTxToMempoolWithExecutionMetadata { 20 | pub execution: SubmitTxToMempool, 21 | pub metadata: ExecutionMetadata, 22 | } 23 | 24 | /// Core Action enum for the current strategy. 25 | #[derive(Debug, Clone)] 26 | pub enum Action { 27 | SubmitTx(SubmitTxToMempool), 28 | SubmitPublicTx(SubmitTxToMempoolWithExecutionMetadata), 29 | } 30 | 31 | /// Configuration for variables we need to pass to the strategy. 32 | #[derive(Debug, Clone)] 33 | pub struct Config { 34 | pub bid_percentage: Option, 35 | pub executor_address: String, 36 | pub min_block_percentage_buffer: Option, 37 | pub fallback_bid_scale_factor: Option, 38 | } 39 | 40 | #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)] 41 | pub struct TokenInTokenOut { 42 | pub token_in: String, 43 | pub token_out: String, 44 | } 45 | 46 | #[derive(Debug, Clone)] 47 | pub enum OrderStatus { 48 | Open(ResolvedOrder), 49 | NotFillableYet(ResolvedOrder), 50 | Done, 51 | } 52 | -------------------------------------------------------------------------------- /src/executors/queued_executor.rs: -------------------------------------------------------------------------------- 1 | use crate::executors::priority_executor::PriorityExecutor; 2 | use crate::strategies::keystore::KeyStore; 3 | use crate::strategies::types::SubmitTxToMempoolWithExecutionMetadata; 4 | use alloy::{network::AnyNetwork, providers::DynProvider}; 5 | use artemis_core::types::Executor; 6 | use async_trait::async_trait; 7 | use aws_sdk_cloudwatch::Client as CloudWatchClient; 8 | use std::sync::Arc; 9 | 10 | pub struct QueuedExecutor { 11 | provider: Arc>, 12 | sender_client: Arc>, 13 | key_store: Arc, 14 | cloudwatch_client: Option>, 15 | } 16 | 17 | impl QueuedExecutor { 18 | pub fn new( 19 | provider: Arc>, 20 | sender_client: Arc>, 21 | key_store: Arc, 22 | cloudwatch_client: Option>, 23 | ) -> Self { 24 | Self { 25 | provider, 26 | sender_client, 27 | key_store, 28 | cloudwatch_client, 29 | } 30 | } 31 | } 32 | 33 | #[async_trait] 34 | impl Executor for QueuedExecutor { 35 | async fn execute( 36 | &self, 37 | action: SubmitTxToMempoolWithExecutionMetadata, 38 | ) -> Result<(), anyhow::Error> { 39 | let public_executor = PriorityExecutor::new( 40 | self.provider.clone(), 41 | self.sender_client.clone(), 42 | self.key_store.clone(), 43 | self.cloudwatch_client.clone(), 44 | ); 45 | 46 | tokio::spawn(async move { public_executor.execute(action).await }); 47 | 48 | Ok(()) 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /compose.yaml: -------------------------------------------------------------------------------- 1 | # Comments are provided throughout this file to help you get started. 2 | # If you need more help, visit the Docker Compose reference guide at 3 | # https://docs.docker.com/go/compose-spec-reference/ 4 | 5 | # Here the instructions define your application as a service called "server". 6 | # This service is built from the Dockerfile in the current directory. 7 | # You can add other services your application may depend on here, such as a 8 | # database or a cache. For examples, see the Awesome Compose repository: 9 | # https://github.com/docker/awesome-compose 10 | services: 11 | server: 12 | build: 13 | context: . 14 | target: final 15 | ports: 16 | - 1559:1559 17 | restart: always 18 | 19 | # The commented out section below is an example of how to define a PostgreSQL 20 | # database that your application can use. `depends_on` tells Docker Compose to 21 | # start the database before your application. The `db-data` volume persists the 22 | # database data between container restarts. The `db-password` secret is used 23 | # to set the database password. You must create `db/password.txt` and add 24 | # a password of your choosing to it before running `docker compose up`. 25 | # depends_on: 26 | # db: 27 | # condition: service_healthy 28 | # db: 29 | # image: postgres 30 | # restart: always 31 | # user: postgres 32 | # secrets: 33 | # - db-password 34 | # volumes: 35 | # - db-data:/var/lib/postgresql/data 36 | # environment: 37 | # - POSTGRES_DB=example 38 | # - POSTGRES_PASSWORD_FILE=/run/secrets/db-password 39 | # expose: 40 | # - 5432 41 | # healthcheck: 42 | # test: [ "CMD", "pg_isready" ] 43 | # interval: 10s 44 | # timeout: 5s 45 | # retries: 5 46 | # volumes: 47 | # db-data: 48 | # secrets: 49 | # db-password: 50 | # file: db/password.txt 51 | 52 | -------------------------------------------------------------------------------- /.github/workflows/claude-pr-metadata-update.yml: -------------------------------------------------------------------------------- 1 | name: "[claude] Generate PR Title & Description" 2 | 3 | # Automated PR title and description generation using Claude AI 4 | # 5 | # This workflow automatically generates: 6 | # - Conventional commit-style PR titles based on repository patterns 7 | # - Comprehensive PR descriptions based on recent merged PR templates 8 | # 9 | # Features: 10 | # - Skips rebases (uses patch-ID to detect actual code changes) 11 | # - Learns title patterns from recent commits 12 | # - Learns description templates from recent merged PRs 13 | # - Conventional commit format enforcement 14 | # - Preserves user content outside of marked sections 15 | 16 | on: 17 | pull_request: 18 | types: [opened, synchronize, ready_for_review] 19 | 20 | # Concurrency: Cancel in-flight runs for the same PR 21 | concurrency: 22 | group: pr-metadata-${{ github.event.pull_request.number }} 23 | cancel-in-progress: true 24 | 25 | jobs: 26 | generate-pr-metadata: 27 | # Skip conditions: 28 | # - Merge queue PRs (handled separately) 29 | # - Dependabot PRs (already have proper titles) 30 | # - Release PRs (have their own format) 31 | if: | 32 | !contains(github.head_ref, 'gh-readonly-queue/') && 33 | !contains(github.head_ref, 'gtmq') && 34 | !contains(github.head_ref, 'dependabot/') && 35 | !contains(github.head_ref, 'release/') && 36 | !startsWith(github.event.pull_request.title, 'chore(release):') 37 | 38 | uses: Uniswap/ai-toolkit/.github/workflows/_generate-pr-metadata.yml@9aa3cf98744a2b4e1aac51cd2d26144ea337ab3b 39 | with: 40 | generation_mode: "description,deferred-title" 41 | pr_number: ${{ github.event.pull_request.number }} 42 | base_ref: ${{ github.base_ref }} 43 | commit_history_count: 30 44 | pr_history_count: 10 45 | secrets: 46 | ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} 47 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # syntax=docker/dockerfile:1 2 | 3 | # Comments are provided throughout this file to help you get started. 4 | # If you need more help, visit the Dockerfile reference guide at 5 | # https://docs.docker.com/go/dockerfile-reference/ 6 | 7 | # Want to help us make this template better? Share your feedback here: https://forms.gle/ybq9Krt8jtBL3iCk7 8 | 9 | ARG RUST_VERSION=1.81 10 | ARG APP_NAME=uniswapx-artemis 11 | 12 | ################################################################################ 13 | # Create a stage for building the application. 14 | 15 | FROM public.ecr.aws/docker/library/rust:${RUST_VERSION}-bookworm AS build 16 | ARG APP_NAME 17 | WORKDIR /app 18 | 19 | 20 | # AWS CodeBuild doesn't seem to support buildkit so can't use --mount 21 | COPY . . 22 | RUN cargo build --locked --release && \ 23 | cp ./target/release/$APP_NAME /bin/server 24 | 25 | ################################################################################ 26 | # Create a new stage for running the application that contains the minimal 27 | # runtime dependencies for the application. This often uses a different base 28 | # image from the build stage where the necessary files are copied from the build 29 | # stage. 30 | # 31 | FROM public.ecr.aws/debian/debian:bookworm-slim AS final 32 | RUN apt-get clean && \ 33 | rm -rf /var/lib/apt/lists/* && \ 34 | apt-get update -y && \ 35 | apt-get install -y --no-install-recommends \ 36 | libssl3 \ 37 | ca-certificates && \ 38 | update-ca-certificates && \ 39 | rm -rf /var/lib/apt/lists/* 40 | 41 | # Copy the executable from the "build" stage. 42 | COPY --from=build /bin/server /bin/ 43 | 44 | # Expose the port that the application listens on. 45 | EXPOSE 1559 46 | 47 | # Add Tini 48 | # Tini helps with the problem of accidentally created zombie processes, and also makes sure that the signal handlers work 49 | # see https://github.com/krallin/tini for detail 50 | ENV TINI_VERSION=v0.19.0 51 | ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini 52 | RUN chmod +x /tini 53 | ENTRYPOINT ["/tini", "--"] 54 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # UniswapX Atomic Filler 2 | 3 | This is a sample [Artemis](https://github.com/paradigmxyz/artemis) bot that fills UniswapX orders atomically using Uniswap v2 and v3 liquidity. 4 | 5 | Feel free to fork and modify to run any strategies you wish to fill UniswapX orders! 6 | 7 | # Usage 8 | 9 | First you must deploy an executor contract that implements the [IReactorCallback](https://github.com/Uniswap/UniswapX/blob/main/src/interfaces/IReactorCallback.sol) interface. This sample currently uses the provided [SwapRouter02Executor](https://github.com/Uniswap/UniswapX/blob/main/src/sample-executors/SwapRouter02Executor.sol). 10 | 11 | Then update the address constant in [uniswapx_strategy](./src/strategies/uniswapx_strategy.rs) to point to your executor contract. 12 | 13 | Finally, run the bot with the following command: 14 | 15 | ``` 16 | cargo run -- --http --mevblocker-http --private-key --bid-percentage --order-type --chain-id --executor-address 17 | ``` 18 | 19 | # Collectors 20 | 21 | ### [block-collector](./src/collectors/block_collector.rs) 22 | 23 | Collects new blocks as they are confirmed. Similar to the base one in Artemis-core but includes timestamp data to resolve dutch decays 24 | 25 | ### [uniswapx-order-collector](./src/collectors/uniswapx_order_collector.rs) 26 | 27 | Collects new executable UniswapX orders as they are posted. 28 | 29 | ### [uniswapx-route-collector](./src/collectors/uniswapx_route_collector.rs) 30 | 31 | Finds on-chain AMM routes to fill UniswapX orders. Ran in a separate collector thread as these can be slow and don't want to block other processing. 32 | 33 | # Strategies 34 | 35 | ### [uniswapx-strategy](./src/strategies/uniswapx_strategy.rs) 36 | 37 | Simple strategy that batches UniswapX orders together by tokenin/tokenout pair and attempts to fill using Uniswap protocol liquidity 38 | 39 | # Crates 40 | 41 | ### [uniswapx-rs](./crates/uniswapx-rs) 42 | 43 | Library for encoding, decoding, and resolving UniswapX dutch orders 44 | 45 | ### [bindings-uniswapx](./crates/bindings-uniswapx) 46 | 47 | Autogenerated forge bindings for UniswapX contracts 48 | 49 | # Generating bindings 50 | 51 | ``` 52 | forge bind --root ../UniswapX --overwrite --alloy # replace UniswapX with the path to the UniswapX repo 53 | ``` 54 | -------------------------------------------------------------------------------- /src/executors/bundle_client.rs: -------------------------------------------------------------------------------- 1 | use std::sync::Arc; 2 | use alloy::{ 3 | eips::eip2718::Encodable2718, 4 | network::{AnyNetwork, EthereumWallet, TransactionBuilder}, 5 | primitives::keccak256, 6 | providers::{DynProvider, Provider}, 7 | rpc::types::TransactionRequest, 8 | serde::WithOtherFields, 9 | hex, 10 | }; 11 | use anyhow::Result; 12 | use serde::{Serialize, Deserialize}; 13 | use serde_json::Value; 14 | use tracing::info; 15 | 16 | const HEX_PREFIX: &str = "0x"; 17 | 18 | #[derive(Debug, Serialize, Deserialize)] 19 | #[serde(rename_all = "camelCase")] 20 | pub struct BundleParams { 21 | pub txs: Vec, 22 | pub min_block_number: String, 23 | pub max_block_number: String, 24 | pub reverting_tx_hashes: Vec, 25 | } 26 | 27 | pub struct BundleClient { 28 | sender_client: Arc>, 29 | } 30 | 31 | impl BundleClient { 32 | pub fn new(sender_client: Arc>) -> Self { 33 | Self { sender_client } 34 | } 35 | 36 | /// Send a single transaction as a bundle 37 | pub async fn send_bundle( 38 | &self, 39 | wallet: &EthereumWallet, 40 | tx_request: WithOtherFields, 41 | target_block: u64, 42 | bundle_window: u64, 43 | order_hash: &str, 44 | ) -> Result<(alloy::network::AnyTxEnvelope, Option)> { 45 | // Sign the transaction 46 | let tx_envelope = tx_request.build(wallet).await?; 47 | let raw_tx = tx_envelope.encoded_2718(); 48 | let signed_tx = format!("{}{}", HEX_PREFIX, hex::encode(&raw_tx)); 49 | 50 | let tx_hash = keccak256(&raw_tx); 51 | let tx_hash_hex = format!("{}{}", HEX_PREFIX, hex::encode(tx_hash)); 52 | 53 | // Build bundle params (single transaction bundle that's allowed to revert) 54 | let params = BundleParams { 55 | txs: vec![signed_tx], 56 | min_block_number: format!("{}{:x}", HEX_PREFIX, target_block), 57 | max_block_number: format!("{}{:x}", HEX_PREFIX, target_block + bundle_window), 58 | reverting_tx_hashes: vec![tx_hash_hex], 59 | }; 60 | 61 | info!("{} - Sending bundle for blocks {}-{}", order_hash, target_block, target_block + bundle_window); 62 | info!("{} - Bundle params: {:?}", order_hash, params); 63 | 64 | // Send bundle 65 | let bundle_result = self.sender_client 66 | .raw_request::, Value>( 67 | std::borrow::Cow::Borrowed("eth_sendBundle"), 68 | vec![serde_json::to_value(¶ms)?] 69 | ) 70 | .await?; 71 | 72 | // Extract bundle hash if available 73 | let bundle_hash = bundle_result.get("bundleHash") 74 | .and_then(|h| h.as_str()) 75 | .map(|s| s.to_string()); 76 | 77 | if let Some(hash) = &bundle_hash { 78 | info!("{} - Bundle submitted with hash: {}", order_hash, hash); 79 | } 80 | 81 | Ok((tx_envelope, bundle_hash)) 82 | } 83 | } -------------------------------------------------------------------------------- /src/collectors/block_collector.rs: -------------------------------------------------------------------------------- 1 | use alloy::{ 2 | network::AnyNetwork, 3 | primitives::{BlockHash, BlockNumber, BlockTimestamp}, 4 | providers::{DynProvider, Provider}, 5 | rpc::types::eth::{BlockTransactionsKind, BlockNumberOrTag}, 6 | }; 7 | use anyhow::Result; 8 | use artemis_core::types::{Collector, CollectorStream}; 9 | use async_trait::async_trait; 10 | use std::sync::Arc; 11 | use tokio_stream::StreamExt; 12 | use tokio::time::Duration; 13 | 14 | const BLOCK_POLLING_INTERVAL: Duration = Duration::from_secs(1); 15 | 16 | /// A collector that listens for new blocks, and generates a stream of 17 | /// [events](NewBlock) which contain the block number and hash. 18 | pub struct BlockCollector { 19 | provider: Arc>, 20 | } 21 | 22 | /// A new block event, containing the block number and hash. 23 | #[derive(Debug, Clone)] 24 | pub struct NewBlock { 25 | pub hash: BlockHash, 26 | pub number: BlockNumber, 27 | pub timestamp: BlockTimestamp, 28 | } 29 | 30 | impl BlockCollector { 31 | pub fn new(provider: Arc>) -> Self { 32 | Self { provider } 33 | } 34 | } 35 | 36 | /// Implementation of the [Collector](Collector) trait for the [BlockCollector](BlockCollector). 37 | /// This implementation uses polling to subscribe to new blocks. 38 | #[async_trait] 39 | impl Collector for BlockCollector { 40 | async fn get_event_stream(&self) -> Result> { 41 | let provider = self.provider.clone(); 42 | 43 | // First try to subscribe to blocks 44 | match provider.subscribe_blocks().await { 45 | Ok(sub) => { 46 | 47 | let stream = sub.into_stream().map(|header| NewBlock { 48 | hash: header.hash, 49 | number: header.number, 50 | timestamp: header.timestamp, 51 | }); 52 | Ok(Box::pin(stream)) 53 | } 54 | Err(_) => { 55 | // Fallback to polling 56 | let stream = tokio_stream::wrappers::IntervalStream::new(tokio::time::interval(BLOCK_POLLING_INTERVAL)) 57 | .then(move |_| { 58 | let provider = provider.clone(); 59 | async move { 60 | match provider.get_block_by_number(BlockNumberOrTag::Latest, BlockTransactionsKind::Full).await { 61 | Ok(Some(block)) => { 62 | let header = &block.header; 63 | Some(NewBlock { 64 | hash: header.hash, 65 | number: header.number, 66 | timestamp: header.timestamp, 67 | }) 68 | } 69 | Ok(None) => None, 70 | Err(_) => None, 71 | } 72 | } 73 | }) 74 | .filter_map(|x| x); 75 | Ok(Box::pin(stream)) 76 | } 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /crates/bindings-uniswapx/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![allow(unused_imports, clippy::all, rustdoc::all)] 2 | //! This module contains the sol! generated bindings for solidity contracts. 3 | //! This is autogenerated code. 4 | //! Do not manually edit these files. 5 | //! These files may be overwritten by the codegen system at any time. 6 | pub mod r#arraybuilder; 7 | pub mod r#basereactor; 8 | pub mod r#blocknumberish; 9 | pub mod r#mockblocknumberish; 10 | pub mod r#byteslib; 11 | pub mod r#cosignerlib; 12 | pub mod r#mockcosignerlibcontract; 13 | pub mod r#currencylibrary; 14 | pub mod r#curvebuilder; 15 | pub mod r#deploydutch; 16 | pub mod r#deploydutchv2; 17 | pub mod r#deploydutchv3; 18 | pub mod r#deployexclusivedutch; 19 | pub mod r#deploymultifillerexecutor; 20 | pub mod r#deploypermit2; 21 | pub mod r#deploypriorityorderreactor; 22 | pub mod r#deployswaprouter02executor; 23 | pub mod r#deployuniversalrouterexecutor; 24 | pub mod r#dutchdecaylib; 25 | pub mod r#dutchorderlib; 26 | pub mod r#dutchorderreactor; 27 | pub mod r#ecdsa; 28 | pub mod r#eip712; 29 | pub mod r#erc20; 30 | pub mod r#exclusivedutchorderlib; 31 | pub mod r#exclusivedutchorderreactor; 32 | pub mod r#exclusivefillervalidation; 33 | pub mod r#exclusivitylib; 34 | pub mod r#fixedpointmathlib; 35 | pub mod r#iallowancetransfer; 36 | pub mod r#iarbsys; 37 | pub mod r#ieip712; 38 | pub mod r#ierc165; 39 | pub mod r#ierc20; 40 | pub mod r#ierc5267; 41 | pub mod r#ierc721; 42 | pub mod r#ierc721enumerable; 43 | pub mod r#ierc721metadata; 44 | pub mod r#ierc721tokenreceiver; 45 | pub mod r#ipermit2; 46 | pub mod r#iprotocolfeecontroller; 47 | pub mod r#ireactor; 48 | pub mod r#ireactorcallback; 49 | pub mod r#isignaturetransfer; 50 | pub mod r#iswaprouter02; 51 | pub mod r#iuniversalrouter; 52 | pub mod r#ivalidationcallback; 53 | pub mod r#limitorderlib; 54 | pub mod r#limitorderreactor; 55 | pub mod r#math; 56 | pub mod r#mathext; 57 | pub mod r#mockarbsys; 58 | pub mod r#mockdutchorderreactor; 59 | pub mod r#mockerc20; 60 | pub mod r#mockerc721; 61 | pub mod r#mockexclusivitylib; 62 | pub mod r#mockfeecontroller; 63 | pub mod r#mockfeecontrollerduplicates; 64 | pub mod r#mockfeecontrollerinputandoutputfees; 65 | pub mod r#mockfeecontrollerinputfees; 66 | pub mod r#mockfeecontrollerzerofee; 67 | pub mod r#mockfillcontract; 68 | pub mod r#mockfillcontractdoubleexecution; 69 | pub mod r#mockfillcontractwithoutputoverride; 70 | pub mod r#mockprotocolfees; 71 | pub mod r#mockresolvedorderlib; 72 | pub mod r#mockswaprouter; 73 | pub mod r#mockswapper; 74 | pub mod r#mockvalidationcontract; 75 | pub mod r#multifillerswaprouter02executor; 76 | pub mod r#nonlineardutchdecaylib; 77 | pub mod r#orderinfobuilder; 78 | pub mod r#orderinfolib; 79 | pub mod r#orderquoter; 80 | pub mod r#outputsbuilder; 81 | pub mod r#owned; 82 | pub mod r#path; 83 | pub mod r#pathbuilder; 84 | pub mod r#permit2lib; 85 | pub mod r#permitsignature; 86 | pub mod r#priorityfeelib; 87 | pub mod r#priorityorderlib; 88 | pub mod r#priorityorderreactor; 89 | pub mod r#protocolfees; 90 | pub mod r#reactorevents; 91 | pub mod r#reentrancyguard; 92 | pub mod r#resolvedorderlib; 93 | pub mod r#safecast; 94 | pub mod r#safetransferlib; 95 | pub mod r#shortstrings; 96 | pub mod r#signedmath; 97 | pub mod r#solarray; 98 | pub mod r#storageslot; 99 | pub mod r#strings; 100 | pub mod r#swaprouter02executor; 101 | pub mod r#uint16arraylibrary; 102 | pub mod r#universalrouterexecutor; 103 | pub mod r#v2dutchorderlib; 104 | pub mod r#v2dutchorderreactor; 105 | pub mod r#v3dutchorderlib; 106 | pub mod r#v3dutchorderreactor; 107 | pub mod r#weth; 108 | -------------------------------------------------------------------------------- /src/executors/reactor_error_code.rs: -------------------------------------------------------------------------------- 1 | use alloy::{ 2 | eips::BlockId, 3 | network::AnyNetwork, 4 | providers::{DynProvider, Provider}, 5 | rpc::types::TransactionRequest, 6 | serde::WithOtherFields, 7 | transports::RpcError, 8 | }; 9 | use anyhow::Result; 10 | 11 | pub enum ReactorErrorCode { 12 | InvalidDeadline, 13 | OrderNotFillable, 14 | OrderAlreadyFilled, 15 | InsufficientETH, 16 | InsufficientToken, 17 | NativeTransferFailed, 18 | AllowanceExpired, 19 | Unknown, 20 | } 21 | 22 | // implements the From trait for the ReactorErrorCode enum to convert it to a string 23 | impl From for ReactorErrorCode { 24 | fn from(s: String) -> Self { 25 | // Remove quotes and whitespace before matching 26 | let cleaned = s.trim().trim_matches('\"'); 27 | // Take first 10 chars (including 0x) if longer 28 | let code = if cleaned.len() > 10 { 29 | &cleaned[..10] 30 | } else { 31 | cleaned 32 | }; 33 | 34 | match code { 35 | "0xc6035520" => ReactorErrorCode::OrderNotFillable, 36 | "0xee3b3d4b" => ReactorErrorCode::OrderAlreadyFilled, 37 | "0x769d11e4" => ReactorErrorCode::InvalidDeadline, 38 | "0x6a12f104" => ReactorErrorCode::InsufficientETH, 39 | "0x675cae38" => ReactorErrorCode::InsufficientToken, 40 | "0xf4b3b1bc" => ReactorErrorCode::NativeTransferFailed, 41 | "0xd81b2f2e" => ReactorErrorCode::AllowanceExpired, 42 | _ => ReactorErrorCode::Unknown, 43 | } 44 | } 45 | } 46 | 47 | impl std::fmt::Display for ReactorErrorCode { 48 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 49 | let s = match self { 50 | ReactorErrorCode::InvalidDeadline => "InvalidDeadline", 51 | ReactorErrorCode::OrderNotFillable => "OrderNotFillable", 52 | ReactorErrorCode::OrderAlreadyFilled => "OrderAlreadyFilled", 53 | ReactorErrorCode::InsufficientETH => "InsufficientETH", 54 | ReactorErrorCode::InsufficientToken => "InsufficientToken", 55 | ReactorErrorCode::NativeTransferFailed => "NativeTransferFailed", 56 | ReactorErrorCode::AllowanceExpired => "AllowanceExpired", 57 | ReactorErrorCode::Unknown => "Unknown", 58 | }; 59 | write!(f, "{}", s) 60 | } 61 | } 62 | 63 | pub async fn get_revert_reason( 64 | provider: &DynProvider, 65 | tx: WithOtherFields, 66 | block_number: u64, 67 | ) -> Result> { 68 | 69 | // Simulate the transaction at the block right before it was mined 70 | let result = provider 71 | .call(&tx) 72 | .block(BlockId::Number(block_number.into())) 73 | .await; 74 | 75 | // Extract revert reason from the error 76 | match result { 77 | Ok(_) => Err("Tx succeeded in simulation".into()), 78 | Err(e) => { 79 | let err_msg = e.to_string(); // Clone the error message first 80 | if let RpcError::ErrorResp(err) = e { 81 | if let Some(data) = err.data.as_ref().map(|d| d.get()) { 82 | let error_code = ReactorErrorCode::from(data.to_string()); 83 | if matches!(error_code, ReactorErrorCode::Unknown) { 84 | Err(format!("Failed to extract revert reason from code: {}", data).into()) 85 | } else { 86 | Ok(error_code) 87 | } 88 | } else { 89 | Err(format!("Failed to extract revert reason: {}", err_msg).into()) 90 | } 91 | } else { 92 | Err(format!("Failed to extract revert reason: {}", err_msg).into()) 93 | } 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /crates/uniswapx-rs/src/sol_math.rs: -------------------------------------------------------------------------------- 1 | use alloy_primitives::Uint; 2 | 3 | type U256 = Uint<256, 4>; 4 | 5 | pub trait MulDiv { 6 | fn mul_div_down(&self, b: U256, c: U256) -> Result; 7 | fn mul_div_up(&self, b: U256, c: U256) -> Result; 8 | } 9 | 10 | impl MulDiv for U256 { 11 | fn mul_div_down(&self, b: U256, c: U256) -> Result { 12 | let product = self.checked_mul(b).ok_or_else(|| anyhow::anyhow!("Multiplication overflow"))?; 13 | product.checked_div(c).ok_or_else(|| anyhow::anyhow!("Division by zero")) 14 | } 15 | fn mul_div_up(&self, b: U256, c: U256) -> Result { 16 | let product = self.checked_mul(b).ok_or_else(|| anyhow::anyhow!("Multiplication overflow"))?; 17 | if c == U256::ZERO { 18 | return Err(anyhow::anyhow!("Division by zero")); 19 | } 20 | let (quotient, remainder) = product.div_rem(c); 21 | if remainder == U256::ZERO { 22 | Ok(quotient) 23 | } else { 24 | Ok(quotient + U256::from(1)) 25 | } 26 | } 27 | } 28 | 29 | // tests 30 | #[cfg(test)] 31 | mod tests { 32 | use super::*; 33 | 34 | #[test] 35 | fn test_mul_div_down() { 36 | let a = U256::from(10); 37 | let b = U256::from(20); 38 | let c = U256::from(5); 39 | 40 | assert_eq!(a.mul_div_down(b, c).unwrap(), U256::from(40)); 41 | 42 | // Test with larger numbers 43 | let a = U256::from(1_000_000_000_000_u64); 44 | let b = U256::from(2_000_000_000_000_u64); 45 | let c = U256::from(500_000_000_000_u64); 46 | 47 | assert_eq!(a.mul_div_down(b, c).unwrap(), U256::from(4_000_000_000_000_u64)); 48 | } 49 | 50 | #[test] 51 | fn test_mul_div_up() { 52 | let a = U256::from(10); 53 | let b = U256::from(20); 54 | let c = U256::from(3); 55 | 56 | assert_eq!(a.mul_div_up(b, c).unwrap(), U256::from(67)); 57 | 58 | // Test with larger numbers 59 | let a = U256::from(1_000_000_000_000_u64); 60 | let b = U256::from(2_000_000_000_000_u64); 61 | let c = U256::from(300_000_000_000_u64); 62 | 63 | assert_eq!(a.mul_div_up(b, c).unwrap(), U256::from(6_666_666_666_667_u64)); 64 | } 65 | 66 | #[test] 67 | fn test_mul_div_down_no_remainder() { 68 | let a = U256::from(10); 69 | let b = U256::from(20); 70 | let c = U256::from(2); 71 | 72 | assert_eq!(a.mul_div_down(b, c).unwrap(), U256::from(100)); 73 | } 74 | 75 | #[test] 76 | fn test_mul_div_down_with_remainder() { 77 | let a = U256::from(10); 78 | let b = U256::from(20); 79 | let c = U256::from(3); 80 | 81 | assert_eq!(a.mul_div_down(b, c).unwrap(), U256::from(66)); 82 | } 83 | 84 | #[test] 85 | fn test_mul_div_up_no_remainder() { 86 | let a = U256::from(10); 87 | let b = U256::from(20); 88 | let c = U256::from(2); 89 | 90 | assert_eq!(a.mul_div_up(b, c).unwrap(), U256::from(100)); 91 | } 92 | 93 | #[test] 94 | fn test_mul_div_up_with_remainder() { 95 | let a = U256::from(10); 96 | let b = U256::from(20); 97 | let c = U256::from(3); 98 | 99 | assert_eq!(a.mul_div_up(b, c).unwrap(), U256::from(67)); 100 | } 101 | 102 | #[test] 103 | fn test_mul_div_down_overflow() { 104 | let a = U256::MAX; 105 | let b = U256::from(2); 106 | let c = U256::from(1); 107 | 108 | let result = a.mul_div_down(b, c); 109 | assert!(result.is_err()); 110 | assert_eq!(result.unwrap_err().to_string(), "Multiplication overflow"); 111 | } 112 | 113 | #[test] 114 | fn test_mul_div_up_overflow() { 115 | let a = U256::MAX; 116 | let b = U256::from(2); 117 | let c = U256::from(1); 118 | 119 | let result = a.mul_div_up(b, c); 120 | assert!(result.is_err()); 121 | assert_eq!(result.unwrap_err().to_string(), "Multiplication overflow"); 122 | } 123 | 124 | #[test] 125 | fn test_mul_div_down_division_by_zero() { 126 | let a = U256::from(10); 127 | let b = U256::from(20); 128 | let c = U256::from(0); 129 | 130 | let result = a.mul_div_down(b, c); 131 | assert!(result.is_err()); 132 | assert_eq!(result.unwrap_err().to_string(), "Division by zero"); 133 | } 134 | 135 | #[test] 136 | fn test_mul_div_up_division_by_zero() { 137 | let a = U256::from(10); 138 | let b = U256::from(20); 139 | let c = U256::from(0); 140 | 141 | let result = a.mul_div_up(b, c); 142 | assert!(result.is_err()); 143 | assert_eq!(result.unwrap_err().to_string(), "Division by zero"); 144 | } 145 | } 146 | -------------------------------------------------------------------------------- /.claude/prompts/claude-pr-review.md: -------------------------------------------------------------------------------- 1 | # Claude PR Review Guidelines 2 | 3 | You're a code reviewer helping engineers ship better code. Your feedback should be high-signal: every comment should prevent a bug, improve maintainability, or teach something valuable. 4 | 5 | ## Review Philosophy 6 | 7 | **Every PR tells a story.** Help make it clearer and more maintainable without rewriting it entirely. 8 | 9 | **Review the code, not the coder.** Focus on patterns and principles. 10 | 11 | **Teach through specifics.** Concrete examples stick better than abstract feedback. But only teach when there's a genuine gap - don't explain things the author already knows. 12 | 13 | **Balance teaching with shipping.** Balance idealism with pragmatism. 14 | 15 | ## Review Priorities 16 | 17 | ### Phase 1: Critical Issues 18 | 19 | Problems that would cause immediate harm: 20 | 21 | - Bugs or logic errors 22 | - Security vulnerabilities 23 | - Performance problems impacting users 24 | - Data corruption risks 25 | - Race conditions 26 | 27 | ### Phase 2: Patterns & Principles 28 | 29 | Improvements to maintainability (flag these, but they're rarely blockers): 30 | 31 | - Functions doing too many things - can't test pieces independently 32 | - Hidden dependencies - requires complex mocking, creates surprising behaviors 33 | - Missing error handling - silent failures, hard to debug 34 | 35 | ### Phase 3: Polish 36 | 37 | Nice-to-haves. Mention only if the win is obvious: 38 | 39 | - Naming improvements 40 | - Test coverage gaps 41 | - Documentation 42 | 43 | ## Decision Framework 44 | 45 | **Request Changes** - Only when you're certain something will break: 46 | 47 | - Bugs that will hit production 48 | - Security vulnerabilities with clear exploit paths 49 | - Data loss risks 50 | 51 | If you're not 100% certain, don't request changes. 52 | 53 | **Approve** - Your default. Use it when: 54 | 55 | - The code works 56 | - You have suggestions but they're improvements, not blockers 57 | - You're uncertain whether something is actually a problem 58 | 59 | Approve with comments beats comment-only reviews. If it's not worth blocking, it's worth approving. 60 | 61 | **Comment** - Rarely. Creates friction without clear signal. 62 | 63 | ## Weighting Existing Context 64 | 65 | Before deciding, check existing comments and discussions: 66 | 67 | - **Resolved threads**: Don't re-raise them 68 | - **Engineer responses**: If they explained why something is intentional, weight their domain knowledge heavily. They understand context you don't. 69 | - **Prior approvals**: Your bar for requesting changes should be even higher 70 | 71 | When engineers push back on feedback, assume they have context you're missing. Don't repeat the same point. 72 | 73 | ## Inline Comment Behavior 74 | 75 | You post reviews as `github-actions[bot]`. This identity matters for managing comment threads. 76 | 77 | ### Comment Resolution 78 | 79 | - **Only resolve your own comments** (from `github-actions[bot]`) 80 | - **Never resolve human comments** - engineers add call-outs, context, and explanations that should remain visible 81 | - Resolve your comments only when the code addresses the issue 82 | 83 | ### Self-Replies 84 | 85 | **Don't reply to your own comments.** When reviewing code you've previously commented on: 86 | 87 | - Issue fixed → resolve the comment silently 88 | - Issue still present → leave silently, the existing comment speaks for itself 89 | - Avoid creating reply threads with yourself 90 | 91 | ### Human Replies 92 | 93 | **Carefully consider human replies to your comments.** When someone responds: 94 | 95 | - Assume they have context you're missing 96 | - If they say it's intentional, accept it 97 | - If they correct you, update your understanding 98 | - Don't repeat or argue the same point 99 | 100 | ### Human Comments 101 | 102 | - Leave human call-outs alone (context notes, explanations, FYIs) 103 | - Only respond to direct questions aimed at you 104 | - Don't resolve conversations between engineers 105 | 106 | ## Pattern Examples 107 | 108 | **Spot this (mixed concerns):** 109 | 110 | ```ts 111 | async function handleUserAction(userId, action) { 112 | if (!userId) throw new Error('Invalid user'); 113 | const user = await db.getUser(userId); 114 | const result = processAction(user, action); 115 | await db.save(result); 116 | return result; 117 | } 118 | ``` 119 | 120 | **Suggest this:** 121 | 122 | "Four responsibilities here. Splitting them makes testing easier - each piece testable without mocking the others." 123 | 124 | **Spot this (hardcoded dependency):** 125 | 126 | ```javascript 127 | import { stripeClient } from './stripe'; 128 | async function chargeCard(amount) { 129 | return stripeClient.charge(amount); 130 | } 131 | ``` 132 | 133 | **Suggest this:** 134 | 135 | "Accepting the payment client as a parameter makes this testable and swappable: 136 | 137 | ```javascript 138 | async function chargeCard(amount, paymentClient) { 139 | return paymentClient.charge(amount); 140 | } 141 | ```" 142 | 143 | ## Writing Comments 144 | 145 | Be direct and brief. 146 | 147 | **Good:** 148 | 149 | > Line 714: logger.error expects Error objects, not strings. 150 | 151 | **Good:** 152 | 153 | > This could throw if `user` is null. Consider `user?.preferences?.theme`. 154 | 155 | **Good:** 156 | 157 | > Heads up: Opus is pricier than Sonnet - assuming that's intentional? 158 | 159 | **Good (recognizing good code):** 160 | 161 | > Clean separation here - validation is pure, easy to test. 162 | 163 | **Too much:** 164 | 165 | > Issue 1: Logger Interface Violation (Blocking) 166 | > The Danger bot correctly identified that the code is logging strings directly to logger.error()... Why this matters: The logger interface expects Error objects for structured error logging... 167 | 168 | One issue, one or two lines. Skip headers, emojis, and "Why this matters" sections unless it's genuinely non-obvious. 169 | 170 | ## Avoid 171 | 172 | - Filler words: "robust," "comprehensive," "excellent," "well-structured," "solid" 173 | - Summarizing what the PR description already says 174 | - Hedging: "Maybe you could...", "Consider perhaps..." 175 | - Starting with generic praise: "Great job!", "Nice work!" 176 | - Long reviews - if it's more than a few paragraphs, you're not sure what actually matters 177 | 178 | ## Remember 179 | 180 | Your job is to catch real problems and help engineers ship safely. A short review that approves working code is better than a thorough essay that blocks it for theoretical improvements. 181 | 182 | When in doubt, approve. 183 | -------------------------------------------------------------------------------- /src/executors/transaction_utils.rs: -------------------------------------------------------------------------------- 1 | use std::sync::Arc; 2 | use alloy::{ 3 | eips::eip2718::Encodable2718, 4 | network::{AnyNetwork, EthereumWallet, ReceiptResponse}, 5 | primitives::keccak256, 6 | providers::{DynProvider, Provider}, 7 | rpc::types::TransactionRequest, 8 | serde::WithOtherFields, 9 | }; 10 | use anyhow::Result; 11 | use aws_sdk_cloudwatch::Client as CloudWatchClient; 12 | use tracing::{debug, info, warn}; 13 | 14 | use crate::{ 15 | aws_utils::cloudwatch_utils::{ 16 | build_metric_future, revert_code_to_metric, CwMetrics, DimensionValue 17 | }, 18 | executors::reactor_error_code::{get_revert_reason, ReactorErrorCode}, 19 | shared::{burn_nonce, send_metric_with_order_hash}, 20 | }; 21 | 22 | #[derive(Debug)] 23 | pub enum TransactionOutcome { 24 | Success(Option), 25 | Failure(Option), 26 | RetryableFailure, 27 | } 28 | 29 | /// Poll for transaction receipt with timeout 30 | pub async fn poll_for_receipt( 31 | sender_client: &Arc>, 32 | client: &Arc>, 33 | tx_envelope: &alloy::network::AnyTxEnvelope, 34 | target_block: u64, 35 | order_hash: &str, 36 | timeout_sec: u64, 37 | poll_interval_ms: u64, 38 | ) -> Result>>>> { 39 | // Compute the transaction hash 40 | let tx_bytes = tx_envelope.encoded_2718(); 41 | let tx_hash = keccak256(&tx_bytes); 42 | 43 | let start_time = std::time::Instant::now(); 44 | while start_time.elapsed() < std::time::Duration::from_secs(timeout_sec) { 45 | // Use sender_client to get receipt from the same endpoint 46 | match sender_client.get_transaction_receipt(tx_hash).await { 47 | Ok(Some(receipt)) => return Ok(Some(receipt)), 48 | Ok(None) => { 49 | // Check if we've passed the target block 50 | let current_block = client.get_block_number().await?; 51 | if current_block > target_block + 1 { 52 | info!("{} - Transaction not included, target block passed", order_hash); 53 | return Ok(None); 54 | } 55 | } 56 | Err(e) => { 57 | debug!("{} - Error getting receipt: {}", order_hash, e); 58 | } 59 | } 60 | 61 | tokio::time::sleep(std::time::Duration::from_millis(poll_interval_ms)).await; 62 | } 63 | 64 | Ok(None) 65 | } 66 | 67 | /// Process transaction receipt and determine outcome 68 | pub async fn process_receipt( 69 | receipt: Option, 70 | client: &Arc>, 71 | tx_request_for_revert: WithOtherFields, 72 | order_hash: &str, 73 | chain_id: u64, 74 | target_block: Option, 75 | cloudwatch_client: Option>, 76 | ) -> Result { 77 | match receipt { 78 | Some(receipt) => { 79 | // Handle metrics for target block delta 80 | if let (Some(block_num), Some(target)) = (receipt.block_number(), target_block) { 81 | let target_block_delta = block_num as f64 - target as f64; 82 | info!("{} - target block delta: {}, target_block: {}, actual_block: {}", 83 | order_hash, target_block_delta, target, block_num); 84 | 85 | let metric_future = build_metric_future( 86 | cloudwatch_client.clone(), 87 | DimensionValue::PriorityExecutor, 88 | CwMetrics::TargetBlockDelta(chain_id), 89 | target_block_delta, 90 | ); 91 | if let Some(metric_future) = metric_future { 92 | send_metric_with_order_hash!(&Arc::new(order_hash.to_string()), metric_future); 93 | } 94 | } 95 | 96 | let status = receipt.status(); 97 | info!("{} - receipt: tx_hash: {:?}, status: {}", 98 | order_hash, receipt.transaction_hash(), status); 99 | 100 | if !status && receipt.block_number().is_some() { 101 | // Get revert reason 102 | info!("{} - Attempting to get revert reason", order_hash); 103 | match get_revert_reason(client, tx_request_for_revert, receipt.block_number().unwrap()).await { 104 | Ok(reason) => { 105 | info!("{} - Revert reason: {}", order_hash, reason); 106 | let metric_future = build_metric_future( 107 | cloudwatch_client, 108 | DimensionValue::PriorityExecutor, 109 | revert_code_to_metric(chain_id, reason.to_string()), 110 | 1.0, 111 | ); 112 | if let Some(metric_future) = metric_future { 113 | send_metric_with_order_hash!(&Arc::new(order_hash.to_string()), metric_future); 114 | } 115 | 116 | if matches!(reason, ReactorErrorCode::OrderNotFillable) { 117 | Ok(TransactionOutcome::RetryableFailure) 118 | } else { 119 | Ok(TransactionOutcome::Failure(receipt.block_number())) 120 | } 121 | } 122 | Err(e) => { 123 | info!("{} - Failed to get revert reason: {:?}", order_hash, e); 124 | Ok(TransactionOutcome::Failure(receipt.block_number())) 125 | } 126 | } 127 | } else { 128 | Ok(TransactionOutcome::Success(receipt.block_number())) 129 | } 130 | } 131 | None => { 132 | warn!("{} - No receipt found", order_hash); 133 | Ok(TransactionOutcome::Failure(None)) 134 | } 135 | } 136 | } 137 | 138 | /// Handle transaction sending errors 139 | pub async fn handle_send_error( 140 | error: anyhow::Error, 141 | sender_client: &Arc>, 142 | wallet: &EthereumWallet, 143 | tx_request: &WithOtherFields, 144 | order_hash: &str, 145 | ) -> Result { 146 | warn!("{} - Error sending transaction: {}", order_hash, error); 147 | 148 | // Handle nonce issues 149 | if error.to_string().contains("replacement transaction underpriced") { 150 | info!("{} - Nonce already used, burning nonce for next transaction", order_hash); 151 | burn_nonce( 152 | sender_client, 153 | wallet, 154 | tx_request.from.unwrap(), 155 | tx_request.nonce.unwrap(), 156 | order_hash 157 | ).await?; 158 | } 159 | 160 | Ok(TransactionOutcome::Failure(None)) 161 | } -------------------------------------------------------------------------------- /src/shared.rs: -------------------------------------------------------------------------------- 1 | use std::sync::Arc; 2 | 3 | use alloy::{network::{AnyNetwork, EthereumWallet, TransactionBuilder}, providers::{DynProvider, Provider}, rpc::types::TransactionRequest, serde::WithOtherFields}; 4 | use alloy_primitives::{Address, U256}; 5 | use serde::Deserialize; 6 | 7 | const NONCE_BURN_GAS_MULTIPLIER: u128 = 10; 8 | const NONCE_BURN_PRIORITY_FEE: u128 = 1e7 as u128; // 0.01 gwei (max priority bid possible) 9 | const ETH_TRANSFER_GAS: u64 = 21000; 10 | 11 | /// ERC20ETH address - same across all chains 12 | /// ERC20ETH is an ERC20 wrapper for native ETH that uses ERC-7914 for smart wallet compatibility 13 | pub const ERC20ETH_ADDRESS: &str = "0x00000000e20E49e6dCeE6e8283A0C090578F0fb9"; 14 | 15 | macro_rules! send_metric_with_order_hash { 16 | ($order_hash: expr, $future: expr) => { 17 | let hash = Arc::clone($order_hash); 18 | tokio::spawn(async move { 19 | if let Err(e) = $future.await { 20 | tracing::warn!("{} - error sending metric: {:?}", hash, e); 21 | } 22 | }) 23 | }; 24 | } 25 | 26 | macro_rules! u256 { 27 | ($($limb:expr),*) => { 28 | alloy_primitives::Uint::from_limbs([$($limb, 0, 0, 0),*]) 29 | }; 30 | } 31 | 32 | pub(crate) use send_metric_with_order_hash; 33 | pub(crate) use u256; 34 | 35 | /// Normalizes ERC20ETH to native ETH (zero address) for internal processing. 36 | /// ERC20ETH is an ERC20 wrapper for native ETH, so we treat it as native ETH 37 | /// since that's what we'll receive during the callback. 38 | pub fn normalize_erc20eth_to_native(token: &str) -> String { 39 | if token.eq_ignore_ascii_case(ERC20ETH_ADDRESS) { 40 | "0x0000000000000000000000000000000000000000".to_string() 41 | } else { 42 | token.to_string() 43 | } 44 | } 45 | 46 | /// Normalizes ERC20ETH to native ETH (Address::ZERO) for internal processing. 47 | pub fn normalize_erc20eth_to_native_address(token: Address) -> Address { 48 | if let Ok(erc20eth_addr) = ERC20ETH_ADDRESS.parse::
() { 49 | if token == erc20eth_addr { 50 | return Address::ZERO; 51 | } 52 | } 53 | token 54 | } 55 | 56 | #[derive(Clone, Debug, Deserialize)] 57 | #[serde(tag = "type")] 58 | pub struct MethodParameters { 59 | pub calldata: String, 60 | pub value: String, 61 | pub to: String, 62 | } 63 | 64 | #[derive(Debug, Clone, Deserialize)] 65 | pub struct RouteInfo { 66 | pub quote: String, 67 | #[serde(rename = "quoteGasAdjusted")] 68 | pub quote_gas_adjusted: String, 69 | #[serde(rename = "gasUseEstimate")] 70 | pub gas_use_estimate: String, 71 | #[serde(rename = "gasUseEstimateQuote")] 72 | pub gas_use_estimate_quote: String, 73 | #[serde(rename = "gasPriceWei")] 74 | pub gas_price_wei: String, 75 | #[serde(rename = "methodParameters")] 76 | pub method_parameters: MethodParameters, 77 | } 78 | 79 | 80 | pub async fn get_nonce_with_retry( 81 | sender_client: &Arc>, 82 | address: Address, 83 | order_hash: &str, 84 | max_attempts: u32, 85 | ) -> Result { 86 | let mut attempts = 0; 87 | loop { 88 | match sender_client.get_transaction_count(address).await { 89 | Ok(nonce) => break Ok(nonce), 90 | Err(e) => { 91 | if attempts < max_attempts - 1 { 92 | attempts += 1; 93 | } else { 94 | return Err(anyhow::anyhow!( 95 | "{} - Failed to get nonce after {} attempts: {}", 96 | order_hash, 97 | max_attempts, 98 | e 99 | )); 100 | } 101 | } 102 | } 103 | } 104 | } 105 | 106 | /// @notice Burns a specific nonce by sending a 0 ETH transaction to self with a high gas price. 107 | /// @dev This function is used to invalidate a nonce by creating a dummy transaction. 108 | /// @param provider The Ethereum provider used to send the transaction. 109 | /// @param wallet The wallet used to sign the transaction. 110 | /// @param address The address whose nonce will be burned. 111 | /// @param nonce The specific nonce to burn. 112 | /// @param order_hash A string identifier for logging and tracing purposes. 113 | /// @return Returns Ok(()) if the transaction is sent and confirmed, or an error otherwise. 114 | pub async fn burn_nonce( 115 | provider: &Arc>, 116 | wallet: &EthereumWallet, 117 | address: Address, 118 | nonce: u64, 119 | order_hash: &str, 120 | ) -> Result<(), anyhow::Error> { 121 | let base_fee = provider 122 | .get_gas_price() 123 | .await?; 124 | 125 | // Create a dummy transaction that sends 0 ETH to self with high gas price 126 | let tx_request = WithOtherFields::new(TransactionRequest { 127 | from: Some(address), 128 | to: Some(address.into()), 129 | value: Some(U256::ZERO), 130 | nonce: Some(nonce), 131 | gas: Some(ETH_TRANSFER_GAS), // Standard ETH transfer gas 132 | gas_price: Some(base_fee * NONCE_BURN_GAS_MULTIPLIER), 133 | max_fee_per_gas: Some(base_fee * NONCE_BURN_GAS_MULTIPLIER), 134 | max_priority_fee_per_gas: Some(NONCE_BURN_PRIORITY_FEE), 135 | ..Default::default() 136 | }); 137 | 138 | // Sign and send the transaction 139 | let tx = tx_request.build(wallet).await?; 140 | let result = provider.send_tx_envelope(tx).await; 141 | 142 | match result { 143 | Ok(tx) => { 144 | // Don't wait for confirmations 145 | tracing::info!("{} - Nonce burn transaction sent: {:?}", order_hash, tx.tx_hash()); 146 | Ok(()) 147 | } 148 | Err(e) => { 149 | tracing::error!("{} - Error sending nonce burn transaction: {}", order_hash, e); 150 | return Err(anyhow::anyhow!("{} - Error sending nonce burn transaction: {}", order_hash, e)); 151 | } 152 | } 153 | } 154 | 155 | #[cfg(test)] 156 | mod tests { 157 | use super::*; 158 | 159 | #[test] 160 | fn test_normalize_erc20eth_to_native_lowercase() { 161 | let erc20eth = "0x00000000e20e49e6dcee6e8283a0c090578f0fb9"; 162 | let result = normalize_erc20eth_to_native(erc20eth); 163 | assert_eq!(result, "0x0000000000000000000000000000000000000000"); 164 | } 165 | 166 | #[test] 167 | fn test_normalize_erc20eth_to_native_uppercase() { 168 | let erc20eth = "0x00000000E20E49E6DCEE6E8283A0C090578F0FB9"; 169 | let result = normalize_erc20eth_to_native(erc20eth); 170 | assert_eq!(result, "0x0000000000000000000000000000000000000000"); 171 | } 172 | 173 | #[test] 174 | fn test_normalize_erc20eth_to_native_mixed_case() { 175 | let erc20eth = ERC20ETH_ADDRESS; // Already mixed case 176 | let result = normalize_erc20eth_to_native(erc20eth); 177 | assert_eq!(result, "0x0000000000000000000000000000000000000000"); 178 | } 179 | 180 | #[test] 181 | fn test_normalize_erc20eth_to_native_regular_token() { 182 | let token = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"; 183 | let result = normalize_erc20eth_to_native(token); 184 | assert_eq!(result, token); 185 | } 186 | 187 | #[test] 188 | fn test_normalize_erc20eth_to_native_zero_address() { 189 | let zero = "0x0000000000000000000000000000000000000000"; 190 | let result = normalize_erc20eth_to_native(zero); 191 | assert_eq!(result, zero); // Should remain unchanged 192 | } 193 | 194 | #[test] 195 | fn test_normalize_erc20eth_to_native_address_erc20eth() { 196 | let erc20eth = ERC20ETH_ADDRESS.parse::
().unwrap(); 197 | let result = normalize_erc20eth_to_native_address(erc20eth); 198 | assert_eq!(result, Address::ZERO); 199 | } 200 | 201 | #[test] 202 | fn test_normalize_erc20eth_to_native_address_regular_token() { 203 | let token = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2".parse::
().unwrap(); 204 | let result = normalize_erc20eth_to_native_address(token); 205 | assert_eq!(result, token); 206 | } 207 | 208 | #[test] 209 | fn test_normalize_erc20eth_to_native_address_zero() { 210 | let zero = Address::ZERO; 211 | let result = normalize_erc20eth_to_native_address(zero); 212 | assert_eq!(result, Address::ZERO); 213 | } 214 | } -------------------------------------------------------------------------------- /src/strategies/shared.rs: -------------------------------------------------------------------------------- 1 | use crate::{ 2 | collectors::uniswapx_route_collector::RoutedOrder, 3 | shared::{ERC20ETH_ADDRESS, normalize_erc20eth_to_native}, 4 | }; 5 | use alloy::{ 6 | hex, 7 | network::{AnyNetwork, TransactionBuilder}, 8 | primitives::{Address, U256}, 9 | providers::{DynProvider, Provider}, 10 | rpc::types::TransactionRequest, 11 | serde::WithOtherFields, 12 | sol, 13 | }; 14 | use alloy_primitives::Bytes; 15 | use anyhow::Result; 16 | use async_trait::async_trait; 17 | use bindings_uniswapx::{ 18 | basereactor::BaseReactor::SignedOrder, erc20::ERC20, 19 | universalrouterexecutor::UniversalRouterExecutor, 20 | }; 21 | use ethabi::{ethereum_types::H160, Token}; 22 | use std::{ 23 | sync::Arc, 24 | time::{SystemTime, UNIX_EPOCH}, 25 | }; 26 | 27 | const REACTOR_ADDRESS: &str = "0x00000011F84B9aa48e5f8aA8B9897600006289Be"; 28 | const PERMIT2_ADDRESS: &str = "0x000000000022D473030F116dDEE9F6B43aC78BA3"; 29 | pub const WETH_ADDRESS: &str = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"; 30 | const ARBITRUM_GAS_PRECOMPILE: &str = "0x000000000000000000000000000000000000006C"; 31 | 32 | sol! { 33 | #[allow(missing_docs)] 34 | #[sol(rpc)] 35 | contract GasPrecompileContract { 36 | function getMinimumGasPrice() external view returns (uint256); 37 | } 38 | } 39 | 40 | #[async_trait] 41 | pub trait UniswapXStrategy { 42 | // builds a transaction to fill an order 43 | async fn build_fill( 44 | &self, 45 | client: Arc>, 46 | executor_address: &str, 47 | signed_orders: Vec, 48 | RoutedOrder { request, route, .. }: &RoutedOrder, 49 | ) -> Result> { 50 | let chain_id = client.get_chain_id().await?; 51 | let fill_contract = 52 | UniversalRouterExecutor::new(executor_address.parse::
()?, client.clone()); 53 | 54 | // Normalize ERC20ETH to native ETH (zero address) since we'll receive native ETH during callback 55 | let normalized_token_in = normalize_erc20eth_to_native(&request.token_in); 56 | let token_in = normalized_token_in.parse::
()?; 57 | let token_out = request.token_out.parse::
()?; 58 | 59 | let permit2_approval = self 60 | .get_tokens_to_approve(client.clone(), token_in, executor_address, PERMIT2_ADDRESS) 61 | .await?; 62 | 63 | let reactor_approval = self 64 | .get_tokens_to_approve(client.clone(), token_out, executor_address, REACTOR_ADDRESS) 65 | .await?; 66 | 67 | let execute_bytes = &route.method_parameters.calldata; 68 | let encoded_execute_bytes = hex::decode(&execute_bytes[2..]).expect("Failed to decode hex"); 69 | 70 | // abi encode as [tokens to approve to swap router 02, tokens to approve to reactor, multicall data] 71 | // [address[], address[], bytes[]] 72 | let encoded_calldata = ethabi::encode(&[ 73 | Token::Array(permit2_approval), 74 | Token::Array(reactor_approval), 75 | Token::Bytes(encoded_execute_bytes), 76 | ]); 77 | let orders: Vec = signed_orders 78 | .into_iter() 79 | .map(|order| UniversalRouterExecutor::SignedOrder { 80 | order: order.order, 81 | sig: order.sig, 82 | }) 83 | .collect(); 84 | let call = fill_contract.executeBatch(orders, Bytes::from(encoded_calldata)); 85 | Ok(call.into_transaction_request().with_chain_id(chain_id)) 86 | } 87 | 88 | fn current_timestamp(&self) -> Result { 89 | let start = SystemTime::now(); 90 | Ok(start.duration_since(UNIX_EPOCH)?.as_secs()) 91 | } 92 | 93 | async fn get_tokens_to_approve( 94 | &self, 95 | client: Arc>, 96 | token: Address, 97 | from: &str, 98 | to: &str, 99 | ) -> Result, anyhow::Error> { 100 | // Native ETH and ERC20ETH don't need approval 101 | // ERC20ETH will result in native ETH transfer during callback, so no approval needed 102 | if token == Address::ZERO { 103 | return Ok(vec![]); 104 | } 105 | if let Ok(erc20eth_addr) = ERC20ETH_ADDRESS.parse::
() { 106 | if token == erc20eth_addr { 107 | return Ok(vec![]); 108 | } 109 | } 110 | let token_contract = ERC20::new(token, client.clone()); 111 | let allowance = token_contract 112 | .allowance( 113 | from.parse::
().expect("Error encoding from address"), 114 | to.parse::
().expect("Error encoding from address"), 115 | ) 116 | .call() 117 | .await 118 | .expect("Failed to get allowance"); 119 | if allowance._0 < U256::MAX / U256::from(2) { 120 | Ok(vec![Token::Address(H160(token.0 .0))]) 121 | } else { 122 | Ok(vec![]) 123 | } 124 | } 125 | 126 | fn get_profit_eth(&self, RoutedOrder { request, route, .. }: &RoutedOrder) -> Option { 127 | let quote = U256::from_str_radix(&route.quote, 10).ok()?; 128 | let amount_required = 129 | U256::from_str_radix(&request.amount_required.to_string(), 10).ok()?; 130 | 131 | // exact_out: quote must be less than amount_in_required 132 | // exact_in: quote must be greater than amount_out_required 133 | if (request.orders.first().unwrap().order.is_exact_output() && quote.ge(&amount_required)) || 134 | (!request.orders.first().unwrap().order.is_exact_output() && quote.le(&amount_required)) { 135 | return None; 136 | } 137 | 138 | // exact_out: profit = amount_in_required - quote 139 | // exact_in: profit = quote - amount_out_required 140 | let profit_quote = if request.orders.first().unwrap().order.is_exact_output() { 141 | amount_required.saturating_sub(quote) 142 | } else { 143 | quote.saturating_sub(amount_required) 144 | }; 145 | 146 | if request.token_out.to_lowercase() == WETH_ADDRESS.to_lowercase() { 147 | return Some(profit_quote); 148 | } 149 | 150 | let gas_use_eth = U256::from_str_radix(&route.gas_use_estimate, 10) 151 | .ok()? 152 | .saturating_mul(U256::from_str_radix(&route.gas_price_wei, 10).ok()?); 153 | profit_quote 154 | .saturating_mul(gas_use_eth) 155 | .checked_div(U256::from_str_radix(&route.gas_use_estimate_quote, 10).ok()?) 156 | } 157 | 158 | /// Converts the quote amount to ETH equivalent value 159 | /// 160 | /// For WETH output tokens, returns the quote directly since it's already in ETH. 161 | /// For non-WETH output tokens, converts using the following formula: 162 | /// quote_eth = quote * gas_wei / gas_in_quote 163 | /// 164 | /// # Arguments 165 | /// * `request` - The order request containing token information 166 | /// * `route` - The route containing quote and gas estimates 167 | /// 168 | /// # Returns 169 | /// * `Some(U256)` - The quote value in ETH 170 | /// * `None` - If any conversion fails or division by zero would occur 171 | fn get_quote_eth(&self, RoutedOrder { request, route, .. }: &RoutedOrder) -> Option { 172 | let quote = U256::from_str_radix(&route.quote, 10).ok()?; 173 | 174 | // If output token is WETH, quote is already in ETH 175 | if request.token_out.to_lowercase() == WETH_ADDRESS.to_lowercase() { 176 | return Some(quote); 177 | } 178 | 179 | let gas_use_eth = U256::from_str_radix(&route.gas_use_estimate, 10) 180 | .ok()? 181 | .saturating_mul(U256::from_str_radix(&route.gas_price_wei, 10).ok()?); 182 | quote 183 | .saturating_mul(gas_use_eth) 184 | .checked_div(U256::from_str_radix(&route.gas_use_estimate_quote, 10).ok()?) 185 | } 186 | 187 | /// Get the minimum gas price on Arbitrum 188 | /// https://docs.arbitrum.io/build-decentralized-apps/precompiles/reference#arbgasinfo 189 | async fn get_arbitrum_min_gas_price( 190 | &self, 191 | client: Arc>, 192 | ) -> Result { 193 | let precompile_address = ARBITRUM_GAS_PRECOMPILE.parse::
()?; 194 | let gas_precompile = GasPrecompileContract::new(precompile_address, client.clone()); 195 | let gas_info = gas_precompile.getMinimumGasPrice().call().await?._0; 196 | 197 | Ok(gas_info) 198 | } 199 | } 200 | -------------------------------------------------------------------------------- /crates/bindings-uniswapx/src/reentrancyguard.rs: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | Generated by the following Solidity interface... 4 | ```solidity 5 | interface ReentrancyGuard {} 6 | ``` 7 | 8 | ...which was generated by the following JSON ABI: 9 | ```json 10 | [] 11 | ```*/ 12 | #[allow( 13 | non_camel_case_types, 14 | non_snake_case, 15 | clippy::pub_underscore_fields, 16 | clippy::style, 17 | clippy::empty_structs_with_brackets 18 | )] 19 | pub mod ReentrancyGuard { 20 | use super::*; 21 | use alloy::sol_types as alloy_sol_types; 22 | /// The creation / init bytecode of the contract. 23 | /// 24 | /// ```text 25 | ///0x 26 | /// ``` 27 | #[rustfmt::skip] 28 | #[allow(clippy::all)] 29 | pub static BYTECODE: alloy_sol_types::private::Bytes = alloy_sol_types::private::Bytes::from_static( 30 | b"", 31 | ); 32 | /// The runtime bytecode of the contract, as deployed on the network. 33 | /// 34 | /// ```text 35 | ///0x 36 | /// ``` 37 | #[rustfmt::skip] 38 | #[allow(clippy::all)] 39 | pub static DEPLOYED_BYTECODE: alloy_sol_types::private::Bytes = alloy_sol_types::private::Bytes::from_static( 40 | b"", 41 | ); 42 | use alloy::contract as alloy_contract; 43 | /**Creates a new wrapper around an on-chain [`ReentrancyGuard`](self) contract instance. 44 | 45 | See the [wrapper's documentation](`ReentrancyGuardInstance`) for more details.*/ 46 | #[inline] 47 | pub const fn new< 48 | T: alloy_contract::private::Transport + ::core::clone::Clone, 49 | P: alloy_contract::private::Provider, 50 | N: alloy_contract::private::Network, 51 | >( 52 | address: alloy_sol_types::private::Address, 53 | provider: P, 54 | ) -> ReentrancyGuardInstance { 55 | ReentrancyGuardInstance::::new(address, provider) 56 | } 57 | /**Deploys this contract using the given `provider` and constructor arguments, if any. 58 | 59 | Returns a new instance of the contract, if the deployment was successful. 60 | 61 | For more fine-grained control over the deployment process, use [`deploy_builder`] instead.*/ 62 | #[inline] 63 | pub fn deploy< 64 | T: alloy_contract::private::Transport + ::core::clone::Clone, 65 | P: alloy_contract::private::Provider, 66 | N: alloy_contract::private::Network, 67 | >( 68 | provider: P, 69 | ) -> impl ::core::future::Future< 70 | Output = alloy_contract::Result>, 71 | > { 72 | ReentrancyGuardInstance::::deploy(provider) 73 | } 74 | /**Creates a `RawCallBuilder` for deploying this contract using the given `provider` 75 | and constructor arguments, if any. 76 | 77 | This is a simple wrapper around creating a `RawCallBuilder` with the data set to 78 | the bytecode concatenated with the constructor's ABI-encoded arguments.*/ 79 | #[inline] 80 | pub fn deploy_builder< 81 | T: alloy_contract::private::Transport + ::core::clone::Clone, 82 | P: alloy_contract::private::Provider, 83 | N: alloy_contract::private::Network, 84 | >(provider: P) -> alloy_contract::RawCallBuilder { 85 | ReentrancyGuardInstance::::deploy_builder(provider) 86 | } 87 | /**A [`ReentrancyGuard`](self) instance. 88 | 89 | Contains type-safe methods for interacting with an on-chain instance of the 90 | [`ReentrancyGuard`](self) contract located at a given `address`, using a given 91 | provider `P`. 92 | 93 | If the contract bytecode is available (see the [`sol!`](alloy_sol_types::sol!) 94 | documentation on how to provide it), the `deploy` and `deploy_builder` methods can 95 | be used to deploy a new instance of the contract. 96 | 97 | See the [module-level documentation](self) for all the available methods.*/ 98 | #[derive(Clone)] 99 | pub struct ReentrancyGuardInstance { 100 | address: alloy_sol_types::private::Address, 101 | provider: P, 102 | _network_transport: ::core::marker::PhantomData<(N, T)>, 103 | } 104 | #[automatically_derived] 105 | impl ::core::fmt::Debug for ReentrancyGuardInstance { 106 | #[inline] 107 | fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { 108 | f.debug_tuple("ReentrancyGuardInstance").field(&self.address).finish() 109 | } 110 | } 111 | /// Instantiation and getters/setters. 112 | #[automatically_derived] 113 | impl< 114 | T: alloy_contract::private::Transport + ::core::clone::Clone, 115 | P: alloy_contract::private::Provider, 116 | N: alloy_contract::private::Network, 117 | > ReentrancyGuardInstance { 118 | /**Creates a new wrapper around an on-chain [`ReentrancyGuard`](self) contract instance. 119 | 120 | See the [wrapper's documentation](`ReentrancyGuardInstance`) for more details.*/ 121 | #[inline] 122 | pub const fn new( 123 | address: alloy_sol_types::private::Address, 124 | provider: P, 125 | ) -> Self { 126 | Self { 127 | address, 128 | provider, 129 | _network_transport: ::core::marker::PhantomData, 130 | } 131 | } 132 | /**Deploys this contract using the given `provider` and constructor arguments, if any. 133 | 134 | Returns a new instance of the contract, if the deployment was successful. 135 | 136 | For more fine-grained control over the deployment process, use [`deploy_builder`] instead.*/ 137 | #[inline] 138 | pub async fn deploy( 139 | provider: P, 140 | ) -> alloy_contract::Result> { 141 | let call_builder = Self::deploy_builder(provider); 142 | let contract_address = call_builder.deploy().await?; 143 | Ok(Self::new(contract_address, call_builder.provider)) 144 | } 145 | /**Creates a `RawCallBuilder` for deploying this contract using the given `provider` 146 | and constructor arguments, if any. 147 | 148 | This is a simple wrapper around creating a `RawCallBuilder` with the data set to 149 | the bytecode concatenated with the constructor's ABI-encoded arguments.*/ 150 | #[inline] 151 | pub fn deploy_builder(provider: P) -> alloy_contract::RawCallBuilder { 152 | alloy_contract::RawCallBuilder::new_raw_deploy( 153 | provider, 154 | ::core::clone::Clone::clone(&BYTECODE), 155 | ) 156 | } 157 | /// Returns a reference to the address. 158 | #[inline] 159 | pub const fn address(&self) -> &alloy_sol_types::private::Address { 160 | &self.address 161 | } 162 | /// Sets the address. 163 | #[inline] 164 | pub fn set_address(&mut self, address: alloy_sol_types::private::Address) { 165 | self.address = address; 166 | } 167 | /// Sets the address and returns `self`. 168 | pub fn at(mut self, address: alloy_sol_types::private::Address) -> Self { 169 | self.set_address(address); 170 | self 171 | } 172 | /// Returns a reference to the provider. 173 | #[inline] 174 | pub const fn provider(&self) -> &P { 175 | &self.provider 176 | } 177 | } 178 | impl ReentrancyGuardInstance { 179 | /// Clones the provider and returns a new instance with the cloned provider. 180 | #[inline] 181 | pub fn with_cloned_provider(self) -> ReentrancyGuardInstance { 182 | ReentrancyGuardInstance { 183 | address: self.address, 184 | provider: ::core::clone::Clone::clone(&self.provider), 185 | _network_transport: ::core::marker::PhantomData, 186 | } 187 | } 188 | } 189 | /// Function calls. 190 | #[automatically_derived] 191 | impl< 192 | T: alloy_contract::private::Transport + ::core::clone::Clone, 193 | P: alloy_contract::private::Provider, 194 | N: alloy_contract::private::Network, 195 | > ReentrancyGuardInstance { 196 | /// Creates a new call builder using this contract instance's provider and address. 197 | /// 198 | /// Note that the call can be any function call, not just those defined in this 199 | /// contract. Prefer using the other methods for building type-safe contract calls. 200 | pub fn call_builder( 201 | &self, 202 | call: &C, 203 | ) -> alloy_contract::SolCallBuilder { 204 | alloy_contract::SolCallBuilder::new_sol(&self.provider, &self.address, call) 205 | } 206 | } 207 | /// Event filters. 208 | #[automatically_derived] 209 | impl< 210 | T: alloy_contract::private::Transport + ::core::clone::Clone, 211 | P: alloy_contract::private::Provider, 212 | N: alloy_contract::private::Network, 213 | > ReentrancyGuardInstance { 214 | /// Creates a new event filter using this contract instance's provider and address. 215 | /// 216 | /// Note that the type can be any event, not just those defined in this contract. 217 | /// Prefer using the other methods for building type-safe event filters. 218 | pub fn event_filter( 219 | &self, 220 | ) -> alloy_contract::Event { 221 | alloy_contract::Event::new_sol(&self.provider, &self.address) 222 | } 223 | } 224 | } 225 | -------------------------------------------------------------------------------- /src/strategies/keystore.rs: -------------------------------------------------------------------------------- 1 | use rand::seq::IteratorRandom; 2 | use rand::seq::SliceRandom; 3 | use std::collections::HashMap; 4 | use std::sync::Arc; 5 | use std::sync::atomic::{AtomicUsize, Ordering}; 6 | use tokio::sync::{Mutex, Notify}; 7 | use tracing::info; 8 | 9 | use std::fmt; 10 | 11 | #[derive(Debug, PartialEq)] 12 | pub enum KeyStoreError { 13 | KeyNotFound, 14 | LockError, 15 | } 16 | 17 | impl fmt::Display for KeyStoreError { 18 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { 19 | match self { 20 | KeyStoreError::KeyNotFound => write!(f, "Key not found"), 21 | KeyStoreError::LockError => write!(f, "Failed to acquire lock"), 22 | } 23 | } 24 | } 25 | 26 | impl std::error::Error for KeyStoreError {} 27 | 28 | // Private key type to prevent accidental exposure of private keys 29 | // Does not implement Debug 30 | pub struct PrivateKey(String); 31 | impl PrivateKey { 32 | pub fn new(key: String) -> Self { 33 | PrivateKey(key) 34 | } 35 | pub fn as_str(&self) -> &str { 36 | &self.0 37 | } 38 | } 39 | impl Clone for PrivateKey { 40 | fn clone(&self) -> Self { 41 | PrivateKey(self.0.clone()) 42 | } 43 | } 44 | impl PartialEq for PrivateKey { 45 | fn eq(&self, other: &Self) -> bool { 46 | self.0 == other.0 47 | } 48 | } 49 | 50 | #[derive(Clone)] 51 | pub struct KeyStore { 52 | keys: HashMap>>, 53 | notify: Arc, 54 | keys_in_use_count: Arc, // Track in-use count efficiently 55 | } 56 | 57 | impl KeyStore { 58 | pub fn new() -> Self { 59 | KeyStore { 60 | keys: HashMap::new(), 61 | notify: Arc::new(Notify::new()), 62 | keys_in_use_count: Arc::new(AtomicUsize::new(0)), 63 | } 64 | } 65 | 66 | pub async fn add_key(&mut self, public_address: String, private_key: String) { 67 | self.keys.insert( 68 | public_address, 69 | Arc::new(Mutex::new((PrivateKey::new(private_key), false))), 70 | ); 71 | } 72 | 73 | // Gets the first key address in the store 74 | pub fn get_address(&self) -> Option { 75 | if self.keys.len() == 0 { 76 | return None; 77 | } 78 | let mut rng = rand::thread_rng(); 79 | self.keys.keys().choose(&mut rng).cloned() 80 | } 81 | 82 | pub async fn acquire_key(&self) -> Result<(String, PrivateKey), KeyStoreError> { 83 | loop { 84 | // Create a randomized list of keys to check 85 | let mut shuffled_keys: Vec<_> = self.keys.iter().collect(); 86 | shuffled_keys.shuffle(&mut rand::thread_rng()); 87 | 88 | for (public_address, key_mutex) in shuffled_keys { 89 | if let Ok(mut key_data) = key_mutex.try_lock() { 90 | let (private_key, in_use) = &mut *key_data; 91 | if !*in_use { 92 | *in_use = true; 93 | self.keys_in_use_count.fetch_add(1, Ordering::Relaxed); 94 | return Ok((public_address.clone(), private_key.clone())); 95 | } 96 | } 97 | } 98 | info!("No keys available, waiting for notification"); 99 | self.notify.notified().await; 100 | } 101 | } 102 | 103 | pub async fn release_key(&self, public_address: String) -> Result<(), KeyStoreError> { 104 | if let Some(key_mutex) = self.keys.get(&public_address) { 105 | let mut key_data = key_mutex.lock().await; 106 | let (_, in_use) = &mut *key_data; 107 | if *in_use { // Only decrement if it was actually in use 108 | *in_use = false; 109 | self.keys_in_use_count.fetch_sub(1, Ordering::Relaxed); 110 | } 111 | self.notify.notify_one(); 112 | Ok(()) 113 | } else { 114 | Err(KeyStoreError::KeyNotFound) 115 | } 116 | } 117 | 118 | pub fn len(&self) -> usize { 119 | self.keys.len() 120 | } 121 | 122 | pub fn is_empty(&self) -> bool { 123 | self.keys.is_empty() 124 | } 125 | 126 | /// Get the number of keys currently in use (O(1) operation) 127 | pub fn get_keys_in_use(&self) -> usize { 128 | self.keys_in_use_count.load(Ordering::Relaxed) 129 | } 130 | 131 | /// Get the number of keys available (O(1) operation) 132 | pub fn get_keys_available(&self) -> usize { 133 | self.len() - self.get_keys_in_use() 134 | } 135 | } 136 | 137 | #[cfg(test)] 138 | mod tests { 139 | use super::*; 140 | use tokio::time::{timeout, Duration}; 141 | 142 | #[tokio::test] 143 | async fn test_acquire_key() { 144 | let mut keystore = KeyStore::new(); 145 | keystore 146 | .add_key("address1".to_string(), "private_key".to_string()) 147 | .await; 148 | keystore 149 | .add_key("address2".to_string(), "private_key".to_string()) 150 | .await; 151 | 152 | // Test for valid key retrieval 153 | let (public_key, private_key) = keystore.acquire_key().await.unwrap(); 154 | assert_eq!(private_key.as_str(), "private_key"); 155 | 156 | // Test that the key is marked as in-use 157 | let key_data = keystore.keys.get(&public_key).unwrap().lock().await; 158 | assert!(key_data.1); 159 | drop(key_data); 160 | 161 | // Test for valid key retrieval of the second key 162 | let (public_key2, private_key2) = keystore.acquire_key().await.unwrap(); 163 | assert_eq!(private_key2.as_str(), "private_key"); 164 | assert_ne!(public_key, public_key2); 165 | 166 | // Test that the second key is marked as in-use 167 | let key_data2 = keystore.keys.get(&public_key2).unwrap().lock().await; 168 | assert!(key_data2.1); 169 | drop(key_data2); 170 | } 171 | 172 | #[tokio::test] 173 | async fn test_len() { 174 | let mut keystore = KeyStore::new(); 175 | keystore 176 | .add_key("address1".to_string(), "private_key1".to_string()) 177 | .await; 178 | keystore 179 | .add_key("address2".to_string(), "private_key2".to_string()) 180 | .await; 181 | 182 | // Test for correct length 183 | assert_eq!(keystore.len(), 2); 184 | } 185 | 186 | #[tokio::test] 187 | async fn test_release_nonexistent_key() { 188 | let keystore = KeyStore::new(); 189 | 190 | // Attempt to release a key that is not in the store 191 | let result = keystore 192 | .release_key("nonexistent_address".to_string()) 193 | .await; 194 | assert!(result.is_err()); 195 | assert_eq!(result.unwrap_err(), KeyStoreError::KeyNotFound); 196 | } 197 | 198 | #[tokio::test] 199 | async fn test_notify_on_key_release() { 200 | let mut keystore = KeyStore::new(); 201 | keystore 202 | .add_key("address1".to_string(), "private_key1".to_string()) 203 | .await; 204 | keystore 205 | .add_key("address2".to_string(), "private_key2".to_string()) 206 | .await; 207 | 208 | // Acquire both keys 209 | let (addr1, _) = keystore.acquire_key().await.unwrap(); 210 | let (addr2, _) = keystore.acquire_key().await.unwrap(); 211 | 212 | // Attempt to acquire a key (should wait) 213 | let acquire_future = tokio::spawn({ 214 | let keystore = keystore.clone(); 215 | async move { keystore.acquire_key().await } 216 | }); 217 | 218 | // Wait a bit to ensure the acquire_future is waiting 219 | tokio::time::sleep(Duration::from_millis(100)).await; 220 | 221 | // Release one key 222 | keystore.release_key(addr1.clone()).await.unwrap(); 223 | 224 | // The acquire_future should now complete 225 | let acquire_result = timeout(Duration::from_secs(1), acquire_future).await; 226 | assert!(acquire_result.is_ok(), "Acquire operation timed out"); 227 | 228 | let (acquired_addr, _) = acquire_result.unwrap().unwrap().unwrap(); 229 | assert_eq!( 230 | acquired_addr, addr1, 231 | "Acquired address should match released address" 232 | ); 233 | 234 | // Clean up 235 | keystore.release_key(addr2).await.unwrap(); 236 | keystore.release_key(acquired_addr).await.unwrap(); 237 | } 238 | 239 | #[tokio::test] 240 | async fn test_get_address_randomness() { 241 | let mut keystore = KeyStore::new(); 242 | keystore 243 | .add_key("address1".to_string(), "private_key1".to_string()) 244 | .await; 245 | keystore 246 | .add_key("address2".to_string(), "private_key2".to_string()) 247 | .await; 248 | keystore 249 | .add_key("address3".to_string(), "private_key3".to_string()) 250 | .await; 251 | 252 | let mut counts = HashMap::new(); 253 | let iterations = 1000000; 254 | 255 | for _ in 0..iterations { 256 | if let Some(address) = keystore.get_address() { 257 | *counts.entry(address).or_insert(0) += 1; 258 | } 259 | } 260 | 261 | // Check that each address was selected roughly equally 262 | for count in counts.values() { 263 | let proportion = *count as f64 / iterations as f64; 264 | assert!( 265 | (0.32..0.34).contains(&proportion), 266 | "Proportion out of expected range" 267 | ); 268 | } 269 | } 270 | } 271 | -------------------------------------------------------------------------------- /crates/bindings-uniswapx/src/path.rs: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | Generated by the following Solidity interface... 4 | ```solidity 5 | interface Path {} 6 | ``` 7 | 8 | ...which was generated by the following JSON ABI: 9 | ```json 10 | [] 11 | ```*/ 12 | #[allow( 13 | non_camel_case_types, 14 | non_snake_case, 15 | clippy::pub_underscore_fields, 16 | clippy::style, 17 | clippy::empty_structs_with_brackets 18 | )] 19 | pub mod Path { 20 | use super::*; 21 | use alloy::sol_types as alloy_sol_types; 22 | /// The creation / init bytecode of the contract. 23 | /// 24 | /// ```text 25 | ///0x60556032600b8282823980515f1a607314602657634e487b7160e01b5f525f60045260245ffd5b305f52607381538281f3fe730000000000000000000000000000000000000000301460806040525f80fdfea26469706673582212207dbb50d1d3d7660c3062ab325249f1b623b2538a69abfdbcdcdb8c71490d2abb64736f6c63430008180033 26 | /// ``` 27 | #[rustfmt::skip] 28 | #[allow(clippy::all)] 29 | pub static BYTECODE: alloy_sol_types::private::Bytes = alloy_sol_types::private::Bytes::from_static( 30 | b"`U`2`\x0B\x82\x82\x829\x80Q_\x1A`s\x14`&WcNH{q`\xE0\x1B_R_`\x04R`$_\xFD[0_R`s\x81S\x82\x81\xF3\xFEs\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x000\x14`\x80`@R_\x80\xFD\xFE\xA2dipfsX\"\x12 }\xBBP\xD1\xD3\xD7f\x0C0b\xAB2RI\xF1\xB6#\xB2S\x8Ai\xAB\xFD\xBC\xDC\xDB\x8CqI\r*\xBBdsolcC\0\x08\x18\x003", 31 | ); 32 | /// The runtime bytecode of the contract, as deployed on the network. 33 | /// 34 | /// ```text 35 | ///0x730000000000000000000000000000000000000000301460806040525f80fdfea26469706673582212207dbb50d1d3d7660c3062ab325249f1b623b2538a69abfdbcdcdb8c71490d2abb64736f6c63430008180033 36 | /// ``` 37 | #[rustfmt::skip] 38 | #[allow(clippy::all)] 39 | pub static DEPLOYED_BYTECODE: alloy_sol_types::private::Bytes = alloy_sol_types::private::Bytes::from_static( 40 | b"s\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x000\x14`\x80`@R_\x80\xFD\xFE\xA2dipfsX\"\x12 }\xBBP\xD1\xD3\xD7f\x0C0b\xAB2RI\xF1\xB6#\xB2S\x8Ai\xAB\xFD\xBC\xDC\xDB\x8CqI\r*\xBBdsolcC\0\x08\x18\x003", 41 | ); 42 | use alloy::contract as alloy_contract; 43 | /**Creates a new wrapper around an on-chain [`Path`](self) contract instance. 44 | 45 | See the [wrapper's documentation](`PathInstance`) for more details.*/ 46 | #[inline] 47 | pub const fn new< 48 | T: alloy_contract::private::Transport + ::core::clone::Clone, 49 | P: alloy_contract::private::Provider, 50 | N: alloy_contract::private::Network, 51 | >(address: alloy_sol_types::private::Address, provider: P) -> PathInstance { 52 | PathInstance::::new(address, provider) 53 | } 54 | /**Deploys this contract using the given `provider` and constructor arguments, if any. 55 | 56 | Returns a new instance of the contract, if the deployment was successful. 57 | 58 | For more fine-grained control over the deployment process, use [`deploy_builder`] instead.*/ 59 | #[inline] 60 | pub fn deploy< 61 | T: alloy_contract::private::Transport + ::core::clone::Clone, 62 | P: alloy_contract::private::Provider, 63 | N: alloy_contract::private::Network, 64 | >( 65 | provider: P, 66 | ) -> impl ::core::future::Future< 67 | Output = alloy_contract::Result>, 68 | > { 69 | PathInstance::::deploy(provider) 70 | } 71 | /**Creates a `RawCallBuilder` for deploying this contract using the given `provider` 72 | and constructor arguments, if any. 73 | 74 | This is a simple wrapper around creating a `RawCallBuilder` with the data set to 75 | the bytecode concatenated with the constructor's ABI-encoded arguments.*/ 76 | #[inline] 77 | pub fn deploy_builder< 78 | T: alloy_contract::private::Transport + ::core::clone::Clone, 79 | P: alloy_contract::private::Provider, 80 | N: alloy_contract::private::Network, 81 | >(provider: P) -> alloy_contract::RawCallBuilder { 82 | PathInstance::::deploy_builder(provider) 83 | } 84 | /**A [`Path`](self) instance. 85 | 86 | Contains type-safe methods for interacting with an on-chain instance of the 87 | [`Path`](self) contract located at a given `address`, using a given 88 | provider `P`. 89 | 90 | If the contract bytecode is available (see the [`sol!`](alloy_sol_types::sol!) 91 | documentation on how to provide it), the `deploy` and `deploy_builder` methods can 92 | be used to deploy a new instance of the contract. 93 | 94 | See the [module-level documentation](self) for all the available methods.*/ 95 | #[derive(Clone)] 96 | pub struct PathInstance { 97 | address: alloy_sol_types::private::Address, 98 | provider: P, 99 | _network_transport: ::core::marker::PhantomData<(N, T)>, 100 | } 101 | #[automatically_derived] 102 | impl ::core::fmt::Debug for PathInstance { 103 | #[inline] 104 | fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { 105 | f.debug_tuple("PathInstance").field(&self.address).finish() 106 | } 107 | } 108 | /// Instantiation and getters/setters. 109 | #[automatically_derived] 110 | impl< 111 | T: alloy_contract::private::Transport + ::core::clone::Clone, 112 | P: alloy_contract::private::Provider, 113 | N: alloy_contract::private::Network, 114 | > PathInstance { 115 | /**Creates a new wrapper around an on-chain [`Path`](self) contract instance. 116 | 117 | See the [wrapper's documentation](`PathInstance`) for more details.*/ 118 | #[inline] 119 | pub const fn new( 120 | address: alloy_sol_types::private::Address, 121 | provider: P, 122 | ) -> Self { 123 | Self { 124 | address, 125 | provider, 126 | _network_transport: ::core::marker::PhantomData, 127 | } 128 | } 129 | /**Deploys this contract using the given `provider` and constructor arguments, if any. 130 | 131 | Returns a new instance of the contract, if the deployment was successful. 132 | 133 | For more fine-grained control over the deployment process, use [`deploy_builder`] instead.*/ 134 | #[inline] 135 | pub async fn deploy( 136 | provider: P, 137 | ) -> alloy_contract::Result> { 138 | let call_builder = Self::deploy_builder(provider); 139 | let contract_address = call_builder.deploy().await?; 140 | Ok(Self::new(contract_address, call_builder.provider)) 141 | } 142 | /**Creates a `RawCallBuilder` for deploying this contract using the given `provider` 143 | and constructor arguments, if any. 144 | 145 | This is a simple wrapper around creating a `RawCallBuilder` with the data set to 146 | the bytecode concatenated with the constructor's ABI-encoded arguments.*/ 147 | #[inline] 148 | pub fn deploy_builder(provider: P) -> alloy_contract::RawCallBuilder { 149 | alloy_contract::RawCallBuilder::new_raw_deploy( 150 | provider, 151 | ::core::clone::Clone::clone(&BYTECODE), 152 | ) 153 | } 154 | /// Returns a reference to the address. 155 | #[inline] 156 | pub const fn address(&self) -> &alloy_sol_types::private::Address { 157 | &self.address 158 | } 159 | /// Sets the address. 160 | #[inline] 161 | pub fn set_address(&mut self, address: alloy_sol_types::private::Address) { 162 | self.address = address; 163 | } 164 | /// Sets the address and returns `self`. 165 | pub fn at(mut self, address: alloy_sol_types::private::Address) -> Self { 166 | self.set_address(address); 167 | self 168 | } 169 | /// Returns a reference to the provider. 170 | #[inline] 171 | pub const fn provider(&self) -> &P { 172 | &self.provider 173 | } 174 | } 175 | impl PathInstance { 176 | /// Clones the provider and returns a new instance with the cloned provider. 177 | #[inline] 178 | pub fn with_cloned_provider(self) -> PathInstance { 179 | PathInstance { 180 | address: self.address, 181 | provider: ::core::clone::Clone::clone(&self.provider), 182 | _network_transport: ::core::marker::PhantomData, 183 | } 184 | } 185 | } 186 | /// Function calls. 187 | #[automatically_derived] 188 | impl< 189 | T: alloy_contract::private::Transport + ::core::clone::Clone, 190 | P: alloy_contract::private::Provider, 191 | N: alloy_contract::private::Network, 192 | > PathInstance { 193 | /// Creates a new call builder using this contract instance's provider and address. 194 | /// 195 | /// Note that the call can be any function call, not just those defined in this 196 | /// contract. Prefer using the other methods for building type-safe contract calls. 197 | pub fn call_builder( 198 | &self, 199 | call: &C, 200 | ) -> alloy_contract::SolCallBuilder { 201 | alloy_contract::SolCallBuilder::new_sol(&self.provider, &self.address, call) 202 | } 203 | } 204 | /// Event filters. 205 | #[automatically_derived] 206 | impl< 207 | T: alloy_contract::private::Transport + ::core::clone::Clone, 208 | P: alloy_contract::private::Provider, 209 | N: alloy_contract::private::Network, 210 | > PathInstance { 211 | /// Creates a new event filter using this contract instance's provider and address. 212 | /// 213 | /// Note that the type can be any event, not just those defined in this contract. 214 | /// Prefer using the other methods for building type-safe event filters. 215 | pub fn event_filter( 216 | &self, 217 | ) -> alloy_contract::Event { 218 | alloy_contract::Event::new_sol(&self.provider, &self.address) 219 | } 220 | } 221 | } 222 | -------------------------------------------------------------------------------- /crates/bindings-uniswapx/src/math.rs: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | Generated by the following Solidity interface... 4 | ```solidity 5 | interface Math {} 6 | ``` 7 | 8 | ...which was generated by the following JSON ABI: 9 | ```json 10 | [] 11 | ```*/ 12 | #[allow( 13 | non_camel_case_types, 14 | non_snake_case, 15 | clippy::pub_underscore_fields, 16 | clippy::style, 17 | clippy::empty_structs_with_brackets 18 | )] 19 | pub mod Math { 20 | use super::*; 21 | use alloy::sol_types as alloy_sol_types; 22 | /// The creation / init bytecode of the contract. 23 | /// 24 | /// ```text 25 | ///0x60556032600b8282823980515f1a607314602657634e487b7160e01b5f525f60045260245ffd5b305f52607381538281f3fe730000000000000000000000000000000000000000301460806040525f80fdfea2646970667358221220945881513b2cb4aacab13a7d2b471a8242b2ba43aca96c910ebd8d79fd3bc77664736f6c63430008180033 26 | /// ``` 27 | #[rustfmt::skip] 28 | #[allow(clippy::all)] 29 | pub static BYTECODE: alloy_sol_types::private::Bytes = alloy_sol_types::private::Bytes::from_static( 30 | b"`U`2`\x0B\x82\x82\x829\x80Q_\x1A`s\x14`&WcNH{q`\xE0\x1B_R_`\x04R`$_\xFD[0_R`s\x81S\x82\x81\xF3\xFEs\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x000\x14`\x80`@R_\x80\xFD\xFE\xA2dipfsX\"\x12 \x94X\x81Q;,\xB4\xAA\xCA\xB1:}+G\x1A\x82B\xB2\xBAC\xAC\xA9l\x91\x0E\xBD\x8Dy\xFD;\xC7vdsolcC\0\x08\x18\x003", 31 | ); 32 | /// The runtime bytecode of the contract, as deployed on the network. 33 | /// 34 | /// ```text 35 | ///0x730000000000000000000000000000000000000000301460806040525f80fdfea2646970667358221220945881513b2cb4aacab13a7d2b471a8242b2ba43aca96c910ebd8d79fd3bc77664736f6c63430008180033 36 | /// ``` 37 | #[rustfmt::skip] 38 | #[allow(clippy::all)] 39 | pub static DEPLOYED_BYTECODE: alloy_sol_types::private::Bytes = alloy_sol_types::private::Bytes::from_static( 40 | b"s\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x000\x14`\x80`@R_\x80\xFD\xFE\xA2dipfsX\"\x12 \x94X\x81Q;,\xB4\xAA\xCA\xB1:}+G\x1A\x82B\xB2\xBAC\xAC\xA9l\x91\x0E\xBD\x8Dy\xFD;\xC7vdsolcC\0\x08\x18\x003", 41 | ); 42 | use alloy::contract as alloy_contract; 43 | /**Creates a new wrapper around an on-chain [`Math`](self) contract instance. 44 | 45 | See the [wrapper's documentation](`MathInstance`) for more details.*/ 46 | #[inline] 47 | pub const fn new< 48 | T: alloy_contract::private::Transport + ::core::clone::Clone, 49 | P: alloy_contract::private::Provider, 50 | N: alloy_contract::private::Network, 51 | >(address: alloy_sol_types::private::Address, provider: P) -> MathInstance { 52 | MathInstance::::new(address, provider) 53 | } 54 | /**Deploys this contract using the given `provider` and constructor arguments, if any. 55 | 56 | Returns a new instance of the contract, if the deployment was successful. 57 | 58 | For more fine-grained control over the deployment process, use [`deploy_builder`] instead.*/ 59 | #[inline] 60 | pub fn deploy< 61 | T: alloy_contract::private::Transport + ::core::clone::Clone, 62 | P: alloy_contract::private::Provider, 63 | N: alloy_contract::private::Network, 64 | >( 65 | provider: P, 66 | ) -> impl ::core::future::Future< 67 | Output = alloy_contract::Result>, 68 | > { 69 | MathInstance::::deploy(provider) 70 | } 71 | /**Creates a `RawCallBuilder` for deploying this contract using the given `provider` 72 | and constructor arguments, if any. 73 | 74 | This is a simple wrapper around creating a `RawCallBuilder` with the data set to 75 | the bytecode concatenated with the constructor's ABI-encoded arguments.*/ 76 | #[inline] 77 | pub fn deploy_builder< 78 | T: alloy_contract::private::Transport + ::core::clone::Clone, 79 | P: alloy_contract::private::Provider, 80 | N: alloy_contract::private::Network, 81 | >(provider: P) -> alloy_contract::RawCallBuilder { 82 | MathInstance::::deploy_builder(provider) 83 | } 84 | /**A [`Math`](self) instance. 85 | 86 | Contains type-safe methods for interacting with an on-chain instance of the 87 | [`Math`](self) contract located at a given `address`, using a given 88 | provider `P`. 89 | 90 | If the contract bytecode is available (see the [`sol!`](alloy_sol_types::sol!) 91 | documentation on how to provide it), the `deploy` and `deploy_builder` methods can 92 | be used to deploy a new instance of the contract. 93 | 94 | See the [module-level documentation](self) for all the available methods.*/ 95 | #[derive(Clone)] 96 | pub struct MathInstance { 97 | address: alloy_sol_types::private::Address, 98 | provider: P, 99 | _network_transport: ::core::marker::PhantomData<(N, T)>, 100 | } 101 | #[automatically_derived] 102 | impl ::core::fmt::Debug for MathInstance { 103 | #[inline] 104 | fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { 105 | f.debug_tuple("MathInstance").field(&self.address).finish() 106 | } 107 | } 108 | /// Instantiation and getters/setters. 109 | #[automatically_derived] 110 | impl< 111 | T: alloy_contract::private::Transport + ::core::clone::Clone, 112 | P: alloy_contract::private::Provider, 113 | N: alloy_contract::private::Network, 114 | > MathInstance { 115 | /**Creates a new wrapper around an on-chain [`Math`](self) contract instance. 116 | 117 | See the [wrapper's documentation](`MathInstance`) for more details.*/ 118 | #[inline] 119 | pub const fn new( 120 | address: alloy_sol_types::private::Address, 121 | provider: P, 122 | ) -> Self { 123 | Self { 124 | address, 125 | provider, 126 | _network_transport: ::core::marker::PhantomData, 127 | } 128 | } 129 | /**Deploys this contract using the given `provider` and constructor arguments, if any. 130 | 131 | Returns a new instance of the contract, if the deployment was successful. 132 | 133 | For more fine-grained control over the deployment process, use [`deploy_builder`] instead.*/ 134 | #[inline] 135 | pub async fn deploy( 136 | provider: P, 137 | ) -> alloy_contract::Result> { 138 | let call_builder = Self::deploy_builder(provider); 139 | let contract_address = call_builder.deploy().await?; 140 | Ok(Self::new(contract_address, call_builder.provider)) 141 | } 142 | /**Creates a `RawCallBuilder` for deploying this contract using the given `provider` 143 | and constructor arguments, if any. 144 | 145 | This is a simple wrapper around creating a `RawCallBuilder` with the data set to 146 | the bytecode concatenated with the constructor's ABI-encoded arguments.*/ 147 | #[inline] 148 | pub fn deploy_builder(provider: P) -> alloy_contract::RawCallBuilder { 149 | alloy_contract::RawCallBuilder::new_raw_deploy( 150 | provider, 151 | ::core::clone::Clone::clone(&BYTECODE), 152 | ) 153 | } 154 | /// Returns a reference to the address. 155 | #[inline] 156 | pub const fn address(&self) -> &alloy_sol_types::private::Address { 157 | &self.address 158 | } 159 | /// Sets the address. 160 | #[inline] 161 | pub fn set_address(&mut self, address: alloy_sol_types::private::Address) { 162 | self.address = address; 163 | } 164 | /// Sets the address and returns `self`. 165 | pub fn at(mut self, address: alloy_sol_types::private::Address) -> Self { 166 | self.set_address(address); 167 | self 168 | } 169 | /// Returns a reference to the provider. 170 | #[inline] 171 | pub const fn provider(&self) -> &P { 172 | &self.provider 173 | } 174 | } 175 | impl MathInstance { 176 | /// Clones the provider and returns a new instance with the cloned provider. 177 | #[inline] 178 | pub fn with_cloned_provider(self) -> MathInstance { 179 | MathInstance { 180 | address: self.address, 181 | provider: ::core::clone::Clone::clone(&self.provider), 182 | _network_transport: ::core::marker::PhantomData, 183 | } 184 | } 185 | } 186 | /// Function calls. 187 | #[automatically_derived] 188 | impl< 189 | T: alloy_contract::private::Transport + ::core::clone::Clone, 190 | P: alloy_contract::private::Provider, 191 | N: alloy_contract::private::Network, 192 | > MathInstance { 193 | /// Creates a new call builder using this contract instance's provider and address. 194 | /// 195 | /// Note that the call can be any function call, not just those defined in this 196 | /// contract. Prefer using the other methods for building type-safe contract calls. 197 | pub fn call_builder( 198 | &self, 199 | call: &C, 200 | ) -> alloy_contract::SolCallBuilder { 201 | alloy_contract::SolCallBuilder::new_sol(&self.provider, &self.address, call) 202 | } 203 | } 204 | /// Event filters. 205 | #[automatically_derived] 206 | impl< 207 | T: alloy_contract::private::Transport + ::core::clone::Clone, 208 | P: alloy_contract::private::Provider, 209 | N: alloy_contract::private::Network, 210 | > MathInstance { 211 | /// Creates a new event filter using this contract instance's provider and address. 212 | /// 213 | /// Note that the type can be any event, not just those defined in this contract. 214 | /// Prefer using the other methods for building type-safe event filters. 215 | pub fn event_filter( 216 | &self, 217 | ) -> alloy_contract::Event { 218 | alloy_contract::Event::new_sol(&self.provider, &self.address) 219 | } 220 | } 221 | } 222 | -------------------------------------------------------------------------------- /src/aws_utils/cloudwatch_utils.rs: -------------------------------------------------------------------------------- 1 | use std::{future::Future, pin::Pin, sync::Arc}; 2 | 3 | use aws_sdk_cloudwatch::Client as CloudWatchClient; 4 | use aws_sdk_cloudwatch::{ 5 | config::http::HttpResponse, 6 | error::SdkError, 7 | operation::put_metric_data::{PutMetricDataError, PutMetricDataOutput}, 8 | types::Dimension, 9 | }; 10 | 11 | /// Constants for dimension names and values 12 | pub const SERVICE_DIMENSION: &str = "Service"; 13 | pub const ROUTER02: &str = "Router02"; 14 | pub const PRIORITY_EXECUTOR: &str = "PriorityExecutor"; 15 | pub const V2_EXECUTOR: &str = "V2Executor"; 16 | pub const V3_EXECUTOR: &str = "V3Executor"; 17 | pub const ORDER_COLLECTOR: &str = "OrderCollector"; 18 | 19 | /// Constants for metric names 20 | pub const ROUTING_MS: &str = "RoutingMs"; 21 | pub const TX_SUCCEEDED_METRIC: &str = "TransactionSucceeded"; 22 | pub const TX_REVERTED_METRIC: &str = "TransactionReverted"; 23 | pub const TX_SUBMITTED_METRIC: &str = "TransactionSubmitted"; 24 | pub const ORDER_RECEIVED_METRIC: &str = "OrderReceived"; 25 | pub const ORDER_BID_METRIC: &str = "OrderBid"; 26 | pub const ORDER_FILLED_METRIC: &str = "OrderFilled"; 27 | pub const TX_STATUS_UNKNOWN_METRIC: &str = "TransactionStatusUnknown"; 28 | pub const LATEST_BLOCK: &str = "LatestBlock"; 29 | pub const EXECUTION_ATTEMPTED_METRIC: &str = "ExecutionAttempted"; 30 | pub const EXECUTION_SKIPPED_ALREADY_FILLED_METRIC: &str = "ExecutionSkippedAlreadyFilled"; 31 | pub const EXECUTION_SKIPPED_PAST_DEADLINE_METRIC: &str = "ExecutionSkippedPastDeadline"; 32 | pub const UNPROFITABLE_METRIC: &str = "Unprofitable"; 33 | pub const TARGET_BLOCK_DELTA: &str = "TargetBlockDelta"; 34 | pub const REVERT_CODE_METRIC: &str = "RevertCode"; 35 | pub const KEYS_IN_USE: &str = "KeysInUse"; 36 | pub const KEYS_AVAILABLE: &str = "KeysAvailable"; 37 | pub const ORDER_STALENESS_SEC: &str = "OrderStalenessSec"; 38 | 39 | pub enum DimensionName { 40 | Service, 41 | } 42 | 43 | impl AsRef for DimensionName { 44 | fn as_ref(&self) -> &str { 45 | match self { 46 | DimensionName::Service => SERVICE_DIMENSION, 47 | } 48 | } 49 | } 50 | 51 | impl From for String { 52 | fn from(dimension: DimensionName) -> Self { 53 | match dimension { 54 | DimensionName::Service => SERVICE_DIMENSION.to_string(), 55 | } 56 | } 57 | } 58 | 59 | pub enum DimensionValue { 60 | PriorityExecutor, 61 | V2Executor, 62 | V3Executor, 63 | Router02, 64 | OrderCollector, 65 | } 66 | impl From for String { 67 | fn from(value: DimensionValue) -> Self { 68 | match value { 69 | DimensionValue::PriorityExecutor => PRIORITY_EXECUTOR.to_string(), 70 | DimensionValue::V2Executor => V2_EXECUTOR.to_string(), 71 | DimensionValue::V3Executor => V3_EXECUTOR.to_string(), 72 | DimensionValue::Router02 => ROUTER02.to_string(), 73 | DimensionValue::OrderCollector => ORDER_COLLECTOR.to_string(), 74 | } 75 | } 76 | } 77 | 78 | impl AsRef for DimensionValue { 79 | fn as_ref(&self) -> &str { 80 | match self { 81 | DimensionValue::PriorityExecutor => PRIORITY_EXECUTOR, 82 | DimensionValue::V2Executor => V2_EXECUTOR, 83 | DimensionValue::V3Executor => V3_EXECUTOR, 84 | DimensionValue::Router02 => ROUTER02, 85 | DimensionValue::OrderCollector => ORDER_COLLECTOR, 86 | } 87 | } 88 | } 89 | 90 | pub enum CwMetrics { 91 | RoutingMs(u64), 92 | Unprofitable(u64), 93 | ExecutionAttempted(u64), 94 | ExecutionSkippedAlreadyFilled(u64), 95 | ExecutionSkippedPastDeadline(u64), 96 | TxSucceeded(u64), 97 | TxReverted(u64), 98 | TxSubmitted(u64), 99 | OrderReceived(u64), 100 | OrderBid(u64), 101 | OrderFilled(u64), 102 | TxStatusUnknown(u64), 103 | LatestBlock(u64), 104 | RevertCode(u64, String), // chain_id and revert code string 105 | 106 | /// Balance for individual address 107 | Balance(String), 108 | // negative is too early, positive is too late 109 | TargetBlockDelta(u64), 110 | 111 | /// Keystore metrics 112 | KeysInUse(u64), // chain_id 113 | KeysAvailable(u64), // chain_id 114 | 115 | /// Order staleness metric (time delta between current time and createdAt) 116 | OrderStalenessSec(u64), // chain_id 117 | } 118 | impl From for String { 119 | fn from(metric: CwMetrics) -> Self { 120 | match metric { 121 | CwMetrics::RoutingMs(chain_id) => format!("{}-{}", chain_id, ROUTING_MS), 122 | CwMetrics::Unprofitable(chain_id) => format!("{}-{}", chain_id, UNPROFITABLE_METRIC), 123 | CwMetrics::ExecutionAttempted(chain_id) => { 124 | format!("{}-{}", chain_id, EXECUTION_ATTEMPTED_METRIC) 125 | } 126 | CwMetrics::ExecutionSkippedAlreadyFilled(chain_id) => { 127 | format!("{}-{}", chain_id, EXECUTION_SKIPPED_ALREADY_FILLED_METRIC) 128 | } 129 | CwMetrics::ExecutionSkippedPastDeadline(chain_id) => { 130 | format!("{}-{}", chain_id, EXECUTION_SKIPPED_PAST_DEADLINE_METRIC) 131 | } 132 | CwMetrics::TxSucceeded(chain_id) => format!("{}-{}", chain_id, TX_SUCCEEDED_METRIC), 133 | CwMetrics::TxReverted(chain_id) => format!("{}-{}", chain_id, TX_REVERTED_METRIC), 134 | CwMetrics::TxSubmitted(chain_id) => format!("{}-{}", chain_id, TX_SUBMITTED_METRIC), 135 | CwMetrics::OrderReceived(chain_id) => format!("{}-{}", chain_id, ORDER_RECEIVED_METRIC), 136 | CwMetrics::OrderBid(chain_id) => format!("{}-{}", chain_id, ORDER_BID_METRIC), 137 | CwMetrics::OrderFilled(chain_id) => format!("{}-{}", chain_id, ORDER_FILLED_METRIC), 138 | CwMetrics::TxStatusUnknown(chain_id) => { 139 | format!("{}-{}", chain_id, TX_STATUS_UNKNOWN_METRIC) 140 | } 141 | CwMetrics::Balance(val) => format!("Bal-{}", val), 142 | CwMetrics::LatestBlock(chain_id) => format!("{}-{}", chain_id, LATEST_BLOCK), 143 | CwMetrics::TargetBlockDelta(chain_id) => format!("{}-{}", chain_id, TARGET_BLOCK_DELTA), 144 | CwMetrics::RevertCode(chain_id, code) => format!("{}-{}-{}", chain_id, REVERT_CODE_METRIC, code), 145 | CwMetrics::KeysInUse(chain_id) => format!("{}-{}", chain_id, KEYS_IN_USE), 146 | CwMetrics::KeysAvailable(chain_id) => format!("{}-{}", chain_id, KEYS_AVAILABLE), 147 | CwMetrics::OrderStalenessSec(chain_id) => format!("{}-{}", chain_id, ORDER_STALENESS_SEC), 148 | } 149 | } 150 | } 151 | 152 | pub const ARTEMIS_NAMESPACE: &str = "Artemis"; 153 | 154 | pub struct MetricBuilder { 155 | metric_name: String, 156 | dimensions: Vec, 157 | value: f64, 158 | } 159 | 160 | // TODO: TxStatus type metrics => TxStatus(u32) 161 | impl MetricBuilder { 162 | pub fn new(metric: CwMetrics) -> Self { 163 | match metric { 164 | CwMetrics::Balance(val) => Self { 165 | metric_name: format!("Bal-{}", val), 166 | dimensions: Vec::new(), 167 | value: 0.0, 168 | }, 169 | _ => Self { 170 | metric_name: metric.into(), 171 | dimensions: Vec::new(), 172 | value: 1.0, 173 | }, 174 | } 175 | } 176 | 177 | pub fn add_dimension(mut self, name: &str, value: &str) -> Self { 178 | self.dimensions 179 | .push(Dimension::builder().name(name).value(value).build()); 180 | self 181 | } 182 | 183 | pub fn with_value(mut self, value: f64) -> Self { 184 | self.value = value; 185 | self 186 | } 187 | 188 | pub fn build(self) -> aws_sdk_cloudwatch::types::MetricDatum { 189 | aws_sdk_cloudwatch::types::MetricDatum::builder() 190 | .metric_name(self.metric_name) 191 | .value(self.value) 192 | .set_dimensions(Some(self.dimensions)) 193 | .build() 194 | } 195 | } 196 | 197 | pub fn receipt_status_to_metric(status: bool, chain_id: u64) -> CwMetrics { 198 | match status { 199 | true => CwMetrics::TxSucceeded(chain_id), 200 | false => CwMetrics::TxReverted(chain_id), 201 | } 202 | } 203 | 204 | pub fn revert_code_to_metric(chain_id: u64, revert_code: String) -> CwMetrics { 205 | CwMetrics::RevertCode(chain_id, revert_code) 206 | } 207 | 208 | pub fn build_metric_future( 209 | cloudwatch_client: Option>, 210 | dimension_value: DimensionValue, 211 | metric: CwMetrics, 212 | value: f64, 213 | ) -> Option< 214 | Pin< 215 | Box< 216 | impl Future< 217 | Output = Result< 218 | PutMetricDataOutput, 219 | SdkError, 220 | >, 221 | > + Send 222 | + 'static, 223 | >, 224 | >, 225 | > { 226 | cloudwatch_client.map(|client| { 227 | Box::pin(async move { 228 | client 229 | .put_metric_data() 230 | .namespace(ARTEMIS_NAMESPACE) 231 | .metric_data( 232 | MetricBuilder::new(metric) 233 | .add_dimension(DimensionName::Service.as_ref(), dimension_value.as_ref()) 234 | .with_value(value) 235 | .build(), 236 | ) 237 | .send() 238 | .await 239 | }) 240 | }) 241 | } 242 | 243 | #[macro_export] 244 | macro_rules! send_metric_with_order_hash { 245 | ($order_hash: expr, $future: expr) => { 246 | let hash = Arc::clone($order_hash); 247 | tokio::spawn(async move { 248 | if let Err(e) = $future.await { 249 | warn!("{} - error sending metric: {:?}", hash, e); 250 | } 251 | }) 252 | }; 253 | } 254 | 255 | #[macro_export] 256 | macro_rules! send_metric { 257 | ($future: expr) => { 258 | tokio::spawn(async move { 259 | if let Err(e) = $future.await { 260 | warn!("error sending metric: {:?}", e); 261 | } 262 | }) 263 | }; 264 | } 265 | -------------------------------------------------------------------------------- /crates/bindings-uniswapx/src/ecdsa.rs: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | Generated by the following Solidity interface... 4 | ```solidity 5 | interface ECDSA {} 6 | ``` 7 | 8 | ...which was generated by the following JSON ABI: 9 | ```json 10 | [] 11 | ```*/ 12 | #[allow( 13 | non_camel_case_types, 14 | non_snake_case, 15 | clippy::pub_underscore_fields, 16 | clippy::style, 17 | clippy::empty_structs_with_brackets 18 | )] 19 | pub mod ECDSA { 20 | use super::*; 21 | use alloy::sol_types as alloy_sol_types; 22 | /// The creation / init bytecode of the contract. 23 | /// 24 | /// ```text 25 | ///0x60556032600b8282823980515f1a607314602657634e487b7160e01b5f525f60045260245ffd5b305f52607381538281f3fe730000000000000000000000000000000000000000301460806040525f80fdfea26469706673582212209d1b0494fde68659cf477a8a6c8200cc72b195c34daeb7c6703486ab8c3c250164736f6c63430008180033 26 | /// ``` 27 | #[rustfmt::skip] 28 | #[allow(clippy::all)] 29 | pub static BYTECODE: alloy_sol_types::private::Bytes = alloy_sol_types::private::Bytes::from_static( 30 | b"`U`2`\x0B\x82\x82\x829\x80Q_\x1A`s\x14`&WcNH{q`\xE0\x1B_R_`\x04R`$_\xFD[0_R`s\x81S\x82\x81\xF3\xFEs\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x000\x14`\x80`@R_\x80\xFD\xFE\xA2dipfsX\"\x12 \x9D\x1B\x04\x94\xFD\xE6\x86Y\xCFGz\x8Al\x82\0\xCCr\xB1\x95\xC3M\xAE\xB7\xC6p4\x86\xAB\x8C<%\x01dsolcC\0\x08\x18\x003", 31 | ); 32 | /// The runtime bytecode of the contract, as deployed on the network. 33 | /// 34 | /// ```text 35 | ///0x730000000000000000000000000000000000000000301460806040525f80fdfea26469706673582212209d1b0494fde68659cf477a8a6c8200cc72b195c34daeb7c6703486ab8c3c250164736f6c63430008180033 36 | /// ``` 37 | #[rustfmt::skip] 38 | #[allow(clippy::all)] 39 | pub static DEPLOYED_BYTECODE: alloy_sol_types::private::Bytes = alloy_sol_types::private::Bytes::from_static( 40 | b"s\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x000\x14`\x80`@R_\x80\xFD\xFE\xA2dipfsX\"\x12 \x9D\x1B\x04\x94\xFD\xE6\x86Y\xCFGz\x8Al\x82\0\xCCr\xB1\x95\xC3M\xAE\xB7\xC6p4\x86\xAB\x8C<%\x01dsolcC\0\x08\x18\x003", 41 | ); 42 | use alloy::contract as alloy_contract; 43 | /**Creates a new wrapper around an on-chain [`ECDSA`](self) contract instance. 44 | 45 | See the [wrapper's documentation](`ECDSAInstance`) for more details.*/ 46 | #[inline] 47 | pub const fn new< 48 | T: alloy_contract::private::Transport + ::core::clone::Clone, 49 | P: alloy_contract::private::Provider, 50 | N: alloy_contract::private::Network, 51 | >( 52 | address: alloy_sol_types::private::Address, 53 | provider: P, 54 | ) -> ECDSAInstance { 55 | ECDSAInstance::::new(address, provider) 56 | } 57 | /**Deploys this contract using the given `provider` and constructor arguments, if any. 58 | 59 | Returns a new instance of the contract, if the deployment was successful. 60 | 61 | For more fine-grained control over the deployment process, use [`deploy_builder`] instead.*/ 62 | #[inline] 63 | pub fn deploy< 64 | T: alloy_contract::private::Transport + ::core::clone::Clone, 65 | P: alloy_contract::private::Provider, 66 | N: alloy_contract::private::Network, 67 | >( 68 | provider: P, 69 | ) -> impl ::core::future::Future< 70 | Output = alloy_contract::Result>, 71 | > { 72 | ECDSAInstance::::deploy(provider) 73 | } 74 | /**Creates a `RawCallBuilder` for deploying this contract using the given `provider` 75 | and constructor arguments, if any. 76 | 77 | This is a simple wrapper around creating a `RawCallBuilder` with the data set to 78 | the bytecode concatenated with the constructor's ABI-encoded arguments.*/ 79 | #[inline] 80 | pub fn deploy_builder< 81 | T: alloy_contract::private::Transport + ::core::clone::Clone, 82 | P: alloy_contract::private::Provider, 83 | N: alloy_contract::private::Network, 84 | >(provider: P) -> alloy_contract::RawCallBuilder { 85 | ECDSAInstance::::deploy_builder(provider) 86 | } 87 | /**A [`ECDSA`](self) instance. 88 | 89 | Contains type-safe methods for interacting with an on-chain instance of the 90 | [`ECDSA`](self) contract located at a given `address`, using a given 91 | provider `P`. 92 | 93 | If the contract bytecode is available (see the [`sol!`](alloy_sol_types::sol!) 94 | documentation on how to provide it), the `deploy` and `deploy_builder` methods can 95 | be used to deploy a new instance of the contract. 96 | 97 | See the [module-level documentation](self) for all the available methods.*/ 98 | #[derive(Clone)] 99 | pub struct ECDSAInstance { 100 | address: alloy_sol_types::private::Address, 101 | provider: P, 102 | _network_transport: ::core::marker::PhantomData<(N, T)>, 103 | } 104 | #[automatically_derived] 105 | impl ::core::fmt::Debug for ECDSAInstance { 106 | #[inline] 107 | fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { 108 | f.debug_tuple("ECDSAInstance").field(&self.address).finish() 109 | } 110 | } 111 | /// Instantiation and getters/setters. 112 | #[automatically_derived] 113 | impl< 114 | T: alloy_contract::private::Transport + ::core::clone::Clone, 115 | P: alloy_contract::private::Provider, 116 | N: alloy_contract::private::Network, 117 | > ECDSAInstance { 118 | /**Creates a new wrapper around an on-chain [`ECDSA`](self) contract instance. 119 | 120 | See the [wrapper's documentation](`ECDSAInstance`) for more details.*/ 121 | #[inline] 122 | pub const fn new( 123 | address: alloy_sol_types::private::Address, 124 | provider: P, 125 | ) -> Self { 126 | Self { 127 | address, 128 | provider, 129 | _network_transport: ::core::marker::PhantomData, 130 | } 131 | } 132 | /**Deploys this contract using the given `provider` and constructor arguments, if any. 133 | 134 | Returns a new instance of the contract, if the deployment was successful. 135 | 136 | For more fine-grained control over the deployment process, use [`deploy_builder`] instead.*/ 137 | #[inline] 138 | pub async fn deploy( 139 | provider: P, 140 | ) -> alloy_contract::Result> { 141 | let call_builder = Self::deploy_builder(provider); 142 | let contract_address = call_builder.deploy().await?; 143 | Ok(Self::new(contract_address, call_builder.provider)) 144 | } 145 | /**Creates a `RawCallBuilder` for deploying this contract using the given `provider` 146 | and constructor arguments, if any. 147 | 148 | This is a simple wrapper around creating a `RawCallBuilder` with the data set to 149 | the bytecode concatenated with the constructor's ABI-encoded arguments.*/ 150 | #[inline] 151 | pub fn deploy_builder(provider: P) -> alloy_contract::RawCallBuilder { 152 | alloy_contract::RawCallBuilder::new_raw_deploy( 153 | provider, 154 | ::core::clone::Clone::clone(&BYTECODE), 155 | ) 156 | } 157 | /// Returns a reference to the address. 158 | #[inline] 159 | pub const fn address(&self) -> &alloy_sol_types::private::Address { 160 | &self.address 161 | } 162 | /// Sets the address. 163 | #[inline] 164 | pub fn set_address(&mut self, address: alloy_sol_types::private::Address) { 165 | self.address = address; 166 | } 167 | /// Sets the address and returns `self`. 168 | pub fn at(mut self, address: alloy_sol_types::private::Address) -> Self { 169 | self.set_address(address); 170 | self 171 | } 172 | /// Returns a reference to the provider. 173 | #[inline] 174 | pub const fn provider(&self) -> &P { 175 | &self.provider 176 | } 177 | } 178 | impl ECDSAInstance { 179 | /// Clones the provider and returns a new instance with the cloned provider. 180 | #[inline] 181 | pub fn with_cloned_provider(self) -> ECDSAInstance { 182 | ECDSAInstance { 183 | address: self.address, 184 | provider: ::core::clone::Clone::clone(&self.provider), 185 | _network_transport: ::core::marker::PhantomData, 186 | } 187 | } 188 | } 189 | /// Function calls. 190 | #[automatically_derived] 191 | impl< 192 | T: alloy_contract::private::Transport + ::core::clone::Clone, 193 | P: alloy_contract::private::Provider, 194 | N: alloy_contract::private::Network, 195 | > ECDSAInstance { 196 | /// Creates a new call builder using this contract instance's provider and address. 197 | /// 198 | /// Note that the call can be any function call, not just those defined in this 199 | /// contract. Prefer using the other methods for building type-safe contract calls. 200 | pub fn call_builder( 201 | &self, 202 | call: &C, 203 | ) -> alloy_contract::SolCallBuilder { 204 | alloy_contract::SolCallBuilder::new_sol(&self.provider, &self.address, call) 205 | } 206 | } 207 | /// Event filters. 208 | #[automatically_derived] 209 | impl< 210 | T: alloy_contract::private::Transport + ::core::clone::Clone, 211 | P: alloy_contract::private::Provider, 212 | N: alloy_contract::private::Network, 213 | > ECDSAInstance { 214 | /// Creates a new event filter using this contract instance's provider and address. 215 | /// 216 | /// Note that the type can be any event, not just those defined in this contract. 217 | /// Prefer using the other methods for building type-safe event filters. 218 | pub fn event_filter( 219 | &self, 220 | ) -> alloy_contract::Event { 221 | alloy_contract::Event::new_sol(&self.provider, &self.address) 222 | } 223 | } 224 | } 225 | -------------------------------------------------------------------------------- /crates/bindings-uniswapx/src/mathext.rs: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | Generated by the following Solidity interface... 4 | ```solidity 5 | interface MathExt {} 6 | ``` 7 | 8 | ...which was generated by the following JSON ABI: 9 | ```json 10 | [] 11 | ```*/ 12 | #[allow( 13 | non_camel_case_types, 14 | non_snake_case, 15 | clippy::pub_underscore_fields, 16 | clippy::style, 17 | clippy::empty_structs_with_brackets 18 | )] 19 | pub mod MathExt { 20 | use super::*; 21 | use alloy::sol_types as alloy_sol_types; 22 | /// The creation / init bytecode of the contract. 23 | /// 24 | /// ```text 25 | ///0x60556032600b8282823980515f1a607314602657634e487b7160e01b5f525f60045260245ffd5b305f52607381538281f3fe730000000000000000000000000000000000000000301460806040525f80fdfea26469706673582212201377637f7cfbcbff6c96aa3e04c5405684c30ed17d341ceba48a285ed9a67b1564736f6c63430008180033 26 | /// ``` 27 | #[rustfmt::skip] 28 | #[allow(clippy::all)] 29 | pub static BYTECODE: alloy_sol_types::private::Bytes = alloy_sol_types::private::Bytes::from_static( 30 | b"`U`2`\x0B\x82\x82\x829\x80Q_\x1A`s\x14`&WcNH{q`\xE0\x1B_R_`\x04R`$_\xFD[0_R`s\x81S\x82\x81\xF3\xFEs\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x000\x14`\x80`@R_\x80\xFD\xFE\xA2dipfsX\"\x12 \x13wc\x7F|\xFB\xCB\xFFl\x96\xAA>\x04\xC5@V\x84\xC3\x0E\xD1}4\x1C\xEB\xA4\x8A(^\xD9\xA6{\x15dsolcC\0\x08\x18\x003", 31 | ); 32 | /// The runtime bytecode of the contract, as deployed on the network. 33 | /// 34 | /// ```text 35 | ///0x730000000000000000000000000000000000000000301460806040525f80fdfea26469706673582212201377637f7cfbcbff6c96aa3e04c5405684c30ed17d341ceba48a285ed9a67b1564736f6c63430008180033 36 | /// ``` 37 | #[rustfmt::skip] 38 | #[allow(clippy::all)] 39 | pub static DEPLOYED_BYTECODE: alloy_sol_types::private::Bytes = alloy_sol_types::private::Bytes::from_static( 40 | b"s\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x000\x14`\x80`@R_\x80\xFD\xFE\xA2dipfsX\"\x12 \x13wc\x7F|\xFB\xCB\xFFl\x96\xAA>\x04\xC5@V\x84\xC3\x0E\xD1}4\x1C\xEB\xA4\x8A(^\xD9\xA6{\x15dsolcC\0\x08\x18\x003", 41 | ); 42 | use alloy::contract as alloy_contract; 43 | /**Creates a new wrapper around an on-chain [`MathExt`](self) contract instance. 44 | 45 | See the [wrapper's documentation](`MathExtInstance`) for more details.*/ 46 | #[inline] 47 | pub const fn new< 48 | T: alloy_contract::private::Transport + ::core::clone::Clone, 49 | P: alloy_contract::private::Provider, 50 | N: alloy_contract::private::Network, 51 | >( 52 | address: alloy_sol_types::private::Address, 53 | provider: P, 54 | ) -> MathExtInstance { 55 | MathExtInstance::::new(address, provider) 56 | } 57 | /**Deploys this contract using the given `provider` and constructor arguments, if any. 58 | 59 | Returns a new instance of the contract, if the deployment was successful. 60 | 61 | For more fine-grained control over the deployment process, use [`deploy_builder`] instead.*/ 62 | #[inline] 63 | pub fn deploy< 64 | T: alloy_contract::private::Transport + ::core::clone::Clone, 65 | P: alloy_contract::private::Provider, 66 | N: alloy_contract::private::Network, 67 | >( 68 | provider: P, 69 | ) -> impl ::core::future::Future< 70 | Output = alloy_contract::Result>, 71 | > { 72 | MathExtInstance::::deploy(provider) 73 | } 74 | /**Creates a `RawCallBuilder` for deploying this contract using the given `provider` 75 | and constructor arguments, if any. 76 | 77 | This is a simple wrapper around creating a `RawCallBuilder` with the data set to 78 | the bytecode concatenated with the constructor's ABI-encoded arguments.*/ 79 | #[inline] 80 | pub fn deploy_builder< 81 | T: alloy_contract::private::Transport + ::core::clone::Clone, 82 | P: alloy_contract::private::Provider, 83 | N: alloy_contract::private::Network, 84 | >(provider: P) -> alloy_contract::RawCallBuilder { 85 | MathExtInstance::::deploy_builder(provider) 86 | } 87 | /**A [`MathExt`](self) instance. 88 | 89 | Contains type-safe methods for interacting with an on-chain instance of the 90 | [`MathExt`](self) contract located at a given `address`, using a given 91 | provider `P`. 92 | 93 | If the contract bytecode is available (see the [`sol!`](alloy_sol_types::sol!) 94 | documentation on how to provide it), the `deploy` and `deploy_builder` methods can 95 | be used to deploy a new instance of the contract. 96 | 97 | See the [module-level documentation](self) for all the available methods.*/ 98 | #[derive(Clone)] 99 | pub struct MathExtInstance { 100 | address: alloy_sol_types::private::Address, 101 | provider: P, 102 | _network_transport: ::core::marker::PhantomData<(N, T)>, 103 | } 104 | #[automatically_derived] 105 | impl ::core::fmt::Debug for MathExtInstance { 106 | #[inline] 107 | fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { 108 | f.debug_tuple("MathExtInstance").field(&self.address).finish() 109 | } 110 | } 111 | /// Instantiation and getters/setters. 112 | #[automatically_derived] 113 | impl< 114 | T: alloy_contract::private::Transport + ::core::clone::Clone, 115 | P: alloy_contract::private::Provider, 116 | N: alloy_contract::private::Network, 117 | > MathExtInstance { 118 | /**Creates a new wrapper around an on-chain [`MathExt`](self) contract instance. 119 | 120 | See the [wrapper's documentation](`MathExtInstance`) for more details.*/ 121 | #[inline] 122 | pub const fn new( 123 | address: alloy_sol_types::private::Address, 124 | provider: P, 125 | ) -> Self { 126 | Self { 127 | address, 128 | provider, 129 | _network_transport: ::core::marker::PhantomData, 130 | } 131 | } 132 | /**Deploys this contract using the given `provider` and constructor arguments, if any. 133 | 134 | Returns a new instance of the contract, if the deployment was successful. 135 | 136 | For more fine-grained control over the deployment process, use [`deploy_builder`] instead.*/ 137 | #[inline] 138 | pub async fn deploy( 139 | provider: P, 140 | ) -> alloy_contract::Result> { 141 | let call_builder = Self::deploy_builder(provider); 142 | let contract_address = call_builder.deploy().await?; 143 | Ok(Self::new(contract_address, call_builder.provider)) 144 | } 145 | /**Creates a `RawCallBuilder` for deploying this contract using the given `provider` 146 | and constructor arguments, if any. 147 | 148 | This is a simple wrapper around creating a `RawCallBuilder` with the data set to 149 | the bytecode concatenated with the constructor's ABI-encoded arguments.*/ 150 | #[inline] 151 | pub fn deploy_builder(provider: P) -> alloy_contract::RawCallBuilder { 152 | alloy_contract::RawCallBuilder::new_raw_deploy( 153 | provider, 154 | ::core::clone::Clone::clone(&BYTECODE), 155 | ) 156 | } 157 | /// Returns a reference to the address. 158 | #[inline] 159 | pub const fn address(&self) -> &alloy_sol_types::private::Address { 160 | &self.address 161 | } 162 | /// Sets the address. 163 | #[inline] 164 | pub fn set_address(&mut self, address: alloy_sol_types::private::Address) { 165 | self.address = address; 166 | } 167 | /// Sets the address and returns `self`. 168 | pub fn at(mut self, address: alloy_sol_types::private::Address) -> Self { 169 | self.set_address(address); 170 | self 171 | } 172 | /// Returns a reference to the provider. 173 | #[inline] 174 | pub const fn provider(&self) -> &P { 175 | &self.provider 176 | } 177 | } 178 | impl MathExtInstance { 179 | /// Clones the provider and returns a new instance with the cloned provider. 180 | #[inline] 181 | pub fn with_cloned_provider(self) -> MathExtInstance { 182 | MathExtInstance { 183 | address: self.address, 184 | provider: ::core::clone::Clone::clone(&self.provider), 185 | _network_transport: ::core::marker::PhantomData, 186 | } 187 | } 188 | } 189 | /// Function calls. 190 | #[automatically_derived] 191 | impl< 192 | T: alloy_contract::private::Transport + ::core::clone::Clone, 193 | P: alloy_contract::private::Provider, 194 | N: alloy_contract::private::Network, 195 | > MathExtInstance { 196 | /// Creates a new call builder using this contract instance's provider and address. 197 | /// 198 | /// Note that the call can be any function call, not just those defined in this 199 | /// contract. Prefer using the other methods for building type-safe contract calls. 200 | pub fn call_builder( 201 | &self, 202 | call: &C, 203 | ) -> alloy_contract::SolCallBuilder { 204 | alloy_contract::SolCallBuilder::new_sol(&self.provider, &self.address, call) 205 | } 206 | } 207 | /// Event filters. 208 | #[automatically_derived] 209 | impl< 210 | T: alloy_contract::private::Transport + ::core::clone::Clone, 211 | P: alloy_contract::private::Provider, 212 | N: alloy_contract::private::Network, 213 | > MathExtInstance { 214 | /// Creates a new event filter using this contract instance's provider and address. 215 | /// 216 | /// Note that the type can be any event, not just those defined in this contract. 217 | /// Prefer using the other methods for building type-safe event filters. 218 | pub fn event_filter( 219 | &self, 220 | ) -> alloy_contract::Event { 221 | alloy_contract::Event::new_sol(&self.provider, &self.address) 222 | } 223 | } 224 | } 225 | -------------------------------------------------------------------------------- /crates/bindings-uniswapx/src/safecast.rs: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | Generated by the following Solidity interface... 4 | ```solidity 5 | interface SafeCast {} 6 | ``` 7 | 8 | ...which was generated by the following JSON ABI: 9 | ```json 10 | [] 11 | ```*/ 12 | #[allow( 13 | non_camel_case_types, 14 | non_snake_case, 15 | clippy::pub_underscore_fields, 16 | clippy::style, 17 | clippy::empty_structs_with_brackets 18 | )] 19 | pub mod SafeCast { 20 | use super::*; 21 | use alloy::sol_types as alloy_sol_types; 22 | /// The creation / init bytecode of the contract. 23 | /// 24 | /// ```text 25 | ///0x60556032600b8282823980515f1a607314602657634e487b7160e01b5f525f60045260245ffd5b305f52607381538281f3fe730000000000000000000000000000000000000000301460806040525f80fdfea2646970667358221220ec1341014145276a75ff612bbfc1066d2d14c9f9a100aa316f36378bf0dce4ef64736f6c63430008180033 26 | /// ``` 27 | #[rustfmt::skip] 28 | #[allow(clippy::all)] 29 | pub static BYTECODE: alloy_sol_types::private::Bytes = alloy_sol_types::private::Bytes::from_static( 30 | b"`U`2`\x0B\x82\x82\x829\x80Q_\x1A`s\x14`&WcNH{q`\xE0\x1B_R_`\x04R`$_\xFD[0_R`s\x81S\x82\x81\xF3\xFEs\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x000\x14`\x80`@R_\x80\xFD\xFE\xA2dipfsX\"\x12 \xEC\x13A\x01AE'ju\xFFa+\xBF\xC1\x06m-\x14\xC9\xF9\xA1\0\xAA1o67\x8B\xF0\xDC\xE4\xEFdsolcC\0\x08\x18\x003", 31 | ); 32 | /// The runtime bytecode of the contract, as deployed on the network. 33 | /// 34 | /// ```text 35 | ///0x730000000000000000000000000000000000000000301460806040525f80fdfea2646970667358221220ec1341014145276a75ff612bbfc1066d2d14c9f9a100aa316f36378bf0dce4ef64736f6c63430008180033 36 | /// ``` 37 | #[rustfmt::skip] 38 | #[allow(clippy::all)] 39 | pub static DEPLOYED_BYTECODE: alloy_sol_types::private::Bytes = alloy_sol_types::private::Bytes::from_static( 40 | b"s\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x000\x14`\x80`@R_\x80\xFD\xFE\xA2dipfsX\"\x12 \xEC\x13A\x01AE'ju\xFFa+\xBF\xC1\x06m-\x14\xC9\xF9\xA1\0\xAA1o67\x8B\xF0\xDC\xE4\xEFdsolcC\0\x08\x18\x003", 41 | ); 42 | use alloy::contract as alloy_contract; 43 | /**Creates a new wrapper around an on-chain [`SafeCast`](self) contract instance. 44 | 45 | See the [wrapper's documentation](`SafeCastInstance`) for more details.*/ 46 | #[inline] 47 | pub const fn new< 48 | T: alloy_contract::private::Transport + ::core::clone::Clone, 49 | P: alloy_contract::private::Provider, 50 | N: alloy_contract::private::Network, 51 | >( 52 | address: alloy_sol_types::private::Address, 53 | provider: P, 54 | ) -> SafeCastInstance { 55 | SafeCastInstance::::new(address, provider) 56 | } 57 | /**Deploys this contract using the given `provider` and constructor arguments, if any. 58 | 59 | Returns a new instance of the contract, if the deployment was successful. 60 | 61 | For more fine-grained control over the deployment process, use [`deploy_builder`] instead.*/ 62 | #[inline] 63 | pub fn deploy< 64 | T: alloy_contract::private::Transport + ::core::clone::Clone, 65 | P: alloy_contract::private::Provider, 66 | N: alloy_contract::private::Network, 67 | >( 68 | provider: P, 69 | ) -> impl ::core::future::Future< 70 | Output = alloy_contract::Result>, 71 | > { 72 | SafeCastInstance::::deploy(provider) 73 | } 74 | /**Creates a `RawCallBuilder` for deploying this contract using the given `provider` 75 | and constructor arguments, if any. 76 | 77 | This is a simple wrapper around creating a `RawCallBuilder` with the data set to 78 | the bytecode concatenated with the constructor's ABI-encoded arguments.*/ 79 | #[inline] 80 | pub fn deploy_builder< 81 | T: alloy_contract::private::Transport + ::core::clone::Clone, 82 | P: alloy_contract::private::Provider, 83 | N: alloy_contract::private::Network, 84 | >(provider: P) -> alloy_contract::RawCallBuilder { 85 | SafeCastInstance::::deploy_builder(provider) 86 | } 87 | /**A [`SafeCast`](self) instance. 88 | 89 | Contains type-safe methods for interacting with an on-chain instance of the 90 | [`SafeCast`](self) contract located at a given `address`, using a given 91 | provider `P`. 92 | 93 | If the contract bytecode is available (see the [`sol!`](alloy_sol_types::sol!) 94 | documentation on how to provide it), the `deploy` and `deploy_builder` methods can 95 | be used to deploy a new instance of the contract. 96 | 97 | See the [module-level documentation](self) for all the available methods.*/ 98 | #[derive(Clone)] 99 | pub struct SafeCastInstance { 100 | address: alloy_sol_types::private::Address, 101 | provider: P, 102 | _network_transport: ::core::marker::PhantomData<(N, T)>, 103 | } 104 | #[automatically_derived] 105 | impl ::core::fmt::Debug for SafeCastInstance { 106 | #[inline] 107 | fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { 108 | f.debug_tuple("SafeCastInstance").field(&self.address).finish() 109 | } 110 | } 111 | /// Instantiation and getters/setters. 112 | #[automatically_derived] 113 | impl< 114 | T: alloy_contract::private::Transport + ::core::clone::Clone, 115 | P: alloy_contract::private::Provider, 116 | N: alloy_contract::private::Network, 117 | > SafeCastInstance { 118 | /**Creates a new wrapper around an on-chain [`SafeCast`](self) contract instance. 119 | 120 | See the [wrapper's documentation](`SafeCastInstance`) for more details.*/ 121 | #[inline] 122 | pub const fn new( 123 | address: alloy_sol_types::private::Address, 124 | provider: P, 125 | ) -> Self { 126 | Self { 127 | address, 128 | provider, 129 | _network_transport: ::core::marker::PhantomData, 130 | } 131 | } 132 | /**Deploys this contract using the given `provider` and constructor arguments, if any. 133 | 134 | Returns a new instance of the contract, if the deployment was successful. 135 | 136 | For more fine-grained control over the deployment process, use [`deploy_builder`] instead.*/ 137 | #[inline] 138 | pub async fn deploy( 139 | provider: P, 140 | ) -> alloy_contract::Result> { 141 | let call_builder = Self::deploy_builder(provider); 142 | let contract_address = call_builder.deploy().await?; 143 | Ok(Self::new(contract_address, call_builder.provider)) 144 | } 145 | /**Creates a `RawCallBuilder` for deploying this contract using the given `provider` 146 | and constructor arguments, if any. 147 | 148 | This is a simple wrapper around creating a `RawCallBuilder` with the data set to 149 | the bytecode concatenated with the constructor's ABI-encoded arguments.*/ 150 | #[inline] 151 | pub fn deploy_builder(provider: P) -> alloy_contract::RawCallBuilder { 152 | alloy_contract::RawCallBuilder::new_raw_deploy( 153 | provider, 154 | ::core::clone::Clone::clone(&BYTECODE), 155 | ) 156 | } 157 | /// Returns a reference to the address. 158 | #[inline] 159 | pub const fn address(&self) -> &alloy_sol_types::private::Address { 160 | &self.address 161 | } 162 | /// Sets the address. 163 | #[inline] 164 | pub fn set_address(&mut self, address: alloy_sol_types::private::Address) { 165 | self.address = address; 166 | } 167 | /// Sets the address and returns `self`. 168 | pub fn at(mut self, address: alloy_sol_types::private::Address) -> Self { 169 | self.set_address(address); 170 | self 171 | } 172 | /// Returns a reference to the provider. 173 | #[inline] 174 | pub const fn provider(&self) -> &P { 175 | &self.provider 176 | } 177 | } 178 | impl SafeCastInstance { 179 | /// Clones the provider and returns a new instance with the cloned provider. 180 | #[inline] 181 | pub fn with_cloned_provider(self) -> SafeCastInstance { 182 | SafeCastInstance { 183 | address: self.address, 184 | provider: ::core::clone::Clone::clone(&self.provider), 185 | _network_transport: ::core::marker::PhantomData, 186 | } 187 | } 188 | } 189 | /// Function calls. 190 | #[automatically_derived] 191 | impl< 192 | T: alloy_contract::private::Transport + ::core::clone::Clone, 193 | P: alloy_contract::private::Provider, 194 | N: alloy_contract::private::Network, 195 | > SafeCastInstance { 196 | /// Creates a new call builder using this contract instance's provider and address. 197 | /// 198 | /// Note that the call can be any function call, not just those defined in this 199 | /// contract. Prefer using the other methods for building type-safe contract calls. 200 | pub fn call_builder( 201 | &self, 202 | call: &C, 203 | ) -> alloy_contract::SolCallBuilder { 204 | alloy_contract::SolCallBuilder::new_sol(&self.provider, &self.address, call) 205 | } 206 | } 207 | /// Event filters. 208 | #[automatically_derived] 209 | impl< 210 | T: alloy_contract::private::Transport + ::core::clone::Clone, 211 | P: alloy_contract::private::Provider, 212 | N: alloy_contract::private::Network, 213 | > SafeCastInstance { 214 | /// Creates a new event filter using this contract instance's provider and address. 215 | /// 216 | /// Note that the type can be any event, not just those defined in this contract. 217 | /// Prefer using the other methods for building type-safe event filters. 218 | pub fn event_filter( 219 | &self, 220 | ) -> alloy_contract::Event { 221 | alloy_contract::Event::new_sol(&self.provider, &self.address) 222 | } 223 | } 224 | } 225 | -------------------------------------------------------------------------------- /crates/bindings-uniswapx/src/strings.rs: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | Generated by the following Solidity interface... 4 | ```solidity 5 | interface Strings {} 6 | ``` 7 | 8 | ...which was generated by the following JSON ABI: 9 | ```json 10 | [] 11 | ```*/ 12 | #[allow( 13 | non_camel_case_types, 14 | non_snake_case, 15 | clippy::pub_underscore_fields, 16 | clippy::style, 17 | clippy::empty_structs_with_brackets 18 | )] 19 | pub mod Strings { 20 | use super::*; 21 | use alloy::sol_types as alloy_sol_types; 22 | /// The creation / init bytecode of the contract. 23 | /// 24 | /// ```text 25 | ///0x60556032600b8282823980515f1a607314602657634e487b7160e01b5f525f60045260245ffd5b305f52607381538281f3fe730000000000000000000000000000000000000000301460806040525f80fdfea264697066735822122001f51552e9e351e2904b0752c5b3aa6c92c9be2b2e7fa4d180c42351e487390264736f6c63430008180033 26 | /// ``` 27 | #[rustfmt::skip] 28 | #[allow(clippy::all)] 29 | pub static BYTECODE: alloy_sol_types::private::Bytes = alloy_sol_types::private::Bytes::from_static( 30 | b"`U`2`\x0B\x82\x82\x829\x80Q_\x1A`s\x14`&WcNH{q`\xE0\x1B_R_`\x04R`$_\xFD[0_R`s\x81S\x82\x81\xF3\xFEs\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x000\x14`\x80`@R_\x80\xFD\xFE\xA2dipfsX\"\x12 \x01\xF5\x15R\xE9\xE3Q\xE2\x90K\x07R\xC5\xB3\xAAl\x92\xC9\xBE+.\x7F\xA4\xD1\x80\xC4#Q\xE4\x879\x02dsolcC\0\x08\x18\x003", 31 | ); 32 | /// The runtime bytecode of the contract, as deployed on the network. 33 | /// 34 | /// ```text 35 | ///0x730000000000000000000000000000000000000000301460806040525f80fdfea264697066735822122001f51552e9e351e2904b0752c5b3aa6c92c9be2b2e7fa4d180c42351e487390264736f6c63430008180033 36 | /// ``` 37 | #[rustfmt::skip] 38 | #[allow(clippy::all)] 39 | pub static DEPLOYED_BYTECODE: alloy_sol_types::private::Bytes = alloy_sol_types::private::Bytes::from_static( 40 | b"s\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x000\x14`\x80`@R_\x80\xFD\xFE\xA2dipfsX\"\x12 \x01\xF5\x15R\xE9\xE3Q\xE2\x90K\x07R\xC5\xB3\xAAl\x92\xC9\xBE+.\x7F\xA4\xD1\x80\xC4#Q\xE4\x879\x02dsolcC\0\x08\x18\x003", 41 | ); 42 | use alloy::contract as alloy_contract; 43 | /**Creates a new wrapper around an on-chain [`Strings`](self) contract instance. 44 | 45 | See the [wrapper's documentation](`StringsInstance`) for more details.*/ 46 | #[inline] 47 | pub const fn new< 48 | T: alloy_contract::private::Transport + ::core::clone::Clone, 49 | P: alloy_contract::private::Provider, 50 | N: alloy_contract::private::Network, 51 | >( 52 | address: alloy_sol_types::private::Address, 53 | provider: P, 54 | ) -> StringsInstance { 55 | StringsInstance::::new(address, provider) 56 | } 57 | /**Deploys this contract using the given `provider` and constructor arguments, if any. 58 | 59 | Returns a new instance of the contract, if the deployment was successful. 60 | 61 | For more fine-grained control over the deployment process, use [`deploy_builder`] instead.*/ 62 | #[inline] 63 | pub fn deploy< 64 | T: alloy_contract::private::Transport + ::core::clone::Clone, 65 | P: alloy_contract::private::Provider, 66 | N: alloy_contract::private::Network, 67 | >( 68 | provider: P, 69 | ) -> impl ::core::future::Future< 70 | Output = alloy_contract::Result>, 71 | > { 72 | StringsInstance::::deploy(provider) 73 | } 74 | /**Creates a `RawCallBuilder` for deploying this contract using the given `provider` 75 | and constructor arguments, if any. 76 | 77 | This is a simple wrapper around creating a `RawCallBuilder` with the data set to 78 | the bytecode concatenated with the constructor's ABI-encoded arguments.*/ 79 | #[inline] 80 | pub fn deploy_builder< 81 | T: alloy_contract::private::Transport + ::core::clone::Clone, 82 | P: alloy_contract::private::Provider, 83 | N: alloy_contract::private::Network, 84 | >(provider: P) -> alloy_contract::RawCallBuilder { 85 | StringsInstance::::deploy_builder(provider) 86 | } 87 | /**A [`Strings`](self) instance. 88 | 89 | Contains type-safe methods for interacting with an on-chain instance of the 90 | [`Strings`](self) contract located at a given `address`, using a given 91 | provider `P`. 92 | 93 | If the contract bytecode is available (see the [`sol!`](alloy_sol_types::sol!) 94 | documentation on how to provide it), the `deploy` and `deploy_builder` methods can 95 | be used to deploy a new instance of the contract. 96 | 97 | See the [module-level documentation](self) for all the available methods.*/ 98 | #[derive(Clone)] 99 | pub struct StringsInstance { 100 | address: alloy_sol_types::private::Address, 101 | provider: P, 102 | _network_transport: ::core::marker::PhantomData<(N, T)>, 103 | } 104 | #[automatically_derived] 105 | impl ::core::fmt::Debug for StringsInstance { 106 | #[inline] 107 | fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { 108 | f.debug_tuple("StringsInstance").field(&self.address).finish() 109 | } 110 | } 111 | /// Instantiation and getters/setters. 112 | #[automatically_derived] 113 | impl< 114 | T: alloy_contract::private::Transport + ::core::clone::Clone, 115 | P: alloy_contract::private::Provider, 116 | N: alloy_contract::private::Network, 117 | > StringsInstance { 118 | /**Creates a new wrapper around an on-chain [`Strings`](self) contract instance. 119 | 120 | See the [wrapper's documentation](`StringsInstance`) for more details.*/ 121 | #[inline] 122 | pub const fn new( 123 | address: alloy_sol_types::private::Address, 124 | provider: P, 125 | ) -> Self { 126 | Self { 127 | address, 128 | provider, 129 | _network_transport: ::core::marker::PhantomData, 130 | } 131 | } 132 | /**Deploys this contract using the given `provider` and constructor arguments, if any. 133 | 134 | Returns a new instance of the contract, if the deployment was successful. 135 | 136 | For more fine-grained control over the deployment process, use [`deploy_builder`] instead.*/ 137 | #[inline] 138 | pub async fn deploy( 139 | provider: P, 140 | ) -> alloy_contract::Result> { 141 | let call_builder = Self::deploy_builder(provider); 142 | let contract_address = call_builder.deploy().await?; 143 | Ok(Self::new(contract_address, call_builder.provider)) 144 | } 145 | /**Creates a `RawCallBuilder` for deploying this contract using the given `provider` 146 | and constructor arguments, if any. 147 | 148 | This is a simple wrapper around creating a `RawCallBuilder` with the data set to 149 | the bytecode concatenated with the constructor's ABI-encoded arguments.*/ 150 | #[inline] 151 | pub fn deploy_builder(provider: P) -> alloy_contract::RawCallBuilder { 152 | alloy_contract::RawCallBuilder::new_raw_deploy( 153 | provider, 154 | ::core::clone::Clone::clone(&BYTECODE), 155 | ) 156 | } 157 | /// Returns a reference to the address. 158 | #[inline] 159 | pub const fn address(&self) -> &alloy_sol_types::private::Address { 160 | &self.address 161 | } 162 | /// Sets the address. 163 | #[inline] 164 | pub fn set_address(&mut self, address: alloy_sol_types::private::Address) { 165 | self.address = address; 166 | } 167 | /// Sets the address and returns `self`. 168 | pub fn at(mut self, address: alloy_sol_types::private::Address) -> Self { 169 | self.set_address(address); 170 | self 171 | } 172 | /// Returns a reference to the provider. 173 | #[inline] 174 | pub const fn provider(&self) -> &P { 175 | &self.provider 176 | } 177 | } 178 | impl StringsInstance { 179 | /// Clones the provider and returns a new instance with the cloned provider. 180 | #[inline] 181 | pub fn with_cloned_provider(self) -> StringsInstance { 182 | StringsInstance { 183 | address: self.address, 184 | provider: ::core::clone::Clone::clone(&self.provider), 185 | _network_transport: ::core::marker::PhantomData, 186 | } 187 | } 188 | } 189 | /// Function calls. 190 | #[automatically_derived] 191 | impl< 192 | T: alloy_contract::private::Transport + ::core::clone::Clone, 193 | P: alloy_contract::private::Provider, 194 | N: alloy_contract::private::Network, 195 | > StringsInstance { 196 | /// Creates a new call builder using this contract instance's provider and address. 197 | /// 198 | /// Note that the call can be any function call, not just those defined in this 199 | /// contract. Prefer using the other methods for building type-safe contract calls. 200 | pub fn call_builder( 201 | &self, 202 | call: &C, 203 | ) -> alloy_contract::SolCallBuilder { 204 | alloy_contract::SolCallBuilder::new_sol(&self.provider, &self.address, call) 205 | } 206 | } 207 | /// Event filters. 208 | #[automatically_derived] 209 | impl< 210 | T: alloy_contract::private::Transport + ::core::clone::Clone, 211 | P: alloy_contract::private::Provider, 212 | N: alloy_contract::private::Network, 213 | > StringsInstance { 214 | /// Creates a new event filter using this contract instance's provider and address. 215 | /// 216 | /// Note that the type can be any event, not just those defined in this contract. 217 | /// Prefer using the other methods for building type-safe event filters. 218 | pub fn event_filter( 219 | &self, 220 | ) -> alloy_contract::Event { 221 | alloy_contract::Event::new_sol(&self.provider, &self.address) 222 | } 223 | } 224 | } 225 | -------------------------------------------------------------------------------- /crates/bindings-uniswapx/src/byteslib.rs: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | Generated by the following Solidity interface... 4 | ```solidity 5 | interface BytesLib {} 6 | ``` 7 | 8 | ...which was generated by the following JSON ABI: 9 | ```json 10 | [] 11 | ```*/ 12 | #[allow( 13 | non_camel_case_types, 14 | non_snake_case, 15 | clippy::pub_underscore_fields, 16 | clippy::style, 17 | clippy::empty_structs_with_brackets 18 | )] 19 | pub mod BytesLib { 20 | use super::*; 21 | use alloy::sol_types as alloy_sol_types; 22 | /// The creation / init bytecode of the contract. 23 | /// 24 | /// ```text 25 | ///0x60556032600b8282823980515f1a607314602657634e487b7160e01b5f525f60045260245ffd5b305f52607381538281f3fe730000000000000000000000000000000000000000301460806040525f80fdfea2646970667358221220a6be359ad586752416b55d8f60e2d79b623bac13b61a49589094471acda44dd564736f6c63430008180033 26 | /// ``` 27 | #[rustfmt::skip] 28 | #[allow(clippy::all)] 29 | pub static BYTECODE: alloy_sol_types::private::Bytes = alloy_sol_types::private::Bytes::from_static( 30 | b"`U`2`\x0B\x82\x82\x829\x80Q_\x1A`s\x14`&WcNH{q`\xE0\x1B_R_`\x04R`$_\xFD[0_R`s\x81S\x82\x81\xF3\xFEs\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x000\x14`\x80`@R_\x80\xFD\xFE\xA2dipfsX\"\x12 \xA6\xBE5\x9A\xD5\x86u$\x16\xB5]\x8F`\xE2\xD7\x9Bb;\xAC\x13\xB6\x1AIX\x90\x94G\x1A\xCD\xA4M\xD5dsolcC\0\x08\x18\x003", 31 | ); 32 | /// The runtime bytecode of the contract, as deployed on the network. 33 | /// 34 | /// ```text 35 | ///0x730000000000000000000000000000000000000000301460806040525f80fdfea2646970667358221220a6be359ad586752416b55d8f60e2d79b623bac13b61a49589094471acda44dd564736f6c63430008180033 36 | /// ``` 37 | #[rustfmt::skip] 38 | #[allow(clippy::all)] 39 | pub static DEPLOYED_BYTECODE: alloy_sol_types::private::Bytes = alloy_sol_types::private::Bytes::from_static( 40 | b"s\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x000\x14`\x80`@R_\x80\xFD\xFE\xA2dipfsX\"\x12 \xA6\xBE5\x9A\xD5\x86u$\x16\xB5]\x8F`\xE2\xD7\x9Bb;\xAC\x13\xB6\x1AIX\x90\x94G\x1A\xCD\xA4M\xD5dsolcC\0\x08\x18\x003", 41 | ); 42 | use alloy::contract as alloy_contract; 43 | /**Creates a new wrapper around an on-chain [`BytesLib`](self) contract instance. 44 | 45 | See the [wrapper's documentation](`BytesLibInstance`) for more details.*/ 46 | #[inline] 47 | pub const fn new< 48 | T: alloy_contract::private::Transport + ::core::clone::Clone, 49 | P: alloy_contract::private::Provider, 50 | N: alloy_contract::private::Network, 51 | >( 52 | address: alloy_sol_types::private::Address, 53 | provider: P, 54 | ) -> BytesLibInstance { 55 | BytesLibInstance::::new(address, provider) 56 | } 57 | /**Deploys this contract using the given `provider` and constructor arguments, if any. 58 | 59 | Returns a new instance of the contract, if the deployment was successful. 60 | 61 | For more fine-grained control over the deployment process, use [`deploy_builder`] instead.*/ 62 | #[inline] 63 | pub fn deploy< 64 | T: alloy_contract::private::Transport + ::core::clone::Clone, 65 | P: alloy_contract::private::Provider, 66 | N: alloy_contract::private::Network, 67 | >( 68 | provider: P, 69 | ) -> impl ::core::future::Future< 70 | Output = alloy_contract::Result>, 71 | > { 72 | BytesLibInstance::::deploy(provider) 73 | } 74 | /**Creates a `RawCallBuilder` for deploying this contract using the given `provider` 75 | and constructor arguments, if any. 76 | 77 | This is a simple wrapper around creating a `RawCallBuilder` with the data set to 78 | the bytecode concatenated with the constructor's ABI-encoded arguments.*/ 79 | #[inline] 80 | pub fn deploy_builder< 81 | T: alloy_contract::private::Transport + ::core::clone::Clone, 82 | P: alloy_contract::private::Provider, 83 | N: alloy_contract::private::Network, 84 | >(provider: P) -> alloy_contract::RawCallBuilder { 85 | BytesLibInstance::::deploy_builder(provider) 86 | } 87 | /**A [`BytesLib`](self) instance. 88 | 89 | Contains type-safe methods for interacting with an on-chain instance of the 90 | [`BytesLib`](self) contract located at a given `address`, using a given 91 | provider `P`. 92 | 93 | If the contract bytecode is available (see the [`sol!`](alloy_sol_types::sol!) 94 | documentation on how to provide it), the `deploy` and `deploy_builder` methods can 95 | be used to deploy a new instance of the contract. 96 | 97 | See the [module-level documentation](self) for all the available methods.*/ 98 | #[derive(Clone)] 99 | pub struct BytesLibInstance { 100 | address: alloy_sol_types::private::Address, 101 | provider: P, 102 | _network_transport: ::core::marker::PhantomData<(N, T)>, 103 | } 104 | #[automatically_derived] 105 | impl ::core::fmt::Debug for BytesLibInstance { 106 | #[inline] 107 | fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { 108 | f.debug_tuple("BytesLibInstance").field(&self.address).finish() 109 | } 110 | } 111 | /// Instantiation and getters/setters. 112 | #[automatically_derived] 113 | impl< 114 | T: alloy_contract::private::Transport + ::core::clone::Clone, 115 | P: alloy_contract::private::Provider, 116 | N: alloy_contract::private::Network, 117 | > BytesLibInstance { 118 | /**Creates a new wrapper around an on-chain [`BytesLib`](self) contract instance. 119 | 120 | See the [wrapper's documentation](`BytesLibInstance`) for more details.*/ 121 | #[inline] 122 | pub const fn new( 123 | address: alloy_sol_types::private::Address, 124 | provider: P, 125 | ) -> Self { 126 | Self { 127 | address, 128 | provider, 129 | _network_transport: ::core::marker::PhantomData, 130 | } 131 | } 132 | /**Deploys this contract using the given `provider` and constructor arguments, if any. 133 | 134 | Returns a new instance of the contract, if the deployment was successful. 135 | 136 | For more fine-grained control over the deployment process, use [`deploy_builder`] instead.*/ 137 | #[inline] 138 | pub async fn deploy( 139 | provider: P, 140 | ) -> alloy_contract::Result> { 141 | let call_builder = Self::deploy_builder(provider); 142 | let contract_address = call_builder.deploy().await?; 143 | Ok(Self::new(contract_address, call_builder.provider)) 144 | } 145 | /**Creates a `RawCallBuilder` for deploying this contract using the given `provider` 146 | and constructor arguments, if any. 147 | 148 | This is a simple wrapper around creating a `RawCallBuilder` with the data set to 149 | the bytecode concatenated with the constructor's ABI-encoded arguments.*/ 150 | #[inline] 151 | pub fn deploy_builder(provider: P) -> alloy_contract::RawCallBuilder { 152 | alloy_contract::RawCallBuilder::new_raw_deploy( 153 | provider, 154 | ::core::clone::Clone::clone(&BYTECODE), 155 | ) 156 | } 157 | /// Returns a reference to the address. 158 | #[inline] 159 | pub const fn address(&self) -> &alloy_sol_types::private::Address { 160 | &self.address 161 | } 162 | /// Sets the address. 163 | #[inline] 164 | pub fn set_address(&mut self, address: alloy_sol_types::private::Address) { 165 | self.address = address; 166 | } 167 | /// Sets the address and returns `self`. 168 | pub fn at(mut self, address: alloy_sol_types::private::Address) -> Self { 169 | self.set_address(address); 170 | self 171 | } 172 | /// Returns a reference to the provider. 173 | #[inline] 174 | pub const fn provider(&self) -> &P { 175 | &self.provider 176 | } 177 | } 178 | impl BytesLibInstance { 179 | /// Clones the provider and returns a new instance with the cloned provider. 180 | #[inline] 181 | pub fn with_cloned_provider(self) -> BytesLibInstance { 182 | BytesLibInstance { 183 | address: self.address, 184 | provider: ::core::clone::Clone::clone(&self.provider), 185 | _network_transport: ::core::marker::PhantomData, 186 | } 187 | } 188 | } 189 | /// Function calls. 190 | #[automatically_derived] 191 | impl< 192 | T: alloy_contract::private::Transport + ::core::clone::Clone, 193 | P: alloy_contract::private::Provider, 194 | N: alloy_contract::private::Network, 195 | > BytesLibInstance { 196 | /// Creates a new call builder using this contract instance's provider and address. 197 | /// 198 | /// Note that the call can be any function call, not just those defined in this 199 | /// contract. Prefer using the other methods for building type-safe contract calls. 200 | pub fn call_builder( 201 | &self, 202 | call: &C, 203 | ) -> alloy_contract::SolCallBuilder { 204 | alloy_contract::SolCallBuilder::new_sol(&self.provider, &self.address, call) 205 | } 206 | } 207 | /// Event filters. 208 | #[automatically_derived] 209 | impl< 210 | T: alloy_contract::private::Transport + ::core::clone::Clone, 211 | P: alloy_contract::private::Provider, 212 | N: alloy_contract::private::Network, 213 | > BytesLibInstance { 214 | /// Creates a new event filter using this contract instance's provider and address. 215 | /// 216 | /// Note that the type can be any event, not just those defined in this contract. 217 | /// Prefer using the other methods for building type-safe event filters. 218 | pub fn event_filter( 219 | &self, 220 | ) -> alloy_contract::Event { 221 | alloy_contract::Event::new_sol(&self.provider, &self.address) 222 | } 223 | } 224 | } 225 | -------------------------------------------------------------------------------- /crates/bindings-uniswapx/src/solarray.rs: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | Generated by the following Solidity interface... 4 | ```solidity 5 | interface Solarray {} 6 | ``` 7 | 8 | ...which was generated by the following JSON ABI: 9 | ```json 10 | [] 11 | ```*/ 12 | #[allow( 13 | non_camel_case_types, 14 | non_snake_case, 15 | clippy::pub_underscore_fields, 16 | clippy::style, 17 | clippy::empty_structs_with_brackets 18 | )] 19 | pub mod Solarray { 20 | use super::*; 21 | use alloy::sol_types as alloy_sol_types; 22 | /// The creation / init bytecode of the contract. 23 | /// 24 | /// ```text 25 | ///0x60556032600b8282823980515f1a607314602657634e487b7160e01b5f525f60045260245ffd5b305f52607381538281f3fe730000000000000000000000000000000000000000301460806040525f80fdfea2646970667358221220cf14d2309a579dbe9c20f2dd854495ca825c263d198035c1dfb5a301be53f20064736f6c63430008180033 26 | /// ``` 27 | #[rustfmt::skip] 28 | #[allow(clippy::all)] 29 | pub static BYTECODE: alloy_sol_types::private::Bytes = alloy_sol_types::private::Bytes::from_static( 30 | b"`U`2`\x0B\x82\x82\x829\x80Q_\x1A`s\x14`&WcNH{q`\xE0\x1B_R_`\x04R`$_\xFD[0_R`s\x81S\x82\x81\xF3\xFEs\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x000\x14`\x80`@R_\x80\xFD\xFE\xA2dipfsX\"\x12 \xCF\x14\xD20\x9AW\x9D\xBE\x9C \xF2\xDD\x85D\x95\xCA\x82\\&=\x19\x805\xC1\xDF\xB5\xA3\x01\xBES\xF2\0dsolcC\0\x08\x18\x003", 31 | ); 32 | /// The runtime bytecode of the contract, as deployed on the network. 33 | /// 34 | /// ```text 35 | ///0x730000000000000000000000000000000000000000301460806040525f80fdfea2646970667358221220cf14d2309a579dbe9c20f2dd854495ca825c263d198035c1dfb5a301be53f20064736f6c63430008180033 36 | /// ``` 37 | #[rustfmt::skip] 38 | #[allow(clippy::all)] 39 | pub static DEPLOYED_BYTECODE: alloy_sol_types::private::Bytes = alloy_sol_types::private::Bytes::from_static( 40 | b"s\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x000\x14`\x80`@R_\x80\xFD\xFE\xA2dipfsX\"\x12 \xCF\x14\xD20\x9AW\x9D\xBE\x9C \xF2\xDD\x85D\x95\xCA\x82\\&=\x19\x805\xC1\xDF\xB5\xA3\x01\xBES\xF2\0dsolcC\0\x08\x18\x003", 41 | ); 42 | use alloy::contract as alloy_contract; 43 | /**Creates a new wrapper around an on-chain [`Solarray`](self) contract instance. 44 | 45 | See the [wrapper's documentation](`SolarrayInstance`) for more details.*/ 46 | #[inline] 47 | pub const fn new< 48 | T: alloy_contract::private::Transport + ::core::clone::Clone, 49 | P: alloy_contract::private::Provider, 50 | N: alloy_contract::private::Network, 51 | >( 52 | address: alloy_sol_types::private::Address, 53 | provider: P, 54 | ) -> SolarrayInstance { 55 | SolarrayInstance::::new(address, provider) 56 | } 57 | /**Deploys this contract using the given `provider` and constructor arguments, if any. 58 | 59 | Returns a new instance of the contract, if the deployment was successful. 60 | 61 | For more fine-grained control over the deployment process, use [`deploy_builder`] instead.*/ 62 | #[inline] 63 | pub fn deploy< 64 | T: alloy_contract::private::Transport + ::core::clone::Clone, 65 | P: alloy_contract::private::Provider, 66 | N: alloy_contract::private::Network, 67 | >( 68 | provider: P, 69 | ) -> impl ::core::future::Future< 70 | Output = alloy_contract::Result>, 71 | > { 72 | SolarrayInstance::::deploy(provider) 73 | } 74 | /**Creates a `RawCallBuilder` for deploying this contract using the given `provider` 75 | and constructor arguments, if any. 76 | 77 | This is a simple wrapper around creating a `RawCallBuilder` with the data set to 78 | the bytecode concatenated with the constructor's ABI-encoded arguments.*/ 79 | #[inline] 80 | pub fn deploy_builder< 81 | T: alloy_contract::private::Transport + ::core::clone::Clone, 82 | P: alloy_contract::private::Provider, 83 | N: alloy_contract::private::Network, 84 | >(provider: P) -> alloy_contract::RawCallBuilder { 85 | SolarrayInstance::::deploy_builder(provider) 86 | } 87 | /**A [`Solarray`](self) instance. 88 | 89 | Contains type-safe methods for interacting with an on-chain instance of the 90 | [`Solarray`](self) contract located at a given `address`, using a given 91 | provider `P`. 92 | 93 | If the contract bytecode is available (see the [`sol!`](alloy_sol_types::sol!) 94 | documentation on how to provide it), the `deploy` and `deploy_builder` methods can 95 | be used to deploy a new instance of the contract. 96 | 97 | See the [module-level documentation](self) for all the available methods.*/ 98 | #[derive(Clone)] 99 | pub struct SolarrayInstance { 100 | address: alloy_sol_types::private::Address, 101 | provider: P, 102 | _network_transport: ::core::marker::PhantomData<(N, T)>, 103 | } 104 | #[automatically_derived] 105 | impl ::core::fmt::Debug for SolarrayInstance { 106 | #[inline] 107 | fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { 108 | f.debug_tuple("SolarrayInstance").field(&self.address).finish() 109 | } 110 | } 111 | /// Instantiation and getters/setters. 112 | #[automatically_derived] 113 | impl< 114 | T: alloy_contract::private::Transport + ::core::clone::Clone, 115 | P: alloy_contract::private::Provider, 116 | N: alloy_contract::private::Network, 117 | > SolarrayInstance { 118 | /**Creates a new wrapper around an on-chain [`Solarray`](self) contract instance. 119 | 120 | See the [wrapper's documentation](`SolarrayInstance`) for more details.*/ 121 | #[inline] 122 | pub const fn new( 123 | address: alloy_sol_types::private::Address, 124 | provider: P, 125 | ) -> Self { 126 | Self { 127 | address, 128 | provider, 129 | _network_transport: ::core::marker::PhantomData, 130 | } 131 | } 132 | /**Deploys this contract using the given `provider` and constructor arguments, if any. 133 | 134 | Returns a new instance of the contract, if the deployment was successful. 135 | 136 | For more fine-grained control over the deployment process, use [`deploy_builder`] instead.*/ 137 | #[inline] 138 | pub async fn deploy( 139 | provider: P, 140 | ) -> alloy_contract::Result> { 141 | let call_builder = Self::deploy_builder(provider); 142 | let contract_address = call_builder.deploy().await?; 143 | Ok(Self::new(contract_address, call_builder.provider)) 144 | } 145 | /**Creates a `RawCallBuilder` for deploying this contract using the given `provider` 146 | and constructor arguments, if any. 147 | 148 | This is a simple wrapper around creating a `RawCallBuilder` with the data set to 149 | the bytecode concatenated with the constructor's ABI-encoded arguments.*/ 150 | #[inline] 151 | pub fn deploy_builder(provider: P) -> alloy_contract::RawCallBuilder { 152 | alloy_contract::RawCallBuilder::new_raw_deploy( 153 | provider, 154 | ::core::clone::Clone::clone(&BYTECODE), 155 | ) 156 | } 157 | /// Returns a reference to the address. 158 | #[inline] 159 | pub const fn address(&self) -> &alloy_sol_types::private::Address { 160 | &self.address 161 | } 162 | /// Sets the address. 163 | #[inline] 164 | pub fn set_address(&mut self, address: alloy_sol_types::private::Address) { 165 | self.address = address; 166 | } 167 | /// Sets the address and returns `self`. 168 | pub fn at(mut self, address: alloy_sol_types::private::Address) -> Self { 169 | self.set_address(address); 170 | self 171 | } 172 | /// Returns a reference to the provider. 173 | #[inline] 174 | pub const fn provider(&self) -> &P { 175 | &self.provider 176 | } 177 | } 178 | impl SolarrayInstance { 179 | /// Clones the provider and returns a new instance with the cloned provider. 180 | #[inline] 181 | pub fn with_cloned_provider(self) -> SolarrayInstance { 182 | SolarrayInstance { 183 | address: self.address, 184 | provider: ::core::clone::Clone::clone(&self.provider), 185 | _network_transport: ::core::marker::PhantomData, 186 | } 187 | } 188 | } 189 | /// Function calls. 190 | #[automatically_derived] 191 | impl< 192 | T: alloy_contract::private::Transport + ::core::clone::Clone, 193 | P: alloy_contract::private::Provider, 194 | N: alloy_contract::private::Network, 195 | > SolarrayInstance { 196 | /// Creates a new call builder using this contract instance's provider and address. 197 | /// 198 | /// Note that the call can be any function call, not just those defined in this 199 | /// contract. Prefer using the other methods for building type-safe contract calls. 200 | pub fn call_builder( 201 | &self, 202 | call: &C, 203 | ) -> alloy_contract::SolCallBuilder { 204 | alloy_contract::SolCallBuilder::new_sol(&self.provider, &self.address, call) 205 | } 206 | } 207 | /// Event filters. 208 | #[automatically_derived] 209 | impl< 210 | T: alloy_contract::private::Transport + ::core::clone::Clone, 211 | P: alloy_contract::private::Provider, 212 | N: alloy_contract::private::Network, 213 | > SolarrayInstance { 214 | /// Creates a new event filter using this contract instance's provider and address. 215 | /// 216 | /// Note that the type can be any event, not just those defined in this contract. 217 | /// Prefer using the other methods for building type-safe event filters. 218 | pub fn event_filter( 219 | &self, 220 | ) -> alloy_contract::Event { 221 | alloy_contract::Event::new_sol(&self.provider, &self.address) 222 | } 223 | } 224 | } 225 | -------------------------------------------------------------------------------- /crates/bindings-uniswapx/src/signedmath.rs: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | Generated by the following Solidity interface... 4 | ```solidity 5 | interface SignedMath {} 6 | ``` 7 | 8 | ...which was generated by the following JSON ABI: 9 | ```json 10 | [] 11 | ```*/ 12 | #[allow( 13 | non_camel_case_types, 14 | non_snake_case, 15 | clippy::pub_underscore_fields, 16 | clippy::style, 17 | clippy::empty_structs_with_brackets 18 | )] 19 | pub mod SignedMath { 20 | use super::*; 21 | use alloy::sol_types as alloy_sol_types; 22 | /// The creation / init bytecode of the contract. 23 | /// 24 | /// ```text 25 | ///0x60556032600b8282823980515f1a607314602657634e487b7160e01b5f525f60045260245ffd5b305f52607381538281f3fe730000000000000000000000000000000000000000301460806040525f80fdfea26469706673582212206ac34247505793e6a35803f13c38089d045d64a836bf25d6c09c217bd7daaaf664736f6c63430008180033 26 | /// ``` 27 | #[rustfmt::skip] 28 | #[allow(clippy::all)] 29 | pub static BYTECODE: alloy_sol_types::private::Bytes = alloy_sol_types::private::Bytes::from_static( 30 | b"`U`2`\x0B\x82\x82\x829\x80Q_\x1A`s\x14`&WcNH{q`\xE0\x1B_R_`\x04R`$_\xFD[0_R`s\x81S\x82\x81\xF3\xFEs\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x000\x14`\x80`@R_\x80\xFD\xFE\xA2dipfsX\"\x12 j\xC3BGPW\x93\xE6\xA3X\x03\xF1<8\x08\x9D\x04]d\xA86\xBF%\xD6\xC0\x9C!{\xD7\xDA\xAA\xF6dsolcC\0\x08\x18\x003", 31 | ); 32 | /// The runtime bytecode of the contract, as deployed on the network. 33 | /// 34 | /// ```text 35 | ///0x730000000000000000000000000000000000000000301460806040525f80fdfea26469706673582212206ac34247505793e6a35803f13c38089d045d64a836bf25d6c09c217bd7daaaf664736f6c63430008180033 36 | /// ``` 37 | #[rustfmt::skip] 38 | #[allow(clippy::all)] 39 | pub static DEPLOYED_BYTECODE: alloy_sol_types::private::Bytes = alloy_sol_types::private::Bytes::from_static( 40 | b"s\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x000\x14`\x80`@R_\x80\xFD\xFE\xA2dipfsX\"\x12 j\xC3BGPW\x93\xE6\xA3X\x03\xF1<8\x08\x9D\x04]d\xA86\xBF%\xD6\xC0\x9C!{\xD7\xDA\xAA\xF6dsolcC\0\x08\x18\x003", 41 | ); 42 | use alloy::contract as alloy_contract; 43 | /**Creates a new wrapper around an on-chain [`SignedMath`](self) contract instance. 44 | 45 | See the [wrapper's documentation](`SignedMathInstance`) for more details.*/ 46 | #[inline] 47 | pub const fn new< 48 | T: alloy_contract::private::Transport + ::core::clone::Clone, 49 | P: alloy_contract::private::Provider, 50 | N: alloy_contract::private::Network, 51 | >( 52 | address: alloy_sol_types::private::Address, 53 | provider: P, 54 | ) -> SignedMathInstance { 55 | SignedMathInstance::::new(address, provider) 56 | } 57 | /**Deploys this contract using the given `provider` and constructor arguments, if any. 58 | 59 | Returns a new instance of the contract, if the deployment was successful. 60 | 61 | For more fine-grained control over the deployment process, use [`deploy_builder`] instead.*/ 62 | #[inline] 63 | pub fn deploy< 64 | T: alloy_contract::private::Transport + ::core::clone::Clone, 65 | P: alloy_contract::private::Provider, 66 | N: alloy_contract::private::Network, 67 | >( 68 | provider: P, 69 | ) -> impl ::core::future::Future< 70 | Output = alloy_contract::Result>, 71 | > { 72 | SignedMathInstance::::deploy(provider) 73 | } 74 | /**Creates a `RawCallBuilder` for deploying this contract using the given `provider` 75 | and constructor arguments, if any. 76 | 77 | This is a simple wrapper around creating a `RawCallBuilder` with the data set to 78 | the bytecode concatenated with the constructor's ABI-encoded arguments.*/ 79 | #[inline] 80 | pub fn deploy_builder< 81 | T: alloy_contract::private::Transport + ::core::clone::Clone, 82 | P: alloy_contract::private::Provider, 83 | N: alloy_contract::private::Network, 84 | >(provider: P) -> alloy_contract::RawCallBuilder { 85 | SignedMathInstance::::deploy_builder(provider) 86 | } 87 | /**A [`SignedMath`](self) instance. 88 | 89 | Contains type-safe methods for interacting with an on-chain instance of the 90 | [`SignedMath`](self) contract located at a given `address`, using a given 91 | provider `P`. 92 | 93 | If the contract bytecode is available (see the [`sol!`](alloy_sol_types::sol!) 94 | documentation on how to provide it), the `deploy` and `deploy_builder` methods can 95 | be used to deploy a new instance of the contract. 96 | 97 | See the [module-level documentation](self) for all the available methods.*/ 98 | #[derive(Clone)] 99 | pub struct SignedMathInstance { 100 | address: alloy_sol_types::private::Address, 101 | provider: P, 102 | _network_transport: ::core::marker::PhantomData<(N, T)>, 103 | } 104 | #[automatically_derived] 105 | impl ::core::fmt::Debug for SignedMathInstance { 106 | #[inline] 107 | fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { 108 | f.debug_tuple("SignedMathInstance").field(&self.address).finish() 109 | } 110 | } 111 | /// Instantiation and getters/setters. 112 | #[automatically_derived] 113 | impl< 114 | T: alloy_contract::private::Transport + ::core::clone::Clone, 115 | P: alloy_contract::private::Provider, 116 | N: alloy_contract::private::Network, 117 | > SignedMathInstance { 118 | /**Creates a new wrapper around an on-chain [`SignedMath`](self) contract instance. 119 | 120 | See the [wrapper's documentation](`SignedMathInstance`) for more details.*/ 121 | #[inline] 122 | pub const fn new( 123 | address: alloy_sol_types::private::Address, 124 | provider: P, 125 | ) -> Self { 126 | Self { 127 | address, 128 | provider, 129 | _network_transport: ::core::marker::PhantomData, 130 | } 131 | } 132 | /**Deploys this contract using the given `provider` and constructor arguments, if any. 133 | 134 | Returns a new instance of the contract, if the deployment was successful. 135 | 136 | For more fine-grained control over the deployment process, use [`deploy_builder`] instead.*/ 137 | #[inline] 138 | pub async fn deploy( 139 | provider: P, 140 | ) -> alloy_contract::Result> { 141 | let call_builder = Self::deploy_builder(provider); 142 | let contract_address = call_builder.deploy().await?; 143 | Ok(Self::new(contract_address, call_builder.provider)) 144 | } 145 | /**Creates a `RawCallBuilder` for deploying this contract using the given `provider` 146 | and constructor arguments, if any. 147 | 148 | This is a simple wrapper around creating a `RawCallBuilder` with the data set to 149 | the bytecode concatenated with the constructor's ABI-encoded arguments.*/ 150 | #[inline] 151 | pub fn deploy_builder(provider: P) -> alloy_contract::RawCallBuilder { 152 | alloy_contract::RawCallBuilder::new_raw_deploy( 153 | provider, 154 | ::core::clone::Clone::clone(&BYTECODE), 155 | ) 156 | } 157 | /// Returns a reference to the address. 158 | #[inline] 159 | pub const fn address(&self) -> &alloy_sol_types::private::Address { 160 | &self.address 161 | } 162 | /// Sets the address. 163 | #[inline] 164 | pub fn set_address(&mut self, address: alloy_sol_types::private::Address) { 165 | self.address = address; 166 | } 167 | /// Sets the address and returns `self`. 168 | pub fn at(mut self, address: alloy_sol_types::private::Address) -> Self { 169 | self.set_address(address); 170 | self 171 | } 172 | /// Returns a reference to the provider. 173 | #[inline] 174 | pub const fn provider(&self) -> &P { 175 | &self.provider 176 | } 177 | } 178 | impl SignedMathInstance { 179 | /// Clones the provider and returns a new instance with the cloned provider. 180 | #[inline] 181 | pub fn with_cloned_provider(self) -> SignedMathInstance { 182 | SignedMathInstance { 183 | address: self.address, 184 | provider: ::core::clone::Clone::clone(&self.provider), 185 | _network_transport: ::core::marker::PhantomData, 186 | } 187 | } 188 | } 189 | /// Function calls. 190 | #[automatically_derived] 191 | impl< 192 | T: alloy_contract::private::Transport + ::core::clone::Clone, 193 | P: alloy_contract::private::Provider, 194 | N: alloy_contract::private::Network, 195 | > SignedMathInstance { 196 | /// Creates a new call builder using this contract instance's provider and address. 197 | /// 198 | /// Note that the call can be any function call, not just those defined in this 199 | /// contract. Prefer using the other methods for building type-safe contract calls. 200 | pub fn call_builder( 201 | &self, 202 | call: &C, 203 | ) -> alloy_contract::SolCallBuilder { 204 | alloy_contract::SolCallBuilder::new_sol(&self.provider, &self.address, call) 205 | } 206 | } 207 | /// Event filters. 208 | #[automatically_derived] 209 | impl< 210 | T: alloy_contract::private::Transport + ::core::clone::Clone, 211 | P: alloy_contract::private::Provider, 212 | N: alloy_contract::private::Network, 213 | > SignedMathInstance { 214 | /// Creates a new event filter using this contract instance's provider and address. 215 | /// 216 | /// Note that the type can be any event, not just those defined in this contract. 217 | /// Prefer using the other methods for building type-safe event filters. 218 | pub fn event_filter( 219 | &self, 220 | ) -> alloy_contract::Event { 221 | alloy_contract::Event::new_sol(&self.provider, &self.address) 222 | } 223 | } 224 | } 225 | -------------------------------------------------------------------------------- /crates/bindings-uniswapx/src/arraybuilder.rs: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | Generated by the following Solidity interface... 4 | ```solidity 5 | interface ArrayBuilder {} 6 | ``` 7 | 8 | ...which was generated by the following JSON ABI: 9 | ```json 10 | [] 11 | ```*/ 12 | #[allow( 13 | non_camel_case_types, 14 | non_snake_case, 15 | clippy::pub_underscore_fields, 16 | clippy::style, 17 | clippy::empty_structs_with_brackets 18 | )] 19 | pub mod ArrayBuilder { 20 | use super::*; 21 | use alloy::sol_types as alloy_sol_types; 22 | /// The creation / init bytecode of the contract. 23 | /// 24 | /// ```text 25 | ///0x60556032600b8282823980515f1a607314602657634e487b7160e01b5f525f60045260245ffd5b305f52607381538281f3fe730000000000000000000000000000000000000000301460806040525f80fdfea2646970667358221220484d41f55545340c0f5e95d5944368c5dafe7c4436264448af389c6095fef56e64736f6c63430008180033 26 | /// ``` 27 | #[rustfmt::skip] 28 | #[allow(clippy::all)] 29 | pub static BYTECODE: alloy_sol_types::private::Bytes = alloy_sol_types::private::Bytes::from_static( 30 | b"`U`2`\x0B\x82\x82\x829\x80Q_\x1A`s\x14`&WcNH{q`\xE0\x1B_R_`\x04R`$_\xFD[0_R`s\x81S\x82\x81\xF3\xFEs\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x000\x14`\x80`@R_\x80\xFD\xFE\xA2dipfsX\"\x12 HMA\xF5UE4\x0C\x0F^\x95\xD5\x94Ch\xC5\xDA\xFE|D6&DH\xAF8\x9C`\x95\xFE\xF5ndsolcC\0\x08\x18\x003", 31 | ); 32 | /// The runtime bytecode of the contract, as deployed on the network. 33 | /// 34 | /// ```text 35 | ///0x730000000000000000000000000000000000000000301460806040525f80fdfea2646970667358221220484d41f55545340c0f5e95d5944368c5dafe7c4436264448af389c6095fef56e64736f6c63430008180033 36 | /// ``` 37 | #[rustfmt::skip] 38 | #[allow(clippy::all)] 39 | pub static DEPLOYED_BYTECODE: alloy_sol_types::private::Bytes = alloy_sol_types::private::Bytes::from_static( 40 | b"s\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x000\x14`\x80`@R_\x80\xFD\xFE\xA2dipfsX\"\x12 HMA\xF5UE4\x0C\x0F^\x95\xD5\x94Ch\xC5\xDA\xFE|D6&DH\xAF8\x9C`\x95\xFE\xF5ndsolcC\0\x08\x18\x003", 41 | ); 42 | use alloy::contract as alloy_contract; 43 | /**Creates a new wrapper around an on-chain [`ArrayBuilder`](self) contract instance. 44 | 45 | See the [wrapper's documentation](`ArrayBuilderInstance`) for more details.*/ 46 | #[inline] 47 | pub const fn new< 48 | T: alloy_contract::private::Transport + ::core::clone::Clone, 49 | P: alloy_contract::private::Provider, 50 | N: alloy_contract::private::Network, 51 | >( 52 | address: alloy_sol_types::private::Address, 53 | provider: P, 54 | ) -> ArrayBuilderInstance { 55 | ArrayBuilderInstance::::new(address, provider) 56 | } 57 | /**Deploys this contract using the given `provider` and constructor arguments, if any. 58 | 59 | Returns a new instance of the contract, if the deployment was successful. 60 | 61 | For more fine-grained control over the deployment process, use [`deploy_builder`] instead.*/ 62 | #[inline] 63 | pub fn deploy< 64 | T: alloy_contract::private::Transport + ::core::clone::Clone, 65 | P: alloy_contract::private::Provider, 66 | N: alloy_contract::private::Network, 67 | >( 68 | provider: P, 69 | ) -> impl ::core::future::Future< 70 | Output = alloy_contract::Result>, 71 | > { 72 | ArrayBuilderInstance::::deploy(provider) 73 | } 74 | /**Creates a `RawCallBuilder` for deploying this contract using the given `provider` 75 | and constructor arguments, if any. 76 | 77 | This is a simple wrapper around creating a `RawCallBuilder` with the data set to 78 | the bytecode concatenated with the constructor's ABI-encoded arguments.*/ 79 | #[inline] 80 | pub fn deploy_builder< 81 | T: alloy_contract::private::Transport + ::core::clone::Clone, 82 | P: alloy_contract::private::Provider, 83 | N: alloy_contract::private::Network, 84 | >(provider: P) -> alloy_contract::RawCallBuilder { 85 | ArrayBuilderInstance::::deploy_builder(provider) 86 | } 87 | /**A [`ArrayBuilder`](self) instance. 88 | 89 | Contains type-safe methods for interacting with an on-chain instance of the 90 | [`ArrayBuilder`](self) contract located at a given `address`, using a given 91 | provider `P`. 92 | 93 | If the contract bytecode is available (see the [`sol!`](alloy_sol_types::sol!) 94 | documentation on how to provide it), the `deploy` and `deploy_builder` methods can 95 | be used to deploy a new instance of the contract. 96 | 97 | See the [module-level documentation](self) for all the available methods.*/ 98 | #[derive(Clone)] 99 | pub struct ArrayBuilderInstance { 100 | address: alloy_sol_types::private::Address, 101 | provider: P, 102 | _network_transport: ::core::marker::PhantomData<(N, T)>, 103 | } 104 | #[automatically_derived] 105 | impl ::core::fmt::Debug for ArrayBuilderInstance { 106 | #[inline] 107 | fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { 108 | f.debug_tuple("ArrayBuilderInstance").field(&self.address).finish() 109 | } 110 | } 111 | /// Instantiation and getters/setters. 112 | #[automatically_derived] 113 | impl< 114 | T: alloy_contract::private::Transport + ::core::clone::Clone, 115 | P: alloy_contract::private::Provider, 116 | N: alloy_contract::private::Network, 117 | > ArrayBuilderInstance { 118 | /**Creates a new wrapper around an on-chain [`ArrayBuilder`](self) contract instance. 119 | 120 | See the [wrapper's documentation](`ArrayBuilderInstance`) for more details.*/ 121 | #[inline] 122 | pub const fn new( 123 | address: alloy_sol_types::private::Address, 124 | provider: P, 125 | ) -> Self { 126 | Self { 127 | address, 128 | provider, 129 | _network_transport: ::core::marker::PhantomData, 130 | } 131 | } 132 | /**Deploys this contract using the given `provider` and constructor arguments, if any. 133 | 134 | Returns a new instance of the contract, if the deployment was successful. 135 | 136 | For more fine-grained control over the deployment process, use [`deploy_builder`] instead.*/ 137 | #[inline] 138 | pub async fn deploy( 139 | provider: P, 140 | ) -> alloy_contract::Result> { 141 | let call_builder = Self::deploy_builder(provider); 142 | let contract_address = call_builder.deploy().await?; 143 | Ok(Self::new(contract_address, call_builder.provider)) 144 | } 145 | /**Creates a `RawCallBuilder` for deploying this contract using the given `provider` 146 | and constructor arguments, if any. 147 | 148 | This is a simple wrapper around creating a `RawCallBuilder` with the data set to 149 | the bytecode concatenated with the constructor's ABI-encoded arguments.*/ 150 | #[inline] 151 | pub fn deploy_builder(provider: P) -> alloy_contract::RawCallBuilder { 152 | alloy_contract::RawCallBuilder::new_raw_deploy( 153 | provider, 154 | ::core::clone::Clone::clone(&BYTECODE), 155 | ) 156 | } 157 | /// Returns a reference to the address. 158 | #[inline] 159 | pub const fn address(&self) -> &alloy_sol_types::private::Address { 160 | &self.address 161 | } 162 | /// Sets the address. 163 | #[inline] 164 | pub fn set_address(&mut self, address: alloy_sol_types::private::Address) { 165 | self.address = address; 166 | } 167 | /// Sets the address and returns `self`. 168 | pub fn at(mut self, address: alloy_sol_types::private::Address) -> Self { 169 | self.set_address(address); 170 | self 171 | } 172 | /// Returns a reference to the provider. 173 | #[inline] 174 | pub const fn provider(&self) -> &P { 175 | &self.provider 176 | } 177 | } 178 | impl ArrayBuilderInstance { 179 | /// Clones the provider and returns a new instance with the cloned provider. 180 | #[inline] 181 | pub fn with_cloned_provider(self) -> ArrayBuilderInstance { 182 | ArrayBuilderInstance { 183 | address: self.address, 184 | provider: ::core::clone::Clone::clone(&self.provider), 185 | _network_transport: ::core::marker::PhantomData, 186 | } 187 | } 188 | } 189 | /// Function calls. 190 | #[automatically_derived] 191 | impl< 192 | T: alloy_contract::private::Transport + ::core::clone::Clone, 193 | P: alloy_contract::private::Provider, 194 | N: alloy_contract::private::Network, 195 | > ArrayBuilderInstance { 196 | /// Creates a new call builder using this contract instance's provider and address. 197 | /// 198 | /// Note that the call can be any function call, not just those defined in this 199 | /// contract. Prefer using the other methods for building type-safe contract calls. 200 | pub fn call_builder( 201 | &self, 202 | call: &C, 203 | ) -> alloy_contract::SolCallBuilder { 204 | alloy_contract::SolCallBuilder::new_sol(&self.provider, &self.address, call) 205 | } 206 | } 207 | /// Event filters. 208 | #[automatically_derived] 209 | impl< 210 | T: alloy_contract::private::Transport + ::core::clone::Clone, 211 | P: alloy_contract::private::Provider, 212 | N: alloy_contract::private::Network, 213 | > ArrayBuilderInstance { 214 | /// Creates a new event filter using this contract instance's provider and address. 215 | /// 216 | /// Note that the type can be any event, not just those defined in this contract. 217 | /// Prefer using the other methods for building type-safe event filters. 218 | pub fn event_filter( 219 | &self, 220 | ) -> alloy_contract::Event { 221 | alloy_contract::Event::new_sol(&self.provider, &self.address) 222 | } 223 | } 224 | } 225 | -------------------------------------------------------------------------------- /crates/bindings-uniswapx/src/permit2lib.rs: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | Generated by the following Solidity interface... 4 | ```solidity 5 | interface Permit2Lib {} 6 | ``` 7 | 8 | ...which was generated by the following JSON ABI: 9 | ```json 10 | [] 11 | ```*/ 12 | #[allow( 13 | non_camel_case_types, 14 | non_snake_case, 15 | clippy::pub_underscore_fields, 16 | clippy::style, 17 | clippy::empty_structs_with_brackets 18 | )] 19 | pub mod Permit2Lib { 20 | use super::*; 21 | use alloy::sol_types as alloy_sol_types; 22 | /// The creation / init bytecode of the contract. 23 | /// 24 | /// ```text 25 | ///0x60556032600b8282823980515f1a607314602657634e487b7160e01b5f525f60045260245ffd5b305f52607381538281f3fe730000000000000000000000000000000000000000301460806040525f80fdfea2646970667358221220fef771135a7fe8514a967d17bb7b49148bc501b1eba8aa1716f071eeafeb507764736f6c63430008180033 26 | /// ``` 27 | #[rustfmt::skip] 28 | #[allow(clippy::all)] 29 | pub static BYTECODE: alloy_sol_types::private::Bytes = alloy_sol_types::private::Bytes::from_static( 30 | b"`U`2`\x0B\x82\x82\x829\x80Q_\x1A`s\x14`&WcNH{q`\xE0\x1B_R_`\x04R`$_\xFD[0_R`s\x81S\x82\x81\xF3\xFEs\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x000\x14`\x80`@R_\x80\xFD\xFE\xA2dipfsX\"\x12 \xFE\xF7q\x13Z\x7F\xE8QJ\x96}\x17\xBB{I\x14\x8B\xC5\x01\xB1\xEB\xA8\xAA\x17\x16\xF0q\xEE\xAF\xEBPwdsolcC\0\x08\x18\x003", 31 | ); 32 | /// The runtime bytecode of the contract, as deployed on the network. 33 | /// 34 | /// ```text 35 | ///0x730000000000000000000000000000000000000000301460806040525f80fdfea2646970667358221220fef771135a7fe8514a967d17bb7b49148bc501b1eba8aa1716f071eeafeb507764736f6c63430008180033 36 | /// ``` 37 | #[rustfmt::skip] 38 | #[allow(clippy::all)] 39 | pub static DEPLOYED_BYTECODE: alloy_sol_types::private::Bytes = alloy_sol_types::private::Bytes::from_static( 40 | b"s\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x000\x14`\x80`@R_\x80\xFD\xFE\xA2dipfsX\"\x12 \xFE\xF7q\x13Z\x7F\xE8QJ\x96}\x17\xBB{I\x14\x8B\xC5\x01\xB1\xEB\xA8\xAA\x17\x16\xF0q\xEE\xAF\xEBPwdsolcC\0\x08\x18\x003", 41 | ); 42 | use alloy::contract as alloy_contract; 43 | /**Creates a new wrapper around an on-chain [`Permit2Lib`](self) contract instance. 44 | 45 | See the [wrapper's documentation](`Permit2LibInstance`) for more details.*/ 46 | #[inline] 47 | pub const fn new< 48 | T: alloy_contract::private::Transport + ::core::clone::Clone, 49 | P: alloy_contract::private::Provider, 50 | N: alloy_contract::private::Network, 51 | >( 52 | address: alloy_sol_types::private::Address, 53 | provider: P, 54 | ) -> Permit2LibInstance { 55 | Permit2LibInstance::::new(address, provider) 56 | } 57 | /**Deploys this contract using the given `provider` and constructor arguments, if any. 58 | 59 | Returns a new instance of the contract, if the deployment was successful. 60 | 61 | For more fine-grained control over the deployment process, use [`deploy_builder`] instead.*/ 62 | #[inline] 63 | pub fn deploy< 64 | T: alloy_contract::private::Transport + ::core::clone::Clone, 65 | P: alloy_contract::private::Provider, 66 | N: alloy_contract::private::Network, 67 | >( 68 | provider: P, 69 | ) -> impl ::core::future::Future< 70 | Output = alloy_contract::Result>, 71 | > { 72 | Permit2LibInstance::::deploy(provider) 73 | } 74 | /**Creates a `RawCallBuilder` for deploying this contract using the given `provider` 75 | and constructor arguments, if any. 76 | 77 | This is a simple wrapper around creating a `RawCallBuilder` with the data set to 78 | the bytecode concatenated with the constructor's ABI-encoded arguments.*/ 79 | #[inline] 80 | pub fn deploy_builder< 81 | T: alloy_contract::private::Transport + ::core::clone::Clone, 82 | P: alloy_contract::private::Provider, 83 | N: alloy_contract::private::Network, 84 | >(provider: P) -> alloy_contract::RawCallBuilder { 85 | Permit2LibInstance::::deploy_builder(provider) 86 | } 87 | /**A [`Permit2Lib`](self) instance. 88 | 89 | Contains type-safe methods for interacting with an on-chain instance of the 90 | [`Permit2Lib`](self) contract located at a given `address`, using a given 91 | provider `P`. 92 | 93 | If the contract bytecode is available (see the [`sol!`](alloy_sol_types::sol!) 94 | documentation on how to provide it), the `deploy` and `deploy_builder` methods can 95 | be used to deploy a new instance of the contract. 96 | 97 | See the [module-level documentation](self) for all the available methods.*/ 98 | #[derive(Clone)] 99 | pub struct Permit2LibInstance { 100 | address: alloy_sol_types::private::Address, 101 | provider: P, 102 | _network_transport: ::core::marker::PhantomData<(N, T)>, 103 | } 104 | #[automatically_derived] 105 | impl ::core::fmt::Debug for Permit2LibInstance { 106 | #[inline] 107 | fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { 108 | f.debug_tuple("Permit2LibInstance").field(&self.address).finish() 109 | } 110 | } 111 | /// Instantiation and getters/setters. 112 | #[automatically_derived] 113 | impl< 114 | T: alloy_contract::private::Transport + ::core::clone::Clone, 115 | P: alloy_contract::private::Provider, 116 | N: alloy_contract::private::Network, 117 | > Permit2LibInstance { 118 | /**Creates a new wrapper around an on-chain [`Permit2Lib`](self) contract instance. 119 | 120 | See the [wrapper's documentation](`Permit2LibInstance`) for more details.*/ 121 | #[inline] 122 | pub const fn new( 123 | address: alloy_sol_types::private::Address, 124 | provider: P, 125 | ) -> Self { 126 | Self { 127 | address, 128 | provider, 129 | _network_transport: ::core::marker::PhantomData, 130 | } 131 | } 132 | /**Deploys this contract using the given `provider` and constructor arguments, if any. 133 | 134 | Returns a new instance of the contract, if the deployment was successful. 135 | 136 | For more fine-grained control over the deployment process, use [`deploy_builder`] instead.*/ 137 | #[inline] 138 | pub async fn deploy( 139 | provider: P, 140 | ) -> alloy_contract::Result> { 141 | let call_builder = Self::deploy_builder(provider); 142 | let contract_address = call_builder.deploy().await?; 143 | Ok(Self::new(contract_address, call_builder.provider)) 144 | } 145 | /**Creates a `RawCallBuilder` for deploying this contract using the given `provider` 146 | and constructor arguments, if any. 147 | 148 | This is a simple wrapper around creating a `RawCallBuilder` with the data set to 149 | the bytecode concatenated with the constructor's ABI-encoded arguments.*/ 150 | #[inline] 151 | pub fn deploy_builder(provider: P) -> alloy_contract::RawCallBuilder { 152 | alloy_contract::RawCallBuilder::new_raw_deploy( 153 | provider, 154 | ::core::clone::Clone::clone(&BYTECODE), 155 | ) 156 | } 157 | /// Returns a reference to the address. 158 | #[inline] 159 | pub const fn address(&self) -> &alloy_sol_types::private::Address { 160 | &self.address 161 | } 162 | /// Sets the address. 163 | #[inline] 164 | pub fn set_address(&mut self, address: alloy_sol_types::private::Address) { 165 | self.address = address; 166 | } 167 | /// Sets the address and returns `self`. 168 | pub fn at(mut self, address: alloy_sol_types::private::Address) -> Self { 169 | self.set_address(address); 170 | self 171 | } 172 | /// Returns a reference to the provider. 173 | #[inline] 174 | pub const fn provider(&self) -> &P { 175 | &self.provider 176 | } 177 | } 178 | impl Permit2LibInstance { 179 | /// Clones the provider and returns a new instance with the cloned provider. 180 | #[inline] 181 | pub fn with_cloned_provider(self) -> Permit2LibInstance { 182 | Permit2LibInstance { 183 | address: self.address, 184 | provider: ::core::clone::Clone::clone(&self.provider), 185 | _network_transport: ::core::marker::PhantomData, 186 | } 187 | } 188 | } 189 | /// Function calls. 190 | #[automatically_derived] 191 | impl< 192 | T: alloy_contract::private::Transport + ::core::clone::Clone, 193 | P: alloy_contract::private::Provider, 194 | N: alloy_contract::private::Network, 195 | > Permit2LibInstance { 196 | /// Creates a new call builder using this contract instance's provider and address. 197 | /// 198 | /// Note that the call can be any function call, not just those defined in this 199 | /// contract. Prefer using the other methods for building type-safe contract calls. 200 | pub fn call_builder( 201 | &self, 202 | call: &C, 203 | ) -> alloy_contract::SolCallBuilder { 204 | alloy_contract::SolCallBuilder::new_sol(&self.provider, &self.address, call) 205 | } 206 | } 207 | /// Event filters. 208 | #[automatically_derived] 209 | impl< 210 | T: alloy_contract::private::Transport + ::core::clone::Clone, 211 | P: alloy_contract::private::Provider, 212 | N: alloy_contract::private::Network, 213 | > Permit2LibInstance { 214 | /// Creates a new event filter using this contract instance's provider and address. 215 | /// 216 | /// Note that the type can be any event, not just those defined in this contract. 217 | /// Prefer using the other methods for building type-safe event filters. 218 | pub fn event_filter( 219 | &self, 220 | ) -> alloy_contract::Event { 221 | alloy_contract::Event::new_sol(&self.provider, &self.address) 222 | } 223 | } 224 | } 225 | -------------------------------------------------------------------------------- /crates/bindings-uniswapx/src/storageslot.rs: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | Generated by the following Solidity interface... 4 | ```solidity 5 | interface StorageSlot {} 6 | ``` 7 | 8 | ...which was generated by the following JSON ABI: 9 | ```json 10 | [] 11 | ```*/ 12 | #[allow( 13 | non_camel_case_types, 14 | non_snake_case, 15 | clippy::pub_underscore_fields, 16 | clippy::style, 17 | clippy::empty_structs_with_brackets 18 | )] 19 | pub mod StorageSlot { 20 | use super::*; 21 | use alloy::sol_types as alloy_sol_types; 22 | /// The creation / init bytecode of the contract. 23 | /// 24 | /// ```text 25 | ///0x60556032600b8282823980515f1a607314602657634e487b7160e01b5f525f60045260245ffd5b305f52607381538281f3fe730000000000000000000000000000000000000000301460806040525f80fdfea26469706673582212202756757be558811381b6cc869ca827684846f0767da7e51643e305fafaad964d64736f6c63430008180033 26 | /// ``` 27 | #[rustfmt::skip] 28 | #[allow(clippy::all)] 29 | pub static BYTECODE: alloy_sol_types::private::Bytes = alloy_sol_types::private::Bytes::from_static( 30 | b"`U`2`\x0B\x82\x82\x829\x80Q_\x1A`s\x14`&WcNH{q`\xE0\x1B_R_`\x04R`$_\xFD[0_R`s\x81S\x82\x81\xF3\xFEs\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x000\x14`\x80`@R_\x80\xFD\xFE\xA2dipfsX\"\x12 'Vu{\xE5X\x81\x13\x81\xB6\xCC\x86\x9C\xA8'hHF\xF0v}\xA7\xE5\x16C\xE3\x05\xFA\xFA\xAD\x96MdsolcC\0\x08\x18\x003", 31 | ); 32 | /// The runtime bytecode of the contract, as deployed on the network. 33 | /// 34 | /// ```text 35 | ///0x730000000000000000000000000000000000000000301460806040525f80fdfea26469706673582212202756757be558811381b6cc869ca827684846f0767da7e51643e305fafaad964d64736f6c63430008180033 36 | /// ``` 37 | #[rustfmt::skip] 38 | #[allow(clippy::all)] 39 | pub static DEPLOYED_BYTECODE: alloy_sol_types::private::Bytes = alloy_sol_types::private::Bytes::from_static( 40 | b"s\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x000\x14`\x80`@R_\x80\xFD\xFE\xA2dipfsX\"\x12 'Vu{\xE5X\x81\x13\x81\xB6\xCC\x86\x9C\xA8'hHF\xF0v}\xA7\xE5\x16C\xE3\x05\xFA\xFA\xAD\x96MdsolcC\0\x08\x18\x003", 41 | ); 42 | use alloy::contract as alloy_contract; 43 | /**Creates a new wrapper around an on-chain [`StorageSlot`](self) contract instance. 44 | 45 | See the [wrapper's documentation](`StorageSlotInstance`) for more details.*/ 46 | #[inline] 47 | pub const fn new< 48 | T: alloy_contract::private::Transport + ::core::clone::Clone, 49 | P: alloy_contract::private::Provider, 50 | N: alloy_contract::private::Network, 51 | >( 52 | address: alloy_sol_types::private::Address, 53 | provider: P, 54 | ) -> StorageSlotInstance { 55 | StorageSlotInstance::::new(address, provider) 56 | } 57 | /**Deploys this contract using the given `provider` and constructor arguments, if any. 58 | 59 | Returns a new instance of the contract, if the deployment was successful. 60 | 61 | For more fine-grained control over the deployment process, use [`deploy_builder`] instead.*/ 62 | #[inline] 63 | pub fn deploy< 64 | T: alloy_contract::private::Transport + ::core::clone::Clone, 65 | P: alloy_contract::private::Provider, 66 | N: alloy_contract::private::Network, 67 | >( 68 | provider: P, 69 | ) -> impl ::core::future::Future< 70 | Output = alloy_contract::Result>, 71 | > { 72 | StorageSlotInstance::::deploy(provider) 73 | } 74 | /**Creates a `RawCallBuilder` for deploying this contract using the given `provider` 75 | and constructor arguments, if any. 76 | 77 | This is a simple wrapper around creating a `RawCallBuilder` with the data set to 78 | the bytecode concatenated with the constructor's ABI-encoded arguments.*/ 79 | #[inline] 80 | pub fn deploy_builder< 81 | T: alloy_contract::private::Transport + ::core::clone::Clone, 82 | P: alloy_contract::private::Provider, 83 | N: alloy_contract::private::Network, 84 | >(provider: P) -> alloy_contract::RawCallBuilder { 85 | StorageSlotInstance::::deploy_builder(provider) 86 | } 87 | /**A [`StorageSlot`](self) instance. 88 | 89 | Contains type-safe methods for interacting with an on-chain instance of the 90 | [`StorageSlot`](self) contract located at a given `address`, using a given 91 | provider `P`. 92 | 93 | If the contract bytecode is available (see the [`sol!`](alloy_sol_types::sol!) 94 | documentation on how to provide it), the `deploy` and `deploy_builder` methods can 95 | be used to deploy a new instance of the contract. 96 | 97 | See the [module-level documentation](self) for all the available methods.*/ 98 | #[derive(Clone)] 99 | pub struct StorageSlotInstance { 100 | address: alloy_sol_types::private::Address, 101 | provider: P, 102 | _network_transport: ::core::marker::PhantomData<(N, T)>, 103 | } 104 | #[automatically_derived] 105 | impl ::core::fmt::Debug for StorageSlotInstance { 106 | #[inline] 107 | fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { 108 | f.debug_tuple("StorageSlotInstance").field(&self.address).finish() 109 | } 110 | } 111 | /// Instantiation and getters/setters. 112 | #[automatically_derived] 113 | impl< 114 | T: alloy_contract::private::Transport + ::core::clone::Clone, 115 | P: alloy_contract::private::Provider, 116 | N: alloy_contract::private::Network, 117 | > StorageSlotInstance { 118 | /**Creates a new wrapper around an on-chain [`StorageSlot`](self) contract instance. 119 | 120 | See the [wrapper's documentation](`StorageSlotInstance`) for more details.*/ 121 | #[inline] 122 | pub const fn new( 123 | address: alloy_sol_types::private::Address, 124 | provider: P, 125 | ) -> Self { 126 | Self { 127 | address, 128 | provider, 129 | _network_transport: ::core::marker::PhantomData, 130 | } 131 | } 132 | /**Deploys this contract using the given `provider` and constructor arguments, if any. 133 | 134 | Returns a new instance of the contract, if the deployment was successful. 135 | 136 | For more fine-grained control over the deployment process, use [`deploy_builder`] instead.*/ 137 | #[inline] 138 | pub async fn deploy( 139 | provider: P, 140 | ) -> alloy_contract::Result> { 141 | let call_builder = Self::deploy_builder(provider); 142 | let contract_address = call_builder.deploy().await?; 143 | Ok(Self::new(contract_address, call_builder.provider)) 144 | } 145 | /**Creates a `RawCallBuilder` for deploying this contract using the given `provider` 146 | and constructor arguments, if any. 147 | 148 | This is a simple wrapper around creating a `RawCallBuilder` with the data set to 149 | the bytecode concatenated with the constructor's ABI-encoded arguments.*/ 150 | #[inline] 151 | pub fn deploy_builder(provider: P) -> alloy_contract::RawCallBuilder { 152 | alloy_contract::RawCallBuilder::new_raw_deploy( 153 | provider, 154 | ::core::clone::Clone::clone(&BYTECODE), 155 | ) 156 | } 157 | /// Returns a reference to the address. 158 | #[inline] 159 | pub const fn address(&self) -> &alloy_sol_types::private::Address { 160 | &self.address 161 | } 162 | /// Sets the address. 163 | #[inline] 164 | pub fn set_address(&mut self, address: alloy_sol_types::private::Address) { 165 | self.address = address; 166 | } 167 | /// Sets the address and returns `self`. 168 | pub fn at(mut self, address: alloy_sol_types::private::Address) -> Self { 169 | self.set_address(address); 170 | self 171 | } 172 | /// Returns a reference to the provider. 173 | #[inline] 174 | pub const fn provider(&self) -> &P { 175 | &self.provider 176 | } 177 | } 178 | impl StorageSlotInstance { 179 | /// Clones the provider and returns a new instance with the cloned provider. 180 | #[inline] 181 | pub fn with_cloned_provider(self) -> StorageSlotInstance { 182 | StorageSlotInstance { 183 | address: self.address, 184 | provider: ::core::clone::Clone::clone(&self.provider), 185 | _network_transport: ::core::marker::PhantomData, 186 | } 187 | } 188 | } 189 | /// Function calls. 190 | #[automatically_derived] 191 | impl< 192 | T: alloy_contract::private::Transport + ::core::clone::Clone, 193 | P: alloy_contract::private::Provider, 194 | N: alloy_contract::private::Network, 195 | > StorageSlotInstance { 196 | /// Creates a new call builder using this contract instance's provider and address. 197 | /// 198 | /// Note that the call can be any function call, not just those defined in this 199 | /// contract. Prefer using the other methods for building type-safe contract calls. 200 | pub fn call_builder( 201 | &self, 202 | call: &C, 203 | ) -> alloy_contract::SolCallBuilder { 204 | alloy_contract::SolCallBuilder::new_sol(&self.provider, &self.address, call) 205 | } 206 | } 207 | /// Event filters. 208 | #[automatically_derived] 209 | impl< 210 | T: alloy_contract::private::Transport + ::core::clone::Clone, 211 | P: alloy_contract::private::Provider, 212 | N: alloy_contract::private::Network, 213 | > StorageSlotInstance { 214 | /// Creates a new event filter using this contract instance's provider and address. 215 | /// 216 | /// Note that the type can be any event, not just those defined in this contract. 217 | /// Prefer using the other methods for building type-safe event filters. 218 | pub fn event_filter( 219 | &self, 220 | ) -> alloy_contract::Event { 221 | alloy_contract::Event::new_sol(&self.provider, &self.address) 222 | } 223 | } 224 | } 225 | --------------------------------------------------------------------------------