https://github.com/manifoldfinance/simulate-swap
Realtime simulation for a swap or any transaction, on Ethereum, through BlockSec API.
https://github.com/manifoldfinance/simulate-swap
Last synced: about 1 month ago
JSON representation
Realtime simulation for a swap or any transaction, on Ethereum, through BlockSec API.
- Host: GitHub
- URL: https://github.com/manifoldfinance/simulate-swap
- Owner: manifoldfinance
- License: mit
- Created: 2023-01-14T16:12:52.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2023-01-14T16:19:00.000Z (over 2 years ago)
- Last Synced: 2025-08-28T17:00:45.004Z (about 1 month ago)
- Language: Python
- Size: 15.6 KB
- Stars: 14
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Simualte a swap BlockSec API
Run a realtime simulation for a swap or any transaction, on Ethereum, through [BlockSec API](https://docs.blocksec.com/mopsus/pre-execution-api).
## Install
[Poetry](https://python-poetry.org/) is used to manage the project.```bash
poetry install
```## Setup
[BlockSec API](https://docs.blocksec.com/mopsus/pre-execution-api) is used for simulation. Please attain an access token and save it to `.env` in the format given in `.env.example`.e.g.
```bash
export token=eyJ...-aU
```then run
```bash
source .env
```
## Run simulation for a swap
Example
```bash
poetry run simulate_swap/main.py --token_in 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2 --token_out 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48 --value 1000000000000000000
```Simulation results are saved to `results` folder. [See example output](results/1673709882.json)
Options for swap simulations:
- `--token_in` - address of token to swap in
- `--token_out` - address of token to swap out
- `--value` - amount of eth to send in (default=0)
- `--amount_in` - amount of token in to swap (default=0)
- `--sender` - address of sender / receiver of swap (default=heavy-eth-address)
- `--receiver` - address of router (default=open-mev-router)
- `--gas_limit` - first estimate of gas limit (default=1000000)
- `--amount_out_min` - min amount out required (default=0)Use `--help` for reference.
```bash
poetry run simulate_swap/main.py --help
```