From b61ed7c02adb5c5233e23275df634f8cd84936df Mon Sep 17 00:00:00 2001 From: gabrielkerekes Date: Fri, 22 Mar 2024 10:57:09 +0100 Subject: [PATCH] fix(solana): round up transaction fee If `unit_price * unit_limit / 1000000` didn't result in an integer `int()` would round the number down. However on the blockchain the resulting fee was be rounded up. --- core/src/apps/solana/sign_tx.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/src/apps/solana/sign_tx.py b/core/src/apps/solana/sign_tx.py index 71981b319..828f4b956 100644 --- a/core/src/apps/solana/sign_tx.py +++ b/core/src/apps/solana/sign_tx.py @@ -113,6 +113,8 @@ async def confirm_instructions( def calculate_fee(transaction: Transaction) -> int: + import math + from .constants import SOLANA_BASE_FEE_LAMPORTS, SOLANA_COMPUTE_UNIT_LIMIT from .transaction.instructions import ( COMPUTE_BUDGET_PROGRAM_ID, @@ -150,4 +152,4 @@ def calculate_fee(transaction: Transaction) -> int: unit_price = instruction.lamports is_unit_price_set = True - return int(base_fee + unit_price * unit_limit / 1000000) + return int(base_fee + math.ceil(unit_price * unit_limit / 1000000))