https://github.com/cowprotocol/univ3-api
https://github.com/cowprotocol/univ3-api
Last synced: 10 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/cowprotocol/univ3-api
- Owner: cowprotocol
- License: gpl-3.0
- Created: 2022-04-08T08:36:04.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2025-07-31T14:24:44.000Z (11 months ago)
- Last Synced: 2025-08-03T16:45:38.424Z (10 months ago)
- Language: TypeScript
- Size: 93.8 KB
- Stars: 2
- Watchers: 7
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Introduction
Runs the uniswap routing algorithm behind an http api. Intended to be used as a single order solver by the driver.
# Setup
Developed with node v17.8.0.
```
npm install
npm run start
```
Uses the environment variables NODE_URL, HOST, PORT.
The application accepts post requests on `/estimate`. The body of the request and the response are json. See `interface Request` and `interface Response` in `src/app.ts` or the example requests and example response below.
# Testing
Here are some test requests that have been useful during development.
weth 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2 18 decimals
usdc 0xdAC17F958D2ee523a2206206994597C13D831ec7 6 decmials
Sell 1 weth for usdt
```json
{
"type": "sell",
"token_in": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
"token_out": "0xdAC17F958D2ee523a2206206994597C13D831ec7",
"amount": "1000000000000000000",
"recipient": "0x0000000000000000000000000000000000000000"
}
```
Buy 1 weth with usdt:
```json
{
"type": "buy",
"token_in": "0xdAC17F958D2ee523a2206206994597C13D831ec7",
"token_out": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
"amount": "1000000000000000000",
"recipient": "0x0000000000000000000000000000000000000000"
}
```
Sell 1000 usdt for eth:
```json
{
"type": "sell",
"token_in": "0xdAC17F958D2ee523a2206206994597C13D831ec7",
"token_out": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
"amount": "1000000000",
"recipient": "0x0000000000000000000000000000000000000000"
}
```
Buy 1000 usdt with eth:
```json
{
"type": "buy",
"token_in": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
"token_out": "0xdAC17F958D2ee523a2206206994597C13D831ec7",
"amount": "1000000000",
"recipient": "0x0000000000000000000000000000000000000000"
}
```
Example response:
```json
{
"quote": "284671676368727715",
"gas": "113000",
"gas_price": "45790763269",
"call_data": "0x5ae401dc00000000000000000000000000000000000000000000000000000000000003e800000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000e45023b4df000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec700000000000000000000000000000000000000000000000000000000000001f40000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003b9aca0000000000000000000000000000000000000000000000000003f3dcd5c8a5924e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"call_value": "0x00"
}
```