@venusprotocol/oracle 1.5.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/artifacts/@chainlink/contracts/src/v0.8/interfaces/AggregatorInterface.sol/AggregatorInterface.dbg.json +1 -1
  2. package/artifacts/@chainlink/contracts/src/v0.8/interfaces/AggregatorV2V3Interface.sol/AggregatorV2V3Interface.dbg.json +1 -1
  3. package/artifacts/@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol/AggregatorV3Interface.dbg.json +1 -1
  4. package/artifacts/@openzeppelin/contracts/token/ERC20/ERC20.sol/ERC20.dbg.json +1 -1
  5. package/artifacts/@openzeppelin/contracts/token/ERC20/IERC20.sol/IERC20.dbg.json +1 -1
  6. package/artifacts/@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol/IERC20Metadata.dbg.json +1 -1
  7. package/artifacts/@openzeppelin/contracts/utils/Context.sol/Context.dbg.json +1 -1
  8. package/artifacts/@openzeppelin/contracts/utils/math/SafeCast.sol/SafeCast.dbg.json +1 -1
  9. package/artifacts/@openzeppelin/contracts/utils/math/SafeMath.sol/SafeMath.dbg.json +1 -1
  10. package/artifacts/@openzeppelin/contracts/utils/math/SignedMath.sol/SignedMath.dbg.json +1 -1
  11. package/artifacts/@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol/OwnableUpgradeable.dbg.json +1 -1
  12. package/artifacts/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol/Initializable.dbg.json +1 -1
  13. package/artifacts/@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol/PausableUpgradeable.dbg.json +1 -1
  14. package/artifacts/@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol/AddressUpgradeable.dbg.json +1 -1
  15. package/artifacts/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol/ContextUpgradeable.dbg.json +1 -1
  16. package/artifacts/build-info/1d7bedd9b14544f287811332b9a539d7.json +1 -0
  17. package/artifacts/build-info/{96c10bfc915caedc90a237abc802c96d.json → 57da5d39a9f98618d0dcf1f6d4ff6b0d.json} +1 -1
  18. package/artifacts/build-info/f6af69795174616b8b4a6373f9f1c538.json +1 -0
  19. package/artifacts/contracts/PriceOracle.sol/PriceOracle.dbg.json +1 -1
  20. package/artifacts/contracts/ResilientOracle.sol/ResilientOracle.dbg.json +1 -1
  21. package/artifacts/contracts/ResilientOracle.sol/ResilientOracle.json +2 -2
  22. package/artifacts/contracts/interfaces/FeedRegistryInterface.sol/FeedRegistryInterface.dbg.json +1 -1
  23. package/artifacts/contracts/interfaces/OracleInterface.sol/BoundValidatorInterface.dbg.json +1 -1
  24. package/artifacts/contracts/interfaces/OracleInterface.sol/OracleInterface.dbg.json +1 -1
  25. package/artifacts/contracts/interfaces/OracleInterface.sol/ResilientOracleInterface.dbg.json +1 -1
  26. package/artifacts/contracts/interfaces/OracleInterface.sol/TwapInterface.dbg.json +1 -1
  27. package/artifacts/contracts/interfaces/PythInterface.sol/AbstractPyth.dbg.json +1 -1
  28. package/artifacts/contracts/interfaces/PythInterface.sol/IPyth.dbg.json +1 -1
  29. package/artifacts/contracts/interfaces/PythInterface.sol/PythStructs.dbg.json +1 -1
  30. package/artifacts/contracts/interfaces/VBep20Interface.sol/VBep20Interface.dbg.json +1 -1
  31. package/artifacts/contracts/libraries/PancakeLibrary.sol/FixedPoint.dbg.json +1 -1
  32. package/artifacts/contracts/libraries/PancakeLibrary.sol/FixedPoint.json +2 -2
  33. package/artifacts/contracts/libraries/PancakeLibrary.sol/IPancakePair.dbg.json +1 -1
  34. package/artifacts/contracts/libraries/PancakeLibrary.sol/PancakeOracleLibrary.dbg.json +1 -1
  35. package/artifacts/contracts/libraries/PancakeLibrary.sol/PancakeOracleLibrary.json +2 -2
  36. package/artifacts/contracts/oracles/BinanceOracle.sol/BinanceOracle.dbg.json +1 -1
  37. package/artifacts/contracts/oracles/BinanceOracle.sol/BinanceOracle.json +2 -2
  38. package/artifacts/contracts/oracles/BoundValidator.sol/BoundValidator.dbg.json +1 -1
  39. package/artifacts/contracts/oracles/BoundValidator.sol/BoundValidator.json +3 -3
  40. package/artifacts/contracts/oracles/ChainlinkOracle.sol/ChainlinkOracle.dbg.json +1 -1
  41. package/artifacts/contracts/oracles/ChainlinkOracle.sol/ChainlinkOracle.json +2 -2
  42. package/artifacts/contracts/oracles/PythOracle.sol/PythOracle.dbg.json +1 -1
  43. package/artifacts/contracts/oracles/PythOracle.sol/PythOracle.json +2 -2
  44. package/artifacts/contracts/oracles/TwapOracle.sol/TwapOracle.dbg.json +1 -1
  45. package/artifacts/contracts/oracles/TwapOracle.sol/TwapOracle.json +2 -2
  46. package/artifacts/contracts/oracles/mocks/MockBinanceFeedRegistry.sol/MockBinanceFeedRegistry.dbg.json +1 -1
  47. package/artifacts/contracts/oracles/mocks/MockBinanceOracle.sol/MockBinanceOracle.dbg.json +1 -1
  48. package/artifacts/contracts/oracles/mocks/MockBinanceOracle.sol/MockBinanceOracle.json +2 -2
  49. package/artifacts/contracts/oracles/mocks/MockChainlinkOracle.sol/MockChainlinkOracle.dbg.json +1 -1
  50. package/artifacts/contracts/oracles/mocks/MockChainlinkOracle.sol/MockChainlinkOracle.json +2 -2
  51. package/artifacts/contracts/oracles/mocks/MockPythOracle.sol/MockPythOracle.dbg.json +1 -1
  52. package/artifacts/contracts/oracles/mocks/MockPythOracle.sol/MockPythOracle.json +2 -2
  53. package/artifacts/contracts/oracles/mocks/MockTwapOracle.sol/MockTwapOracle.dbg.json +1 -1
  54. package/artifacts/contracts/oracles/mocks/MockTwapOracle.sol/MockTwapOracle.json +2 -2
  55. package/artifacts/contracts/test/BEP20Harness.sol/BEP20Harness.dbg.json +1 -1
  56. package/artifacts/contracts/test/MockPyth.sol/MockPyth.dbg.json +1 -1
  57. package/artifacts/contracts/test/MockPyth.sol/MockPyth.json +2 -2
  58. package/artifacts/contracts/test/MockSimpleOracle.sol/MockBoundValidator.dbg.json +1 -1
  59. package/artifacts/contracts/test/MockSimpleOracle.sol/MockBoundValidator.json +2 -2
  60. package/artifacts/contracts/test/MockSimpleOracle.sol/MockSimpleOracle.dbg.json +1 -1
  61. package/artifacts/contracts/test/MockSimpleOracle.sol/MockSimpleOracle.json +2 -2
  62. package/artifacts/contracts/test/MockV3Aggregator.sol/MockV3Aggregator.dbg.json +1 -1
  63. package/artifacts/contracts/test/MockV3Aggregator.sol/MockV3Aggregator.json +2 -2
  64. package/artifacts/contracts/test/PancakePairHarness.sol/Math.dbg.json +1 -1
  65. package/artifacts/contracts/test/PancakePairHarness.sol/Math.json +2 -2
  66. package/artifacts/contracts/test/PancakePairHarness.sol/PancakePairHarness.dbg.json +1 -1
  67. package/artifacts/contracts/test/PancakePairHarness.sol/PancakePairHarness.json +2 -2
  68. package/artifacts/contracts/test/PancakePairHarness.sol/UQ112x112.dbg.json +1 -1
  69. package/artifacts/contracts/test/PancakePairHarness.sol/UQ112x112.json +2 -2
  70. package/artifacts/contracts/test/VBEP20Harness.sol/VBEP20Harness.dbg.json +1 -1
  71. package/contracts/PriceOracle.sol +2 -2
  72. package/contracts/ResilientOracle.sol +127 -114
  73. package/contracts/libraries/PancakeLibrary.sol +8 -8
  74. package/contracts/oracles/BinanceOracle.sol +4 -4
  75. package/contracts/oracles/BoundValidator.sol +31 -29
  76. package/contracts/oracles/ChainlinkOracle.sol +85 -83
  77. package/contracts/oracles/PythOracle.sol +41 -41
  78. package/contracts/oracles/TwapOracle.sol +67 -67
  79. package/contracts/oracles/mocks/MockBinanceOracle.sol +4 -4
  80. package/contracts/oracles/mocks/MockChainlinkOracle.sol +4 -4
  81. package/contracts/oracles/mocks/MockPythOracle.sol +4 -4
  82. package/contracts/oracles/mocks/MockTwapOracle.sol +4 -4
  83. package/contracts/test/MockPyth.sol +13 -13
  84. package/contracts/test/MockSimpleOracle.sol +8 -8
  85. package/contracts/test/MockV3Aggregator.sol +18 -18
  86. package/contracts/test/PancakePairHarness.sol +10 -10
  87. package/deploy/1-deploy-oracles.d.ts +1 -3
  88. package/deploy/1-deploy-oracles.d.ts.map +1 -1
  89. package/deploy/1-deploy-oracles.js +13 -3
  90. package/deploy/1-deploy-oracles.js.map +1 -1
  91. package/deploy/2-configure-feeds.d.ts +1 -3
  92. package/deploy/2-configure-feeds.d.ts.map +1 -1
  93. package/deploy/2-configure-feeds.js +101 -87
  94. package/deploy/2-configure-feeds.js.map +1 -1
  95. package/deployments/bsctestnet/BinanceOracle.json +42 -29
  96. package/deployments/bsctestnet/BinanceOracle_Implementation.json +96 -23
  97. package/deployments/bsctestnet/BinanceOracle_Proxy.json +28 -28
  98. package/deployments/bsctestnet/BoundValidator.json +65 -39
  99. package/deployments/bsctestnet/BoundValidator_Implementation.json +113 -35
  100. package/deployments/bsctestnet/BoundValidator_Proxy.json +37 -37
  101. package/deployments/bsctestnet/ChainlinkOracle.json +64 -38
  102. package/deployments/bsctestnet/ChainlinkOracle_Implementation.json +122 -41
  103. package/deployments/bsctestnet/ChainlinkOracle_Proxy.json +37 -37
  104. package/deployments/bsctestnet/DefaultProxyAdmin.json +15 -15
  105. package/deployments/bsctestnet/PythOracle.json +71 -45
  106. package/deployments/bsctestnet/PythOracle_Implementation.json +128 -44
  107. package/deployments/bsctestnet/PythOracle_Proxy.json +44 -44
  108. package/deployments/bsctestnet/ResilientOracle.json +67 -54
  109. package/deployments/bsctestnet/ResilientOracle_Implementation.json +161 -63
  110. package/deployments/bsctestnet/ResilientOracle_Proxy.json +39 -39
  111. package/deployments/bsctestnet/TwapOracle.json +74 -71
  112. package/deployments/bsctestnet/TwapOracle_Implementation.json +163 -93
  113. package/deployments/bsctestnet/TwapOracle_Proxy.json +37 -41
  114. package/deployments/bsctestnet/solcInputs/6153c675ce838eebb6442d63350712be.json +144 -0
  115. package/package.json +4 -2
  116. package/deployments/bsctestnet/solcInputs/09bc2981019c6dcce653b90bac585fe0.json +0 -81
  117. package/deployments/bsctestnet/solcInputs/5dedb37ab8105f1f71e53a3f865859c5.json +0 -57
  118. package/deployments/bsctestnet/solcInputs/bb71c6049f6b7b21a6581f40daf802bc.json +0 -138
