UNPKG

@sonicswap/periphery

Version:

🎚 Peripheral smart contracts for interacting with the Sonicswap exchanges

553 lines • 470 kB
{ "contractName": "ExampleSlidingWindowOracle", "abi": [ { "inputs": [ { "internalType": "address", "name": "factory_", "type": "address" }, { "internalType": "uint256", "name": "windowSize_", "type": "uint256" }, { "internalType": "uint8", "name": "granularity_", "type": "uint8" } ], "stateMutability": "nonpayable", "type": "constructor" }, { "inputs": [], "name": "factory", "outputs": [ { "internalType": "address", "name": "", "type": "address" } ], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "granularity", "outputs": [ { "internalType": "uint8", "name": "", "type": "uint8" } ], "stateMutability": "view", "type": "function" }, { "inputs": [ { "internalType": "address", "name": "", "type": "address" }, { "internalType": "uint256", "name": "", "type": "uint256" } ], "name": "pairObservations", "outputs": [ { "internalType": "uint256", "name": "timestamp", "type": "uint256" }, { "internalType": "uint256", "name": "price0Cumulative", "type": "uint256" }, { "internalType": "uint256", "name": "price1Cumulative", "type": "uint256" } ], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "periodSize", "outputs": [ { "internalType": "uint256", "name": "", "type": "uint256" } ], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "windowSize", "outputs": [ { "internalType": "uint256", "name": "", "type": "uint256" } ], "stateMutability": "view", "type": "function" }, { "inputs": [ { "internalType": "uint256", "name": "timestamp", "type": "uint256" } ], "name": "observationIndexOf", "outputs": [ { "internalType": "uint8", "name": "index", "type": "uint8" } ], "stateMutability": "view", "type": "function" }, { "inputs": [ { "internalType": "address", "name": "tokenA", "type": "address" }, { "internalType": "address", "name": "tokenB", "type": "address" } ], "name": "update", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [ { "internalType": "address", "name": "tokenIn", "type": "address" }, { "internalType": "uint256", "name": "amountIn", "type": "uint256" }, { "internalType": "address", "name": "tokenOut", "type": "address" } ], "name": "consult", "outputs": [ { "internalType": "uint256", "name": "amountOut", "type": "uint256" } ], "stateMutability": "view", "type": "function" } ], "metadata": "{\"compiler\":{\"version\":\"0.6.12+commit.27d51765\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"factory_\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"windowSize_\",\"type\":\"uint256\"},{\"internalType\":\"uint8\",\"name\":\"granularity_\",\"type\":\"uint8\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"tokenIn\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amountIn\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"tokenOut\",\"type\":\"address\"}],\"name\":\"consult\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"amountOut\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"factory\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"granularity\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"timestamp\",\"type\":\"uint256\"}],\"name\":\"observationIndexOf\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"index\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"pairObservations\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"timestamp\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"price0Cumulative\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"price1Cumulative\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"periodSize\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"tokenA\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"tokenB\",\"type\":\"address\"}],\"name\":\"update\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"windowSize\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"/var/www/Sonic/sonicswap-periphery/contracts/examples/ExampleSlidingWindowOracle.sol\":\"ExampleSlidingWindowOracle\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"/var/www/Sonic/sonicswap-periphery/contracts/examples/ExampleSlidingWindowOracle.sol\":{\"keccak256\":\"0x03fe5a9c0ff36afc247d609f3f33891da1234dc8e6bbe573723fd11a008aefe0\",\"license\":\"GPL-3.0\",\"urls\":[\"bzz-raw://af269faddcc4dbdda710283bc084536d05db727fa30cca598bbfd311b076363c\",\"dweb:/ipfs/QmPASYUJt5CqhBNwFw3PLAvyX5z77kwG3krYzCf4GySJc3\"]},\"/var/www/Sonic/sonicswap-periphery/contracts/libraries/SafeMath.sol\":{\"keccak256\":\"0x97845129a51dbb1869a765595d1c671fa473b97ef800756402afaadc7640a94e\",\"license\":\"GPL-3.0\",\"urls\":[\"bzz-raw://5928803fe14654103d3f15b57b5b8df40b98f58cbe4e7044888f092f2462af04\",\"dweb:/ipfs/QmdnB83EBtNjwoKFHizxsTo6e2ytKN97SCvYnX28p75DCu\"]},\"/var/www/Sonic/sonicswap-periphery/contracts/libraries/UniswapV2Library.sol\":{\"keccak256\":\"0x97bae257510f91855e0f098176f8dbb967702f788492884bca5886dc1d1aec7d\",\"license\":\"GPL-3.0\",\"urls\":[\"bzz-raw://310af80b5807f9ca7b8da55e529f44d41cd2f897511191f40d85d41e351bbeb4\",\"dweb:/ipfs/QmXMrQD79HZXN7JrHqNGYp3AKTSN7Kw8TjwrUw8Z33jFU6\"]},\"/var/www/Sonic/sonicswap-periphery/contracts/libraries/UniswapV2OracleLibrary.sol\":{\"keccak256\":\"0xa41e7d2548091ad9d2a7d41a7d204dc02de4c239918befdc91d38fe86a45c8a3\",\"license\":\"GPL-3.0\",\"urls\":[\"bzz-raw://9b334a4d861aaffed92ad7157e7c272a043ed985f7ebe2054530cec5ac4164dc\",\"dweb:/ipfs/QmcuLSWUDLFXaogTpQNqHavfE1GKDjZHvoWDwcZ5x1eDea\"]},\"@sonicswap/core/contracts/interfaces/IUniswapV2Factory.sol\":{\"keccak256\":\"0xf493893f508c8caa2f5923d1a39080fc5f1f362ea1f1d65ffc38b7782b35c4b7\",\"license\":\"GPL-3.0\",\"urls\":[\"bzz-raw://993a51b20f6d79edb33069524ee3a66378f8687d3df52e279561c4ef72e17cb2\",\"dweb:/ipfs/QmQSmgeRkVyA4jyShZStAWVt1CWNZQ8JvYmc2V2jgEUNEE\"]},\"@sonicswap/core/contracts/interfaces/IUniswapV2Pair.sol\":{\"keccak256\":\"0xa87a1a8e9d72090e25812f396a9c0766a715dda52d8b6115ca0ab3f2a9c10f87\",\"license\":\"GPL-3.0\",\"urls\":[\"bzz-raw://3b179da8f464eaa162ef0f9cfac56989d6fb5aa9667bebd23b355d93ea3ff10b\",\"dweb:/ipfs/QmcgYA55h3VJJRo7fFFNSDDDspdnJVTW83aH657v4E9bGZ\"]},\"@sonicswap/lib/contracts/libraries/Babylonian.sol\":{\"keccak256\":\"0xc2389737a1d4954f93ed88099f8833ccc350a62b8b29b61c2a24f237eb4649bc\",\"license\":\"GPL-3.0-or-later\",\"urls\":[\"bzz-raw://3d95218a6f0c7c5030e1f81aabcfe297449bf8bb92fcac1c4ba9bcfc8d61e62b\",\"dweb:/ipfs/QmXzJQLQfgqCuxL5JGMrKRQf5ziRNvQiQkNK3ZK6Lkn4CR\"]},\"@sonicswap/lib/contracts/libraries/BitMath.sol\":{\"keccak256\":\"0xa4d662f44b982fc9aa6542249aa79b2b07b3e34d5cdaa03720d3d471ac07f5de\",\"license\":\"GPL-3.0-or-later\",\"urls\":[\"bzz-raw://4d40d6c87edb8699d5c5c80344b642a516e0a071f173d393678fee58bbc5fde5\",\"dweb:/ipfs/QmXfp4W5jAdpcsv8VTP8RWsPcmASEtmzF9Xg9xehKK7Xdm\"]},\"@sonicswap/lib/contracts/libraries/FixedPoint.sol\":{\"keccak256\":\"0xba90ab07a7e7870d349fd22dda12b02b78a2b5c0f797de591115cde1ae3e47b0\",\"license\":\"GPL-3.0-or-later\",\"urls\":[\"bzz-raw://b91731ebb4825bcd8512fbf9721d602c298a18392919ddf800f3394231090cb4\",\"dweb:/ipfs/QmUNu1dqnNMyjUeD23KheR1ACVvWmP1T6SmH55Q2kS4nwS\"]},\"@sonicswap/lib/contracts/libraries/FullMath.sol\":{\"keccak256\":\"0x074f43cf798f046118ed21bb9859a7fa1074b9581fe315c8702d6d292fdb2784\",\"license\":\"CC-BY-4.0\",\"urls\":[\"bzz-raw://55a5cb6c5ae9ccc1e6870315bfa5f23f4c758db606f6a292fdff2224fcec082e\",\"dweb:/ipfs/QmRZayK4DWdWHaape9XcVj6VobzX7en7Tejk7gbzv7CHTy\"]}},\"version\":1}", "bytecode": "0x61010060405234801561001157600080fd5b5060405161106f38038061106f8339818101604052606081101561003457600080fd5b5080516020820151604090920151909190600160ff82161161009d576040805162461bcd60e51b815260206004820181905260248201527f536c6964696e6757696e646f774f7261636c653a204752414e554c4152495459604482015290519081900360640190fd5b8160ff82168082816100ab57fe5b0460e081905202146100ee5760405162461bcd60e51b815260040180806020018281038252603081526020018061103f6030913960400191505060405180910390fd5b606083901b6001600160601b03191660805260a082905260f881901b7fff000000000000000000000000000000000000000000000000000000000000001660c05260e0516001600160a01b039093169260ff90911690610ea061019f600039806102a952806104eb528061053e528061059e5250806101c05280610448528061056a52806106925250806101e4528061024a52806102cd52508061020e52806103da52806104035250610ea06000f3fe608060405234801561001057600080fd5b50600436106100885760003560e01c8063c45a01551161005b578063c45a015514610145578063c640752d14610169578063dbaad32f14610199578063e4463eb2146101b657610088565b8063556f0dc71461008d5780638a14117a146100ab5780638c86f1e4146100c5578063bfcc8e42146100fb575b600080fd5b6100956101be565b6040805160ff9092168252519081900360200190f35b6100b36101e2565b60408051918252519081900360200190f35b6100b3600480360360608110156100db57600080fd5b506001600160a01b03813581169160208101359160409091013516610206565b6101276004803603604081101561011157600080fd5b506001600160a01b038135169060200135610399565b60408051938452602084019290925282820152519081900360600190f35b61014d6103d8565b604080516001600160a01b039092168252519081900360200190f35b6101976004803603604081101561017f57600080fd5b506001600160a01b03813581169160200135166103fc565b005b610095600480360360208110156101af57600080fd5b5035610539565b6100b361059c565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b6000806102347f000000000000000000000000000000000000000000000000000000000000000086856105c0565b9050600061024182610680565b805490915042037f00000000000000000000000000000000000000000000000000000000000000008111156102a75760405162461bcd60e51b8152600401808060200182810382526033815260200180610dc16033913960400191505060405180910390fd5b7f00000000000000000000000000000000000000000000000000000000000000006002027f00000000000000000000000000000000000000000000000000000000000000000381101561032b5760405162461bcd60e51b815260040180806020018281038252602c815260200180610df4602c913960400191505060405180910390fd5b6000806103378561070e565b509150915060006103488a896108fd565b509050896001600160a01b0316816001600160a01b0316141561038257610375856001015484868c6109db565b9650505050505050610392565b610375856002015483868c6109db565b9392505050565b600060205281600052604060002081815481106103b257fe5b600091825260209091206003909102018054600182015460029092015490935090915083565b7f000000000000000000000000000000000000000000000000000000000000000081565b60006104297f000000000000000000000000000000000000000000000000000000000000000084846105c0565b6001600160a01b0381166000908152602081905260409020549091505b7f000000000000000000000000000000000000000000000000000000000000000060ff1681101561049a576001600160a01b0382166000908152602081905260408120805460019081018255915201610446565b5060006104a642610539565b6001600160a01b03831660009081526020819052604081208054929350909160ff84169081106104d257fe5b60009182526020909120600390910201805490915042037f00000000000000000000000000000000000000000000000000000000000000008111156105315760008061051d8661070e565b504286556001860191909155600285015550505b505050505050565b6000807f0000000000000000000000000000000000000000000000000000000000000000838161056557fe5b0490507f000000000000000000000000000000000000000000000000000000000000000060ff16818161059457fe5b069392505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b60008060006105cf85856108fd565b604080516bffffffffffffffffffffffff19606094851b811660208084019190915293851b81166034830152825160288184030181526048830184528051908501206001600160f81b031960688401529a90941b9093166069840152607d8301989098527f4a8da68f30e6bab8a1cda432a2de48a79d41e83ccf07532497c0762037cdc0cb609d808401919091528851808403909101815260bd909201909752805196019590952095945050505050565b60008061068c42610539565b905060007f000000000000000000000000000000000000000000000000000000000000000060ff168260010160ff16816106c257fe5b069050600080856001600160a01b03166001600160a01b031681526020019081526020016000208160ff16815481106106f757fe5b906000526020600020906003020192505050919050565b600080600061071b610a2e565b9050836001600160a01b0316635909c0d56040518163ffffffff1660e01b815260040160206040518083038186803b15801561075657600080fd5b505afa15801561076a573d6000803e3d6000fd5b505050506040513d602081101561078057600080fd5b505160408051635a3d549360e01b815290519194506001600160a01b03861691635a3d549391600480820192602092909190829003018186803b1580156107c657600080fd5b505afa1580156107da573d6000803e3d6000fd5b505050506040513d60208110156107f057600080fd5b505160408051630240bc6b60e21b81529051919350600091829182916001600160a01b03891691630902f1ac916004808301926060929190829003018186803b15801561083c57600080fd5b505afa158015610850573d6000803e3d6000fd5b505050506040513d606081101561086657600080fd5b5080516020820151604090920151909450909250905063ffffffff808216908516146108f35780840363ffffffff81166108ac6001600160701b03808616908716610a38565b600001516001600160e01b031602870196508063ffffffff166108e1856001600160701b0316856001600160701b0316610a38565b516001600160e01b0316029590950194505b5050509193909250565b600080826001600160a01b0316846001600160a01b031614156109515760405162461bcd60e51b8152600401808060200182810382526025815260200180610e206025913960400191505060405180910390fd5b826001600160a01b0316846001600160a01b031610610971578284610974565b83835b90925090506001600160a01b0382166109d4576040805162461bcd60e51b815260206004820152601e60248201527f556e697377617056324c6962726172793a205a45524f5f414444524553530000604482015290519081900360640190fd5b9250929050565b60006109e5610d9b565b604051806020016040528085888803816109fb57fe5b046001600160e01b031690529050610a1b610a168285610baa565b610c3e565b6001600160901b03169695505050505050565b63ffffffff421690565b610a40610d9b565b60008211610a7f5760405162461bcd60e51b8152600401808060200182810382526026815260200180610e456026913960400191505060405180910390fd5b82610a995750604080516020810190915260008152610ba4565b6001600160901b038311610b3557600082607085901b81610ab657fe5b0490506001600160e01b03811115610b15576040805162461bcd60e51b815260206004820152601e60248201527f4669786564506f696e743a3a6672616374696f6e3a206f766572666c6f770000604482015290519081900360640190fd5b6040518060200160405280826001600160e01b0316815250915050610ba4565b6000610b4684600160701b85610c45565b90506001600160e01b03811115610b15576040805162461bcd60e51b815260206004820152601e60248201527f4669786564506f696e743a3a6672616374696f6e3a206f766572666c6f770000604482015290519081900360640190fd5b92915050565b610bb2610dad565b6000821580610bd857505082516001600160e01b031682810290838281610bd557fe5b04145b610c29576040805162461bcd60e51b815260206004820152601960248201527f4669786564506f696e743a3a6d756c3a206f766572666c6f7700000000000000604482015290519081900360640190fd5b60408051602081019091529081529392505050565b5160701c90565b6000806000610c548686610cfe565b9150915060008480610c6257fe5b868809905082811115610c76576001820391505b918290039181610c9457848381610c8957fe5b049350505050610392565b848210610ce8576040805162461bcd60e51b815260206004820152601a60248201527f46756c6c4d6174683a2046554c4c4449565f4f564552464c4f57000000000000604482015290519081900360640190fd5b610cf3838387610d2b565b979650505050505050565b6000808060001984860990508385029250828103915082811015610d23576001820391505b509250929050565b60008181038216808381610d3b57fe5b049250808581610d4757fe5b049450808160000381610d5657fe5b60028581038087028203028087028203028087028203028087028203028087028203028087028203029586029003909402930460010193909302939093010292915050565b60408051602081019091526000815290565b604051806020016040528060008152509056fe536c6964696e6757696e646f774f7261636c653a204d495353494e475f484953544f524943414c5f4f42534552564154494f4e536c6964696e6757696e646f774f7261636c653a20554e45585045435445445f54494d455f454c4150534544556e697377617056324c6962726172793a204944454e544943414c5f4144445245535345534669786564506f696e743a3a6672616374696f6e3a206469766973696f6e206279207a65726fa26469706673582212207fa692c55e9ed93cef631303e11016599bc9921e65d4ef1f2028405f391082ee64736f6c634300060c0033536c6964696e6757696e646f774f7261636c653a2057494e444f575f4e4f545f4556454e4c595f444956495349424c45", "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100885760003560e01c8063c45a01551161005b578063c45a015514610145578063c640752d14610169578063dbaad32f14610199578063e4463eb2146101b657610088565b8063556f0dc71461008d5780638a14117a146100ab5780638c86f1e4146100c5578063bfcc8e42146100fb575b600080fd5b6100956101be565b6040805160ff9092168252519081900360200190f35b6100b36101e2565b60408051918252519081900360200190f35b6100b3600480360360608110156100db57600080fd5b506001600160a01b03813581169160208101359160409091013516610206565b6101276004803603604081101561011157600080fd5b506001600160a01b038135169060200135610399565b60408051938452602084019290925282820152519081900360600190f35b61014d6103d8565b604080516001600160a01b039092168252519081900360200190f35b6101976004803603604081101561017f57600080fd5b506001600160a01b03813581169160200135166103fc565b005b610095600480360360208110156101af57600080fd5b5035610539565b6100b361059c565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b6000806102347f000000000000000000000000000000000000000000000000000000000000000086856105c0565b9050600061024182610680565b805490915042037f00000000000000000000000000000000000000000000000000000000000000008111156102a75760405162461bcd60e51b8152600401808060200182810382526033815260200180610dc16033913960400191505060405180910390fd5b7f00000000000000000000000000000000000000000000000000000000000000006002027f00000000000000000000000000000000000000000000000000000000000000000381101561032b5760405162461bcd60e51b815260040180806020018281038252602c815260200180610df4602c913960400191505060405180910390fd5b6000806103378561070e565b509150915060006103488a896108fd565b509050896001600160a01b0316816001600160a01b0316141561038257610375856001015484868c6109db565b9650505050505050610392565b610375856002015483868c6109db565b9392505050565b600060205281600052604060002081815481106103b257fe5b600091825260209091206003909102018054600182015460029092015490935090915083565b7f000000000000000000000000000000000000000000000000000000000000000081565b60006104297f000000000000000000000000000000000000000000000000000000000000000084846105c0565b6001600160a01b0381166000908152602081905260409020549091505b7f000000000000000000000000000000000000000000000000000000000000000060ff1681101561049a576001600160a01b0382166000908152602081905260408120805460019081018255915201610446565b5060006104a642610539565b6001600160a01b03831660009081526020819052604081208054929350909160ff84169081106104d257fe5b60009182526020909120600390910201805490915042037f00000000000000000000000000000000000000000000000000000000000000008111156105315760008061051d8661070e565b504286556001860191909155600285015550505b505050505050565b6000807f0000000000000000000000000000000000000000000000000000000000000000838161056557fe5b0490507f000000000000000000000000000000000000000000000000000000000000000060ff16818161059457fe5b069392505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b60008060006105cf85856108fd565b604080516bffffffffffffffffffffffff19606094851b811660208084019190915293851b81166034830152825160288184030181526048830184528051908501206001600160f81b031960688401529a90941b9093166069840152607d8301989098527f4a8da68f30e6bab8a1cda432a2de48a79d41e83ccf07532497c0762037cdc0cb609d808401919091528851808403909101815260bd909201909752805196019590952095945050505050565b60008061068c42610539565b905060007f000000000000000000000000000000000000000000000000000000000000000060ff168260010160ff16816106c257fe5b069050600080856001600160a01b03166001600160a01b031681526020019081526020016000208160ff16815481106106f757fe5b906000526020600020906003020192505050919050565b600080600061071b610a2e565b9050836001600160a01b0316635909c0d56040518163ffffffff1660e01b815260040160206040518083038186803b15801561075657600080fd5b505afa15801561076a573d6000803e3d6000fd5b505050506040513d602081101561078057600080fd5b505160408051635a3d549360e01b815290519194506001600160a01b03861691635a3d549391600480820192602092909190829003018186803b1580156107c657600080fd5b505afa1580156107da573d6000803e3d6000fd5b505050506040513d60208110156107f057600080fd5b505160408051630240bc6b60e21b81529051919350600091829182916001600160a01b03891691630902f1ac916004808301926060929190829003018186803b15801561083c57600080fd5b505afa158015610850573d6000803e3d6000fd5b505050506040513d606081101561086657600080fd5b5080516020820151604090920151909450909250905063ffffffff808216908516146108f35780840363ffffffff81166108ac6001600160701b03808616908716610a38565b600001516001600160e01b031602870196508063ffffffff166108e1856001600160701b0316856001600160701b0316610a38565b516001600160e01b0316029590950194505b5050509193909250565b600080826001600160a01b0316846001600160a01b031614156109515760405162461bcd60e51b8152600401808060200182810382526025815260200180610e206025913960400191505060405180910390fd5b826001600160a01b0316846001600160a01b031610610971578284610974565b83835b90925090506001600160a01b0382166109d4576040805162461bcd60e51b815260206004820152601e60248201527f556e697377617056324c6962726172793a205a45524f5f414444524553530000604482015290519081900360640190fd5b9250929050565b60006109e5610d9b565b604051806020016040528085888803816109fb57fe5b046001600160e01b031690529050610a1b610a168285610baa565b610c3e565b6001600160901b03169695505050505050565b63ffffffff421690565b610a40610d9b565b60008211610a7f5760405162461bcd60e51b8152600401808060200182810382526026815260200180610e456026913960400191505060405180910390fd5b82610a995750604080516020810190915260008152610ba4565b6001600160901b038311610b3557600082607085901b81610ab657fe5b0490506001600160e01b03811115610b15576040805162461bcd60e51b815260206004820152601e60248201527f4669786564506f696e743a3a6672616374696f6e3a206f766572666c6f770000604482015290519081900360640190fd5b6040518060200160405280826001600160e01b0316815250915050610ba4565b6000610b4684600160701b85610c45565b90506001600160e01b03811115610b15576040805162461bcd60e51b815260206004820152601e60248201527f4669786564506f696e743a3a6672616374696f6e3a206f766572666c6f770000604482015290519081900360640190fd5b92915050565b610bb2610dad565b6000821580610bd857505082516001600160e01b031682810290838281610bd557fe5b04145b610c29576040805162461bcd60e51b815260206004820152601960248201527f4669786564506f696e743a3a6d756c3a206f766572666c6f7700000000000000604482015290519081900360640190fd5b60408051602081019091529081529392505050565b5160701c90565b6000806000610c548686610cfe565b9150915060008480610c6257fe5b868809905082811115610c76576001820391505b918290039181610c9457848381610c8957fe5b049350505050610392565b848210610ce8576040805162461bcd60e51b815260206004820152601a60248201527f46756c6c4d6174683a2046554c4c4449565f4f564552464c4f57000000000000604482015290519081900360640190fd5b610cf3838387610d2b565b979650505050505050565b6000808060001984860990508385029250828103915082811015610d23576001820391505b509250929050565b60008181038216808381610d3b57fe5b049250808581610d4757fe5b049450808160000381610d5657fe5b60028581038087028203028087028203028087028203028087028203028087028203028087028203029586029003909402930460010193909302939093010292915050565b60408051602081019091526000815290565b604051806020016040528060008152509056fe536c6964696e6757696e646f774f7261636c653a204d495353494e475f484953544f524943414c5f4f42534552564154494f4e536c6964696e6757696e646f774f7261636c653a20554e45585045435445445f54494d455f454c4150534544556e697377617056324c6962726172793a204944454e544943414c5f4144445245535345534669786564506f696e743a3a6672616374696f6e3a206469766973696f6e206279207a65726fa26469706673582212207fa692c55e9ed93cef631303e11016599bc9921e65d4ef1f2028405f391082ee64736f6c634300060c0033", "immutableReferences": { "4417": [ { "length": 32, "start": 526 }, { "length": 32, "start": 986 }, { "length": 32, "start": 1027 } ], "4419": [ { "length": 32, "start": 484 }, { "length": 32, "start": 586 }, { "length": 32, "start": 717 } ], "4421": [ { "length": 32, "start": 448 }, { "length": 32, "start": 1096 }, { "length": 32, "start": 1386 }, { "length": 32, "start": 1682 } ], "4423": [ { "length": 32, "start": 681 }, { "length": 32, "start": 1259 }, { "length": 32, "start": 1342 }, { "length": 32, "start": 1438 } ] }, "sourceMap": "741:5705:6:-:0;;;2012:427;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;2012:427:6;;;;;;;;;;;;;;2120:1;2105:16;;;;2097:61;;;;;-1:-1:-1;;;2097:61:6;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2249:11;2189:56;;;;2249:11;2189:56;2203:26;;;;;2190:39;;;;2189:56;:71;2168:166;;;;-1:-1:-1;;;2168:166:6;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2344:18;;;;-1:-1:-1;;;;;;2344:18:6;;;2372:24;;;;2406:26;;;;;;;;741:5705;;-1:-1:-1;;;;;741:5705:6;;;;;;;;;;;;;;;;;;;", "deployedSourceMap": "741:5705:6:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1680:34;;;:::i;:::-;;;;;;;;;;;;;;;;;;;1095:32;;;:::i;:::-;;;;;;;;;;;;;;;;5382:1062;;;;;;;;;;;;;;;;-1:-1:-1;;;;;;5382:1062:6;;;;;;;;;;;;;;;;;:::i;1948:57::-;;;;;;;;;;;;;;;;-1:-1:-1;;;;;;1948:57:6;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;959:32;;;:::i;:::-;;;;-1:-1:-1;;;;;959:32:6;;;;;;;;;;;;;;3410:1050;;;;;;;;;;;;;;;;-1:-1:-1;;;;;;3410:1050:6;;;;;;;;;;:::i;:::-;;2526:185;;;;;;;;;;;;;;;;-1:-1:-1;2526:185:6;;:::i;1831:32::-;;;:::i;1680:34::-;;;:::o;1095:32::-;;;:::o;5382:1062::-;5472:14;5498:12;5513:52;5538:7;5547;5556:8;5513:24;:52::i;:::-;5498:67;;5575:36;5614:33;5642:4;5614:27;:33::i;:::-;5695:26;;5575:72;;-1:-1:-1;5677:15:6;:44;5754:10;5739:25;;;5731:89;;;;-1:-1:-1;;;5731:89:6;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;5898:10;5911:1;5898:14;5885:10;:27;5870:11;:42;;5862:99;;;;-1:-1:-1;;;5862:99:6;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;5973:21;5996;6022:52;6069:4;6022:46;:52::i;:::-;5972:102;;;;;6085:14;6104:46;6132:7;6141:8;6104:27;:46::i;:::-;6084:66;;;6175:7;-1:-1:-1;;;;;6165:17:6;:6;-1:-1:-1;;;;;6165:17:6;;6161:277;;;6205:92;6222:16;:33;;;6257:16;6275:11;6288:8;6205:16;:92::i;:::-;6198:99;;;;;;;;;;6161:277;6335:92;6352:16;:33;;;6387:16;6405:11;6418:8;6335:16;:92::i;5382:1062::-;;;;;;:::o;1948:57::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;1948:57:6;;-1:-1:-1;1948:57:6;:::o;959:32::-;;;:::o;3410:1050::-;3477:12;3492:49;3517:7;3526:6;3534;3492:24;:49::i;:::-;-1:-1:-1;;;;;3638:22:6;;3629:6;3638:22;;;;;;;;;;:29;3477:64;;-1:-1:-1;3624:121:6;3673:11;3669:15;;:1;:15;3624:121;;;-1:-1:-1;;;;;3705:22:6;;:16;:22;;;;;;;;;;:29;;;;;;;;;;3686:3;3624:121;;;;3809:22;3834:35;3853:15;3834:18;:35::i;:::-;-1:-1:-1;;;;;3913:22:6;;3879:31;3913:22;;;;;;;;;;:40;;3809:60;;-1:-1:-1;3879:31:6;;3913:40;;;;;;;;;;;;;;;;;;;;;;;4091:21;;3913:40;;-1:-1:-1;4073:15:6;:39;4140:10;4126:24;;4122:332;;;4167:21;4190;4216:52;4263:4;4216:46;:52::i;:::-;-1:-1:-1;4306:15:6;4282:39;;4335:28;;;:47;;;;4396:28;;;:47;-1:-1:-1;;4122:332:6;3410:1050;;;;;;:::o;2526:185::-;2591:11;2614:16;2645:10;2633:9;:22;;;;;;2614:41;;2692:11;2678:25;;:11;:25;;;;;;;2526:185;-1:-1:-1;;;2526:185:6:o;1831:32::-;;;:::o;750:470:16:-;839:12;864:14;880;898:26;909:6;917;898:10;:26::i;:::-;1058:32;;;-1:-1:-1;;1058:32:16;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1048:43;;;;;;-1:-1:-1;;;;;;964:246:16;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;954:257;;;;;;;;;750:470;-1:-1:-1;;;;;750:470:16:o;2832:425:6:-;2905:36;2953:22;2978:35;2997:15;2978:18;:35::i;:::-;2953:60;;3110:27;3165:11;3140:36;;3141:16;3160:1;3141:20;3140:36;;;;;;;;3110:66;;3205:16;:22;3222:4;-1:-1:-1;;;;;3205:22:6;-1:-1:-1;;;;;3205:22:6;;;;;;;;;;;;3228:21;3205:45;;;;;;;;;;;;;;;;;;;;3186:64;;2832:425;;;;;:::o;683:1040:18:-;767:21;790;813;863:23;:21;:23::i;:::-;846:40;;930:4;-1:-1:-1;;;;;915:41:18;;:43;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;915:43:18;987;;;-1:-1:-1;;;987:43:18;;;;915;;-1:-1:-1;;;;;;987:41:18;;;;;:43;;;;;915;;987;;;;;;;;:41;:43;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;987:43:18;1207:34;;;-1:-1:-1;;;1207:34:18;;;;987:43;;-1:-1:-1;1142:16:18;;;;;;-1:-1:-1;;;;;1207:32:18;;;;;:34;;;;;;;;;;;;;;:32;:34;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;1207:34:18;;;;;;;;;;;;;-1:-1:-1;1207:34:18;;-1:-1:-1;1207:34:18;-1:-1:-1;1255:36:18;;;;;;;;1251:466;;1375:35;;;1518:62;;;1523:39;-1:-1:-1;;;;;1523:39:18;;;;;;:19;:39::i;:::-;:42;;;-1:-1:-1;;;;;1518:48:18;:62;1498:82;;;;1695:11;1644:62;;1649:39;1669:8;-1:-1:-1;;;;;1649:39:18;1679:8;-1:-1:-1;;;;;1649:39:18;:19;:39::i;:::-;:42;-1:-1:-1;;;;;1644:48:18;:62;1624:82;;;;;-1:-1:-1;1251:466:18;683:1040;;;;;;;;:::o;316:345:16:-;391:14;407;451:6;-1:-1:-1;;;;;441:16:16;:6;-1:-1:-1;;;;;441:16:16;;;433:66;;;;-1:-1:-1;;;433:66:16;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;537:6;-1:-1:-1;;;;;528:15:16;:6;-1:-1:-1;;;;;528:15:16;;:53;;566:6;574;528:53;;;547:6;555;528:53;509:72;;-1:-1:-1;509:72:16;-1:-1:-1;;;;;;599:20:16;;591:63;;;;;-1:-1:-1;;;591:63:16;;;;;;;;;;;;;;;;;;;;;;;;;;;;316:345;;;;;:::o;4660:433:6:-;4815:14;4873:40;;:::i;:::-;4916:110;;;;;;;;5004:11;4980:20;4959:18;:41;4958:57;;;;;;-1:-1:-1;;;;;4916:110:6;;;4873:153;-1:-1:-1;5048:38:6;:26;4873:153;5065:8;5048:16;:26::i;:::-;:36;:38::i;:::-;-1:-1:-1;;;;;5036:50:6;;4660:433;-1:-1:-1;;;;;;4660:433:6:o;459:121:18:-;547:25;:15;:25;;459:121::o;4526:706:28:-;4607:16;;:::i;:::-;4657:1;4643:11;:15;4635:66;;;;-1:-1:-1;;;4635:66:28;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4715:14;4711:50;;-1:-1:-1;4738:23:28;;;;;;;;;-1:-1:-1;4738:23:28;;4731:30;;4711:50;-1:-1:-1;;;;;4776:24:28;;4772:454;;4816:14;4861:11;531:3;4834:23;;;4861:11;4833:39;;;;;;-1:-1:-1;;;;;;4894:21:28;;;4886:64;;;;;-1:-1:-1;;;4886:64:28;;;;;;;;;;;;;;;;;;;;;;;;;;;;4971:26;;;;;;;;4989:6;-1:-1:-1;;;;;4971:26:28;;;;4964:33;;;;;4772:454;5028:14;5045:45;5061:9;-1:-1:-1;;;5078:11:28;5045:15;:45::i;:::-;5028:62;-1:-1:-1;;;;;;5112:21:28;;;5104:64;;;;;-1:-1:-1;;;5104:64:28;;;;;;;;;;;;;;;;;;;;;;;;;;;4772:454;4526:706;;;;:::o;1694:237::-;1764:16;;:::i;:::-;1792:9;1823:6;;;:42;;-1:-1:-1;;1858:7:28;;-1:-1:-1;;;;;1833:32:28;1838:11;;;;1853:1;1838:11;1853:1;1833:21;;;;;:32;1823:42;1815:80;;;;;-1:-1:-1;;;1815:80:28;;;;;;;;;;;;;;;;;;;;;;;;;;;;1912:12;;;;;;;;;;;;;1694:237;-1:-1:-1;;;1694:237:28:o;1472:128::-;1571:7;531:3;1571:21;;1472:128::o;897:373:29:-;999:7;1019:9;1030;1043:13;1051:1;1054;1043:7;:13::i;:::-;1018:38;;;;1067:10;1093:1;1080:15;;;;;1090:1;1087;1080:15;1067:28;;1114:1;1109:2;:6;1105:18;;;1122:1;1117:6;;;;1105:18;1133:7;;;;;1155:6;1151:24;;1174:1;1170;:5;;;;;;1163:12;;;;;;;1151:24;1198:1;1194;:5;1186:44;;;;;-1:-1:-1;;;1186:44:29;;;;;;;;;;;;;;;;;;;;;;;;;;;;1247:16;1255:1;1258;1261;1247:7;:16::i;:::-;1240:23;897:373;-1:-1:-1;;;;;;;897:373:29:o;216:206::-;278:9;;;-1:-1:-1;;333:1:29;330;323:25;310:38;;366:1;362;:5;358:9;;386:1;381:2;:6;377:10;;406:1;401:2;:6;397:18;;;414:1;409:6;;;;397:18;216:206;;;;;;:::o;428:463::-;530:7;568:2;;;564:6;;;569:1;564:6;580:9;;;;;;;604:4;599:9;;;;;;;;;638:4;630;629:5;;628:14;;;;;685:1;:9;;;713:5;;;709:9;;704:14;737:5;;;733:9;;728:14;761:5;;;757:9;;752:14;785:5;;;781:9;;776:14;809:5;;;805:9;;800:14;833:5;;;829:9;;824:14;857:5;;;853:9;;848:14;;;628;;645:1;628:18;623:24;;;;618:29;;;;879:5;;428:463;-1:-1:-1;;428:463:29:o;-1:-1:-1:-;;;;;;;;;;;;;;:::o;:::-;;;;;;;;;;;;;;:::o", "source": "// SPDX-License-Identifier: GPL-3.0\npragma solidity =0.6.12;\n\nimport '@sonicswap/core/contracts/interfaces/IUniswapV2Factory.sol';\nimport '@sonicswap/core/contracts/interfaces/IUniswapV2Pair.sol';\nimport '@sonicswap/lib/contracts/libraries/FixedPoint.sol';\n\nimport '../libraries/SafeMath.sol';\nimport '../libraries/UniswapV2Library.sol';\nimport '../libraries/UniswapV2OracleLibrary.sol';\n\n// sliding window oracle that uses observations collected over a window to provide moving price averages in the past\n// `windowSize` with a precision of `windowSize / granularity`\n// note this is a singleton oracle and only needs to be deployed once per desired parameters, which\n// differs from the simple oracle which must be deployed once per pair.\ncontract ExampleSlidingWindowOracle {\n using FixedPoint for *;\n using SafeMath for uint;\n\n struct Observation {\n uint timestamp;\n uint price0Cumulative;\n uint price1Cumulative;\n }\n\n address public immutable factory;\n // the desired amount of time over which the moving average should be computed, e.g. 24 hours\n uint public immutable windowSize;\n // the number of observations stored for each pair, i.e. how many price observations are stored for the window.\n // as granularity increases from 1, more frequent updates are needed, but moving averages become more precise.\n // averages are computed over intervals with sizes in the range:\n // [windowSize - (windowSize / granularity) * 2, windowSize]\n // e.g. if the window size is 24 hours, and the granularity is 24, the oracle will return the average price for\n // the period:\n // [now - [22 hours, 24 hours], now]\n uint8 public immutable granularity;\n // this is redundant with granularity and windowSize, but stored for gas savings & informational purposes.\n uint public immutable periodSize;\n\n // mapping from pair address to a list of price observations of that pair\n mapping(address => Observation[]) public pairObservations;\n\n constructor(address factory_, uint windowSize_, uint8 granularity_) public {\n require(granularity_ > 1, 'SlidingWindowOracle: GRANULARITY');\n require(\n (periodSize = windowSize_ / granularity_) * granularity_ == windowSize_,\n 'SlidingWindowOracle: WINDOW_NOT_EVENLY_DIVISIBLE'\n );\n factory = factory_;\n windowSize = windowSize_;\n granularity = granularity_;\n }\n\n // returns the index of the observation corresponding to the given timestamp\n function observationIndexOf(uint timestamp) public view returns (uint8 index) {\n uint epochPeriod = timestamp / periodSize;\n return uint8(epochPeriod % granularity);\n }\n\n // returns the observation from the oldest epoch (at the beginning of the window) relative to the current time\n function getFirstObservationInWindow(address pair) private view returns (Observation storage firstObservation) {\n uint8 observationIndex = observationIndexOf(block.timestamp);\n // no overflow issue. if observationIndex + 1 overflows, result is still zero.\n uint8 firstObservationIndex = (observationIndex + 1) % granularity;\n firstObservation = pairObservations[pair][firstObservationIndex];\n }\n\n // update the cumulative price for the observation at the current timestamp. each observation is updated at most\n // once per epoch period.\n function update(address tokenA, address tokenB) external {\n address pair = UniswapV2Library.pairFor(factory, tokenA, tokenB);\n\n // populate the array with empty observations (first call only)\n for (uint i = pairObservations[pair].length; i < granularity; i++) {\n pairObservations[pair].push();\n }\n\n // get the observation for the current period\n uint8 observationIndex = observationIndexOf(block.timestamp);\n Observation storage observation = pairObservations[pair][observationIndex];\n\n // we only want to commit updates once per period (i.e. windowSize / granularity)\n uint timeElapsed = block.timestamp - observation.timestamp;\n if (timeElapsed > periodSize) {\n (uint price0Cumulative, uint price1Cumulative,) = UniswapV2OracleLibrary.currentCumulativePrices(pair);\n observation.timestamp = block.timestamp;\n observation.price0Cumulative = price0Cumulative;\n observation.price1Cumulative = price1Cumulative;\n }\n }\n\n // given the cumulative prices of the start and end of a period, and the length of the period, compute the average\n // price in terms of how much amount out is received for the amount in\n function computeAmountOut(\n uint priceCumulativeStart, uint priceCumulativeEnd,\n uint timeElapsed, uint amountIn\n ) private pure returns (uint amountOut) {\n // overflow is desired.\n FixedPoint.uq112x112 memory priceAverage = FixedPoint.uq112x112(\n uint224((priceCumulativeEnd - priceCumulativeStart) / timeElapsed)\n );\n amountOut = priceAverage.mul(amountIn).decode144();\n }\n\n // returns the amount out corresponding to the amount in for a given token using the moving average over the time\n // range [now - [windowSize, windowSize - periodSize * 2], now]\n // update must have been called for the bucket corresponding to timestamp `now - windowSize`\n function consult(address tokenIn, uint amountIn, address tokenOut) external view returns (uint amountOut) {\n address pair = UniswapV2Library.pairFor(factory, tokenIn, tokenOut);\n Observation storage firstObservation = getFirstObservationInWindow(pair);\n\n uint timeElapsed = block.timestamp - firstObservation.timestamp;\n require(timeElapsed <= windowSize, 'SlidingWindowOracle: MISSING_HISTORICAL_OBSERVATION');\n // should never happen.\n require(timeElapsed >= windowSize - periodSize * 2, 'SlidingWindowOracle: UNEXPECTED_TIME_ELAPSED');\n\n (uint price0Cumulative, uint price1Cumulative,) = UniswapV2OracleLibrary.currentCumulativePrices(pair);\n (address token0,) = UniswapV2Library.sortTokens(tokenIn, tokenOut);\n\n if (token0 == tokenIn) {\n return computeAmountOut(firstObservation.price0Cumulative, price0Cumulative, timeElapsed, amountIn);\n } else {\n return computeAmountOut(firstObservation.price1Cumulative, price1Cumulative, timeElapsed, amountIn);\n }\n }\n}\n", "sourcePath": "/var/www/Sonic/sonicswap-periphery/contracts/examples/ExampleSlidingWindowOracle.sol", "ast": { "absolutePath": "/var/www/Sonic/sonicswap-periphery/contracts/examples/ExampleSlidingWindowOracle.sol", "exportedSymbols": { "ExampleSlidingWindowOracle": [ 4751 ] }, "id": 4752, "license": "GPL-3.0", "nodeType": "SourceUnit", "nodes": [ { "id": 4397, "literals": [ "solidity", "=", "0.6", ".12" ], "nodeType": "PragmaDirective", "src": "36:24:6" }, { "absolutePath": "@sonicswap/core/contracts/interfaces/IUniswapV2Factory.sol", "file": "@sonicswap/core/contracts/interfaces/IUniswapV2Factory.sol", "id": 4398, "nodeType": "ImportDirective", "scope": 4752, "sourceUnit": 8112, "src": "62:68:6", "symbolAliases": [], "unitAlias": "" }, { "absolutePath": "@sonicswap/core/contracts/interfaces/IUniswapV2Pair.sol", "file": "@sonicswap/core/contracts/interfaces/IUniswapV2Pair.sol", "id": 4399, "nodeType": "ImportDirective", "scope": 4752, "sourceUnit": 8354, "src": "131:65:6", "symbolAliases": [], "unitAlias": "" }, { "absolutePath": "@sonicswap/lib/contracts/libraries/FixedPoint.sol", "file": "@sonicswap/lib/contracts/libraries/FixedPoint.sol", "id": 4400, "nodeType": "ImportDirective", "scope": 4752, "sourceUnit": 9464, "src": "197:59:6", "symbolAliases": [], "unitAlias": "" }, { "absolutePath": "/var/www/Sonic/sonicswap-periphery/contracts/libraries/SafeMath.sol", "file": "../libraries/SafeMath.sol", "id": 4401, "nodeType": "ImportDirective", "scope": 4752, "sourceUnit": 5609, "src": "258:35:6", "symbolAliases": [], "unitAlias": "" }, { "absolutePath": "/var/www/Sonic/sonicswap-periphery/contracts/libraries/UniswapV2Library.sol", "file": "../libraries/UniswapV2Library.sol", "id": 4402, "nodeType": "ImportDirective", "scope": 4752, "sourceUnit": 6081, "src": "294:43:6", "symbolAliases": [], "unitAlias": "" }, { "absolutePath": "/var/www/Sonic/sonicswap-periphery/contracts/libraries/UniswapV2OracleLibrary.sol", "file": "../libraries/UniswapV2OracleLibrary.sol", "id": 4403, "nodeType": "ImportDirective", "scope": 4752, "sourceUnit": 6654, "src": "338:49:6", "symbolAliases": [], "unitAlias": "" }, { "abstract": false, "baseContracts": [], "contractDependencies": [], "contractKind": "contract", "documentation": null, "fullyImplemented": true, "id": 4751, "linearizedBaseContracts": [ 4751 ], "name": "ExampleSlidingWindowOracle", "nodeType": "ContractDefinition", "nodes": [ { "id": 4405, "libraryName": { "contractScope": null, "id": 4404, "name": "FixedPoint", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 9463, "src": "789:10:6", "typeDescriptions": { "typeIdentifier": "t_contract$_FixedPoint_$9463", "typeString": "library FixedPoint" } }, "nodeType": "UsingForDirective", "src": "783:23:6", "typeName": null }, { "id": 4408, "libraryName": { "contractScope": null, "id": 4406, "name": "SafeMath", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 5608, "src": "817:8:6", "typeDescriptions": { "typeIdentifier": "t_contract$_SafeMath_$5608", "typeString": "library SafeMath" } }, "nodeType": "UsingForDirective", "src": "811:24:6", "typeName": { "id": 4407, "name": "uint", "nodeType": "ElementaryTypeName", "src": "830:4:6", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } } }, { "canonicalName": "ExampleSlidingWindowOracle.Observation", "id": 4415, "members": [ { "constant": false, "id": 4410, "mutability": "mutable", "name": "timestamp", "nodeType": "VariableDeclaration", "overrides": null, "scope": 4415, "src": "870:14:6", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 4409, "name": "uint", "nodeType": "ElementaryTypeName", "src": "870:4:6", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": null, "visibility": "internal" }, { "constant": false, "id": 4412, "mutability": "mutable", "name": "price0Cumulative", "nodeType": "VariableDeclaration", "overrides": null, "scope": 4415, "src": "894:21:6", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 4411, "name": "uint", "nodeType": "ElementaryTypeName", "src": "894:4:6", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": null, "visibility": "internal" }, { "constant": false, "id": 4414, "mutability": "mutable", "name": "price1Cumulative", "nodeType": "VariableDeclaration", "overrides": null, "scope": 4415, "src": "925:21:6", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 4413, "name": "uint", "nodeType": "ElementaryTypeName", "src": "925:4:6", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": null, "visibility": "internal" } ], "name": "Observation", "nodeType": "StructDefinition", "scope": 4751, "src": "841:112:6", "visibility": "public" }, { "constant": false, "functionSelector": "c45a0155", "id": 4417, "mutability": "immutable", "name": "factory", "nodeType": "VariableDeclaration", "overrides": null, "scope": 4751, "src": "959:32:6", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" }, "typeName": { "id": 4416, "name": "address", "nodeType": "ElementaryTypeName", "src": "959:7:6", "stateMutability": "nonpayable", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "value": null, "visibility": "public" }, { "constant": false, "functionSelector": "8a14117a", "id": 4419, "mutability": "immutable", "name": "windowSize", "nodeType": "VariableDeclaration", "overrides": null, "scope": 4751, "src": "1095:32:6", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 4418, "name": "uint", "nodeType": "ElementaryTypeName", "src": "1095:4:6", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": null, "visibility": "public" }, { "constant