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

Collateralization Limits Final #177

Merged
merged 25 commits into from
Dec 18, 2023
Merged

Collateralization Limits Final #177

merged 25 commits into from
Dec 18, 2023

Conversation

0xripleys
Copy link

@0xripleys 0xripleys commented Dec 17, 2023

Solend V2 introduces collateralization limits, which are global limits on how much can be borrowed against an asset. For example, a collateralization limit of $20M for SOL means only $20M of borrows can be secured by SOL collateral.

If the collateralization limit for an asset is hit, increasing borrows against that asset (via borrows or withdraws) is not allowed. Additionally, any obligation that violates this limit can be marked as closeable by the lending market owner or risk authority. A closeable obligation can be liquidated without penalty.

Comments:

  • borrow attribution values are not updated in the deposit instruction, which is technically incorrect. this can cause staleness issues if multiple txns are in the same slot. eg [A refresh, B deposit, A borrow]. the deposit might cause the borrow to be invalid wrt attribution limits, but the program will still allow it. the solution is to update the borrow attribution limits in deposit, but im not sure if we wanna do that.

Compute unit usage of refresh obligation before and after changes.

#Deposits before after delta
9 161474 195305 33831
8 145275 175341 30066
7 129076 155393 26317
6 112881 135435 22554
5 96682 115480 18798
4 80487 95529 15042
3 64288 75577 11289
2 48093 55623 7530
1 31894 35181 3287

@0xripleys 0xripleys changed the title Collateralization Limits Collateralization Limits Final Dec 17, 2023
@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

❗ No coverage uploaded for pull request base (v2.0.3_upcoming@2888452). Click here to learn what that means.

Additional details and impacted files
@@                Coverage Diff                 @@
##             v2.0.3_upcoming     #177   +/-   ##
==================================================
  Coverage                   ?   85.28%           
==================================================
  Files                      ?       53           
  Lines                      ?    21381           
  Branches                   ?        0           
==================================================
  Hits                       ?    18235           
  Misses                     ?     3146           
  Partials                   ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@nope-finance nope-finance left a comment

Choose a reason for hiding this comment

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

approved pending clock account removal

@0xripleys 0xripleys merged commit 131e246 into v2.0.3_upcoming Dec 18, 2023
6 checks passed
nope-finance pushed a commit that referenced this pull request Jan 22, 2024
* oracle price multiplier (#174)

* oracle price multiplier

* changing added price weight to be i64

* rename added price weight

* Allow risk authority to change rate limiter config in the lending market (#167)

* account for risk authority in set lending market owner and config

* PR fixes

* only let risk authority disable outflows

* Optional, extra oracle on reserve (#176)

* minor refactoring of price fields in reserve

* adding extra oracle pubkey and extra market price to reserve

* using extra market price everywhere

* https://www.youtube.com/watch?v=uLHqpjW3aDs

* validate extra_oracle_pubkey in init reserve / update reserve

* writing tests

* more tests

* more refresh reserve checks

* adding some unit tests for extra_oracle stuff

* test init reserve

* clippy

* pr fixes

* don't care about staleness or variance for the extra oracle

* Collateralization Limits Final (#177)

* forgot to update smoothed price with price scale in switchboard case

* remove redundant multiply

* remove clock (#179)
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