From e733757ebc5512e746c0828de5d70846c59fc577 Mon Sep 17 00:00:00 2001 From: Meek Msaki <98189596+mmsaki@users.noreply.github.com> Date: Tue, 15 Oct 2024 18:07:26 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=A5=9E=20clean=20up?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/defigraph/Edge.py | 3 + src/defigraph/Edge_test.py | 3 +- src/defigraph/Graph_test.py | 114 +---------------------------------- src/defigraph/Pool.py | 8 +-- src/defigraph/Vertex.py | 6 +- src/defigraph/Vertex_test.py | 15 +++-- 6 files changed, 21 insertions(+), 128 deletions(-) diff --git a/src/defigraph/Edge.py b/src/defigraph/Edge.py index 4a8aea0..2044ebe 100644 --- a/src/defigraph/Edge.py +++ b/src/defigraph/Edge.py @@ -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: diff --git a/src/defigraph/Edge_test.py b/src/defigraph/Edge_test.py index fc5919d..f075818 100644 --- a/src/defigraph/Edge_test.py +++ b/src/defigraph/Edge_test.py @@ -1,8 +1,7 @@ import unittest class TestEdgeMethods(unittest.TestCase): - pass - + """Test class for Edge methods""" if __name__ == "__main__": unittest.main() \ No newline at end of file diff --git a/src/defigraph/Graph_test.py b/src/defigraph/Graph_test.py index eda9c51..653baa0 100644 --- a/src/defigraph/Graph_test.py +++ b/src/defigraph/Graph_test.py @@ -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""" \ No newline at end of file diff --git a/src/defigraph/Pool.py b/src/defigraph/Pool.py index 78bcdd1..ad5fb41 100644 --- a/src/defigraph/Pool.py +++ b/src/defigraph/Pool.py @@ -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 \ No newline at end of file + self.token1 = token1 \ No newline at end of file diff --git a/src/defigraph/Vertex.py b/src/defigraph/Vertex.py index 5060b0e..39910ff 100644 --- a/src/defigraph/Vertex.py +++ b/src/defigraph/Vertex.py @@ -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): diff --git a/src/defigraph/Vertex_test.py b/src/defigraph/Vertex_test.py index 6e9c896..d907ff4 100644 --- a/src/defigraph/Vertex_test.py +++ b/src/defigraph/Vertex_test.py @@ -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()