Skip to content

Conversation

@jalextowle
Copy link
Contributor

@jalextowle jalextowle commented Jan 23, 2024

Fixes: #74 (the issue is pretty old and refers to something different, but I think this addresses the spirit of the issue).

This PR goes through and explicitly documents all of the code paths that invoke mulDown, mulUp, mulDivDown, mulDivUp, divDown, or divUp and ensures that we are rounding in the correct direction. Several discrepancies were addressed in this PR that will result in Hyperdrive erring on the side of being more conservative. There weren't any significant test failures, and all of the tests appear to be passing. This gives additional confidence that the rounding updates were safe.

@github-actions
Copy link

github-actions bot commented Jan 23, 2024

Hyperdrive Gas Benchmark

Benchmark suite Current: 0fba78b Previous: 73b7616 Deviation Status
addLiquidity: min 1633 gas 1633 gas 0% 🟰
addLiquidity: avg 65131 gas 65988 gas -1.2987%
addLiquidity: max 292045 gas 291577 gas 0.1605% 🚨
checkpoint: min 1150 gas 1150 gas 0% 🟰
checkpoint: avg 48537 gas 47780 gas 1.5843% 🚨
checkpoint: max 191003 gas 190769 gas 0.1227% 🚨
closeLong: min 1558 gas 1558 gas 0% 🟰
closeLong: avg 28050 gas 28036 gas 0.0499% 🚨
closeLong: max 151196 gas 150962 gas 0.1550% 🚨
closeShort: min 1549 gas 1549 gas 0% 🟰
closeShort: avg 29813 gas 29828 gas -0.0503%
closeShort: max 145678 gas 145418 gas 0.1788% 🚨
initialize: min 1582 gas 1582 gas 0% 🟰
initialize: avg 213322 gas 213244 gas 0.0366% 🚨
initialize: max 255137 gas 255056 gas 0.0318% 🚨
openLong: min 1487 gas 1487 gas 0% 🟰
openLong: avg 50463 gas 50463 gas 0% 🟰
openLong: max 184891 gas 184813 gas 0.0422% 🚨
openShort: min 1608 gas 1608 gas 0% 🟰
openShort: avg 50112 gas 49917 gas 0.3906% 🚨
openShort: max 180398 gas 180216 gas 0.1010% 🚨
redeemWithdrawalShares: min 1575 gas 1575 gas 0% 🟰
redeemWithdrawalShares: avg 19385 gas 19149 gas 1.2324% 🚨
redeemWithdrawalShares: max 57811 gas 57733 gas 0.1351% 🚨
removeLiquidity: min 1639 gas 1639 gas 0% 🟰
removeLiquidity: avg 148879 gas 149151 gas -0.1824%
removeLiquidity: max 324287 gas 323845 gas 0.1365% 🚨

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

@jalextowle jalextowle force-pushed the jalextowle/feature/rounding-roundup branch from e1a44d7 to f593a0b Compare January 23, 2024 03:35
@jalextowle jalextowle force-pushed the jalextowle/feature/rounding-roundup branch from f593a0b to e275ede Compare January 23, 2024 03:36
@jalextowle jalextowle changed the title WIP: Rounding Roundup Rounding Roundup Jan 23, 2024
@jalextowle jalextowle requested a review from jrhea January 23, 2024 04:09
@coveralls
Copy link
Collaborator

coveralls commented Jan 23, 2024

Coverage Status

coverage: 95.552% (+0.03%) from 95.52%
when pulling 0fba78b on jalextowle/feature/rounding-roundup
into 73b7616 on main.

Copy link
Contributor

@jrhea jrhea left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just one nit in the comments

@jalextowle jalextowle enabled auto-merge (squash) January 23, 2024 17:14
@jalextowle jalextowle merged commit 78dee14 into main Jan 23, 2024
@jalextowle jalextowle deleted the jalextowle/feature/rounding-roundup branch January 23, 2024 18:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Numerical precision

4 participants