ostium-python-sdk 0.1.34__tar.gz → 0.1.36__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.
- {ostium_python_sdk-0.1.34 → ostium_python_sdk-0.1.36}/PKG-INFO +14 -2
- {ostium_python_sdk-0.1.34 → ostium_python_sdk-0.1.36}/README.md +3 -1
- {ostium_python_sdk-0.1.34 → ostium_python_sdk-0.1.36}/ostium_python_sdk/faucet.py +10 -2
- {ostium_python_sdk-0.1.34 → ostium_python_sdk-0.1.36}/ostium_python_sdk/ostium.py +11 -8
- {ostium_python_sdk-0.1.34 → ostium_python_sdk-0.1.36}/ostium_python_sdk.egg-info/PKG-INFO +14 -2
- {ostium_python_sdk-0.1.34 → ostium_python_sdk-0.1.36}/setup.py +1 -1
- {ostium_python_sdk-0.1.34 → ostium_python_sdk-0.1.36}/ostium_python_sdk/__init__.py +0 -0
- {ostium_python_sdk-0.1.34 → ostium_python_sdk-0.1.36}/ostium_python_sdk/abi/__init__.py +0 -0
- {ostium_python_sdk-0.1.34 → ostium_python_sdk-0.1.36}/ostium_python_sdk/abi/abi.py +0 -0
- {ostium_python_sdk-0.1.34 → ostium_python_sdk-0.1.36}/ostium_python_sdk/abi/faucet_abi.py +0 -0
- {ostium_python_sdk-0.1.34 → ostium_python_sdk-0.1.36}/ostium_python_sdk/balance.py +0 -0
- {ostium_python_sdk-0.1.34 → ostium_python_sdk-0.1.36}/ostium_python_sdk/config.py +0 -0
- {ostium_python_sdk-0.1.34 → ostium_python_sdk-0.1.36}/ostium_python_sdk/constants.py +0 -0
- {ostium_python_sdk-0.1.34 → ostium_python_sdk-0.1.36}/ostium_python_sdk/exceptions.py +0 -0
- {ostium_python_sdk-0.1.34 → ostium_python_sdk-0.1.36}/ostium_python_sdk/formulae.py +0 -0
- {ostium_python_sdk-0.1.34 → ostium_python_sdk-0.1.36}/ostium_python_sdk/formulae_wrapper.py +0 -0
- {ostium_python_sdk-0.1.34 → ostium_python_sdk-0.1.36}/ostium_python_sdk/price.py +0 -0
- {ostium_python_sdk-0.1.34 → ostium_python_sdk-0.1.36}/ostium_python_sdk/sdk.py +0 -0
- {ostium_python_sdk-0.1.34 → ostium_python_sdk-0.1.36}/ostium_python_sdk/subgraph.py +0 -0
- {ostium_python_sdk-0.1.34 → ostium_python_sdk-0.1.36}/ostium_python_sdk/utils.py +0 -0
- {ostium_python_sdk-0.1.34 → ostium_python_sdk-0.1.36}/ostium_python_sdk.egg-info/SOURCES.txt +0 -0
- {ostium_python_sdk-0.1.34 → ostium_python_sdk-0.1.36}/ostium_python_sdk.egg-info/dependency_links.txt +0 -0
- {ostium_python_sdk-0.1.34 → ostium_python_sdk-0.1.36}/ostium_python_sdk.egg-info/requires.txt +0 -0
- {ostium_python_sdk-0.1.34 → ostium_python_sdk-0.1.36}/ostium_python_sdk.egg-info/top_level.txt +0 -0
- {ostium_python_sdk-0.1.34 → ostium_python_sdk-0.1.36}/pyproject.toml +0 -0
- {ostium_python_sdk-0.1.34 → ostium_python_sdk-0.1.36}/setup.cfg +0 -0
- {ostium_python_sdk-0.1.34 → ostium_python_sdk-0.1.36}/tests/__init__.py +0 -0
- {ostium_python_sdk-0.1.34 → ostium_python_sdk-0.1.36}/tests/test_slippage.py +0 -0
- {ostium_python_sdk-0.1.34 → ostium_python_sdk-0.1.36}/tests/test_trade_get_tp_price.py +0 -0
- {ostium_python_sdk-0.1.34 → ostium_python_sdk-0.1.36}/tests/test_trade_liquidation_price.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: ostium-python-sdk
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.36
|
|
4
4
|
Summary: A python based SDK developed for interacting with Ostium, a leveraged trading application for trading currencies, commodities, indices, crypto and more.
|
|
5
5
|
Home-page: https://github.com/0xOstium/ostium-python-sdk
|
|
6
6
|
Author: ami@ostium.io
|
|
@@ -90,7 +90,6 @@ You can instantiate the SDK with the following parameters.
|
|
|
90
90
|
Ostium Platform is deployed on Arbitrum. You can use the testnet or mainnet config via the `NetworkConfig` class, see below for an example.
|
|
91
91
|
|
|
92
92
|
|
|
93
|
-
**NOTE: You can also use the SDK _without_ providing a private key, in which case you will be limited to read only operations on the SDK.**
|
|
94
93
|
|
|
95
94
|
```python
|
|
96
95
|
from dotenv import load_dotenv
|
|
@@ -117,8 +116,11 @@ sdk = OstiumSDK(configTestnet, private_key)
|
|
|
117
116
|
# sdk = OstiumSDK(configMainnet, private_key)
|
|
118
117
|
#
|
|
119
118
|
```
|
|
119
|
+
|
|
120
120
|
<b>NOTE:</b> create a .env file with PRIVATE_KEY and RPC_URL to use the SDK. An RPC URL is required to use the SDK. You can get one by signing up for a free account at https://www.alchemy.com/ and creating an app.
|
|
121
121
|
|
|
122
|
+
**NOTE: You can also use the SDK _without_ providing a private key, in which case you will be limited to read only operations on the SDK.**
|
|
123
|
+
|
|
122
124
|
```
|
|
123
125
|
PRIVATE_KEY=your_private_key_here
|
|
124
126
|
RPC_URL=https://arb-sepolia.g.alchemy.com/v2/...
|
|
@@ -475,6 +477,16 @@ All notable changes to the Ostium Python SDK will be documented in this file.
|
|
|
475
477
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
476
478
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
477
479
|
|
|
480
|
+
## [0.1.36] - 2025-01-14
|
|
481
|
+
|
|
482
|
+
### Added
|
|
483
|
+
- Before write-operations, check if private key is provided
|
|
484
|
+
|
|
485
|
+
## [0.1.34] - 2025-01-14
|
|
486
|
+
|
|
487
|
+
### Added
|
|
488
|
+
- Allow read only operations on the SDK without providing a private key
|
|
489
|
+
|
|
478
490
|
## [0.1.31] - 2025-01-13
|
|
479
491
|
|
|
480
492
|
### Added
|
|
@@ -62,7 +62,6 @@ You can instantiate the SDK with the following parameters.
|
|
|
62
62
|
Ostium Platform is deployed on Arbitrum. You can use the testnet or mainnet config via the `NetworkConfig` class, see below for an example.
|
|
63
63
|
|
|
64
64
|
|
|
65
|
-
**NOTE: You can also use the SDK _without_ providing a private key, in which case you will be limited to read only operations on the SDK.**
|
|
66
65
|
|
|
67
66
|
```python
|
|
68
67
|
from dotenv import load_dotenv
|
|
@@ -89,8 +88,11 @@ sdk = OstiumSDK(configTestnet, private_key)
|
|
|
89
88
|
# sdk = OstiumSDK(configMainnet, private_key)
|
|
90
89
|
#
|
|
91
90
|
```
|
|
91
|
+
|
|
92
92
|
<b>NOTE:</b> create a .env file with PRIVATE_KEY and RPC_URL to use the SDK. An RPC URL is required to use the SDK. You can get one by signing up for a free account at https://www.alchemy.com/ and creating an app.
|
|
93
93
|
|
|
94
|
+
**NOTE: You can also use the SDK _without_ providing a private key, in which case you will be limited to read only operations on the SDK.**
|
|
95
|
+
|
|
94
96
|
```
|
|
95
97
|
PRIVATE_KEY=your_private_key_here
|
|
96
98
|
RPC_URL=https://arb-sepolia.g.alchemy.com/v2/...
|
|
@@ -40,7 +40,17 @@ class Faucet:
|
|
|
40
40
|
wait_days = wait_hours // 24
|
|
41
41
|
return f"{wait_days} day{'s' if wait_days != 1 else ''}"
|
|
42
42
|
|
|
43
|
+
def _check_private_key(self):
|
|
44
|
+
if not self.private_key:
|
|
45
|
+
raise ValueError(
|
|
46
|
+
"Private key is required for Faucet operations")
|
|
47
|
+
|
|
48
|
+
def _get_account(self):
|
|
49
|
+
self._check_private_key()
|
|
50
|
+
return self.web3.eth.account.from_key(self.private_key)
|
|
51
|
+
|
|
43
52
|
def request_tokens(self) -> dict:
|
|
53
|
+
account = self._get_account()
|
|
44
54
|
"""
|
|
45
55
|
Request testnet USDC tokens from the faucet.
|
|
46
56
|
Raises:
|
|
@@ -50,8 +60,6 @@ class Faucet:
|
|
|
50
60
|
Transaction receipt
|
|
51
61
|
"""
|
|
52
62
|
try:
|
|
53
|
-
account = self.web3.eth.account.from_key(self.private_key)
|
|
54
|
-
|
|
55
63
|
# Get the current base fee and add a buffer
|
|
56
64
|
base_fee = self.web3.eth.get_block('latest')['baseFeePerGas']
|
|
57
65
|
# Add 50% buffer to ensure it's above base fee
|
|
@@ -16,10 +16,6 @@ class OpenOrderType(Enum):
|
|
|
16
16
|
|
|
17
17
|
class Ostium:
|
|
18
18
|
def __init__(self, w3: Web3, usdc_address: str, ostium_trading_storage_address: str, ostium_trading_address: str, private_key: str) -> None:
|
|
19
|
-
# if not private_key:
|
|
20
|
-
# raise ValueError(
|
|
21
|
-
# "Private key is required for Ostium initialization")
|
|
22
|
-
|
|
23
19
|
self.web3 = w3
|
|
24
20
|
self.private_key = private_key
|
|
25
21
|
self.usdc_address = usdc_address
|
|
@@ -43,6 +39,7 @@ class Ostium:
|
|
|
43
39
|
return self.slippage_percentage
|
|
44
40
|
|
|
45
41
|
def _get_account(self) -> Account:
|
|
42
|
+
self._check_private_key()
|
|
46
43
|
"""Get account from stored private key"""
|
|
47
44
|
return self.web3.eth.account.from_key(self.private_key)
|
|
48
45
|
|
|
@@ -52,6 +49,11 @@ class Ostium:
|
|
|
52
49
|
def get_nonce(self, address):
|
|
53
50
|
return self.web3.eth.get_transaction_count(address)
|
|
54
51
|
|
|
52
|
+
def _check_private_key(self):
|
|
53
|
+
if not self.private_key:
|
|
54
|
+
raise ValueError(
|
|
55
|
+
"Private key is required for Ostium platform write-operations")
|
|
56
|
+
|
|
55
57
|
def perform_trade(self, trade_params, at_price):
|
|
56
58
|
account = self._get_account()
|
|
57
59
|
amount = to_base_units(trade_params['collateral'], decimals=6)
|
|
@@ -142,8 +144,8 @@ class Ostium:
|
|
|
142
144
|
return trade_receipt
|
|
143
145
|
|
|
144
146
|
def add_collateral(self, pairID, index, collateral):
|
|
147
|
+
account = self._get_account()
|
|
145
148
|
try:
|
|
146
|
-
account = self._get_account()
|
|
147
149
|
amount = to_base_units(collateral, decimals=6)
|
|
148
150
|
self.__approve(account, amount)
|
|
149
151
|
|
|
@@ -168,8 +170,8 @@ class Ostium:
|
|
|
168
170
|
raise e
|
|
169
171
|
|
|
170
172
|
def update_tp(self, pairID, index, tp):
|
|
173
|
+
account = self._get_account()
|
|
171
174
|
try:
|
|
172
|
-
account = self._get_account()
|
|
173
175
|
tp_value = to_base_units(tp, decimals=18)
|
|
174
176
|
|
|
175
177
|
update_tp_tx = self.ostium_trading_contract.functions.updateTp(
|
|
@@ -188,8 +190,8 @@ class Ostium:
|
|
|
188
190
|
raise e
|
|
189
191
|
|
|
190
192
|
def update_sl(self, pairID, index, sl):
|
|
193
|
+
account = self._get_account()
|
|
191
194
|
try:
|
|
192
|
-
account = self._get_account()
|
|
193
195
|
sl_value = to_base_units(sl, decimals=18)
|
|
194
196
|
|
|
195
197
|
update_sl_tx = self.ostium_trading_contract.functions.updateSl(
|
|
@@ -232,8 +234,9 @@ class Ostium:
|
|
|
232
234
|
print('Approval Receipt:', approve_receipt)
|
|
233
235
|
|
|
234
236
|
def withdraw(self, amount, receiving_address):
|
|
237
|
+
account = self._get_account()
|
|
238
|
+
|
|
235
239
|
try:
|
|
236
|
-
account = self._get_account()
|
|
237
240
|
amount_in_base_units = to_base_units(amount, decimals=6)
|
|
238
241
|
|
|
239
242
|
if not self.web3.is_address(receiving_address):
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: ostium-python-sdk
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.36
|
|
4
4
|
Summary: A python based SDK developed for interacting with Ostium, a leveraged trading application for trading currencies, commodities, indices, crypto and more.
|
|
5
5
|
Home-page: https://github.com/0xOstium/ostium-python-sdk
|
|
6
6
|
Author: ami@ostium.io
|
|
@@ -90,7 +90,6 @@ You can instantiate the SDK with the following parameters.
|
|
|
90
90
|
Ostium Platform is deployed on Arbitrum. You can use the testnet or mainnet config via the `NetworkConfig` class, see below for an example.
|
|
91
91
|
|
|
92
92
|
|
|
93
|
-
**NOTE: You can also use the SDK _without_ providing a private key, in which case you will be limited to read only operations on the SDK.**
|
|
94
93
|
|
|
95
94
|
```python
|
|
96
95
|
from dotenv import load_dotenv
|
|
@@ -117,8 +116,11 @@ sdk = OstiumSDK(configTestnet, private_key)
|
|
|
117
116
|
# sdk = OstiumSDK(configMainnet, private_key)
|
|
118
117
|
#
|
|
119
118
|
```
|
|
119
|
+
|
|
120
120
|
<b>NOTE:</b> create a .env file with PRIVATE_KEY and RPC_URL to use the SDK. An RPC URL is required to use the SDK. You can get one by signing up for a free account at https://www.alchemy.com/ and creating an app.
|
|
121
121
|
|
|
122
|
+
**NOTE: You can also use the SDK _without_ providing a private key, in which case you will be limited to read only operations on the SDK.**
|
|
123
|
+
|
|
122
124
|
```
|
|
123
125
|
PRIVATE_KEY=your_private_key_here
|
|
124
126
|
RPC_URL=https://arb-sepolia.g.alchemy.com/v2/...
|
|
@@ -475,6 +477,16 @@ All notable changes to the Ostium Python SDK will be documented in this file.
|
|
|
475
477
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
476
478
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
477
479
|
|
|
480
|
+
## [0.1.36] - 2025-01-14
|
|
481
|
+
|
|
482
|
+
### Added
|
|
483
|
+
- Before write-operations, check if private key is provided
|
|
484
|
+
|
|
485
|
+
## [0.1.34] - 2025-01-14
|
|
486
|
+
|
|
487
|
+
### Added
|
|
488
|
+
- Allow read only operations on the SDK without providing a private key
|
|
489
|
+
|
|
478
490
|
## [0.1.31] - 2025-01-13
|
|
479
491
|
|
|
480
492
|
### Added
|
|
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
|
{ostium_python_sdk-0.1.34 → ostium_python_sdk-0.1.36}/ostium_python_sdk.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{ostium_python_sdk-0.1.34 → ostium_python_sdk-0.1.36}/ostium_python_sdk.egg-info/requires.txt
RENAMED
|
File without changes
|
{ostium_python_sdk-0.1.34 → ostium_python_sdk-0.1.36}/ostium_python_sdk.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|