Address Contract Verified
Address
0xDaa4B74C6bAc4e25188e64ebc68DB5050b690cAc
Balance
0 ETH
Nonce
1
Code Size
1554 bytes
Creator
0x914d7Fec...43d7 at tx 0x81d67eba...6823c0
Indexed Transactions
0
Contract Bytecode
1554 bytes
0x608060405234801561000f575f80fd5b5060043610610085575f3560e01c80637284e416116100585780637284e4161461010b578063910bb70c14610120578063918f86741461015f578063de4aedab14610186575f80fd5b80630417cf8e146100895780632e0f2625146100a8578063313ce567146100cf57806350d25bcd146100f5575b5f80fd5b610091601281565b60405160ff90911681526020015b60405180910390f35b6100917f000000000000000000000000000000000000000000000000000000000000000881565b7f0000000000000000000000000000000000000000000000000000000000000008610091565b6100fd6101ad565b60405190815260200161009f565b610113610341565b60405161009f91906103d0565b6101477f000000000000000000000000fdfd9c85ad200c506cf9e21f1fd8dd01932fbb2381565b6040516001600160a01b03909116815260200161009f565b6100fd7f000000000000000000000000000000000000000000000000002386f26fc1000081565b6101477f000000000000000000000000b41e773f507f7a7ea890b1afb7d2b660c30c8b0a81565b5f807f000000000000000000000000fdfd9c85ad200c506cf9e21f1fd8dd01932fbb236001600160a01b03166350d25bcd6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561020b573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061022f919061041b565b90505f7f000000000000000000000000b41e773f507f7a7ea890b1afb7d2b660c30c8b0a6001600160a01b03166350d25bcd6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561028e573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906102b2919061041b565b90505f821315806102c357505f8113155b156102d0575f9250505090565b7f000000000000000000000000000000000000000000000000002386f26fc1000061031c7f0000000000000000000000000000000000000000000000000000000000000008600a610528565b610326838561053d565b610330919061053d565b61033a919061056c565b9250505090565b60605f805461034f906105a4565b80601f016020809104026020016040519081016040528092919081815260200182805461037b906105a4565b80156103c65780601f1061039d576101008083540402835291602001916103c6565b820191905f5260205f20905b8154815290600101906020018083116103a957829003601f168201915b5050505050905090565b5f6020808352835180828501525f5b818110156103fb578581018301518582016040015282016103df565b505f604082860101526040601f19601f8301168501019250505092915050565b5f6020828403121561042b575f80fd5b5051919050565b634e487b7160e01b5f52601160045260245ffd5b600181815b8085111561048057815f190482111561046657610466610432565b8085161561047357918102915b93841c939080029061044b565b509250929050565b5f8261049657506001610522565b816104a257505f610522565b81600181146104b857600281146104c2576104de565b6001915050610522565b60ff8411156104d3576104d3610432565b50506001821b610522565b5060208310610133831016604e8410600b8410161715610501575081810a610522565b61050b8383610446565b805f190482111561051e5761051e610432565b0290505b92915050565b5f61053660ff841683610488565b9392505050565b8082025f8212600160ff1b8414161561055857610558610432565b818105831482151761052257610522610432565b5f8261058657634e487b7160e01b5f52601260045260245ffd5b600160ff1b82145f198414161561059f5761059f610432565b500590565b600181811c908216806105b857607f821691505b6020821081036105d657634e487b7160e01b5f52602260045260245ffd5b5091905056fea26469706673582212209239dcb18b1a9a7e41abd34dda3b103442fe6cd9cf8b0fc211066af40ca11f9f64736f6c63430008140033
Verified Source Code Full Match
Compiler: v0.8.20+commit.a1b79de6
EVM: shanghai
Optimization: Yes (200 runs)
CLSynchronicityPriceAdapterPegToBase.sol 93 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import {IChainlinkAggregator} from '../interfaces/IChainlinkAggregator.sol';
import {ICLSynchronicityPriceAdapter} from '../interfaces/ICLSynchronicityPriceAdapter.sol';
/**
* @title CLSynchronicityPriceAdapter
* @author BGD Labs
* @notice Price adapter to calculate price of (Asset / Base) pair by using
* @notice Chainlink Data Feeds for (Asset / Peg) and (Peg / Base) pairs.
* @notice For example it can be used to calculate stETH / USD
* @notice based on stETH / ETH and ETH / USD feeds.
*/
contract CLSynchronicityPriceAdapterPegToBase is ICLSynchronicityPriceAdapter {
/**
* @notice Price feed for (Base / Peg) pair
*/
IChainlinkAggregator public immutable PEG_TO_BASE;
/**
* @notice Price feed for (Asset / Peg) pair
*/
IChainlinkAggregator public immutable ASSET_TO_PEG;
/**
* @notice Number of decimals in the output of this price adapter
*/
uint8 public immutable DECIMALS;
/**
* @notice This is a parameter to bring the resulting answer with the proper precision.
* @notice will be equal to 10 to the power of the sum decimals of feeds
*/
int256 public immutable DENOMINATOR;
/**
* @notice Maximum number of resulting and feed decimals
*/
uint8 public constant MAX_DECIMALS = 18;
string private _description;
/**
* @param pegToBaseAggregatorAddress the address of PEG / BASE feed
* @param assetToPegAggregatorAddress the address of the ASSET / PEG feed
* @param decimals precision of the answer
* @param pairDescription description
*/
constructor(
address pegToBaseAggregatorAddress,
address assetToPegAggregatorAddress,
uint8 decimals,
string memory pairDescription
) {
PEG_TO_BASE = IChainlinkAggregator(pegToBaseAggregatorAddress);
ASSET_TO_PEG = IChainlinkAggregator(assetToPegAggregatorAddress);
if (decimals > MAX_DECIMALS) revert DecimalsAboveLimit();
if (PEG_TO_BASE.decimals() > MAX_DECIMALS) revert DecimalsAboveLimit();
if (ASSET_TO_PEG.decimals() > MAX_DECIMALS) revert DecimalsAboveLimit();
DECIMALS = decimals;
_description = pairDescription;
// equal to 10 to the power of the sum decimals of feeds
unchecked {
DENOMINATOR = int256(10 ** (PEG_TO_BASE.decimals() + ASSET_TO_PEG.decimals()));
}
}
/// @inheritdoc ICLSynchronicityPriceAdapter
function description() external view returns (string memory) {
return _description;
}
/// @inheritdoc ICLSynchronicityPriceAdapter
function decimals() external view returns (uint8) {
return DECIMALS;
}
/// @inheritdoc ICLSynchronicityPriceAdapter
function latestAnswer() public view virtual override returns (int256) {
int256 assetToPegPrice = ASSET_TO_PEG.latestAnswer();
int256 pegToBasePrice = PEG_TO_BASE.latestAnswer();
if (assetToPegPrice <= 0 || pegToBasePrice <= 0) {
return 0;
}
return (assetToPegPrice * pegToBasePrice * int256(10 ** DECIMALS)) / (DENOMINATOR);
}
}
IChainlinkAggregator.sol 19 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface IChainlinkAggregator {
function decimals() external view returns (uint8);
function latestAnswer() external view returns (int256);
function latestTimestamp() external view returns (uint256);
function latestRound() external view returns (uint256);
function getAnswer(uint256 roundId) external view returns (int256);
function getTimestamp(uint256 roundId) external view returns (uint256);
event AnswerUpdated(int256 indexed current, uint256 indexed roundId, uint256 timestamp);
event NewRound(uint256 indexed roundId, address indexed startedBy);
}
ICLSynchronicityPriceAdapter.sol 26 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface ICLSynchronicityPriceAdapter {
/**
* @notice Calculates the current answer based on the aggregators.
* @return int256 latestAnswer
*/
function latestAnswer() external view returns (int256);
/**
* @notice Returns the description of the feed
* @return string desciption
*/
function description() external view returns (string memory);
/**
* @notice Returns the feed decimals
* @return uint8 decimals
*/
function decimals() external view returns (uint8);
error DecimalsAboveLimit();
error DecimalsNotEqual();
error RatioOutOfBounds();
}
Read Contract
ASSET_TO_PEG 0x910bb70c → address
DECIMALS 0x2e0f2625 → uint8
DENOMINATOR 0x918f8674 → int256
MAX_DECIMALS 0x0417cf8e → uint8
PEG_TO_BASE 0xde4aedab → address
decimals 0x313ce567 → uint8
description 0x7284e416 → string
latestAnswer 0x50d25bcd → int256
Recent Transactions
No transactions found for this address