@@ -1,6 +1,22 @@
1
1
  {
2
- "address": "0x6C6d8723f2dF765431c0493D088974a482424030",
2
+ "address": "0x84f720794Aa082B544dAe237DD87311e21eac1B2",
3
3
  "abi": [
4
+ {
5
+ "inputs": [
6
+ {
7
+ "internalType": "address",
8
+ "name": "vBnbAddress",
9
+ "type": "address"
10
+ },
11
+ {
12
+ "internalType": "address",
13
+ "name": "wBnbAddress",
14
+ "type": "address"
15
+ }
16
+ ],
17
+ "stateMutability": "nonpayable",
18
+ "type": "constructor"
19
+ },
4
20
  {
5
21
  "anonymous": false,
6
22
  "inputs": [
@@ -249,13 +265,7 @@
249
265
  "type": "function"
250
266
  },
251
267
  {
252
- "inputs": [
253
- {
254
- "internalType": "address",
255
- "name": "WBNB_",
256
- "type": "address"
257
- }
258
- ],
268
+ "inputs": [],
259
269
  "name": "initialize",
260
270
  "outputs": [],
261
271
  "stateMutability": "nonpayable",
@@ -267,33 +277,14 @@
267
277
  "internalType": "address",
268
278
  "name": "",
269
279
  "type": "address"
270
- }
271
- ],
272
- "name": "newObservations",
273
- "outputs": [
274
- {
275
- "internalType": "uint256",
276
- "name": "timestamp",
277
- "type": "uint256"
278
280
  },
279
281
  {
280
282
  "internalType": "uint256",
281
- "name": "acc",
282
- "type": "uint256"
283
- }
284
- ],
285
- "stateMutability": "view",
286
- "type": "function"
287
- },
288
- {
289
- "inputs": [
290
- {
291
- "internalType": "address",
292
283
  "name": "",
293
- "type": "address"
284
+ "type": "uint256"
294
285
  }
295
286
  ],
296
- "name": "oldObservations",
287
+ "name": "observations",
297
288
  "outputs": [
298
289
  {
299
290
  "internalType": "uint256",
@@ -513,44 +504,95 @@
513
504
  ],
514
505
  "stateMutability": "nonpayable",
515
506
  "type": "function"
507
+ },
508
+ {
509
+ "inputs": [],
510
+ "name": "vBnb",
511
+ "outputs": [
512
+ {
513
+ "internalType": "address",
514
+ "name": "",
515
+ "type": "address"
516
+ }
517
+ ],
518
+ "stateMutability": "view",
519
+ "type": "function"
520
+ },
521
+ {
522
+ "inputs": [
523
+ {
524
+ "internalType": "address",
525
+ "name": "",
526
+ "type": "address"
527
+ }
528
+ ],
529
+ "name": "windowStart",
530
+ "outputs": [
531
+ {
532
+ "internalType": "uint256",
533
+ "name": "",
534
+ "type": "uint256"
535
+ }
536
+ ],
537
+ "stateMutability": "view",
538
+ "type": "function"
516
539
  }
517
540
  ],
518
- "transactionHash": "0x1b110d4ef41bb027a839f5dc247332c6c11b8ccef78043cfb4afa77d6f1e926d",
541
+ "transactionHash": "0xf6e5c7b71e8d6887c3e7c25fa2631d3285e5dfd879e12c246b0f461e279607d7",
519
542
  "receipt": {
520
543
  "to": null,
521
544
  "from": "0x2Ce1d0ffD7E869D9DF33e28552b12DdDed326706",
522
- "contractAddress": "0x6C6d8723f2dF765431c0493D088974a482424030",
523
- "transactionIndex": 5,
524
- "gasUsed": "1442162",
525
- "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
526
- "blockHash": "0xde275c5eb3974cc9493a3645e019ee4ac6bed6d10d03bcd3575ffde47ac65697",
527
- "transactionHash": "0x1b110d4ef41bb027a839f5dc247332c6c11b8ccef78043cfb4afa77d6f1e926d",
528
- "logs": [],
529
- "blockNumber": 24708545,
530
- "cumulativeGasUsed": "1837175",
545
+ "contractAddress": "0x84f720794Aa082B544dAe237DD87311e21eac1B2",
546
+ "transactionIndex": 1,
547
+ "gasUsed": "1633277",
548
+ "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
549
+ "blockHash": "0x5765185052da3ea194974c3debd03f56bee719186f58cb0e6bfe7c04e271b286",
550
+ "transactionHash": "0xf6e5c7b71e8d6887c3e7c25fa2631d3285e5dfd879e12c246b0f461e279607d7",
551
+ "logs": [
552
+ {
553
+ "transactionIndex": 1,
554
+ "blockNumber": 27096238,
555
+ "transactionHash": "0xf6e5c7b71e8d6887c3e7c25fa2631d3285e5dfd879e12c246b0f461e279607d7",
556
+ "address": "0x84f720794Aa082B544dAe237DD87311e21eac1B2",
557
+ "topics": ["0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498"],
558
+ "data": "0x00000000000000000000000000000000000000000000000000000000000000ff",
559
+ "logIndex": 3,
560
+ "blockHash": "0x5765185052da3ea194974c3debd03f56bee719186f58cb0e6bfe7c04e271b286"
561
+ }
562
+ ],
563
+ "blockNumber": 27096238,
564
+ "cumulativeGasUsed": "1820135",
531
565
  "status": 1,
532
566
  "byzantium": true
533
567
  },
534
- "args": [],
568
+ "args": ["0x2E7222e51c0f6e98610A1543Aa3836E092CDe62c", "0xae13d989daC2f0dEbFf460aC112a837C89BAa7cd"],
535
569
  "numDeployments": 1,
536
- "solcInputHash": "bb71c6049f6b7b21a6581f40daf802bc",
537
- "metadata": "{\"compiler\":{\"version\":\"0.8.13+commit.abaa5c0e\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"price\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldTimestamp\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newTimestamp\",\"type\":\"uint256\"}],\"name\":\"AnchorPriceUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"pancakePool\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"anchorPeriod\",\"type\":\"uint256\"}],\"name\":\"TokenConfigAdded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldTimestamp\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldAcc\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newTimestamp\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newAcc\",\"type\":\"uint256\"}],\"name\":\"TwapWindowUpdated\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"WBNB\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"bnbBaseUnit\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"busdBaseUnit\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"baseUnit\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"pancakePool\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"isBnbBased\",\"type\":\"bool\"},{\"internalType\":\"bool\",\"name\":\"isReversedPool\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"anchorPeriod\",\"type\":\"uint256\"}],\"internalType\":\"struct TokenConfig\",\"name\":\"config\",\"type\":\"tuple\"}],\"name\":\"currentCumulativePrice\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"expScale\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"vToken\",\"type\":\"address\"}],\"name\":\"getUnderlyingPrice\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"WBNB_\",\"type\":\"address\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"newObservations\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"timestamp\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"acc\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"oldObservations\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"timestamp\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"acc\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"prices\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"baseUnit\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"pancakePool\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"isBnbBased\",\"type\":\"bool\"},{\"internalType\":\"bool\",\"name\":\"isReversedPool\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"anchorPeriod\",\"type\":\"uint256\"}],\"internalType\":\"struct TokenConfig\",\"name\":\"config\",\"type\":\"tuple\"}],\"name\":\"setTokenConfig\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"baseUnit\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"pancakePool\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"isBnbBased\",\"type\":\"bool\"},{\"internalType\":\"bool\",\"name\":\"isReversedPool\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"anchorPeriod\",\"type\":\"uint256\"}],\"internalType\":\"struct TokenConfig[]\",\"name\":\"configs\",\"type\":\"tuple[]\"}],\"name\":\"setTokenConfigs\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"tokenConfigs\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"baseUnit\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"pancakePool\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"isBnbBased\",\"type\":\"bool\"},{\"internalType\":\"bool\",\"name\":\"isReversedPool\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"anchorPeriod\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"vToken\",\"type\":\"address\"}],\"name\":\"updateTwap\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"currentCumulativePrice((address,uint256,address,bool,bool,uint256))\":{\"returns\":{\"_0\":\"cumulative price of target token regardless of pair order\"}},\"getUnderlyingPrice(address)\":{\"params\":{\"vToken\":\"vToken address\"},\"returns\":{\"_0\":\"price in USD, with 18 decimals\"}},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"renounceOwnership()\":{\"details\":\"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.\"},\"setTokenConfig((address,uint256,address,bool,bool,uint256))\":{\"params\":{\"config\":\"token config struct\"}},\"setTokenConfigs((address,uint256,address,bool,bool,uint256)[])\":{\"params\":{\"configs\":\"config array\"}},\"transferOwnership(address)\":{\"details\":\"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.\"}},\"version\":1},\"userdoc\":{\"events\":{\"AnchorPriceUpdated(address,uint256,uint256,uint256)\":{\"notice\":\"Emit this event when TWAP price is updated\"},\"TokenConfigAdded(address,address,uint256)\":{\"notice\":\"Emit this event when new token configs are added\"},\"TwapWindowUpdated(address,uint256,uint256,uint256,uint256)\":{\"notice\":\"Emit this event when TWAP window is updated\"}},\"kind\":\"user\",\"methods\":{\"WBNB()\":{\"notice\":\"WBNB address\"},\"bnbBaseUnit()\":{\"notice\":\"the base unit of WBNB and BUSD, which are the paired tokens for all assets\"},\"currentCumulativePrice((address,uint256,address,bool,bool,uint256))\":{\"notice\":\"Fetches the current token/WBNB and token/BUSD price accumulator from pancakeswap.\"},\"getUnderlyingPrice(address)\":{\"notice\":\"Get the underlying TWAP price of input vToken\"},\"newObservations(address)\":{\"notice\":\"The current price observation of TWAP. With old and current observations we can calculate the TWAP between this range\"},\"oldObservations(address)\":{\"notice\":\"The old price observation of TWAP\"},\"prices(address)\":{\"notice\":\"Stored price by token\"},\"setTokenConfig((address,uint256,address,bool,bool,uint256))\":{\"notice\":\"Add single token configs\"},\"setTokenConfigs((address,uint256,address,bool,bool,uint256)[])\":{\"notice\":\"Add multiple token configs at the same time\"},\"tokenConfigs(address)\":{\"notice\":\"Configs by token\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/oracles/TwapOracle.sol\":\"TwapOracle\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../utils/ContextUpgradeable.sol\\\";\\nimport \\\"../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Contract module which provides a basic access control mechanism, where\\n * there is an account (an owner) that can be granted exclusive access to\\n * specific functions.\\n *\\n * By default, the owner account will be the one that deploys the contract. This\\n * can later be changed with {transferOwnership}.\\n *\\n * This module is used through inheritance. It will make available the modifier\\n * `onlyOwner`, which can be applied to your functions to restrict their use to\\n * the owner.\\n */\\nabstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {\\n address private _owner;\\n\\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Initializes the contract setting the deployer as the initial owner.\\n */\\n function __Ownable_init() internal onlyInitializing {\\n __Ownable_init_unchained();\\n }\\n\\n function __Ownable_init_unchained() internal onlyInitializing {\\n _transferOwnership(_msgSender());\\n }\\n\\n /**\\n * @dev Throws if called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n _checkOwner();\\n _;\\n }\\n\\n /**\\n * @dev Returns the address of the current owner.\\n */\\n function owner() public view virtual returns (address) {\\n return _owner;\\n }\\n\\n /**\\n * @dev Throws if the sender is not the owner.\\n */\\n function _checkOwner() internal view virtual {\\n require(owner() == _msgSender(), \\\"Ownable: caller is not the owner\\\");\\n }\\n\\n /**\\n * @dev Leaves the contract without owner. It will not be possible to call\\n * `onlyOwner` functions anymore. Can only be called by the current owner.\\n *\\n * NOTE: Renouncing ownership will leave the contract without an owner,\\n * thereby removing any functionality that is only available to the owner.\\n */\\n function renounceOwnership() public virtual onlyOwner {\\n _transferOwnership(address(0));\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual onlyOwner {\\n require(newOwner != address(0), \\\"Ownable: new owner is the zero address\\\");\\n _transferOwnership(newOwner);\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Internal function without access restriction.\\n */\\n function _transferOwnership(address newOwner) internal virtual {\\n address oldOwner = _owner;\\n _owner = newOwner;\\n emit OwnershipTransferred(oldOwner, newOwner);\\n }\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[49] private __gap;\\n}\\n\",\"keccak256\":\"0x247c62047745915c0af6b955470a72d1696ebad4352d7d3011aef1a2463cd888\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/utils/Initializable.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../../utils/AddressUpgradeable.sol\\\";\\n\\n/**\\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\\n *\\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\\n * reused. This mechanism prevents re-execution of each \\\"step\\\" but allows the creation of new initialization steps in\\n * case an upgrade adds a module that needs to be initialized.\\n *\\n * For example:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```\\n * contract MyToken is ERC20Upgradeable {\\n * function initialize() initializer public {\\n * __ERC20_init(\\\"MyToken\\\", \\\"MTK\\\");\\n * }\\n * }\\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\\n * function initializeV2() reinitializer(2) public {\\n * __ERC20Permit_init(\\\"MyToken\\\");\\n * }\\n * }\\n * ```\\n *\\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\\n *\\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\\n *\\n * [CAUTION]\\n * ====\\n * Avoid leaving a contract uninitialized.\\n *\\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```\\n * /// @custom:oz-upgrades-unsafe-allow constructor\\n * constructor() {\\n * _disableInitializers();\\n * }\\n * ```\\n * ====\\n */\\nabstract contract Initializable {\\n /**\\n * @dev Indicates that the contract has been initialized.\\n * @custom:oz-retyped-from bool\\n */\\n uint8 private _initialized;\\n\\n /**\\n * @dev Indicates that the contract is in the process of being initialized.\\n */\\n bool private _initializing;\\n\\n /**\\n * @dev Triggered when the contract has been initialized or reinitialized.\\n */\\n event Initialized(uint8 version);\\n\\n /**\\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\\n * `onlyInitializing` functions can be used to initialize parent contracts. Equivalent to `reinitializer(1)`.\\n */\\n modifier initializer() {\\n bool isTopLevelCall = !_initializing;\\n require(\\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\\n \\\"Initializable: contract is already initialized\\\"\\n );\\n _initialized = 1;\\n if (isTopLevelCall) {\\n _initializing = true;\\n }\\n _;\\n if (isTopLevelCall) {\\n _initializing = false;\\n emit Initialized(1);\\n }\\n }\\n\\n /**\\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\\n * used to initialize parent contracts.\\n *\\n * `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original\\n * initialization step. This is essential to configure modules that are added through upgrades and that require\\n * initialization.\\n *\\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\\n * a contract, executing them in the right order is up to the developer or operator.\\n */\\n modifier reinitializer(uint8 version) {\\n require(!_initializing && _initialized < version, \\\"Initializable: contract is already initialized\\\");\\n _initialized = version;\\n _initializing = true;\\n _;\\n _initializing = false;\\n emit Initialized(version);\\n }\\n\\n /**\\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\\n */\\n modifier onlyInitializing() {\\n require(_initializing, \\\"Initializable: contract is not initializing\\\");\\n _;\\n }\\n\\n /**\\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\\n * through proxies.\\n */\\n function _disableInitializers() internal virtual {\\n require(!_initializing, \\\"Initializable: contract is initializing\\\");\\n if (_initialized < type(uint8).max) {\\n _initialized = type(uint8).max;\\n emit Initialized(type(uint8).max);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x0203dcadc5737d9ef2c211d6fa15d18ebc3b30dfa51903b64870b01a062b0b4e\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary AddressUpgradeable {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x611aa3f23e59cfdd1863c536776407b3e33d695152a266fa7cfb34440a29a8a3\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\nimport \\\"../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract ContextUpgradeable is Initializable {\\n function __Context_init() internal onlyInitializing {\\n }\\n\\n function __Context_init_unchained() internal onlyInitializing {\\n }\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[50] private __gap;\\n}\\n\",\"keccak256\":\"0x963ea7f0b48b032eef72fe3a7582edf78408d6f834115b9feadd673a4d5bd149\",\"license\":\"MIT\"},\"contracts/interfaces/BEP20Interface.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity ^0.8.0;\\n\\ninterface BEP20Interface {\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the token decimals.\\n */\\n function decimals() external view returns (uint8);\\n\\n /**\\n * @dev Returns the token symbol.\\n */\\n function symbol() external view returns (string memory);\\n\\n /**\\n * @dev Returns the token name.\\n */\\n function name() external view returns (string memory);\\n\\n /**\\n * @dev Returns the bep token owner.\\n */\\n function getOwner() external view returns (address);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `recipient`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address recipient, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address _owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `sender` to `recipient` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address sender,\\n address recipient,\\n uint256 amount\\n ) external returns (bool);\\n\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n}\\n\",\"keccak256\":\"0x53aa6d0be81f26e962567f29e9a17f1b73205997c38c6c298e243ef923554c34\",\"license\":\"UNLICENSED\"},\"contracts/interfaces/OracleInterface.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity ^0.8.0;\\npragma experimental ABIEncoderV2;\\n\\ninterface OracleInterface {\\n function getUnderlyingPrice(address vToken) external view returns (uint256);\\n}\\n\\ninterface ResilientOracleInterface is OracleInterface {\\n function updatePrice(address vToken) external;\\n}\\n\\ninterface TwapInterface is OracleInterface {\\n function updateTwap(address vToken) external returns (uint256);\\n}\\n\\ninterface BoundValidatorInterface {\\n function validatePriceWithAnchorPrice(\\n address vToken,\\n uint256 reporterPrice,\\n uint256 anchorPrice\\n ) external view returns (bool);\\n}\\n\",\"keccak256\":\"0x474f40570a75a85caa03217fdef1646e22361ad430b0a67f51b2c038668c3836\",\"license\":\"UNLICENSED\"},\"contracts/interfaces/VBep20Interface.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity ^0.8.0;\\n\\nimport \\\"./BEP20Interface.sol\\\";\\n\\ninterface VBep20Interface is BEP20Interface {\\n /**\\n * @notice Underlying asset for this VToken\\n */\\n function underlying() external view returns (address);\\n}\\n\",\"keccak256\":\"0xf65bba1e926855bbe2796e061755df640fbae160c0fcbcd996087a24d8049a81\",\"license\":\"UNLICENSED\"},\"contracts/libraries/PancakeLibrary.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity ^0.8.0;\\n\\nlibrary FixedPoint {\\n // range: [0, 2**112 - 1]\\n // resolution: 1 / 2**112\\n struct uq112x112 {\\n uint224 _x;\\n }\\n\\n // returns a uq112x112 which represents the ratio of the numerator to the denominator\\n // equivalent to encode(numerator).div(denominator)\\n function fraction(uint112 numerator, uint112 denominator) internal pure returns (uq112x112 memory) {\\n require(denominator > 0, \\\"FixedPoint: DIV_BY_ZERO\\\");\\n return uq112x112((uint224(numerator) << 112) / denominator);\\n }\\n\\n // decode a uq112x112 into a uint with 18 decimals of precision\\n function decode112with18(uq112x112 memory self) internal pure returns (uint256) {\\n // we only have 256 - 224 = 32 bits to spare, so scaling up by ~60 bits is dangerous\\n // instead, get close to:\\n // (x * 1e18) >> 112\\n // without risk of overflowing, e.g.:\\n // (x) / 2 ** (112 - lg(1e18))\\n return uint256(self._x) / 5192296858534827;\\n }\\n}\\n\\n// library with helper methods for oracles that are concerned with computing average prices\\nlibrary PancakeOracleLibrary {\\n using FixedPoint for *;\\n\\n // helper function that returns the current block timestamp within the range of uint32, i.e. [0, 2**32 - 1]\\n function currentBlockTimestamp() internal view returns (uint32) {\\n return uint32(block.timestamp % 2**32);\\n }\\n\\n // produces the cumulative price using counterfactuals to save gas and avoid a call to sync.\\n function currentCumulativePrices(address pair)\\n internal\\n view\\n returns (\\n uint256 price0Cumulative,\\n uint256 price1Cumulative,\\n uint32 blockTimestamp\\n )\\n {\\n blockTimestamp = currentBlockTimestamp();\\n price0Cumulative = IPancakePair(pair).price0CumulativeLast();\\n price1Cumulative = IPancakePair(pair).price1CumulativeLast();\\n\\n // if time has elapsed since the last update on the pair, mock the accumulated price values\\n (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast) = IPancakePair(pair).getReserves();\\n if (blockTimestampLast != blockTimestamp) {\\n unchecked {\\n // subtraction overflow is desired\\n uint32 timeElapsed = blockTimestamp - blockTimestampLast;\\n // addition overflow is desired\\n // counterfactual\\n price0Cumulative += uint256(FixedPoint.fraction(reserve1, reserve0)._x) * timeElapsed;\\n // counterfactual\\n price1Cumulative += uint256(FixedPoint.fraction(reserve0, reserve1)._x) * timeElapsed;\\n }\\n }\\n }\\n}\\n\\ninterface IPancakePair {\\n function getReserves()\\n external\\n view\\n returns (\\n uint112 reserve0,\\n uint112 reserve1,\\n uint32 blockTimestampLast\\n );\\n\\n function price0CumulativeLast() external view returns (uint256);\\n\\n function price1CumulativeLast() external view returns (uint256);\\n}\\n\",\"keccak256\":\"0x4d2321303bb03aeb8eda73db2f04561ef89efb01ffb80019f1969b3c0c63de01\",\"license\":\"UNLICENSED\"},\"contracts/oracles/TwapOracle.sol\":{\"content\":\"// SPDX-License-Identifier: UNLICENSED\\npragma solidity ^0.8.0;\\npragma experimental ABIEncoderV2;\\n\\nimport \\\"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\\\";\\nimport \\\"../libraries/PancakeLibrary.sol\\\";\\nimport \\\"../interfaces/OracleInterface.sol\\\";\\nimport \\\"../interfaces/BEP20Interface.sol\\\";\\nimport \\\"../interfaces/VBep20Interface.sol\\\";\\n\\nstruct Observation {\\n uint256 timestamp;\\n uint256 acc;\\n}\\n\\nstruct TokenConfig {\\n /// @notice asset address, which can't be zero address and can be used for existance check\\n address asset;\\n /// @notice Decimals of underlying asset\\n uint256 baseUnit;\\n /// @notice The address of pancake pair\\n address pancakePool;\\n /// @notice Whether the token is paired with WBNB\\n bool isBnbBased;\\n /// @notice A flag identifies whether the pancake pair is reversed\\n /// e.g. XVS-WBNB is not reversed, while WBNB-XVS is.\\n bool isReversedPool;\\n /// @notice TWAP update period in second, which is the minimum time in seconds required to update TWAP window\\n uint256 anchorPeriod;\\n}\\n\\ncontract TwapOracle is OwnableUpgradeable, TwapInterface {\\n using FixedPoint for *;\\n\\n /// @notice WBNB address\\n address public WBNB;\\n\\n /// @notice the base unit of WBNB and BUSD, which are the paired tokens for all assets\\n uint256 public constant bnbBaseUnit = 1e18;\\n uint256 public constant busdBaseUnit = 1e18;\\n\\n uint256 public constant expScale = 1e18;\\n\\n /// @notice Configs by token\\n mapping(address => TokenConfig) public tokenConfigs;\\n\\n /// @notice The current price observation of TWAP. With old and current observations\\n /// we can calculate the TWAP between this range\\n mapping(address => Observation) public newObservations;\\n\\n /// @notice The old price observation of TWAP\\n mapping(address => Observation) public oldObservations;\\n\\n /// @notice Stored price by token\\n mapping(address => uint256) public prices;\\n\\n /// @notice Emit this event when TWAP window is updated\\n event TwapWindowUpdated(\\n address indexed asset,\\n uint256 oldTimestamp,\\n uint256 oldAcc,\\n uint256 newTimestamp,\\n uint256 newAcc\\n );\\n\\n /// @notice Emit this event when TWAP price is updated\\n event AnchorPriceUpdated(address indexed asset, uint256 price, uint256 oldTimestamp, uint256 newTimestamp);\\n\\n /// @notice Emit this event when new token configs are added\\n event TokenConfigAdded(address indexed asset, address indexed pancakePool, uint256 indexed anchorPeriod);\\n\\n modifier notNullAddress(address someone) {\\n require(someone != address(0), \\\"can't be zero address\\\");\\n _;\\n }\\n\\n function initialize(address WBNB_) public initializer {\\n __Ownable_init();\\n require(WBNB_ != address(0), \\\"WBNB can't be zero address\\\");\\n WBNB = WBNB_;\\n }\\n\\n /**\\n * @notice Add multiple token configs at the same time\\n * @param configs config array\\n */\\n function setTokenConfigs(TokenConfig[] memory configs) external onlyOwner {\\n require(configs.length > 0, \\\"length can't be 0\\\");\\n for (uint8 i = 0; i < configs.length; i++) {\\n setTokenConfig(configs[i]);\\n }\\n }\\n\\n /**\\n * @notice Add single token configs\\n * @param config token config struct\\n */\\n function setTokenConfig(TokenConfig memory config)\\n public\\n onlyOwner\\n notNullAddress(config.asset)\\n notNullAddress(config.pancakePool)\\n {\\n require(config.anchorPeriod > 0, \\\"anchor period must be positive\\\");\\n require(config.baseUnit > 0, \\\"base unit must be positive\\\");\\n uint256 cumulativePrice = currentCumulativePrice(config);\\n\\n // Initialize observation data\\n oldObservations[config.asset].timestamp = block.timestamp;\\n newObservations[config.asset].timestamp = block.timestamp;\\n oldObservations[config.asset].acc = cumulativePrice;\\n newObservations[config.asset].acc = cumulativePrice;\\n tokenConfigs[config.asset] = config;\\n emit TokenConfigAdded(config.asset, config.pancakePool, config.anchorPeriod);\\n }\\n\\n /**\\n * @notice Get the underlying TWAP price of input vToken\\n * @param vToken vToken address\\n * @return price in USD, with 18 decimals\\n */\\n function getUnderlyingPrice(address vToken) external view override returns (uint256) {\\n address asset = VBep20Interface(vToken).underlying();\\n require(tokenConfigs[asset].asset != address(0), \\\"asset not exist\\\");\\n\\n uint256 price = prices[asset];\\n\\n // if price is 0, it means the price hasn't been updated yet and it's meaningless, revert\\n require(price > 0, \\\"TWAP price must be positive\\\");\\n\\n BEP20Interface underlyingToken = BEP20Interface(VBep20Interface(vToken).underlying());\\n return (price * (10**(18 - underlyingToken.decimals())));\\n }\\n\\n /**\\n * @notice Fetches the current token/WBNB and token/BUSD price accumulator from pancakeswap.\\n * @return cumulative price of target token regardless of pair order\\n */\\n function currentCumulativePrice(TokenConfig memory config) public view returns (uint256) {\\n (uint256 price0, uint256 price1, ) = PancakeOracleLibrary.currentCumulativePrices(config.pancakePool);\\n if (config.isReversedPool) {\\n return price1;\\n } else {\\n return price0;\\n }\\n }\\n\\n function updateTwap(address vToken) public returns (uint256) {\\n address asset = VBep20Interface(vToken).underlying();\\n require(tokenConfigs[asset].asset != address(0), \\\"asset not exist\\\");\\n // Update & fetch WBNB price first, so we can calculate the price of WBNB paired token\\n if (asset != WBNB && tokenConfigs[asset].isBnbBased) {\\n require(tokenConfigs[WBNB].asset != address(0), \\\"WBNB not exist\\\");\\n _updateTwapInternal(tokenConfigs[WBNB]);\\n }\\n return _updateTwapInternal(tokenConfigs[asset]);\\n }\\n\\n /**\\n * @notice Fetches the current token/BUSD price from PancakeSwap, with 18 decimals of precision.\\n * @return price in USD, with 18 decimals\\n */\\n function _updateTwapInternal(TokenConfig memory config) internal virtual returns (uint256) {\\n // pokeWindowValues already handled reversed pool cases,\\n // priceAverage will always be Token/BNB or Token/BUSD TWAP price.\\n (uint256 nowCumulativePrice, uint256 oldCumulativePrice, uint256 oldTimestamp) = pokeWindowValues(config);\\n\\n // This should be impossible, but better safe than sorry\\n require(block.timestamp > oldTimestamp, \\\"now must come after before\\\");\\n uint256 timeElapsed = block.timestamp - oldTimestamp;\\n\\n // Calculate Pancakge TWAP\\n FixedPoint.uq112x112 memory priceAverage = FixedPoint.uq112x112(\\n uint224((nowCumulativePrice - oldCumulativePrice) / timeElapsed)\\n );\\n // TWAP price with 1e18 decimal mantissa\\n uint256 priceAverageMantissa = priceAverage.decode112with18();\\n\\n // To cancel the decimals in cumulative price, we need to mulitply the average price with\\n // tokenBaseUnit / (wbnbBaseUnit or busdBaseUnit, which is 1e18)\\n uint256 pairedTokenBaseUnit = config.isBnbBased ? bnbBaseUnit : busdBaseUnit;\\n uint256 anchorPriceMantissa = (priceAverageMantissa * config.baseUnit) / pairedTokenBaseUnit;\\n\\n // if this token is paired with BNB, convert its price to USD\\n if (config.isBnbBased) {\\n uint256 bnbPrice = prices[WBNB];\\n require(bnbPrice != 0, \\\"bnb price is invalid\\\");\\n anchorPriceMantissa = (anchorPriceMantissa * bnbPrice) / bnbBaseUnit;\\n }\\n\\n require(anchorPriceMantissa != 0, \\\"twap price cannot be 0\\\");\\n\\n emit AnchorPriceUpdated(config.asset, anchorPriceMantissa, oldTimestamp, block.timestamp);\\n\\n // save anchor price, which is 1e18 decimals\\n prices[config.asset] = anchorPriceMantissa;\\n\\n return anchorPriceMantissa;\\n }\\n\\n /**\\n * @notice Update new and old observations of lagging window if period elapsed.\\n * @return cumulative price & old observation\\n */\\n function pokeWindowValues(TokenConfig memory config)\\n internal\\n returns (\\n uint256,\\n uint256,\\n uint256\\n )\\n {\\n uint256 cumulativePrice = currentCumulativePrice(config);\\n\\n Observation memory newObservation = newObservations[config.asset];\\n\\n // Update new and old observations if elapsed time is greater than or equal to anchor period\\n uint256 timeElapsed = block.timestamp - newObservation.timestamp;\\n if (timeElapsed >= config.anchorPeriod) {\\n oldObservations[config.asset].timestamp = newObservation.timestamp;\\n oldObservations[config.asset].acc = newObservation.acc;\\n\\n newObservations[config.asset].timestamp = block.timestamp;\\n newObservations[config.asset].acc = cumulativePrice;\\n emit TwapWindowUpdated(\\n config.asset,\\n newObservation.timestamp,\\n block.timestamp,\\n newObservation.acc,\\n cumulativePrice\\n );\\n }\\n return (cumulativePrice, oldObservations[config.asset].acc, oldObservations[config.asset].timestamp);\\n }\\n}\\n\",\"keccak256\":\"0x921d5016d8e1bb6bdc3bbce6de6045bd01d8af26a94260a9c0536f439a2adf28\",\"license\":\"UNLICENSED\"}},\"version\":1}",
538
- "bytecode": "0x608060405234801561001057600080fd5b50611921806100206000396000f3fe608060405234801561001057600080fd5b506004361061010b5760003560e01c80638da5cb5b116100a2578063cbf6791911610071578063cbf6791914610296578063cfed246b146102a9578063f2fde38b146102c9578063fc57d4df146102dc578063fe16e80c146102ef57600080fd5b80638da5cb5b1461024b5780638dd9500214610270578063b8a8a626146101e5578063c4d66de81461028357600080fd5b806369aa3ac6116100de57806369aa3ac6146101e5578063715018a6146101f4578063725068a5146101fc5780638cea8c261461020f57600080fd5b80631b69dc5f14610110578063234a3446146101af5780632b9d9dea146101c4578063609f0f36146101e5575b600080fd5b61016861011e366004611408565b60666020526000908152604090208054600182015460028301546003909301546001600160a01b0392831693919282169160ff600160a01b8204811692600160a81b909204169086565b604080516001600160a01b03978816815260208101969096529390951692840192909252151560608301521515608082015260a081019190915260c0015b60405180910390f35b6101c26101bd366004611519565b610316565b005b6101d76101d23660046115c9565b6103b2565b6040519081526020016101a6565b6101d7670de0b6b3a764000081565b6101c26103e1565b6101d761020a366004611408565b6103f5565b61023661021d366004611408565b6067602052600090815260409020805460019091015482565b604080519283526020830191909152016101a6565b6033546001600160a01b03165b6040516001600160a01b0390911681526020016101a6565b606554610258906001600160a01b031681565b6101c2610291366004611408565b61065a565b6101c26102a43660046115c9565b6107dc565b6101d76102b7366004611408565b60696020526000908152604090205481565b6101c26102d7366004611408565b610a4b565b6101d76102ea366004611408565b610ac4565b6102366102fd366004611408565b6068602052600090815260409020805460019091015482565b61031e610cdc565b60008151116103685760405162461bcd60e51b815260206004820152601160248201527006c656e6774682063616e2774206265203607c1b60448201526064015b60405180910390fd5b60005b81518160ff1610156103ae5761039c828260ff168151811061038f5761038f6115e5565b60200260200101516107dc565b806103a681611611565b91505061036b565b5050565b60008060006103c48460400151610d36565b50915091508360800151156103da579392505050565b5092915050565b6103e9610cdc565b6103f36000610ede565b565b600080826001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa158015610436573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061045a9190611630565b6001600160a01b03808216600090815260666020526040902054919250166104b65760405162461bcd60e51b815260206004820152600f60248201526e185cdcd95d081b9bdd08195e1a5cdd608a1b604482015260640161035f565b6065546001600160a01b038281169116148015906104f657506001600160a01b038116600090815260666020526040902060020154600160a01b900460ff165b156105d7576065546001600160a01b03908116600090815260666020526040902054166105565760405162461bcd60e51b815260206004820152600e60248201526d15d09390881b9bdd08195e1a5cdd60921b604482015260640161035f565b6065546001600160a01b03908116600090815260666020908152604091829020825160c08101845281548516815260018201549281019290925260028101549384169282019290925260ff600160a01b8404811615156060830152600160a81b909304909216151560808301526003015460a08201526105d590610f30565b505b6001600160a01b03808216600090815260666020908152604091829020825160c08101845281548516815260018201549281019290925260028101549384169282019290925260ff600160a01b8404811615156060830152600160a81b909304909216151560808301526003015460a082015261065390610f30565b9392505050565b600054610100900460ff161580801561067a5750600054600160ff909116105b806106945750303b158015610694575060005460ff166001145b6106f75760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b606482015260840161035f565b6000805460ff19166001179055801561071a576000805461ff0019166101001790555b610722611170565b6001600160a01b0382166107785760405162461bcd60e51b815260206004820152601a60248201527f57424e422063616e2774206265207a65726f2061646472657373000000000000604482015260640161035f565b606580546001600160a01b0319166001600160a01b03841617905580156103ae576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15050565b6107e4610cdc565b80516001600160a01b0381166108345760405162461bcd60e51b815260206004820152601560248201527463616e2774206265207a65726f206164647265737360581b604482015260640161035f565b60408201516001600160a01b0381166108875760405162461bcd60e51b815260206004820152601560248201527463616e2774206265207a65726f206164647265737360581b604482015260640161035f565b60008360a00151116108db5760405162461bcd60e51b815260206004820152601e60248201527f616e63686f7220706572696f64206d75737420626520706f7369746976650000604482015260640161035f565b600083602001511161092f5760405162461bcd60e51b815260206004820152601a60248201527f6261736520756e6974206d75737420626520706f736974697665000000000000604482015260640161035f565b600061093a846103b2565b84516001600160a01b03908116600090815260686020818152604080842042908190558a51861685526067808452828620919091558a518616855292825280842060019081018790558a51861685529282528084208301869055895185168452606682528084208a5181549087166001600160a01b031990911681178255928b015193810193909355808a015160028401805460608d015160808e01511515600160a81b0260ff60a81b19911515600160a01b026001600160a81b03199093169490991693841791909117169690961790955560a08a0151600390930183905551949550909390917f3cc8d9cb9370a23a8b9ffa75efa24cecb65c4693980e58260841adc474983c5f91a450505050565b610a53610cdc565b6001600160a01b038116610ab85760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161035f565b610ac181610ede565b50565b600080826001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa158015610b05573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b299190611630565b6001600160a01b0380821660009081526066602052604090205491925016610b855760405162461bcd60e51b815260206004820152600f60248201526e185cdcd95d081b9bdd08195e1a5cdd608a1b604482015260640161035f565b6001600160a01b03811660009081526069602052604090205480610beb5760405162461bcd60e51b815260206004820152601b60248201527f54574150207072696365206d75737420626520706f7369746976650000000000604482015260640161035f565b6000846001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa158015610c2b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c4f9190611630565b9050806001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610c8f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cb3919061164d565b610cbe906012611670565b610cc990600a611777565b610cd39083611786565b95945050505050565b6033546001600160a01b031633146103f35760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161035f565b6000806000610d4361119f565b9050836001600160a01b0316635909c0d56040518163ffffffff1660e01b8152600401602060405180830381865afa158015610d83573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610da791906117a5565b9250836001600160a01b0316635a3d54936040518163ffffffff1660e01b8152600401602060405180830381865afa158015610de7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e0b91906117a5565b91506000806000866001600160a01b0316630902f1ac6040518163ffffffff1660e01b8152600401606060405180830381865afa158015610e50573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e7491906117d5565b9250925092508363ffffffff168163ffffffff1614610ed45780840363ffffffff8116610ea184866111b5565b516001600160e01b031602969096019563ffffffff8116610ec285856111b5565b516001600160e01b0316029590950194505b5050509193909250565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600080600080610f3f85611267565b925092509250804211610f945760405162461bcd60e51b815260206004820152601a60248201527f6e6f77206d75737420636f6d65206166746572206265666f7265000000000000604482015260640161035f565b6000610fa08242611825565b905060006040518060200160405280838688610fbc9190611825565b610fc69190611852565b6001600160e01b0316905290506000610fde826113a3565b905060008860600151610ff957670de0b6b3a7640000611003565b670de0b6b3a76400005b90506000818a60200151846110189190611786565b6110229190611852565b90508960600151156110b1576065546001600160a01b0316600090815260696020526040812054908190036110905760405162461bcd60e51b8152602060048201526014602482015273189b98881c1c9a58d9481a5cc81a5b9d985b1a5960621b604482015260640161035f565b670de0b6b3a76400006110a38284611786565b6110ad9190611852565b9150505b806000036110fa5760405162461bcd60e51b81526020600482015260166024820152750747761702070726963652063616e6e6f7420626520360541b604482015260640161035f565b89516040805183815260208101899052428183015290516001600160a01b03909216917f7d881580fb2bb7844e8ecf8df26510247c4bbea2735d40bf0d9ac33c0d9acd819181900360600190a298516001600160a01b031660009081526069602052604090208990555096979650505050505050565b600054610100900460ff166111975760405162461bcd60e51b815260040161035f90611866565b6103f36113c3565b60006111b0640100000000426118b1565b905090565b6040805160208101909152600081526000826001600160701b03161161121d5760405162461bcd60e51b815260206004820152601760248201527f4669786564506f696e743a204449565f42595f5a45524f000000000000000000604482015260640161035f565b6040805160208101909152806112536001600160701b0385166dffffffffffffffffffffffffffff60701b607088901b166118c5565b6001600160e01b0316905290505b92915050565b600080600080611276856103b2565b85516001600160a01b0316600090815260676020908152604080832081518083019092528054808352600190910154928201929092529293506112b99042611825565b90508660a00151811061136e57815187516001600160a01b0390811660009081526068602090815260408083209490945580860180518c51851684528584206001908101919091558c51851684526067835285842042908190558d518616855293869020018890558b5187519151865192835292820193909352938401526060830186905216907f87208a84ec7402c933c70c261e53b733a9f1c893d73e941a152435d58177a2649060800160405180910390a25b505084516001600160a01b03908116600090815260686020526040808220600101549751909216815220549095909350915050565b8051600090611261906612725dd1d243ab906001600160e01b0316611852565b600054610100900460ff166113ea5760405162461bcd60e51b815260040161035f90611866565b6103f333610ede565b6001600160a01b0381168114610ac157600080fd5b60006020828403121561141a57600080fd5b8135610653816113f3565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff8111828210171561146457611464611425565b604052919050565b8035801515811461147c57600080fd5b919050565b600060c0828403121561149357600080fd5b60405160c0810181811067ffffffffffffffff821117156114b6576114b6611425565b60405290508082356114c7816113f3565b81526020838101359082015260408301356114e1816113f3565b60408201526114f26060840161146c565b60608201526115036080840161146c565b608082015260a083013560a08201525092915050565b6000602080838503121561152c57600080fd5b823567ffffffffffffffff8082111561154457600080fd5b818501915085601f83011261155857600080fd5b81358181111561156a5761156a611425565b611578848260051b0161143b565b818152848101925060c091820284018501918883111561159757600080fd5b938501935b828510156115bd576115ae8986611481565b8452938401939285019261159c565b50979650505050505050565b600060c082840312156115db57600080fd5b6106538383611481565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600060ff821660ff8103611627576116276115fb565b60010192915050565b60006020828403121561164257600080fd5b8151610653816113f3565b60006020828403121561165f57600080fd5b815160ff8116811461065357600080fd5b600060ff821660ff84168082101561168a5761168a6115fb565b90039392505050565b600181815b808511156116ce5781600019048211156116b4576116b46115fb565b808516156116c157918102915b93841c9390800290611698565b509250929050565b6000826116e557506001611261565b816116f257506000611261565b816001811461170857600281146117125761172e565b6001915050611261565b60ff841115611723576117236115fb565b50506001821b611261565b5060208310610133831016604e8410600b8410161715611751575081810a611261565b61175b8383611693565b806000190482111561176f5761176f6115fb565b029392505050565b600061065360ff8416836116d6565b60008160001904831182151516156117a0576117a06115fb565b500290565b6000602082840312156117b757600080fd5b5051919050565b80516001600160701b038116811461147c57600080fd5b6000806000606084860312156117ea57600080fd5b6117f3846117be565b9250611801602085016117be565b9150604084015163ffffffff8116811461181a57600080fd5b809150509250925092565b600082821015611837576118376115fb565b500390565b634e487b7160e01b600052601260045260246000fd5b6000826118615761186161183c565b500490565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b6000826118c0576118c061183c565b500690565b60006001600160e01b03838116806118df576118df61183c565b9216919091049291505056fea26469706673582212200a09a418732861daead22dd2fb3160185d565d9e6aef8995fc4fc61d520bd67964736f6c634300080d0033",
539
- "deployedBytecode": "0x608060405234801561001057600080fd5b506004361061010b5760003560e01c80638da5cb5b116100a2578063cbf6791911610071578063cbf6791914610296578063cfed246b146102a9578063f2fde38b146102c9578063fc57d4df146102dc578063fe16e80c146102ef57600080fd5b80638da5cb5b1461024b5780638dd9500214610270578063b8a8a626146101e5578063c4d66de81461028357600080fd5b806369aa3ac6116100de57806369aa3ac6146101e5578063715018a6146101f4578063725068a5146101fc5780638cea8c261461020f57600080fd5b80631b69dc5f14610110578063234a3446146101af5780632b9d9dea146101c4578063609f0f36146101e5575b600080fd5b61016861011e366004611408565b60666020526000908152604090208054600182015460028301546003909301546001600160a01b0392831693919282169160ff600160a01b8204811692600160a81b909204169086565b604080516001600160a01b03978816815260208101969096529390951692840192909252151560608301521515608082015260a081019190915260c0015b60405180910390f35b6101c26101bd366004611519565b610316565b005b6101d76101d23660046115c9565b6103b2565b6040519081526020016101a6565b6101d7670de0b6b3a764000081565b6101c26103e1565b6101d761020a366004611408565b6103f5565b61023661021d366004611408565b6067602052600090815260409020805460019091015482565b604080519283526020830191909152016101a6565b6033546001600160a01b03165b6040516001600160a01b0390911681526020016101a6565b606554610258906001600160a01b031681565b6101c2610291366004611408565b61065a565b6101c26102a43660046115c9565b6107dc565b6101d76102b7366004611408565b60696020526000908152604090205481565b6101c26102d7366004611408565b610a4b565b6101d76102ea366004611408565b610ac4565b6102366102fd366004611408565b6068602052600090815260409020805460019091015482565b61031e610cdc565b60008151116103685760405162461bcd60e51b815260206004820152601160248201527006c656e6774682063616e2774206265203607c1b60448201526064015b60405180910390fd5b60005b81518160ff1610156103ae5761039c828260ff168151811061038f5761038f6115e5565b60200260200101516107dc565b806103a681611611565b91505061036b565b5050565b60008060006103c48460400151610d36565b50915091508360800151156103da579392505050565b5092915050565b6103e9610cdc565b6103f36000610ede565b565b600080826001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa158015610436573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061045a9190611630565b6001600160a01b03808216600090815260666020526040902054919250166104b65760405162461bcd60e51b815260206004820152600f60248201526e185cdcd95d081b9bdd08195e1a5cdd608a1b604482015260640161035f565b6065546001600160a01b038281169116148015906104f657506001600160a01b038116600090815260666020526040902060020154600160a01b900460ff165b156105d7576065546001600160a01b03908116600090815260666020526040902054166105565760405162461bcd60e51b815260206004820152600e60248201526d15d09390881b9bdd08195e1a5cdd60921b604482015260640161035f565b6065546001600160a01b03908116600090815260666020908152604091829020825160c08101845281548516815260018201549281019290925260028101549384169282019290925260ff600160a01b8404811615156060830152600160a81b909304909216151560808301526003015460a08201526105d590610f30565b505b6001600160a01b03808216600090815260666020908152604091829020825160c08101845281548516815260018201549281019290925260028101549384169282019290925260ff600160a01b8404811615156060830152600160a81b909304909216151560808301526003015460a082015261065390610f30565b9392505050565b600054610100900460ff161580801561067a5750600054600160ff909116105b806106945750303b158015610694575060005460ff166001145b6106f75760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b606482015260840161035f565b6000805460ff19166001179055801561071a576000805461ff0019166101001790555b610722611170565b6001600160a01b0382166107785760405162461bcd60e51b815260206004820152601a60248201527f57424e422063616e2774206265207a65726f2061646472657373000000000000604482015260640161035f565b606580546001600160a01b0319166001600160a01b03841617905580156103ae576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15050565b6107e4610cdc565b80516001600160a01b0381166108345760405162461bcd60e51b815260206004820152601560248201527463616e2774206265207a65726f206164647265737360581b604482015260640161035f565b60408201516001600160a01b0381166108875760405162461bcd60e51b815260206004820152601560248201527463616e2774206265207a65726f206164647265737360581b604482015260640161035f565b60008360a00151116108db5760405162461bcd60e51b815260206004820152601e60248201527f616e63686f7220706572696f64206d75737420626520706f7369746976650000604482015260640161035f565b600083602001511161092f5760405162461bcd60e51b815260206004820152601a60248201527f6261736520756e6974206d75737420626520706f736974697665000000000000604482015260640161035f565b600061093a846103b2565b84516001600160a01b03908116600090815260686020818152604080842042908190558a51861685526067808452828620919091558a518616855292825280842060019081018790558a51861685529282528084208301869055895185168452606682528084208a5181549087166001600160a01b031990911681178255928b015193810193909355808a015160028401805460608d015160808e01511515600160a81b0260ff60a81b19911515600160a01b026001600160a81b03199093169490991693841791909117169690961790955560a08a0151600390930183905551949550909390917f3cc8d9cb9370a23a8b9ffa75efa24cecb65c4693980e58260841adc474983c5f91a450505050565b610a53610cdc565b6001600160a01b038116610ab85760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161035f565b610ac181610ede565b50565b600080826001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa158015610b05573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b299190611630565b6001600160a01b0380821660009081526066602052604090205491925016610b855760405162461bcd60e51b815260206004820152600f60248201526e185cdcd95d081b9bdd08195e1a5cdd608a1b604482015260640161035f565b6001600160a01b03811660009081526069602052604090205480610beb5760405162461bcd60e51b815260206004820152601b60248201527f54574150207072696365206d75737420626520706f7369746976650000000000604482015260640161035f565b6000846001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa158015610c2b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c4f9190611630565b9050806001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610c8f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cb3919061164d565b610cbe906012611670565b610cc990600a611777565b610cd39083611786565b95945050505050565b6033546001600160a01b031633146103f35760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161035f565b6000806000610d4361119f565b9050836001600160a01b0316635909c0d56040518163ffffffff1660e01b8152600401602060405180830381865afa158015610d83573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610da791906117a5565b9250836001600160a01b0316635a3d54936040518163ffffffff1660e01b8152600401602060405180830381865afa158015610de7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e0b91906117a5565b91506000806000866001600160a01b0316630902f1ac6040518163ffffffff1660e01b8152600401606060405180830381865afa158015610e50573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e7491906117d5565b9250925092508363ffffffff168163ffffffff1614610ed45780840363ffffffff8116610ea184866111b5565b516001600160e01b031602969096019563ffffffff8116610ec285856111b5565b516001600160e01b0316029590950194505b5050509193909250565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600080600080610f3f85611267565b925092509250804211610f945760405162461bcd60e51b815260206004820152601a60248201527f6e6f77206d75737420636f6d65206166746572206265666f7265000000000000604482015260640161035f565b6000610fa08242611825565b905060006040518060200160405280838688610fbc9190611825565b610fc69190611852565b6001600160e01b0316905290506000610fde826113a3565b905060008860600151610ff957670de0b6b3a7640000611003565b670de0b6b3a76400005b90506000818a60200151846110189190611786565b6110229190611852565b90508960600151156110b1576065546001600160a01b0316600090815260696020526040812054908190036110905760405162461bcd60e51b8152602060048201526014602482015273189b98881c1c9a58d9481a5cc81a5b9d985b1a5960621b604482015260640161035f565b670de0b6b3a76400006110a38284611786565b6110ad9190611852565b9150505b806000036110fa5760405162461bcd60e51b81526020600482015260166024820152750747761702070726963652063616e6e6f7420626520360541b604482015260640161035f565b89516040805183815260208101899052428183015290516001600160a01b03909216917f7d881580fb2bb7844e8ecf8df26510247c4bbea2735d40bf0d9ac33c0d9acd819181900360600190a298516001600160a01b031660009081526069602052604090208990555096979650505050505050565b600054610100900460ff166111975760405162461bcd60e51b815260040161035f90611866565b6103f36113c3565b60006111b0640100000000426118b1565b905090565b6040805160208101909152600081526000826001600160701b03161161121d5760405162461bcd60e51b815260206004820152601760248201527f4669786564506f696e743a204449565f42595f5a45524f000000000000000000604482015260640161035f565b6040805160208101909152806112536001600160701b0385166dffffffffffffffffffffffffffff60701b607088901b166118c5565b6001600160e01b0316905290505b92915050565b600080600080611276856103b2565b85516001600160a01b0316600090815260676020908152604080832081518083019092528054808352600190910154928201929092529293506112b99042611825565b90508660a00151811061136e57815187516001600160a01b0390811660009081526068602090815260408083209490945580860180518c51851684528584206001908101919091558c51851684526067835285842042908190558d518616855293869020018890558b5187519151865192835292820193909352938401526060830186905216907f87208a84ec7402c933c70c261e53b733a9f1c893d73e941a152435d58177a2649060800160405180910390a25b505084516001600160a01b03908116600090815260686020526040808220600101549751909216815220549095909350915050565b8051600090611261906612725dd1d243ab906001600160e01b0316611852565b600054610100900460ff166113ea5760405162461bcd60e51b815260040161035f90611866565b6103f333610ede565b6001600160a01b0381168114610ac157600080fd5b60006020828403121561141a57600080fd5b8135610653816113f3565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff8111828210171561146457611464611425565b604052919050565b8035801515811461147c57600080fd5b919050565b600060c0828403121561149357600080fd5b60405160c0810181811067ffffffffffffffff821117156114b6576114b6611425565b60405290508082356114c7816113f3565b81526020838101359082015260408301356114e1816113f3565b60408201526114f26060840161146c565b60608201526115036080840161146c565b608082015260a083013560a08201525092915050565b6000602080838503121561152c57600080fd5b823567ffffffffffffffff8082111561154457600080fd5b818501915085601f83011261155857600080fd5b81358181111561156a5761156a611425565b611578848260051b0161143b565b818152848101925060c091820284018501918883111561159757600080fd5b938501935b828510156115bd576115ae8986611481565b8452938401939285019261159c565b50979650505050505050565b600060c082840312156115db57600080fd5b6106538383611481565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600060ff821660ff8103611627576116276115fb565b60010192915050565b60006020828403121561164257600080fd5b8151610653816113f3565b60006020828403121561165f57600080fd5b815160ff8116811461065357600080fd5b600060ff821660ff84168082101561168a5761168a6115fb565b90039392505050565b600181815b808511156116ce5781600019048211156116b4576116b46115fb565b808516156116c157918102915b93841c9390800290611698565b509250929050565b6000826116e557506001611261565b816116f257506000611261565b816001811461170857600281146117125761172e565b6001915050611261565b60ff841115611723576117236115fb565b50506001821b611261565b5060208310610133831016604e8410600b8410161715611751575081810a611261565b61175b8383611693565b806000190482111561176f5761176f6115fb565b029392505050565b600061065360ff8416836116d6565b60008160001904831182151516156117a0576117a06115fb565b500290565b6000602082840312156117b757600080fd5b5051919050565b80516001600160701b038116811461147c57600080fd5b6000806000606084860312156117ea57600080fd5b6117f3846117be565b9250611801602085016117be565b9150604084015163ffffffff8116811461181a57600080fd5b809150509250925092565b600082821015611837576118376115fb565b500390565b634e487b7160e01b600052601260045260246000fd5b6000826118615761186161183c565b500490565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b6000826118c0576118c061183c565b500690565b60006001600160e01b03838116806118df576118df61183c565b9216919091049291505056fea26469706673582212200a09a418732861daead22dd2fb3160185d565d9e6aef8995fc4fc61d520bd67964736f6c634300080d0033",
570
+ "solcInputHash": "6153c675ce838eebb6442d63350712be",
571
+ "metadata": "{\"compiler\":{\"version\":\"0.8.13+commit.abaa5c0e\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"vBnbAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"wBnbAddress\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"price\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldTimestamp\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newTimestamp\",\"type\":\"uint256\"}],\"name\":\"AnchorPriceUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"pancakePool\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"anchorPeriod\",\"type\":\"uint256\"}],\"name\":\"TokenConfigAdded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldTimestamp\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldAcc\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newTimestamp\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newAcc\",\"type\":\"uint256\"}],\"name\":\"TwapWindowUpdated\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"WBNB\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"bnbBaseUnit\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"busdBaseUnit\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"baseUnit\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"pancakePool\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"isBnbBased\",\"type\":\"bool\"},{\"internalType\":\"bool\",\"name\":\"isReversedPool\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"anchorPeriod\",\"type\":\"uint256\"}],\"internalType\":\"struct TokenConfig\",\"name\":\"config\",\"type\":\"tuple\"}],\"name\":\"currentCumulativePrice\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"expScale\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"vToken\",\"type\":\"address\"}],\"name\":\"getUnderlyingPrice\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"observations\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"timestamp\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"acc\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"prices\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"baseUnit\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"pancakePool\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"isBnbBased\",\"type\":\"bool\"},{\"internalType\":\"bool\",\"name\":\"isReversedPool\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"anchorPeriod\",\"type\":\"uint256\"}],\"internalType\":\"struct TokenConfig\",\"name\":\"config\",\"type\":\"tuple\"}],\"name\":\"setTokenConfig\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"baseUnit\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"pancakePool\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"isBnbBased\",\"type\":\"bool\"},{\"internalType\":\"bool\",\"name\":\"isReversedPool\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"anchorPeriod\",\"type\":\"uint256\"}],\"internalType\":\"struct TokenConfig[]\",\"name\":\"configs\",\"type\":\"tuple[]\"}],\"name\":\"setTokenConfigs\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"tokenConfigs\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"baseUnit\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"pancakePool\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"isBnbBased\",\"type\":\"bool\"},{\"internalType\":\"bool\",\"name\":\"isReversedPool\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"anchorPeriod\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"vToken\",\"type\":\"address\"}],\"name\":\"updateTwap\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"vBnb\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"windowStart\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"constructor\":{\"custom:oz-upgrades-unsafe-allow\":\"constructor\",\"params\":{\"vBnbAddress\":\"The address of the VBNB\",\"wBnbAddress\":\"The address of the WBNB\"}},\"currentCumulativePrice((address,uint256,address,bool,bool,uint256))\":{\"returns\":{\"_0\":\"cumulative price of target token regardless of pair order\"}},\"getUnderlyingPrice(address)\":{\"custom:error\":\"Missing error is thrown if the token config does not existRange error is thrown if TWAP price is not greater than zero\",\"params\":{\"vToken\":\"vToken address\"},\"returns\":{\"_0\":\"price Underlying price in USD\"}},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"renounceOwnership()\":{\"details\":\"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.\"},\"setTokenConfig((address,uint256,address,bool,bool,uint256))\":{\"custom:access\":\"Only Governance\",\"custom:error\":\"Range error is thrown if anchor period is not greater than zeroRange error is thrown if base unit is not greater than zeroValue error is thrown if base unit decimals is not the same as asset decimalsNotNullAddress error is thrown if address of asset is nullNotNullAddress error is thrown if PancakeSwap pool address is null\",\"custom:event\":\"Emits TokenConfigAdded event if new token config are added with asset address, PancakePool address, anchor period address\",\"params\":{\"config\":\"token config struct\"}},\"setTokenConfigs((address,uint256,address,bool,bool,uint256)[])\":{\"custom:error\":\"Zero length error thrown, if length of the config array is 0\",\"params\":{\"configs\":\"Config array\"}},\"transferOwnership(address)\":{\"details\":\"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.\"},\"updateTwap(address)\":{\"custom:error\":\"Missing error is thrown if token config does not exist\",\"returns\":{\"_0\":\"vToken Address of vToken\"}}},\"stateVariables\":{\"WBNB\":{\"custom:oz-upgrades-unsafe-allow\":\"state-variable-immutable\"},\"vBnb\":{\"custom:oz-upgrades-unsafe-allow\":\"state-variable-immutable\"}},\"version\":1},\"userdoc\":{\"events\":{\"AnchorPriceUpdated(address,uint256,uint256,uint256)\":{\"notice\":\"Emit this event when TWAP price is updated\"},\"TokenConfigAdded(address,address,uint256)\":{\"notice\":\"Emit this event when new token configs are added\"},\"TwapWindowUpdated(address,uint256,uint256,uint256,uint256)\":{\"notice\":\"Emit this event when TWAP window is updated\"}},\"kind\":\"user\",\"methods\":{\"WBNB()\":{\"notice\":\"WBNB address\"},\"bnbBaseUnit()\":{\"notice\":\"the base unit of WBNB and BUSD, which are the paired tokens for all assets\"},\"constructor\":{\"notice\":\"Constructor for the implementation contract. Sets immutable variables.\"},\"currentCumulativePrice((address,uint256,address,bool,bool,uint256))\":{\"notice\":\"Fetches the current token/WBNB and token/BUSD price accumulator from PancakeSwap.\"},\"getUnderlyingPrice(address)\":{\"notice\":\"Get the underlying TWAP price for the given vToken\"},\"initialize()\":{\"notice\":\"Initializes the owner of the contract and sets the contracts required\"},\"observations(address,uint256)\":{\"notice\":\"Keeps a record of token observations mapped by address, updated on every updateTwap invocation.\"},\"prices(address)\":{\"notice\":\"Stored price by token\"},\"setTokenConfig((address,uint256,address,bool,bool,uint256))\":{\"notice\":\"Adds a single token config\"},\"setTokenConfigs((address,uint256,address,bool,bool,uint256)[])\":{\"notice\":\"Adds multiple token configs at the same time\"},\"tokenConfigs(address)\":{\"notice\":\"Configs by token\"},\"updateTwap(address)\":{\"notice\":\"Updates the current token/BUSD price from PancakeSwap, with 18 decimals of precision.\"},\"vBnb()\":{\"notice\":\"vBNB address\"},\"windowStart(address)\":{\"notice\":\"Observation array index which probably falls in current anchor period mapped by asset address\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/oracles/TwapOracle.sol\":\"TwapOracle\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../utils/ContextUpgradeable.sol\\\";\\nimport \\\"../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Contract module which provides a basic access control mechanism, where\\n * there is an account (an owner) that can be granted exclusive access to\\n * specific functions.\\n *\\n * By default, the owner account will be the one that deploys the contract. This\\n * can later be changed with {transferOwnership}.\\n *\\n * This module is used through inheritance. It will make available the modifier\\n * `onlyOwner`, which can be applied to your functions to restrict their use to\\n * the owner.\\n */\\nabstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {\\n address private _owner;\\n\\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Initializes the contract setting the deployer as the initial owner.\\n */\\n function __Ownable_init() internal onlyInitializing {\\n __Ownable_init_unchained();\\n }\\n\\n function __Ownable_init_unchained() internal onlyInitializing {\\n _transferOwnership(_msgSender());\\n }\\n\\n /**\\n * @dev Throws if called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n _checkOwner();\\n _;\\n }\\n\\n /**\\n * @dev Returns the address of the current owner.\\n */\\n function owner() public view virtual returns (address) {\\n return _owner;\\n }\\n\\n /**\\n * @dev Throws if the sender is not the owner.\\n */\\n function _checkOwner() internal view virtual {\\n require(owner() == _msgSender(), \\\"Ownable: caller is not the owner\\\");\\n }\\n\\n /**\\n * @dev Leaves the contract without owner. It will not be possible to call\\n * `onlyOwner` functions anymore. Can only be called by the current owner.\\n *\\n * NOTE: Renouncing ownership will leave the contract without an owner,\\n * thereby removing any functionality that is only available to the owner.\\n */\\n function renounceOwnership() public virtual onlyOwner {\\n _transferOwnership(address(0));\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual onlyOwner {\\n require(newOwner != address(0), \\\"Ownable: new owner is the zero address\\\");\\n _transferOwnership(newOwner);\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Internal function without access restriction.\\n */\\n function _transferOwnership(address newOwner) internal virtual {\\n address oldOwner = _owner;\\n _owner = newOwner;\\n emit OwnershipTransferred(oldOwner, newOwner);\\n }\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[49] private __gap;\\n}\\n\",\"keccak256\":\"0x247c62047745915c0af6b955470a72d1696ebad4352d7d3011aef1a2463cd888\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.1) (proxy/utils/Initializable.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../../utils/AddressUpgradeable.sol\\\";\\n\\n/**\\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\\n *\\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\\n * reused. This mechanism prevents re-execution of each \\\"step\\\" but allows the creation of new initialization steps in\\n * case an upgrade adds a module that needs to be initialized.\\n *\\n * For example:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```\\n * contract MyToken is ERC20Upgradeable {\\n * function initialize() initializer public {\\n * __ERC20_init(\\\"MyToken\\\", \\\"MTK\\\");\\n * }\\n * }\\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\\n * function initializeV2() reinitializer(2) public {\\n * __ERC20Permit_init(\\\"MyToken\\\");\\n * }\\n * }\\n * ```\\n *\\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\\n *\\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\\n *\\n * [CAUTION]\\n * ====\\n * Avoid leaving a contract uninitialized.\\n *\\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```\\n * /// @custom:oz-upgrades-unsafe-allow constructor\\n * constructor() {\\n * _disableInitializers();\\n * }\\n * ```\\n * ====\\n */\\nabstract contract Initializable {\\n /**\\n * @dev Indicates that the contract has been initialized.\\n * @custom:oz-retyped-from bool\\n */\\n uint8 private _initialized;\\n\\n /**\\n * @dev Indicates that the contract is in the process of being initialized.\\n */\\n bool private _initializing;\\n\\n /**\\n * @dev Triggered when the contract has been initialized or reinitialized.\\n */\\n event Initialized(uint8 version);\\n\\n /**\\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\\n * `onlyInitializing` functions can be used to initialize parent contracts.\\n *\\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\\n * constructor.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier initializer() {\\n bool isTopLevelCall = !_initializing;\\n require(\\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\\n \\\"Initializable: contract is already initialized\\\"\\n );\\n _initialized = 1;\\n if (isTopLevelCall) {\\n _initializing = true;\\n }\\n _;\\n if (isTopLevelCall) {\\n _initializing = false;\\n emit Initialized(1);\\n }\\n }\\n\\n /**\\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\\n * used to initialize parent contracts.\\n *\\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\\n * are added through upgrades and that require initialization.\\n *\\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\\n * cannot be nested. If one is invoked in the context of another, execution will revert.\\n *\\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\\n * a contract, executing them in the right order is up to the developer or operator.\\n *\\n * WARNING: setting the version to 255 will prevent any future reinitialization.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier reinitializer(uint8 version) {\\n require(!_initializing && _initialized < version, \\\"Initializable: contract is already initialized\\\");\\n _initialized = version;\\n _initializing = true;\\n _;\\n _initializing = false;\\n emit Initialized(version);\\n }\\n\\n /**\\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\\n */\\n modifier onlyInitializing() {\\n require(_initializing, \\\"Initializable: contract is not initializing\\\");\\n _;\\n }\\n\\n /**\\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\\n * through proxies.\\n *\\n * Emits an {Initialized} event the first time it is successfully executed.\\n */\\n function _disableInitializers() internal virtual {\\n require(!_initializing, \\\"Initializable: contract is initializing\\\");\\n if (_initialized < type(uint8).max) {\\n _initialized = type(uint8).max;\\n emit Initialized(type(uint8).max);\\n }\\n }\\n\\n /**\\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\\n */\\n function _getInitializedVersion() internal view returns (uint8) {\\n return _initialized;\\n }\\n\\n /**\\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\\n */\\n function _isInitializing() internal view returns (bool) {\\n return _initializing;\\n }\\n}\\n\",\"keccak256\":\"0x037c334add4b033ad3493038c25be1682d78c00992e1acb0e2795caff3925271\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary AddressUpgradeable {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x2edcb41c121abc510932e8d83ff8b82cf9cdde35e7c297622f5c29ef0af25183\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\nimport \\\"../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract ContextUpgradeable is Initializable {\\n function __Context_init() internal onlyInitializing {\\n }\\n\\n function __Context_init_unchained() internal onlyInitializing {\\n }\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[50] private __gap;\\n}\\n\",\"keccak256\":\"0x963ea7f0b48b032eef72fe3a7582edf78408d6f834115b9feadd673a4d5bd149\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20 {\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `to`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address to, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x9750c6b834f7b43000631af5cc30001c5f547b3ceb3635488f140f60e897ea6b\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\n\\n/**\\n * @dev Interface for the optional metadata functions from the ERC20 standard.\\n *\\n * _Available since v4.1._\\n */\\ninterface IERC20Metadata is IERC20 {\\n /**\\n * @dev Returns the name of the token.\\n */\\n function name() external view returns (string memory);\\n\\n /**\\n * @dev Returns the symbol of the token.\\n */\\n function symbol() external view returns (string memory);\\n\\n /**\\n * @dev Returns the decimals places of the token.\\n */\\n function decimals() external view returns (uint8);\\n}\\n\",\"keccak256\":\"0x8de418a5503946cabe331f35fe242d3201a73f67f77aaeb7110acb1f30423aca\",\"license\":\"MIT\"},\"contracts/interfaces/OracleInterface.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity 0.8.13;\\n\\ninterface OracleInterface {\\n function getUnderlyingPrice(address vToken) external view returns (uint256);\\n}\\n\\ninterface ResilientOracleInterface is OracleInterface {\\n function updatePrice(address vToken) external;\\n}\\n\\ninterface TwapInterface is OracleInterface {\\n function updateTwap(address vToken) external returns (uint256);\\n}\\n\\ninterface BoundValidatorInterface {\\n function validatePriceWithAnchorPrice(\\n address vToken,\\n uint256 reporterPrice,\\n uint256 anchorPrice\\n ) external view returns (bool);\\n}\\n\",\"keccak256\":\"0x8ac0bda5d5789c320bf219dc6691eef0e6617e9653bc0e24f407a44e4281edda\",\"license\":\"BSD-3-Clause\"},\"contracts/interfaces/VBep20Interface.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity 0.8.13;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\\\";\\n\\ninterface VBep20Interface is IERC20Metadata {\\n /**\\n * @notice Underlying asset for this VToken\\n */\\n function underlying() external view returns (address);\\n}\\n\",\"keccak256\":\"0x3f845cd51b2d82f7932ac6c0ab714df97f733b01ce50f6fb0adb4c28447d4618\",\"license\":\"BSD-3-Clause\"},\"contracts/libraries/PancakeLibrary.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity 0.8.13;\\n\\ninterface IPancakePair {\\n function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);\\n\\n function price0CumulativeLast() external view returns (uint256);\\n\\n function price1CumulativeLast() external view returns (uint256);\\n}\\n\\nlibrary FixedPoint {\\n // range: [0, 2**112 - 1]\\n // resolution: 1 / 2**112\\n struct uq112x112 {\\n uint224 _x;\\n }\\n\\n // returns a uq112x112 which represents the ratio of the numerator to the denominator\\n // equivalent to encode(numerator).div(denominator)\\n function fraction(uint112 numerator, uint112 denominator) internal pure returns (uq112x112 memory) {\\n require(denominator > 0, \\\"FixedPoint: DIV_BY_ZERO\\\");\\n return uq112x112((uint224(numerator) << 112) / denominator);\\n }\\n\\n // decode a uq112x112 into a uint with 18 decimals of precision\\n function decode112with18(uq112x112 memory self) internal pure returns (uint256) {\\n // we only have 256 - 224 = 32 bits to spare, so scaling up by ~60 bits is dangerous\\n // instead, get close to:\\n // (x * 1e18) >> 112\\n // without risk of overflowing, e.g.:\\n // (x) / 2 ** (112 - lg(1e18))\\n return uint256(self._x) / 5192296858534827;\\n }\\n}\\n\\n// library with helper methods for oracles that are concerned with computing average prices\\nlibrary PancakeOracleLibrary {\\n using FixedPoint for *;\\n\\n // helper function that returns the current block timestamp within the range of uint32, i.e. [0, 2**32 - 1]\\n function currentBlockTimestamp() internal view returns (uint32) {\\n return uint32(block.timestamp % 2 ** 32);\\n }\\n\\n // produces the cumulative price using counterfactuals to save gas and avoid a call to sync.\\n function currentCumulativePrices(\\n address pair\\n ) internal view returns (uint256 price0Cumulative, uint256 price1Cumulative, uint32 blockTimestamp) {\\n blockTimestamp = currentBlockTimestamp();\\n price0Cumulative = IPancakePair(pair).price0CumulativeLast();\\n price1Cumulative = IPancakePair(pair).price1CumulativeLast();\\n\\n // if time has elapsed since the last update on the pair, mock the accumulated price values\\n (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast) = IPancakePair(pair).getReserves();\\n if (blockTimestampLast != blockTimestamp) {\\n unchecked {\\n // subtraction overflow is desired\\n uint32 timeElapsed = blockTimestamp - blockTimestampLast;\\n // addition overflow is desired\\n // counterfactual\\n price0Cumulative += uint256(FixedPoint.fraction(reserve1, reserve0)._x) * timeElapsed;\\n // counterfactual\\n price1Cumulative += uint256(FixedPoint.fraction(reserve0, reserve1)._x) * timeElapsed;\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x2c8179ebad223998514d6f25ebd90f80ecb294b562d9fbc4a42bf6710486c25b\",\"license\":\"BSD-3-Clause\"},\"contracts/oracles/TwapOracle.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-3-Clause\\npragma solidity 0.8.13;\\n\\nimport \\\"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\\\";\\nimport \\\"../libraries/PancakeLibrary.sol\\\";\\nimport \\\"../interfaces/OracleInterface.sol\\\";\\nimport \\\"../interfaces/VBep20Interface.sol\\\";\\n\\nstruct Observation {\\n uint256 timestamp;\\n uint256 acc;\\n}\\n\\nstruct TokenConfig {\\n /// @notice Asset address, which can't be zero address and can be used for existance check\\n address asset;\\n /// @notice Decimals of underlying asset\\n uint256 baseUnit;\\n /// @notice The address of Pancake pair\\n address pancakePool;\\n /// @notice Whether the token is paired with WBNB\\n bool isBnbBased;\\n /// @notice A flag identifies whether the Pancake pair is reversed\\n /// e.g. XVS-WBNB is not reversed, while WBNB-XVS is.\\n bool isReversedPool;\\n /// @notice The minimum window in seconds required between TWAP updates\\n uint256 anchorPeriod;\\n}\\n\\ncontract TwapOracle is OwnableUpgradeable, TwapInterface {\\n using FixedPoint for *;\\n\\n /// @notice WBNB address\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n address public immutable WBNB;\\n\\n /// @notice vBNB address\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n address public immutable vBnb;\\n\\n /// @notice the base unit of WBNB and BUSD, which are the paired tokens for all assets\\n uint256 public constant bnbBaseUnit = 1e18;\\n uint256 public constant busdBaseUnit = 1e18;\\n\\n uint256 public constant expScale = 1e18;\\n\\n /// @notice Configs by token\\n mapping(address => TokenConfig) public tokenConfigs;\\n\\n /// @notice Stored price by token\\n mapping(address => uint256) public prices;\\n\\n /// @notice Keeps a record of token observations mapped by address, updated on every updateTwap invocation.\\n mapping(address => Observation[]) public observations;\\n\\n /// @notice Observation array index which probably falls in current anchor period mapped by asset address\\n mapping(address => uint256) public windowStart;\\n\\n /// @notice Emit this event when TWAP window is updated\\n event TwapWindowUpdated(\\n address indexed asset,\\n uint256 oldTimestamp,\\n uint256 oldAcc,\\n uint256 newTimestamp,\\n uint256 newAcc\\n );\\n\\n /// @notice Emit this event when TWAP price is updated\\n event AnchorPriceUpdated(address indexed asset, uint256 price, uint256 oldTimestamp, uint256 newTimestamp);\\n\\n /// @notice Emit this event when new token configs are added\\n event TokenConfigAdded(address indexed asset, address indexed pancakePool, uint256 indexed anchorPeriod);\\n\\n modifier notNullAddress(address someone) {\\n require(someone != address(0), \\\"can't be zero address\\\");\\n _;\\n }\\n\\n /// @notice Constructor for the implementation contract. Sets immutable variables.\\n /// @param vBnbAddress The address of the VBNB\\n /// @param wBnbAddress The address of the WBNB\\n /// @custom:oz-upgrades-unsafe-allow constructor\\n constructor(address vBnbAddress, address wBnbAddress) notNullAddress(vBnbAddress) notNullAddress(wBnbAddress) {\\n vBnb = vBnbAddress;\\n WBNB = wBnbAddress;\\n _disableInitializers();\\n }\\n\\n /**\\n * @notice Adds multiple token configs at the same time\\n * @param configs Config array\\n * @custom:error Zero length error thrown, if length of the config array is 0\\n */\\n function setTokenConfigs(TokenConfig[] memory configs) external onlyOwner {\\n require(configs.length > 0, \\\"length can't be 0\\\");\\n uint256 numTokenConfigs = configs.length;\\n for (uint256 i; i < numTokenConfigs; ++i) {\\n setTokenConfig(configs[i]);\\n }\\n }\\n\\n /**\\n * @notice Get the underlying TWAP price for the given vToken\\n * @param vToken vToken address\\n * @return price Underlying price in USD\\n * @custom:error Missing error is thrown if the token config does not exist\\n * @custom:error Range error is thrown if TWAP price is not greater than zero\\n */\\n function getUnderlyingPrice(address vToken) external view override returns (uint256) {\\n // VBNB token doesn't have `underlying` method, vBNB's underlying token is wBNB\\n address asset = address(vToken) == vBnb ? WBNB : VBep20Interface(vToken).underlying();\\n require(tokenConfigs[asset].asset != address(0), \\\"asset not exist\\\");\\n uint256 price = prices[asset];\\n\\n // if price is 0, it means the price hasn't been updated yet and it's meaningless, revert\\n require(price > 0, \\\"TWAP price must be positive\\\");\\n return (price * (10 ** (18 - IERC20Metadata(asset).decimals())));\\n }\\n\\n /**\\n * @notice Initializes the owner of the contract and sets the contracts required\\n */\\n function initialize() public initializer {\\n __Ownable_init();\\n }\\n\\n /**\\n * @notice Adds a single token config\\n * @param config token config struct\\n * @custom:access Only Governance\\n * @custom:error Range error is thrown if anchor period is not greater than zero\\n * @custom:error Range error is thrown if base unit is not greater than zero\\n * @custom:error Value error is thrown if base unit decimals is not the same as asset decimals\\n * @custom:error NotNullAddress error is thrown if address of asset is null\\n * @custom:error NotNullAddress error is thrown if PancakeSwap pool address is null\\n * @custom:event Emits TokenConfigAdded event if new token config are added with\\n * asset address, PancakePool address, anchor period address\\n */\\n function setTokenConfig(\\n TokenConfig memory config\\n ) public onlyOwner notNullAddress(config.asset) notNullAddress(config.pancakePool) {\\n require(config.anchorPeriod > 0, \\\"anchor period must be positive\\\");\\n require(config.baseUnit > 0, \\\"base unit must be positive\\\");\\n require(\\n config.baseUnit == 10 ** IERC20Metadata(config.asset).decimals(),\\n \\\"base unit decimals must be same as asset decimals\\\"\\n );\\n\\n uint256 cumulativePrice = currentCumulativePrice(config);\\n\\n // Initialize observation data\\n observations[config.asset].push(Observation(block.timestamp, cumulativePrice));\\n tokenConfigs[config.asset] = config;\\n emit TokenConfigAdded(config.asset, config.pancakePool, config.anchorPeriod);\\n }\\n\\n /**\\n * @notice Updates the current token/BUSD price from PancakeSwap, with 18 decimals of precision.\\n * @return vToken Address of vToken\\n * @custom:error Missing error is thrown if token config does not exist\\n */\\n function updateTwap(address vToken) public returns (uint256) {\\n // VBNB token doesn't have `underlying` method, vBNB's underlying token is wBNB\\n address asset = address(vToken) == vBnb ? WBNB : VBep20Interface(vToken).underlying();\\n require(tokenConfigs[asset].asset != address(0), \\\"asset not exist\\\");\\n // Update & fetch WBNB price first, so we can calculate the price of WBNB paired token\\n if (asset != WBNB && tokenConfigs[asset].isBnbBased) {\\n require(tokenConfigs[WBNB].asset != address(0), \\\"WBNB not exist\\\");\\n _updateTwapInternal(tokenConfigs[WBNB]);\\n }\\n return _updateTwapInternal(tokenConfigs[asset]);\\n }\\n\\n /**\\n * @notice Fetches the current token/WBNB and token/BUSD price accumulator from PancakeSwap.\\n * @return cumulative price of target token regardless of pair order\\n */\\n function currentCumulativePrice(TokenConfig memory config) public view returns (uint256) {\\n (uint256 price0, uint256 price1, ) = PancakeOracleLibrary.currentCumulativePrices(config.pancakePool);\\n if (config.isReversedPool) {\\n return price1;\\n } else {\\n return price0;\\n }\\n }\\n\\n /**\\n * @notice Fetches the current token/BUSD price from PancakeSwap, with 18 decimals of precision.\\n * @return price Underlying price in USD, with 18 decimals\\n * @custom:error Timing error is thrown if current time is not greater than old observation timestamp\\n * @custom:error Zero price error is thrown if token is BNB based and price is zero\\n * @custom:error Zero price error is thrown if fetched anchorPriceMantissa is zero\\n * @custom:event Emits AnchorPriceUpdated event on successful update of observation with assset address,\\n * AnchorPrice, old observation timestamp and current timestamp\\n */\\n function _updateTwapInternal(TokenConfig memory config) internal virtual returns (uint256) {\\n // pokeWindowValues already handled reversed pool cases,\\n // priceAverage will always be Token/BNB or Token/BUSD *twap** price.\\n (uint256 nowCumulativePrice, uint256 oldCumulativePrice, uint256 oldTimestamp) = pokeWindowValues(config);\\n\\n // This should be impossible, but better safe than sorry\\n require(block.timestamp > oldTimestamp, \\\"now must come after before\\\");\\n uint256 timeElapsed = block.timestamp - oldTimestamp;\\n\\n // Calculate Pancakge *twap**\\n FixedPoint.uq112x112 memory priceAverage = FixedPoint.uq112x112(\\n uint224((nowCumulativePrice - oldCumulativePrice) / timeElapsed)\\n );\\n // *twap** price with 1e18 decimal mantissa\\n uint256 priceAverageMantissa = priceAverage.decode112with18();\\n\\n // To cancel the decimals in cumulative price, we need to mulitply the average price with\\n // tokenBaseUnit / (wbnbBaseUnit or busdBaseUnit, which is 1e18)\\n uint256 pairedTokenBaseUnit = config.isBnbBased ? bnbBaseUnit : busdBaseUnit;\\n uint256 anchorPriceMantissa = (priceAverageMantissa * config.baseUnit) / pairedTokenBaseUnit;\\n\\n // if this token is paired with BNB, convert its price to USD\\n if (config.isBnbBased) {\\n uint256 bnbPrice = prices[WBNB];\\n require(bnbPrice != 0, \\\"bnb price is invalid\\\");\\n anchorPriceMantissa = (anchorPriceMantissa * bnbPrice) / bnbBaseUnit;\\n }\\n\\n require(anchorPriceMantissa != 0, \\\"twap price cannot be 0\\\");\\n\\n emit AnchorPriceUpdated(config.asset, anchorPriceMantissa, oldTimestamp, block.timestamp);\\n\\n // save anchor price, which is 1e18 decimals\\n prices[config.asset] = anchorPriceMantissa;\\n\\n return anchorPriceMantissa;\\n }\\n\\n /**\\n * @notice Appends current observation and pick an observation with a timestamp equal\\n * or just greater than the window start timestamp. If one is not available,\\n * then pick the last availableobservation. The window start index is updated in both the cases.\\n * Only the current observation is saved, prior observations are deleted during this operation.\\n * @return Tuple of cumulative price, old observation and timestamp\\n * @custom:event Emits TwapWindowUpdated on successful calculation of cumulative price with asset address,\\n * new observation timestamp, current timestamp, new observation price and cumulative price\\n */\\n function pokeWindowValues(\\n TokenConfig memory config\\n ) internal returns (uint256, uint256 startCumulativePrice, uint256 startCumulativeTimestamp) {\\n uint256 cumulativePrice = currentCumulativePrice(config);\\n uint256 currentTimestamp = block.timestamp;\\n uint256 windowStartTimestamp = currentTimestamp - config.anchorPeriod;\\n Observation[] memory storedObservations = observations[config.asset];\\n\\n uint256 storedObservationsLength = storedObservations.length;\\n for (\\n uint256 windowStartIndex = windowStart[config.asset];\\n windowStartIndex < storedObservationsLength;\\n ++windowStartIndex\\n ) {\\n if (\\n (storedObservations[windowStartIndex].timestamp >= windowStartTimestamp) ||\\n (windowStartIndex == storedObservationsLength - 1)\\n ) {\\n startCumulativePrice = storedObservations[windowStartIndex].acc;\\n startCumulativeTimestamp = storedObservations[windowStartIndex].timestamp;\\n windowStart[config.asset] = windowStartIndex;\\n break;\\n } else {\\n delete observations[config.asset][windowStartIndex];\\n }\\n }\\n\\n observations[config.asset].push(Observation(currentTimestamp, cumulativePrice));\\n emit TwapWindowUpdated(\\n config.asset,\\n startCumulativeTimestamp,\\n startCumulativePrice,\\n block.timestamp,\\n cumulativePrice\\n );\\n return (cumulativePrice, startCumulativePrice, startCumulativeTimestamp);\\n }\\n}\\n\",\"keccak256\":\"0x26e5625410f8683895402bd1374cdb85388ceaa25c97a8439e34a268db86d752\",\"license\":\"BSD-3-Clause\"}},\"version\":1}",
572
+ "bytecode": "0x60c06040523480156200001157600080fd5b5060405162001e8d38038062001e8d8339810160408190526200003491620001ed565b816001600160a01b038116620000915760405162461bcd60e51b815260206004820152601560248201527f63616e2774206265207a65726f2061646472657373000000000000000000000060448201526064015b60405180910390fd5b816001600160a01b038116620000ea5760405162461bcd60e51b815260206004820152601560248201527f63616e2774206265207a65726f20616464726573730000000000000000000000604482015260640162000088565b6001600160a01b0380851660a05283166080526200010762000111565b5050505062000225565b600054610100900460ff16156200017b5760405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b606482015260840162000088565b60005460ff9081161015620001ce576000805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b80516001600160a01b0381168114620001e857600080fd5b919050565b600080604083850312156200020157600080fd5b6200020c83620001d0565b91506200021c60208401620001d0565b90509250929050565b60805160a051611c0a620002836000396000818161023d015281816104540152610c420152600081816102bf015281816104f401528181610572015281816105e30152818161065b01528181610ce201526111aa0152611c0a6000f3fe608060405234801561001057600080fd5b50600436106101165760003560e01c8063725068a5116100a2578063b8a8a62611610071578063b8a8a62614610277578063cbf67919146102e1578063cfed246b146102f4578063f2fde38b14610314578063fc57d4df1461032757600080fd5b8063725068a51461028e5780638129fc1c146102a15780638da5cb5b146102a95780638dd95002146102ba57600080fd5b80633334ecc5116100e95780633334ecc5146102185780635ba3792d14610238578063609f0f361461027757806369aa3ac614610277578063715018a61461028657600080fd5b8063024599661461011b5780631b69dc5f14610148578063234a3446146101e25780632b9d9dea146101f7575b600080fd5b61012e6101293660046116cb565b61033a565b604080519283526020830191909152015b60405180910390f35b6101a06101563660046116f7565b60656020526000908152604090208054600182015460028301546003909301546001600160a01b0392831693919282169160ff600160a01b8204811692600160a81b909204169086565b604080516001600160a01b03978816815260208101969096529390951692840192909252151560608301521515608082015260a081019190915260c00161013f565b6101f56101f0366004611808565b610376565b005b61020a6102053660046118b8565b61040c565b60405190815260200161013f565b61020a6102263660046116f7565b60686020526000908152604090205481565b61025f7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b03909116815260200161013f565b61020a670de0b6b3a764000081565b6101f561043b565b61020a61029c3660046116f7565b61044f565b6101f5610772565b6033546001600160a01b031661025f565b61025f7f000000000000000000000000000000000000000000000000000000000000000081565b6101f56102ef3660046118b8565b610883565b61020a6103023660046116f7565b60666020526000908152604090205481565b6101f56103223660046116f7565b610bc7565b61020a6103353660046116f7565b610c3d565b6067602052816000526040600020818154811061035657600080fd5b600091825260209091206002909102018054600190910154909250905082565b61037e610e4e565b60008151116103c85760405162461bcd60e51b815260206004820152601160248201527006c656e6774682063616e2774206265203607c1b60448201526064015b60405180910390fd5b805160005b81811015610407576103f78382815181106103ea576103ea6118d4565b6020026020010151610883565b61040081611900565b90506103cd565b505050565b600080600061041e8460400151610ea8565b5091509150836080015115610434579392505050565b5092915050565b610443610e4e565b61044d6000611050565b565b6000807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316836001600160a01b0316146104f257826001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa1580156104c9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104ed9190611919565b610514565b7f00000000000000000000000000000000000000000000000000000000000000005b6001600160a01b03808216600090815260656020526040902054919250166105705760405162461bcd60e51b815260206004820152600f60248201526e185cdcd95d081b9bdd08195e1a5cdd608a1b60448201526064016103bf565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316816001600160a01b0316141580156105d457506001600160a01b038116600090815260656020526040902060020154600160a01b900460ff165b156106ef576001600160a01b037f00000000000000000000000000000000000000000000000000000000000000008116600090815260656020526040902054166106515760405162461bcd60e51b815260206004820152600e60248201526d15d09390881b9bdd08195e1a5cdd60921b60448201526064016103bf565b6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000008116600090815260656020908152604091829020825160c08101845281548516815260018201549281019290925260028101549384169282019290925260ff600160a01b8404811615156060830152600160a81b909304909216151560808301526003015460a08201526106ed906110a2565b505b6001600160a01b03808216600090815260656020908152604091829020825160c08101845281548516815260018201549281019290925260028101549384169282019290925260ff600160a01b8404811615156060830152600160a81b909304909216151560808301526003015460a082015261076b906110a2565b9392505050565b600054610100900460ff16158080156107925750600054600160ff909116105b806107ac5750303b1580156107ac575060005460ff166001145b61080f5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016103bf565b6000805460ff191660011790558015610832576000805461ff0019166101001790555b61083a611300565b8015610880576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50565b61088b610e4e565b80516001600160a01b0381166108db5760405162461bcd60e51b815260206004820152601560248201527463616e2774206265207a65726f206164647265737360581b60448201526064016103bf565b60408201516001600160a01b03811661092e5760405162461bcd60e51b815260206004820152601560248201527463616e2774206265207a65726f206164647265737360581b60448201526064016103bf565b60008360a00151116109825760405162461bcd60e51b815260206004820152601e60248201527f616e63686f7220706572696f64206d75737420626520706f736974697665000060448201526064016103bf565b60008360200151116109d65760405162461bcd60e51b815260206004820152601a60248201527f6261736520756e6974206d75737420626520706f73697469766500000000000060448201526064016103bf565b82600001516001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610a18573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a3c9190611936565b610a4790600a611a3d565b836020015114610ab35760405162461bcd60e51b815260206004820152603160248201527f6261736520756e697420646563696d616c73206d7573742062652073616d6520604482015270617320617373657420646563696d616c7360781b60648201526084016103bf565b6000610abe8461040c565b84516001600160a01b03908116600090815260676020908152604080832081518083018352428152808401878152825460018181018555938752858720925160029182029093019283559051918301919091558a5186168552606584528285208b5181549088166001600160a01b031990911681178255948c015192810192909255828b0151908201805460608d015160808e01511515600160a81b0260ff60a81b19911515600160a01b026001600160a81b03199093169490991693841791909117169690961790955560a08a0151600390910181905590519495509390917f3cc8d9cb9370a23a8b9ffa75efa24cecb65c4693980e58260841adc474983c5f91a450505050565b610bcf610e4e565b6001600160a01b038116610c345760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016103bf565b61088081611050565b6000807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316836001600160a01b031614610ce057826001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa158015610cb7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cdb9190611919565b610d02565b7f00000000000000000000000000000000000000000000000000000000000000005b6001600160a01b0380821660009081526065602052604090205491925016610d5e5760405162461bcd60e51b815260206004820152600f60248201526e185cdcd95d081b9bdd08195e1a5cdd608a1b60448201526064016103bf565b6001600160a01b03811660009081526066602052604090205480610dc45760405162461bcd60e51b815260206004820152601b60248201527f54574150207072696365206d75737420626520706f736974697665000000000060448201526064016103bf565b816001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610e02573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e269190611936565b610e31906012611a4c565b610e3c90600a611a3d565b610e469082611a6f565b949350505050565b6033546001600160a01b0316331461044d5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016103bf565b6000806000610eb561132f565b9050836001600160a01b0316635909c0d56040518163ffffffff1660e01b8152600401602060405180830381865afa158015610ef5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f199190611a8e565b9250836001600160a01b0316635a3d54936040518163ffffffff1660e01b8152600401602060405180830381865afa158015610f59573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f7d9190611a8e565b91506000806000866001600160a01b0316630902f1ac6040518163ffffffff1660e01b8152600401606060405180830381865afa158015610fc2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fe69190611abe565b9250925092508363ffffffff168163ffffffff16146110465780840363ffffffff81166110138486611345565b516001600160e01b031602969096019563ffffffff81166110348585611345565b516001600160e01b0316029590950194505b5050509193909250565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6000806000806110b1856113f7565b9250925092508042116111065760405162461bcd60e51b815260206004820152601a60248201527f6e6f77206d75737420636f6d65206166746572206265666f726500000000000060448201526064016103bf565b60006111128242611b0e565b90506000604051806020016040528083868861112e9190611b0e565b6111389190611b3b565b6001600160e01b031690529050600061115082611666565b90506000886060015161116b57670de0b6b3a7640000611175565b670de0b6b3a76400005b90506000818a602001518461118a9190611a6f565b6111949190611b3b565b9050896060015115611241576001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016600090815260666020526040812054908190036112205760405162461bcd60e51b8152602060048201526014602482015273189b98881c1c9a58d9481a5cc81a5b9d985b1a5960621b60448201526064016103bf565b670de0b6b3a76400006112338284611a6f565b61123d9190611b3b565b9150505b8060000361128a5760405162461bcd60e51b81526020600482015260166024820152750747761702070726963652063616e6e6f7420626520360541b60448201526064016103bf565b89516040805183815260208101899052428183015290516001600160a01b03909216917f7d881580fb2bb7844e8ecf8df26510247c4bbea2735d40bf0d9ac33c0d9acd819181900360600190a298516001600160a01b031660009081526066602052604090208990555096979650505050505050565b600054610100900460ff166113275760405162461bcd60e51b81526004016103bf90611b4f565b61044d611686565b600061134064010000000042611b9a565b905090565b6040805160208101909152600081526000826001600160701b0316116113ad5760405162461bcd60e51b815260206004820152601760248201527f4669786564506f696e743a204449565f42595f5a45524f00000000000000000060448201526064016103bf565b6040805160208101909152806113e36001600160701b0385166dffffffffffffffffffffffffffff60701b607088901b16611bae565b6001600160e01b0316905290505b92915050565b6000806000806114068561040c565b60a0860151909150429060009061141d9083611b0e565b87516001600160a01b0316600090815260676020908152604080832080548251818502810185019093528083529495509293909291849084015b8282101561149d57838290600052602060002090600202016040518060400160405290816000820154815260200160018201548152505081526020019060010190611457565b505082518b516001600160a01b0316600090815260686020526040902054939450929150505b818110156115b957838382815181106114de576114de6118d4565b60200260200101516000015110158061150057506114fd600183611b0e565b81145b1561156857828181518110611517576115176118d4565b6020026020010151602001519750828181518110611537576115376118d4565b602090810291909101810151518b516001600160a01b031660009081526068909252604090912082905596506115b9565b89516001600160a01b03166000908152606760205260409020805482908110611593576115936118d4565b600091825260208220600290910201818155600101556115b281611900565b90506114c3565b5088516001600160a01b039081166000908152606760209081526040808320815180830183528981528084018b81528254600180820185559387529585902091516002909602909101948555519301929092558b5182518a81529182018b90524292820192909252606081018890529116907f87208a84ec7402c933c70c261e53b733a9f1c893d73e941a152435d58177a2649060800160405180910390a2509295505050509193909250565b80516000906113f1906612725dd1d243ab906001600160e01b0316611b3b565b600054610100900460ff166116ad5760405162461bcd60e51b81526004016103bf90611b4f565b61044d33611050565b6001600160a01b038116811461088057600080fd5b600080604083850312156116de57600080fd5b82356116e9816116b6565b946020939093013593505050565b60006020828403121561170957600080fd5b813561076b816116b6565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff8111828210171561175357611753611714565b604052919050565b8035801515811461176b57600080fd5b919050565b600060c0828403121561178257600080fd5b60405160c0810181811067ffffffffffffffff821117156117a5576117a5611714565b60405290508082356117b6816116b6565b81526020838101359082015260408301356117d0816116b6565b60408201526117e16060840161175b565b60608201526117f26080840161175b565b608082015260a083013560a08201525092915050565b6000602080838503121561181b57600080fd5b823567ffffffffffffffff8082111561183357600080fd5b818501915085601f83011261184757600080fd5b81358181111561185957611859611714565b611867848260051b0161172a565b818152848101925060c091820284018501918883111561188657600080fd5b938501935b828510156118ac5761189d8986611770565b8452938401939285019261188b565b50979650505050505050565b600060c082840312156118ca57600080fd5b61076b8383611770565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600060018201611912576119126118ea565b5060010190565b60006020828403121561192b57600080fd5b815161076b816116b6565b60006020828403121561194857600080fd5b815160ff8116811461076b57600080fd5b600181815b8085111561199457816000190482111561197a5761197a6118ea565b8085161561198757918102915b93841c939080029061195e565b509250929050565b6000826119ab575060016113f1565b816119b8575060006113f1565b81600181146119ce57600281146119d8576119f4565b60019150506113f1565b60ff8411156119e9576119e96118ea565b50506001821b6113f1565b5060208310610133831016604e8410600b8410161715611a17575081810a6113f1565b611a218383611959565b8060001904821115611a3557611a356118ea565b029392505050565b600061076b60ff84168361199c565b600060ff821660ff841680821015611a6657611a666118ea565b90039392505050565b6000816000190483118215151615611a8957611a896118ea565b500290565b600060208284031215611aa057600080fd5b5051919050565b80516001600160701b038116811461176b57600080fd5b600080600060608486031215611ad357600080fd5b611adc84611aa7565b9250611aea60208501611aa7565b9150604084015163ffffffff81168114611b0357600080fd5b809150509250925092565b600082821015611b2057611b206118ea565b500390565b634e487b7160e01b600052601260045260246000fd5b600082611b4a57611b4a611b25565b500490565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b600082611ba957611ba9611b25565b500690565b60006001600160e01b0383811680611bc857611bc8611b25565b9216919091049291505056fea2646970667358221220169f7039201eaee6ac8916f3c32c3d615a2c1fa9eb6aafcecbb2f7c1e0a84bb464736f6c634300080d0033",
573
+ "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106101165760003560e01c8063725068a5116100a2578063b8a8a62611610071578063b8a8a62614610277578063cbf67919146102e1578063cfed246b146102f4578063f2fde38b14610314578063fc57d4df1461032757600080fd5b8063725068a51461028e5780638129fc1c146102a15780638da5cb5b146102a95780638dd95002146102ba57600080fd5b80633334ecc5116100e95780633334ecc5146102185780635ba3792d14610238578063609f0f361461027757806369aa3ac614610277578063715018a61461028657600080fd5b8063024599661461011b5780631b69dc5f14610148578063234a3446146101e25780632b9d9dea146101f7575b600080fd5b61012e6101293660046116cb565b61033a565b604080519283526020830191909152015b60405180910390f35b6101a06101563660046116f7565b60656020526000908152604090208054600182015460028301546003909301546001600160a01b0392831693919282169160ff600160a01b8204811692600160a81b909204169086565b604080516001600160a01b03978816815260208101969096529390951692840192909252151560608301521515608082015260a081019190915260c00161013f565b6101f56101f0366004611808565b610376565b005b61020a6102053660046118b8565b61040c565b60405190815260200161013f565b61020a6102263660046116f7565b60686020526000908152604090205481565b61025f7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b03909116815260200161013f565b61020a670de0b6b3a764000081565b6101f561043b565b61020a61029c3660046116f7565b61044f565b6101f5610772565b6033546001600160a01b031661025f565b61025f7f000000000000000000000000000000000000000000000000000000000000000081565b6101f56102ef3660046118b8565b610883565b61020a6103023660046116f7565b60666020526000908152604090205481565b6101f56103223660046116f7565b610bc7565b61020a6103353660046116f7565b610c3d565b6067602052816000526040600020818154811061035657600080fd5b600091825260209091206002909102018054600190910154909250905082565b61037e610e4e565b60008151116103c85760405162461bcd60e51b815260206004820152601160248201527006c656e6774682063616e2774206265203607c1b60448201526064015b60405180910390fd5b805160005b81811015610407576103f78382815181106103ea576103ea6118d4565b6020026020010151610883565b61040081611900565b90506103cd565b505050565b600080600061041e8460400151610ea8565b5091509150836080015115610434579392505050565b5092915050565b610443610e4e565b61044d6000611050565b565b6000807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316836001600160a01b0316146104f257826001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa1580156104c9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104ed9190611919565b610514565b7f00000000000000000000000000000000000000000000000000000000000000005b6001600160a01b03808216600090815260656020526040902054919250166105705760405162461bcd60e51b815260206004820152600f60248201526e185cdcd95d081b9bdd08195e1a5cdd608a1b60448201526064016103bf565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316816001600160a01b0316141580156105d457506001600160a01b038116600090815260656020526040902060020154600160a01b900460ff165b156106ef576001600160a01b037f00000000000000000000000000000000000000000000000000000000000000008116600090815260656020526040902054166106515760405162461bcd60e51b815260206004820152600e60248201526d15d09390881b9bdd08195e1a5cdd60921b60448201526064016103bf565b6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000008116600090815260656020908152604091829020825160c08101845281548516815260018201549281019290925260028101549384169282019290925260ff600160a01b8404811615156060830152600160a81b909304909216151560808301526003015460a08201526106ed906110a2565b505b6001600160a01b03808216600090815260656020908152604091829020825160c08101845281548516815260018201549281019290925260028101549384169282019290925260ff600160a01b8404811615156060830152600160a81b909304909216151560808301526003015460a082015261076b906110a2565b9392505050565b600054610100900460ff16158080156107925750600054600160ff909116105b806107ac5750303b1580156107ac575060005460ff166001145b61080f5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016103bf565b6000805460ff191660011790558015610832576000805461ff0019166101001790555b61083a611300565b8015610880576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50565b61088b610e4e565b80516001600160a01b0381166108db5760405162461bcd60e51b815260206004820152601560248201527463616e2774206265207a65726f206164647265737360581b60448201526064016103bf565b60408201516001600160a01b03811661092e5760405162461bcd60e51b815260206004820152601560248201527463616e2774206265207a65726f206164647265737360581b60448201526064016103bf565b60008360a00151116109825760405162461bcd60e51b815260206004820152601e60248201527f616e63686f7220706572696f64206d75737420626520706f736974697665000060448201526064016103bf565b60008360200151116109d65760405162461bcd60e51b815260206004820152601a60248201527f6261736520756e6974206d75737420626520706f73697469766500000000000060448201526064016103bf565b82600001516001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610a18573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a3c9190611936565b610a4790600a611a3d565b836020015114610ab35760405162461bcd60e51b815260206004820152603160248201527f6261736520756e697420646563696d616c73206d7573742062652073616d6520604482015270617320617373657420646563696d616c7360781b60648201526084016103bf565b6000610abe8461040c565b84516001600160a01b03908116600090815260676020908152604080832081518083018352428152808401878152825460018181018555938752858720925160029182029093019283559051918301919091558a5186168552606584528285208b5181549088166001600160a01b031990911681178255948c015192810192909255828b0151908201805460608d015160808e01511515600160a81b0260ff60a81b19911515600160a01b026001600160a81b03199093169490991693841791909117169690961790955560a08a0151600390910181905590519495509390917f3cc8d9cb9370a23a8b9ffa75efa24cecb65c4693980e58260841adc474983c5f91a450505050565b610bcf610e4e565b6001600160a01b038116610c345760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016103bf565b61088081611050565b6000807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316836001600160a01b031614610ce057826001600160a01b0316636f307dc36040518163ffffffff1660e01b8152600401602060405180830381865afa158015610cb7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cdb9190611919565b610d02565b7f00000000000000000000000000000000000000000000000000000000000000005b6001600160a01b0380821660009081526065602052604090205491925016610d5e5760405162461bcd60e51b815260206004820152600f60248201526e185cdcd95d081b9bdd08195e1a5cdd608a1b60448201526064016103bf565b6001600160a01b03811660009081526066602052604090205480610dc45760405162461bcd60e51b815260206004820152601b60248201527f54574150207072696365206d75737420626520706f736974697665000000000060448201526064016103bf565b816001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610e02573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e269190611936565b610e31906012611a4c565b610e3c90600a611a3d565b610e469082611a6f565b949350505050565b6033546001600160a01b0316331461044d5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016103bf565b6000806000610eb561132f565b9050836001600160a01b0316635909c0d56040518163ffffffff1660e01b8152600401602060405180830381865afa158015610ef5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f199190611a8e565b9250836001600160a01b0316635a3d54936040518163ffffffff1660e01b8152600401602060405180830381865afa158015610f59573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f7d9190611a8e565b91506000806000866001600160a01b0316630902f1ac6040518163ffffffff1660e01b8152600401606060405180830381865afa158015610fc2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fe69190611abe565b9250925092508363ffffffff168163ffffffff16146110465780840363ffffffff81166110138486611345565b516001600160e01b031602969096019563ffffffff81166110348585611345565b516001600160e01b0316029590950194505b5050509193909250565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6000806000806110b1856113f7565b9250925092508042116111065760405162461bcd60e51b815260206004820152601a60248201527f6e6f77206d75737420636f6d65206166746572206265666f726500000000000060448201526064016103bf565b60006111128242611b0e565b90506000604051806020016040528083868861112e9190611b0e565b6111389190611b3b565b6001600160e01b031690529050600061115082611666565b90506000886060015161116b57670de0b6b3a7640000611175565b670de0b6b3a76400005b90506000818a602001518461118a9190611a6f565b6111949190611b3b565b9050896060015115611241576001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016600090815260666020526040812054908190036112205760405162461bcd60e51b8152602060048201526014602482015273189b98881c1c9a58d9481a5cc81a5b9d985b1a5960621b60448201526064016103bf565b670de0b6b3a76400006112338284611a6f565b61123d9190611b3b565b9150505b8060000361128a5760405162461bcd60e51b81526020600482015260166024820152750747761702070726963652063616e6e6f7420626520360541b60448201526064016103bf565b89516040805183815260208101899052428183015290516001600160a01b03909216917f7d881580fb2bb7844e8ecf8df26510247c4bbea2735d40bf0d9ac33c0d9acd819181900360600190a298516001600160a01b031660009081526066602052604090208990555096979650505050505050565b600054610100900460ff166113275760405162461bcd60e51b81526004016103bf90611b4f565b61044d611686565b600061134064010000000042611b9a565b905090565b6040805160208101909152600081526000826001600160701b0316116113ad5760405162461bcd60e51b815260206004820152601760248201527f4669786564506f696e743a204449565f42595f5a45524f00000000000000000060448201526064016103bf565b6040805160208101909152806113e36001600160701b0385166dffffffffffffffffffffffffffff60701b607088901b16611bae565b6001600160e01b0316905290505b92915050565b6000806000806114068561040c565b60a0860151909150429060009061141d9083611b0e565b87516001600160a01b0316600090815260676020908152604080832080548251818502810185019093528083529495509293909291849084015b8282101561149d57838290600052602060002090600202016040518060400160405290816000820154815260200160018201548152505081526020019060010190611457565b505082518b516001600160a01b0316600090815260686020526040902054939450929150505b818110156115b957838382815181106114de576114de6118d4565b60200260200101516000015110158061150057506114fd600183611b0e565b81145b1561156857828181518110611517576115176118d4565b6020026020010151602001519750828181518110611537576115376118d4565b602090810291909101810151518b516001600160a01b031660009081526068909252604090912082905596506115b9565b89516001600160a01b03166000908152606760205260409020805482908110611593576115936118d4565b600091825260208220600290910201818155600101556115b281611900565b90506114c3565b5088516001600160a01b039081166000908152606760209081526040808320815180830183528981528084018b81528254600180820185559387529585902091516002909602909101948555519301929092558b5182518a81529182018b90524292820192909252606081018890529116907f87208a84ec7402c933c70c261e53b733a9f1c893d73e941a152435d58177a2649060800160405180910390a2509295505050509193909250565b80516000906113f1906612725dd1d243ab906001600160e01b0316611b3b565b600054610100900460ff166116ad5760405162461bcd60e51b81526004016103bf90611b4f565b61044d33611050565b6001600160a01b038116811461088057600080fd5b600080604083850312156116de57600080fd5b82356116e9816116b6565b946020939093013593505050565b60006020828403121561170957600080fd5b813561076b816116b6565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff8111828210171561175357611753611714565b604052919050565b8035801515811461176b57600080fd5b919050565b600060c0828403121561178257600080fd5b60405160c0810181811067ffffffffffffffff821117156117a5576117a5611714565b60405290508082356117b6816116b6565b81526020838101359082015260408301356117d0816116b6565b60408201526117e16060840161175b565b60608201526117f26080840161175b565b608082015260a083013560a08201525092915050565b6000602080838503121561181b57600080fd5b823567ffffffffffffffff8082111561183357600080fd5b818501915085601f83011261184757600080fd5b81358181111561185957611859611714565b611867848260051b0161172a565b818152848101925060c091820284018501918883111561188657600080fd5b938501935b828510156118ac5761189d8986611770565b8452938401939285019261188b565b50979650505050505050565b600060c082840312156118ca57600080fd5b61076b8383611770565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600060018201611912576119126118ea565b5060010190565b60006020828403121561192b57600080fd5b815161076b816116b6565b60006020828403121561194857600080fd5b815160ff8116811461076b57600080fd5b600181815b8085111561199457816000190482111561197a5761197a6118ea565b8085161561198757918102915b93841c939080029061195e565b509250929050565b6000826119ab575060016113f1565b816119b8575060006113f1565b81600181146119ce57600281146119d8576119f4565b60019150506113f1565b60ff8411156119e9576119e96118ea565b50506001821b6113f1565b5060208310610133831016604e8410600b8410161715611a17575081810a6113f1565b611a218383611959565b8060001904821115611a3557611a356118ea565b029392505050565b600061076b60ff84168361199c565b600060ff821660ff841680821015611a6657611a666118ea565b90039392505050565b6000816000190483118215151615611a8957611a896118ea565b500290565b600060208284031215611aa057600080fd5b5051919050565b80516001600160701b038116811461176b57600080fd5b600080600060608486031215611ad357600080fd5b611adc84611aa7565b9250611aea60208501611aa7565b9150604084015163ffffffff81168114611b0357600080fd5b809150509250925092565b600082821015611b2057611b206118ea565b500390565b634e487b7160e01b600052601260045260246000fd5b600082611b4a57611b4a611b25565b500490565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b600082611ba957611ba9611b25565b500690565b60006001600160e01b0383811680611bc857611bc8611b25565b9216919091049291505056fea2646970667358221220169f7039201eaee6ac8916f3c32c3d615a2c1fa9eb6aafcecbb2f7c1e0a84bb464736f6c634300080d0033",
540
574
  "devdoc": {
541
575
  "kind": "dev",
542
576
  "methods": {
577
+ "constructor": {
578
+ "custom:oz-upgrades-unsafe-allow": "constructor",
579
+ "params": {
580
+ "vBnbAddress": "The address of the VBNB",
581
+ "wBnbAddress": "The address of the WBNB"
582
+ }
583
+ },
543
584
  "currentCumulativePrice((address,uint256,address,bool,bool,uint256))": {
544
585
  "returns": {
545
586
  "_0": "cumulative price of target token regardless of pair order"
546
587
  }
547
588
  },
548
589
  "getUnderlyingPrice(address)": {
590
+ "custom:error": "Missing error is thrown if the token config does not existRange error is thrown if TWAP price is not greater than zero",
549
591
  "params": {
550
592
  "vToken": "vToken address"
551
593
  },
552
594
  "returns": {
553
- "_0": "price in USD, with 18 decimals"
595
+ "_0": "price Underlying price in USD"
554
596
  }
555
597
  },
556
598
  "owner()": {
@@ -560,17 +602,35 @@
560
602
  "details": "Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner."
561
603
  },
562
604
  "setTokenConfig((address,uint256,address,bool,bool,uint256))": {
605
+ "custom:access": "Only Governance",
606
+ "custom:error": "Range error is thrown if anchor period is not greater than zeroRange error is thrown if base unit is not greater than zeroValue error is thrown if base unit decimals is not the same as asset decimalsNotNullAddress error is thrown if address of asset is nullNotNullAddress error is thrown if PancakeSwap pool address is null",
607
+ "custom:event": "Emits TokenConfigAdded event if new token config are added with asset address, PancakePool address, anchor period address",
563
608
  "params": {
564
609
  "config": "token config struct"
565
610
  }
566
611
  },
567
612
  "setTokenConfigs((address,uint256,address,bool,bool,uint256)[])": {
613
+ "custom:error": "Zero length error thrown, if length of the config array is 0",
568
614
  "params": {
569
- "configs": "config array"
615
+ "configs": "Config array"
570
616
  }
571
617
  },
572
618
  "transferOwnership(address)": {
573
619
  "details": "Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner."
620
+ },
621
+ "updateTwap(address)": {
622
+ "custom:error": "Missing error is thrown if token config does not exist",
623
+ "returns": {
624
+ "_0": "vToken Address of vToken"
625
+ }
626
+ }
627
+ },
628
+ "stateVariables": {
629
+ "WBNB": {
630
+ "custom:oz-upgrades-unsafe-allow": "state-variable-immutable"
631
+ },
632
+ "vBnb": {
633
+ "custom:oz-upgrades-unsafe-allow": "state-variable-immutable"
574
634
  }
575
635
  },
576
636
  "version": 1
@@ -595,29 +655,41 @@
595
655
  "bnbBaseUnit()": {
596
656
  "notice": "the base unit of WBNB and BUSD, which are the paired tokens for all assets"
597
657
  },
658
+ "constructor": {
659
+ "notice": "Constructor for the implementation contract. Sets immutable variables."
660
+ },
598
661
  "currentCumulativePrice((address,uint256,address,bool,bool,uint256))": {
599
- "notice": "Fetches the current token/WBNB and token/BUSD price accumulator from pancakeswap."
662
+ "notice": "Fetches the current token/WBNB and token/BUSD price accumulator from PancakeSwap."
600
663
  },
601
664
  "getUnderlyingPrice(address)": {
602
- "notice": "Get the underlying TWAP price of input vToken"
665
+ "notice": "Get the underlying TWAP price for the given vToken"
603
666
  },
604
- "newObservations(address)": {
605
- "notice": "The current price observation of TWAP. With old and current observations we can calculate the TWAP between this range"
667
+ "initialize()": {
668
+ "notice": "Initializes the owner of the contract and sets the contracts required"
606
669
  },
607
- "oldObservations(address)": {
608
- "notice": "The old price observation of TWAP"
670
+ "observations(address,uint256)": {
671
+ "notice": "Keeps a record of token observations mapped by address, updated on every updateTwap invocation."
609
672
  },
610
673
  "prices(address)": {
611
674
  "notice": "Stored price by token"
612
675
  },
613
676
  "setTokenConfig((address,uint256,address,bool,bool,uint256))": {
614
- "notice": "Add single token configs"
677
+ "notice": "Adds a single token config"
615
678
  },
616
679
  "setTokenConfigs((address,uint256,address,bool,bool,uint256)[])": {
617
- "notice": "Add multiple token configs at the same time"
680
+ "notice": "Adds multiple token configs at the same time"
618
681
  },
619
682
  "tokenConfigs(address)": {
620
683
  "notice": "Configs by token"
684
+ },
685
+ "updateTwap(address)": {
686
+ "notice": "Updates the current token/BUSD price from PancakeSwap, with 18 decimals of precision."
687
+ },
688
+ "vBnb()": {
689
+ "notice": "vBNB address"
690
+ },
691
+ "windowStart(address)": {
692
+ "notice": "Observation array index which probably falls in current anchor period mapped by asset address"
621
693
  }
622
694
  },
623
695
  "version": 1
@@ -625,7 +697,7 @@
625
697
  "storageLayout": {
626
698
  "storage": [
627
699
  {
628
- "astId": 138,
700
+ "astId": 241,
629
701
  "contract": "contracts/oracles/TwapOracle.sol:TwapOracle",
630
702
  "label": "_initialized",
631
703
  "offset": 0,
@@ -633,7 +705,7 @@
633
705
  "type": "t_uint8"
634
706
  },
635
707
  {
636
- "astId": 141,
708
+ "astId": 244,
637
709
  "contract": "contracts/oracles/TwapOracle.sol:TwapOracle",
638
710
  "label": "_initializing",
639
711
  "offset": 1,
@@ -641,7 +713,7 @@
641
713
  "type": "t_bool"
642
714
  },
643
715
  {
644
- "astId": 693,
716
+ "astId": 855,
645
717
  "contract": "contracts/oracles/TwapOracle.sol:TwapOracle",
646
718
  "label": "__gap",
647
719
  "offset": 0,
@@ -649,7 +721,7 @@
649
721
  "type": "t_array(t_uint256)50_storage"
650
722
  },
651
723
  {
652
- "astId": 10,
724
+ "astId": 113,
653
725
  "contract": "contracts/oracles/TwapOracle.sol:TwapOracle",
654
726
  "label": "_owner",
655
727
  "offset": 0,
@@ -657,7 +729,7 @@
657
729
  "type": "t_address"
658
730
  },
659
731
  {
660
- "astId": 130,
732
+ "astId": 233,
661
733
  "contract": "contracts/oracles/TwapOracle.sol:TwapOracle",
662
734
  "label": "__gap",
663
735
  "offset": 0,
@@ -665,43 +737,35 @@
665
737
  "type": "t_array(t_uint256)49_storage"
666
738
  },
667
739
  {
668
- "astId": 6560,
740
+ "astId": 6431,
669
741
  "contract": "contracts/oracles/TwapOracle.sol:TwapOracle",
670
- "label": "WBNB",
742
+ "label": "tokenConfigs",
671
743
  "offset": 0,
672
744
  "slot": "101",
673
- "type": "t_address"
745
+ "type": "t_mapping(t_address,t_struct(TokenConfig)6403_storage)"
674
746
  },
675
747
  {
676
- "astId": 6576,
748
+ "astId": 6436,
677
749
  "contract": "contracts/oracles/TwapOracle.sol:TwapOracle",
678
- "label": "tokenConfigs",
750
+ "label": "prices",
679
751
  "offset": 0,
680
752
  "slot": "102",
681
- "type": "t_mapping(t_address,t_struct(TokenConfig)6551_storage)"
753
+ "type": "t_mapping(t_address,t_uint256)"
682
754
  },
683
755
  {
684
- "astId": 6582,
756
+ "astId": 6443,
685
757
  "contract": "contracts/oracles/TwapOracle.sol:TwapOracle",
686
- "label": "newObservations",
758
+ "label": "observations",
687
759
  "offset": 0,
688
760
  "slot": "103",
689
- "type": "t_mapping(t_address,t_struct(Observation)6532_storage)"
761
+ "type": "t_mapping(t_address,t_array(t_struct(Observation)6384_storage)dyn_storage)"
690
762
  },
691
763
  {
692
- "astId": 6588,
764
+ "astId": 6448,
693
765
  "contract": "contracts/oracles/TwapOracle.sol:TwapOracle",
694
- "label": "oldObservations",
766
+ "label": "windowStart",
695
767
  "offset": 0,
696
768
  "slot": "104",
697
- "type": "t_mapping(t_address,t_struct(Observation)6532_storage)"
698
- },
699
- {
700
- "astId": 6593,
701
- "contract": "contracts/oracles/TwapOracle.sol:TwapOracle",
702
- "label": "prices",
703
- "offset": 0,
704
- "slot": "105",
705
769
  "type": "t_mapping(t_address,t_uint256)"
706
770
  }
707
771
  ],
@@ -711,6 +775,12 @@
711
775
  "label": "address",
712
776
  "numberOfBytes": "20"
713
777
  },
778
+ "t_array(t_struct(Observation)6384_storage)dyn_storage": {
779
+ "base": "t_struct(Observation)6384_storage",
780
+ "encoding": "dynamic_array",
781
+ "label": "struct Observation[]",
782
+ "numberOfBytes": "32"
783
+ },
714
784
  "t_array(t_uint256)49_storage": {
715
785
  "base": "t_uint256",
716
786
  "encoding": "inplace",
@@ -728,19 +798,19 @@
728
798
  "label": "bool",
729
799
  "numberOfBytes": "1"
730
800
  },
731
- "t_mapping(t_address,t_struct(Observation)6532_storage)": {
801
+ "t_mapping(t_address,t_array(t_struct(Observation)6384_storage)dyn_storage)": {
732
802
  "encoding": "mapping",
733
803
  "key": "t_address",
734
- "label": "mapping(address => struct Observation)",
804
+ "label": "mapping(address => struct Observation[])",
735
805
  "numberOfBytes": "32",
736
- "value": "t_struct(Observation)6532_storage"
806
+ "value": "t_array(t_struct(Observation)6384_storage)dyn_storage"
737
807
  },
738
- "t_mapping(t_address,t_struct(TokenConfig)6551_storage)": {
808
+ "t_mapping(t_address,t_struct(TokenConfig)6403_storage)": {
739
809
  "encoding": "mapping",
740
810
  "key": "t_address",
741
811
  "label": "mapping(address => struct TokenConfig)",
742
812
  "numberOfBytes": "32",
743
- "value": "t_struct(TokenConfig)6551_storage"
813
+ "value": "t_struct(TokenConfig)6403_storage"
744
814
  },
745
815
  "t_mapping(t_address,t_uint256)": {
746
816
  "encoding": "mapping",
@@ -749,12 +819,12 @@
749
819
  "numberOfBytes": "32",
750
820
  "value": "t_uint256"
751
821
  },
752
- "t_struct(Observation)6532_storage": {
822
+ "t_struct(Observation)6384_storage": {
753
823
  "encoding": "inplace",
754
824
  "label": "struct Observation",
755
825
  "members": [
756
826
  {
757
- "astId": 6529,
827
+ "astId": 6381,
758
828
  "contract": "contracts/oracles/TwapOracle.sol:TwapOracle",
759
829
  "label": "timestamp",
760
830
  "offset": 0,
@@ -762,7 +832,7 @@
762
832
  "type": "t_uint256"
763
833
  },
764
834
  {
765
- "astId": 6531,
835
+ "astId": 6383,
766
836
  "contract": "contracts/oracles/TwapOracle.sol:TwapOracle",
767
837
  "label": "acc",
768
838
  "offset": 0,
@@ -772,12 +842,12 @@
772
842
  ],
773
843
  "numberOfBytes": "64"
774
844
  },
775
- "t_struct(TokenConfig)6551_storage": {
845
+ "t_struct(TokenConfig)6403_storage": {
776
846
  "encoding": "inplace",
777
847
  "label": "struct TokenConfig",
778
848
  "members": [
779
849
  {
780
- "astId": 6535,
850
+ "astId": 6387,
781
851
  "contract": "contracts/oracles/TwapOracle.sol:TwapOracle",
782
852
  "label": "asset",
783
853
  "offset": 0,
@@ -785,7 +855,7 @@
785
855
  "type": "t_address"
786
856
  },
787
857
  {
788
- "astId": 6538,
858
+ "astId": 6390,
789
859
  "contract": "contracts/oracles/TwapOracle.sol:TwapOracle",
790
860
  "label": "baseUnit",
791
861
  "offset": 0,
@@ -793,7 +863,7 @@
793
863
  "type": "t_uint256"
794
864
  },
795
865
  {
796
- "astId": 6541,
866
+ "astId": 6393,
797
867
  "contract": "contracts/oracles/TwapOracle.sol:TwapOracle",
798
868
  "label": "pancakePool",
799
869
  "offset": 0,
@@ -801,7 +871,7 @@
801
871
  "type": "t_address"
802
872
  },
803
873
  {
804
- "astId": 6544,
874
+ "astId": 6396,
805
875
  "contract": "contracts/oracles/TwapOracle.sol:TwapOracle",
806
876
  "label": "isBnbBased",
807
877
  "offset": 20,
@@ -809,7 +879,7 @@
809
879
  "type": "t_bool"
810
880
  },
811
881
  {
812
- "astId": 6547,
882
+ "astId": 6399,
813
883
  "contract": "contracts/oracles/TwapOracle.sol:TwapOracle",
814
884
  "label": "isReversedPool",
815
885
  "offset": 21,
@@ -817,7 +887,7 @@
817
887
  "type": "t_bool"
818
888
  },
819
889
  {
820
- "astId": 6550,
890
+ "astId": 6402,
821
891
  "contract": "contracts/oracles/TwapOracle.sol:TwapOracle",
822
892
  "label": "anchorPeriod",
823
893
  "offset": 0,