Skip to content

Issue 43 - Need to account for already repaid amount in liquidations#85

Open
ethereumdegen wants to merge 20 commits intomerge-train-r5from
fix/issue-43
Open

Issue 43 - Need to account for already repaid amount in liquidations#85
ethereumdegen wants to merge 20 commits intomerge-train-r5from
fix/issue-43

Conversation

@ethereumdegen
Copy link
Collaborator

@ethereumdegen ethereumdegen commented Dec 18, 2024

Need to account for already repaid amount in liquidations

if a loan had already been partially repaid, the pool WILL have more tokens, but the estimated value of the pool will not increase because we arent (we cant) include tokens repaid amount in the tool est value. In this story, if the loan is normally repaid in full so there is no issue.

However, if a loan is repaid 95% but the remaining 5% is unpaid, then it goes into liquidation, this is more complex.

For example, if the loan auction is at a shortfall of $200 but the loan was previously partially repaid $1800 , the loan really isnt at a shortfall but it is up $1600 overall. SO that is how it should affect the accounting. Before, we would account that it was a total shortfall of $200.

@ethereumdegen ethereumdegen changed the base branch from main to merge-train-r5 December 18, 2024 19:02
@ethereumdegen
Copy link
Collaborator Author

ethereumdegen commented Dec 18, 2024

additional work must be done here + testing

it is important that this accounting is done correctly so that the poolTotalEstimatedValue remains valid even after a loan, which had been partially repaid, is liquidated

@ethereumdegen
Copy link
Collaborator Author

used TDD to help me improve and simplify this - built 6 unit tests with different scenarios/stories

rebuilt some of the logic related to liquidations. The amount taken from the liquidator is actually now the amount that remained unpaid -- not the total loan amount.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant