Skip to content

A collection of simple API integrations for Gnosis Protocol V2

Notifications You must be signed in to change notification settings

bh2smith/cowswap-integrations-py

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

⚠️ UNDER CONSTRUCTION ⚠️

Make an order through API CowSwap

Setup & Installation

python3 -m venv venv
source ./env/bin/activate
pip install -r requirements.txt

You will need to create your own .env file. A template exists here as .env.sample from which you can make your own by running the command cp .env.sample .env and filling in your own account details.

Placing an Order

Set your network and private key in .env.

Fill the variables in the cow_swap method of ./main.py

source .env
python -m src.main

If you run the script exactly as is with the public and private keys provided, you should receive an error from the orderbook API saying:

{"errorType":"InsufficientFunds","description":"order owner must have funds worth at least x in his account"}

CowSwap API Integrations & Tid Bits

A collection of python scripts and services built as simple integrations with Gnosis Protocol v2

[WIP] Trading Bot for Stable Coin Orders

Initially inspired by Martin's script. This integration is a simple bot which monitors the orderbook seeking open orders between stable coins. Assuming that, on average, USD stable coins are worth 1 USD, the bot is prepared to place a counter order for any swap willing to trade x of token A for y of token B when x < y. It is important to remember that execution fees must be factored into this decision-making process so that the counter order placed should net a result of strictly more tokens purchased than sold (including fees).

For this reason, the script is primarily intended to be run on xDai network where transaction fees are negligible.

To see the trading history of the bot currently running on xDai with this script check out this trade history table filtered by address 0xd2cc479be0512301d0b19c3c0a9300baa1e03758

[TODO] LP Token Solver

Design an HTTP solver which allow people to "swap" LP tokens

In essence, the solver will fetch the open orderbook, filtering for orders whose buy or sell token is an LP token. It will then encode the interactions necessary to enter or exit liquidity from the corresponding pool.

Advanced features

In the event that there is a coincidence of wants (a.k.a. a CoW), the solver could match the orders directly to reduce the cost of execution. Note that, A CoW in this scenario corresponds to a simultaneous desire to provide and withdraw liquidity from a specific pool.

About

A collection of simple API integrations for Gnosis Protocol V2

Topics

Resources

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •  

Languages