Skip to main content

A package for creating a directed graphs based on DeFi protocols

Project description

Defi Graph

This is package for creating and visualizing graphs in DeFi protocols.

Modules

  • Edge - describes a path bewtween tokens
  • Vertex - describes a token
  • Graph - describes a defi market
  • Pool - describes trading token pairs

Edge type

Edges store two main state:

  1. self.weight - a weight between two tokens
    • typeof float
    • {0,1} Depends on direction of edge
    • Calculated as -Math.log(self.pool.token_price_{0,1})
  2. self.pool - an instance of a token pool
    • typeof Pool
  3. self._tuple - Allows indexing/iteration of the edge object
    • typeof iter
    • Array of [Vertex1, Vertex2, (self.weight, Pool)]

Pool type

A pool object describing tokens:

  1. self.address - the address of the pool
    • typeof Hex checksum address
  2. self.token0 - a token described as a vertex
    • typeof Vertex
  3. self.token1 - a token described as a vertex
    • typeof Vertex
  4. self.token0_price - the price of token0
    • typeof float
  5. self.token1_price - the price of token1
    • typeof `float
  6. self.fee - describes the pool fee e.g Uniswap (100 | 500 | 1000 | 3000)
    • typeof int

Graph type

An adjacency list graph object desribing a defi market

  1. self.vertices - contains a list of all vertices
    • typeof List[Vertex]
  2. self.adjascency_list - a mapping describing edges in the graph
    • typeof Dict[Vertex, List[Edge]]
    • example: {Vertex: [Edge1, Edge2, Edge3, Edge4]}

Vertex type

A node on the graph describing a token

  1. self.name - name of the token
    • typeof string
  2. self.decimals - number of decimals for token
    • typeof int
  3. self.address - address of token
    • typeof Hex checksum address

Tests

Run tests:

pytest

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

defigraph-0.1.1.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

defigraph-0.1.1-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file defigraph-0.1.1.tar.gz.

File metadata

  • Download URL: defigraph-0.1.1.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.1

File hashes

Hashes for defigraph-0.1.1.tar.gz
Algorithm Hash digest
SHA256 22b5922170bbf8b2512792f08e6ab4761873d2cd101f4ab4b2024596dd314bfd
MD5 07aac820e300ddd2555f858a58888196
BLAKE2b-256 bb47b83764ed3e9b95167e65674ba5b8dc01138e2acbf83715849feaa0c3cc44

See more details on using hashes here.

File details

Details for the file defigraph-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for defigraph-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f75378a3f75662fd01ec5536a7498e04f5702ad64e5872d12a96e97790afa6b1
MD5 51522aefb03d35745147074965729106
BLAKE2b-256 4f06b3d94bcce03d430ba0e0e009c43abc2d07a26f9b8f9b2a4f46577d3c8f92

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page