Skip to content

Commit

Permalink
add ContractConfig class
Browse files Browse the repository at this point in the history
  • Loading branch information
mshrieve committed Oct 24, 2023
1 parent 079595c commit 0a916c3
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 16 deletions.
36 changes: 20 additions & 16 deletions py_order_utils/config.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,11 @@
class ContractConfig:
def __init__(self, exchange, collateral, conditional):
self.exchange = exchange
self.collateral = collateral
self.conditional = conditional
from .model import ContractConfig

def get_exchange(self):
return self.exchange

def get_collateral(self):
return self.collateral

def get_conditional(self):
return self.conditional


def get_contract_config(chainID: int) -> ContractConfig:
def get_contract_config(chainID: int, neg_risk: bool=False) -> ContractConfig:
"""
Get the contract configuration for the chain
"""

CONFIG = {
137: ContractConfig(
exchange="0x4bFb41d5B3570DeFd03C39a9A4D8dE6Bd8B8982E",
Expand All @@ -31,7 +19,23 @@ def get_contract_config(chainID: int) -> ContractConfig:
),
}

config = CONFIG.get(chainID)
NEG_RISK_CONFIG = {
137: ContractConfig(
exchange="", # TODO
collateral="", # TODO
conditional="0x4D97DCd97eC945f40cF65F87097ACe5EA0476045",
),
80001: ContractConfig(
exchange="", # TODO
collateral="", # TODO
conditional="0x7D8610E9567d2a6C9FBf66a5A13E9Ba8bb120d43",
),
}

if neg_risk:
config = NEG_RISK_CONFIG.get(chainID)
else:
config = CONFIG.get(chainID)
if config is None:
raise Exception("Invalid chainID: ${}".format(chainID))

Expand Down
1 change: 1 addition & 0 deletions py_order_utils/model/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from py_order_utils.model.order import OrderData, Order, SignedOrder
from py_order_utils.model.signatures import EOA, POLY_PROXY, POLY_GNOSIS_SAFE
from py_order_utils.model.sides import BUY, SELL
from py_order_utils.model.contract_config import ContractConfig
22 changes: 22 additions & 0 deletions py_order_utils/model/contract_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from dataclasses import dataclass

@dataclass
class ContractConfig:
"""
Contract Configuration
"""

exchange: str
"""
The exchange contract responsible for matching orders
"""

collateral: str
"""
The ERC20 token used as collateral for the exchange's markets
"""

conditional: str
"""
The ERC1155 conditional tokens contract
"""

0 comments on commit 0a916c3

Please sign in to comment.