delvtech / hyperdrive-rs

Rust SDK for the Hyperdrive AMM.
https://docs.rs/crate/hyperdrive-math/latest
Apache License 2.0
2 stars 0 forks source link

add `calculate_short_proceeds_up` #123

Closed dpaiton closed 5 months ago

dpaiton commented 5 months ago

Resolved Issues

Partially addresses https://github.com/delvtech/hyperdrive-rs/issues/29 and https://github.com/delvtech/hyperdrive-rs/issues/21

Description

These are steps towards implementing a parity implementation of open short as well as targeted short.

Since these functions are implemented on State, we preferentially use State member variables (e.g. vault_share_price) instead of passing arguments.

The short proceeds is given by:

$$ P{\text{short}}(\Delta y) = \tfrac{\Delta y \cdot c{1}}{c{0} \cdot c} + \tfrac{\Delta y}{c} \cdot \phi{f} - \Delta z(\Delta y) $$