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

Correct issues handling interest rate update events #57

Merged
merged 4 commits into from
Aug 19, 2023
Merged

Conversation

EdNoepel
Copy link
Contributor

@EdNoepel EdNoepel commented Aug 18, 2023

Moved logic for updating depositFeeRate into updatePool, eliminating the need for redundant getRateInfo calls. Centralized logic for handling rate resets and updates to a single method in base-pool.ts. Removed old fee rates from schema, since we cannot reliably provide them.

@EdNoepel EdNoepel marked this pull request as draft August 18, 2023 15:11
@EdNoepel
Copy link
Contributor Author

Not convinced this is right yet. Experimentally, most of the fee rates have the same value for old and new. Investigating.

@EdNoepel
Copy link
Contributor Author

Seems the problem is that the UpdateInterestRate event is coming after the TX has already mutated the state of the pool. For example, when a borrower draws debt, the DrawDebt event is emitted first, so handleDrawDebt calls updatePool, updating rates and fees. When the UpdateInterestRate is handled, the pool already has updated rates and fees, so the "old" values are reflecting the new state.

@EdNoepel
Copy link
Contributor Author

Solution was to remove old fee rates from the event, as providing them would introduce more complexity than they were worth. Note that we can still provide the old lendRate, even though updatePool is likely to be called in the same TX before the interest rate update. This is because updatePool will recalculate lendRate using the old borrower rate, producing the same old number. Later on in the TX, borrow rate is updated and updatePool sets the new lendRate as appropriate.

@EdNoepel EdNoepel marked this pull request as ready for review August 18, 2023 16:49
Copy link
Contributor

@MikeHathaway MikeHathaway left a comment

Choose a reason for hiding this comment

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

LGTM

@EdNoepel EdNoepel merged commit 55240d5 into develop Aug 19, 2023
Copy link

@tsifrer tsifrer left a comment

Choose a reason for hiding this comment

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

Looks good 👍 thank you

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.

3 participants