Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move counterfactual logic for reading price0Cumulative and price1Cumulative to pair #2

Closed
moodysalem opened this issue Jun 8, 2020 · 0 comments · Fixed by #51
Closed
Labels
oracle involves the accumulators user experience improves experience of interacting with contracts

Comments

@moodysalem
Copy link
Contributor

When reading price*CumulativeLast variables, all oracle consumers actually want the cumulative price as of the current block, not the last liquidity event (e.g. mint/burn/swap)

We provided a library in uniswap v2 periphery for this
https://github.com/Uniswap/uniswap-v2-periphery/blob/master/contracts/libraries/UniswapV2OracleLibrary.sol#L16

However, we should just add the view method directly to the pair getCumulativePrices() returns (price0Cumulative, price1Cumulative) that returns the cumulative prices as of the current block, even if there was no liquidity event.

Also potentially consider marking the Last suffixed variables private, if we want to force others to use this other method.

@moodysalem moodysalem added the oracle involves the accumulators label Jun 9, 2020
@NoahZinsmeister NoahZinsmeister added the user experience improves experience of interacting with contracts label Jul 21, 2020
gakonst added a commit that referenced this issue Aug 10, 2020
DamienCassous added a commit to DamienCassous/v3-core that referenced this issue Jan 6, 2023
hackhero920 added a commit to hackhero920/v3-core that referenced this issue Jul 6, 2023
leonhiat added a commit to leonhiat/v3-core that referenced this issue Oct 31, 2023
0xrelapse pushed a commit to ferumlabs/uni-v3-core that referenced this issue Mar 22, 2024
* chore: fix doctest error

* feat: add library for calculating liquidity from amount0/amount1

Co-authored-by: Moody Salem <moody.salem@gmail.com>
whisperky added a commit to whisperky/Peacwap-v3-core that referenced this issue May 4, 2024
HappyCodingWizard added a commit to HappyCodingWizard/v3-core that referenced this issue Jun 6, 2024
EnigmaGlimmer pushed a commit to EnigmaGlimmer/Uniswap_V4 that referenced this issue Aug 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
oracle involves the accumulators user experience improves experience of interacting with contracts
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants