Skip to content
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 out-of-collateral algorithm #835

Merged
merged 3 commits into from
Dec 19, 2023
Merged

Conversation

ChrisSchinnerl
Copy link
Member

Arequipa kept refreshing a specific contract in a loop because the autopilot considered the contract out-of-collateral but just before refreshing the contract we didn't. So we didn't enforce a minimum on the collateral expected to be in the contract after the refresh.

To fix this I changed the isOutOfCollateral check to be more in line with isOutOfFunds one. Instead of looking at a theoretical amount of funding the contract might have after a refresh, we use the remaining funds in a contract to determine how much storage it is still good for and then expect the amount of remaining collateral to cover 5% of that storage.

Only when we refresh the contract, we use the new renterFunds to determine the minNewCollateral since increasing the renterFunds might push a contract over the threshold

@ChrisSchinnerl ChrisSchinnerl self-assigned this Dec 18, 2023
@ChrisSchinnerl ChrisSchinnerl marked this pull request as ready for review December 18, 2023 13:45
Copy link
Member

@peterjan peterjan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but left some comments

@ChrisSchinnerl ChrisSchinnerl merged commit 6983365 into dev Dec 19, 2023
6 checks passed
@ChrisSchinnerl ChrisSchinnerl deleted the chris/update-collateral-check branch December 19, 2023 10:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants