delvtech / hyperdrive

An automated market maker for fixed and variable yield with on-demand terms.
Apache License 2.0
25 stars 3 forks source link

update rounding behavior in `calculateSolvencyAfterShort` #1061

Closed dpaiton closed 2 weeks ago

dpaiton commented 2 weeks ago

Resolved Issues

working towards https://github.com/delvtech/hyperdrive-rs/issues/29

Description

The solvency after short check used divDown to convert from base to shares, but the open short function uses divUp. Therefore it was possible to have the solvency check say "all good" and then open short reverts. This fixes that problem.

I also added some intermediate checks so that the function fails gracefully in more situations.

Review Checklists

Please check each item before approving the pull request. While going through the checklist, it is recommended to leave comments on items that are referenced in the checklist to make sure that they are reviewed. If there are multiple reviewers, copy the checklists into sections titled ## [Reviewer Name]. If the PR doesn't touch Solidity, the corresponding checklist can be removed.

[[Reviewer Name]]

coveralls commented 2 weeks ago

Pull Request Test Coverage Report for Build 9555621955

Details


Totals Coverage Status
Change from base Build 9523138246: 0.0%
Covered Lines: 1965
Relevant Lines: 2133

💛 - Coveralls
coveralls commented 2 weeks ago

Pull Request Test Coverage Report for Build 9555779516

Details


Totals Coverage Status
Change from base Build 9523138246: 0.0%
Covered Lines: 1965
Relevant Lines: 2133

💛 - Coveralls
github-actions[bot] commented 2 weeks ago

Hyperdrive Gas Benchmark

Benchmark suite Current: 57240de0d00d783dd7a8fd8324f749dc74bced06 Previous: e5525e96fea5bc61e0eec7fe694049aa6722aa1c Deviation Status
addLiquidity: min 33937 gas 33937 gas 0% 🟰
addLiquidity: avg 156470 gas 155877 gas 0.3804% 🚨
addLiquidity: max 429437 gas 429437 gas 0% 🟰
checkpoint: min 40316 gas 40316 gas 0% 🟰
checkpoint: avg 144612 gas 144636 gas -0.0166% ✅
checkpoint: max 255830 gas 255830 gas 0% 🟰
closeLong: min 31361 gas 31361 gas 0% 🟰
closeLong: avg 136498 gas 136439 gas 0.0432% 🚨
closeLong: max 2621435 gas 2621435 gas 0% 🟰
closeShort: min 31327 gas 31327 gas 0% 🟰
closeShort: avg 132281 gas 132305 gas -0.0181% ✅
closeShort: max 402622 gas 272530 gas 47.7349% 🚨
initialize: min 31349 gas 31349 gas 0% 🟰
initialize: avg 333288 gas 333352 gas -0.0192% ✅
initialize: max 399922 gas 399922 gas 0% 🟰
openLong: min 33370 gas 33370 gas 0% 🟰
openLong: avg 174259 gas 174248 gas 0.0063% 🚨
openLong: max 335241 gas 335241 gas 0% 🟰
openShort: min 33936 gas 33936 gas 0% 🟰
openShort: avg 169132 gas 168925 gas 0.1225% 🚨
openShort: max 416115 gas 415870 gas 0.0589% 🚨
redeemWithdrawalShares: min 31251 gas 31251 gas 0% 🟰
redeemWithdrawalShares: avg 74764 gas 75830 gas -1.4058% ✅
redeemWithdrawalShares: max 305633 gas 305633 gas 0% 🟰
removeLiquidity: min 31301 gas 31301 gas 0% 🟰
removeLiquidity: avg 215692 gas 214933 gas 0.3531% 🚨
removeLiquidity: max 404194 gas 404194 gas 0% 🟰

This comment was automatically generated by workflow using github-action-benchmark.

coveralls commented 2 weeks ago

Pull Request Test Coverage Report for Build 9555912671

Details


Totals Coverage Status
Change from base Build 9523138246: 0.0%
Covered Lines: 1965
Relevant Lines: 2133

💛 - Coveralls
coveralls commented 2 weeks ago

Pull Request Test Coverage Report for Build 9555967822

Details


Totals Coverage Status
Change from base Build 9523138246: 0.0%
Covered Lines: 1965
Relevant Lines: 2133

💛 - Coveralls
coveralls commented 2 weeks ago

Pull Request Test Coverage Report for Build 9556234202

Details


Totals Coverage Status
Change from base Build 9523138246: 0.0%
Covered Lines: 1965
Relevant Lines: 2133

💛 - Coveralls