S Price: $0.56255 (-5.76%)

Contract Diff Checker

Contract Name:
UsdcQuote

Contract Source Code:

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

/**
 * @dev Minimal interface to get USDC price of 1 token
 */
interface IGetAmountOut {
    function getAmountOut(
        uint256 amountIn,
        address tokenIn,
        address tokenOut
    ) external view returns (uint256 amount, bool stable);
}

contract UsdcQuote {
    address public constant QUOTER_ADDRESS = 0xF5F7231073b3B41c04BA655e1a7438b1a7b29c27; 

    address public constant USDC = 0x29219dd400f2Bf60E5a23d13Be72B486D4038894;

    uint256 public constant ONE_TOKEN = 1e18;

    IGetAmountOut public quoter;

    constructor() {
        quoter = IGetAmountOut(QUOTER_ADDRESS);
    }

    /**
     * @dev Returns how many USDC (in 18-decimal format) you'd get for exactly 1 tokenIn,
     *      ignoring the stable bool returned by the quoter.
     *
     * @param tokenIn The address of the input token
     * @return amount18 The quoted USDC amount, scaled to 1e18
     */
    function getLatestPrice(address tokenIn) external view returns (uint256 amount18) {
        (uint256 rawAmount, ) = quoter.getAmountOut(
            ONE_TOKEN,
            tokenIn,
            USDC
        );

        amount18 = rawAmount * 1e12;

        return amount18;
    }
}

Please enter a contract address above to load the contract details and source code.

Context size (optional):