Open DannyDelott opened 1 month ago
The sdk's calculate_max_short method takes a budget and returns a bond amount.
calculate_max_short
budget
The calculate_open_short takes a bond amount and returns the trader deposit (ie: budget).
calculate_open_short
We expect that the outputs of one would reflect the inputs of the other, however the steps below show that this is not the case.
traderDeposit
The bond amount returned from calculate_max_short should be the same as the bond amount we gave to calculate_open_short.
Feeding the traderDeposit back into calculate_max_short results in significantly fewer bonds shorted.
Usecase: In the Open Short form, users can input either an amount to pay (budget) or the number of bonds to short.
Depending on which one they type into, either calculate_max_short or calculate_open_short will be called to update the form.
We're currently not passing a conservative_price argument to calcMaxShort, there is prior art on how to calculate this here that we should try:
calcMaxShort
https://github.com/delvtech/hyperdrive-rs/blob/e4fcc3994a8ec3cf657de418309c0fe9909b3b00/crates/hyperdrive-math/src/test_utils/agent.rs#L178
Background
The sdk's
calculate_max_short
method takes abudget
and returns a bond amount.The
calculate_open_short
takes a bond amount and returns the trader deposit (ie:budget
).We expect that the outputs of one would reflect the inputs of the other, however the steps below show that this is not the case.
Steps to reproduce
calculate_max_short
with a max uint256 budget to get the pool's max short (in bonds).calculate_open_short
to get the actualtraderDeposit
needed.traderDeposit
back intocalculate_max_short
as the budget.Expected
The bond amount returned from
calculate_max_short
should be the same as the bond amount we gave tocalculate_open_short
.Actual
Feeding the
traderDeposit
back intocalculate_max_short
results in significantly fewer bonds shorted.Usecase: In the Open Short form, users can input either an amount to pay (budget) or the number of bonds to short.
Depending on which one they type into, either
calculate_max_short
orcalculate_open_short
will be called to update the form.