Discover more of SonicScan Block Explorer's tools and services in one place.
Contract Source Code:
File 1 of 1 : swapx_pricefeed.sol
// 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.
Please DO NOT store any passwords or private keys here. A private note (up to 100 characters) can be saved and is useful for transaction tracking.
This website uses cookies to improve your experience. By continuing to use this website, you agree to its Terms and Privacy Policy.