Yto4ka & Bancor
Hey Bancor, how about we sketch a token that turns volatility into a profit engine? I hate boring models, so bring your data crunching and I'll bring the chaos.
Sure, but first we need a clear mechanism, risk model, and data points to validate that volatility can be reliably turned into profit. Let me know the assumptions.
Sure thing. Here’s the skeleton:
**Mechanism**
1. Spot‑price feeds + real‑time VIX‑style vol index.
2. Bot scans for mispriced “variance swaps” or options relative to the spot.
3. It locks in a forward variance position, then hedges the delta with the spot.
4. As the implied vol rises or falls, the variance position moves opposite to the spot, locking in a spread.
5. All trades are auto‑liquidated if slippage exceeds a set threshold.
**Risk model**
- **VaR & Expected Shortfall** over 1‑day horizon, recalculated every 5 minutes.
- **Stress tests**: 2σ drop in spot, 3σ jump in vol, liquidity freeze.
- **Counterparty check**: 70 % of volume on top 10 DEXs with 2‑step escrow.
- **Transaction‑cost buffer**: 0.3 % of trade value per side, built into the spread target.
**Data points for validation**
- Historical daily spot‑price series of the token (5‑min bars).
- Daily closing values of the token’s implied vol index.
- Order‑book depth snapshots every minute to gauge slippage.
- Past variance‑swap or option pricing data (if available).
- Liquidity metrics: average trade size, bid‑ask spread.
**Assumptions**
- The token’s vol is driven mainly by supply‑demand imbalance, not regulatory shock.
- The market for variance or options is liquid enough to support our hedges.
- No sudden black‑swan events that wipe out liquidity overnight.
- Transaction costs stay below 0.5 % of trade value; if they climb, we shut down.
If you can pull those data points and we confirm the assumptions, we’ll have a working prototype. Let me know if you need anything tweaked.
Looks solid. I’ll start pulling the 5‑minute spot and volatility feeds and compute the variance swap pricing model. I’ll also set up a 5‑minute VaR loop with a 0.3 % transaction‑cost buffer. If the implied vol data is sparse, we’ll need to interpolate, but that’s a minor tweak. Let me know which data feeds you’ll use for the order‑book snapshots. Once I have the initial dataset, we can run a backtest to confirm the spread targets hold up under the stress scenarios you outlined.
Use the top 3 DEXs that list the token: Uniswap v3, SushiSwap, and Curve (if it’s a stablecoin pair). Pull the 5‑minute depth snapshots via their GraphQL endpoints or directly from the subgraph for each pool. Grab the top 10 levels on both sides, calculate the weighted average price, and store the spread. That’ll give you enough depth to gauge slippage and run your VaR loop. Once you’ve got that, hit me with the backtest data.
I don’t have the ability to pull live data or run backtests myself. I can walk you through setting up the queries for Uniswap v3, SushiSwap, and Curve’s subgraphs, or help you script the 5‑minute depth pulls and VaR loop if you want to do it on your end. Just let me know what you need next.
Okay, give me the subgraph URLs and the GraphQL query template for each platform. I’ll plug those into a script that pulls the top 10 depth levels every 5 minutes and logs the weighted price. Then we can feed that into the VaR loop. Just keep the queries snappy; I don’t want to waste time on a bloated payload. Let's get this rolling.
**Subgraph endpoints**
- Uniswap v3 – https://api.thegraph.com/subgraphs/name/uniswap/uniswap-v3
- SushiSwap – https://api.thegraph.com/subgraphs/name/sushiswap/exchange
- Curve – https://api.thegraph.com/subgraphs/name/curvefi/curve
**GraphQL query templates**
---
### 1. Uniswap v3
*Get the top 10 tick levels above and below the current price (each tick gives a price and liquidity).*
```graphql
query($poolAddress: Bytes!, $ticksAbove: Int!, $ticksBelow: Int!) {
pool(id: $poolAddress) {
tickCurrentIndex
ticks(first: $ticksAbove, orderBy: tickIdx, orderDirection: asc, where: { tickIdx_gt: $tickCurrentIndex }) {
tickIdx
liquidityNet
}
ticks(first: $ticksBelow, orderBy: tickIdx, orderDirection: desc, where: { tickIdx_lt: $tickCurrentIndex }) {
tickIdx
liquidityNet
}
}
}
```
*Variables example:*
```json
{
"poolAddress": "0x... (token‑token pool address)",
"ticksAbove": 10,
"ticksBelow": 10
}
```
*Post‑processing:*
Convert each `tickIdx` to a price (price = 1.0001^tickIdx * sqrtPriceX96 / 2^96), then weight by `liquidityNet` to get the weighted average price for the ask and bid sides.
---
### 2. SushiSwap
*Pool reserves give the best price (no depth in the subgraph). Use the `reserve0` and `reserve1` to calculate the price and then pull the on‑chain order book if needed.*
```graphql
query($pairAddress: Bytes!) {
pair(id: $pairAddress) {
reserve0
reserve1
totalSupply
token0 { id }
token1 { id }
}
}
```
*Variables example:*
```json
{
"pairAddress": "0x... (pair address)"
}
```
*Post‑processing:*
Price = reserve1 / reserve0 (if token0 is the base). For depth, you’ll need an on‑chain call to the pool contract or a 3rd‑party service; the subgraph can’t give you top‑10 levels.
---
### 3. Curve
*For a stablecoin pool, the subgraph lists the balances of each coin. The best price is the ratio of balances.*
```graphql
query($poolAddress: Bytes!) {
pool(id: $poolAddress) {
balances
coins
totalSupply
}
}
```
*Variables example:*
```json
{
"poolAddress": "0x... (stablecoin pool address)"
}
```
*Post‑processing:*
Take `balances[i] / balances[j]` for the two coins of interest to get the spot price. Like SushiSwap, the subgraph doesn’t expose depth; you’ll need to query the contract or a depth provider for tick data.
---
**Quick tip for your script**
1. Hit each endpoint with the query above every 5 minutes.
2. For Uniswap, map the ticks to prices and weight by liquidityNet to compute the weighted bid/ask average.
3. Store the timestamp, weighted bid, weighted ask, and the spread (`ask - bid`).
4. Feed that time‑series into your VaR loop.
That’s all the payload you need—minimal data, enough for depth and spread estimation. Good luck!