add calc_bonds_given_shares_and_rate to rust utils#624
add calc_bonds_given_shares_and_rate to rust utils#624dpaiton merged 4 commits intohyperdrive_v0.0.16from
Conversation
Hyperdrive Gas Benchmark
This comment was automatically generated by workflow using github-action-benchmark. |
|
can we get rid of |
|
maybe clarify that apr is actually the target rate. I prefer |
|
I would follow the style of the docstrings we already reviewed and merged into elf-sims. I'm assuming we didn't make any incorrect calls then 😉 |
|
the above uses the raw calc_bond_reserves here delvtech/agent0@94f363e#diff-b313c8dbfc991949469eb56e9a6e328e49c8f75b570e57e791f4e0e0c53196ecR32-R70 |
1852d27 to
24052e5
Compare
The docs are admittedly confusing, but I don't think we should make that change in this PR. The rust docs should be the same or a superset of the solidity docs. So I recommend making your own PR for this change, and make it in both the SOL & RS implementations. |
the variable name is chosen to match the solidity code. If you'd like to change the variable name, you should submit a PR that changes it in both places after this one lands. |
same annoying reply as above unfortunately -- docstring fixes should be their own PR, as these ones are a mirror of what is in solidity. |
yup, covered here: delvtech/agent0#1040 |
jalextowle
left a comment
There was a problem hiding this comment.
Approved with some nits. Our pipeline didn't pick this up since this isn't based on main, so I can test it locally before cutting the release. We'll need to make sure to add this commit to another PR targeting main to get it into v0.0.17.
Adds a Rust version of the solidity
calculateInitialBondReservesfunction inHyperdriveMath.sol.edit: The below has been resolved with the most recent commit; there was a bug in the calculation.
I have a draft here for wrapping this in Python delvtech/hyperdrive-bindings#16
It can't run in CI until we merge this PR and cut a new hyperdrive release. However, I can run the tests locally.
I am finding that the
calculate_bonds_given_shares_and_ratetest in pyperdrive is giving me an interesting error:I think this error is popping up in the underlying rust implementation from this PR, but I don't know why.
Here's are the settings for the test:
Following the equation for bonds:
mu * (z - zeta) * (1 + apr * t) ** (1/tau)I would expect the output to be
Not sure why this would be invalid.