https://github.com/byteball/oswap-triangular-arb
Triangular arbitrage among Oswap pools
https://github.com/byteball/oswap-triangular-arb
Last synced: about 1 year ago
JSON representation
Triangular arbitrage among Oswap pools
- Host: GitHub
- URL: https://github.com/byteball/oswap-triangular-arb
- Owner: byteball
- Created: 2023-06-29T09:19:36.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-10-17T07:09:10.000Z (over 1 year ago)
- Last Synced: 2025-04-14T14:17:33.129Z (about 1 year ago)
- Language: JavaScript
- Size: 42 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Autonomous agent and bot for triangular arbitrage among Oswap pools
The bot finds triangles among Oswap pools, such as AB-BC-CA (where A, B, and C are tokens), and looks for opportunities to make money by trading along the triangle, e.g.:
1. swap A to B via pool AB
1. swap B received in the previous step to swap it to C via pool BC
1. swap C received in the previous step to swap it to A via pool CA
If the amount of A received in the final step is greater than the input amount in the first step, an arbitrage opportunity exists, and the bot trades.
The trades are executed by an AA that stores the trading capital and ensures that either all 3 trades succeed or none, and that it earns a profit. The AA is triggered by the companion bot when it sees an opportunity for a profitable arbitrage.
## Usage
The base AA is already deployed (see its addresses by opening `oswap-triangular-arb.oscript` in VS Code with [Oscript plugin](https://marketplace.visualstudio.com/items?itemName=obyte.oscript-vscode-plugin)), deploy your personal arbitrage AA by indicating your address in the `owner` field of your `conf.json` and running
```bash
node deploy.js
```
This deploys an arb AA whose capital is in GBYTE and all triangles must have two GBYTE pairs. Edit the `deploy.js` script to deploy a bot with a different main asset.
Run the bot:
```bash
node run.js oswap-triangular-arb 2>errlog
```
Add some money to your arb AA and a small amount (for network fees) to the bot's balance.
### Run tests
```bash
yarn test
```