Skip to content

Commit fd60afc

Browse files
committed
Merge branch 'master' of https://github.com/InjectiveLabs/sdk-python into CP-235/update_gas_estimator_for_fixed_exchange_gas
2 parents 41dda82 + 0416c2a commit fd60afc

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ All notable changes to this project will be documented in this file.
66
### Changed
77
- Update in the implementation of the gas limit estimator to use the same values as the chain for the fixed gas messages
88

9-
## [1.9.0] - 9999-99-99
9+
## [1.9.1] - 2025-03-03
10+
### Fixed
11+
- Added quantization in the functions that convert notional values to chain format
12+
13+
## [1.9.0] - 2025-02-13
1014
### Added
1115
- Added support for all new queries and messages from the new Permissions module
1216

examples/exchange_client/oracle_rpc/1_StreamPrices.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ async def main() -> None:
2929

3030
base_symbol = market.oracle_base
3131
quote_symbol = market.oracle_quote
32-
oracle_type = market.oracle_type
32+
oracle_type = market.oracle_type.lower()
3333

3434
task = asyncio.get_event_loop().create_task(
3535
client.listen_oracle_prices_updates(

pyinjective/core/market.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from dataclasses import dataclass
2-
from decimal import Decimal
2+
from decimal import ROUND_UP, Decimal
33
from typing import Optional
44

55
from pyinjective.constant import ADDITIONAL_CHAIN_FORMAT_DECIMALS
@@ -39,7 +39,8 @@ def price_to_chain_format(self, human_readable_value: Decimal) -> Decimal:
3939
def notional_to_chain_format(self, human_readable_value: Decimal) -> Decimal:
4040
decimals = self.quote_token.decimals
4141
chain_formatted_value = human_readable_value * Decimal(f"1e{decimals}")
42-
extended_chain_formatted_value = chain_formatted_value * Decimal(f"1e{ADDITIONAL_CHAIN_FORMAT_DECIMALS}")
42+
quantized_balue = chain_formatted_value.quantize(Decimal("1"), rounding=ROUND_UP)
43+
extended_chain_formatted_value = quantized_balue * Decimal(f"1e{ADDITIONAL_CHAIN_FORMAT_DECIMALS}")
4344

4445
return extended_chain_formatted_value
4546

@@ -120,7 +121,8 @@ def calculate_margin_in_chain_format(
120121
def notional_to_chain_format(self, human_readable_value: Decimal) -> Decimal:
121122
decimals = self.quote_token.decimals
122123
chain_formatted_value = human_readable_value * Decimal(f"1e{decimals}")
123-
extended_chain_formatted_value = chain_formatted_value * Decimal(f"1e{ADDITIONAL_CHAIN_FORMAT_DECIMALS}")
124+
quantized_notional = chain_formatted_value.quantize(Decimal("1"), rounding=ROUND_UP)
125+
extended_chain_formatted_value = quantized_notional * Decimal(f"1e{ADDITIONAL_CHAIN_FORMAT_DECIMALS}")
124126

125127
return extended_chain_formatted_value
126128

@@ -230,7 +232,8 @@ def calculate_margin_in_chain_format(
230232
def notional_to_chain_format(self, human_readable_value: Decimal) -> Decimal:
231233
decimals = self.quote_token.decimals
232234
chain_formatted_value = human_readable_value * Decimal(f"1e{decimals}")
233-
extended_chain_formatted_value = chain_formatted_value * Decimal(f"1e{ADDITIONAL_CHAIN_FORMAT_DECIMALS}")
235+
quantized_value = chain_formatted_value.quantize(Decimal("1"), rounding=ROUND_UP)
236+
extended_chain_formatted_value = quantized_value * Decimal(f"1e{ADDITIONAL_CHAIN_FORMAT_DECIMALS}")
234237

235238
return extended_chain_formatted_value
236239

pyinjective/ofac.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"0x178169b423a011fff22b9e3f3abea13414ddd0f1",
2020
"0x179f48c78f57a3a78f0608cc9197b8972921d1d2",
2121
"0x1967d8af5bd86a497fb3dd7899a020e47560daaf",
22+
"0x1999ef52700c34de7ec2b68a28aafb37db0c5ade",
2223
"0x19aa5fe80d33a56d56c78e82ea5e50e5d80b4dff",
2324
"0x19f8f2b0915daa12a3f5c9cf01df9e24d53794f7",
2425
"0x1da5821544e25c636c1417ba96ade4cf6d2f9b5a",

0 commit comments

Comments
 (0)