-
Notifications
You must be signed in to change notification settings - Fork 85
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
feat: fix linear pricing migration #1838
Conversation
7214b97
to
bf4ae7d
Compare
>; | ||
|
||
#[storage_alias] | ||
pub type CreatedLoan<T: Config> = StorageDoubleMap< |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious, are we sure we do not need to migrate ClosedLoan
? Will the expected decoded vector with that empty value match the current structure?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After a second thought, I'm pretty sure we need migrate the ClosedLoan
storage. We need to "reencoding" the on-chain values to be able to decode them fine later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I wanted to say: We only need to migrate if this storage is not empty. Right now, it is empty and it seems reasonable we can keep this state until upgrading Mainnet.
However, then I checked Demo and it has one entry. So yes, I will write a migration!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ok, I didn't know it was empty in centrifuge
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ClosedLoan
migration added here: 833b9d1
…ear-pricing-migration
@lemunozm There still seems to be an issue. We have surpassed the underflow error and now experience a
|
That loan has something peculiar, either or the current oracle price is 0, or it has been borrowed/repaid with 0 (I assume the last). Independently of the current issue. After adding this feature to that loan, the portfolio will have a significant change in its value. Are we ok? @mustermeiszer |
@wischli great catch! It should be fixed now after you rebase the branch again. I've added more testing to hope checking everything... 😅 |
…ear-pricing-migration
This reverts commit bf4ae7d.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your super migration on this!! Suuuper clean!
Description
with_linear_pricing
handle ofExternalPrice
structwith_linear_pricing
true for all active (8 on mainnet) and created (1 on mainnet) loansPlease ignore temporary adjustments to tomls and the added logs, they are purely for debugging and will be removed!
TODO
y_coord_in_rect
inmaybe_with_linear_accrual_price
, we seem to have infeasible values:oracle_provided_at == price_last_updated == x1 = 1715869380
price == y1 = 0
maturity == x2 = 1715212800
self.info.notional == y2 = 100000000
T::Time::now() == x = 1715949888
Since
x1 > x2
,y_coord_in_rect
performsx1.ensure_sub(x)?
which throws becausenow
is larger than the oracle timestampx1
. Logically, I don't think this could ever be right because the oracle timestamp should always be in the past?! So I imagine the order of the arguments of they_coord_in_rect
call is wrong here.Logs
Fixes #(issue)
Changes and Descriptions
[List your changes here]
Checklist: