ETH Price: $2,074.37 (+5.95%)
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

More Info

Private Name Tags

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To

There are no matching entries

1 Internal Transaction found.

Latest 1 internal transaction

Advanced mode:
Parent Transaction Hash Method Block
From
To
0x60c06040243246012026-01-27 7:13:3518 days ago1769498015  Contract Creation0 ETH
Loading...
Loading
Loading...
Loading
Cross-Chain Transactions

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
DiscountedMKRSKYAdapter

Compiler Version
v0.8.27+commit.40a35a09

Optimization Enabled:
Yes with 200 runs

Other Settings:
shanghai EvmVersion
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;

import {IDiscountedMKRSKYAdapter} from '../../interfaces/IDiscountedMKRSKYAdapter.sol';
import {IBasicFeed} from '../../interfaces/IBasicFeed.sol';
import {IMkrSky} from '../../interfaces/IMkrSky.sol';
import {IChainlinkAggregator} from '../../interfaces/IChainlinkAggregator.sol';

/**
 * @title DiscountedMKRSKYAdapter
 * @author BGD Labs
 * @notice Price adapter to calculate MKR price based on SKY price, a fixed exchange rate, and a dynamic discount.
 *         Designed for the Aave v3 protocol to be used during the active MKR to SKY migration.
 *
 * @dev Price Formula:
 *      MKR_price = SKY_price * EXCHANGE_RATE * (1 - discount)
 *
 *      Implementation:
 *      ((referenceFeedPrice * EXCHANGE_RATE) * (1e18 - discount())) / 1e18
 *
 *      Parameters:
 *      - REFERENCE_FEED: Chainlink SKY/USD price feed on Ethereum (constant)
 *      - EXCHANGE_RATE: MKR/SKY conversion rate (24000, meaning 1 MKR = 24000 SKY). This is a constant
 *        in the MkrSky contract, but cached here as immutable to avoid external calls on every price query.
 *      - discount(): Dynamically fetched from DISCOUNT_PROVIDER (MkrSky migration contract)
 *        Returns raw fee where 1e18 = 100%, 0.02e18 = 2%
 *
 *      Example:
 *      - SKY/USD price: $0.0665 (6650503 with 8 decimals)
 *      - Exchange rate: 24000
 *      - Discount: 2% (0.02e18)
 *      - Result: (6650503 * 24000) * (1e18 - 0.02e18) / 1e18 = ~$1564 (156489827040 with 8 decimals)
 *
 *      Constants/Immutables:
 *      - DISCOUNT_PROVIDER, REFERENCE_FEED, DESCRIPTION (constants)
 *      - EXCHANGE_RATE (cached from MkrSky.rate()), DECIMALS (immutable)
 *
 *      Assumptions:
 *      - If reference price <= 0 at query time, returns 0 (Aave handles that case)
 *      - DISCOUNT_PROVIDER returns fee (discount) in MkrSky format (1 ether = 100%)
 */
