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

Loans: Integration with OracleV2 #1658

Merged
merged 9 commits into from
Dec 29, 2023
Merged

Loans: Integration with OracleV2 #1658

merged 9 commits into from
Dec 29, 2023

Conversation

lemunozm
Copy link
Contributor

@lemunozm lemunozm commented Dec 22, 2023

Description

This PR makes loans to use OracleV2.

Changes and Descriptions

  • Remove the old oracle system from runtimes and configure pallet-loans with the new one.
  • Loans refactor to remove usage of DataFeeder and DataProvider from orml traits and simplify loan benchmarks
  • Remove unused pallet-loans utilities
  • Add ValueProvider implementation under runtime-benchmarks for pallet-oracle-data-collection in order to set benchmarking states using the feeder. (required for loans or users of DataRegistry traits)
  • Migration (we do not have storage in Centrifuge/Altair) 🥳
  • integration-tests
    • Adapt previous oracle test
    • New oracle tests when the oracle values comes from the collection for updating the portfolio
  •  Remove pallet-data-collector code from database

@lemunozm lemunozm added Q5-hard Can be done by an experienced coder with a good knowledge of the codebase. P7-asap Issue should be addressed in the next days. I8-enhancement An additional feature. crcl-protocol Circle protocol related. labels Dec 22, 2023
@lemunozm lemunozm self-assigned this Dec 22, 2023
Copy link
Collaborator

@mustermeiszer mustermeiszer left a comment

Choose a reason for hiding this comment

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

What a PR. Almost 1000 LoC removed!

I would still change the runtime configs/or add additional docs, otherwise good.

libs/mocks/src/data.rs Show resolved Hide resolved
parameter_types! {
pub const MaxActiveLoansPerPool: u32 = 300;
pub const MaxRateCount: u32 = MaxActiveLoansPerPool::get();
pub const MaxCollectionSize: u32 = MaxActiveLoansPerPool::get();
pub const MaxRateCount: u32 = 300; // See #1024
Copy link
Collaborator

Choose a reason for hiding this comment

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

@lemunozm briefly looked at the issue, but why does this now not need to be bound by the maximum number of active loans per pool? Shouldn't that still be the upper limit?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ahh, I see. I would still set it to MaxActiveLioansperpool to not misconfigure it accidently, wdyt?

Copy link
Contributor Author

@lemunozm lemunozm Dec 29, 2023

Choose a reason for hiding this comment

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

I would forget to comment on that!

As far as I know, MaxRateCount should be greater than MaxActiveLoansPerPool. If not, if one pool reaches MaxActiveLoansPerPool, there are no more rates available for other pools. That's why I maintain the value (by now) but disassociate it from MaxActiveLoansPerPool.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've comment this into issue #1024 to track this change

Copy link
Collaborator

Choose a reason for hiding this comment

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

IIRC we restrict the rate to be between 100.00 and 0, so we have a max amount of rates equal to 10001.

What would be the weight of that? Shouldn't we just allow that maximum?

Copy link
Contributor Author

@lemunozm lemunozm Dec 29, 2023

Choose a reason for hiding this comment

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

Ohh, I didn't think about that inherent limitation from the rate limitation.

Then, yes, we can use that value if we're sure that computing a pow over 10000 elements does not exceed the block limit. We would need to perform a benchmark first.

I would go with this for another PR, where we first make a benchmark for the worst case. Do you agree? Actually, it can be an update for the #1024 issue.

Copy link
Contributor Author

@lemunozm lemunozm Dec 29, 2023

Choose a reason for hiding this comment

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

Idea:

We can even create an utility method for it, which can be called from the runtime as follows:

type MaxCountRate = InterestAccrual::get_max_rate_count(0.25, MAXIMUM_BLOCK_WEIGHT)

returning the exact value to not overpass the 25% of the block limit.

Copy link
Collaborator

Choose a reason for hiding this comment

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

That would be great!! Agreed with all above!

runtime/altair/src/lib.rs Show resolved Hide resolved
runtime/centrifuge/src/lib.rs Show resolved Hide resolved
runtime/development/src/lib.rs Show resolved Hide resolved
@lemunozm lemunozm merged commit f8a7bbf into main Dec 29, 2023
9 checks passed
@lemunozm lemunozm deleted the loans/oracle-v2 branch December 29, 2023 22:31
@lemunozm
Copy link
Contributor Author

Thanks for your review @mustermeiszer in your free time!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crcl-protocol Circle protocol related. I8-enhancement An additional feature. P7-asap Issue should be addressed in the next days. Q5-hard Can be done by an experienced coder with a good knowledge of the codebase.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants