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/change default gas price #280

Merged
merged 7 commits into from
Dec 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ clean-all:
$(call clean_repos)

clone-injective-core:
git clone https://github.com/InjectiveLabs/injective-core.git -b v1.12.6-testnet --depth 1 --single-branch
git clone https://github.com/InjectiveLabs/injective-core.git -b v1.12.8-testnet --depth 1 --single-branch

clone-injective-indexer:
git clone https://github.com/InjectiveLabs/injective-indexer.git -b v1.12.59 --depth 1 --single-branch
git clone https://github.com/InjectiveLabs/injective-indexer.git -b v1.12.67 --depth 1 --single-branch

clone-cometbft:
git clone https://github.com/cometbft/cometbft.git -b v0.37.2 --depth 1 --single-branch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ async def main() -> None:
skip = 4
limit = 4
pagination = PaginationOption(skip=skip, limit=limit)
positions = await client.fetch_derivative_positions(
positions = await client.fetch_derivative_positions_v2(
market_ids=market_ids,
subaccount_id=subaccount_id,
direction=direction,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ async def main() -> None:
network = Network.testnet()
client = AsyncClient(network)
account_address = "inj1clw20s2uxeyxtam6f7m84vgae92s9eh7vygagt"
portfolio = await client.fetch_account_portfolio(account_address=account_address)
portfolio = await client.fetch_account_portfolio_balances(account_address=account_address)
print(portfolio)


Expand Down
1,717 changes: 1,008 additions & 709 deletions poetry.lock

Large diffs are not rendered by default.

18 changes: 10 additions & 8 deletions pyinjective/async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2105,9 +2105,9 @@

async def get_derivative_positions(self, **kwargs):
"""
This method is deprecated and will be removed soon. Please use `fetch_derivative_positions` instead
This method is deprecated and will be removed soon. Please use `fetch_derivative_positions_v2` instead
"""
warn("This method is deprecated. Use fetch_derivative_positions instead", DeprecationWarning, stacklevel=2)
warn("This method is deprecated. Use fetch_derivative_positions_v2 instead", DeprecationWarning, stacklevel=2)
req = derivative_exchange_rpc_pb.PositionsRequest(
market_id=kwargs.get("market_id"),
market_ids=kwargs.get("market_ids"),
Expand All @@ -2119,15 +2119,15 @@
)
return await self.stubDerivativeExchange.Positions(req)

async def fetch_derivative_positions(
async def fetch_derivative_positions_v2(
self,
market_ids: Optional[List[str]] = None,
subaccount_id: Optional[str] = None,
direction: Optional[str] = None,
subaccount_total_positions: Optional[bool] = None,
pagination: Optional[PaginationOption] = None,
) -> Dict[str, Any]:
return await self.exchange_derivative_api.fetch_positions(
return await self.exchange_derivative_api.fetch_positions_v2(

Check warning on line 2130 in pyinjective/async_client.py

View check run for this annotation

Codecov / codecov/patch

pyinjective/async_client.py#L2130

Added line #L2130 was not covered by tests
market_ids=market_ids,
subaccount_id=subaccount_id,
direction=direction,
Expand Down Expand Up @@ -2344,14 +2344,16 @@

async def get_account_portfolio(self, account_address: str):
"""
This method is deprecated and will be removed soon. Please use `fetch_account_portfolio` instead
This method is deprecated and will be removed soon. Please use `fetch_account_portfolio_balances` instead
"""
warn("This method is deprecated. Use fetch_account_portfolio instead", DeprecationWarning, stacklevel=2)
warn(
"This method is deprecated. Use fetch_account_portfolio_balances instead", DeprecationWarning, stacklevel=2
)
req = portfolio_rpc_pb.AccountPortfolioRequest(account_address=account_address)
return await self.stubPortfolio.AccountPortfolio(req)

async def fetch_account_portfolio(self, account_address: str) -> Dict[str, Any]:
return await self.exchange_portfolio_api.fetch_account_portfolio(account_address=account_address)
async def fetch_account_portfolio_balances(self, account_address: str) -> Dict[str, Any]:
return await self.exchange_portfolio_api.fetch_account_portfolio_balances(account_address=account_address)

Check warning on line 2356 in pyinjective/async_client.py

View check run for this annotation

Codecov / codecov/patch

pyinjective/async_client.py#L2356

Added line #L2356 was not covered by tests

async def stream_account_portfolio(self, account_address: str, **kwargs):
"""
Expand Down
24 changes: 24 additions & 0 deletions pyinjective/client/indexer/grpc/indexer_grpc_derivative_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,30 @@ async def fetch_positions(

return response

async def fetch_positions_v2(
self,
market_ids: Optional[List[str]] = None,
subaccount_id: Optional[str] = None,
direction: Optional[str] = None,
subaccount_total_positions: Optional[bool] = None,
pagination: Optional[PaginationOption] = None,
) -> Dict[str, Any]:
pagination = pagination or PaginationOption()
request = exchange_derivative_pb.PositionsV2Request(
market_ids=market_ids,
subaccount_id=subaccount_id,
skip=pagination.skip,
limit=pagination.limit,
start_time=pagination.start_time,
end_time=pagination.end_time,
direction=direction,
subaccount_total_positions=subaccount_total_positions,
)

response = await self._execute_call(call=self._stub.PositionsV2, request=request)

return response

async def fetch_liquidable_positions(
self,
market_id: Optional[str] = None,
Expand Down
6 changes: 6 additions & 0 deletions pyinjective/client/indexer/grpc/indexer_grpc_portfolio_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,11 @@ async def fetch_account_portfolio(self, account_address: str) -> Dict[str, Any]:

return response

async def fetch_account_portfolio_balances(self, account_address: str) -> Dict[str, Any]:
request = exchange_portfolio_pb.AccountPortfolioBalancesRequest(account_address=account_address)
response = await self._execute_call(call=self._stub.AccountPortfolioBalances, request=request)

return response

async def _execute_call(self, call: Callable, request) -> Dict[str, Any]:
return await self._assistant.execute_call(call=call, request=request)
2 changes: 1 addition & 1 deletion pyinjective/constant.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
from configparser import ConfigParser

GAS_PRICE = 500_000_000
GAS_PRICE = 160_000_000
GAS_FEE_BUFFER_AMOUNT = 25_000
MAX_MEMO_CHARACTERS = 256
ADDITIONAL_CHAIN_FORMAT_DECIMALS = 18
Expand Down
3 changes: 2 additions & 1 deletion pyinjective/core/broadcaster.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from pyinjective import PrivateKey, PublicKey, Transaction
from pyinjective.async_client import AsyncClient
from pyinjective.composer import Composer
from pyinjective.constant import GAS_PRICE
from pyinjective.core.gas_limit_estimator import GasLimitEstimator
from pyinjective.core.network import Network

Expand All @@ -35,7 +36,7 @@ def messages_prepared_for_transaction(self, messages: List[any_pb2.Any]) -> List


class TransactionFeeCalculator(ABC):
DEFAULT_GAS_PRICE = 500_000_000
DEFAULT_GAS_PRICE = GAS_PRICE

@abstractmethod
async def configure_gas_fee_for_transaction(
Expand Down
8 changes: 4 additions & 4 deletions pyinjective/proto/cosmos/ics23/v1/proofs_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading