# Cross Chain Trade Test (CCTT)
Test automated trades between multiple chains on Mach.
[PyPI](https://pypi.org/project/mach-cctt/)
[Test PyPI](https://test.pypi.org/project/mach-cctt/)
## Overview
Test automated trades on Mach. Specify a start chain and symbol, and a policy determining how the destination token will be chosen (randomize chain and symbol, randomize chain and fix symbol). In each trade, the test wallet's entire balance of the source token will be sold for the destination token, and then the destination token because the new source token for the next trade. This continues until the script is killed by the user.
## Usage
1. Install
```bash
python -m pip install mach-cctt
```
1. Usage
```bash
cctt --help
```
1. Example
```bash
# The script will create log files and an account data file. Make a working directory for it.
mkdir cctt/ && cd cctt/
# Set password to avoid being prompted
# export CCTT_PASSWORD="abc"
# Backend defaults to production, change if necessary
# export MACH_BACKEND_URL="https://cache-half-full-staging.fly.dev"
cctt import # Import account
cctt decrypt # Show public/private key
cctt balances # Show account balances
# Trade USDC on random chains, starting from optimism-USDC
cctt run --source optimism-USDC --destination-policy fixed:USDC
# Trade USDC on only arbitrum and optimism, starting from polygon-USDC
cctt run --source polygon-USDC --destination-policy cheap:USDC
# Trade between random tokens on random chains, starting from arbitrum-USDT
cctt run --source arbitrum-USDT --destination-policy random
# If the --source is empty, then an appropriate source with a non-zero balance is chosen for you.
cctt run --source --destination-policy random
```
Notes:
- You need to have a gas on every chain, or a gas of exactly 0 on chains that you do not wish the testing script to trade on, which will cause those chains to be disabled.
- The `--source` token should be one that you hold a non-zero balance of in your wallet. If you set it to empty, it will be automatically chosen as any token with a non-zero balance in the wallet.
- There is a known issue with trades filling for a single tick less than the order was placed at. As a preventative measure, any token balance of 1 tick in the wallet is treated as an empty balance.
## Log Files
There are 4 log files created by the application:
- `app.log` - everything
- `delayed_transactions.log` - the source funds where not withdrawn in time
- `stuck_transactions.log` - the source funds were withdrawn but the destination funds were not received in time
- `improper_fill.log` - the trade filled on the source chain for 1 tick less than the order was placed for. This has been observed to happen primarily to USDM (on multiple chains)
## Account File
A plaintext JSON file storing your account encrypted with your password will be created once you first generate or import a wallet. By default this file is called `account.json` but you can give a path to your own file via the `--file PATH` flag. This file is required to be present for any operation other than importing or generating a new wallet.
## Development
### Requirements
You need the [`just`](https://github.com/casey/just) command runner and either Python 3.12.5+ with `virtualenv`, or `pyenv`.
### Setup
1. **Clone the repository**
```bash
git clone https://github.com/tristeroresearch/cross-chain-trade-test.git
cd cross-chain-trade-test
```
1. **Create and activate a virtual environment**
Using `venv`:
```bash
python -m venv .venv
source .venv/bin/activate
```
Or using `pyenv`:
```bash
pyenv virtualenv 3.12.5 cctt
pyenv activate
```
1. **Install dependencies**
```bash
just init
```
1. **View available recipes**
```bash
just -l
```
Note that there are recipes that allow you to run the application in-source without needed to build and package to PyPI first:
```bash
just account_file=account.json import <private key> # Import a new account
just decrypt # Show public and private key
just balances # List balances of account
just source=arbitrum-USDC policy=random run # Run the trade tester, starting from arbitrum-USDC and trading to random tokens
just wallet=<public key> withdraw # Withdraw funds from the stored account to the given wallet
```
1. **Building**
```bash
just build
```
#### Packaging
Make sure to bump the version number in `pyproject.toml`.
To upload to the test PyPI:
```bash
just upload-test
```
To upload to the main PyPI:
```bash
just upload
```
Raw data
{
"_id": null,
"home_page": null,
"name": "mach-cctt",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.12.6",
"maintainer_email": null,
"keywords": "crypto, cryptocurrencies, cryptocurrency, defi, exchange, liquidity, mach, pool, swap, tristero",
"author": "Marwan Hassanien",
"author_email": "Richard Dong <richard@tristero.xyz>",
"download_url": "https://files.pythonhosted.org/packages/d8/b1/ffea420bb1ab0b6dd1e095e8486f9638ded0ea4e6d28c5bdefa206b75a32/mach_cctt-0.0.125.tar.gz",
"platform": null,
"description": "# Cross Chain Trade Test (CCTT)\n\nTest automated trades between multiple chains on Mach.\n\n[PyPI](https://pypi.org/project/mach-cctt/)\n\n[Test PyPI](https://test.pypi.org/project/mach-cctt/)\n\n## Overview\n\nTest automated trades on Mach. Specify a start chain and symbol, and a policy determining how the destination token will be chosen (randomize chain and symbol, randomize chain and fix symbol). In each trade, the test wallet's entire balance of the source token will be sold for the destination token, and then the destination token because the new source token for the next trade. This continues until the script is killed by the user.\n\n## Usage\n\n1. Install\n\n ```bash\n python -m pip install mach-cctt\n ```\n\n1. Usage\n\n ```bash\n cctt --help\n ```\n\n1. Example\n\n ```bash\n # The script will create log files and an account data file. Make a working directory for it.\n mkdir cctt/ && cd cctt/\n\n # Set password to avoid being prompted\n # export CCTT_PASSWORD=\"abc\"\n\n # Backend defaults to production, change if necessary\n # export MACH_BACKEND_URL=\"https://cache-half-full-staging.fly.dev\"\n \n cctt import # Import account\n cctt decrypt # Show public/private key\n cctt balances # Show account balances\n\n # Trade USDC on random chains, starting from optimism-USDC\n cctt run --source optimism-USDC --destination-policy fixed:USDC\n\n # Trade USDC on only arbitrum and optimism, starting from polygon-USDC\n cctt run --source polygon-USDC --destination-policy cheap:USDC\n\n # Trade between random tokens on random chains, starting from arbitrum-USDT\n cctt run --source arbitrum-USDT --destination-policy random\n \n # If the --source is empty, then an appropriate source with a non-zero balance is chosen for you.\n cctt run --source --destination-policy random\n ```\n\n Notes:\n\n - You need to have a gas on every chain, or a gas of exactly 0 on chains that you do not wish the testing script to trade on, which will cause those chains to be disabled.\n - The `--source` token should be one that you hold a non-zero balance of in your wallet. If you set it to empty, it will be automatically chosen as any token with a non-zero balance in the wallet.\n - There is a known issue with trades filling for a single tick less than the order was placed at. As a preventative measure, any token balance of 1 tick in the wallet is treated as an empty balance.\n\n## Log Files\n\nThere are 4 log files created by the application:\n\n- `app.log` - everything\n- `delayed_transactions.log` - the source funds where not withdrawn in time\n- `stuck_transactions.log` - the source funds were withdrawn but the destination funds were not received in time\n- `improper_fill.log` - the trade filled on the source chain for 1 tick less than the order was placed for. This has been observed to happen primarily to USDM (on multiple chains)\n\n## Account File\n\nA plaintext JSON file storing your account encrypted with your password will be created once you first generate or import a wallet. By default this file is called `account.json` but you can give a path to your own file via the `--file PATH` flag. This file is required to be present for any operation other than importing or generating a new wallet.\n\n## Development\n\n### Requirements\n\nYou need the [`just`](https://github.com/casey/just) command runner and either Python 3.12.5+ with `virtualenv`, or `pyenv`.\n\n### Setup\n\n1. **Clone the repository**\n\n ```bash\n git clone https://github.com/tristeroresearch/cross-chain-trade-test.git\n cd cross-chain-trade-test\n ```\n\n1. **Create and activate a virtual environment**\n\n Using `venv`:\n\n ```bash\n python -m venv .venv\n source .venv/bin/activate\n ```\n\n Or using `pyenv`:\n\n ```bash\n pyenv virtualenv 3.12.5 cctt\n pyenv activate\n ```\n\n1. **Install dependencies**\n\n ```bash\n just init\n ```\n\n1. **View available recipes**\n\n ```bash\n just -l\n ```\n\n Note that there are recipes that allow you to run the application in-source without needed to build and package to PyPI first:\n\n ```bash\n just account_file=account.json import <private key> # Import a new account\n just decrypt # Show public and private key\n just balances # List balances of account\n just source=arbitrum-USDC policy=random run # Run the trade tester, starting from arbitrum-USDC and trading to random tokens\n just wallet=<public key> withdraw # Withdraw funds from the stored account to the given wallet\n ```\n\n1. **Building**\n\n ```bash\n just build\n ```\n\n#### Packaging\n\nMake sure to bump the version number in `pyproject.toml`.\n\nTo upload to the test PyPI:\n\n```bash\njust upload-test\n```\n\nTo upload to the main PyPI:\n\n```bash\njust upload\n```\n",
"bugtrack_url": null,
"license": null,
"summary": "Test automated trades on the Mach exchange.",
"version": "0.0.125",
"project_urls": {
"Homepage": "https://github.com/tristeroresearch/cross-chain-trade-test",
"Issues": "https://github.com/tristeroresearch/cross-chain-trade-test/issues"
},
"split_keywords": [
"crypto",
" cryptocurrencies",
" cryptocurrency",
" defi",
" exchange",
" liquidity",
" mach",
" pool",
" swap",
" tristero"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "6bf33b1f15e0ef5db192861e120feb9595514884b3da805eb13b650718bc3e18",
"md5": "d8456a660459fcdd1679d8058ca781af",
"sha256": "ae8307a39837aec342fe177ea40e133cf4afa47f42370b13870f4d46735a9de4"
},
"downloads": -1,
"filename": "mach_cctt-0.0.125-py3-none-any.whl",
"has_sig": false,
"md5_digest": "d8456a660459fcdd1679d8058ca781af",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.12.6",
"size": 50874,
"upload_time": "2024-11-07T21:13:05",
"upload_time_iso_8601": "2024-11-07T21:13:05.253590Z",
"url": "https://files.pythonhosted.org/packages/6b/f3/3b1f15e0ef5db192861e120feb9595514884b3da805eb13b650718bc3e18/mach_cctt-0.0.125-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "d8b1ffea420bb1ab0b6dd1e095e8486f9638ded0ea4e6d28c5bdefa206b75a32",
"md5": "c1091acc401c051e808821282f035a95",
"sha256": "62b5d115d970173f656640acad7bd3a8111557e855622fcd4fbeea2e5f213d90"
},
"downloads": -1,
"filename": "mach_cctt-0.0.125.tar.gz",
"has_sig": false,
"md5_digest": "c1091acc401c051e808821282f035a95",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.12.6",
"size": 37444,
"upload_time": "2024-11-07T21:13:07",
"upload_time_iso_8601": "2024-11-07T21:13:07.275499Z",
"url": "https://files.pythonhosted.org/packages/d8/b1/ffea420bb1ab0b6dd1e095e8486f9638ded0ea4e6d28c5bdefa206b75a32/mach_cctt-0.0.125.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-07 21:13:07",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "tristeroresearch",
"github_project": "cross-chain-trade-test",
"github_not_found": true,
"lcname": "mach-cctt"
}