-
Notifications
You must be signed in to change notification settings - Fork 177
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
fix(across): address issue in liquidity utilization calculation #3499
fix(across): address issue in liquidity utilization calculation #3499
Conversation
Signed-off-by: Christopher Maree <christopher.maree@gmail.com>
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.
Looks great!
…ttps://github.com/UMAprotocol/protocol into chrismaree/fix-implementation-liquidityutilization
Co-authored-by: nicholaspai <9457025+nicholaspai@users.noreply.github.com>
Signed-off-by: Christopher Maree <christopher.maree@gmail.com>
…github.com:UMAprotocol/protocol into chrismaree/fix-implementation-liquidityutilization
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.
LGTM awesome work
_sync(); // Fetch any balance changes due to token bridging finalization and factor them in. | ||
|
||
// liquidityUtilizationRatio := | ||
// (relayedAmount + pendingReserves + max(utilizedReserves,0)) / (liquidReserves + max(utilizedReserves,0)) |
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.
One side effect of flooring utilizedReserves
when it is negative (due to having tokens transferred to the contract by mistake) is that the calculated utilization rate would drop just after the pending relay is settled since the settlement moves deposit amount from pendingReserves
to utilizedReserves
.
Maybe alternative to avoid this could be to floor the sum of (pendingReserves + utilizedReserves)? Though not sure if this still is ideal, but the source of the problem is not being able to distinguish token transfers by mistake from L2->L1 native bridging transfers.
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.
ye, this is a good idea! I think we'll leave as it is for now and can re-visit this in the coming week and make sure that we are all happy with how this is implemented right now.
Motivation
This PR addresses a small issue in the
liquidityUtilizationPostRelay
which did not correctly consider the denominator. The denominator now considersutilizedReserves
to correctly capture the funds in the pool.Testing
Check a box to describe how you tested these changes and list the steps for reviewers to test.