Skip to content

Initial Token Test w Y2K #1

@0x0scion

Description

@0x0scion

Simulate the Balancer Y2K pool (80% Y2K | 20% WETH):

  1. add Balancer datasource
    subgraph:
    https://thegraph.com/hosted-service/subgraph/balancer-labs/balancer-arbitrum-v2

Y2K-WETH pair: 0x569061e2d807881f4a33e1cbe1063bc614cb75a4
https://arbiscan.io/address/0x569061e2d807881f4a33e1cbe1063bc614cb75a4
poolId (for subgraph queries): 0x569061e2d807881f4a33e1cbe1063bc614cb75a40002000000000000000002bb

  1. Query all swaps for a given time period (start small - past couple of days)
  2. Create back-test that will reconstruct the Y2K price for the time period:
  • starting price (query tokenPrices for filtering for approx timestamp)
  • starting liquidity (query poolSnapshots)
  • for each swap, use the spotPrice formula from here: https://docs.balancer.fi/reference/math/weighted-math.html#invariant to update price (can ignore fees for now)
  • output a single graph of price
  • bonus plot against actual price (again using tokenPrices)

reference queries:

{
  pool(id: "0x569061e2d807881f4a33e1cbe1063bc614cb75a40002000000000000000002bb") {
    address
  }
  swaps(first: 5, where:{poolId:"0x569061e2d807881f4a33e1cbe1063bc614cb75a40002000000000000000002bb"}) {
    id
    tokenIn
    tokenIn
    tokenAmountIn
    tokenAmountOut
    timestamp
    poolId {
      id
    }
    
  }
  tokenPrices(first: 10, where:{poolId: "0x569061e2d807881f4a33e1cbe1063bc614cb75a40002000000000000000002bb"}){
    price
    asset
    timestamp
  }
  poolSnapshots(first: 10, where:{pool: "0x569061e2d807881f4a33e1cbe1063bc614cb75a40002000000000000000002bb"}){
    amounts
    timestamp
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions