Skip to content

Should openShort() call isSolvent() at the end of _applyOpenLong()? #558

@jrhea

Description

@jrhea
          it's not a bad suggestion.  the way it works now is that since opening a short lowers the exposure, that solvency test is more likely to pass.  tl;dr is that the current way is more "conservative" and it still allows for a short to make the system tradeable again if it is locked up with too many shorts (it's just a little confusing to think about)

consider this scenario though

  • open long is called and the system is barely solvent (meaning high exposure due to many longs being open)
  • open short is called. isSolvent() should pass bc it passed in the previous call to openLong(). Long Exposure is decreased from opening the long and we now have more breathing room for new longs.

In the happy path this is fine, but how do we want it to behave if there is negative variable interest that accrues after the openLong()? that could actually cause isSolvent() to fail in openShort() and now the system is stuck.

now consider the other scenario:

  • openShort() is called and we are near the boundary of how many openShorts we can support. isSolvent() passes (remember that shareReserves have already been updated so having enough shareReserves shouldn't be a problem, right?). Lets say it takes us to where shareReserves - exposure < minShareReserves. The check fails and the short isn't opened. Now lets say the exposure decreased first before the check, then the short would have been opened.

As i type this out, i think i am convincing myself that we shouldn't consider negative exposure bc it puts as at risk of shareReserves < minShareReserves and doesn't buy us that much additional room. On the other hand, we don't allow exposure to go negative then the first openShort won't decrease exposure and will never be netted so maybe the solution is to consider max(longExposure, 0)

Originally posted by @jrhea in #547 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions