Skip to content
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

Merged
merged 9 commits into from
Aug 6, 2024

Conversation

aarmoa
Copy link
Collaborator

@aarmoa aarmoa commented Aug 6, 2024

  • Added support for the new messages in exchange module, included in the chain upgrade v1.13.
  • Added unit tests and example scripts
  • Added the min_notional field to all market classes.
  • Added logic to initialize the min_notional as part of the markets and tokens initialization in AsyncClient

Solves CHAIN-170

Summary by CodeRabbit

  • New Features

    • Introduced new message support within the "exchange" module, enhancing functionality with five new message types related to market operations and stake grants.
    • Added methods for updating market parameters and decreasing position margins, improving market management capabilities.
    • Implemented a minimum notional parameter across various configurations and market classes, enhancing trading conditions and controls.
  • Bug Fixes

    • Improved error handling in the token loading process to prevent potential issues with missing attributes.
  • Tests

    • Expanded test coverage with new test functions for validating notional value conversions and market operations. Enhanced existing tests to align with new functionalities.
  • Chores

    • Updated project version from 1.6.0 to 1.6.1 for backward-compatible improvements.

… 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
Copy link
Contributor

coderabbitai bot commented Aug 6, 2024

Important

Review skipped

More 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 reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The recent changes significantly enhance the codebase by introducing a new min_notional parameter to improve market operations and validations. This update allows for more precise trading conditions across various modules, enhancing their functionality and robustness. Testing frameworks have also been updated to ensure comprehensive coverage of these new features, contributing to a more reliable and efficient system overall.

Changes

