Skip to content

Commit

Permalink
Merge pull request #311 from InjectiveLabs/release/release_v140_to_ma…
Browse files Browse the repository at this point in the history
…ster

Release/release v140 to master
  • Loading branch information
aarmoa authored Mar 8, 2024
2 parents 83152b2 + ec1fb93 commit 52033b4
Show file tree
Hide file tree
Showing 172 changed files with 11,174 additions and 1,557 deletions.
8 changes: 8 additions & 0 deletions .coderabbit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
reviews:
auto_review:
base_branches:
- "master"
- "dev"
- "feat/.*"
chat:
auto_reply: true
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

All notable changes to this project will be documented in this file.

## [1.4.0] - 2024-03-11
### Added
- Added support for all queries and messages in the chain 'distribution' module
- Added support for all queries and messages in the chain 'exchange' module
- Use of python-dotenv in all example scripts to load private keys from a .env file

## [1.3.1] - 2024-02-29
### Changed
- Updated cookie assistant logic to support the Indexer exchange server not using cookies and the chain server using them
Expand Down
7 changes: 6 additions & 1 deletion examples/SendToInjective.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
import asyncio
import json
import os

import dotenv

from pyinjective.core.network import Network
from pyinjective.sendtocosmos import Peggo


async def main() -> None:
dotenv.load_dotenv()
private_key = os.getenv("INJECTIVE_PRIVATE_KEY")

# select network: testnet, mainnet
network = Network.testnet()
peggo_composer = Peggo(network=network.string())

private_key = "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e"
ethereum_endpoint = "https://eth-goerli.g.alchemy.com/v2/q-7JVv4mTfsNh1y_djKkKn3maRBGILLL"

maxFeePerGas_Gwei = 4
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import asyncio
import os
import uuid
from decimal import Decimal

import dotenv

from pyinjective.async_client import AsyncClient
from pyinjective.constant import GAS_FEE_BUFFER_AMOUNT, GAS_PRICE
Expand All @@ -10,6 +14,9 @@


async def main() -> None:
dotenv.load_dotenv()
configured_private_key = os.getenv("INJECTIVE_PRIVATE_KEY")

# select network: local, testnet, mainnet
network = Network.testnet()

Expand All @@ -19,7 +26,7 @@ async def main() -> None:
await client.sync_timeout_height()

# load account
priv_key = PrivateKey.from_hex("f9db9bf330e23cb7839039e944adef6e9df447b90b503d5b4464c90bea9022f3")
priv_key = PrivateKey.from_hex(configured_private_key)
pub_key = priv_key.to_public_key()
address = pub_key.to_address()
await client.fetch_account(address.to_acc_bech32())
Expand All @@ -34,57 +41,59 @@ async def main() -> None:
fee_recipient = "inj1hkhdaj2a2clmq5jq6mspsggqs32vynpk228q3r"

