opinion-clob-sdk 0.1.19__py3-none-any.whl → 0.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of opinion-clob-sdk might be problematic. Click here for more details.
- opinion_clob_sdk/__init__.py +3 -3
- opinion_clob_sdk/chain/py_order_utils/builders/base_builder.py +1 -1
- opinion_clob_sdk/chain/py_order_utils/builders/order_builder_test.py +1 -1
- opinion_clob_sdk/chain/safe/safe_test.py +1 -1
- opinion_clob_sdk/config.py +13 -1
- opinion_clob_sdk/sdk.py +23 -11
- {opinion_clob_sdk-0.1.19.dist-info → opinion_clob_sdk-0.2.0.dist-info}/METADATA +13 -8
- {opinion_clob_sdk-0.1.19.dist-info → opinion_clob_sdk-0.2.0.dist-info}/RECORD +10 -10
- {opinion_clob_sdk-0.1.19.dist-info → opinion_clob_sdk-0.2.0.dist-info}/WHEEL +0 -0
- {opinion_clob_sdk-0.1.19.dist-info → opinion_clob_sdk-0.2.0.dist-info}/top_level.txt +0 -0
opinion_clob_sdk/__init__.py
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
from opinion_clob_sdk.sdk import (
|
|
4
4
|
Client,
|
|
5
|
-
|
|
5
|
+
CHAIN_ID_BNB_MAINNET,
|
|
6
6
|
SUPPORTED_CHAIN_IDS
|
|
7
7
|
)
|
|
8
8
|
from opinion_clob_sdk.model import TopicStatus, TopicType, TopicStatusFilter
|
|
@@ -12,13 +12,13 @@ from opinion_clob_sdk.chain.exception import (
|
|
|
12
12
|
InsufficientGasBalance
|
|
13
13
|
)
|
|
14
14
|
|
|
15
|
-
__version__ = "0.
|
|
15
|
+
__version__ = "0.2.0"
|
|
16
16
|
__all__ = [
|
|
17
17
|
"Client",
|
|
18
18
|
"TopicStatus",
|
|
19
19
|
"TopicType",
|
|
20
20
|
"TopicStatusFilter",
|
|
21
|
-
"
|
|
21
|
+
"CHAIN_ID_BNB_MAINNET",
|
|
22
22
|
"SUPPORTED_CHAIN_IDS",
|
|
23
23
|
"BalanceNotEnough",
|
|
24
24
|
"NoPositionsToRedeem",
|
|
@@ -11,7 +11,7 @@ import json
|
|
|
11
11
|
class TestInterfaces(unittest.TestCase):
|
|
12
12
|
def test_sign_order(self):
|
|
13
13
|
exchange_address = "0xF0aebf65490374a477100351291c736c73c11D9F"
|
|
14
|
-
chain_id =
|
|
14
|
+
chain_id = 56
|
|
15
15
|
# Test private key, please do not use the key in production env.
|
|
16
16
|
signer = Signer("0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80")
|
|
17
17
|
builder = OrderBuilder(exchange_address, chain_id, signer, lambda: 1)
|
|
@@ -12,7 +12,7 @@ class TestSafeRx(unittest.TestCase):
|
|
|
12
12
|
self.private_key = '0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80'
|
|
13
13
|
self.safe_address = '0x8F58a1ab58e18Bb3f8ACf5E14c046D4F7add824a'
|
|
14
14
|
self.compatibility_handler_address = '0xf48f2B2d2a534e402487b3ee7C18c33Aec0Fe5e4'
|
|
15
|
-
self.rpc_url = 'https://
|
|
15
|
+
self.rpc_url = 'https://bsc-dataseed.binance.org'
|
|
16
16
|
self.w3 = Web3(HTTPProvider(self.rpc_url))
|
|
17
17
|
|
|
18
18
|
def test_sign_multi_sig_tx(self):
|
opinion_clob_sdk/config.py
CHANGED
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
# Configuration constants for Opinion CLOB SDK
|
|
2
2
|
|
|
3
3
|
# Supported chain IDs
|
|
4
|
-
SUPPORTED_CHAIN_IDS = [
|
|
4
|
+
SUPPORTED_CHAIN_IDS = [56] # BNB Chain (BSC) mainnet
|
|
5
|
+
|
|
6
|
+
# BNB Chain (BSC) Mainnet Contract Addresses
|
|
7
|
+
BNB_CHAIN_CONDITIONAL_TOKENS_ADDR = "0xAD1a38cEc043e70E83a3eC30443dB285ED10D774"
|
|
8
|
+
BNB_CHAIN_MULTISEND_ADDR = "0x998739BFdAAdde7C933B942a68053933098f9EDa"
|
|
9
|
+
|
|
10
|
+
# Default contract addresses by chain ID
|
|
11
|
+
DEFAULT_CONTRACT_ADDRESSES = {
|
|
12
|
+
56: { # BNB Chain Mainnet
|
|
13
|
+
"conditional_tokens": BNB_CHAIN_CONDITIONAL_TOKENS_ADDR,
|
|
14
|
+
"multisend": BNB_CHAIN_MULTISEND_ADDR,
|
|
15
|
+
}
|
|
16
|
+
}
|
opinion_clob_sdk/sdk.py
CHANGED
|
@@ -19,6 +19,7 @@ from .chain.py_order_utils.model.sides import BUY, SELL, OrderSide
|
|
|
19
19
|
from .chain.py_order_utils.model.order_type import LIMIT_ORDER, MARKET_ORDER
|
|
20
20
|
from .model import TopicStatus, TopicStatusFilter, TopicType
|
|
21
21
|
from .chain.py_order_utils.utils import calculate_order_amounts
|
|
22
|
+
from .config import DEFAULT_CONTRACT_ADDRESSES
|
|
22
23
|
|
|
23
24
|
API_INTERNAL_ERROR_MSG = "Unable to process your request. Please contact technical support."
|
|
24
25
|
MISSING_MARKET_ID_MSG = "market_id is required."
|
|
@@ -26,8 +27,8 @@ MISSING_TOKEN_ID_MSG = "token_id is required."
|
|
|
26
27
|
MAX_DECIMALS = 18 # Standard maximum for ERC20 tokens (ETH, DAI, etc.)
|
|
27
28
|
|
|
28
29
|
# Supported blockchain chain IDs
|
|
29
|
-
|
|
30
|
-
SUPPORTED_CHAIN_IDS = [
|
|
30
|
+
CHAIN_ID_BNB_MAINNET = 56 # BNB Chain (BSC) mainnet
|
|
31
|
+
SUPPORTED_CHAIN_IDS = [CHAIN_ID_BNB_MAINNET]
|
|
31
32
|
|
|
32
33
|
class InvalidParamError(Exception):
|
|
33
34
|
pass
|
|
@@ -82,8 +83,8 @@ class Client:
|
|
|
82
83
|
rpc_url: str = '',
|
|
83
84
|
private_key: HexStr = HexStr(''),
|
|
84
85
|
multi_sig_addr: str = '',
|
|
85
|
-
conditional_tokens_addr: ChecksumAddress =
|
|
86
|
-
multisend_addr: ChecksumAddress =
|
|
86
|
+
conditional_tokens_addr: Optional[ChecksumAddress] = None,
|
|
87
|
+
multisend_addr: Optional[ChecksumAddress] = None,
|
|
87
88
|
enable_trading_check_interval: int = 3600,
|
|
88
89
|
quote_tokens_cache_ttl: int = 3600,
|
|
89
90
|
market_cache_ttl: int = 300
|
|
@@ -94,12 +95,12 @@ class Client:
|
|
|
94
95
|
Args:
|
|
95
96
|
host: API host URL
|
|
96
97
|
apikey: API authentication key
|
|
97
|
-
chain_id: Blockchain chain ID (
|
|
98
|
+
chain_id: Blockchain chain ID (56 for BNB Chain mainnet)
|
|
98
99
|
rpc_url: RPC endpoint URL
|
|
99
100
|
private_key: Private key for signing transactions
|
|
100
101
|
multi_sig_addr: Multi-signature wallet address
|
|
101
|
-
conditional_tokens_addr: Conditional tokens contract address
|
|
102
|
-
multisend_addr: Multisend contract address
|
|
102
|
+
conditional_tokens_addr: Conditional tokens contract address (optional, uses default if not provided)
|
|
103
|
+
multisend_addr: Multisend contract address (optional, uses default if not provided)
|
|
103
104
|
enable_trading_check_interval: Time interval (in seconds) to cache enable_trading checks.
|
|
104
105
|
Default is 3600 (1 hour). Set to 0 to check every time.
|
|
105
106
|
This significantly improves performance for frequent operations.
|
|
@@ -108,6 +109,21 @@ class Client:
|
|
|
108
109
|
market_cache_ttl: Time interval (in seconds) to cache market data.
|
|
109
110
|
Default is 300 (5 minutes). Set to 0 to disable caching.
|
|
110
111
|
"""
|
|
112
|
+
# Validate and set chain_id first
|
|
113
|
+
if chain_id not in SUPPORTED_CHAIN_IDS:
|
|
114
|
+
raise InvalidParamError(f'chain_id must be one of {SUPPORTED_CHAIN_IDS}')
|
|
115
|
+
self.chain_id = chain_id
|
|
116
|
+
|
|
117
|
+
# Use default contract addresses if not provided
|
|
118
|
+
if conditional_tokens_addr is None:
|
|
119
|
+
conditional_tokens_addr = ChecksumAddress(
|
|
120
|
+
DEFAULT_CONTRACT_ADDRESSES[chain_id]["conditional_tokens"]
|
|
121
|
+
)
|
|
122
|
+
if multisend_addr is None:
|
|
123
|
+
multisend_addr = ChecksumAddress(
|
|
124
|
+
DEFAULT_CONTRACT_ADDRESSES[chain_id]["multisend"]
|
|
125
|
+
)
|
|
126
|
+
|
|
111
127
|
self.conf = Configuration(host=host)
|
|
112
128
|
self.conf.api_key['ApiKeyAuth'] = apikey
|
|
113
129
|
self.api_key = apikey
|
|
@@ -119,10 +135,6 @@ class Client:
|
|
|
119
135
|
self.api_client = ApiClient(self.conf)
|
|
120
136
|
self.market_api = PredictionMarketApi(self.api_client)
|
|
121
137
|
self.user_api = UserApi(self.api_client)
|
|
122
|
-
# Validate and set chain_id
|
|
123
|
-
if chain_id not in SUPPORTED_CHAIN_IDS:
|
|
124
|
-
raise InvalidParamError(f'chain_id must be one of {SUPPORTED_CHAIN_IDS}')
|
|
125
|
-
self.chain_id = chain_id
|
|
126
138
|
|
|
127
139
|
# Cache configuration
|
|
128
140
|
self.quote_tokens_cache_ttl = quote_tokens_cache_ttl
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: opinion_clob_sdk
|
|
3
|
-
Version: 0.
|
|
4
|
-
Summary: Opinion CLOB SDK - Python SDK for Opinion Prediction Market Central Limit Order Book API
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Opinion CLOB SDK (Tech Preview) - Python SDK for Opinion Prediction Market Central Limit Order Book API
|
|
5
5
|
Home-page: https://opinion.trade
|
|
6
6
|
Author: Opinion Labs
|
|
7
7
|
Author-email: support@opinion.trade
|
|
8
|
-
Keywords: PredictionMarket,CLOB,Trading,Blockchain,
|
|
9
|
-
Classifier: Development Status ::
|
|
8
|
+
Keywords: PredictionMarket,CLOB,Trading,Blockchain,BNBChain,BSC,Opinion
|
|
9
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
10
10
|
Classifier: Intended Audience :: Developers
|
|
11
11
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
12
12
|
Classifier: License :: OSI Approved :: MIT License
|
|
@@ -40,17 +40,22 @@ Dynamic: requires-python
|
|
|
40
40
|
Dynamic: summary
|
|
41
41
|
|
|
42
42
|
|
|
43
|
-
# Opinion CLOB SDK
|
|
43
|
+
# Opinion CLOB SDK (Tech Preview)
|
|
44
|
+
|
|
45
|
+
**Technology Preview Release - BNB Chain Support**
|
|
44
46
|
|
|
45
47
|
Python SDK for interacting with Opinion prediction markets via the CLOB (Central Limit Order Book) API.
|
|
46
48
|
|
|
49
|
+
> ⚠️ **Tech Preview Notice**: This version includes the migration from Base to BNB Chain.
|
|
50
|
+
> While fully functional and tested, we recommend thorough testing in your environment before production use.
|
|
51
|
+
|
|
47
52
|
## Features
|
|
48
53
|
|
|
49
54
|
- Market data queries (markets, orderbooks, prices, candles)
|
|
50
55
|
- Order management (place, cancel, query orders)
|
|
51
56
|
- Position and balance tracking
|
|
52
57
|
- Smart contract interactions (split, merge, redeem)
|
|
53
|
-
- Support for
|
|
58
|
+
- Support for BNB Chain mainnet (chain ID 56)
|
|
54
59
|
|
|
55
60
|
## Installation
|
|
56
61
|
|
|
@@ -66,8 +71,8 @@ from opinion_clob_sdk import Client
|
|
|
66
71
|
client = Client(
|
|
67
72
|
host='https://api.opinion.trade',
|
|
68
73
|
apikey='your_api_key',
|
|
69
|
-
chain_id=
|
|
70
|
-
rpc_url='
|
|
74
|
+
chain_id=56, # BNB Chain mainnet
|
|
75
|
+
rpc_url='https://bsc-dataseed.binance.org',
|
|
71
76
|
private_key='your_private_key',
|
|
72
77
|
multi_sig_addr='your_multi_sig_address'
|
|
73
78
|
)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
opinion_clob_sdk/__init__.py,sha256=
|
|
2
|
-
opinion_clob_sdk/config.py,sha256=
|
|
1
|
+
opinion_clob_sdk/__init__.py,sha256=TDyNucU03zE555L78Ugf7kv4rONGXQDLHo8S9QU4Mi4,622
|
|
2
|
+
opinion_clob_sdk/config.py,sha256=xODivHbEcgrPLYXEoGsUZ4eQaXr0LY35gw6Dxg_wIeo,547
|
|
3
3
|
opinion_clob_sdk/model.py,sha256=eqNkEdyJPmcL_wax8ieybeyhR40JwGDB_KPplXLmNxE,309
|
|
4
|
-
opinion_clob_sdk/sdk.py,sha256=
|
|
4
|
+
opinion_clob_sdk/sdk.py,sha256=l6zTGh5RSwWt8jD2L6luuDVLYeiFlNUZT6B7kSS8M5k,40912
|
|
5
5
|
opinion_clob_sdk/verify_api_calls.py,sha256=MU4NEyfQ5hDmFJ0lT8g7KXVdlZ0cBtFyBTCbhhfI6a4,5031
|
|
6
6
|
opinion_clob_sdk/chain/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
7
|
opinion_clob_sdk/chain/contract_caller.py,sha256=AKCD1ZvLTbJX_YWFJecRtZ4Pi7L3_20Q7YOSGfAolEY,17148
|
|
@@ -14,10 +14,10 @@ opinion_clob_sdk/chain/py_order_utils/constants.py,sha256=afsZ0OahGbCzNPE2rXKU1k
|
|
|
14
14
|
opinion_clob_sdk/chain/py_order_utils/signer.py,sha256=NAMHcMREbRUgrz1-28sqpPoMD8LkRJSyUn7-FLUkYsM,447
|
|
15
15
|
opinion_clob_sdk/chain/py_order_utils/utils.py,sha256=rrdtPW2T5raF0TntKVrR9RVz6XkkRWhiaWHPaGHMtrg,6193
|
|
16
16
|
opinion_clob_sdk/chain/py_order_utils/builders/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
17
|
-
opinion_clob_sdk/chain/py_order_utils/builders/base_builder.py,sha256=
|
|
17
|
+
opinion_clob_sdk/chain/py_order_utils/builders/base_builder.py,sha256=qE4pusFjbMXG7tmNkbcE2M_cn9i8K93Jtmv0aseOdz4,1275
|
|
18
18
|
opinion_clob_sdk/chain/py_order_utils/builders/exception.py,sha256=525fSH8Q241VjxdllBkWi3DiW_-6I1AmG-iHwZBTp4E,47
|
|
19
19
|
opinion_clob_sdk/chain/py_order_utils/builders/order_builder.py,sha256=NybKbNhRd1jceSjtp6lL9x1DjDzJ4ClhsAK2zS58P4c,2968
|
|
20
|
-
opinion_clob_sdk/chain/py_order_utils/builders/order_builder_test.py,sha256=
|
|
20
|
+
opinion_clob_sdk/chain/py_order_utils/builders/order_builder_test.py,sha256=R4yvhspUpnATt6N4cSsSMiGiUnXcJjtLRasUlplb1nQ,1771
|
|
21
21
|
opinion_clob_sdk/chain/py_order_utils/model/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
22
22
|
opinion_clob_sdk/chain/py_order_utils/model/order.py,sha256=fI2NhqX_cdUmZivliki4rHXJCxQQY5ykjh8a58FFfPE,5852
|
|
23
23
|
opinion_clob_sdk/chain/py_order_utils/model/order_type.py,sha256=kYXJ0Ikk3Qnr00yCIfrtJibFve8DUjNSJ_xiLw7IphY,185
|
|
@@ -30,7 +30,7 @@ opinion_clob_sdk/chain/safe/exceptions.py,sha256=kp0jfnP93JyEkEgwPERL6MZ9D8ozbio
|
|
|
30
30
|
opinion_clob_sdk/chain/safe/multisend.py,sha256=l-lWlb7jSzmNCyFbpAr-d8SYEKM4QRm_h0tF53T3CzE,12659
|
|
31
31
|
opinion_clob_sdk/chain/safe/safe.py,sha256=OO-010or-qCCwCSTSh4qKGmoSwEsL2IYECW8IYmSmKQ,5216
|
|
32
32
|
opinion_clob_sdk/chain/safe/safe_signature.py,sha256=W1Xn73DSzE3PZ6ITyikhdWhosY3wdey-scX0Jci037I,12559
|
|
33
|
-
opinion_clob_sdk/chain/safe/safe_test.py,sha256=
|
|
33
|
+
opinion_clob_sdk/chain/safe/safe_test.py,sha256=u1l2JDK9N49ZhQlyIGM8JRJL4qd8DqOGl3ZQWbEYlRc,1392
|
|
34
34
|
opinion_clob_sdk/chain/safe/safe_tx.py,sha256=QxKzv0EA7uwjakFMDVoDLrzYlZANpEhblPBQ7ZcF9zE,17211
|
|
35
35
|
opinion_clob_sdk/chain/safe/signatures.py,sha256=8l6t6R21E9Mj4_USagIp1GiUlJmAp0Cqq9VpB7Zk960,1978
|
|
36
36
|
opinion_clob_sdk/chain/safe/typing.py,sha256=wytgXXRbpyccM_HxpQLeDzfo40Ch_K-Z_ivORb-eNZo,419
|
|
@@ -41,7 +41,7 @@ opinion_clob_sdk/chain/safe/safe_contracts/compatibility_fallback_handler_v1_3_0
|
|
|
41
41
|
opinion_clob_sdk/chain/safe/safe_contracts/multisend_v1_3_0.py,sha256=8oGhNkS2k2Cy5pG6YNt_BKytS3AEtPeXv4rkyXv_p0M,380
|
|
42
42
|
opinion_clob_sdk/chain/safe/safe_contracts/safe_v1_3_0.py,sha256=YCUWTpf_pR44iUUkDl42f3n2YXSVGlTBcvMtReN7rlM,21922
|
|
43
43
|
opinion_clob_sdk/chain/safe/safe_contracts/utils.py,sha256=xnW8JSq8tVMfvZ4lhT-L96P3Usjs2zrZ5jzrNZvFHjc,631
|
|
44
|
-
opinion_clob_sdk-0.
|
|
45
|
-
opinion_clob_sdk-0.
|
|
46
|
-
opinion_clob_sdk-0.
|
|
47
|
-
opinion_clob_sdk-0.
|
|
44
|
+
opinion_clob_sdk-0.2.0.dist-info/METADATA,sha256=rDhdp6nY5p3GngAXVIbK8E_QbhqJ0B-IZVkfkR5zT64,3110
|
|
45
|
+
opinion_clob_sdk-0.2.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
46
|
+
opinion_clob_sdk-0.2.0.dist-info/top_level.txt,sha256=4gH76GRX1WZSc3b146FfxE6BAxggJD8y3NMEHUOSPA0,17
|
|
47
|
+
opinion_clob_sdk-0.2.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|