@valueswap/v2-periphery
Version:
🎚 Peripheral smart contracts for interacting with Valueswap V2
458 lines • 473 kB
JSON
{
"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.6+commit.6c089d02\"},\"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\":{\"methods\":{}},\"userdoc\":{\"methods\":{}}},\"settings\":{\"compilationTarget\":{\"/Users/second/Documents/work/valueswap-v2-periphery/contracts/examples/ExampleSlidingWindowOracle.sol\":\"ExampleSlidingWindowOracle\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":999999},\"remappings\":[]},\"sources\":{\"/Users/second/Documents/work/valueswap-v2-periphery/contracts/examples/ExampleSlidingWindowOracle.sol\":{\"keccak256\":\"0x4bb51c1e536a781fceed675d3b5730d7fb6cce08349206af9695c8faef86a770\",\"urls\":[\"bzz-raw://1525402b3912ffb33fe9daecd4faa24fb7712c91ac3808a367b19a954c8c1d38\",\"dweb:/ipfs/QmdVokJ6Lc7HaRrEyBwaG6bUkjbbc3ATrFURG2WUpciMUu\"]},\"/Users/second/Documents/work/valueswap-v2-periphery/contracts/libraries/SafeMath.sol\":{\"keccak256\":\"0x27f0ea82f879b3b01387b583e6d9d0ec858dca3b22b0aad173f8fbda06e761e1\",\"urls\":[\"bzz-raw://0db9cf37793eb7035f0bfced36323d240f0212150009c39a3a108701d9b50b6c\",\"dweb:/ipfs/QmUAdiG9XNcieXkKfiMB49zQqD34FbXFE15csV2KQzwEqg\"]},\"/Users/second/Documents/work/valueswap-v2-periphery/contracts/libraries/ValueswapV2Library.sol\":{\"keccak256\":\"0xf676dcf67bcef334c141c95ae2c8328c76bcaf316edd882fe9bf960dc7887904\",\"urls\":[\"bzz-raw://37aa805cf7db173d7465a186acb5d9a958c8d1628c2335807c054e7864501dc5\",\"dweb:/ipfs/QmbZhcmRJkPLzsfMoNbeRZ8UKrqsjF86QNiZjsYyfxg9t6\"]},\"/Users/second/Documents/work/valueswap-v2-periphery/contracts/libraries/ValueswapV2OracleLibrary.sol\":{\"keccak256\":\"0x3a8a56b8e1d867cecffdb0ff2de6e9a293cc132dd9b2fbd54a8e1cd0eb14cf38\",\"urls\":[\"bzz-raw://892355f90888817408635e26a4c9514f1e18f1a57d7fdd492aef676644bde319\",\"dweb:/ipfs/QmNcMiLuFVHdnEgTSMubByZkzVu8hWjchR9SRKQe7j53TQ\"]},\"@valueswap/lib/contracts/libraries/Babylonian.sol\":{\"keccak256\":\"0xeb1c2a281a00f4660775f75ccfa1e51fbe1d75f86aeb9d0d297151ecdb900177\",\"urls\":[\"bzz-raw://68515f0265381bddfb1d1356ea10ce4e5784276fc09f197fcdcedfa5c75cc069\",\"dweb:/ipfs/QmXWVVPnuJwRUAu3Qpu1s7Fyc5WPQxmZPczVEe5cJ5wVHZ\"]},\"@valueswap/lib/contracts/libraries/BitMath.sol\":{\"keccak256\":\"0x19f84d5268286794b44939ec0d85b3c6f59e133f826cdbd9e40112fc94919bb7\",\"urls\":[\"bzz-raw://d21c67ed58cf667d052e141df2fba76c46c159edcc45eb897c908c20c69d2727\",\"dweb:/ipfs/QmUyKz1992wgR8nYAzBuQzjBAKMxLAN3hTgzpYJxusbmVH\"]},\"@valueswap/lib/contracts/libraries/FixedPoint.sol\":{\"keccak256\":\"0xc3a39b8a11715cea45ad9f67f50e4e4c33778c1124acd59e90daf064c9a93974\",\"urls\":[\"bzz-raw://2c6c3cdcdb30caa5d15477550003b5dbb174cb2c0be3c012af030fce3d043f28\",\"dweb:/ipfs/QmWh3n5g6zq3umJcURnKCFhhif2c8yb6mKczFjfoCNLC3g\"]},\"@valueswap/lib/contracts/libraries/FullMath.sol\":{\"keccak256\":\"0xc4ffcf28169f73fc9fdd1f82345d6d4fcccf3fd5aea83c133437c25e4e0950a9\",\"urls\":[\"bzz-raw://c9257a47501005f0a648bc4801ef4abc33843681aaf03a6d0c43d46b69e37407\",\"dweb:/ipfs/QmciHvDrqhxs5fjsrm9aNq29FZXpunMn17n2wWj83Zsh3B\"]},\"@valueswap/v2-core/contracts/interfaces/IValueswapV2Factory.sol\":{\"keccak256\":\"0xb460a829a001f806a64896c88b0094dfc6f0673e4511028258e901e5bf100fcc\",\"urls\":[\"bzz-raw://0c5d49debe3da0e52d459238afb9c9170c0c57b7985fb10ac08b501251095775\",\"dweb:/ipfs/QmdZBtyUdxSwN1wy99GhQHUBexQbQaPbaYWjqmjkLmHos7\"]},\"@valueswap/v2-core/contracts/interfaces/IValueswapV2Pair.sol\":{\"keccak256\":\"0x4899f60670cbc336cd8f5fefb631d6ce27ae4226ad4aac5d0963cd23db2fc36a\",\"urls\":[\"bzz-raw://7aa68c3572d1a4713c4af9ba99dd1907a9dc5a104273dab86e1d02797f6b1dd6\",\"dweb:/ipfs/QmXq89Vb6D4XeA2PDqNy13VkNeevTJePCrLF7KUHkver4q\"]}},\"version\":1}",
"bytecode": "0x61010060405234801561001157600080fd5b506040516113963803806113968339818101604052606081101561003457600080fd5b5080516020820151604090920151909190600160ff82161161009d576040805162461bcd60e51b815260206004820181905260248201527f536c6964696e6757696e646f774f7261636c653a204752414e554c4152495459604482015290519081900360640190fd5b8160ff82168082816100ab57fe5b0460e081905202146100ee5760405162461bcd60e51b81526004018080602001828103825260308152602001806113666030913960400191505060405180910390fd5b606083901b6001600160601b03191660805260a082905260f881901b7fff000000000000000000000000000000000000000000000000000000000000001660c05260e0516001600160a01b039093169260ff909116906111c761019f600039806102f7528061059452806105e752806106475250806101f452806104d752806106135280610766525080610218528061027e528061031b525080610242528061045c528061048552506111c76000f3fe608060405234801561001057600080fd5b50600436106100885760003560e01c8063c45a01551161005b578063c45a01551461015f578063c640752d14610190578063dbaad32f146101cd578063e4463eb2146101ea57610088565b8063556f0dc71461008d5780638a14117a146100ab5780638c86f1e4146100c5578063bfcc8e4214610108575b600080fd5b6100956101f2565b6040805160ff9092168252519081900360200190f35b6100b3610216565b60408051918252519081900360200190f35b6100b3600480360360608110156100db57600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81358116916020810135916040909101351661023a565b6101416004803603604081101561011e57600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813516906020013561041b565b60408051938452602084019290925282820152519081900360600190f35b61016761045a565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b6101cb600480360360408110156101a657600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135811691602001351661047e565b005b610095600480360360208110156101e357600080fd5b50356105e2565b6100b3610645565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b6000806102687f00000000000000000000000000000000000000000000000000000000000000008685610669565b9050600061027582610754565b805490915042037f00000000000000000000000000000000000000000000000000000000000000008111156102f5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260338152602001806110e66033913960400191505060405180910390fd5b7f00000000000000000000000000000000000000000000000000000000000000006002027f000000000000000000000000000000000000000000000000000000000000000003811015610393576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c815260200180611119602c913960400191505060405180910390fd5b60008061039f856107fc565b509150915060006103b08a89610a83565b5090508973ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610404576103f7856001015484868c610bd6565b9650505050505050610414565b6103f7856002015483868c610bd6565b9392505050565b6000602052816000526040600020818154811061043457fe5b600091825260209091206003909102018054600182015460029092015490935090915083565b7f000000000000000000000000000000000000000000000000000000000000000081565b60006104ab7f00000000000000000000000000000000000000000000000000000000000000008484610669565b73ffffffffffffffffffffffffffffffffffffffff81166000908152602081905260409020549091505b7f000000000000000000000000000000000000000000000000000000000000000060ff168110156105365773ffffffffffffffffffffffffffffffffffffffff821660009081526020819052604081208054600190810182559152016104d5565b506000610542426105e2565b73ffffffffffffffffffffffffffffffffffffffff831660009081526020819052604081208054929350909160ff841690811061057b57fe5b60009182526020909120600390910201805490915042037f00000000000000000000000000000000000000000000000000000000000000008111156105da576000806105c6866107fc565b504286556001860191909155600285015550505b505050505050565b6000807f0000000000000000000000000000000000000000000000000000000000000000838161060e57fe5b0490507f000000000000000000000000000000000000000000000000000000000000000060ff16818161063d57fe5b069392505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b60008060006106788585610a83565b604080517fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606094851b811660208084019190915293851b81166034830152825160288184030181526048830184528051908501207fff0000000000000000000000000000000000000000000000000000000000000060688401529a90941b9093166069840152607d8301989098527ff27fee3fc000c2148077e3c1de2bfc88ca0e8881a5c9fbb18615dc16f0cc1b75609d808401919091528851808403909101815260bd909201909752805196019590952095945050505050565b600080610760426105e2565b905060007f000000000000000000000000000000000000000000000000000000000000000060ff168260010160ff168161079657fe5b0690506000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208160ff16815481106107e557fe5b906000526020600020906003020192505050919050565b6000806000610809610c49565b90508373ffffffffffffffffffffffffffffffffffffffff16635909c0d56040518163ffffffff1660e01b815260040160206040518083038186803b15801561085157600080fd5b505afa158015610865573d6000803e3d6000fd5b505050506040513d602081101561087b57600080fd5b5051604080517f5a3d5493000000000000000000000000000000000000000000000000000000008152905191945073ffffffffffffffffffffffffffffffffffffffff861691635a3d549391600480820192602092909190829003018186803b1580156108e757600080fd5b505afa1580156108fb573d6000803e3d6000fd5b505050506040513d602081101561091157600080fd5b5051604080517f0902f1ac00000000000000000000000000000000000000000000000000000000815290519193506000918291829173ffffffffffffffffffffffffffffffffffffffff891691630902f1ac916004808301926060929190829003018186803b15801561098357600080fd5b505afa158015610997573d6000803e3d6000fd5b505050506040513d60608110156109ad57600080fd5b5080516020820151604090920151909450909250905063ffffffff80821690851614610a795780840363ffffffff81166109fa6dffffffffffffffffffffffffffff808616908716610c53565b600001517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1602870196508063ffffffff16610a52856dffffffffffffffffffffffffffff16856dffffffffffffffffffffffffffff16610c53565b517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff16029590950194505b5050509193909250565b6000808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161415610b0b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602781526020018061116b6027913960400191505060405180910390fd5b8273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1610610b45578284610b48565b83835b909250905073ffffffffffffffffffffffffffffffffffffffff8216610bcf57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f56616c75657377617056324c6962726172793a205a45524f5f41444452455353604482015290519081900360640190fd5b9250929050565b6000610be06110c0565b60405180602001604052808588880381610bf657fe5b047bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1690529050610c2b610c268285610e68565b610f2b565b71ffffffffffffffffffffffffffffffffffff169695505050505050565b63ffffffff421690565b610c5b6110c0565b60008211610cb4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806111456026913960400191505060405180910390fd5b82610cce5750604080516020810190915260008152610e62565b71ffffffffffffffffffffffffffffffffffff8311610db957600082607085901b81610cf657fe5b0490507bffffffffffffffffffffffffffffffffffffffffffffffffffffffff811115610d8457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f4669786564506f696e743a3a6672616374696f6e3a206f766572666c6f770000604482015290519081900360640190fd5b6040518060200160405280827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff16815250915050610e62565b6000610dd5846e01000000000000000000000000000085610f32565b90507bffffffffffffffffffffffffffffffffffffffffffffffffffffffff811115610d8457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f4669786564506f696e743a3a6672616374696f6e3a206f766572666c6f770000604482015290519081900360640190fd5b92915050565b610e706110d2565b6000821580610eab57505082517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1682810290838281610ea857fe5b04145b610f1657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f4669786564506f696e743a3a6d756c3a206f766572666c6f7700000000000000604482015290519081900360640190fd5b60408051602081019091529081529392505050565b5160701c90565b6000806000610f418686611005565b9150915060008480610f4f57fe5b868809905082811115610f63576001820391505b918290039181610f8157848381610f7657fe5b049350505050610414565b848210610fef57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f46756c6c4d6174683a2046554c4c4449565f4f564552464c4f57000000000000604482015290519081900360640190fd5b610ffa838387611050565b979650505050505050565b600080807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff84860990508385029250828103915082811015611048576001820391505b509250929050565b6000818103821680838161106057fe5b04925080858161106c57fe5b04945080816000038161107b57fe5b60028581038087028203028087028203028087028203028087028203028087028203028087028203029586029003909402930460010193909302939093010292915050565b60408051602081019091526000815290565b604051806020016040528060008152509056fe536c6964696e6757696e646f774f7261636c653a204d495353494e475f484953544f524943414c5f4f42534552564154494f4e536c6964696e6757696e646f774f7261636c653a20554e45585045435445445f54494d455f454c41505345444669786564506f696e743a3a6672616374696f6e3a206469766973696f6e206279207a65726f56616c75657377617056324c6962726172793a204944454e544943414c5f414444524553534553a2646970667358221220ebf69c90830f2e0560c371ab09d4648a76465beb4cfbc5d22c85de5fdc3eb1e264736f6c63430006060033536c6964696e6757696e646f774f7261636c653a2057494e444f575f4e4f545f4556454e4c595f444956495349424c45",
"deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100885760003560e01c8063c45a01551161005b578063c45a01551461015f578063c640752d14610190578063dbaad32f146101cd578063e4463eb2146101ea57610088565b8063556f0dc71461008d5780638a14117a146100ab5780638c86f1e4146100c5578063bfcc8e4214610108575b600080fd5b6100956101f2565b6040805160ff9092168252519081900360200190f35b6100b3610216565b60408051918252519081900360200190f35b6100b3600480360360608110156100db57600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81358116916020810135916040909101351661023a565b6101416004803603604081101561011e57600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813516906020013561041b565b60408051938452602084019290925282820152519081900360600190f35b61016761045a565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b6101cb600480360360408110156101a657600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135811691602001351661047e565b005b610095600480360360208110156101e357600080fd5b50356105e2565b6100b3610645565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b6000806102687f00000000000000000000000000000000000000000000000000000000000000008685610669565b9050600061027582610754565b805490915042037f00000000000000000000000000000000000000000000000000000000000000008111156102f5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260338152602001806110e66033913960400191505060405180910390fd5b7f00000000000000000000000000000000000000000000000000000000000000006002027f000000000000000000000000000000000000000000000000000000000000000003811015610393576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c815260200180611119602c913960400191505060405180910390fd5b60008061039f856107fc565b509150915060006103b08a89610a83565b5090508973ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610404576103f7856001015484868c610bd6565b9650505050505050610414565b6103f7856002015483868c610bd6565b9392505050565b6000602052816000526040600020818154811061043457fe5b600091825260209091206003909102018054600182015460029092015490935090915083565b7f000000000000000000000000000000000000000000000000000000000000000081565b60006104ab7f00000000000000000000000000000000000000000000000000000000000000008484610669565b73ffffffffffffffffffffffffffffffffffffffff81166000908152602081905260409020549091505b7f000000000000000000000000000000000000000000000000000000000000000060ff168110156105365773ffffffffffffffffffffffffffffffffffffffff821660009081526020819052604081208054600190810182559152016104d5565b506000610542426105e2565b73ffffffffffffffffffffffffffffffffffffffff831660009081526020819052604081208054929350909160ff841690811061057b57fe5b60009182526020909120600390910201805490915042037f00000000000000000000000000000000000000000000000000000000000000008111156105da576000806105c6866107fc565b504286556001860191909155600285015550505b505050505050565b6000807f0000000000000000000000000000000000000000000000000000000000000000838161060e57fe5b0490507f000000000000000000000000000000000000000000000000000000000000000060ff16818161063d57fe5b069392505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b60008060006106788585610a83565b604080517fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606094851b811660208084019190915293851b81166034830152825160288184030181526048830184528051908501207fff0000000000000000000000000000000000000000000000000000000000000060688401529a90941b9093166069840152607d8301989098527ff27fee3fc000c2148077e3c1de2bfc88ca0e8881a5c9fbb18615dc16f0cc1b75609d808401919091528851808403909101815260bd909201909752805196019590952095945050505050565b600080610760426105e2565b905060007f000000000000000000000000000000000000000000000000000000000000000060ff168260010160ff168161079657fe5b0690506000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208160ff16815481106107e557fe5b906000526020600020906003020192505050919050565b6000806000610809610c49565b90508373ffffffffffffffffffffffffffffffffffffffff16635909c0d56040518163ffffffff1660e01b815260040160206040518083038186803b15801561085157600080fd5b505afa158015610865573d6000803e3d6000fd5b505050506040513d602081101561087b57600080fd5b5051604080517f5a3d5493000000000000000000000000000000000000000000000000000000008152905191945073ffffffffffffffffffffffffffffffffffffffff861691635a3d549391600480820192602092909190829003018186803b1580156108e757600080fd5b505afa1580156108fb573d6000803e3d6000fd5b505050506040513d602081101561091157600080fd5b5051604080517f0902f1ac00000000000000000000000000000000000000000000000000000000815290519193506000918291829173ffffffffffffffffffffffffffffffffffffffff891691630902f1ac916004808301926060929190829003018186803b15801561098357600080fd5b505afa158015610997573d6000803e3d6000fd5b505050506040513d60608110156109ad57600080fd5b5080516020820151604090920151909450909250905063ffffffff80821690851614610a795780840363ffffffff81166109fa6dffffffffffffffffffffffffffff808616908716610c53565b600001517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1602870196508063ffffffff16610a52856dffffffffffffffffffffffffffff16856dffffffffffffffffffffffffffff16610c53565b517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff16029590950194505b5050509193909250565b6000808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161415610b0b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602781526020018061116b6027913960400191505060405180910390fd5b8273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1610610b45578284610b48565b83835b909250905073ffffffffffffffffffffffffffffffffffffffff8216610bcf57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f56616c75657377617056324c6962726172793a205a45524f5f41444452455353604482015290519081900360640190fd5b9250929050565b6000610be06110c0565b60405180602001604052808588880381610bf657fe5b047bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1690529050610c2b610c268285610e68565b610f2b565b71ffffffffffffffffffffffffffffffffffff169695505050505050565b63ffffffff421690565b610c5b6110c0565b60008211610cb4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806111456026913960400191505060405180910390fd5b82610cce5750604080516020810190915260008152610e62565b71ffffffffffffffffffffffffffffffffffff8311610db957600082607085901b81610cf657fe5b0490507bffffffffffffffffffffffffffffffffffffffffffffffffffffffff811115610d8457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f4669786564506f696e743a3a6672616374696f6e3a206f766572666c6f770000604482015290519081900360640190fd5b6040518060200160405280827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff16815250915050610e62565b6000610dd5846e01000000000000000000000000000085610f32565b90507bffffffffffffffffffffffffffffffffffffffffffffffffffffffff811115610d8457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f4669786564506f696e743a3a6672616374696f6e3a206f766572666c6f770000604482015290519081900360640190fd5b92915050565b610e706110d2565b6000821580610eab57505082517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1682810290838281610ea857fe5b04145b610f1657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f4669786564506f696e743a3a6d756c3a206f766572666c6f7700000000000000604482015290519081900360640190fd5b60408051602081019091529081529392505050565b5160701c90565b6000806000610f418686611005565b9150915060008480610f4f57fe5b868809905082811115610f63576001820391505b918290039181610f8157848381610f7657fe5b049350505050610414565b848210610fef57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f46756c6c4d6174683a2046554c4c4449565f4f564552464c4f57000000000000604482015290519081900360640190fd5b610ffa838387611050565b979650505050505050565b600080807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff84860990508385029250828103915082811015611048576001820391505b509250929050565b6000818103821680838161106057fe5b04925080858161106c57fe5b04945080816000038161107b57fe5b60028581038087028203028087028203028087028203028087028203028087028203028087028203029586029003909402930460010193909302939093010292915050565b60408051602081019091526000815290565b604051806020016040528060008152509056fe536c6964696e6757696e646f774f7261636c653a204d495353494e475f484953544f524943414c5f4f42534552564154494f4e536c6964696e6757696e646f774f7261636c653a20554e45585045435445445f54494d455f454c41505345444669786564506f696e743a3a6672616374696f6e3a206469766973696f6e206279207a65726f56616c75657377617056324c6962726172793a204944454e544943414c5f414444524553534553a2646970667358221220ebf69c90830f2e0560c371ab09d4648a76465beb4cfbc5d22c85de5fdc3eb1e264736f6c63430006060033",
"immutableReferences": {
"4315": [
{
"length": 32,
"start": 578
},
{
"length": 32,
"start": 1116
},
{
"length": 32,
"start": 1157
}
],
"4317": [
{
"length": 32,
"start": 536
},
{
"length": 32,
"start": 638
},
{
"length": 32,
"start": 795
}
],
"4319": [
{
"length": 32,
"start": 500
},
{
"length": 32,
"start": 1239
},
{
"length": 32,
"start": 1555
},
{
"length": 32,
"start": 1894
}
],
"4321": [
{
"length": 32,
"start": 759
},
{
"length": 32,
"start": 1428
},
{
"length": 32,
"start": 1511
},
{
"length": 32,
"start": 1607
}
]
},
"sourceMap": "718:5715:6:-:0;;;1989:427;5:9:-1;2:2;;;27:1;24;17:12;2:2;1989:427:6;;;;;;;;;;;;;;;15:2:-1;10:3;7:11;4:2;;;31:1;28;21:12;4:2;-1:-1;1989:427:6;;;;;;;;;;;;;;2097:1;2082:16;;;;2074:61;;;;;-1:-1:-1;;;2074:61:6;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2226:11;2166:56;;;;2226:11;2166:56;2180:26;;;;;2167:39;;;;2166:56;:71;2145:166;;;;-1:-1:-1;;;2145:166:6;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2321:18;;;;-1:-1:-1;;;;;;2321:18:6;;;2349:24;;;;2383:26;;;;;;;;718:5715;;-1:-1:-1;;;;;718:5715:6;;;;;;;;;;;;;;;;;;;",
"deployedSourceMap": "718:5715:6:-:0;;;;5:9:-1;2:2;;;27:1;24;17:12;2:2;718:5715:6;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;12:1:-1;9;2:12;1657:34:6;;;:::i;:::-;;;;;;;;;;;;;;;;;;;1072:32;;;:::i;:::-;;;;;;;;;;;;;;;;5363:1068;;;;;;15:2:-1;10:3;7:11;4:2;;;31:1;28;21:12;4:2;-1:-1;5363:1068:6;;;;;;;;;;;;;;;;;;:::i;1925:57::-;;;;;;15:2:-1;10:3;7:11;4:2;;;31:1;28;21:12;4:2;-1:-1;1925:57:6;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;936:32;;;:::i;:::-;;;;;;;;;;;;;;;;;;;3387:1054;;;;;;15:2:-1;10:3;7:11;4:2;;;31:1;28;21:12;4:2;-1:-1;3387:1054:6;;;;;;;;;;;:::i;:::-;;2503:185;;;;;;15:2:-1;10:3;7:11;4:2;;;31:1;28;21:12;4:2;-1:-1;2503:185:6;;:::i;1808:32::-;;;:::i;1657:34::-;;;:::o;1072:32::-;;;:::o;5363:1068::-;5453:14;5479:12;5494:54;5521:7;5530;5539:8;5494:26;:54::i;:::-;5479:69;;5558:36;5597:33;5625:4;5597:27;:33::i;:::-;5678:26;;5558:72;;-1:-1:-1;5660:15:6;:44;5737:10;5722:25;;;5714:89;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;5881:10;5894:1;5881:14;5868:10;:27;5853:11;:42;;5845:99;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;5956:21;5979;6005:54;6054:4;6005:48;:54::i;:::-;5955:104;;;;;6070:14;6089:48;6119:7;6128:8;6089:29;:48::i;:::-;6069:68;;;6162:7;6152:17;;:6;:17;;;6148:277;;;6192:92;6209:16;:33;;;6244:16;6262:11;6275:8;6192:16;:92::i;:::-;6185:99;;;;;;;;;;6148:277;6322:92;6339:16;:33;;;6374:16;6392:11;6405:8;6322:16;:92::i;5363:1068::-;;;;;;:::o;1925:57::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;1925:57:6;;-1:-1:-1;1925:57:6;:::o;936:32::-;;;:::o;3387:1054::-;3454:12;3469:51;3496:7;3505:6;3513;3469:26;:51::i;:::-;3617:22;;;3608:6;3617:22;;;;;;;;;;:29;3454:66;;-1:-1:-1;3603:121:6;3652:11;3648:15;;:1;:15;3603:121;;;3684:22;;;:16;:22;;;;;;;;;;27:10:-1;;3684:29:6;23:18:-1;;;45:23;;3684:29:6;;3665:3;3603:121;;;;3788:22;3813:35;3832:15;3813:18;:35::i;:::-;3892:22;;;3858:31;3892:22;;;;;;;;;;:40;;3788:60;;-1:-1:-1;3858:31:6;;3892:40;;;;;;;;;;;;;;;;;;;;;;;4070:21;;3892:40;;-1:-1:-1;4052:15:6;:39;4119:10;4105:24;;4101:334;;;4146:21;4169;4195:54;4244:4;4195:48;:54::i;:::-;-1:-1:-1;4287:15:6;4263:39;;4316:28;;;:47;;;;4377:28;;;:47;-1:-1:-1;;4101:334:6;3387:1054;;;;;;:::o;2503:185::-;2568:11;2591:16;2622:10;2610:9;:22;;;;;;2591:41;;2669:11;2655:25;;:11;:25;;;;;;;2503:185;-1:-1:-1;;;2503:185:6:o;1808:32::-;;;:::o;725:470:16:-;814:12;839:14;855;873:26;884:6;892;873:10;:26::i;:::-;1033:32;;;;;;;;;;;;;;;;;;;;;;;;;;;;;22::-1;26:21;;;22:32;6:49;;1033:32:16;;;;;1023:43;;;;;;939:246;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;26:21:-1;;;22:32;;;6:49;;939:246:16;;;;;;;929:257;;;;;;;;;725:470;-1:-1:-1;;;;;725:470:16:o;2809:425:6:-;2882:36;2930:22;2955:35;2974:15;2955:18;:35::i;:::-;2930:60;;3087:27;3142:11;3117:36;;3118:16;3137:1;3118:20;3117:36;;;;;;;;3087:66;;3182:16;:22;3199:4;3182:22;;;;;;;;;;;;;;;3205:21;3182:45;;;;;;;;;;;;;;;;;;;;3163:64;;2809:425;;;;;:::o;654:1046:17:-;738:21;761;784;834:23;:21;:23::i;:::-;817:40;;903:4;886:43;;;:45;;;;;;;;;;;;;;;;;;;;;;5:9:-1;2:2;;;27:1;24;17:12;2:2;886:45:17;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;886:45:17;;;;;;;15:2:-1;10:3;7:11;4:2;;;31:1;28;21:12;4:2;-1:-1;886:45:17;960;;;;;;;;886;;-1:-1:-1;960:43:17;;;;;;:45;;;;;886;;960;;;;;;;;:43;:45;;;2:2:-1;;;;27:1;24;17:12;2:2;960:45:17;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;960:45:17;;;;;;;15:2:-1;10:3;7:11;4:2;;;31:1;28;21:12;4:2;-1:-1;960:45:17;1182:36;;;;;;;;960:45;;-1:-1:-1;1117:16:17;;;;;;1182:34;;;;;;:36;;;;;;;;;;;;;;:34;:36;;;2:2:-1;;;;27:1;24;17:12;2:2;1182:36:17;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;1182:36:17;;;;;;;15:2:-1;10:3;7:11;4:2;;;31:1;28;21:12;4:2;-1:-1;1182:36:17;;;;;;;;;;;;;-1:-1:-1;1182:36:17;;-1:-1:-1;1182:36:17;-1:-1:-1;1232:36:17;;;;;;;;1228:466;;1352:35;;;1495:62;;;1500:39;;;;;;;;:19;:39::i;:::-;:42;;;1495:48;;:62;1475:82;;;;1672:11;1621:62;;1626:39;1646:8;1626:39;;1656:8;1626:39;;:19;:39::i;:::-;:42;1621:48;;:62;1601:82;;;;;-1:-1:-1;1228:466:17;654:1046;;;;;;;;:::o;287:349:16:-;362:14;378;422:6;412:16;;:6;:16;;;;404:68;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;510:6;501:15;;:6;:15;;;:53;;539:6;547;501:53;;;520:6;528;501:53;482:72;;-1:-1:-1;482:72:16;-1:-1:-1;572:20:16;;;564:65;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;287:349;;;;;:::o;4641:433:6:-;4796:14;4854:40;;:::i;:::-;4897:110;;;;;;;;4985:11;4961:20;4940:18;:41;4939:57;;;;;;4897:110;;;;4854:153;-1:-1:-1;5029:38:6;:26;4854:153;5046:8;5029:16;:26::i;:::-;:36;:38::i;:::-;5017:50;;;4641:433;-1:-1:-1;;;;;;4641:433:6:o;430:121:17:-;518:25;:15;:25;;430:121::o;4526:706:24:-;4607:16;;:::i;:::-;4657:1;4643:11;:15;4635:66;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4715:14;4711:50;;-1:-1:-1;4738:23:24;;;;;;;;;-1:-1:-1;4738:23:24;;4731:30;;4711:50;4776:24;;;4772:454;;4816:14;4861:11;531:3;4834:23;;;4861:11;4833:39;;;;;;-1:-1:-1;4894:21:24;;;;4886:64;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4971:26;;;;;;;;4989:6;4971:26;;;;;4964:33;;;;;4772:454;5028:14;5045:45;5061:9;571:31;5078:11;5045:15;:45::i;:::-;5028:62;-1:-1:-1;5112:21:24;;;;5104:64;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4772:454;4526:706;;;;:::o;1694:237::-;1764:16;;:::i;:::-;1792:9;1823:6;;;:42;;-1:-1:-1;;1858:7:24;;1833:32;;1838:11;;;;1853:1;1838:11;1853:1;1833:21;;;;;:32;1823:42;1815:80;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1912:12;;;;;;;;;;;;;1694:237;-1:-1:-1;;;1694:237:24:o;1472:128::-;1571:7;531:3;1571:21;;1472:128::o;897:373:25:-;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1247:16;1255:1;1258;1261;1247:7;:16::i;:::-;1240:23;897:373;-1:-1:-1;;;;;;;897:373:25:o;216:206::-;278:9;;;344:2;333:1;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:25:o;718:5715:6:-;;;;;;;;;;-1:-1:-1;718:5715:6;;;:::o;:::-;;;;;;;;;;;;;;:::o",
"source": "pragma solidity =0.6.6;\n\nimport '@valueswap/v2-core/contracts/interfaces/IValueswapV2Factory.sol';\nimport '@valueswap/v2-core/contracts/interfaces/IValueswapV2Pair.sol';\nimport '@valueswap/lib/contracts/libraries/FixedPoint.sol';\n\nimport '../libraries/SafeMath.sol';\nimport '../libraries/ValueswapV2Library.sol';\nimport '../libraries/ValueswapV2OracleLibrary.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 = ValueswapV2Library.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,) = ValueswapV2OracleLibrary.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 = ValueswapV2Library.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,) = ValueswapV2OracleLibrary.currentCumulativePrices(pair);\n (address token0,) = ValueswapV2Library.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": "/Users/second/Documents/work/valueswap-v2-periphery/contracts/examples/ExampleSlidingWindowOracle.sol",
"ast": {
"absolutePath": "/Users/second/Documents/work/valueswap-v2-periphery/contracts/examples/ExampleSlidingWindowOracle.sol",
"exportedSymbols": {
"ExampleSlidingWindowOracle": [
4649
]
},
"id": 4650,
"nodeType": "SourceUnit",
"nodes": [
{
"id": 4295,
"literals": [
"solidity",
"=",
"0.6",
".6"
],
"nodeType": "PragmaDirective",
"src": "0:23:6"
},
{
"absolutePath": "@valueswap/v2-core/contracts/interfaces/IValueswapV2Factory.sol",
"file": "@valueswap/v2-core/contracts/interfaces/IValueswapV2Factory.sol",
"id": 4296,
"nodeType": "ImportDirective",
"scope": 4650,
"sourceUnit": 9117,
"src": "25:73:6",
"symbolAliases": [],
"unitAlias": ""
},
{
"absolutePath": "@valueswap/v2-core/contracts/interfaces/IValueswapV2Pair.sol",
"file": "@valueswap/v2-core/contracts/interfaces/IValueswapV2Pair.sol",
"id": 4297,
"nodeType": "ImportDirective",
"scope": 4650,
"sourceUnit": 9359,
"src": "99:70:6",
"symbolAliases": [],
"unitAlias": ""
},
{
"absolutePath": "@valueswap/lib/contracts/libraries/FixedPoint.sol",
"file": "@valueswap/lib/contracts/libraries/FixedPoint.sol",
"id": 4298,
"nodeType": "ImportDirective",
"scope": 4650,
"sourceUnit": 8659,
"src": "170:59:6",
"symbolAliases": [],
"unitAlias": ""
},
{
"absolutePath": "/Users/second/Documents/work/valueswap-v2-periphery/contracts/libraries/SafeMath.sol",
"file": "../libraries/SafeMath.sol",
"id": 4299,
"nodeType": "ImportDirective",
"scope": 4650,
"sourceUnit": 5582,
"src": "231:35:6",
"symbolAliases": [],
"unitAlias": ""
},
{
"absolutePath": "/Users/second/Documents/work/valueswap-v2-periphery/contracts/libraries/ValueswapV2Library.sol",
"file": "../libraries/ValueswapV2Library.sol",
"id": 4300,
"nodeType": "ImportDirective",
"scope": 4650,
"sourceUnit": 6054,
"src": "267:45:6",
"symbolAliases": [],
"unitAlias": ""
},
{
"absolutePath": "/Users/second/Documents/work/valueswap-v2-periphery/contracts/libraries/ValueswapV2OracleLibrary.sol",
"file": "../libraries/ValueswapV2OracleLibrary.sol",
"id": 4301,
"nodeType": "ImportDirective",
"scope": 4650,
"sourceUnit": 6161,
"src": "313:51:6",
"symbolAliases": [],
"unitAlias": ""
},
{
"abstract": false,
"baseContracts": [],
"contractDependencies": [],
"contractKind": "contract",
"documentation": null,
"fullyImplemented": true,
"id": 4649,
"linearizedBaseContracts": [
4649
],
"name": "ExampleSlidingWindowOracle",
"nodeType": "ContractDefinition",
"nodes": [
{
"id": 4303,
"libraryName": {
"contractScope": null,
"id": 4302,
"name": "FixedPoint",
"nodeType": "UserDefinedTypeName",
"referencedDeclaration": 8658,
"src": "766:10:6",
"typeDescriptions": {
"typeIdentifier": "t_contract$_FixedPoint_$8658",
"typeString": "library FixedPoint"
}
},
"nodeType": "UsingForDirective",
"src": "760:23:6",
"typeName": null
},
{
"id": 4306,
"libraryName": {
"contractScope": null,
"id": 4304,
"name": "SafeMath",
"nodeType": "UserDefinedTypeName",
"referencedDeclaration": 5581,
"src": "794:8:6",
"typeDescriptions": {
"typeIdentifier": "t_contract$_SafeMath_$5581",
"typeString": "library SafeMath"
}
},
"nodeType": "UsingForDirective",
"src": "788:24:6",
"typeName": {
"id": 4305,
"name": "uint",
"nodeType": "ElementaryTypeName",
"src": "807:4:6",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
}
},
{
"canonicalName": "ExampleSlidingWindowOracle.Observation",
"id": 4313,
"members": [
{
"constant": false,
"id": 4308,
"mutability": "mutable",
"name": "timestamp",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 4313,
"src": "847:14:6",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 4307,
"name": "uint",
"nodeType": "ElementaryTypeName",
"src": "847:4:6",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 4310,
"mutability": "mutable",
"name": "price0Cumulative",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 4313,
"src": "871:21:6",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 4309,
"name": "uint",
"nodeType": "ElementaryTypeName",
"src": "871:4:6",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,