OriginProtocol / OriginProtocol/origin-dollar

OUSD rebases can fail if there are no rebasingTokens

Open
#1,164 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

contracts
Dominant language
Solidity
Stars
152
Forks
115
Avg merge
3d 20h
Merged PRs (30d)
17

Description

In the unlikely event that all OUSD is nonRebasing, then rebases revert, blocking redeems and large mints.

This isn't something that's going to happen in real life, but it's an incorrectness that would be nice to fix someday as a part of renaming the rebasing part of OUSD.

  it("Rebasing should not fail when all OUSD is non-rebasing.", async () => {
    let { ousd, vault, matt, josh, usdc, mockNonRebasing } = await loadFixture(
      defaultFixture
    );
    await ousd.connect(matt).transfer(mockNonRebasing.address, ousdUnits("100"));
    await ousd.connect(josh).transfer(mockNonRebasing.address, ousdUnits("100"));
    await usdc.mintTo(vault.address, usdcUnits("10"));
    await vault.rebase(); // Revert
   // Should succeed and keep rebasing tokens per credit the same.
  })

My initial lean is towards just short-circuit out of rebasing if rebasingTokens = 0, similar to what we do if the token amount has not changed.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Search the contracts and tests for rebasingTokens and the vault.rebase() entry point, then reproduce the supplied fixture with all OUSD transferred to mockNonRebasing. Add or update the regression test so the rebase succeeds and preserves the rebasing-token credit when no rebasing tokens remain.

Written by the indexing model from the issue text.

Assessment

Tech stack
solidity
Domain
blockchain
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.