Obedient Lava Monkey
Medium
In BridgeLogic.sol
, the function calculates backingAmount
as the lesser of amount
or reserve.unbacked
, but it does not adjust the fee proportionately to match the backingAmount
, which will cause overpayment of fees for backers as the protocol charges fees on the full amount
instead of the actual backingAmount
.
In BridgeLogic.sol
, the line:
uint256 backingAmount = (amount < reserve.unbacked) ? amount : reserve.unbacked;
correctly limits backingAmount
to reserve.unbacked
. However, the fee
remains based on the original amount
:
uint256 added = backingAmount + fee;
This overcharges fees when amount > reserve.unbacked
.
- User calls
executeBackUnbacked
withamount
greater thanreserve.unbacked
. - The reserve has an
unbacked
amount less than the requestedamount
.
- The caller has approved sufficient tokens to cover
amount + fee
to theaToken
contract.
- A backer calls
executeBackUnbacked
with anamount
significantly larger thanreserve.unbacked
(e.g.,amount = 1000
,reserve.unbacked = 100
). - The function limits the
backingAmount
to100
, but thefee
is still calculated for the fullamount = 1000
. - The backer is forced to pay an excessive fee disproportionate to the actual
backingAmount
.
The backer suffers excessive fee payments, causing inefficiencies and potentially deterring liquidity provision. For example:
- If the
protocolFeeBps
is 100 (1%) andfee = 10
foramount = 1000
, the backer paysfee = 10
instead offee = 1
forbackingAmount = 100
.
Adjust the fee
proportionally to match the backingAmount
:
if (amount > reserve.unbacked) {
fee = fee.percentMul(reserve.unbacked).percentDiv(amount);
}