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

Inter Protocol vaults should allow adjustments that don't increase debt when mint limit <= debt outstanding #9837

Closed
rowgraus opened this issue Aug 5, 2024 · 1 comment · Fixed by #9907
Assignees
Labels
bug Something isn't working

Comments

@rowgraus
Copy link

rowgraus commented Aug 5, 2024

Describe the bug

Inter Protocol vaults have per-collateral global mint limits that prevent new IST from being minted beyond that threshold.

These mint limits can be adjusted by the Economic Committee, independent of the amount of IST that has been minted against that collateral already

In scenarios where the mint limit is adjusted to be below the debt outstanding (even to zero), users should be able to make adjustments to their vaults which do not increase debt outstanding. For example, they should be able to repay debt, add collateral, and/or withdraw collateral (subject to collateralization ratio constraints for the last).

This is not occurring. The EC recently reduced mint limits for stOSMO vaults below the IST debt outstanding, and now users with stOSMO vaults are prevented from adjusting them at all. Users attempting to avoid liquidation are stuck.

To Reproduce

Steps to reproduce the behavior:

  1. Create a vault for a specific collateral type
  2. Use EC powers to vote to reduce the mint limit below the currently minted IST debt for that specific collateral type
  3. Attempt to adjust your vault (repay IST, add collateral, or any other type of adjustment)
  4. See error

Note that in production, you will not have control of #2 and therefore will need to have an existing stOSMO vault open.

Expected behavior

When mint limit is <= current debt outstanding, Vault Manager should prevent new minting of IST but should allow all other vault adjustments

User should be able to:

  • Repay debt
  • Add collateral
  • Withdraw collateral (subject to collateralization ratio constraints)

Platform Environment

Mainnet

Additional context

Error found by user:
Offer failed: Error: Minting {"brand":"[Alleged: IST brand]","value":"[0n]"} past {"brand":"[Alleged: IST brand]","value":"[490607974495n]"} would hit total debt limit {"brand":"[Alleged: IST brand]","value":"[490000000000n]"}

@rowgraus rowgraus added the bug Something isn't working label Aug 5, 2024
@dckc
Copy link
Member

dckc commented Aug 5, 2024

another way to confirm: I just made a (failing) test:

test('repay works regardless of mintLimit', async t => {

https://github.com/Agoric/agoric-sdk/blob/dc-test-repay/packages/inter-protocol/test/vaultFactory/test-vault-collateralization.js#L38
c560ca7

ag-mainnet1B/packages/inter-protocol$ yarn test test/vaultFactory/test-vault-collateralization.js -m 'repay*'
yarn run v1.22.19
$ ava test/vaultFactory/test-vault-collateralization.js -m 'repay*'
...
Temporary logging of sent error (Error#1)
Error#1: Minting { brand: Object [Alleged: IST brand] {}, value: 0n } past { brand: Object [Alleged: IST brand] {}, value: 4726n } would hit total debt limit { brand: Object [Alleged: IST brand] {}, value: 1000n }
  at checkDebtLimit (.../inter-protocol/src/contractSupport.js:73:6)
  at Object.mintAndTransfer (.../inter-protocol/src/vaultFactory/vaultManager.js:802:1)
  at Object.commitBalanceAdjustment (.../inter-protocol/src/vaultFactory/vault.js:554:15)
  at Object.adjustBalancesHook (.../inter-protocol/src/vaultFactory/vault.js:511:15)
  at eval (.../inter-protocol/src/vaultFactory/vault.js:722:16)
  at eval (.../pass-style/src/make-far.js:161:31)

Error#1 ERROR_NOTE: Sent as error:captp:far-zoeTest#20001
CapTP near-zoeTest exception: (RemoteError(error:captp:far-zoeTest#20001)#2)
RemoteError(error:captp:far-zoeTest#20001)#2: Minting {"brand":"[Alleged: IST brand]","value":"[0n]"} past {"brand":"[Alleged: IST brand]","value":"[4726n]"} would hit total debt limit {"brand":"[Alleged: IST brand]","value":"[1000n]"}
Error: Minting {"brand":"[Alleged: IST brand]","value":"[0n]"} past {"brand":"[Alleged: IST brand]","value":"[4726n]"} would hit total debt limit {"brand":"[Alleged: IST brand]","value":"[1000n]"}

Error#1 ERROR_NOTE: Sent as error:anon-marshal#10001
Temporary logging of sent error (Error#1)
Error#1 ERROR_NOTE: Sent as error:anon-marshal#10002
Temporary logging of sent error (Error#1)
REJECTED from ava test("repay works regardless of mintLimit"): (RemoteError(error:captp:far-zoeTest#20001)#2)
  ✘ [fail]: repay works regardless of mintLimit Rejected promise returned by test
    ℹ @@ schedule task for:3600, currently: 0 @@
    ℹ @@ schedule task for:1800, currently: 0 @@
    ℹ @@ schedule task for:1800, currently: 0 @@
    ℹ @@ schedule task for:1800, currently: 0 @@
    ℹ @@ schedule task for:2, currently: 0 @@
    ℹ ----- VFDriver.8  2 giveCollateral 100n
    ℹ ----- VFDriver.8  3 giveCollateral 20n
    ℹ ----- VFDriver.8  4 setGovernedParam DebtLimit
    ℹ ----- VFDriver.8  5 giveCollateral 20n


  repay works regardless of mintLimit
  Rejected promise returned by test. Reason:

  Error {
    message: 'Minting {"brand":"[Alleged: IST brand]","value":"[0n]"} past {"brand":"[Alleged: IST brand]","value":"[4726n]"} would hit total debt limit {"brand":"[Alleged: IST brand]","value":"[1000n]"}',
  }



  1 test failed

this seems to be the same stack trace as observed...

2024-08-05T12:56:52.845Z SwingSet: ls: v48: Error: Minting {"brand":"[Alleged: IST brand]","value":"[0n]"} past {"brand":"[Alleged: IST brand]","value":"[490607974495n]"} would hit total debt limit {"brand":"[Alleged: IST brand]","value":"[490000000000n]"}
 at construct ()
 at Error (/bundled-source/.../node_modules/ses/src/error/tame-error-constructor.js:56)
 at makeError (/bundled-source/.../node_modules/ses/src/error/assert.js:243)
 at fail (/bundled-source/.../node_modules/ses/src/error/assert.js:357)
 at checkDebtLimit (.../inter-protocol/src/contractSupport.js:75)
 at mintAndTransfer (.../inter-protocol/src/vaultFactory/vaultManager.js:805)
 at apply ()
 at apply ()
 at In "mintAndTransfer" method of (VaultManagerKit manager) (/bundled-source/.../node_modules/@endo/exo/src/exo-tools.js:42)
 at commitBalanceAdjustment (.../inter-protocol/src/vaultFactory/vault.js:554)
 at apply ()
 at apply ()
 at In "commitBalanceAdjustment" method of (Vault helper) (/bundled-source/.../node_modules/@endo/exo/src/exo-tools.js:42)
 at apply ()
 at apply ()
 at In "adjustBalancesHook" method of (Vault helper) (/bundled-source/.../node_modules/@endo/exo/src/exo-tools.js:42)
 at apply ()
 at apply ()
 at dispatchToHandler (/bundled-source/.../node_modules/@endo/eventual-send/src/handled-promise.js:163)
 at win (/bundled-source/.../node_modules/@endo/eventual-send/src/handled-promise.js:511)
 at ()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants