The OfferLibraries
contract contains utility functions for managing offers in a decentralized market system. Two key functions in this library are getDepositAmount
and getRefundAmount
, which are responsible for calculating deposit and refund amounts for different types of offers (bid and ask).
The getDepositAmount
function correctly applies the collateral rate to ask offers when creating an offer, and to bid offers when creating an order. This behavior is crucial for maintaining the economic balance of the system.
In the getRefundAmount
function, there is an inconsistency in how the collateral rate is applied compared to the getDepositAmount
function. Specifically:
For bid offers, the function does not apply the collateral rate at all.
For ask offers, the function always applies the collateral rate.
This behavior is inconsistent with getDepositAmount
and does not correctly mirror the deposit calculation when refunding.
This inconsistency could lead to incorrect refund calculations, potentially causing:
Financial losses for users or the protocol
Imbalance in the economic model of the market
Potential exploitation through arbitrage opportunities
Modify the getRefundAmount
function to apply the collateral rate consistently with getDepositAmount
:
This modification ensures that:
For bid offers, the refund is calculated without applying the collateral rate.
For ask offers, the refund is calculated with the collateral rate applied.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.