uniswap / v3-core-optimism Goto Github PK
View Code? Open in Web Editor NEWOptimism fork of the V3 core contracts
License: Other
Optimism fork of the V3 core contracts
License: Other
(atOrAfter.tickCumulative - beforeOrAt.tickCumulative) * targetDelta / observationTimeDelta
corresponding L283
Alice have 2 X, 2 Y
Bob have 2 X, 2 Y
Alice Provide liquidity, Bob does not
K=4 x=2, y=2
(1, 4), (2, 2), (4, 1)
X-based assets
fee is zeor
when (2,2) Alice asset 4, Bob asset 4
when (1,4) Alice asset 2, Bob asset 2+21/4=2.5
when (4,1) Alice asset 8, Bob asset 2+24/1=10
so Bob asset >= Alice asset
prove:
(x1, y1) change (x2, y2)
Alice asset is 2 * x2
Bob asset is x1+y1 * x2/y2=x1+(K/x1) * x2/y2=x1+(K/x1) * (x2 * x2)/(x2 * y2)=x1+(K/x1) * (x2 * x2)/K=x1+x2 * x2/x1
x1+x2 * x2/x1 - 2 * x2=(x1 * x1+x2 * x2-2 *x1 * x2)/x1=(x1-x2) * (x1-x2)/x1 >= 0
We skip this normally on L1, and only run it manually to verify changes to the oracle library, because it takes a long time to set up the fixture
Because L2 geth does not have test snapshotting features, this group of tests is expected to take prohibitively long to run, so we are not sure if observe will work with maxed out observations arrays (i.e. 65535 observations)
the #snapshotCumulativesInside tests typically fail in CI, when run locally with .only
, they typically succeed but with 100x the gas usage of the EVM version.
3) UniswapV3Pool gas tests
fee is off
#snapshotCumulativesInside
tick above:
Error: transaction failed (transactionHash="0xc0101c12a0f5481fad60ec9f9055aa4e133cbfc58db98d737f48a5201bd49c3f", transaction={"nonce":4079,"gasPrice":{"type":"BigNumber","hex":"0x00"},"gasLimit":{"type":"BigNumber","hex":"0x68b0bb"},"to":"0x637DCa678569cEf6312CA1d5E2c9b420be7F6d63","value":{"type":"BigNumber","hex":"0x00"},"data":"0x9e77b8050000000000000000000000008f2f4cdf79ca76fd90438b500b15736759b56d58000000000000000000000000fffd8963efd1fc6a506488495d951d5263988d25000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb92266","chainId":420,"v":875,"r":"0xc2e0a91192b2df7c5cd081e14a3b1cdd77d66548403ec3b4fa13664799d89107","s":"0x050fe19e64a9bcfad4e3b9e7e146c18df2831e7530a8fa0e37cf027e38fa615f","from":"0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266","hash":"0xc0101c12a0f5481fad60ec9f9055aa4e133cbfc58db98d737f48a5201bd49c3f"}, receipt={"to":"0x637DCa678569cEf6312CA1d5E2c9b420be7F6d63","from":"0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266","contractAddress":null,"transactionIndex":0,"gasUsed":{"type":"BigNumber","hex":"0x939190"},"logsBloom":"0x00000000000000000000000000000000000000000000000000040000000000000000000000000000000000100000000100000000000000000000000000000000000000000000000000000008000000000000000000000000000000400000000000000000000000000000000100000000000000000000000000000010000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000200000000000000000000000002000000000000000000000000000000000000008000000000000000000000000000000000000000000000000","blockHash":"0x4f054748cda348c9a891df68de0d8554ecd34e459b8ec2a26c392b3929378ea9","transactionHash":"0xc0101c12a0f5481fad60ec9f9055aa4e133cbfc58db98d737f48a5201bd49c3f","logs":[{"transactionIndex":0,"blockNumber":4100,"transactionHash":"0xc0101c12a0f5481fad60ec9f9055aa4e133cbfc58db98d737f48a5201bd49c3f","address":"0x4200000000000000000000000000000000000006","topics":["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef","0x000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb92266","0x0000000000000000000000004200000000000000000000000000000000000011"],"data":"0x0000000000000000000000000000000000000000000000000000000000000000","logIndex":0,"blockHash":"0x4f054748cda348c9a891df68de0d8554ecd34e459b8ec2a26c392b3929378ea9"}],"blockNumber":4100,"confirmations":1,"cumulativeGasUsed":{"type":"BigNumber","hex":"0x939190"},"status":0,"byzantium":true}, code=CALL_EXCEPTION, version=providers/5.0.17)
for example:
old cardinality 10
new cardinality 100
when index=3
self blockTimestamp is 10,11,12,13,4,5,6,7,8,9,1,1,1,....1
call(self, 13, 7, 3, 100)
l=4, r=103
first l=53 r=103
...
not find 7
https://github.com/Uniswap/uniswap-v3-core-optimism/blob/d99ea89a1f29e46bede8fab47e8e737190a6b6fa/contracts/libraries/Oracle.sol#L153-L184
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.