contract DiscountedMKRSKYAdapter is IDiscountedMKRSKYAdapter {
  /// @dev MkrSky migration contract on Ethereum that provides the dynamic fee/discount and exchange rate
  /// @inheritdoc IDiscountedMKRSKYAdapter
  address public constant DISCOUNT_PROVIDER = 0xA1Ea1bA18E88C381C724a75F23a130420C403f9a;

  /// @dev Chainlink SKY/USD price feed on Ethereum
  /// @inheritdoc IDiscountedMKRSKYAdapter
  IChainlinkAggregator public constant REFERENCE_FEED =
    IChainlinkAggregator(0xee10fE5E7aa92dd7b136597449c3d5813cFC5F18);

  string public constant DESCRIPTION = 'MKR/USD (calculated)';

  /// @inheritdoc IBasicFeed
  function description() external pure returns (string memory) {
    return DESCRIPTION;
  }

  /// @inheritdoc IBasicFeed
  uint8 public immutable DECIMALS;

  /// @dev MKR/SKY exchange rate cached from MkrSky.rate() (24000 = 1 MKR = 24000 SKY).
  ///      Constant in MkrSky, cached here to avoid external calls on every price query.
  /// @inheritdoc IDiscountedMKRSKYAdapter
  uint256 public immutable EXCHANGE_RATE;

  constructor() {
    DECIMALS = REFERENCE_FEED.decimals();
    EXCHANGE_RATE = IMkrSky(DISCOUNT_PROVIDER).rate();
  }

  /// @inheritdoc IBasicFeed
  function decimals() external view returns (uint8) {
    return DECIMALS;
  }

  /// @inheritdoc IBasicFeed
  /// @dev Returns 0 when:
  ///      - Reference feed price <= 0
  ///      - Due to integer division truncation when: referenceFeedPrice * 24000 * (1e18 - discount) < 1e18
  ///        For example, with referenceFeedPrice = 1 (smallest unit), zeroes when discount > ~99.996%
  ///        With current SKY/USD price (~$0.0665), zeroes when discount > ~99.9999999994%
  function latestAnswer() external view virtual returns (int256) {
    int256 rawPrice = REFERENCE_FEED.latestAnswer();

    // This should never happen, but as extra validation
    if (rawPrice <= 0) return 0;

    uint256 referenceFeedPrice = uint256(rawPrice);

    // e.g. (6650503 * 24000) * (1e18 - 0.02e18) / 1e18 = 156489827040 (~$1564 with 8 decimals)
    // Safe to cast as final price will always fit into int256
    return int256(((referenceFeedPrice * EXCHANGE_RATE) * (1e18 - discount())) / 1e18);
  }

  /// @inheritdoc IDiscountedMKRSKYAdapter
  function discount() public view returns (uint256) {
    /// @dev In the MkrSky migration contract, 1e18 = 100%, 0.1e18 = 10%, 0.01e18 = 1%
    /// The value is bounded to 100%
    return IMkrSky(DISCOUNT_PROVIDER).fee();
  }
}

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {IBasicFeed} from './IBasicFeed.sol';
import {IChainlinkAggregator} from './IChainlinkAggregator.sol';

/**
 * @title IDiscountedMKRSKYAdapter
 * @author BGD Labs
 * @notice Interface for the DiscountedMKRSKYAdapter price feed
 */
interface IDiscountedMKRSKYAdapter is IBasicFeed {
  /// @notice MKR/SKY exchange rate (24000, meaning 1 MKR = 24000 SKY). Cached from MkrSky.rate() at deployment.
  function EXCHANGE_RATE() external view returns (uint256);

  /// @notice MkrSky migration contract on Ethereum that provides the dynamic fee/discount
  function DISCOUNT_PROVIDER() external view returns (address);

  /// @notice Current discount applied to reduce the final MKR price
  /// @dev Dynamically fetched from DISCOUNT_PROVIDER. Returns raw fee where 1e18 = 100%
  function discount() external view returns (uint256);

  /// @notice Chainlink SKY/USD price feed on Ethereum (constant)
  function REFERENCE_FEED() external view returns (IChainlinkAggregator);
}

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface IBasicFeed {
  /**
   * @notice Returns the description of the feed
   * @return string description
   */
  function description() external view returns (string memory);

  /**
   * @notice Returns the feed decimals (for tooling compatibility)
   * @return uint8 decimals
   */
  function DECIMALS() external view returns (uint8);

  /**
   * @notice Returns the feed decimals
   * @return uint8 decimals
   */
  function decimals() external view returns (uint8);

  /**
   * @notice Returns the fixed hardcoded price of the feed
   * @return int256 latestAnswer
   */
  function latestAnswer() external view returns (int256);
}

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface IMkrSky {
  function fee() external view returns (uint256);
  function rate() external view returns (uint256);
}

// 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);
}

