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 a checkpoint module to `hyperdrive-math` #23

Open jalextowle opened 7 months ago

jalextowle commented 7 months ago

One of the current limitations of the Rust SDK is that it doesn't simulate checkpoints. This means that when the Rust SDK is used to run a simulation at a checkpoint boundary before a new trade has been made, the result could be very inaccurate. The best version of the Rust SDK would simulate the application of checkpoints by replicating the checkpointing logic and the distribute excess idle calculation.

dpaiton commented 1 month ago

This ideally would also need to account for auto-closing positions & zombie interest

jalextowle commented 1 month ago

Yeah, that was the idea behind this issue. Checkpointing accounts for matured positions (you could call this auto-closing), zombie interest, and it distributes excess idle to the withdrawal pool. Here is the checkpoint function in Solidity for context: https://github.com/delvtech/hyperdrive/blob/main/contracts/src/internal/HyperdriveCheckpoint.sol