Files Change Summary
.github/workflows/run-tests.yml Updated Codecov action from v3 to v4 for improved functionality.
CHANGELOG.md Documented new message types added to the "exchange" module, enhancing its capabilities.
examples/chain_client/exchange/*.py Introduced asynchronous scripts for margin adjustments and market updates, incorporating a min_notional parameter.
pyinjective/*.py Added min_notional to multiple classes and methods, enhancing data handling and market operations.
pyinjective/denoms_*.ini Introduced min_notional parameters for various trading pairs to establish minimum transaction conditions.
tests/*.py Updated tests to incorporate min_notional checks, ensuring robust validation of market functionalities.

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
Loading

🐰 In fields of greens and skies so blue,
A change has come, oh how it grew!
With min_notional bright and bold,
Our markets dance, a sight to behold!
Hops of joy in code we weave,
Celebrating all, let’s greatly achieve! 🥕


Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 of Denom class instantiation without the new min_notional parameter found:

The following locations in the codebase instantiate the Denom class without including the new min_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 new min_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 PrivateKey
examples/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 PrivateKey
CHANGELOG.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

Commits

Files that changed from the base of the PR and between 7f39b06 and e5095d5.

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.yml

Length of output: 90

pyinjective/core/tokens_file_loader.py (1)

18-18: Improvement: Use get method to access address attribute.

The use of the get method enhances robustness by preventing potential KeyError 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 of INJECTIVE_PRIVATE_KEY.

Ensure that the INJECTIVE_PRIVATE_KEY environment variable is set and valid.


25-28: Verify the configuration of MsgBroadcasterWithPk.

Ensure that MsgBroadcasterWithPk is correctly configured and the private key is valid.


37-39: Verify the msg_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 the min_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: Initialize min_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! The min_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! The min_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! The min_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! The min_notional parameter is correctly integrated.

The addition of the min_notional parameter enhances the Denom object for more precise control over trading conditions.

tests/rpc_fixtures/markets_fixtures.py (4)

127-127: LGTM! The min_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! The min_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! The min_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! The min_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: Ensure min_notional is correctly initialized.

The addition of the min_notional check is appropriate. Ensure that min_notional is correctly initialized and populated in both the market and denom objects.


46-46: Consistent formatting for min_notional.

Ensure that the min_notional value is consistently formatted as a Decimal in both denom and market dictionaries.


54-54: Consistent formatting for min_notional.

Ensure that the min_notional value is consistently formatted as a float in both denom and market dictionaries.


65-65: Ensure min_notional is correctly initialized.

The addition of the min_notional check is appropriate. Ensure that min_notional is correctly initialized and populated in both the market and denom objects.


74-74: Consistent formatting for min_notional.

Ensure that the min_notional value is consistently formatted as a Decimal in both denom and market dictionaries.


81-81: Consistent formatting for min_notional.

Ensure that the min_notional value is consistently formatted as a float in both denom and market dictionaries.


92-92: Ensure min_notional is correctly initialized.

The addition of the min_notional check is appropriate. Ensure that min_notional is correctly initialized and populated in both the market and denom objects.


101-101: Consistent formatting for min_notional.

Ensure that the min_notional value is consistently formatted as a Decimal in both denom and market dictionaries.


108-108: Consistent formatting for min_notional.

Ensure that the min_notional value is consistently formatted as a float in both denom and market dictionaries.

pyinjective/core/market.py (12)

22-22: Ensure min_notional is correctly initialized.

The addition of the min_notional attribute is appropriate. Ensure that min_notional is correctly initialized and populated.


39-46: Verify notional_to_chain_format logic.

The notional_to_chain_format method correctly converts human-readable values to chain format. Verify that the min_notional attribute is correctly used as the quantization factor.


55-57: Verify notional_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: Verify notional_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: Ensure min_notional is correctly initialized.

The addition of the min_notional attribute is appropriate. Ensure that min_notional is correctly initialized and populated.


122-130: Verify notional_to_chain_format logic.

The notional_to_chain_format method correctly converts human-readable values to chain format. Verify that the min_notional attribute is correctly used as the quantization factor.


140-141: Verify notional_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: Verify notional_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: Ensure min_notional is correctly initialized.

The addition of the min_notional attribute is appropriate. Ensure that min_notional is correctly initialized and populated.


234-242: Verify notional_to_chain_format logic.

The notional_to_chain_format method correctly converts human-readable values to chain format. Verify that the min_notional attribute is correctly used as the quantization factor.


255-257: Verify notional_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: Verify notional_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 for SpotMarket 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 for SpotMarket 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 for SpotMarket 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 for DerivativeMarket 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 for DerivativeMarket 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 for DerivativeMarket 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 for BinaryOptionMarket 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 for BinaryOptionMarket 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 for BinaryOptionMarket 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 the min_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 the min_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 of test_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 of test_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 of test_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 of test_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 of test_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 of test_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 the min_notional value is correctly parsed.

The min_notional value is being converted to a Decimal. Ensure that the market_info["minNotional"] field always contains a valid numeric string to avoid potential parsing errors.


3363-3363: Ensure the min_notional value is correctly parsed.

The min_notional value is being converted to a Decimal. Ensure that the market_info["minNotional"] field always contains a valid numeric string to avoid potential parsing errors.


3388-3388: Ensure the min_notional value is correctly parsed.

The min_notional value is being converted to a Decimal. Ensure that the market_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.

Comment on lines +1834 to +1862
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}",
)
Copy link
Contributor

@coderabbitai coderabbitai bot Aug 6, 2024

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.

Copy link
Collaborator Author

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

Copy link
Contributor

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.

Comment on lines +47 to +48
if __name__ == "__main__":
asyncio.get_event_loop().run_until_complete(main())
Copy link
Contributor

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.

Suggested change
if __name__ == "__main__":
asyncio.get_event_loop().run_until_complete(main())
if __name__ == "__main__":
asyncio.run(main())

Comment on lines +14 to +15
dotenv.load_dotenv()
configured_private_key = os.getenv("INJECTIVE_PRIVATE_KEY")
Copy link
Contributor

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.

Suggested change
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.")

Comment on lines +50 to +52
result = await message_broadcaster.broadcast([msg])
print("---Transaction Response---")
print(result)
Copy link
Contributor

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.

Suggested change
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}")

pyinjective/composer.py Outdated Show resolved Hide resolved
Comment on lines +14 to +15
dotenv.load_dotenv()
configured_private_key = os.getenv("INJECTIVE_PRIVATE_KEY")
Copy link
Contributor

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.

Suggested change
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.")

Comment on lines +50 to +52
result = await message_broadcaster.broadcast([message])
print("---Transaction Response---")
print(result)
Copy link
Contributor

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.

Suggested change
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}")

Comment on lines +26 to +29
message_broadcaster = MsgBroadcasterWithPk.new_using_simulation(
network=network,
private_key=configured_private_key,
)
Copy link
Contributor

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.

Suggested change
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}",
Copy link
Contributor

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.

Suggested change
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}",
Copy link
Contributor

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.

Suggested change
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>
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

Commits

Files that changed from the base of the PR and between e5095d5 and dedef04.

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

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

Commits

Files that changed from the base of the PR and between dedef04 and 1bffc7c.

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)

Comment on lines +67 to +75
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

Copy link
Contributor

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.

Suggested change
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)

Comment on lines +492 to +500
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

Copy link
Contributor

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.

Suggested change
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)

Comment on lines +189 to +197
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

Copy link
Contributor

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.

Suggested change
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)

Comment on lines +230 to +242
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

Copy link
Contributor

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.

Suggested change
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)

Comment on lines +101 to +113
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

Copy link
Contributor

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.

Suggested change
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)

Comment on lines +153 to +162
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

Copy link
Contributor

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.

Suggested change
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)

Comment on lines +425 to +434
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

Copy link
Contributor

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.

Suggested change
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)

Comment on lines +576 to +587
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
Copy link
Contributor

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.

Suggested change
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)

Comment on lines +40 to +49
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

Copy link
Contributor

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.

Suggested change
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
Copy link

socket-security bot commented Aug 6, 2024

New and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
pypi/[email protected] network 0 77.4 kB bdraco
pypi/[email protected] environment, eval, filesystem, network, shell, unsafe 0 14.3 MB Andrew.Svetlov, fafhrd, webknjaz
pypi/[email protected] environment, eval, filesystem, shell, unsafe 0 1.47 MB hynek
pypi/[email protected] environment, eval, filesystem, network, shell, unsafe 0 2.16 MB Armin.Rigo, alexgaynor, fijal, ...5 more
pypi/[email protected] environment, eval, filesystem, network 0 826 kB nedbatchelder
pypi/[email protected] None 0 0 B
pypi/[email protected] environment, network 0 37 MB google_opensource, grpc-packages

🚮 Removed packages: pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected], pypi/[email protected]

View full report↗︎

@aarmoa aarmoa merged commit e68db6f into master Aug 6, 2024
12 checks passed
@aarmoa aarmoa deleted the feat/add_exchange_messages_from_v1_13 branch August 6, 2024 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant