opinion-clob-sdk 0.1.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.0/PKG-INFO +97 -0
- opinion_clob_sdk-0.1.0/README.md +232 -0
- opinion_clob_sdk-0.1.0/chain/__init__.py +0 -0
- opinion_clob_sdk-0.1.0/chain/contract_caller.py +390 -0
- opinion_clob_sdk-0.1.0/chain/contracts/__init__.py +0 -0
- opinion_clob_sdk-0.1.0/chain/contracts/conditional_tokens.py +707 -0
- opinion_clob_sdk-0.1.0/chain/contracts/erc20.py +111 -0
- opinion_clob_sdk-0.1.0/chain/exception.py +11 -0
- opinion_clob_sdk-0.1.0/chain/py_order_utils/__init__.py +0 -0
- opinion_clob_sdk-0.1.0/chain/py_order_utils/builders/__init__.py +0 -0
- opinion_clob_sdk-0.1.0/chain/py_order_utils/builders/base_builder.py +41 -0
- opinion_clob_sdk-0.1.0/chain/py_order_utils/builders/exception.py +2 -0
- opinion_clob_sdk-0.1.0/chain/py_order_utils/builders/order_builder.py +90 -0
- opinion_clob_sdk-0.1.0/chain/py_order_utils/builders/order_builder_test.py +40 -0
- opinion_clob_sdk-0.1.0/chain/py_order_utils/constants.py +2 -0
- opinion_clob_sdk-0.1.0/chain/py_order_utils/model/__init__.py +0 -0
- opinion_clob_sdk-0.1.0/chain/py_order_utils/model/order.py +254 -0
- opinion_clob_sdk-0.1.0/chain/py_order_utils/model/order_type.py +9 -0
- opinion_clob_sdk-0.1.0/chain/py_order_utils/model/sides.py +8 -0
- opinion_clob_sdk-0.1.0/chain/py_order_utils/model/signatures.py +8 -0
- opinion_clob_sdk-0.1.0/chain/py_order_utils/signer.py +20 -0
- opinion_clob_sdk-0.1.0/chain/py_order_utils/utils.py +109 -0
- opinion_clob_sdk-0.1.0/chain/safe/__init__.py +0 -0
- opinion_clob_sdk-0.1.0/chain/safe/constants.py +19 -0
- opinion_clob_sdk-0.1.0/chain/safe/eip712/__init__.py +176 -0
- opinion_clob_sdk-0.1.0/chain/safe/enums.py +6 -0
- opinion_clob_sdk-0.1.0/chain/safe/exceptions.py +94 -0
- opinion_clob_sdk-0.1.0/chain/safe/multisend.py +347 -0
- opinion_clob_sdk-0.1.0/chain/safe/safe.py +141 -0
- opinion_clob_sdk-0.1.0/chain/safe/safe_contracts/__init__.py +0 -0
- opinion_clob_sdk-0.1.0/chain/safe/safe_contracts/compatibility_fallback_handler_v1_3_0.py +327 -0
- opinion_clob_sdk-0.1.0/chain/safe/safe_contracts/multisend_v1_3_0.py +22 -0
- opinion_clob_sdk-0.1.0/chain/safe/safe_contracts/safe_v1_3_0.py +1035 -0
- opinion_clob_sdk-0.1.0/chain/safe/safe_contracts/utils.py +26 -0
- opinion_clob_sdk-0.1.0/chain/safe/safe_signature.py +364 -0
- opinion_clob_sdk-0.1.0/chain/safe/safe_test.py +37 -0
- opinion_clob_sdk-0.1.0/chain/safe/safe_tx.py +437 -0
- opinion_clob_sdk-0.1.0/chain/safe/signatures.py +63 -0
- opinion_clob_sdk-0.1.0/chain/safe/typing.py +17 -0
- opinion_clob_sdk-0.1.0/chain/safe/utils.py +218 -0
- opinion_clob_sdk-0.1.0/opinion_clob_sdk.egg-info/PKG-INFO +97 -0
- opinion_clob_sdk-0.1.0/opinion_clob_sdk.egg-info/SOURCES.txt +49 -0
- opinion_clob_sdk-0.1.0/opinion_clob_sdk.egg-info/dependency_links.txt +1 -0
- opinion_clob_sdk-0.1.0/opinion_clob_sdk.egg-info/requires.txt +10 -0
- opinion_clob_sdk-0.1.0/opinion_clob_sdk.egg-info/top_level.txt +1 -0
- opinion_clob_sdk-0.1.0/setup.cfg +4 -0
- opinion_clob_sdk-0.1.0/setup.py +98 -0
- opinion_clob_sdk-0.1.0/tests/test_integration.py +135 -0
- opinion_clob_sdk-0.1.0/tests/test_model.py +43 -0
- opinion_clob_sdk-0.1.0/tests/test_order_calculations.py +112 -0
- opinion_clob_sdk-0.1.0/tests/test_sdk.py +274 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: opinion_clob_sdk
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Opinion CLOB SDK - Python SDK for Opinion Prediction Market Central Limit Order Book API
|
|
5
|
+
Home-page: https://opinion.trade
|
|
6
|
+
Author: Opinion Labs
|
|
7
|
+
Author-email: support@opinion.trade
|
|
8
|
+
Keywords: PredictionMarket,CLOB,Trading,Blockchain,Base,Opinion
|
|
9
|
+
Classifier: Development Status :: 4 - Beta
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Requires-Python: >=3.8
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
Requires-Dist: urllib3>=2.3.0
|
|
22
|
+
Requires-Dist: six>=1.17.0
|
|
23
|
+
Requires-Dist: certifi>=2024.12.14
|
|
24
|
+
Requires-Dist: python-dateutil>=2.9.0.post0
|
|
25
|
+
Requires-Dist: hexbytes>=1.2.1
|
|
26
|
+
Requires-Dist: web3>=7.6.1
|
|
27
|
+
Requires-Dist: eth_account>=0.13.0
|
|
28
|
+
Requires-Dist: poly_eip712_structs>=0.0.1
|
|
29
|
+
Requires-Dist: opinion_api>=0.1.0
|
|
30
|
+
Requires-Dist: pytest>=7.0.0
|
|
31
|
+
Dynamic: author
|
|
32
|
+
Dynamic: author-email
|
|
33
|
+
Dynamic: classifier
|
|
34
|
+
Dynamic: description
|
|
35
|
+
Dynamic: description-content-type
|
|
36
|
+
Dynamic: home-page
|
|
37
|
+
Dynamic: keywords
|
|
38
|
+
Dynamic: requires-dist
|
|
39
|
+
Dynamic: requires-python
|
|
40
|
+
Dynamic: summary
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
# Opinion CLOB SDK
|
|
44
|
+
|
|
45
|
+
Python SDK for interacting with Opinion prediction markets via the CLOB (Central Limit Order Book) API.
|
|
46
|
+
|
|
47
|
+
## Features
|
|
48
|
+
|
|
49
|
+
- Market data queries (markets, orderbooks, prices, candles)
|
|
50
|
+
- Order management (place, cancel, query orders)
|
|
51
|
+
- Position and balance tracking
|
|
52
|
+
- Smart contract interactions (split, merge, redeem)
|
|
53
|
+
- Support for Base mainnet (chain ID 8453)
|
|
54
|
+
|
|
55
|
+
## Installation
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
pip install opinion_clob_sdk
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Quick Start
|
|
62
|
+
|
|
63
|
+
```python
|
|
64
|
+
from opinion_clob_sdk import Client
|
|
65
|
+
|
|
66
|
+
client = Client(
|
|
67
|
+
host='https://api.opinion.trade',
|
|
68
|
+
apikey='your_api_key',
|
|
69
|
+
chain_id=8453, # Base mainnet
|
|
70
|
+
rpc_url='your_rpc_url',
|
|
71
|
+
private_key='your_private_key',
|
|
72
|
+
multi_sig_addr='your_multi_sig_address'
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
# Get markets
|
|
76
|
+
markets = client.get_markets(page=1, limit=10)
|
|
77
|
+
|
|
78
|
+
# Get orderbook
|
|
79
|
+
orderbook = client.get_orderbook(token_id='token_id')
|
|
80
|
+
|
|
81
|
+
# Place an order
|
|
82
|
+
from opinion_clob_sdk.chain.py_order_utils.model.order import PlaceOrderDataInput
|
|
83
|
+
from opinion_clob_sdk.chain.py_order_utils.model.sides import OrderSide
|
|
84
|
+
from opinion_clob_sdk.chain.py_order_utils.model.order_type import LIMIT_ORDER
|
|
85
|
+
|
|
86
|
+
order_data = PlaceOrderDataInput(
|
|
87
|
+
marketId=123,
|
|
88
|
+
tokenId='token_id',
|
|
89
|
+
side=OrderSide.BUY,
|
|
90
|
+
orderType=LIMIT_ORDER,
|
|
91
|
+
price='0.5',
|
|
92
|
+
makerAmountInQuoteToken=10
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
result = client.place_order(order_data)
|
|
96
|
+
```
|
|
97
|
+
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
# Opinion CLOB SDK
|
|
2
|
+
|
|
3
|
+
Python SDK for interacting with Opinion prediction markets via the CLOB (Central Limit Order Book) API.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
The Opinion CLOB SDK provides a Python interface for:
|
|
8
|
+
- Querying prediction market data
|
|
9
|
+
- Placing and managing orders
|
|
10
|
+
- Tracking positions and balances
|
|
11
|
+
- Interacting with smart contracts (split, merge, redeem)
|
|
12
|
+
|
|
13
|
+
Supports Base mainnet (chain ID 8453) and Base testnet (chain ID 10143).
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pip install opinion_clob_sdk
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Quick Start
|
|
22
|
+
|
|
23
|
+
```python
|
|
24
|
+
from opinion_clob_sdk import Client
|
|
25
|
+
|
|
26
|
+
# Initialize client
|
|
27
|
+
client = Client(
|
|
28
|
+
host='https://api.opinion.trade',
|
|
29
|
+
apikey='your_api_key',
|
|
30
|
+
chain_id=8453, # Base mainnet
|
|
31
|
+
rpc_url='your_rpc_url',
|
|
32
|
+
private_key='your_private_key',
|
|
33
|
+
multi_sig_addr='your_multi_sig_address'
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
# Get markets
|
|
37
|
+
markets = client.get_markets(page=1, limit=10)
|
|
38
|
+
|
|
39
|
+
# Get market detail
|
|
40
|
+
market = client.get_market(market_id=123)
|
|
41
|
+
|
|
42
|
+
# Get orderbook
|
|
43
|
+
orderbook = client.get_orderbook(token_id='token_123')
|
|
44
|
+
|
|
45
|
+
# Get latest price
|
|
46
|
+
price = client.get_latest_price(token_id='token_123')
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Core Features
|
|
50
|
+
|
|
51
|
+
### Market Data
|
|
52
|
+
|
|
53
|
+
```python
|
|
54
|
+
# Get all markets with filters
|
|
55
|
+
from opinion_clob_sdk.model import TopicType, TopicStatusFilter
|
|
56
|
+
|
|
57
|
+
markets = client.get_markets(
|
|
58
|
+
topic_type=TopicType.BINARY,
|
|
59
|
+
status=TopicStatusFilter.ACTIVATED,
|
|
60
|
+
page=1,
|
|
61
|
+
limit=20
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
# Get specific market
|
|
65
|
+
market = client.get_market(market_id=123)
|
|
66
|
+
|
|
67
|
+
# Get categorical market
|
|
68
|
+
categorical = client.get_categorical_market(market_id=456)
|
|
69
|
+
|
|
70
|
+
# Get supported currencies
|
|
71
|
+
currencies = client.get_currencies()
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Token Data
|
|
75
|
+
|
|
76
|
+
```python
|
|
77
|
+
# Get orderbook
|
|
78
|
+
orderbook = client.get_orderbook(token_id='token_123')
|
|
79
|
+
|
|
80
|
+
# Get latest price
|
|
81
|
+
price = client.get_latest_price(token_id='token_123')
|
|
82
|
+
|
|
83
|
+
# Get price history
|
|
84
|
+
history = client.get_price_history(
|
|
85
|
+
token_id='token_123',
|
|
86
|
+
interval='1hour',
|
|
87
|
+
bars=24
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
# Get fee rates
|
|
91
|
+
fees = client.get_fee_rates(token_id='token_123')
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Trading
|
|
95
|
+
|
|
96
|
+
```python
|
|
97
|
+
from opinion_clob_sdk.chain.py_order_utils.model.order import PlaceOrderDataInput
|
|
98
|
+
from opinion_clob_sdk.chain.py_order_utils.model.sides import OrderSide
|
|
99
|
+
from opinion_clob_sdk.chain.py_order_utils.model.order_type import LIMIT_ORDER, MARKET_ORDER
|
|
100
|
+
|
|
101
|
+
# Place a limit order
|
|
102
|
+
order_data = PlaceOrderDataInput(
|
|
103
|
+
marketId=123,
|
|
104
|
+
tokenId='token_yes',
|
|
105
|
+
side=OrderSide.BUY,
|
|
106
|
+
orderType=LIMIT_ORDER,
|
|
107
|
+
price='0.5',
|
|
108
|
+
makerAmountInQuoteToken=10 # 10 USDC
|
|
109
|
+
)
|
|
110
|
+
result = client.place_order(order_data)
|
|
111
|
+
|
|
112
|
+
# Place a market order
|
|
113
|
+
market_order = PlaceOrderDataInput(
|
|
114
|
+
marketId=123,
|
|
115
|
+
tokenId='token_yes',
|
|
116
|
+
side=OrderSide.SELL,
|
|
117
|
+
orderType=MARKET_ORDER,
|
|
118
|
+
price='0', # Market orders don't need price
|
|
119
|
+
makerAmountInBaseToken=5 # 5 YES tokens
|
|
120
|
+
)
|
|
121
|
+
result = client.place_order(market_order)
|
|
122
|
+
|
|
123
|
+
# Cancel an order
|
|
124
|
+
client.cancel_order(trans_no='order_trans_no')
|
|
125
|
+
|
|
126
|
+
# Get my orders
|
|
127
|
+
my_orders = client.get_my_orders(market_id=123, limit=10)
|
|
128
|
+
|
|
129
|
+
# Get order by ID
|
|
130
|
+
order = client.get_order_by_id(order_id='order_123')
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### User Data
|
|
134
|
+
|
|
135
|
+
```python
|
|
136
|
+
# Get balances
|
|
137
|
+
balances = client.get_my_balances()
|
|
138
|
+
|
|
139
|
+
# Get positions
|
|
140
|
+
positions = client.get_my_positions(page=1, pageSize=10)
|
|
141
|
+
|
|
142
|
+
# Get trade history
|
|
143
|
+
trades = client.get_my_trades(market_id=123, limit=20)
|
|
144
|
+
|
|
145
|
+
# Get user auth info
|
|
146
|
+
auth = client.get_user_auth()
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### Smart Contract Operations
|
|
150
|
+
|
|
151
|
+
```python
|
|
152
|
+
# Enable trading (approve tokens)
|
|
153
|
+
client.enable_trading()
|
|
154
|
+
|
|
155
|
+
# Split collateral into outcome tokens
|
|
156
|
+
tx_hash = client.split(market_id=123, amount=1000000) # amount in wei
|
|
157
|
+
|
|
158
|
+
# Merge outcome tokens back to collateral
|
|
159
|
+
tx_hash = client.merge(market_id=123, amount=1000000)
|
|
160
|
+
|
|
161
|
+
# Redeem winning positions
|
|
162
|
+
tx_hash = client.redeem(market_id=123)
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
## Configuration
|
|
166
|
+
|
|
167
|
+
### Environment Variables
|
|
168
|
+
|
|
169
|
+
Create a `.env` file:
|
|
170
|
+
|
|
171
|
+
```
|
|
172
|
+
API_KEY=your_api_key
|
|
173
|
+
RPC_URL=your_rpc_url
|
|
174
|
+
PRIVATE_KEY=your_private_key
|
|
175
|
+
MULTI_SIG_ADDRESS=your_multi_sig_address
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### Chain IDs
|
|
179
|
+
|
|
180
|
+
- **Base Mainnet**: 8453
|
|
181
|
+
- **Base Testnet**: 10143
|
|
182
|
+
|
|
183
|
+
## Development
|
|
184
|
+
|
|
185
|
+
### Running Tests
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
# Install development dependencies
|
|
189
|
+
pip install -r requirements.txt
|
|
190
|
+
|
|
191
|
+
# Run unit tests
|
|
192
|
+
pytest -v -m "not integration"
|
|
193
|
+
|
|
194
|
+
# Run all tests (including integration)
|
|
195
|
+
pytest -v
|
|
196
|
+
|
|
197
|
+
# Run with coverage
|
|
198
|
+
pytest --cov=opinion_clob_sdk --cov-report=html
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### Project Structure
|
|
202
|
+
|
|
203
|
+
```
|
|
204
|
+
opinion_clob_sdk/
|
|
205
|
+
├── __init__.py # Package exports
|
|
206
|
+
├── sdk.py # Main Client class
|
|
207
|
+
├── model.py # Enums and types
|
|
208
|
+
├── config.py # Configuration constants
|
|
209
|
+
├── chain/ # Blockchain interactions
|
|
210
|
+
│ ├── contract_caller.py
|
|
211
|
+
│ ├── py_order_utils/ # Order building and signing
|
|
212
|
+
│ └── safe/ # Gnosis Safe integration
|
|
213
|
+
└── tests/ # Test suite
|
|
214
|
+
├── test_sdk.py
|
|
215
|
+
├── test_model.py
|
|
216
|
+
├── test_order_calculations.py
|
|
217
|
+
└── test_integration.py
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
## API Reference
|
|
221
|
+
|
|
222
|
+
See the [full API documentation](https://docs.opinion.trade) for detailed information.
|
|
223
|
+
|
|
224
|
+
## Support
|
|
225
|
+
|
|
226
|
+
- Documentation: https://docs.opinion.trade
|
|
227
|
+
- Email: support@opinion.trade
|
|
228
|
+
- GitHub Issues: https://github.com/opinionlabs/openapi/issues
|
|
229
|
+
|
|
230
|
+
## License
|
|
231
|
+
|
|
232
|
+
MIT License - see LICENSE file for details
|
|
File without changes
|