Open dpaiton opened 8 months ago
we discussed this a bit, and the most robust solution would be to add guardrails to the rust sdk. that may still be something we want to do, but it's a bigger task, since the logic needs to be mirrored in solidity. we have a lot more flexibility in addressing this issue in python, like running a mock trade at the end.
A shortcut was added to max long in https://github.com/delvtech/hyperdrive-rs/pull/5 A similar one should be added to max short.
in our fuzz tests we should prevent allowing two max longs/shorts in row
lets put a check in the interface before calling rust funcs; if bond & share are at certain levels (e.g. close to equal for max long) then we directly return FixedPoint(0) without bothering with the rust func. Similar for max short
we should also catch neg interest in crash reporting and see if it's because max long was too big (calc_max has noise, this results from two max trades in a row)