Use UV for better package management

This commit is contained in:
warproxxx
2025-11-03 09:26:42 -08:00
parent 7c7ef82c80
commit 0a8ff4cefd
6 changed files with 2968 additions and 42 deletions
+12 -12
View File
@@ -4,7 +4,7 @@ from py_clob_client.clob_types import OrderArgs, BalanceAllowanceParams, AssetTy
from py_clob_client.order_builder.constants import BUY
from web3 import Web3
from web3.middleware import geth_poa_middleware
from web3.middleware import ExtraDataToPOAMiddleware
import json
@@ -41,8 +41,8 @@ def get_clob_client():
def approveContracts():
web3 = Web3(Web3.HTTPProvider("https://polygon-rpc.com"))
web3.middleware_onion.inject(geth_poa_middleware, layer=0)
wallet = web3.eth.account.privateKeyToAccount(os.getenv("PK"))
web3.middleware_onion.inject(ExtraDataToPOAMiddleware, layer=0)
wallet = web3.eth.account.from_key(os.getenv("PK"))
with open('erc20ABI.json', 'r') as file:
@@ -56,7 +56,7 @@ def approveContracts():
for address in ['0x4bFb41d5B3570DeFd03C39a9A4D8dE6Bd8B8982E', '0xC5d563A36AE78145C45a50134d48A1215220f80a', '0xd91E80cF2E7be2e162c6513ceD06f1dD0dA35296']:
usdc_nonce = web3.eth.getTransactionCount( wallet.address )
usdc_nonce = web3.eth.get_transaction_count( wallet.address )
raw_usdc_txn = usdc_contract.functions.approve(address, int(MAX_INT, 0)).build_transaction({
"chainId": 137,
"from": wallet.address,
@@ -69,41 +69,41 @@ def approveContracts():
print(f'USDC Transaction for {address} returned {usdc_tx_receipt}')
time.sleep(1)
ctf_nonce = web3.eth.getTransactionCount( wallet.address )
ctf_nonce = web3.eth.get_transaction_count( wallet.address )
raw_ctf_approval_txn = ctf_contract.functions.setApprovalForAll(address, True).buildTransaction({
raw_ctf_approval_txn = ctf_contract.functions.setApprovalForAll(address, True).build_transaction({
"chainId": 137,
"from": wallet.address,
"nonce": ctf_nonce
})
signed_ctf_approval_tx = web3.eth.account.sign_transaction(raw_ctf_approval_txn, private_key=os.getenv("PK"))
send_ctf_approval_tx = web3.eth.send_raw_transaction(signed_ctf_approval_tx.rawTransaction)
send_ctf_approval_tx = web3.eth.send_raw_transaction(signed_ctf_approval_tx.raw_transaction)
ctf_approval_tx_receipt = web3.eth.wait_for_transaction_receipt(send_ctf_approval_tx, 600)
print(f'CTF Transaction for {address} returned {ctf_approval_tx_receipt}')
time.sleep(1)
nonce = web3.eth.getTransactionCount( wallet.address )
nonce = web3.eth.get_transaction_count( wallet.address )
raw_txn_2 = usdc_contract.functions.approve("0xC5d563A36AE78145C45a50134d48A1215220f80a", int(MAX_INT, 0)).build_transaction({
"chainId": 137,
"from": wallet.address,
"nonce": nonce
})
signed_txn_2 = web3.eth.account.sign_transaction(raw_txn_2, private_key=os.getenv("PK"))
send_txn_2 = web3.eth.send_raw_transaction(signed_txn_2.rawTransaction)
send_txn_2 = web3.eth.send_raw_transaction(signed_txn_2.raw_transaction)
nonce = web3.eth.getTransactionCount( wallet.address )
nonce = web3.eth.get_transaction_count( wallet.address )
raw_txn_3 = usdc_contract.functions.approve("0xd91E80cF2E7be2e162c6513ceD06f1dD0dA35296", int(MAX_INT, 0)).build_transaction({
"chainId": 137,
"from": wallet.address,
"nonce": nonce
})
signed_txn_3 = web3.eth.account.sign_transaction(raw_txn_3, private_key=os.getenv("PK"))
send_txn_3 = web3.eth.send_raw_transaction(signed_txn_3.rawTransaction)
send_txn_3 = web3.eth.send_raw_transaction(signed_txn_3.raw_transaction)
def market_action( marketId, action, price, size ):