Settings
{
  "remappings": [
    "forge-std/=lib/forge-std/src/",
    "aave-address-book/=lib/aave-address-book/src/",
    "aave-helpers/=lib/aave-helpers/src/",
    "solidity-utils/=lib/aave-address-book/lib/aave-v3-origin/lib/solidity-utils/src/",
    "aave-v3-origin/=lib/aave-address-book/lib/aave-v3-origin/src/",
    "@openzeppelin/contracts-upgradeable/=lib/aave-address-book/lib/aave-v3-origin/lib/solidity-utils/lib/openzeppelin-contracts-upgradeable/contracts/",
    "@openzeppelin/contracts/=lib/aave-address-book/lib/aave-v3-origin/lib/solidity-utils/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/contracts/",
    "aave-v3-origin-tests/=lib/aave-helpers/lib/aave-address-book/lib/aave-v3-origin/tests/",
    "cl-synchronicity-price-adapter/=lib/cl-synchronicity-price-adapter/",
    "ds-test/=lib/cl-synchronicity-price-adapter/lib/forge-std/lib/ds-test/src/",
    "erc4626-tests/=lib/aave-address-book/lib/aave-v3-origin/lib/solidity-utils/lib/openzeppelin-contracts-upgradeable/lib/erc4626-tests/",
    "halmos-cheatcodes/=lib/aave-address-book/lib/aave-v3-origin/lib/solidity-utils/lib/openzeppelin-contracts-upgradeable/lib/halmos-cheatcodes/src/",
    "openzeppelin-contracts-upgradeable/=lib/aave-address-book/lib/aave-v3-origin/lib/solidity-utils/lib/openzeppelin-contracts-upgradeable/",
    "openzeppelin-contracts/=lib/aave-address-book/lib/aave-v3-origin/lib/solidity-utils/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/"
  ],
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "metadata": {
    "useLiteralContent": false,
    "bytecodeHash": "ipfs",
    "appendCBOR": true
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "evmVersion": "shanghai",
  "viaIR": false
}

Contract Security Audit

Contract ABI

API
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"DECIMALS","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DESCRIPTION","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DISCOUNT_PROVIDER","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"EXCHANGE_RATE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"REFERENCE_FEED","outputs":[{"internalType":"contract IChainlinkAggregator","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"description","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"discount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"latestAnswer","outputs":[{"internalType":"int256","name":"","type":"int256"}],"stateMutability":"view","type":"function"}]

60c060405234801561000f575f5ffd5b5073ee10fe5e7aa92dd7b136597449c3d5813cfc5f186001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610060573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906100849190610104565b60ff1660805260408051631627391760e11b8152905173a1ea1ba18e88c381c724a75f23a130420c403f9a91632c4e722e9160048083019260209291908290030181865afa1580156100d8573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906100fc919061012b565b60a052610142565b5f60208284031215610114575f5ffd5b815160ff81168114610124575f5ffd5b9392505050565b5f6020828403121561013b575f5ffd5b5051919050565b60805160a05161045b61016f5f395f8181609901526102a601525f818160d30152610109015261045b5ff3fe608060405234801561000f575f5ffd5b5060043610610090575f3560e01c806350d25bcd1161006357806350d25bcd146101605780636b6f4a9d146101685780637284e416146101705780637996362f146101a9578063f1ae8856146101c4575f5ffd5b806314a8bd0d146100945780632e0f2625146100ce578063313ce567146101075780633179e7f01461012d575b5f5ffd5b6100bb7f000000000000000000000000000000000000000000000000000000000000000081565b6040519081526020015b60405180910390f35b6100f57f000000000000000000000000000000000000000000000000000000000000000081565b60405160ff90911681526020016100c5565b7f00000000000000000000000000000000000000000000000000000000000000006100f5565b61014873ee10fe5e7aa92dd7b136597449c3d5813cfc5f1881565b6040516001600160a01b0390911681526020016100c5565b6100bb6101f7565b6100bb6102e6565b6040805180820190915260148152734d4b522f555344202863616c63756c617465642960601b60208201525b6040516100c59190610360565b61014873a1ea1ba18e88c381c724a75f23a130420c403f9a81565b61019c604051806040016040528060148152602001734d4b522f555344202863616c63756c617465642960601b81525081565b5f5f73ee10fe5e7aa92dd7b136597449c3d5813cfc5f186001600160a01b03166350d25bcd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610249573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061026d91906103ab565b90505f811361027d575f91505090565b80670de0b6b3a764000061028f6102e6565b6102a190670de0b6b3a76400006103d6565b6102cb7f0000000000000000000000000000000000000000000000000000000000000000846103ef565b6102d591906103ef565b6102df9190610406565b9250505090565b5f73a1ea1ba18e88c381c724a75f23a130420c403f9a6001600160a01b031663ddca3f436040518163ffffffff1660e01b8152600401602060405180830381865afa158015610337573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061035b91906103ab565b905090565b602081525f82518060208401525f5b8181101561038c576020818601810151604086840101520161036f565b505f604082850101526040601f19601f83011684010191505092915050565b5f602082840312156103bb575f5ffd5b5051919050565b634e487b7160e01b5f52601160045260245ffd5b818103818111156103e9576103e96103c2565b92915050565b80820281158282048414176103e9576103e96103c2565b5f8261042057634e487b7160e01b5f52601260045260245ffd5b50049056fea2646970667358221220f5133a791803903f3ac7c694794a568e3e06b60883a469ba55e9a89b5974f8e264736f6c634300081b0033

Deployed Bytecode

0x608060405234801561000f575f5ffd5b5060043610610090575f3560e01c806350d25bcd1161006357806350d25bcd146101605780636b6f4a9d146101685780637284e416146101705780637996362f146101a9578063f1ae8856146101c4575f5ffd5b806314a8bd0d146100945780632e0f2625146100ce578063313ce567146101075780633179e7f01461012d575b5f5ffd5b6100bb7f0000000000000000000000000000000000000000000000000000000000005dc081565b6040519081526020015b60405180910390f35b6100f57f000000000000000000000000000000000000000000000000000000000000000881565b60405160ff90911681526020016100c5565b7f00000000000000000000000000000000000000000000000000000000000000086100f5565b61014873ee10fe5e7aa92dd7b136597449c3d5813cfc5f1881565b6040516001600160a01b0390911681526020016100c5565b6100bb6101f7565b6100bb6102e6565b6040805180820190915260148152734d4b522f555344202863616c63756c617465642960601b60208201525b6040516100c59190610360565b61014873a1ea1ba18e88c381c724a75f23a130420c403f9a81565b61019c604051806040016040528060148152602001734d4b522f555344202863616c63756c617465642960601b81525081565b5f5f73ee10fe5e7aa92dd7b136597449c3d5813cfc5f186001600160a01b03166350d25bcd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610249573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061026d91906103ab565b90505f811361027d575f91505090565b80670de0b6b3a764000061028f6102e6565b6102a190670de0b6b3a76400006103d6565b6102cb7f0000000000000000000000000000000000000000000000000000000000005dc0846103ef565b6102d591906103ef565b6102df9190610406565b9250505090565b5f73a1ea1ba18e88c381c724a75f23a130420c403f9a6001600160a01b031663ddca3f436040518163ffffffff1660e01b8152600401602060405180830381865afa158015610337573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061035b91906103ab565b905090565b602081525f82518060208401525f5b8181101561038c576020818601810151604086840101520161036f565b505f604082850101526040601f19601f83011684010191505092915050565b5f602082840312156103bb575f5ffd5b5051919050565b634e487b7160e01b5f52601160045260245ffd5b818103818111156103e9576103e96103c2565b92915050565b80820281158282048414176103e9576103e96103c2565b5f8261042057634e487b7160e01b5f52601260045260245ffd5b50049056fea2646970667358221220f5133a791803903f3ac7c694794a568e3e06b60883a469ba55e9a89b5974f8e264736f6c634300081b0033

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export  ]

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.