2020 OrderBookSummary ,
2121)
2222from py_clob_client .order_builder .constants import BUY
23+ from py_order_utils .builders import OrderBuilder
24+ from py_order_utils .model import OrderData
25+ from py_order_utils .signer import Signer
2326
2427from agents .utils .objects import SimpleMarket , SimpleEvent
2528
@@ -41,10 +44,6 @@ def __init__(self) -> None:
4144
4245 self .chain_id = 137 # POLYGON
4346 self .private_key = os .getenv ("POLYGON_WALLET_PRIVATE_KEY" )
44- if not self .private_key :
45- raise ValueError (
46- "POLYGON_WALLET_PRIVATE_KEY environment variable is required"
47- )
4847
4948 self .polygon_rpc = "https://polygon-rpc.com"
5049 self .w3 = Web3 (Web3 .HTTPProvider (self .polygon_rpc ))
@@ -72,12 +71,15 @@ def __init__(self) -> None:
7271 self ._init_approvals (False )
7372
7473 def _init_api_keys (self ) -> None :
74+ if not self .private_key :
75+ raise ValueError (
76+ "POLYGON_WALLET_PRIVATE_KEY is required for trading operations"
77+ )
7578 self .client = ClobClient (
7679 self .clob_url , key = self .private_key , chain_id = self .chain_id
7780 )
7881 self .credentials = self .client .create_or_derive_api_creds ()
7982 self .client .set_api_creds (self .credentials )
80- # print(self.credentials)
8183
8284 def _init_approvals (self , run : bool = False ) -> None :
8385 if not run :
@@ -104,7 +106,7 @@ def _init_approvals(self, run: bool = False) -> None:
104106 usdc_approve_tx_receipt = web3 .eth .wait_for_transaction_receipt (
105107 send_usdc_approve_tx , 600
106108 )
107- print ( usdc_approve_tx_receipt )
109+ logger . info ( "USDC approve receipt (CTF Exchange): %s" , usdc_approve_tx_receipt )
108110
109111 nonce = web3 .eth .get_transaction_count (pub_key )
110112
@@ -120,7 +122,7 @@ def _init_approvals(self, run: bool = False) -> None:
120122 ctf_approval_tx_receipt = web3 .eth .wait_for_transaction_receipt (
121123 send_ctf_approval_tx , 600
122124 )
123- print ( ctf_approval_tx_receipt )
125+ logger . info ( "CTF approval receipt: %s" , ctf_approval_tx_receipt )
124126
125127 nonce = web3 .eth .get_transaction_count (pub_key )
126128
@@ -137,7 +139,7 @@ def _init_approvals(self, run: bool = False) -> None:
137139 usdc_approve_tx_receipt = web3 .eth .wait_for_transaction_receipt (
138140 send_usdc_approve_tx , 600
139141 )
140- print ( usdc_approve_tx_receipt )
142+ logger . info ( "USDC approve receipt (Neg Risk CTF): %s" , usdc_approve_tx_receipt )
141143
142144 nonce = web3 .eth .get_transaction_count (pub_key )
143145
@@ -153,7 +155,7 @@ def _init_approvals(self, run: bool = False) -> None:
153155 ctf_approval_tx_receipt = web3 .eth .wait_for_transaction_receipt (
154156 send_ctf_approval_tx , 600
155157 )
156- print ( ctf_approval_tx_receipt )
158+ logger . info ( "CTF approval receipt (Neg Risk): %s" , ctf_approval_tx_receipt )
157159
158160 nonce = web3 .eth .get_transaction_count (pub_key )
159161
@@ -170,7 +172,7 @@ def _init_approvals(self, run: bool = False) -> None:
170172 usdc_approve_tx_receipt = web3 .eth .wait_for_transaction_receipt (
171173 send_usdc_approve_tx , 600
172174 )
173- print ( usdc_approve_tx_receipt )
175+ logger . info ( "USDC approve receipt (Neg Risk Adapter): %s" , usdc_approve_tx_receipt )
174176
175177 nonce = web3 .eth .get_transaction_count (pub_key )
176178
@@ -186,7 +188,7 @@ def _init_approvals(self, run: bool = False) -> None:
186188 ctf_approval_tx_receipt = web3 .eth .wait_for_transaction_receipt (
187189 send_ctf_approval_tx , 600
188190 )
189- print ( ctf_approval_tx_receipt )
191+ logger . info ( "CTF approval receipt (Neg Risk Adapter): %s" , ctf_approval_tx_receipt )
190192
191193 def get_all_markets (self ) -> "list[SimpleMarket]" :
192194 markets = []
@@ -353,7 +355,7 @@ def get_usdc_balance(self) -> float:
353355 balance_res = self .usdc .functions .balanceOf (
354356 self .get_address_for_private_key ()
355357 ).call ()
356- return float (balance_res / 10e5 )
358+ return float (balance_res / 10 ** 6 )
357359
358360
359361def test ():
0 commit comments