spot_orders = [
composer.SpotOrder(
composer.spot_order(
market_id=spot_market_id,
subaccount_id=subaccount_id,
fee_recipient=fee_recipient,
price=0.524,
quantity=0.01,
is_buy=True,
is_po=False,
price=Decimal("0.524"),
quantity=Decimal("0.01"),
order_type="BUY",
cid=str(uuid.uuid4()),
),
composer.SpotOrder(
composer.spot_order(
market_id=spot_market_id,
subaccount_id=subaccount_id,
fee_recipient=fee_recipient,
price=27.92,
quantity=0.01,
is_buy=False,
is_po=False,
price=Decimal("27.92"),
quantity=Decimal("0.01"),
order_type="SELL",
cid=str(uuid.uuid4()),
),
]

derivative_orders = [
composer.DerivativeOrder(
composer.derivative_order(
market_id=deriv_market_id,
subaccount_id=subaccount_id,
fee_recipient=fee_recipient,
price=10500,
quantity=0.01,
leverage=1.5,
is_buy=True,
is_po=False,
price=Decimal(10500),
quantity=Decimal(0.01),
margin=composer.calculate_margin(
quantity=Decimal(0.01), price=Decimal(10500), leverage=Decimal(2), is_reduce_only=False
),
order_type="BUY",
cid=str(uuid.uuid4()),
),
composer.DerivativeOrder(
composer.derivative_order(
market_id=deriv_market_id,
subaccount_id=subaccount_id,
fee_recipient=fee_recipient,
price=65111,
quantity=0.01,
leverage=2,
is_buy=False,
is_reduce_only=False,
price=Decimal(65111),
quantity=Decimal(0.01),
margin=composer.calculate_margin(
quantity=Decimal(0.01), price=Decimal(65111), leverage=Decimal(2), is_reduce_only=False
),
order_type="SELL",
cid=str(uuid.uuid4()),
),
]

# prepare tx msg
spot_msg = composer.MsgBatchCreateSpotLimitOrders(sender=address.to_acc_bech32(), orders=spot_orders)
spot_msg = composer.msg_batch_create_spot_limit_orders(sender=address.to_acc_bech32(), orders=spot_orders)

deriv_msg = composer.MsgBatchCreateDerivativeLimitOrders(sender=address.to_acc_bech32(), orders=derivative_orders)
deriv_msg = composer.msg_batch_create_derivative_limit_orders(
sender=address.to_acc_bech32(), orders=derivative_orders
)

# compute order hashes
order_hashes = order_hash_manager.compute_order_hashes(
Expand All @@ -107,7 +116,7 @@ async def main() -> None:
gas_limit = base_gas + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation
gas_fee = "{:.18f}".format((gas_price * gas_limit) / pow(10, 18)).rstrip("0")
fee = [
composer.Coin(
composer.coin(
amount=gas_price * gas_limit,
denom=network.fee_denom,
)
Expand Down Expand Up @@ -144,7 +153,7 @@ async def main() -> None:
gas_limit = base_gas + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation
gas_fee = "{:.18f}".format((gas_price * gas_limit) / pow(10, 18)).rstrip("0")
fee = [
composer.Coin(
composer.coin(
amount=gas_price * gas_limit,
denom=network.fee_denom,
)
Expand All @@ -161,57 +170,59 @@ async def main() -> None:
print("gas fee: {} INJ".format(gas_fee))

spot_orders = [
composer.SpotOrder(
composer.spot_order(
market_id=spot_market_id,
subaccount_id=subaccount_id_2,
fee_recipient=fee_recipient,
price=1.524,
quantity=0.01,
is_buy=True,
is_po=True,
price=Decimal("1.524"),
quantity=Decimal("0.01"),
order_type="BUY_PO",
cid=str(uuid.uuid4()),
),
composer.SpotOrder(
composer.spot_order(
market_id=spot_market_id,
subaccount_id=subaccount_id_2,
fee_recipient=fee_recipient,
price=27.92,
quantity=0.01,
is_buy=False,
is_po=False,
price=Decimal("27.92"),
quantity=Decimal("0.01"),
order_type="SELL_PO",
cid=str(uuid.uuid4()),
),
]

derivative_orders = [
composer.DerivativeOrder(
composer.derivative_order(
market_id=deriv_market_id,
subaccount_id=subaccount_id_2,
fee_recipient=fee_recipient,
price=25111,
quantity=0.01,
leverage=1.5,
is_buy=True,
is_po=False,
price=Decimal(25111),
quantity=Decimal(0.01),
margin=composer.calculate_margin(
quantity=Decimal(0.01), price=Decimal(25111), leverage=Decimal("1.5"), is_reduce_only=False
),
order_type="BUY",
cid=str(uuid.uuid4()),
),
composer.DerivativeOrder(
composer.derivative_order(
market_id=deriv_market_id,
subaccount_id=subaccount_id_2,
fee_recipient=fee_recipient,
price=65111,
quantity=0.01,
leverage=2,
is_buy=False,
is_reduce_only=False,
price=Decimal(65111),
quantity=Decimal(0.01),
margin=composer.calculate_margin(
quantity=Decimal(0.01), price=Decimal(25111), leverage=Decimal(2), is_reduce_only=False
),
order_type="SELL",
cid=str(uuid.uuid4()),
),
]

# prepare tx msg
spot_msg = composer.MsgBatchCreateSpotLimitOrders(sender=address.to_acc_bech32(), orders=spot_orders)
spot_msg = composer.msg_batch_create_spot_limit_orders(sender=address.to_acc_bech32(), orders=spot_orders)

deriv_msg = composer.MsgBatchCreateDerivativeLimitOrders(sender=address.to_acc_bech32(), orders=derivative_orders)
deriv_msg = composer.msg_batch_create_derivative_limit_orders(
sender=address.to_acc_bech32(), orders=derivative_orders
)

# compute order hashes
order_hashes = order_hash_manager.compute_order_hashes(
Expand All @@ -234,7 +245,7 @@ async def main() -> None:
gas_limit = base_gas + GAS_FEE_BUFFER_AMOUNT # add buffer for gas fee computation
gas_fee = "{:.18f}".format((gas_price * gas_limit) / pow(10, 18)).rstrip("0")
fee = [
composer.Coin(
composer.coin(
amount=gas_price * gas_limit,
denom=network.fee_denom,
)
Expand Down
76 changes: 0 additions & 76 deletions examples/chain_client/26_MsgWithdrawDelegatorReward.py

This file was deleted.

Loading

0 comments on commit 52033b4

Please sign in to comment.