Skip to content

Commit

Permalink
⚡️ uv lint rules and docummentation
Browse files Browse the repository at this point in the history
  • Loading branch information
mmsaki committed Nov 16, 2024
1 parent d8706e1 commit 1b3380e
Show file tree
Hide file tree
Showing 13 changed files with 2,245 additions and 567 deletions.
53 changes: 31 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,65 +1,74 @@
# Defi Graph

![GitHub](https://img.shields.io/github/license/mmsaki/defigraph)
![GitHub repo size](https://img.shields.io/github/repo-size/mmsaki/defigraph)
![GitHub last commit](https://img.shields.io/github/last-commit/mmsaki/defigraph)
![PyPI - Version](https://img.shields.io/pypi/v/defigraph)
![PyPI - Downloads](https://img.shields.io/pypi/dm/defigraph)
![GitHub top language](https://img.shields.io/github/languages/top/mmsaki/defigraph)

![X (formerly Twitter) Follow](https://img.shields.io/twitter/follow/msakiart)

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

## Modules

- [x] [Edge](src/defigraph/Edge.py) - describes a path bewtween tokens
- [x] [Vertex](src/defigraph/Vertex.py) - describes a token
- [x] [Graph](src/defigraph/Graph.py) - describes a defi market
- [x] [Pool](src/defigraph/Pool.py) - describes trading token pairs
- [x] [Edge](#edge-type) - describes a path between tokens
- [x] [Vertex](#vertex-type) - describes a token
- [x] [Graph](#graph-type) - describes a defi market
- [x] [Pool](#pool-type) - 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})`
- typeof `float`
- `{0,1}` Depends on direction of edge
- Calculated as `-Math.log(self.pool.token_price_{0,1})`
1. `self.pool` - an instance of a token pool
- typeof `Pool`
- typeof `Pool`
1. `self._tuple` - Allows indexing/iteration of the edge object
- typeof `iter`
- Array of `[Vertex1, Vertex2, (self.weight, Pool)]`
- 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
- typeof `Hex` checksum address
1. `self.token0` - a token described as a vertex
- typeof `Vertex`
- typeof `Vertex`
1. `self.token1` - a token described as a vertex
- typeof `Vertex`
- typeof `Vertex`
1. `self.token0_price` - the price of token0
- typeof `float`
- typeof `float`
1. `self.token1_price` - the price of token1
- typeof `float
- typeof `float
1. `self.fee` - describes the pool fee e.g Uniswap (100 | 500 | 1000 | 3000)
- typeof `int`
- 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]`
- typeof `List[Vertex]`
1. `self.adjascency_list` - a mapping describing edges in the graph
- typeof `Dict[Vertex, List[Edge]]`
- example: {Vertex: [Edge1, Edge2, Edge3, Edge4]}
- 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`
- typeof `string`
1. `self.decimals` - number of decimals for token
- typeof `int`
- typeof `int`
1. `self.address` - address of token
- typeof `Hex` checksum address
- typeof `Hex` checksum address

## Tests

Expand Down
Loading

0 comments on commit 1b3380e

Please sign in to comment.