Skip to content

Commit

Permalink
Round up depositor fee calculation (#398)
Browse files Browse the repository at this point in the history
Due to the incorrect rounding, unless the bridged amount is a multiple
of the depositorFeeDivisor, a loss of 1 wei of fees will occur on every
bridging attempt. Additionally, depositorFeeDivisor - 1 tokens can be
bridged without any fees.

To avoid that we round up the calculation.
  • Loading branch information
dimpar authored May 7, 2024
2 parents 736f04b + c2308c2 commit 216ef05
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion solidity/contracts/BitcoinDepositor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ contract BitcoinDepositor is AbstractTBTCDepositor, Ownable2StepUpgradeable {
// Compute depositor fee. The fee is calculated based on the initial funding
// transaction amount, before the tBTC protocol network fees were taken.
uint256 depositorFee = depositorFeeDivisor > 0
? (initialAmount / depositorFeeDivisor)
? Math.ceilDiv(initialAmount, depositorFeeDivisor)
: 0;

// Ensure the depositor fee does not exceed the approximate minted tBTC
Expand Down

0 comments on commit 216ef05

Please sign in to comment.