-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Split maxSettlementFee
into maxSyncFee
and maxAsyncFee
#508
Changes from 5 commits
48d1b95
f1a7de2
d54b4a0
d34b4e1
27fea51
4a33bef
9b12444
3de1997
aac4ffe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,15 +69,17 @@ library PriceResponseLib { | |
return self.syncFee.add(self.asyncFee.mul(UFixed6Lib.from(callbacks))); | ||
} | ||
|
||
/// @notice Scales down sync and async fees if they exceed the maximum settlement fee | ||
/// @notice Scales down sync and async fees if they exceed the maximums | ||
/// @param self The price response object | ||
/// @param maxSettlementFee The maximum settlement fee | ||
function applyFeeMaximum(PriceResponse memory self, UFixed6 maxSettlementFee, uint256 callbacks) internal pure { | ||
UFixed6 totalSettlementFee = settlementFee(self, callbacks); | ||
if (totalSettlementFee.gt(maxSettlementFee)) { | ||
self.syncFee = self.syncFee.muldiv(maxSettlementFee, totalSettlementFee); | ||
self.asyncFee = self.asyncFee.muldiv(maxSettlementFee, totalSettlementFee); | ||
} | ||
/// @param maxSyncFee The max sync fee | ||
/// @param maxAsyncFee The max async fee | ||
/// @param callbacks The number of settlement callbacks to be made | ||
function applyFeeMaximum(PriceResponse memory self, UFixed6 maxSyncFee, UFixed6 maxAsyncFee, uint256 callbacks) internal pure { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. instead of
it's a bit cleaner to write these caps as:
|
||
if (self.syncFee.gt(maxSyncFee)) | ||
self.syncFee = maxSyncFee; | ||
UFixed6 asyncFee = self.asyncFee.mul(UFixed6Lib.from(callbacks)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The async fee maximum will cap the individual async fees charges (so that if we have tons of orders in a single version we're not capping the total amount charged). So no need to multiply this by the callback amount, that won't be needed anymore. |
||
if (asyncFee.gt(maxAsyncFee)) | ||
self.asyncFee = maxAsyncFee.div(UFixed6Lib.from(callbacks)); | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually now that
applyFeeMaximum
is so simple, maybe we can just apply the.min(oracleParameter....)
directly on these above and delete the helper function altogether.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed helper method in aac4ffe