ostium-python-sdk 0.1.35__tar.gz → 0.1.37__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.
Files changed (30) hide show
  1. {ostium_python_sdk-0.1.35 → ostium_python_sdk-0.1.37}/PKG-INFO +6 -1
  2. {ostium_python_sdk-0.1.35 → ostium_python_sdk-0.1.37}/ostium_python_sdk/faucet.py +10 -2
  3. {ostium_python_sdk-0.1.35 → ostium_python_sdk-0.1.37}/ostium_python_sdk/ostium.py +11 -8
  4. {ostium_python_sdk-0.1.35 → ostium_python_sdk-0.1.37}/ostium_python_sdk.egg-info/PKG-INFO +6 -1
  5. {ostium_python_sdk-0.1.35 → ostium_python_sdk-0.1.37}/setup.py +1 -1
  6. {ostium_python_sdk-0.1.35 → ostium_python_sdk-0.1.37}/README.md +0 -0
  7. {ostium_python_sdk-0.1.35 → ostium_python_sdk-0.1.37}/ostium_python_sdk/__init__.py +0 -0
  8. {ostium_python_sdk-0.1.35 → ostium_python_sdk-0.1.37}/ostium_python_sdk/abi/__init__.py +0 -0
  9. {ostium_python_sdk-0.1.35 → ostium_python_sdk-0.1.37}/ostium_python_sdk/abi/abi.py +0 -0
  10. {ostium_python_sdk-0.1.35 → ostium_python_sdk-0.1.37}/ostium_python_sdk/abi/faucet_abi.py +0 -0
  11. {ostium_python_sdk-0.1.35 → ostium_python_sdk-0.1.37}/ostium_python_sdk/balance.py +0 -0
  12. {ostium_python_sdk-0.1.35 → ostium_python_sdk-0.1.37}/ostium_python_sdk/config.py +0 -0
  13. {ostium_python_sdk-0.1.35 → ostium_python_sdk-0.1.37}/ostium_python_sdk/constants.py +0 -0
  14. {ostium_python_sdk-0.1.35 → ostium_python_sdk-0.1.37}/ostium_python_sdk/exceptions.py +0 -0
  15. {ostium_python_sdk-0.1.35 → ostium_python_sdk-0.1.37}/ostium_python_sdk/formulae.py +0 -0
  16. {ostium_python_sdk-0.1.35 → ostium_python_sdk-0.1.37}/ostium_python_sdk/formulae_wrapper.py +0 -0
  17. {ostium_python_sdk-0.1.35 → ostium_python_sdk-0.1.37}/ostium_python_sdk/price.py +0 -0
  18. {ostium_python_sdk-0.1.35 → ostium_python_sdk-0.1.37}/ostium_python_sdk/sdk.py +0 -0
  19. {ostium_python_sdk-0.1.35 → ostium_python_sdk-0.1.37}/ostium_python_sdk/subgraph.py +0 -0
  20. {ostium_python_sdk-0.1.35 → ostium_python_sdk-0.1.37}/ostium_python_sdk/utils.py +0 -0
  21. {ostium_python_sdk-0.1.35 → ostium_python_sdk-0.1.37}/ostium_python_sdk.egg-info/SOURCES.txt +0 -0
  22. {ostium_python_sdk-0.1.35 → ostium_python_sdk-0.1.37}/ostium_python_sdk.egg-info/dependency_links.txt +0 -0
  23. {ostium_python_sdk-0.1.35 → ostium_python_sdk-0.1.37}/ostium_python_sdk.egg-info/requires.txt +0 -0
  24. {ostium_python_sdk-0.1.35 → ostium_python_sdk-0.1.37}/ostium_python_sdk.egg-info/top_level.txt +0 -0
  25. {ostium_python_sdk-0.1.35 → ostium_python_sdk-0.1.37}/pyproject.toml +0 -0
  26. {ostium_python_sdk-0.1.35 → ostium_python_sdk-0.1.37}/setup.cfg +0 -0
  27. {ostium_python_sdk-0.1.35 → ostium_python_sdk-0.1.37}/tests/__init__.py +0 -0
  28. {ostium_python_sdk-0.1.35 → ostium_python_sdk-0.1.37}/tests/test_slippage.py +0 -0
  29. {ostium_python_sdk-0.1.35 → ostium_python_sdk-0.1.37}/tests/test_trade_get_tp_price.py +0 -0
  30. {ostium_python_sdk-0.1.35 → ostium_python_sdk-0.1.37}/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.35
3
+ Version: 0.1.37
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
@@ -477,6 +477,11 @@ All notable changes to the Ostium Python SDK will be documented in this file.
477
477
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
478
478
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
479
479
 
480
+ ## [0.1.36] - 2025-01-14
481
+
482
+ ### Added
483
+ - Before write-operations, check if private key is provided
484
+
480
485
  ## [0.1.34] - 2025-01-14
481
486
 
482
487
  ### Added
@@ -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.35
3
+ Version: 0.1.37
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
@@ -477,6 +477,11 @@ All notable changes to the Ostium Python SDK will be documented in this file.
477
477
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
478
478
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
479
479
 
480
+ ## [0.1.36] - 2025-01-14
481
+
482
+ ### Added
483
+ - Before write-operations, check if private key is provided
484
+
480
485
  ## [0.1.34] - 2025-01-14
481
486
 
482
487
  ### Added
@@ -12,7 +12,7 @@ if changelog_path.exists():
12
12
 
13
13
  setup(
14
14
  name="ostium-python-sdk",
15
- version="0.1.35",
15
+ version="0.1.37",
16
16
  packages=find_packages(),
17
17
  install_requires=[
18
18
  "web3>=6.0.0",