Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
This contract has been verified via Sourcify.
View contract in Sourcify repository
- Contract name:
- TarotSolidlyPriceOracleV2
- Optimization enabled
- true
- Compiler version
- v0.5.16+commit.9c3226ce
- Optimization runs
- 10000
- EVM Version
- istanbul
- Verified at
- 2026-04-22T16:11:14.822979Z
contracts/TarotSolidlyPriceOracleV2.sol
pragma solidity =0.5.16;
import "./interfaces/ISolidlyBaseV1Pair.sol";
import "./interfaces/ITarotSolidlyPriceOracleV2.sol";
contract TarotSolidlyPriceOracleV2 is ITarotSolidlyPriceOracleV2 {
uint32 public constant MIN_T = 900;
function safe112(uint256 n) internal pure returns (uint112) {
require(n < 2**112, "TarotSolidlyPriceOracleV2: SAFE112");
return uint112(n);
}
function getResult(address pair) external returns (uint112 reserve0, uint112 reserve1, uint32 T) {
(
uint256 reserve0CumulativeCurrent,
uint256 reserve1CumulativeCurrent,
uint256 blockTimestampCurrent
) = ISolidlyBaseV1Pair(pair).currentCumulativePrices();
uint256 observationLength = ISolidlyBaseV1Pair(pair).observationLength();
(
uint256 blockTimestampLast,
uint256 reserve0CumulativeLast,
uint256 reserve1CumulativeLast
) = ISolidlyBaseV1Pair(pair).observations(observationLength - 1);
T = uint32(blockTimestampCurrent - blockTimestampLast);
if (T < MIN_T) {
(
blockTimestampLast,
reserve0CumulativeLast,
reserve1CumulativeLast
) = ISolidlyBaseV1Pair(pair).observations(observationLength - 2);
T = uint32(blockTimestampCurrent - blockTimestampLast);
}
reserve0 = safe112((reserve0CumulativeCurrent - reserve0CumulativeLast) / T);
reserve1 = safe112((reserve1CumulativeCurrent - reserve1CumulativeLast) / T);
}
}
/
pragma solidity >=0.5;
interface ITarotSolidlyPriceOracleV2 {
function MIN_T() external pure returns (uint32);
function getResult(address pair) external returns (uint112 reserve0, uint112 reserve1, uint32 T);
}
/
pragma solidity >=0.5;
interface ISolidlyBaseV1Pair {
function getReserves()
external
view
returns (
uint112 _reserve0,
uint112 _reserve1,
uint32 _blockTimestampLast
);
function reserve0CumulativeLast() external view returns (uint256);
function reserve1CumulativeLast() external view returns (uint256);
function currentCumulativePrices()
external
view
returns (
uint256 reserve0Cumulative,
uint256 reserve1Cumulative,
uint256 blockTimestamp
);
function stable() external view returns (bool);
function observationLength() external view returns (uint256);
function observations(uint256) external view returns (uint256 timestamp, uint256 reserve0Cumulative, uint256 reserve1Cumulative);
}
Compiler Settings
{"remappings":[],"optimizer":{"runs":10000,"enabled":true},"libraries":{},"evmVersion":"istanbul","compilationTarget":{"contracts/TarotSolidlyPriceOracleV2.sol":"TarotSolidlyPriceOracleV2"}}
Contract ABI
[{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint32","name":"","internalType":"uint32"}],"name":"MIN_T","inputs":[],"constant":true},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[{"type":"uint112","name":"reserve0","internalType":"uint112"},{"type":"uint112","name":"reserve1","internalType":"uint112"},{"type":"uint32","name":"T","internalType":"uint32"}],"name":"getResult","inputs":[{"type":"address","name":"pair","internalType":"address"}],"constant":false}]
Contract Creation Code
0x608060405234801561001057600080fd5b50610478806100206000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c8063446a37e01461003b578063f51b5531146100a5575b600080fd5b61006e6004803603602081101561005157600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166100c6565b604080516dffffffffffffffffffffffffffff948516815292909316602083015263ffffffff168183015290519081900360600190f35b6100ad6103ae565b6040805163ffffffff9092168252519081900360200190f35b6000806000806000808673ffffffffffffffffffffffffffffffffffffffff16631df8c7176040518163ffffffff1660e01b815260040160606040518083038186803b15801561011557600080fd5b505afa158015610129573d6000803e3d6000fd5b505050506040513d606081101561013f57600080fd5b50805160208083015160409384015184517febeb31db0000000000000000000000000000000000000000000000000000000081529451939750909550935060009273ffffffffffffffffffffffffffffffffffffffff8b169263ebeb31db92600480840193919291829003018186803b1580156101bb57600080fd5b505afa1580156101cf573d6000803e3d6000fd5b505050506040513d60208110156101e557600080fd5b5051604080517f252c09d70000000000000000000000000000000000000000000000000000000081527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8301600482015290519192506000918291829173ffffffffffffffffffffffffffffffffffffffff8d169163252c09d7916024808301926060929190829003018186803b15801561027f57600080fd5b505afa158015610293573d6000803e3d6000fd5b505050506040513d60608110156102a957600080fd5b50805160208201516040909201518188039a50909450909250905061038463ffffffff8916101561036e578a73ffffffffffffffffffffffffffffffffffffffff1663252c09d7600286036040518263ffffffff1660e01b81526004018082815260200191505060606040518083038186803b15801561032857600080fd5b505afa15801561033c573d6000803e3d6000fd5b505050506040513d606081101561035257600080fd5b50805160208201516040909201518188039a5090945090925090505b6103888863ffffffff168389038161038257fe5b046103b4565b995061039e8863ffffffff168288038161038257fe5b9850505050505050509193909250565b61038481565b60006e010000000000000000000000000000821061041d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806104226022913960400191505060405180910390fd5b509056fe5461726f74536f6c69646c7950726963654f7261636c6556323a2053414645313132a265627a7a7231582036fff6f57eaa5fc9d25d80102b4b4294057d995dec474c0c1518776b425b8b9d64736f6c63430005100032
Deployed ByteCode
0x608060405234801561001057600080fd5b50600436106100365760003560e01c8063446a37e01461003b578063f51b5531146100a5575b600080fd5b61006e6004803603602081101561005157600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166100c6565b604080516dffffffffffffffffffffffffffff948516815292909316602083015263ffffffff168183015290519081900360600190f35b6100ad6103ae565b6040805163ffffffff9092168252519081900360200190f35b6000806000806000808673ffffffffffffffffffffffffffffffffffffffff16631df8c7176040518163ffffffff1660e01b815260040160606040518083038186803b15801561011557600080fd5b505afa158015610129573d6000803e3d6000fd5b505050506040513d606081101561013f57600080fd5b50805160208083015160409384015184517febeb31db0000000000000000000000000000000000000000000000000000000081529451939750909550935060009273ffffffffffffffffffffffffffffffffffffffff8b169263ebeb31db92600480840193919291829003018186803b1580156101bb57600080fd5b505afa1580156101cf573d6000803e3d6000fd5b505050506040513d60208110156101e557600080fd5b5051604080517f252c09d70000000000000000000000000000000000000000000000000000000081527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8301600482015290519192506000918291829173ffffffffffffffffffffffffffffffffffffffff8d169163252c09d7916024808301926060929190829003018186803b15801561027f57600080fd5b505afa158015610293573d6000803e3d6000fd5b505050506040513d60608110156102a957600080fd5b50805160208201516040909201518188039a50909450909250905061038463ffffffff8916101561036e578a73ffffffffffffffffffffffffffffffffffffffff1663252c09d7600286036040518263ffffffff1660e01b81526004018082815260200191505060606040518083038186803b15801561032857600080fd5b505afa15801561033c573d6000803e3d6000fd5b505050506040513d606081101561035257600080fd5b50805160208201516040909201518188039a5090945090925090505b6103888863ffffffff168389038161038257fe5b046103b4565b995061039e8863ffffffff168288038161038257fe5b9850505050505050509193909250565b61038481565b60006e010000000000000000000000000000821061041d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806104226022913960400191505060405180910390fd5b509056fe5461726f74536f6c69646c7950726963654f7261636c6556323a2053414645313132a265627a7a7231582036fff6f57eaa5fc9d25d80102b4b4294057d995dec474c0c1518776b425b8b9d64736f6c63430005100032