Skip to content

Commit

Permalink
🥞 clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
mmsaki committed Oct 15, 2024
1 parent 431afed commit e733757
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 128 deletions.
3 changes: 3 additions & 0 deletions src/defigraph/Edge.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
from defigraph.Vertex import Vertex
from defigraph.Pool import Pool

class Edge:
def __init__(self, u: Vertex, v: Vertex, weight: float=None):
self.u = u
self.v = v
self.weight = weight
address = ""
self.pool = Pool(address=address,token0=u, token1=v)

def __repr__(self):
if not self.weight:
Expand Down
3 changes: 1 addition & 2 deletions src/defigraph/Edge_test.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import unittest

class TestEdgeMethods(unittest.TestCase):
pass

"""Test class for Edge methods"""

if __name__ == "__main__":
unittest.main()
114 changes: 1 addition & 113 deletions src/defigraph/Graph_test.py
Original file line number Diff line number Diff line change
@@ -1,116 +1,4 @@
import unittest

class TestGraphMethods(unittest.TestCase):
pass





example = [{'token0': {'decimals': '6',
'id': '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
'name': 'USD//C',
'symbol': 'USDC'},
'token0Price': '2641.142903892657526061976507543203',
'token1': {'decimals': '18',
'id': '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
'name': 'Wrapped Ether',
'symbol': 'WETH'},
'token1Price': '0.0003786239656044913627135607719183758'},
{'token0': {'decimals': '18',
'id': '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
'name': 'Wrapped Ether',
'symbol': 'WETH'},
'token0Price': '0.0003786580802251639838481269011846667',
'token1': {'decimals': '6',
'id': '0xdac17f958d2ee523a2206206994597c13d831ec7',
'name': 'Tether USD',
'symbol': 'USDT'},
'token1Price': '2640.904954161715813793523450379703'},
{'token0': {'decimals': '18',
'id': '0xa47c8bf37f92abed4a126bda807a7b7498661acd',
'name': 'Wrapped UST Token',
'symbol': 'UST'},
'token0Price': '172.3285469089209495097152810118144',
'token1': {'decimals': '18',
'id': '0xc8d674114bac90148d11d3c1d33c61835a0f9dcd',
'name': 'Wrapped Mirror NFLX Token',
'symbol': 'mNFLX'},
'token1Price': '0.00580286910054733884454595992314855'},
{'token0': {'decimals': '18',
'id': '0x6b175474e89094c44da98b954eedeac495271d0f',
'name': 'Dai Stablecoin',
'symbol': 'DAI'},
'token0Price': '2642.084702975490249791028895791357',
'token1': {'decimals': '18',
'id': '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
'name': 'Wrapped Ether',
'symbol': 'WETH'},
'token1Price': '0.0003784890010807790028953257550626265'},
{'token0': {'decimals': '18',
'id': '0x637f415687b7b2545ef2cd8dcc1614e1cc175850',
'name': 'TajiriRyujin',
'symbol': 'RYU'},
'token0Price': '81468030.3573833857207250048983931',
'token1': {'decimals': '18',
'id': '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
'name': 'Wrapped Ether',
'symbol': 'WETH'},
'token1Price': '0.00000001227475361332791519300474916649763'},
{'token0': {'decimals': '0',
'id': '0x05934eba98486693aaec2d00b0e9ce918e37dc3f',
'name': "You don't blacklist delta.financial",
'symbol': 'SCAMMY'},
'token0Price': '1076485.935308498746627553589949114',
'token1': {'decimals': '18',
'id': '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
'name': 'Wrapped Ether',
'symbol': 'WETH'},
'token1Price': '0.00000092894850476'},
{'token0': {'decimals': '0',
'id': '0x3d7e683fc9c86b4d653c9e47ca12517440fad14e',
'name': "You don't blacklist delta.financial",
'symbol': 'welp'},
'token0Price': '1077914.955160846266961089909716836',
'token1': {'decimals': '18',
'id': '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
'name': 'Wrapped Ether',
'symbol': 'WETH'},
'token1Price': '0.0000009277169736'},
{'token0': {'decimals': '18',
'id': '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
'name': 'Wrapped Ether',
'symbol': 'WETH'},
'token0Price': '0.000000928945984824',
'token1': {'decimals': '0',
'id': '0xfae9c647ad7d89e738aba720acf09af93dc535f7',
'name': "You don't blacklist delta.financial",
'symbol': 'Ian Laphan fan token'},
'token1Price': '1076488.855473617272336191473965162'},
{'token0': {'decimals': '0',
'id': '0x7296368fe9bcb25d3ecc19af13655b907818cc09',
'name': "You don't blacklist delta.financial",
'symbol': 'generalize fix for rebass tokens'},
'token0Price': '1078042.756852850056954751364743746',
'token1': {'decimals': '18',
'id': '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
'name': 'Wrapped Ether',
'symbol': 'WETH'},
'token1Price': '0.000000927606992991'},
{'token0': {'decimals': '18',
'id': '0x9ea3b5b4ec044b70375236a281986106457b20ef',
'name': 'DELTA.financial - deep DeFi derivatives',
'symbol': 'DELTA'},
'token0Price': '42330.47390705461472683958950540331',
'token1': {'decimals': '18',
'id': '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
'name': 'Wrapped Ether',
'symbol': 'WETH'},
'token1Price': '0.00002362364291492952789245145740281717'}]

if __name__ == "__main__":
unittest.main()




"""Test class for Graph methods"""
8 changes: 4 additions & 4 deletions src/defigraph/Pool.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from defigraph.Vertex import Vertex

class Pool:
def __init__(self, address, chainId, token0, token1, liquidity):
def __init__(self, address: str, token0: Vertex, token1: Vertex):
self.address = address
self.chainId = chainId
self.token0 = token0
self.token1 = token1
self.liquidity = liquidity
self.token1 = token1
6 changes: 1 addition & 5 deletions src/defigraph/Vertex.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
from typing import Optional, Union
from defigraph.Pool import Pool

class Vertex:
def __init__(self, name: Optional[Union[str,int]], pool: Pool, decimals: int):
def __init__(self, name: str, decimals: int):
self.name = name
self.pool = pool
self.decimals = decimals

def __repr__(self):
Expand Down
15 changes: 11 additions & 4 deletions src/defigraph/Vertex_test.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
import unittest
from graph.Vertex import Vertex
from defigraph.Vertex import Vertex

class TestVertexMethods(unittest.TestCase):
"""Test class for Edge methods"""

def setUp(self):
self.vertex = Vertex("WETH")
name = "WETH"
decimals = 18
self.vertex = Vertex(name=name,decimals=decimals)

def test_vertex_has_value(self):
assert self.vertex.value is not None
def test_vertex_has_name(self):
assert self.vertex.name is not None

def test_vertex_has_decimals(self):
assert self.vertex.decimals is not None

def tearDown(self):
return super().tearDown()
Expand Down

0 comments on commit e733757

Please sign in to comment.