Skip to content

Commit

Permalink
Merge pull request #24 from blockydevs/max-fees-calculation-fixes
Browse files Browse the repository at this point in the history
Fix compute budget max fees calculation - convert microlamports to lamports
  • Loading branch information
0xMMBD authored Sep 17, 2024
2 parents c3306fa + be50479 commit 2aa3da3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
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 2aa3da3

Please sign in to comment.