opinion-clob-sdk 0.1.18__tar.gz → 0.2.0__tar.gz
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-0.1.18/opinion_clob_sdk.egg-info → opinion_clob_sdk-0.2.0}/PKG-INFO +13 -8
- {opinion_clob_sdk-0.1.18 → opinion_clob_sdk-0.2.0}/README.md +9 -5
- {opinion_clob_sdk-0.1.18 → opinion_clob_sdk-0.2.0}/__init__.py +3 -3
- {opinion_clob_sdk-0.1.18 → opinion_clob_sdk-0.2.0}/chain/py_order_utils/builders/base_builder.py +1 -1
- {opinion_clob_sdk-0.1.18 → opinion_clob_sdk-0.2.0}/chain/py_order_utils/builders/order_builder_test.py +1 -1
- {opinion_clob_sdk-0.1.18 → opinion_clob_sdk-0.2.0}/chain/safe/safe_test.py +1 -1
- opinion_clob_sdk-0.2.0/config.py +16 -0
- {opinion_clob_sdk-0.1.18 → opinion_clob_sdk-0.2.0/opinion_clob_sdk.egg-info}/PKG-INFO +13 -8
- {opinion_clob_sdk-0.1.18 → opinion_clob_sdk-0.2.0}/opinion_clob_sdk.egg-info/SOURCES.txt +43 -0
- {opinion_clob_sdk-0.1.18 → opinion_clob_sdk-0.2.0}/sdk.py +63 -26
- {opinion_clob_sdk-0.1.18 → opinion_clob_sdk-0.2.0}/setup.py +13 -8
- {opinion_clob_sdk-0.1.18 → opinion_clob_sdk-0.2.0}/tests/test_integration.py +1 -1
- {opinion_clob_sdk-0.1.18 → opinion_clob_sdk-0.2.0}/tests/test_sdk.py +29 -29
- opinion_clob_sdk-0.1.18/config.py +0 -4
- {opinion_clob_sdk-0.1.18 → opinion_clob_sdk-0.2.0}/MANIFEST.in +0 -0
- {opinion_clob_sdk-0.1.18 → opinion_clob_sdk-0.2.0}/chain/__init__.py +0 -0
- {opinion_clob_sdk-0.1.18 → opinion_clob_sdk-0.2.0}/chain/contract_caller.py +0 -0
- {opinion_clob_sdk-0.1.18 → opinion_clob_sdk-0.2.0}/chain/contracts/__init__.py +0 -0
- {opinion_clob_sdk-0.1.18 → opinion_clob_sdk-0.2.0}/chain/contracts/conditional_tokens.py +0 -0
- {opinion_clob_sdk-0.1.18 → opinion_clob_sdk-0.2.0}/chain/contracts/erc20.py +0 -0
- {opinion_clob_sdk-0.1.18 → opinion_clob_sdk-0.2.0}/chain/exception.py +0 -0
- {opinion_clob_sdk-0.1.18 → opinion_clob_sdk-0.2.0}/chain/py_order_utils/__init__.py +0 -0
- {opinion_clob_sdk-0.1.18 → opinion_clob_sdk-0.2.0}/chain/py_order_utils/builders/__init__.py +0 -0
- {opinion_clob_sdk-0.1.18 → opinion_clob_sdk-0.2.0}/chain/py_order_utils/builders/exception.py +0 -0
- {opinion_clob_sdk-0.1.18 → opinion_clob_sdk-0.2.0}/chain/py_order_utils/builders/order_builder.py +0 -0
- {opinion_clob_sdk-0.1.18 → opinion_clob_sdk-0.2.0}/chain/py_order_utils/constants.py +0 -0
- {opinion_clob_sdk-0.1.18 → opinion_clob_sdk-0.2.0}/chain/py_order_utils/model/__init__.py +0 -0
- {opinion_clob_sdk-0.1.18 → opinion_clob_sdk-0.2.0}/chain/py_order_utils/model/order.py +0 -0
- {opinion_clob_sdk-0.1.18 → opinion_clob_sdk-0.2.0}/chain/py_order_utils/model/order_type.py +0 -0
- {opinion_clob_sdk-0.1.18 → opinion_clob_sdk-0.2.0}/chain/py_order_utils/model/sides.py +0 -0
- {opinion_clob_sdk-0.1.18 → opinion_clob_sdk-0.2.0}/chain/py_order_utils/model/signatures.py +0 -0
- {opinion_clob_sdk-0.1.18 → opinion_clob_sdk-0.2.0}/chain/py_order_utils/signer.py +0 -0
- {opinion_clob_sdk-0.1.18 → opinion_clob_sdk-0.2.0}/chain/py_order_utils/utils.py +0 -0
- {opinion_clob_sdk-0.1.18 → opinion_clob_sdk-0.2.0}/chain/safe/__init__.py +0 -0
- {opinion_clob_sdk-0.1.18 → opinion_clob_sdk-0.2.0}/chain/safe/constants.py +0 -0
- {opinion_clob_sdk-0.1.18 → opinion_clob_sdk-0.2.0}/chain/safe/eip712/__init__.py +0 -0
- {opinion_clob_sdk-0.1.18 → opinion_clob_sdk-0.2.0}/chain/safe/enums.py +0 -0
- {opinion_clob_sdk-0.1.18 → opinion_clob_sdk-0.2.0}/chain/safe/exceptions.py +0 -0
- {opinion_clob_sdk-0.1.18 → opinion_clob_sdk-0.2.0}/chain/safe/multisend.py +0 -0
- {opinion_clob_sdk-0.1.18 → opinion_clob_sdk-0.2.0}/chain/safe/safe.py +0 -0
- {opinion_clob_sdk-0.1.18 → opinion_clob_sdk-0.2.0}/chain/safe/safe_contracts/__init__.py +0 -0
- {opinion_clob_sdk-0.1.18 → opinion_clob_sdk-0.2.0}/chain/safe/safe_contracts/compatibility_fallback_handler_v1_3_0.py +0 -0
- {opinion_clob_sdk-0.1.18 → opinion_clob_sdk-0.2.0}/chain/safe/safe_contracts/multisend_v1_3_0.py +0 -0
- {opinion_clob_sdk-0.1.18 → opinion_clob_sdk-0.2.0}/chain/safe/safe_contracts/safe_v1_3_0.py +0 -0
- {opinion_clob_sdk-0.1.18 → opinion_clob_sdk-0.2.0}/chain/safe/safe_contracts/utils.py +0 -0
- {opinion_clob_sdk-0.1.18 → opinion_clob_sdk-0.2.0}/chain/safe/safe_signature.py +0 -0
- {opinion_clob_sdk-0.1.18 → opinion_clob_sdk-0.2.0}/chain/safe/safe_tx.py +0 -0
- {opinion_clob_sdk-0.1.18 → opinion_clob_sdk-0.2.0}/chain/safe/signatures.py +0 -0
- {opinion_clob_sdk-0.1.18 → opinion_clob_sdk-0.2.0}/chain/safe/typing.py +0 -0
- {opinion_clob_sdk-0.1.18 → opinion_clob_sdk-0.2.0}/chain/safe/utils.py +0 -0
- {opinion_clob_sdk-0.1.18 → opinion_clob_sdk-0.2.0}/model.py +0 -0
- {opinion_clob_sdk-0.1.18 → opinion_clob_sdk-0.2.0}/opinion_clob_sdk.egg-info/dependency_links.txt +0 -0
- {opinion_clob_sdk-0.1.18 → opinion_clob_sdk-0.2.0}/opinion_clob_sdk.egg-info/requires.txt +0 -0
- {opinion_clob_sdk-0.1.18 → opinion_clob_sdk-0.2.0}/opinion_clob_sdk.egg-info/top_level.txt +0 -0
- {opinion_clob_sdk-0.1.18 → opinion_clob_sdk-0.2.0}/setup.cfg +0 -0
- {opinion_clob_sdk-0.1.18 → opinion_clob_sdk-0.2.0}/tests/test_model.py +0 -0
- {opinion_clob_sdk-0.1.18 → opinion_clob_sdk-0.2.0}/tests/test_order_calculations.py +0 -0
- {opinion_clob_sdk-0.1.18 → opinion_clob_sdk-0.2.0}/tests/test_precision.py +0 -0
- {opinion_clob_sdk-0.1.18 → opinion_clob_sdk-0.2.0}/verify_api_calls.py +0 -0
|
@@ -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,12 @@
|
|
|
1
|
-
# Opinion CLOB SDK
|
|
1
|
+
# Opinion CLOB SDK (Tech Preview)
|
|
2
|
+
|
|
3
|
+
**Technology Preview Release - BNB Chain Support**
|
|
2
4
|
|
|
3
5
|
Python SDK for interacting with Opinion prediction markets via the CLOB (Central Limit Order Book) API.
|
|
4
6
|
|
|
7
|
+
> ⚠️ **Tech Preview Notice**: Version 0.2.0 includes the migration from Base to BNB Chain.
|
|
8
|
+
> While fully functional and tested, we recommend thorough testing in your environment before production use.
|
|
9
|
+
|
|
5
10
|
## Overview
|
|
6
11
|
|
|
7
12
|
The Opinion CLOB SDK provides a Python interface for:
|
|
@@ -10,7 +15,7 @@ The Opinion CLOB SDK provides a Python interface for:
|
|
|
10
15
|
- Tracking positions and balances
|
|
11
16
|
- Interacting with smart contracts (split, merge, redeem)
|
|
12
17
|
|
|
13
|
-
Supports
|
|
18
|
+
Supports BNB Chain mainnet (chain ID 56).
|
|
14
19
|
|
|
15
20
|
## Installation
|
|
16
21
|
|
|
@@ -27,7 +32,7 @@ from opinion_clob_sdk import Client
|
|
|
27
32
|
client = Client(
|
|
28
33
|
host='https://api.opinion.trade',
|
|
29
34
|
apikey='your_api_key',
|
|
30
|
-
chain_id=
|
|
35
|
+
chain_id=56, # BNB Chain mainnet
|
|
31
36
|
rpc_url='your_rpc_url',
|
|
32
37
|
private_key='your_private_key',
|
|
33
38
|
multi_sig_addr='your_multi_sig_address'
|
|
@@ -177,8 +182,7 @@ MULTI_SIG_ADDRESS=your_multi_sig_address
|
|
|
177
182
|
|
|
178
183
|
### Chain IDs
|
|
179
184
|
|
|
180
|
-
- **
|
|
181
|
-
- **Base Testnet**: 10143
|
|
185
|
+
- **BNB Chain Mainnet**: 56
|
|
182
186
|
|
|
183
187
|
## Development
|
|
184
188
|
|
|
@@ -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):
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Configuration constants for Opinion CLOB SDK
|
|
2
|
+
|
|
3
|
+
# 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
|
+
}
|
|
@@ -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,6 +1,11 @@
|
|
|
1
1
|
MANIFEST.in
|
|
2
2
|
README.md
|
|
3
|
+
__init__.py
|
|
4
|
+
config.py
|
|
5
|
+
model.py
|
|
6
|
+
sdk.py
|
|
3
7
|
setup.py
|
|
8
|
+
verify_api_calls.py
|
|
4
9
|
./__init__.py
|
|
5
10
|
./config.py
|
|
6
11
|
./model.py
|
|
@@ -44,6 +49,44 @@ setup.py
|
|
|
44
49
|
./chain/safe/safe_contracts/multisend_v1_3_0.py
|
|
45
50
|
./chain/safe/safe_contracts/safe_v1_3_0.py
|
|
46
51
|
./chain/safe/safe_contracts/utils.py
|
|
52
|
+
chain/__init__.py
|
|
53
|
+
chain/contract_caller.py
|
|
54
|
+
chain/exception.py
|
|
55
|
+
chain/contracts/__init__.py
|
|
56
|
+
chain/contracts/conditional_tokens.py
|
|
57
|
+
chain/contracts/erc20.py
|
|
58
|
+
chain/py_order_utils/__init__.py
|
|
59
|
+
chain/py_order_utils/constants.py
|
|
60
|
+
chain/py_order_utils/signer.py
|
|
61
|
+
chain/py_order_utils/utils.py
|
|
62
|
+
chain/py_order_utils/builders/__init__.py
|
|
63
|
+
chain/py_order_utils/builders/base_builder.py
|
|
64
|
+
chain/py_order_utils/builders/exception.py
|
|
65
|
+
chain/py_order_utils/builders/order_builder.py
|
|
66
|
+
chain/py_order_utils/builders/order_builder_test.py
|
|
67
|
+
chain/py_order_utils/model/__init__.py
|
|
68
|
+
chain/py_order_utils/model/order.py
|
|
69
|
+
chain/py_order_utils/model/order_type.py
|
|
70
|
+
chain/py_order_utils/model/sides.py
|
|
71
|
+
chain/py_order_utils/model/signatures.py
|
|
72
|
+
chain/safe/__init__.py
|
|
73
|
+
chain/safe/constants.py
|
|
74
|
+
chain/safe/enums.py
|
|
75
|
+
chain/safe/exceptions.py
|
|
76
|
+
chain/safe/multisend.py
|
|
77
|
+
chain/safe/safe.py
|
|
78
|
+
chain/safe/safe_signature.py
|
|
79
|
+
chain/safe/safe_test.py
|
|
80
|
+
chain/safe/safe_tx.py
|
|
81
|
+
chain/safe/signatures.py
|
|
82
|
+
chain/safe/typing.py
|
|
83
|
+
chain/safe/utils.py
|
|
84
|
+
chain/safe/eip712/__init__.py
|
|
85
|
+
chain/safe/safe_contracts/__init__.py
|
|
86
|
+
chain/safe/safe_contracts/compatibility_fallback_handler_v1_3_0.py
|
|
87
|
+
chain/safe/safe_contracts/multisend_v1_3_0.py
|
|
88
|
+
chain/safe/safe_contracts/safe_v1_3_0.py
|
|
89
|
+
chain/safe/safe_contracts/utils.py
|
|
47
90
|
opinion_clob_sdk.egg-info/PKG-INFO
|
|
48
91
|
opinion_clob_sdk.egg-info/SOURCES.txt
|
|
49
92
|
opinion_clob_sdk.egg-info/dependency_links.txt
|
|
@@ -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
|
|
@@ -652,8 +664,8 @@ class Client:
|
|
|
652
664
|
|
|
653
665
|
from opinion_api.models.openapi_cancel_order_request_open_api import OpenapiCancelOrderRequestOpenAPI
|
|
654
666
|
|
|
655
|
-
#
|
|
656
|
-
request_body = OpenapiCancelOrderRequestOpenAPI(
|
|
667
|
+
# Use order_id for API request
|
|
668
|
+
request_body = OpenapiCancelOrderRequestOpenAPI(order_id=order_id)
|
|
657
669
|
result = self.market_api.openapi_order_cancel_post(apikey=self.api_key, cancel_order_req=request_body)
|
|
658
670
|
return result
|
|
659
671
|
|
|
@@ -768,6 +780,7 @@ class Client:
|
|
|
768
780
|
def cancel_all_orders(self, market_id: Optional[int] = None, side: Optional[OrderSide] = None) -> dict:
|
|
769
781
|
"""
|
|
770
782
|
Cancel all open orders, optionally filtered by market and/or side.
|
|
783
|
+
Uses pagination to fetch all orders (max 20 per page).
|
|
771
784
|
|
|
772
785
|
Args:
|
|
773
786
|
market_id: Optional filter - only cancel orders for this market
|
|
@@ -781,18 +794,40 @@ class Client:
|
|
|
781
794
|
'results': List[dict]
|
|
782
795
|
}
|
|
783
796
|
"""
|
|
784
|
-
#
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
797
|
+
# Collect all open orders using pagination
|
|
798
|
+
all_orders_list = []
|
|
799
|
+
page = 1
|
|
800
|
+
limit = 20 # Backend max page size
|
|
801
|
+
max_pages = 100 # Safety limit to prevent infinite loops
|
|
802
|
+
|
|
803
|
+
while page <= max_pages:
|
|
804
|
+
# Get orders for current page
|
|
805
|
+
page_orders = self.get_my_orders(
|
|
806
|
+
market_id=market_id if market_id else 0,
|
|
807
|
+
status='1', # 1 = pending/open orders
|
|
808
|
+
limit=limit,
|
|
809
|
+
page=page
|
|
810
|
+
)
|
|
811
|
+
|
|
812
|
+
# Parse response to get order list
|
|
813
|
+
orders_list = self._parse_list_response(page_orders, f"get open orders page {page}")
|
|
814
|
+
|
|
815
|
+
if not orders_list or len(orders_list) == 0:
|
|
816
|
+
# No more orders on this page
|
|
817
|
+
break
|
|
791
818
|
|
|
792
|
-
|
|
793
|
-
orders_list = self._parse_list_response(all_orders, "get open orders for cancellation")
|
|
819
|
+
all_orders_list.extend(orders_list)
|
|
794
820
|
|
|
795
|
-
|
|
821
|
+
# If we got fewer orders than the limit, we've reached the last page
|
|
822
|
+
if len(orders_list) < limit:
|
|
823
|
+
break
|
|
824
|
+
|
|
825
|
+
page += 1
|
|
826
|
+
|
|
827
|
+
if page > max_pages:
|
|
828
|
+
logging.warning(f"Reached maximum page limit ({max_pages}), there may be more orders")
|
|
829
|
+
|
|
830
|
+
if not all_orders_list or len(all_orders_list) == 0:
|
|
796
831
|
logging.info("No open orders to cancel")
|
|
797
832
|
return {
|
|
798
833
|
'total_orders': 0,
|
|
@@ -803,10 +838,10 @@ class Client:
|
|
|
803
838
|
|
|
804
839
|
# Filter by side if specified
|
|
805
840
|
if side:
|
|
806
|
-
|
|
841
|
+
all_orders_list = [order for order in all_orders_list if int(order.side) == int(side.value)]
|
|
807
842
|
|
|
808
|
-
# Extract order IDs
|
|
809
|
-
order_ids = [order.
|
|
843
|
+
# Extract order IDs from the response
|
|
844
|
+
order_ids = [order.order_id for order in all_orders_list if hasattr(order, 'order_id')]
|
|
810
845
|
|
|
811
846
|
if not order_ids:
|
|
812
847
|
logging.info("No orders match the filter criteria")
|
|
@@ -817,6 +852,8 @@ class Client:
|
|
|
817
852
|
'results': []
|
|
818
853
|
}
|
|
819
854
|
|
|
855
|
+
logging.info(f"Found {len(order_ids)} orders to cancel")
|
|
856
|
+
|
|
820
857
|
# Cancel all orders in batch
|
|
821
858
|
results = self.cancel_orders_batch(order_ids)
|
|
822
859
|
|
|
@@ -1,24 +1,29 @@
|
|
|
1
1
|
from setuptools import setup, find_packages
|
|
2
2
|
|
|
3
3
|
NAME = "opinion_clob_sdk"
|
|
4
|
-
VERSION = "0.
|
|
4
|
+
VERSION = "0.2.0"
|
|
5
5
|
|
|
6
6
|
setup(
|
|
7
7
|
name=NAME,
|
|
8
8
|
version=VERSION,
|
|
9
|
-
description="Opinion CLOB SDK - Python SDK for Opinion Prediction Market Central Limit Order Book API",
|
|
9
|
+
description="Opinion CLOB SDK (Tech Preview) - Python SDK for Opinion Prediction Market Central Limit Order Book API",
|
|
10
10
|
long_description="""
|
|
11
|
-
# Opinion CLOB SDK
|
|
11
|
+
# Opinion CLOB SDK (Tech Preview)
|
|
12
|
+
|
|
13
|
+
**Technology Preview Release - BNB Chain Support**
|
|
12
14
|
|
|
13
15
|
Python SDK for interacting with Opinion prediction markets via the CLOB (Central Limit Order Book) API.
|
|
14
16
|
|
|
17
|
+
> ⚠️ **Tech Preview Notice**: This version includes the migration from Base to BNB Chain.
|
|
18
|
+
> While fully functional and tested, we recommend thorough testing in your environment before production use.
|
|
19
|
+
|
|
15
20
|
## Features
|
|
16
21
|
|
|
17
22
|
- Market data queries (markets, orderbooks, prices, candles)
|
|
18
23
|
- Order management (place, cancel, query orders)
|
|
19
24
|
- Position and balance tracking
|
|
20
25
|
- Smart contract interactions (split, merge, redeem)
|
|
21
|
-
- Support for
|
|
26
|
+
- Support for BNB Chain mainnet (chain ID 56)
|
|
22
27
|
|
|
23
28
|
## Installation
|
|
24
29
|
|
|
@@ -34,8 +39,8 @@ from opinion_clob_sdk import Client
|
|
|
34
39
|
client = Client(
|
|
35
40
|
host='https://api.opinion.trade',
|
|
36
41
|
apikey='your_api_key',
|
|
37
|
-
chain_id=
|
|
38
|
-
rpc_url='
|
|
42
|
+
chain_id=56, # BNB Chain mainnet
|
|
43
|
+
rpc_url='https://bsc-dataseed.binance.org',
|
|
39
44
|
private_key='your_private_key',
|
|
40
45
|
multi_sig_addr='your_multi_sig_address'
|
|
41
46
|
)
|
|
@@ -67,7 +72,7 @@ result = client.place_order(order_data)
|
|
|
67
72
|
author="Opinion Labs",
|
|
68
73
|
author_email="support@opinion.trade",
|
|
69
74
|
url="https://opinion.trade",
|
|
70
|
-
keywords=["PredictionMarket", "CLOB", "Trading", "Blockchain", "
|
|
75
|
+
keywords=["PredictionMarket", "CLOB", "Trading", "Blockchain", "BNBChain", "BSC", "Opinion"],
|
|
71
76
|
install_requires=[
|
|
72
77
|
"urllib3 >= 2.3.0",
|
|
73
78
|
"six >= 1.17.0",
|
|
@@ -95,7 +100,7 @@ result = client.place_order(order_data)
|
|
|
95
100
|
include_package_data=True,
|
|
96
101
|
python_requires=">=3.8",
|
|
97
102
|
classifiers=[
|
|
98
|
-
"Development Status ::
|
|
103
|
+
"Development Status :: 5 - Production/Stable",
|
|
99
104
|
"Intended Audience :: Developers",
|
|
100
105
|
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
101
106
|
"License :: OSI Approved :: MIT License",
|
|
@@ -9,16 +9,16 @@ class TestClientInitialization:
|
|
|
9
9
|
|
|
10
10
|
def test_client_initialization_with_valid_chain_id(self):
|
|
11
11
|
"""Test client initialization with valid chain ID"""
|
|
12
|
-
# Test
|
|
12
|
+
# Test BNB Chain mainnet
|
|
13
13
|
client = Client(
|
|
14
14
|
host='https://api.opinion.trade',
|
|
15
15
|
apikey='test_key',
|
|
16
|
-
chain_id=
|
|
17
|
-
rpc_url='https://
|
|
16
|
+
chain_id=56,
|
|
17
|
+
rpc_url='https://bsc-dataseed.binance.org',
|
|
18
18
|
private_key='0x' + '0' * 64,
|
|
19
19
|
multi_sig_addr='0x' + '0' * 40
|
|
20
20
|
)
|
|
21
|
-
assert client.chain_id ==
|
|
21
|
+
assert client.chain_id == 56
|
|
22
22
|
|
|
23
23
|
def test_client_initialization_with_invalid_chain_id(self):
|
|
24
24
|
"""Test client initialization with invalid chain ID"""
|
|
@@ -27,7 +27,7 @@ class TestClientInitialization:
|
|
|
27
27
|
host='https://api.opinion.trade',
|
|
28
28
|
apikey='test_key',
|
|
29
29
|
chain_id=1, # Invalid chain ID
|
|
30
|
-
rpc_url='https://
|
|
30
|
+
rpc_url='https://bsc-dataseed.binance.org',
|
|
31
31
|
private_key='0x' + '0' * 64,
|
|
32
32
|
multi_sig_addr='0x' + '0' * 40
|
|
33
33
|
)
|
|
@@ -44,8 +44,8 @@ class TestMarketQueries:
|
|
|
44
44
|
client = Client(
|
|
45
45
|
host='https://api.opinion.trade',
|
|
46
46
|
apikey='test_key',
|
|
47
|
-
chain_id=
|
|
48
|
-
rpc_url='https://
|
|
47
|
+
chain_id=56,
|
|
48
|
+
rpc_url='https://bsc-dataseed.binance.org',
|
|
49
49
|
private_key='0x' + '0' * 64,
|
|
50
50
|
multi_sig_addr='0x' + '0' * 40
|
|
51
51
|
)
|
|
@@ -67,8 +67,8 @@ class TestMarketQueries:
|
|
|
67
67
|
client = Client(
|
|
68
68
|
host='https://api.opinion.trade',
|
|
69
69
|
apikey='test_key',
|
|
70
|
-
chain_id=
|
|
71
|
-
rpc_url='https://
|
|
70
|
+
chain_id=56,
|
|
71
|
+
rpc_url='https://bsc-dataseed.binance.org',
|
|
72
72
|
private_key='0x' + '0' * 64,
|
|
73
73
|
multi_sig_addr='0x' + '0' * 40
|
|
74
74
|
)
|
|
@@ -84,8 +84,8 @@ class TestMarketQueries:
|
|
|
84
84
|
client = Client(
|
|
85
85
|
host='https://api.opinion.trade',
|
|
86
86
|
apikey='test_key',
|
|
87
|
-
chain_id=
|
|
88
|
-
rpc_url='https://
|
|
87
|
+
chain_id=56,
|
|
88
|
+
rpc_url='https://bsc-dataseed.binance.org',
|
|
89
89
|
private_key='0x' + '0' * 64,
|
|
90
90
|
multi_sig_addr='0x' + '0' * 40
|
|
91
91
|
)
|
|
@@ -101,8 +101,8 @@ class TestMarketQueries:
|
|
|
101
101
|
client = Client(
|
|
102
102
|
host='https://api.opinion.trade',
|
|
103
103
|
apikey='test_key',
|
|
104
|
-
chain_id=
|
|
105
|
-
rpc_url='https://
|
|
104
|
+
chain_id=56,
|
|
105
|
+
rpc_url='https://bsc-dataseed.binance.org',
|
|
106
106
|
private_key='0x' + '0' * 64,
|
|
107
107
|
multi_sig_addr='0x' + '0' * 40
|
|
108
108
|
)
|
|
@@ -122,8 +122,8 @@ class TestTokenQueries:
|
|
|
122
122
|
client = Client(
|
|
123
123
|
host='https://api.opinion.trade',
|
|
124
124
|
apikey='test_key',
|
|
125
|
-
chain_id=
|
|
126
|
-
rpc_url='https://
|
|
125
|
+
chain_id=56,
|
|
126
|
+
rpc_url='https://bsc-dataseed.binance.org',
|
|
127
127
|
private_key='0x' + '0' * 64,
|
|
128
128
|
multi_sig_addr='0x' + '0' * 40
|
|
129
129
|
)
|
|
@@ -139,8 +139,8 @@ class TestTokenQueries:
|
|
|
139
139
|
client = Client(
|
|
140
140
|
host='https://api.opinion.trade',
|
|
141
141
|
apikey='test_key',
|
|
142
|
-
chain_id=
|
|
143
|
-
rpc_url='https://
|
|
142
|
+
chain_id=56,
|
|
143
|
+
rpc_url='https://bsc-dataseed.binance.org',
|
|
144
144
|
private_key='0x' + '0' * 64,
|
|
145
145
|
multi_sig_addr='0x' + '0' * 40
|
|
146
146
|
)
|
|
@@ -163,8 +163,8 @@ class TestTokenQueries:
|
|
|
163
163
|
client = Client(
|
|
164
164
|
host='https://api.opinion.trade',
|
|
165
165
|
apikey='test_key',
|
|
166
|
-
chain_id=
|
|
167
|
-
rpc_url='https://
|
|
166
|
+
chain_id=56,
|
|
167
|
+
rpc_url='https://bsc-dataseed.binance.org',
|
|
168
168
|
private_key='0x' + '0' * 64,
|
|
169
169
|
multi_sig_addr='0x' + '0' * 40
|
|
170
170
|
)
|
|
@@ -191,8 +191,8 @@ class TestUserQueries:
|
|
|
191
191
|
client = Client(
|
|
192
192
|
host='https://api.opinion.trade',
|
|
193
193
|
apikey='test_key',
|
|
194
|
-
chain_id=
|
|
195
|
-
rpc_url='https://
|
|
194
|
+
chain_id=56,
|
|
195
|
+
rpc_url='https://bsc-dataseed.binance.org',
|
|
196
196
|
private_key='0x' + '0' * 64,
|
|
197
197
|
multi_sig_addr='0x' + '0' * 40
|
|
198
198
|
)
|
|
@@ -208,8 +208,8 @@ class TestUserQueries:
|
|
|
208
208
|
client = Client(
|
|
209
209
|
host='https://api.opinion.trade',
|
|
210
210
|
apikey='test_key',
|
|
211
|
-
chain_id=
|
|
212
|
-
rpc_url='https://
|
|
211
|
+
chain_id=56,
|
|
212
|
+
rpc_url='https://bsc-dataseed.binance.org',
|
|
213
213
|
private_key='0x' + '0' * 64,
|
|
214
214
|
multi_sig_addr='0x' + '0' * 40
|
|
215
215
|
)
|
|
@@ -225,8 +225,8 @@ class TestUserQueries:
|
|
|
225
225
|
client = Client(
|
|
226
226
|
host='https://api.opinion.trade',
|
|
227
227
|
apikey='test_key',
|
|
228
|
-
chain_id=
|
|
229
|
-
rpc_url='https://
|
|
228
|
+
chain_id=56,
|
|
229
|
+
rpc_url='https://bsc-dataseed.binance.org',
|
|
230
230
|
private_key='0x' + '0' * 64,
|
|
231
231
|
multi_sig_addr='0x' + '0' * 40
|
|
232
232
|
)
|
|
@@ -242,8 +242,8 @@ class TestUserQueries:
|
|
|
242
242
|
client = Client(
|
|
243
243
|
host='https://api.opinion.trade',
|
|
244
244
|
apikey='test_key',
|
|
245
|
-
chain_id=
|
|
246
|
-
rpc_url='https://
|
|
245
|
+
chain_id=56,
|
|
246
|
+
rpc_url='https://bsc-dataseed.binance.org',
|
|
247
247
|
private_key='0x' + '0' * 64,
|
|
248
248
|
multi_sig_addr='0x' + '0' * 40
|
|
249
249
|
)
|
|
@@ -267,8 +267,8 @@ class TestOrderOperations:
|
|
|
267
267
|
client = Client(
|
|
268
268
|
host='https://api.opinion.trade',
|
|
269
269
|
apikey='test_key',
|
|
270
|
-
chain_id=
|
|
271
|
-
rpc_url='https://
|
|
270
|
+
chain_id=56,
|
|
271
|
+
rpc_url='https://bsc-dataseed.binance.org',
|
|
272
272
|
private_key='0x' + '0' * 64,
|
|
273
273
|
multi_sig_addr='0x' + '0' * 40
|
|
274
274
|
)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{opinion_clob_sdk-0.1.18 → opinion_clob_sdk-0.2.0}/chain/py_order_utils/builders/__init__.py
RENAMED
|
File without changes
|
{opinion_clob_sdk-0.1.18 → opinion_clob_sdk-0.2.0}/chain/py_order_utils/builders/exception.py
RENAMED
|
File without changes
|
{opinion_clob_sdk-0.1.18 → opinion_clob_sdk-0.2.0}/chain/py_order_utils/builders/order_builder.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{opinion_clob_sdk-0.1.18 → opinion_clob_sdk-0.2.0}/chain/safe/safe_contracts/multisend_v1_3_0.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{opinion_clob_sdk-0.1.18 → opinion_clob_sdk-0.2.0}/opinion_clob_sdk.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|