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

fix: giving collateral should not change totalDebt #9873

Merged
merged 7 commits into from
Aug 20, 2024
Merged

Conversation

dckc
Copy link
Member

@dckc dckc commented Aug 9, 2024

closes: #XXXX
refs: #XXXX

Description

Updating totalDebt for 1 vault was doing totalDebt += vault.getCurrentDebt() - old where current debt includes compounded interest but old did not.

Security Considerations

This (in combination with another PR to reset totalDebt to the sum over all vaults) should address a confusion risk for metrics clients.

Scaling Considerations

The separate work to reset totalDebt to the sum over all vaults may have some, but I don't see any here.

Testing Considerations

A straightforward unit test is included.

Upgrade Considerations

This change takes effect with the next upgrade to the vaultFactory.

Documentation Considerations

As part of the governance decision to upgrade vaultFactory, metrics consumers should be notified of this fix.

Copy link

cloudflare-workers-and-pages bot commented Aug 9, 2024

Deploying agoric-sdk with  Cloudflare Pages  Cloudflare Pages

Latest commit: e29a42c
Status: ✅  Deploy successful!
Preview URL: https://2f042bef.agoric-sdk.pages.dev
Branch Preview URL: https://dc-totaldebt.agoric-sdk.pages.dev

View logs

@dckc dckc force-pushed the dc-totalDebt branch 3 times, most recently from a48000c to ad65961 Compare August 14, 2024 22:21
@dckc dckc marked this pull request as ready for review August 14, 2024 22:57
totalDebt += WANT_EXTRA + 29n; // magic number is fees
totalDebt += WANT_EXTRA + 20n; // magic number is fees
Copy link
Member Author

Choose a reason for hiding this comment

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

@Chris-Hibbert I'm particularly interested in reviewer feedback on the changes in this file.

I just sort of updated them arbitrarily to match the new observed values.

Copy link
Contributor

Choose a reason for hiding this comment

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

I pushed e9388a5 to repair the test.

@dckc
Copy link
Member Author

dckc commented Aug 16, 2024

pushing 5290d80 to the branch for this PR was a mistake; please ignore.
we're back to 99ed61d

@dckc dckc requested a review from turadg August 16, 2024 16:35
@dckc dckc added the automerge:rebase Automatically rebase updates, then merge label Aug 16, 2024

t.log('charge 2% per day to simulate lower rates over longer times');
const aethKey = { collateralBrand: aeth.brand };
const twoPctPerDay = run.makeRatio(2n * 360n, 100n);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const twoPctPerDay = run.makeRatio(2n * 360n, 100n);
const twoPctPerDay = run.makeRatio(2n * 365n, 100n);

totalDebt += WANT_EXTRA + 29n; // magic number is fees
totalDebt += WANT_EXTRA + 20n; // magic number is fees
Copy link
Contributor

Choose a reason for hiding this comment

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

I pushed e9388a5 to repair the test.

@turadg turadg self-requested a review August 16, 2024 17:32
Copy link
Contributor

@Chris-Hibbert Chris-Hibbert left a comment

Choose a reason for hiding this comment

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

LGTM

turadg
turadg previously requested changes Aug 16, 2024
Comment on lines 355 to 358
if (oldDen < newDen) {
return ratio;
}

Copy link
Member

Choose a reason for hiding this comment

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

this is a change in behavior and I think breaks the declared behavior,

Make an equivalant ratio with a new denominator

This function quantize quantizes. Deciding not to quantize is the responsibility of the caller.

@dckc dckc removed the automerge:rebase Automatically rebase updates, then merge label Aug 16, 2024
@Chris-Hibbert
Copy link
Contributor

Feel free to drop the ratio changes from e9388a. Also it's fine if you don't change 360 to 365.

@dckc dckc dismissed turadg’s stale review August 19, 2024 15:59

made requested change

@dckc dckc added the automerge:rebase Automatically rebase updates, then merge label Aug 19, 2024
@Chris-Hibbert Chris-Hibbert added the Vaults VaultFactor (née Treasury) label Aug 19, 2024
@dckc dckc force-pushed the dc-totalDebt branch 2 times, most recently from a118019 to ae42f73 Compare August 19, 2024 22:09
dckc and others added 6 commits August 19, 2024 23:01
 - use driver to check metrics notifications
When doing `totalDebt += newDebtFor1Vault - oldDebtFor1Vault`,
make sure to use the same sort of calculation for old and new.
The verifications for metrics updates were misplaced. Added interest
@mergify mergify bot merged commit a18dbbf into master Aug 20, 2024
80 checks passed
@mergify mergify bot deleted the dc-totalDebt branch August 20, 2024 03:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge:rebase Automatically rebase updates, then merge Vaults VaultFactor (née Treasury)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants