Skip to content

Added a slippage guard to addLiquidity on the realized LP share price#728

Merged
jalextowle merged 3 commits intomainfrom
jalextowle/feature/add-liquidity-slippage-guard
Jan 18, 2024
Merged

Added a slippage guard to addLiquidity on the realized LP share price#728
jalextowle merged 3 commits intomainfrom
jalextowle/feature/add-liquidity-slippage-guard

Conversation

@jalextowle
Copy link
Copy Markdown
Contributor

Fixes: #428.

The title says most of what needs to be said. The gist is that even though we have a check on the min and max rates at which the LP adds liquidity, we didn't have a slippage guard that protected users from negative slippage that is incurred as a result of changing the execution outcome of closing the net curve position.

@jalextowle jalextowle requested a review from jrhea January 18, 2024 01:30
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jan 18, 2024

Hyperdrive Gas Benchmark

Benchmark suite Current: 781b1ab Previous: 2a8c81f Deviation Status
addLiquidity: min 1633 gas 1600 gas 2.0625% 🚨
addLiquidity: avg 63145 gas 64292 gas -1.7840%
addLiquidity: max 275417 gas 275113 gas 0.1105% 🚨
checkpoint: min 1150 gas 1150 gas 0% 🟰
checkpoint: avg 47761 gas 47670 gas 0.1909% 🚨
checkpoint: max 190992 gas 190992 gas 0% 🟰
closeLong: min 1558 gas 1558 gas 0% 🟰
closeLong: avg 28040 gas 28087 gas -0.1673%
closeLong: max 148081 gas 148328 gas -0.1665%
closeShort: min 1549 gas 1549 gas 0% 🟰
closeShort: avg 29887 gas 29855 gas 0.1072% 🚨
closeShort: max 147421 gas 147421 gas 0% 🟰
initialize: min 1582 gas 1538 gas 2.8609% 🚨
initialize: avg 213204 gas 213159 gas 0.0211% 🚨
initialize: max 255056 gas 254817 gas 0.0938% 🚨
openLong: min 1487 gas 1487 gas 0% 🟰
openLong: avg 50368 gas 50366 gas 0.0040% 🚨
openLong: max 185024 gas 185024 gas 0% 🟰
openShort: min 1608 gas 1608 gas 0% 🟰
openShort: avg 49623 gas 49663 gas -0.0805%
openShort: max 179974 gas 179974 gas 0% 🟰
redeemWithdrawalShares: min 1575 gas 1575 gas 0% 🟰
redeemWithdrawalShares: avg 19566 gas 20332 gas -3.7675%
redeemWithdrawalShares: max 106195 gas 106163 gas 0.0301% 🚨
removeLiquidity: min 1639 gas 1639 gas 0% 🟰
removeLiquidity: avg 150823 gas 148128 gas 1.8194% 🚨
removeLiquidity: max 323845 gas 323757 gas 0.0272% 🚨

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

Comment thread contracts/src/instances/erc4626/ERC4626Hyperdrive.sol
Copy link
Copy Markdown
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.

lgtm

@jalextowle jalextowle enabled auto-merge (squash) January 18, 2024 02:18
@coveralls
Copy link
Copy Markdown
Collaborator

coveralls commented Jan 18, 2024

Coverage Status

coverage: 95.209% (+0.01%) from 95.198%
when pulling 781b1ab on jalextowle/feature/add-liquidity-slippage-guard
into afdc3fd on main.

@jalextowle jalextowle merged commit 6b3cb74 into main Jan 18, 2024
@jalextowle jalextowle deleted the jalextowle/feature/add-liquidity-slippage-guard branch January 18, 2024 20:57
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.

addLiquidity(...) can be griefed

3 participants