This repo is being used as part of the crvUSD Risk Modeling effort.
As part of the crvUSD Risk Modeling effort, we have been storing quotes from the 1Inch Swap API for certain tokens pertaining to the crvUSD ecosystem (a full list can be found in src.configs.tokens.py
and is reproduced below).
We query random trade sizes for each token pair every hour to generate a price impact curve
. This allows us to model the expected price impact of traders arbitraging the various pools connected to Curve's new stablecoin. In turn, this gives us a reasonable idea of when price-sensitive arbitrageur would or would not arbitrage mispricings in these pools. A more detailed explanation of how these price impact curves are used can be found here: https://github.com/xenophonlabs/crvUSDrisk/blob/main/notebooks/demo_slippage_curves.ipynb
.
Sample quotes for WETH -> USDC between December 1, 2023 and December 8, 2023.
Sample price impact curve for WETH -> USDC between December 1, 2023 and December 8, 2023.
All pairwise combinations of the below tokens have been stored every hour since Thursday, November 16, 2023 at 6pm UTC.
All API requests should be made to the base URL: http://97.107.138.106/
with the endpoint quotes
.
Below, we query quotes for all pairs of the supported tokens from December 12, 2023 to December 13, 2023. Notice that the start
and end
parameters are REQUIRED and that we use the --compressed
flag to speed up the query.
curl --compressed "http://97.107.138.106/quotes?&start=1702166400&end=1702252800"
Please refer to notebooks/demo_slippage_curves.ipynb
for a more detailed example.
Note that Python's requests
will handle the gzip
compression automatically.
Parameter | Description | Default Value | Required |
---|---|---|---|
start | The start timestamp to get quotes for. | None | Yes |
end | The end timestamp to get quotes for. | None | Yes |
tokens | Comma-separated string of token addresses to get quotes for. All pairwise permutations of the provided tokens will be fetched. If not provided, all token pairs are returned. | None | No |
cols | Comma-separated string of columns to return. If not provided, the following are returned: [src , dst , in_amount , out_amount , price , price_impact , timestamp ]. |
None | No |
process | Whether to process the quotes. If processed, the returned quotes will be grouped by hour and a price_impact column will be added. Refer to src.db.datahandler.DataHandler.process_quotes . |
True | No |
include-ref-price | Whether to include the inferred reference price for the price impact calc. | False | No |
Quotes for all pairwise permutations of the given tokens
will be fetched (as long as they are supported).
For example: tokens=USDC,USDT,WETH
will return quotes for:
- WETH -> USDC
- USDC -> WETH
- USDT -> USDC
- USDC -> USDT
- USDT -> WETH
- WETH -> USDT
Please note the parameter should specify token addresses not symbols.
There are a couple things we are still working on here:
-
Cache common responses.
-
Acquire and configure a domain name.
-
Add more tokens to our queries.