Skip to content

Commit

Permalink
Merge pull request #95 from blockydevs/max-fees-calculation-fixes (B2…
Browse files Browse the repository at this point in the history
…CA-1765)

Fix compute budget max fees calculation - convert microlamports to lamports
  • Loading branch information
tdejoigny-ledger authored Sep 18, 2024
2 parents c3306fa + 23d3aca commit 6c283b0
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ APPNAME = "Solana"
# Application version
APPVERSION_M = 1
APPVERSION_N = 5
APPVERSION_P = 2
APPVERSION_P = 3
APPVERSION = "$(APPVERSION_M).$(APPVERSION_N).$(APPVERSION_P)"

# Application source files
Expand Down
3 changes: 2 additions & 1 deletion libsol/compute_budget_instruction.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ static uint32_t calculate_max_fee(const ComputeBudgetFeeInfo* info) {
max_compute =
MIN(info->instructions_count * MAX_CU_PER_INSTRUCTION, MAX_CU_PER_TRANSACTION);
}
return max_fee + (info->change_unit_price->units * max_compute);
return max_fee +
((info->change_unit_price->units * max_compute) / MICRO_LAMPORT_MULTIPLIER);
}
return max_fee;
}
Expand Down
1 change: 1 addition & 0 deletions libsol/compute_budget_instruction.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#define MAX_CU_PER_INSTRUCTION 200000
#define MAX_CU_PER_TRANSACTION 1400000
#define FEE_LAMPORTS_PER_SIGNATURE 5000
#define MICRO_LAMPORT_MULTIPLIER 1000000

extern const Pubkey compute_budget_program_id;

Expand Down

0 comments on commit 6c283b0

Please sign in to comment.