Skip to content

Commit

Permalink
Merge pull request #262 from InjectiveLabs/feat/update_gas_fee_buffer…
Browse files Browse the repository at this point in the history
…_amount

Feat/update gas fee buffer amount
  • Loading branch information
aarmoa committed Nov 3, 2023
2 parents 75b7807 + a9a25c6 commit fbbedf0
Show file tree
Hide file tree
Showing 47 changed files with 288 additions and 261 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ All notable changes to this project will be documented in this file.
- Migrated all proto objects dependency to support chain version 1.22
- Moved changelog from the README.md file to its own CHANGELOG.md file
- Remove `aiocron` dependency. Use plain asyncio tasks to solve the timeout height synchronization
- Updated the gas fee buffer used to calculate fee consumption in all examples

## [0.9.3]
* Updated TIA/USDT-30NOV2023 market id in denoms_mainnet.ini file
Expand Down
13 changes: 7 additions & 6 deletions examples/chain_client/0_LocalOrderHash.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import uuid

from pyinjective.async_client import AsyncClient
from pyinjective.constant import GAS_FEE_BUFFER_AMOUNT, GAS_PRICE
from pyinjective.core.network import Network
from pyinjective.orderhash import OrderHashManager
from pyinjective.transaction import Transaction
Expand Down Expand Up @@ -101,9 +102,9 @@ async def main() -> None:
.with_account_num(client.get_number())
.with_chain_id(network.chain_id)
)
gas_price = 500000000
gas_price = GAS_PRICE
base_gas = 85000
gas_limit = base_gas + 20000 # add 20k for gas, fee computation
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(
Expand Down Expand Up @@ -138,9 +139,9 @@ async def main() -> None:
.with_account_num(client.get_number())
.with_chain_id(network.chain_id)
)
gas_price = 500000000
gas_price = GAS_PRICE
base_gas = 85000
gas_limit = base_gas + 20000 # add 20k for gas, fee computation
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(
Expand Down Expand Up @@ -228,9 +229,9 @@ async def main() -> None:
.with_account_num(client.get_number())
.with_chain_id(network.chain_id)
)
gas_price = 500000000
gas_price = GAS_PRICE
base_gas = 85000
gas_limit = base_gas + 20000 # add 20k for gas, fee computation
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(
Expand Down
5 changes: 3 additions & 2 deletions examples/chain_client/13_MsgIncreasePositionMargin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import asyncio

from pyinjective.async_client import AsyncClient
from pyinjective.constant import GAS_FEE_BUFFER_AMOUNT, GAS_PRICE
from pyinjective.core.network import Network
from pyinjective.transaction import Transaction
from pyinjective.wallet import PrivateKey
Expand Down Expand Up @@ -53,8 +54,8 @@ async def main() -> None:
return

# build tx
gas_price = 500000000
gas_limit = sim_res.gas_info.gas_used + 20000 # add 20k for gas, fee computation
gas_price = GAS_PRICE
gas_limit = sim_res.gas_info.gas_used + 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(
Expand Down
19 changes: 3 additions & 16 deletions examples/chain_client/15_MsgWithdraw.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,7 @@
# Copyright 2022 Injective Labs
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import asyncio

from pyinjective.async_client import AsyncClient
from pyinjective.constant import GAS_FEE_BUFFER_AMOUNT, GAS_PRICE
from pyinjective.core.network import Network
from pyinjective.transaction import Transaction
from pyinjective.wallet import PrivateKey
Expand Down Expand Up @@ -58,8 +45,8 @@ async def main() -> None:
return

# build tx
gas_price = 500000000
gas_limit = sim_res.gas_info.gas_used + 20000 # add 20k for gas, fee computation
gas_price = GAS_PRICE
gas_limit = sim_res.gas_info.gas_used + 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(
Expand Down
5 changes: 3 additions & 2 deletions examples/chain_client/16_MsgSubaccountTransfer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import asyncio

from pyinjective.async_client import AsyncClient
from pyinjective.constant import GAS_FEE_BUFFER_AMOUNT, GAS_PRICE
from pyinjective.core.network import Network
from pyinjective.transaction import Transaction
from pyinjective.wallet import PrivateKey
Expand Down Expand Up @@ -51,8 +52,8 @@ async def main() -> None:
return

# build tx
gas_price = 500000000
gas_limit = sim_res.gas_info.gas_used + 20000 # add 20k for gas, fee computation
gas_price = GAS_PRICE
gas_limit = sim_res.gas_info.gas_used + 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(
Expand Down
5 changes: 3 additions & 2 deletions examples/chain_client/17_MsgBatchUpdateOrders.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import uuid

from pyinjective.async_client import AsyncClient
from pyinjective.constant import GAS_FEE_BUFFER_AMOUNT, GAS_PRICE
from pyinjective.core.network import Network
from pyinjective.transaction import Transaction
from pyinjective.wallet import PrivateKey
Expand Down Expand Up @@ -140,8 +141,8 @@ async def main() -> None:
print(sim_res_msg)

# build tx
gas_price = 500000000
gas_limit = sim_res.gas_info.gas_used + 20000 # add 20k for gas, fee computation
gas_price = GAS_PRICE
gas_limit = sim_res.gas_info.gas_used + 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(
Expand Down
5 changes: 3 additions & 2 deletions examples/chain_client/18_MsgBid.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import asyncio

from pyinjective.async_client import AsyncClient
from pyinjective.constant import GAS_FEE_BUFFER_AMOUNT, GAS_PRICE
from pyinjective.core.network import Network
from pyinjective.transaction import Transaction
from pyinjective.wallet import PrivateKey
Expand Down Expand Up @@ -43,8 +44,8 @@ async def main() -> None:
return

# build tx
gas_price = 500000000
gas_limit = sim_res.gas_info.gas_used + 20000 # add 20k for gas, fee computation
gas_price = GAS_PRICE
gas_limit = sim_res.gas_info.gas_used + 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(
Expand Down
5 changes: 3 additions & 2 deletions examples/chain_client/19_MsgGrant.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import asyncio

from pyinjective.async_client import AsyncClient
from pyinjective.constant import GAS_FEE_BUFFER_AMOUNT, GAS_PRICE
from pyinjective.core.network import Network
from pyinjective.transaction import Transaction
from pyinjective.wallet import PrivateKey
Expand Down Expand Up @@ -62,8 +63,8 @@ async def main() -> None:
return

# build tx
gas_price = 500000000
gas_limit = sim_res.gas_info.gas_used + 20000 # add 20k for gas, fee computation
gas_price = GAS_PRICE
gas_limit = sim_res.gas_info.gas_used + 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(
Expand Down
5 changes: 3 additions & 2 deletions examples/chain_client/1_MsgSend.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import asyncio

from pyinjective.async_client import AsyncClient
from pyinjective.constant import GAS_FEE_BUFFER_AMOUNT, GAS_PRICE
from pyinjective.core.network import Network
from pyinjective.transaction import Transaction
from pyinjective.wallet import PrivateKey
Expand Down Expand Up @@ -48,8 +49,8 @@ async def main() -> None:
return

# build tx
gas_price = 500000000
gas_limit = sim_res.gas_info.gas_used + 20000 # add 20k for gas, fee computation
gas_price = GAS_PRICE
gas_limit = sim_res.gas_info.gas_used + 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(
Expand Down
5 changes: 3 additions & 2 deletions examples/chain_client/20_MsgExec.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import uuid

from pyinjective.async_client import AsyncClient
from pyinjective.constant import GAS_FEE_BUFFER_AMOUNT, GAS_PRICE
from pyinjective.core.network import Network
from pyinjective.transaction import Transaction
from pyinjective.wallet import Address, PrivateKey
Expand Down Expand Up @@ -67,8 +68,8 @@ async def main() -> None:
print(unpacked_msg_res)

# build tx
gas_price = 500000000
gas_limit = sim_res.gas_info.gas_used + 20000 # add 20k for gas, fee computation
gas_price = GAS_PRICE
gas_limit = sim_res.gas_info.gas_used + 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(
Expand Down
5 changes: 3 additions & 2 deletions examples/chain_client/21_MsgRevoke.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import asyncio

from pyinjective.async_client import AsyncClient
from pyinjective.constant import GAS_FEE_BUFFER_AMOUNT, GAS_PRICE
from pyinjective.core.network import Network
from pyinjective.transaction import Transaction
from pyinjective.wallet import PrivateKey
Expand Down Expand Up @@ -47,8 +48,8 @@ async def main() -> None:
return

# build tx
gas_price = 500000000
gas_limit = sim_res.gas_info.gas_used + 20000 # add 20k for gas, fee computation
gas_price = GAS_PRICE
gas_limit = sim_res.gas_info.gas_used + 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(
Expand Down
5 changes: 3 additions & 2 deletions examples/chain_client/22_MsgSendToEth.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import requests

from pyinjective.async_client import AsyncClient
from pyinjective.constant import GAS_FEE_BUFFER_AMOUNT, GAS_PRICE
from pyinjective.core.network import Network
from pyinjective.transaction import Transaction
from pyinjective.wallet import PrivateKey
Expand Down Expand Up @@ -58,8 +59,8 @@ async def main() -> None:
return

# build tx
gas_price = 500000000
gas_limit = sim_res.gas_info.gas_used + 20000 # add 20k for gas, fee computation
gas_price = GAS_PRICE
gas_limit = sim_res.gas_info.gas_used + 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(
Expand Down
5 changes: 3 additions & 2 deletions examples/chain_client/23_MsgRelayPriceFeedPrice.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import asyncio

from pyinjective.async_client import AsyncClient
from pyinjective.constant import GAS_FEE_BUFFER_AMOUNT, GAS_PRICE
from pyinjective.core.network import Network
from pyinjective.transaction import Transaction
from pyinjective.wallet import PrivateKey
Expand Down Expand Up @@ -48,8 +49,8 @@ async def main() -> None:
return

# build tx
gas_price = 500000000
gas_limit = sim_res.gas_info.gas_used + 20000 # add 20k for gas, fee computation
gas_price = GAS_PRICE
gas_limit = sim_res.gas_info.gas_used + 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(
Expand Down
5 changes: 3 additions & 2 deletions examples/chain_client/24_MsgRewardsOptOut.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import asyncio

from pyinjective.async_client import AsyncClient
from pyinjective.constant import GAS_FEE_BUFFER_AMOUNT, GAS_PRICE
from pyinjective.core.network import Network
from pyinjective.transaction import Transaction
from pyinjective.wallet import PrivateKey
Expand Down Expand Up @@ -43,8 +44,8 @@ async def main() -> None:
return

# build tx
gas_price = 500000000
gas_limit = sim_res.gas_info.gas_used + 20000 # add 20k for gas, fee computation
gas_price = GAS_PRICE
gas_limit = sim_res.gas_info.gas_used + 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(
Expand Down
5 changes: 3 additions & 2 deletions examples/chain_client/25_MsgDelegate.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import asyncio

from pyinjective.async_client import AsyncClient
from pyinjective.constant import GAS_FEE_BUFFER_AMOUNT, GAS_PRICE
from pyinjective.core.network import Network
from pyinjective.transaction import Transaction
from pyinjective.wallet import PrivateKey
Expand Down Expand Up @@ -48,8 +49,8 @@ async def main() -> None:
return

# build tx
gas_price = 500000000
gas_limit = sim_res.gas_info.gas_used + 20000 # add 20k for gas, fee computation
gas_price = GAS_PRICE
gas_limit = sim_res.gas_info.gas_used + 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(
Expand Down
5 changes: 3 additions & 2 deletions examples/chain_client/26_MsgWithdrawDelegatorReward.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import asyncio

from pyinjective.async_client import AsyncClient
from pyinjective.constant import GAS_FEE_BUFFER_AMOUNT, GAS_PRICE
from pyinjective.core.network import Network
from pyinjective.transaction import Transaction
from pyinjective.wallet import PrivateKey
Expand Down Expand Up @@ -47,8 +48,8 @@ async def main() -> None:
return

# build tx
gas_price = 500000000
gas_limit = sim_res.gas_info.gas_used + 20000 # add 20k for gas, fee computation
gas_price = GAS_PRICE
gas_limit = sim_res.gas_info.gas_used + 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(
Expand Down
5 changes: 3 additions & 2 deletions examples/chain_client/2_MsgDeposit.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import asyncio

from pyinjective.async_client import AsyncClient
from pyinjective.constant import GAS_FEE_BUFFER_AMOUNT, GAS_PRICE
from pyinjective.core.network import Network
from pyinjective.transaction import Transaction
from pyinjective.wallet import PrivateKey
Expand Down Expand Up @@ -44,8 +45,8 @@ async def main() -> None:
return

# build tx
gas_price = 500000000
gas_limit = sim_res.gas_info.gas_used + 20000 # add 20k for gas, fee computation
gas_price = GAS_PRICE
gas_limit = sim_res.gas_info.gas_used + 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(
Expand Down
5 changes: 3 additions & 2 deletions examples/chain_client/30_ExternalTransfer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import asyncio

from pyinjective.async_client import AsyncClient
from pyinjective.constant import GAS_FEE_BUFFER_AMOUNT, GAS_PRICE
from pyinjective.core.network import Network
from pyinjective.transaction import Transaction
from pyinjective.wallet import PrivateKey
Expand Down Expand Up @@ -51,8 +52,8 @@ async def main() -> None:
return

# build tx
gas_price = 500000000
gas_limit = sim_res.gas_info.gas_used + 20000 # add 20k for gas, fee computation
gas_price = GAS_PRICE
gas_limit = sim_res.gas_info.gas_used + 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(
Expand Down
7 changes: 4 additions & 3 deletions examples/chain_client/31_MsgCreateBinaryOptionsLimitOrder.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
import uuid

from pyinjective.async_client import AsyncClient
from pyinjective.constant import Denom
from pyinjective.constant import GAS_FEE_BUFFER_AMOUNT, GAS_PRICE
from pyinjective.core.network import Network
from pyinjective.transaction import Transaction
from pyinjective.utils.denom import Denom
from pyinjective.wallet import PrivateKey


Expand Down Expand Up @@ -68,8 +69,8 @@ async def main() -> None:
print(sim_res_msg)

# build tx
gas_price = 500000000
gas_limit = sim_res.gas_info.gas_used + 20000 # add 20k for gas, fee computation
gas_price = GAS_PRICE
gas_limit = sim_res.gas_info.gas_used + 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(
Expand Down
Loading

0 comments on commit fbbedf0

Please sign in to comment.