-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/add exchange messages from v1.13 #341
Conversation
… markets initialization logic to parse the min_notional. Added logic to populate the min_notional in the INI files
…d in the chain upgrade v1.13. Added unit tests and example scripts
Important Review skippedMore than 25% of the files skipped due to max files limit. The review is being skipped to prevent a low-quality review. 126 files out of 283 files are above the max files limit of 150. You can disable this status message by setting the WalkthroughThe recent changes significantly enhance the codebase by introducing a new Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant App
participant Network
User->>App: Initiate market operation
App->>Network: Validate transaction with min_notional
Network-->>App: Confirmation of validity
App-->>User: Display transaction outcome
TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 11
Outside diff range, codebase verification and nitpick comments (6)
examples/chain_client/exchange/27_MsgActivateStakeGrant.py (2)
4-5
: Remove unnecessary blank line.Remove the unnecessary blank line between imports to improve readability.
-
11-11
: Remove unnecessary blank line.Remove the unnecessary blank line to improve readability.
-
pyinjective/utils/denom.py (1)
6-12
: Instances ofDenom
class instantiation without the newmin_notional
parameter found:The following locations in the codebase instantiate the
Denom
class without including the newmin_notional
parameter. Please update these instances to include the new parameter:
examples/chain_client/exchange/14_MsgCreateBinaryOptionsLimitOrder.py
tests/core/test_market.py
(multiple instances)Ensure that all instances of
Denom
class instantiation include the newmin_notional
parameter for consistency and correctness.Analysis chain
LGTM! But verify the usage of the new parameter in the codebase.
The addition of the
min_notional
parameter is consistent with the existing parameters.However, ensure that all instances where
Denom
is instantiated include the new parameter.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all instances where `Denom` is instantiated include the new parameter. # Test: Search for the instantiation of the `Denom` class. Expect: Only occurrences with the new parameter. rg --type python -A 5 $'Denom('Length of output: 95
Script:
#!/bin/bash # Description: Verify all instances where `Denom` is instantiated include the new parameter. # Test: Search for the instantiation of the `Denom` class. Expect: Only occurrences with the new parameter. rg --type python -A 5 'Denom('Length of output: 95
Script:
#!/bin/bash # Description: Verify all instances where `Denom` is instantiated include the new parameter. # Test: Search for the instantiation of the `Denom` class. Expect: Only occurrences with the new parameter. rg --type python -A 5 'Denom\('Length of output: 64
Script:
#!/bin/bash # Description: Verify all instances where `Denom` is instantiated include the new parameter. # Find all Python files and search for the instantiation of the `Denom` class. Expect: Only occurrences with the new parameter. fd -e py | xargs rg -A 5 'Denom\('Length of output: 12420
examples/chain_client/exchange/23_MsgDecreasePositionMargin.py (1)
1-6
: Organize imports for readability.Grouping standard library imports, third-party imports, and local imports separately improves readability.
import asyncio import os from decimal import Decimal import dotenv from pyinjective.async_client import AsyncClient from pyinjective.core.broadcaster import MsgBroadcasterWithPk from pyinjective.core.network import Network from pyinjective.wallet import PrivateKeyexamples/chain_client/exchange/25_MsgUpdateDerivativeMarket.py (1)
1-6
: Organize imports for readability.Grouping standard library imports, third-party imports, and local imports separately improves readability.
import asyncio import os from decimal import Decimal import dotenv from pyinjective.async_client import AsyncClient from pyinjective.core.broadcaster import MsgBroadcasterWithPk from pyinjective.core.network import Network from pyinjective.wallet import PrivateKeyCHANGELOG.md (1)
6-6
: Typo: Repeated word "Added".There is a repeated word "Added" in the changelog entry.
- Added support for the following messages in the chain "exchange" module: + Support for the following messages in the chain "exchange" module:Tools
LanguageTool
[duplication] ~6-~6: Possible typo: you repeated a word
Context: ...this file. ## [1.6.1] - 2024-08-07 ### Added - Added support for the following messages in t...(ENGLISH_WORD_REPEAT_RULE)
Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (24)
- .github/workflows/run-tests.yml (1 hunks)
- CHANGELOG.md (1 hunks)
- examples/chain_client/exchange/14_MsgCreateBinaryOptionsLimitOrder.py (1 hunks)
- examples/chain_client/exchange/23_MsgDecreasePositionMargin.py (1 hunks)
- examples/chain_client/exchange/24_MsgUpdateSpotMarket.py (1 hunks)
- examples/chain_client/exchange/25_MsgUpdateDerivativeMarket.py (1 hunks)
- examples/chain_client/exchange/26_MsgAuthorizeStakeGrants.py (1 hunks)
- examples/chain_client/exchange/27_MsgActivateStakeGrant.py (1 hunks)
- pyinjective/async_client.py (3 hunks)
- pyinjective/composer.py (9 hunks)
- pyinjective/constant.py (1 hunks)
- pyinjective/core/market.py (10 hunks)
- pyinjective/core/tokens_file_loader.py (1 hunks)
- pyinjective/denoms_devnet.ini (33 hunks)
- pyinjective/denoms_testnet.ini (62 hunks)
- pyinjective/utils/denom.py (2 hunks)
- pyinjective/utils/fetch_metadata.py (3 hunks)
- pyinjective/utils/metadata_validation.py (6 hunks)
- pyproject.toml (1 hunks)
- tests/core/test_gas_limit_estimator.py (1 hunks)
- tests/core/test_market.py (27 hunks)
- tests/model_fixtures/markets_fixtures.py (3 hunks)
- tests/rpc_fixtures/markets_fixtures.py (4 hunks)
- tests/test_composer.py (5 hunks)
Files skipped from review due to trivial changes (2)
- pyinjective/constant.py
- pyproject.toml
Additional context used
LanguageTool
CHANGELOG.md
[duplication] ~6-~6: Possible typo: you repeated a word
Context: ...this file. ## [1.6.1] - 2024-08-07 ### Added - Added support for the following messages in t...(ENGLISH_WORD_REPEAT_RULE)
Ruff
tests/core/test_market.py
40-40: Redefinition of unused
inj_usdt_spot_market
from line 9(F811)
68-68: Redefinition of unused
inj_usdt_spot_market
from line 9(F811)
102-102: Redefinition of unused
inj_usdt_spot_market
from line 9(F811)
154-154: Redefinition of unused
btc_usdt_perp_market
from line 6(F811)
191-191: Redefinition of unused
btc_usdt_perp_market
from line 6(F811)
232-232: Redefinition of unused
btc_usdt_perp_market
from line 6(F811)
427-427: Redefinition of unused
first_match_bet_market
from line 7(F811)
495-495: Redefinition of unused
first_match_bet_market
from line 7(F811)
579-579: Redefinition of unused
first_match_bet_market
from line 7(F811)
Additional comments not posted (121)
.github/workflows/run-tests.yml (1)
43-43
: Verify compatibility with Codecov v4.The update to Codecov action
v4
is approved. Ensure that the new version is compatible with your current setup and does not introduce breaking changes.Verification successful
Codecov v4 compatibility verified.
The current setup does not use any of the deprecated features or arguments listed in the Codecov v4 changelog. Therefore, updating to Codecov v4 should not introduce any breaking changes.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify compatibility with Codecov v4. # Test: Check the Codecov action documentation for breaking changes. curl -s https://raw.githubusercontent.com/codecov/codecov-action/main/CHANGELOG.md | grep -i "breaking changes"Length of output: 176
Script:
#!/bin/bash # Description: Fetch and display the sections of the Codecov action changelog that detail the breaking changes. # Fetch the changelog and extract the sections with breaking changes. curl -s https://raw.githubusercontent.com/codecov/codecov-action/main/CHANGELOG.md | awk '/### Breaking Changes/{flag=1;next}/###/{flag=0}flag'Length of output: 567
Script:
#!/bin/bash # Description: Check for usage of deprecated Codecov features in the run-tests.yml file. # Search for the usage of `aarch64` and `alpine` architectures, tokenless uploading, and specific deprecated arguments. grep -E 'aarch64|alpine|tokenless|functionalities|gcov_' .github/workflows/run-tests.ymlLength of output: 90
pyinjective/core/tokens_file_loader.py (1)
18-18
: Improvement: Useget
method to accessaddress
attribute.The use of the
get
method enhances robustness by preventing potentialKeyError
exceptions.examples/chain_client/exchange/27_MsgActivateStakeGrant.py (4)
1-2
: Ensure environment variables are loaded securely.Ensure that the
.env
file is properly secured and not exposed in the version control system.
14-14
: Verify the presence ofINJECTIVE_PRIVATE_KEY
.Ensure that the
INJECTIVE_PRIVATE_KEY
environment variable is set and valid.
25-28
: Verify the configuration ofMsgBroadcasterWithPk
.Ensure that
MsgBroadcasterWithPk
is correctly configured and the private key is valid.
37-39
: Verify themsg_activate_stake_grant
parameters.Ensure that the
msg_activate_stake_grant
method is correctly used and the parameters are valid.pyinjective/utils/denom.py (1)
36-36
: LGTM!The changes to the
load_market
method are consistent with the addition of themin_notional
parameter.examples/chain_client/exchange/26_MsgAuthorizeStakeGrants.py (1)
1-51
: LGTM! But verify the usage of environment variables and asynchronous operations.The function is well-structured and follows a logical sequence of operations.
However, ensure that the environment variables are correctly set and the asynchronous operations are properly handled.
examples/chain_client/exchange/24_MsgUpdateSpotMarket.py (1)
1-54
: LGTM! But verify the usage of environment variables and asynchronous operations.The function is well-structured and follows a logical sequence of operations.
However, ensure that the environment variables are correctly set and the asynchronous operations are properly handled.
pyinjective/utils/fetch_metadata.py (1)
15-15
: Initializemin_notional
properly.Ensure
min_notional
is initialized properly before being used.min_notional = {}Likely invalid or redundant comment.
tests/model_fixtures/markets_fixtures.py (3)
67-67
: LGTM! Themin_notional
parameter is correctly integrated.The addition of the
min_notional
parameter enhances the market configuration for more precise control over trading conditions.
91-91
: LGTM! Themin_notional
parameter is correctly integrated.The addition of the
min_notional
parameter enhances the market configuration for more precise control over trading conditions.
115-115
: LGTM! Themin_notional
parameter is correctly integrated.The addition of the
min_notional
parameter enhances the market configuration for more precise control over trading conditions.examples/chain_client/exchange/14_MsgCreateBinaryOptionsLimitOrder.py (1)
47-47
: LGTM! Themin_notional
parameter is correctly integrated.The addition of the
min_notional
parameter enhances theDenom
object for more precise control over trading conditions.tests/rpc_fixtures/markets_fixtures.py (4)
127-127
: LGTM! Themin_notional
parameter is correctly integrated.The addition of the
min_notional
parameter enhances the market configuration for more precise control over trading conditions.
150-150
: LGTM! Themin_notional
parameter is correctly integrated.The addition of the
min_notional
parameter enhances the market configuration for more precise control over trading conditions.
192-192
: LGTM! Themin_notional
parameter is correctly integrated.The addition of the
min_notional
parameter enhances the market configuration for more precise control over trading conditions.
218-218
: LGTM! Themin_notional
parameter is correctly integrated.The addition of the
min_notional
parameter enhances the market configuration for more precise control over trading conditions.pyinjective/utils/metadata_validation.py (9)
36-36
: Ensuremin_notional
is correctly initialized.The addition of the
min_notional
check is appropriate. Ensure thatmin_notional
is correctly initialized and populated in both themarket
anddenom
objects.
46-46
: Consistent formatting formin_notional
.Ensure that the
min_notional
value is consistently formatted as aDecimal
in bothdenom
andmarket
dictionaries.
54-54
: Consistent formatting formin_notional
.Ensure that the
min_notional
value is consistently formatted as afloat
in bothdenom
andmarket
dictionaries.
65-65
: Ensuremin_notional
is correctly initialized.The addition of the
min_notional
check is appropriate. Ensure thatmin_notional
is correctly initialized and populated in both themarket
anddenom
objects.
74-74
: Consistent formatting formin_notional
.Ensure that the
min_notional
value is consistently formatted as aDecimal
in bothdenom
andmarket
dictionaries.
81-81
: Consistent formatting formin_notional
.Ensure that the
min_notional
value is consistently formatted as afloat
in bothdenom
andmarket
dictionaries.
92-92
: Ensuremin_notional
is correctly initialized.The addition of the
min_notional
check is appropriate. Ensure thatmin_notional
is correctly initialized and populated in both themarket
anddenom
objects.
101-101
: Consistent formatting formin_notional
.Ensure that the
min_notional
value is consistently formatted as aDecimal
in bothdenom
andmarket
dictionaries.
108-108
: Consistent formatting formin_notional
.Ensure that the
min_notional
value is consistently formatted as afloat
in bothdenom
andmarket
dictionaries.pyinjective/core/market.py (12)
22-22
: Ensuremin_notional
is correctly initialized.The addition of the
min_notional
attribute is appropriate. Ensure thatmin_notional
is correctly initialized and populated.
39-46
: Verifynotional_to_chain_format
logic.The
notional_to_chain_format
method correctly converts human-readable values to chain format. Verify that themin_notional
attribute is correctly used as the quantization factor.
55-57
: Verifynotional_from_chain_format
logic.The
notional_from_chain_format
method correctly converts chain values to human-readable format. Verify that the conversion logic is accurate.
64-66
: Verifynotional_from_extended_chain_format
logic.The
notional_from_extended_chain_format
method correctly converts extended chain values to human-readable format. Verify that the conversion logic is accurate.
88-88
: Ensuremin_notional
is correctly initialized.The addition of the
min_notional
attribute is appropriate. Ensure thatmin_notional
is correctly initialized and populated.
122-130
: Verifynotional_to_chain_format
logic.The
notional_to_chain_format
method correctly converts human-readable values to chain format. Verify that themin_notional
attribute is correctly used as the quantization factor.
140-141
: Verifynotional_from_chain_format
logic.The
notional_from_chain_format
method correctly converts chain values to human-readable format. Verify that the conversion logic is accurate.
152-153
: Verifynotional_from_extended_chain_format
logic.The
notional_from_extended_chain_format
method correctly converts extended chain values to human-readable format. Verify that the conversion logic is accurate.
176-176
: Ensuremin_notional
is correctly initialized.The addition of the
min_notional
attribute is appropriate. Ensure thatmin_notional
is correctly initialized and populated.
234-242
: Verifynotional_to_chain_format
logic.The
notional_to_chain_format
method correctly converts human-readable values to chain format. Verify that themin_notional
attribute is correctly used as the quantization factor.
255-257
: Verifynotional_from_chain_format
logic.The
notional_from_chain_format
method correctly converts chain values to human-readable format. Verify that the conversion logic is accurate.
273-275
: Verifynotional_from_extended_chain_format
logic.The
notional_from_extended_chain_format
method correctly converts extended chain values to human-readable format. Verify that the conversion logic is accurate.tests/core/test_gas_limit_estimator.py (1)
230-230
: LGTM! But verify the function usage in the codebase.The code changes are approved.
However, ensure that all function calls to
test_estimation_for_batch_update_orders_to_create_binary_orders
match the new signature.Verification successful
No issues found with the function usage in the codebase.
The function
test_estimation_for_batch_update_orders_to_create_binary_orders
is not called anywhere else in the codebase, so no further updates are necessary.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all function calls to `test_estimation_for_batch_update_orders_to_create_binary_orders` match the new signature. # Test: Search for the function usage. Expect: Only occurrences of the new signature. rg --type python -A 5 $'test_estimation_for_batch_update_orders_to_create_binary_orders'Length of output: 118
Script:
#!/bin/bash # Description: Verify all function calls to `test_estimation_for_batch_update_orders_to_create_binary_orders` match the new signature. # Test: Search for the function usage. Expect: Only occurrences of the new signature. rg --type py -A 5 $'test_estimation_for_batch_update_orders_to_create_binary_orders'Length of output: 636
Script:
#!/bin/bash # Description: Verify all function calls to `test_estimation_for_batch_update_orders_to_create_binary_orders` match the new signature. # Test: Search for any calls to the function. Expect: Only occurrences of the new signature. rg 'test_estimation_for_batch_update_orders_to_create_binary_orders'Length of output: 198
tests/core/test_market.py (9)
40-47
: LGTM!The function
test_convert_notional_to_chain_format
forSpotMarket
correctly tests the conversion of notional values to chain format.Tools
Ruff
40-40: Redefinition of unused
inj_usdt_spot_market
from line 9(F811)
68-75
: LGTM!The function
test_convert_notional_from_chain_format
forSpotMarket
correctly tests the conversion of notional values from chain format.Tools
Ruff
68-68: Redefinition of unused
inj_usdt_spot_market
from line 9(F811)
102-113
: LGTM!The function
test_convert_notional_from_extended_chain_format
forSpotMarket
correctly tests the conversion of notional values from extended chain format.Tools
Ruff
102-102: Redefinition of unused
inj_usdt_spot_market
from line 9(F811)
154-161
: LGTM!The function
test_convert_notional_to_chain_format
forDerivativeMarket
correctly tests the conversion of notional values to chain format.Tools
Ruff
154-154: Redefinition of unused
btc_usdt_perp_market
from line 6(F811)
191-198
: LGTM!The function
test_convert_notional_from_chain_format
forDerivativeMarket
correctly tests the conversion of notional values from chain format.Tools
Ruff
191-191: Redefinition of unused
btc_usdt_perp_market
from line 6(F811)
232-243
: LGTM!The function
test_convert_notional_from_extended_chain_format
forDerivativeMarket
correctly tests the conversion of notional values from extended chain format.Tools
Ruff
232-232: Redefinition of unused
btc_usdt_perp_market
from line 6(F811)
427-434
: LGTM!The function
test_convert_notional_to_chain_format
forBinaryOptionMarket
correctly tests the conversion of notional values to chain format.Tools
Ruff
427-427: Redefinition of unused
first_match_bet_market
from line 7(F811)
495-502
: LGTM!The function
test_convert_notional_from_chain_format
forBinaryOptionMarket
correctly tests the conversion of notional values from chain format.Tools
Ruff
495-495: Redefinition of unused
first_match_bet_market
from line 7(F811)
579-590
: LGTM!The function
test_convert_notional_from_extended_chain_format
forBinaryOptionMarket
correctly tests the conversion of notional values from extended chain format.Tools
Ruff
579-579: Redefinition of unused
first_match_bet_market
from line 7(F811)
pyinjective/denoms_devnet.ini (26)
9-9
: Verify themin_notional
value.The
min_notional
value is set to 0. Ensure this is intentional and not a placeholder.
19-19
: LGTM!The
min_notional
value of 1000000 appears to be set correctly.
29-29
: LGTM!The
min_notional
value of 1000000 appears to be set correctly.
39-39
: LGTM!The
min_notional
value of 1000000 appears to be set correctly.
49-49
: LGTM!The
min_notional
value of 1000000 appears to be set correctly.
59-59
: LGTM!The
min_notional
value of 1000000 appears to be set correctly.
69-69
: LGTM!The
min_notional
value of 1000000 appears to be set correctly.
79-79
: LGTM!The
min_notional
value of 1000000 appears to be set correctly.
89-89
: LGTM!The
min_notional
value of 1000000 appears to be set correctly.
99-99
: LGTM!The
min_notional
value of 1000000 appears to be set correctly.
109-109
: LGTM!The
min_notional
value of 1000000 appears to be set correctly.
119-119
: LGTM!The
min_notional
value of 1000000 appears to be set correctly.
129-129
: LGTM!The
min_notional
value of 1000000 appears to be set correctly.
139-139
: LGTM!The
min_notional
value of 1000000 appears to be set correctly.
149-149
: LGTM!The
min_notional
value of 1000000 appears to be set correctly.
159-159
: LGTM!The
min_notional
value of 1000000 appears to be set correctly.
169-169
: LGTM!The
min_notional
value of 1000000 appears to be set correctly.
179-179
: LGTM!The
min_notional
value of 10000000000000000 appears to be set correctly, considering the high value of WBTC.
189-189
: LGTM!The
min_notional
value of 10000000000000000 appears to be set correctly, considering the high value of PROJ.
199-199
: LGTM!The
min_notional
value of 10000000000000000 appears to be set correctly, considering the high value of KIRA.
209-209
: Verify themin_notional
value.The
min_notional
value is set to 0. Ensure this is intentional and not a placeholder.
219-219
: LGTM!The
min_notional
value of 10000000000000000 appears to be set correctly, considering the high value of HDRO.
229-229
: LGTM!The
min_notional
value of 10000000000000000 appears to be set correctly, considering the high value of BLACK.
239-239
: LGTM!The
min_notional
value of 1000000 appears to be set correctly.
249-249
: LGTM!The
min_notional
value of 1000000 appears to be set correctly.
259-259
: LGTM!The
min_notional
value of 1000000 appears to be set correctly.tests/test_composer.py (6)
Line range hint
1441-1469
:
LGTM! The addition oftest_msg_increase_position_margin
is well-structured.The function correctly tests the functionality of increasing the position margin and verifies the expected message format.
1471-1500
: LGTM! The addition oftest_msg_decrease_position_margin
is well-structured.The function correctly tests the functionality of decreasing the position margin and verifies the expected message format.
1550-1590
: LGTM! The addition oftest_msg_update_spot_market
is well-structured.The function correctly tests the functionality of updating spot market parameters and verifies the expected message format.
1591-1637
: LGTM! The addition oftest_msg_update_derivative_market
is well-structured.The function correctly tests the functionality of updating derivative market parameters and verifies the expected message format.
1638-1666
: LGTM! The addition oftest_msg_authorize_stake_grants
is well-structured.The function correctly tests the functionality of authorizing stake grants and verifies the expected message format.
1667-1684
: LGTM! The addition oftest_msg_activate_stake_grant
is well-structured.The function correctly tests the functionality of activating stake grants and verifies the expected message format.
pyinjective/composer.py (4)
1906-1910
: Add a return type hint for better clarity.The function should have a return type hint for better readability and maintainability.
- def msg_activate_stake_grant(self, sender: str, granter: str) -> injective_exchange_tx_pb.MsgActivateStakeGrant:
Likely invalid or redundant comment.
456-458
: Add a return type hint for better clarity.The function should have a return type hint for better readability and maintainability.
- def create_grant_authorization(self, grantee: str, amount: Decimal) -> injective_exchange_pb.GrantAuthorization: + def create_grant_authorization(self, grantee: str, amount: Decimal) -> injective_exchange_pb.GrantAuthorization:Likely invalid or redundant comment.
1898-1904
: Add a return type hint for better clarity.The function should have a return type hint for better readability and maintainability.
- def msg_authorize_stake_grants( - self, sender: str, grants: List[injective_exchange_pb.GrantAuthorization] - ) -> injective_exchange_tx_pb.MsgAuthorizeStakeGrants:Likely invalid or redundant comment.
1864-1896
: Add a return type hint for better clarity.The function should have a return type hint for better readability and maintainability.
- def msg_update_derivative_market( - self, - admin: str, - market_id: str, - new_ticker: str, - new_min_price_tick_size: Decimal, - new_min_quantity_tick_size: Decimal, - new_min_notional: Decimal, - new_initial_margin_ratio: Decimal, - new_maintenance_margin_ratio: Decimal, - ) -> injective_exchange_tx_pb.MsgUpdateDerivativeMarket:Likely invalid or redundant comment.
pyinjective/async_client.py (3)
3327-3327
: Ensure themin_notional
value is correctly parsed.The
min_notional
value is being converted to aDecimal
. Ensure that themarket_info["minNotional"]
field always contains a valid numeric string to avoid potential parsing errors.
3363-3363
: Ensure themin_notional
value is correctly parsed.The
min_notional
value is being converted to aDecimal
. Ensure that themarket_info["minNotional"]
field always contains a valid numeric string to avoid potential parsing errors.
3388-3388
: Ensure themin_notional
value is correctly parsed.The
min_notional
value is being converted to aDecimal
. Ensure that themarket_info["minNotional"]
field always contains a valid numeric string to avoid potential parsing errors.pyinjective/denoms_testnet.ini (33)
9-9
: LGTM!The addition of
min_notional = 0
is consistent and correct.
19-19
: LGTM!The addition of
min_notional = 0
is consistent and correct.
29-29
: LGTM!The addition of
min_notional = 0
is consistent and correct.
39-39
: LGTM!The addition of
min_notional = 0
is consistent and correct.
49-49
: LGTM!The addition of
min_notional = 0
is consistent and correct.
59-59
: LGTM!The addition of
min_notional = 0
is consistent and correct.
69-69
: LGTM!The addition of
min_notional = 0
is consistent and correct.
79-79
: LGTM!The addition of
min_notional = 0
is consistent and correct.
89-89
: LGTM!The addition of
min_notional = 0
is consistent and correct.
99-99
: LGTM!The addition of
min_notional = 0
is consistent and correct.
109-109
: LGTM!The addition of
min_notional = 0
is consistent and correct.
119-119
: LGTM!The addition of
min_notional = 0
is consistent and correct.
129-129
: LGTM!The addition of
min_notional = 0
is consistent and correct.
139-139
: LGTM!The addition of
min_notional = 0
is consistent and correct.
149-149
: LGTM!The addition of
min_notional = 0
is consistent and correct.
159-159
: LGTM!The addition of
min_notional = 0
is consistent and correct.
169-169
: LGTM!The addition of
min_notional = 0
is consistent and correct.
179-179
: LGTM!The addition of
min_notional = 0
is consistent and correct.
189-189
: LGTM!The addition of
min_notional = 0
is consistent and correct.
199-199
: LGTM!The addition of
min_notional = 0
is consistent and correct.
209-209
: LGTM!The addition of
min_notional = 0
is consistent and correct.
219-219
: LGTM!The addition of
min_notional = 0
is consistent and correct.
229-229
: LGTM!The addition of
min_notional = 0
is consistent and correct.
239-239
: LGTM!The addition of
min_notional = 0
is consistent and correct.
249-249
: LGTM!The addition of
min_notional = 0
is consistent and correct.
259-259
: LGTM!The addition of
min_notional = 0
is consistent and correct.
269-269
: LGTM!The addition of
min_notional = 0
is consistent and correct.
279-279
: LGTM!The addition of
min_notional = 0
is consistent and correct.
289-289
: LGTM!The addition of
min_notional = 0
is consistent and correct.
299-299
: LGTM!The addition of
min_notional = 0
is consistent and correct.
309-309
: LGTM!The addition of
min_notional = 0
is consistent and correct.
319-319
: LGTM!The addition of
min_notional = 0
is consistent and correct.
329-329
: LGTM!The addition of
min_notional = 0
is consistent and correct.
def msg_update_spot_market( | ||
self, | ||
admin: str, | ||
market_id: str, | ||
new_ticker: str, | ||
new_min_price_tick_size: Decimal, | ||
new_min_quantity_tick_size: Decimal, | ||
new_min_notional: Decimal, | ||
) -> injective_exchange_tx_pb.MsgUpdateSpotMarket: | ||
market = self.spot_markets[market_id] | ||
|
||
chain_min_price_tick_size = new_min_price_tick_size * Decimal( | ||
f"1e{market.quote_token.decimals - market.base_token.decimals + ADDITIONAL_CHAIN_FORMAT_DECIMALS}" | ||
) | ||
chain_min_quantity_tick_size = new_min_quantity_tick_size * Decimal( | ||
f"1e{market.base_token.decimals + ADDITIONAL_CHAIN_FORMAT_DECIMALS}" | ||
) | ||
chain_min_notional = new_min_notional * Decimal( | ||
f"1e{market.quote_token.decimals + ADDITIONAL_CHAIN_FORMAT_DECIMALS}" | ||
) | ||
|
||
return injective_exchange_tx_pb.MsgUpdateSpotMarket( | ||
admin=admin, | ||
market_id=market_id, | ||
new_ticker=new_ticker, | ||
new_min_price_tick_size=f"{chain_min_price_tick_size.normalize():f}", | ||
new_min_quantity_tick_size=f"{chain_min_quantity_tick_size.normalize():f}", | ||
new_min_notional=f"{chain_min_notional.normalize():f}", | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a return type hint for better clarity.
The function should have a return type hint for better readability and maintainability.
- def msg_update_spot_market(
- self,
- admin: str,
- market_id: str,
- new_ticker: str,
- new_min_price_tick_size: Decimal,
- new_min_quantity_tick_size: Decimal,
- new_min_notional: Decimal,
- ) -> injective_exchange_tx_pb.MsgUpdateSpotMarket:
Committable suggestion was skipped due to low confidence.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function already has a return type hint
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aarmoa, you are right. The function msg_update_spot_market
already has a return type hint. I apologize for the oversight. Thank you for pointing that out.
if __name__ == "__main__": | ||
asyncio.get_event_loop().run_until_complete(main()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use asyncio.run
instead of get_event_loop
.
Using asyncio.run
is a more modern and preferred way to run the main function.
- asyncio.get_event_loop().run_until_complete(main())
+ asyncio.run(main())
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
if __name__ == "__main__": | |
asyncio.get_event_loop().run_until_complete(main()) | |
if __name__ == "__main__": | |
asyncio.run(main()) |
dotenv.load_dotenv() | ||
configured_private_key = os.getenv("INJECTIVE_PRIVATE_KEY") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Handle missing environment variable.
Add error handling for the case when INJECTIVE_PRIVATE_KEY
is not set.
dotenv.load_dotenv()
configured_private_key = os.getenv("INJECTIVE_PRIVATE_KEY")
if configured_private_key is None:
raise EnvironmentError("INJECTIVE_PRIVATE_KEY is not set in the environment.")
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
dotenv.load_dotenv() | |
configured_private_key = os.getenv("INJECTIVE_PRIVATE_KEY") | |
dotenv.load_dotenv() | |
configured_private_key = os.getenv("INJECTIVE_PRIVATE_KEY") | |
if configured_private_key is None: | |
raise EnvironmentError("INJECTIVE_PRIVATE_KEY is not set in the environment.") |
result = await message_broadcaster.broadcast([msg]) | ||
print("---Transaction Response---") | ||
print(result) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Handle potential errors in transaction response.
Add error handling for the transaction response to ensure robustness.
try:
result = await message_broadcaster.broadcast([msg])
print("---Transaction Response---")
print(result)
except Exception as e:
print(f"Error broadcasting transaction: {e}")
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
result = await message_broadcaster.broadcast([msg]) | |
print("---Transaction Response---") | |
print(result) | |
try: | |
result = await message_broadcaster.broadcast([msg]) | |
print("---Transaction Response---") | |
print(result) | |
except Exception as e: | |
print(f"Error broadcasting transaction: {e}") |
dotenv.load_dotenv() | ||
configured_private_key = os.getenv("INJECTIVE_PRIVATE_KEY") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Handle missing environment variable.
Add error handling for the case when INJECTIVE_PRIVATE_KEY
is not set.
dotenv.load_dotenv()
configured_private_key = os.getenv("INJECTIVE_PRIVATE_KEY")
if configured_private_key is None:
raise EnvironmentError("INJECTIVE_PRIVATE_KEY is not set in the environment.")
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
dotenv.load_dotenv() | |
configured_private_key = os.getenv("INJECTIVE_PRIVATE_KEY") | |
dotenv.load_dotenv() | |
configured_private_key = os.getenv("INJECTIVE_PRIVATE_KEY") | |
if configured_private_key is None: | |
raise EnvironmentError("INJECTIVE_PRIVATE_KEY is not set in the environment.") |
result = await message_broadcaster.broadcast([message]) | ||
print("---Transaction Response---") | ||
print(result) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Handle potential errors in transaction response.
Add error handling for the transaction response to ensure robustness.
try:
result = await message_broadcaster.broadcast([message])
print("---Transaction Response---")
print(result)
except Exception as e:
print(f"Error broadcasting transaction: {e}")
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
result = await message_broadcaster.broadcast([message]) | |
print("---Transaction Response---") | |
print(result) | |
try: | |
result = await message_broadcaster.broadcast([message]) | |
print("---Transaction Response---") | |
print(result) | |
except Exception as e: | |
print(f"Error broadcasting transaction: {e}") |
message_broadcaster = MsgBroadcasterWithPk.new_using_simulation( | ||
network=network, | ||
private_key=configured_private_key, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Handle potential errors in transaction broadcasting.
Add error handling for the transaction broadcasting process to ensure robustness.
try:
message_broadcaster = MsgBroadcasterWithPk.new_using_simulation(
network=network,
private_key=configured_private_key,
)
except Exception as e:
print(f"Error initializing message broadcaster: {e}")
return
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
message_broadcaster = MsgBroadcasterWithPk.new_using_simulation( | |
network=network, | |
private_key=configured_private_key, | |
) | |
try: | |
message_broadcaster = MsgBroadcasterWithPk.new_using_simulation( | |
network=network, | |
private_key=configured_private_key, | |
) | |
except Exception as e: | |
print(f"Error initializing message broadcaster: {e}") | |
return |
@@ -47,6 +48,7 @@ async def fetch_denom(network) -> str: | |||
f"{min_display_price_tick_size.normalize():f}", | |||
f"{market.min_quantity_tick_size.normalize():f}", | |||
f"{min_display_quantity_tick_size.normalize():f}", | |||
f"{market.min_notional.normalize():f}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Handle missing min_notional
gracefully.
Ensure the code handles cases where min_notional
might be missing or not set.
f"{market.min_notional.normalize():f}" if market.min_notional else "0",
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
f"{market.min_notional.normalize():f}", | |
f"{market.min_notional.normalize():f}" if market.min_notional else "0", |
@@ -66,6 +68,7 @@ | |||
f"{min_display_price_tick_size.normalize():f}", | |||
f"{market.min_quantity_tick_size.normalize():f}", | |||
f"{market.min_quantity_tick_size.normalize():f}", | |||
f"{market.min_notional.normalize():f}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Handle missing min_notional
gracefully.
Ensure the code handles cases where min_notional
might be missing or not set.
f"{market.min_notional.normalize():f}" if market.min_notional else "0",
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
f"{market.min_notional.normalize():f}", | |
f"{market.min_notional.normalize():f}" if market.min_notional else "0", |
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (1)
- pyinjective/composer.py (9 hunks)
Files skipped from review as they are similar to previous changes (1)
- pyinjective/composer.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 9
Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (2)
- pyinjective/core/market.py (10 hunks)
- tests/core/test_market.py (27 hunks)
Files skipped from review as they are similar to previous changes (1)
- pyinjective/core/market.py
Additional context used
Ruff
tests/core/test_market.py
40-40: Redefinition of unused
inj_usdt_spot_market
from line 9(F811)
67-67: Redefinition of unused
inj_usdt_spot_market
from line 9(F811)
101-101: Redefinition of unused
inj_usdt_spot_market
from line 9(F811)
153-153: Redefinition of unused
btc_usdt_perp_market
from line 6(F811)
189-189: Redefinition of unused
btc_usdt_perp_market
from line 6(F811)
230-230: Redefinition of unused
btc_usdt_perp_market
from line 6(F811)
425-425: Redefinition of unused
first_match_bet_market
from line 7(F811)
492-492: Redefinition of unused
first_match_bet_market
from line 7(F811)
576-576: Redefinition of unused
first_match_bet_market
from line 7(F811)
def test_convert_notional_from_chain_format(self, inj_usdt_spot_market: SpotMarket): | ||
expected_notional = Decimal("123.456") | ||
|
||
notional_decimals = inj_usdt_spot_market.quote_token.decimals | ||
chain_format_notional = expected_notional * Decimal(f"1e{notional_decimals}") | ||
human_readable_notional = inj_usdt_spot_market.notional_from_chain_format(chain_value=chain_format_notional) | ||
|
||
assert expected_notional == human_readable_notional | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redefinition of unused fixture inj_usdt_spot_market
.
The fixture inj_usdt_spot_market
is redefined but not used in the test function. This can be resolved by removing the redefinition.
- def test_convert_notional_from_chain_format(self, inj_usdt_spot_market: SpotMarket):
+ def test_convert_notional_from_chain_format(self):
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
def test_convert_notional_from_chain_format(self, inj_usdt_spot_market: SpotMarket): | |
expected_notional = Decimal("123.456") | |
notional_decimals = inj_usdt_spot_market.quote_token.decimals | |
chain_format_notional = expected_notional * Decimal(f"1e{notional_decimals}") | |
human_readable_notional = inj_usdt_spot_market.notional_from_chain_format(chain_value=chain_format_notional) | |
assert expected_notional == human_readable_notional | |
def test_convert_notional_from_chain_format(self): | |
expected_notional = Decimal("123.456") | |
notional_decimals = inj_usdt_spot_market.quote_token.decimals | |
chain_format_notional = expected_notional * Decimal(f"1e{notional_decimals}") | |
human_readable_notional = inj_usdt_spot_market.notional_from_chain_format(chain_value=chain_format_notional) | |
assert expected_notional == human_readable_notional |
Tools
Ruff
67-67: Redefinition of unused
inj_usdt_spot_market
from line 9(F811)
def test_convert_notional_from_chain_format(self, first_match_bet_market: BinaryOptionMarket): | ||
expected_notional = Decimal("123.456") | ||
|
||
notional_decimals = first_match_bet_market.quote_token.decimals | ||
chain_format_notional = expected_notional * Decimal(f"1e{notional_decimals}") | ||
human_readable_notional = first_match_bet_market.notional_from_chain_format(chain_value=chain_format_notional) | ||
|
||
assert expected_notional == human_readable_notional | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redefinition of unused fixture first_match_bet_market
.
The fixture first_match_bet_market
is redefined but not used in the test function. This can be resolved by removing the redefinition.
- def test_convert_notional_from_chain_format(self, first_match_bet_market: BinaryOptionMarket):
+ def test_convert_notional_from_chain_format(self):
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
def test_convert_notional_from_chain_format(self, first_match_bet_market: BinaryOptionMarket): | |
expected_notional = Decimal("123.456") | |
notional_decimals = first_match_bet_market.quote_token.decimals | |
chain_format_notional = expected_notional * Decimal(f"1e{notional_decimals}") | |
human_readable_notional = first_match_bet_market.notional_from_chain_format(chain_value=chain_format_notional) | |
assert expected_notional == human_readable_notional | |
def test_convert_notional_from_chain_format(self): | |
expected_notional = Decimal("123.456") | |
notional_decimals = first_match_bet_market.quote_token.decimals | |
chain_format_notional = expected_notional * Decimal(f"1e{notional_decimals}") | |
human_readable_notional = first_match_bet_market.notional_from_chain_format(chain_value=chain_format_notional) | |
assert expected_notional == human_readable_notional |
Tools
Ruff
492-492: Redefinition of unused
first_match_bet_market
from line 7(F811)
def test_convert_notional_from_chain_format(self, btc_usdt_perp_market: DerivativeMarket): | ||
expected_notional = Decimal("123.456") | ||
|
||
notional_decimals = btc_usdt_perp_market.quote_token.decimals | ||
chain_format_notional = expected_notional * Decimal(f"1e{notional_decimals}") | ||
human_readable_notional = btc_usdt_perp_market.notional_from_chain_format(chain_value=chain_format_notional) | ||
|
||
assert expected_notional == human_readable_notional | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redefinition of unused fixture btc_usdt_perp_market
.
The fixture btc_usdt_perp_market
is redefined but not used in the test function. This can be resolved by removing the redefinition.
- def test_convert_notional_from_chain_format(self, btc_usdt_perp_market: DerivativeMarket):
+ def test_convert_notional_from_chain_format(self):
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
def test_convert_notional_from_chain_format(self, btc_usdt_perp_market: DerivativeMarket): | |
expected_notional = Decimal("123.456") | |
notional_decimals = btc_usdt_perp_market.quote_token.decimals | |
chain_format_notional = expected_notional * Decimal(f"1e{notional_decimals}") | |
human_readable_notional = btc_usdt_perp_market.notional_from_chain_format(chain_value=chain_format_notional) | |
assert expected_notional == human_readable_notional | |
def test_convert_notional_from_chain_format(self): | |
expected_notional = Decimal("123.456") | |
notional_decimals = btc_usdt_perp_market.quote_token.decimals | |
chain_format_notional = expected_notional * Decimal(f"1e{notional_decimals}") | |
human_readable_notional = btc_usdt_perp_market.notional_from_chain_format(chain_value=chain_format_notional) | |
assert expected_notional == human_readable_notional |
Tools
Ruff
189-189: Redefinition of unused
btc_usdt_perp_market
from line 6(F811)
def test_convert_notional_from_extended_chain_format(self, btc_usdt_perp_market: DerivativeMarket): | ||
expected_notional = Decimal("123.456") | ||
|
||
notional_decimals = btc_usdt_perp_market.quote_token.decimals | ||
chain_format_notional = ( | ||
expected_notional * Decimal(f"1e{notional_decimals}") * Decimal(f"1e{ADDITIONAL_CHAIN_FORMAT_DECIMALS}") | ||
) | ||
human_readable_notional = btc_usdt_perp_market.notional_from_extended_chain_format( | ||
chain_value=chain_format_notional | ||
) | ||
|
||
assert expected_notional == human_readable_notional | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redefinition of unused fixture btc_usdt_perp_market
.
The fixture btc_usdt_perp_market
is redefined but not used in the test function. This can be resolved by removing the redefinition.
- def test_convert_notional_from_extended_chain_format(self, btc_usdt_perp_market: DerivativeMarket):
+ def test_convert_notional_from_extended_chain_format(self):
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
def test_convert_notional_from_extended_chain_format(self, btc_usdt_perp_market: DerivativeMarket): | |
expected_notional = Decimal("123.456") | |
notional_decimals = btc_usdt_perp_market.quote_token.decimals | |
chain_format_notional = ( | |
expected_notional * Decimal(f"1e{notional_decimals}") * Decimal(f"1e{ADDITIONAL_CHAIN_FORMAT_DECIMALS}") | |
) | |
human_readable_notional = btc_usdt_perp_market.notional_from_extended_chain_format( | |
chain_value=chain_format_notional | |
) | |
assert expected_notional == human_readable_notional | |
def test_convert_notional_from_extended_chain_format(self): | |
expected_notional = Decimal("123.456") | |
notional_decimals = btc_usdt_perp_market.quote_token.decimals | |
chain_format_notional = ( | |
expected_notional * Decimal(f"1e{notional_decimals}") * Decimal(f"1e{ADDITIONAL_CHAIN_FORMAT_DECIMALS}") | |
) | |
human_readable_notional = btc_usdt_perp_market.notional_from_extended_chain_format( | |
chain_value=chain_format_notional | |
) | |
assert expected_notional == human_readable_notional |
Tools
Ruff
230-230: Redefinition of unused
btc_usdt_perp_market
from line 6(F811)
def test_convert_notional_from_extended_chain_format(self, inj_usdt_spot_market: SpotMarket): | ||
expected_notional = Decimal("123.456") | ||
|
||
notional_decimals = inj_usdt_spot_market.quote_token.decimals | ||
chain_format_notional = ( | ||
expected_notional * Decimal(f"1e{notional_decimals}") * Decimal(f"1e{ADDITIONAL_CHAIN_FORMAT_DECIMALS}") | ||
) | ||
human_readable_notional = inj_usdt_spot_market.notional_from_extended_chain_format( | ||
chain_value=chain_format_notional | ||
) | ||
|
||
assert expected_notional == human_readable_notional | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redefinition of unused fixture inj_usdt_spot_market
.
The fixture inj_usdt_spot_market
is redefined but not used in the test function. This can be resolved by removing the redefinition.
- def test_convert_notional_from_extended_chain_format(self, inj_usdt_spot_market: SpotMarket):
+ def test_convert_notional_from_extended_chain_format(self):
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
def test_convert_notional_from_extended_chain_format(self, inj_usdt_spot_market: SpotMarket): | |
expected_notional = Decimal("123.456") | |
notional_decimals = inj_usdt_spot_market.quote_token.decimals | |
chain_format_notional = ( | |
expected_notional * Decimal(f"1e{notional_decimals}") * Decimal(f"1e{ADDITIONAL_CHAIN_FORMAT_DECIMALS}") | |
) | |
human_readable_notional = inj_usdt_spot_market.notional_from_extended_chain_format( | |
chain_value=chain_format_notional | |
) | |
assert expected_notional == human_readable_notional | |
def test_convert_notional_from_extended_chain_format(self): | |
expected_notional = Decimal("123.456") | |
notional_decimals = inj_usdt_spot_market.quote_token.decimals | |
chain_format_notional = ( | |
expected_notional * Decimal(f"1e{notional_decimals}") * Decimal(f"1e{ADDITIONAL_CHAIN_FORMAT_DECIMALS}") | |
) | |
human_readable_notional = inj_usdt_spot_market.notional_from_extended_chain_format( | |
chain_value=chain_format_notional | |
) | |
assert expected_notional == human_readable_notional |
Tools
Ruff
101-101: Redefinition of unused
inj_usdt_spot_market
from line 9(F811)
def test_convert_notional_to_chain_format(self, btc_usdt_perp_market: DerivativeMarket): | ||
original_notional = Decimal("123.456789") | ||
|
||
chain_value = btc_usdt_perp_market.notional_to_chain_format(human_readable_value=original_notional) | ||
notional_decimals = btc_usdt_perp_market.quote_token.decimals | ||
expected_value = original_notional * Decimal(f"1e{notional_decimals}") | ||
expected_chain_format_value = expected_value * Decimal(f"1e{ADDITIONAL_CHAIN_FORMAT_DECIMALS}") | ||
|
||
assert expected_chain_format_value == chain_value | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redefinition of unused fixture btc_usdt_perp_market
.
The fixture btc_usdt_perp_market
is redefined but not used in the test function. This can be resolved by removing the redefinition.
- def test_convert_notional_to_chain_format(self, btc_usdt_perp_market: DerivativeMarket):
+ def test_convert_notional_to_chain_format(self):
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
def test_convert_notional_to_chain_format(self, btc_usdt_perp_market: DerivativeMarket): | |
original_notional = Decimal("123.456789") | |
chain_value = btc_usdt_perp_market.notional_to_chain_format(human_readable_value=original_notional) | |
notional_decimals = btc_usdt_perp_market.quote_token.decimals | |
expected_value = original_notional * Decimal(f"1e{notional_decimals}") | |
expected_chain_format_value = expected_value * Decimal(f"1e{ADDITIONAL_CHAIN_FORMAT_DECIMALS}") | |
assert expected_chain_format_value == chain_value | |
def test_convert_notional_to_chain_format(self): | |
original_notional = Decimal("123.456789") | |
chain_value = btc_usdt_perp_market.notional_to_chain_format(human_readable_value=original_notional) | |
notional_decimals = btc_usdt_perp_market.quote_token.decimals | |
expected_value = original_notional * Decimal(f"1e{notional_decimals}") | |
expected_chain_format_value = expected_value * Decimal(f"1e{ADDITIONAL_CHAIN_FORMAT_DECIMALS}") | |
assert expected_chain_format_value == chain_value |
Tools
Ruff
153-153: Redefinition of unused
btc_usdt_perp_market
from line 6(F811)
def test_convert_notional_to_chain_format(self, first_match_bet_market: BinaryOptionMarket): | ||
original_notional = Decimal("123.456789") | ||
|
||
chain_value = first_match_bet_market.notional_to_chain_format(human_readable_value=original_notional) | ||
notional_decimals = first_match_bet_market.quote_token.decimals | ||
expected_value = original_notional * Decimal(f"1e{notional_decimals}") | ||
expected_chain_format_value = expected_value * Decimal(f"1e{ADDITIONAL_CHAIN_FORMAT_DECIMALS}") | ||
|
||
assert expected_chain_format_value == chain_value | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redefinition of unused fixture first_match_bet_market
.
The fixture first_match_bet_market
is redefined but not used in the test function. This can be resolved by removing the redefinition.
- def test_convert_notional_to_chain_format(self, first_match_bet_market: BinaryOptionMarket):
+ def test_convert_notional_to_chain_format(self):
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
def test_convert_notional_to_chain_format(self, first_match_bet_market: BinaryOptionMarket): | |
original_notional = Decimal("123.456789") | |
chain_value = first_match_bet_market.notional_to_chain_format(human_readable_value=original_notional) | |
notional_decimals = first_match_bet_market.quote_token.decimals | |
expected_value = original_notional * Decimal(f"1e{notional_decimals}") | |
expected_chain_format_value = expected_value * Decimal(f"1e{ADDITIONAL_CHAIN_FORMAT_DECIMALS}") | |
assert expected_chain_format_value == chain_value | |
def test_convert_notional_to_chain_format(self): | |
original_notional = Decimal("123.456789") | |
chain_value = first_match_bet_market.notional_to_chain_format(human_readable_value=original_notional) | |
notional_decimals = first_match_bet_market.quote_token.decimals | |
expected_value = original_notional * Decimal(f"1e{notional_decimals}") | |
expected_chain_format_value = expected_value * Decimal(f"1e{ADDITIONAL_CHAIN_FORMAT_DECIMALS}") | |
assert expected_chain_format_value == chain_value |
Tools
Ruff
425-425: Redefinition of unused
first_match_bet_market
from line 7(F811)
def test_convert_notional_from_extended_chain_format(self, first_match_bet_market: BinaryOptionMarket): | ||
expected_notional = Decimal("123.456") | ||
|
||
notional_decimals = first_match_bet_market.quote_token.decimals | ||
chain_format_notional = ( | ||
expected_notional * Decimal(f"1e{notional_decimals}") * Decimal(f"1e{ADDITIONAL_CHAIN_FORMAT_DECIMALS}") | ||
) | ||
human_readable_notional = first_match_bet_market.notional_from_extended_chain_format( | ||
chain_value=chain_format_notional | ||
) | ||
|
||
assert expected_notional == human_readable_notional |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redefinition of unused fixture first_match_bet_market
.
The fixture first_match_bet_market
is redefined but not used in the test function. This can be resolved by removing the redefinition.
- def test_convert_notional_from_extended_chain_format(self, first_match_bet_market: BinaryOptionMarket):
+ def test_convert_notional_from_extended_chain_format(self):
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
def test_convert_notional_from_extended_chain_format(self, first_match_bet_market: BinaryOptionMarket): | |
expected_notional = Decimal("123.456") | |
notional_decimals = first_match_bet_market.quote_token.decimals | |
chain_format_notional = ( | |
expected_notional * Decimal(f"1e{notional_decimals}") * Decimal(f"1e{ADDITIONAL_CHAIN_FORMAT_DECIMALS}") | |
) | |
human_readable_notional = first_match_bet_market.notional_from_extended_chain_format( | |
chain_value=chain_format_notional | |
) | |
assert expected_notional == human_readable_notional | |
def test_convert_notional_from_extended_chain_format(self): | |
expected_notional = Decimal("123.456") | |
notional_decimals = first_match_bet_market.quote_token.decimals | |
chain_format_notional = ( | |
expected_notional * Decimal(f"1e{notional_decimals}") * Decimal(f"1e{ADDITIONAL_CHAIN_FORMAT_DECIMALS}") | |
) | |
human_readable_notional = first_match_bet_market.notional_from_extended_chain_format( | |
chain_value=chain_format_notional | |
) | |
assert expected_notional == human_readable_notional |
Tools
Ruff
576-576: Redefinition of unused
first_match_bet_market
from line 7(F811)
def test_convert_notional_to_chain_format(self, inj_usdt_spot_market: SpotMarket): | ||
original_notional = Decimal("123.456789") | ||
|
||
chain_value = inj_usdt_spot_market.notional_to_chain_format(human_readable_value=original_notional) | ||
notional_decimals = inj_usdt_spot_market.quote_token.decimals | ||
expected_value = original_notional * Decimal(f"1e{notional_decimals}") | ||
expected_chain_format_value = expected_value * Decimal(f"1e{ADDITIONAL_CHAIN_FORMAT_DECIMALS}") | ||
|
||
assert expected_chain_format_value == chain_value | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redefinition of unused fixture inj_usdt_spot_market
.
The fixture inj_usdt_spot_market
is redefined but not used in the test function. This can be resolved by removing the redefinition.
- def test_convert_notional_to_chain_format(self, inj_usdt_spot_market: SpotMarket):
+ def test_convert_notional_to_chain_format(self):
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
def test_convert_notional_to_chain_format(self, inj_usdt_spot_market: SpotMarket): | |
original_notional = Decimal("123.456789") | |
chain_value = inj_usdt_spot_market.notional_to_chain_format(human_readable_value=original_notional) | |
notional_decimals = inj_usdt_spot_market.quote_token.decimals | |
expected_value = original_notional * Decimal(f"1e{notional_decimals}") | |
expected_chain_format_value = expected_value * Decimal(f"1e{ADDITIONAL_CHAIN_FORMAT_DECIMALS}") | |
assert expected_chain_format_value == chain_value | |
def test_convert_notional_to_chain_format(self): | |
original_notional = Decimal("123.456789") | |
chain_value = inj_usdt_spot_market.notional_to_chain_format(human_readable_value=original_notional) | |
notional_decimals = inj_usdt_spot_market.quote_token.decimals | |
expected_value = original_notional * Decimal(f"1e{notional_decimals}") | |
expected_chain_format_value = expected_value * Decimal(f"1e{ADDITIONAL_CHAIN_FORMAT_DECIMALS}") | |
assert expected_chain_format_value == chain_value |
Tools
Ruff
40-40: Redefinition of unused
inj_usdt_spot_market
from line 9(F811)
…atible with protobuf 5.26.1. Regenerated all compiled protos
min_notional
field to all market classes.min_notional
as part of the markets and tokens initialization in AsyncClientSolves CHAIN-170
Summary by CodeRabbit
New Features
Bug Fixes
Tests
Chores