S Price: $0.436076 (+6.22%)

Contract

0xdf6343eCD09731620C229382fd0525f4B76A6cdB

Overview

S Balance

Sonic LogoSonic LogoSonic Logo0 S

S Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To

There are no matching entries

Please try again later

Parent Transaction Hash Block From To
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
OffchainOracle

Compiler Version
v0.7.6+commit.7338295f

Optimization Enabled:
No with 200 runs

Other Settings:
default evmVersion, None license
/**
 *Submitted for verification at SonicScan.org on 2025-01-23
*/

// SPDX-License-Identifier: No

pragma solidity 0.7.6;

interface IERC20 {
    function totalSupply() external view returns (uint256);
    function balanceOf(address account) external view returns (uint256);
    function transfer(address recipient, uint256 amount) external returns (bool);
    function allowance(address owner, address spender) external view returns (uint256);
    function approve(address spender, uint256 amount) external returns (bool);
    function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
    event Transfer(address indexed from, address indexed to, uint256 value);
    event Approval(address indexed owner, address indexed spender, uint256 value);
}

interface IERC20Metadata is IERC20 {
    function name() external view returns (string memory);
    function symbol() external view returns (string memory);
    function decimals() external view returns (uint8);
}
// For Solidly v3
interface ISolidlyV3Pool {
    function slot0() external view returns (uint160 sqrtPriceX96, int24, uint24, bool);
    function token0() external view returns (address);
    function token1() external view returns (address);
}
contract OffchainOracle {
    function getRate(address tokenFrom, address tokenTo, address poolAddress, uint8 ver) external view returns (uint256 rate, uint8 decimalsFrom, uint8 decimalsTo) {
        // version = 3 : Solidly v3
        if(ver == 3) {
            address token0 = ISolidlyV3Pool(poolAddress).token0();
            address token1 = ISolidlyV3Pool(poolAddress).token1();
            (uint256 sqrtPriceX96,,,) = ISolidlyV3Pool(poolAddress).slot0();
            if(token0 == tokenFrom) {
                decimalsFrom = IERC20Metadata(token0).decimals();
                decimalsTo = IERC20Metadata(token1).decimals();
                rate = (((1e18 * sqrtPriceX96) >> 96) * sqrtPriceX96) >> 96;
            } else {
                decimalsFrom = IERC20Metadata(token1).decimals();
                decimalsTo = IERC20Metadata(token0).decimals();
                rate = (1e18 << 192) / sqrtPriceX96 / sqrtPriceX96;
            }
        }
    }
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"tokenFrom","type":"address"},{"internalType":"address","name":"tokenTo","type":"address"},{"internalType":"address","name":"poolAddress","type":"address"},{"internalType":"uint8","name":"ver","type":"uint8"}],"name":"getRate","outputs":[{"internalType":"uint256","name":"rate","type":"uint256"},{"internalType":"uint8","name":"decimalsFrom","type":"uint8"},{"internalType":"uint8","name":"decimalsTo","type":"uint8"}],"stateMutability":"view","type":"function"}]

608060405234801561001057600080fd5b50610596806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c8063ecbbfef414610030575b600080fd5b6100bf6004803603608081101561004657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803560ff1690602001909291905050506100e9565b604051808481526020018360ff1681526020018260ff168152602001935050505060405180910390f35b600080600060038460ff1614156105565760008573ffffffffffffffffffffffffffffffffffffffff16630dfe16816040518163ffffffff1660e01b815260040160206040518083038186803b15801561014257600080fd5b505afa158015610156573d6000803e3d6000fd5b505050506040513d602081101561016c57600080fd5b8101908080519060200190929190505050905060008673ffffffffffffffffffffffffffffffffffffffff1663d21220a76040518163ffffffff1660e01b815260040160206040518083038186803b1580156101c757600080fd5b505afa1580156101db573d6000803e3d6000fd5b505050506040513d60208110156101f157600080fd5b8101908080519060200190929190505050905060008773ffffffffffffffffffffffffffffffffffffffff16633850c7bd6040518163ffffffff1660e01b815260040160806040518083038186803b15801561024c57600080fd5b505afa158015610260573d6000803e3d6000fd5b505050506040513d608081101561027657600080fd5b810190808051906020019092919080519060200190929190805190602001909291908051906020019092919050505050505073ffffffffffffffffffffffffffffffffffffffff1690508973ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610416578273ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561033a57600080fd5b505afa15801561034e573d6000803e3d6000fd5b505050506040513d602081101561036457600080fd5b810190808051906020019092919050505094508173ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b1580156103bd57600080fd5b505afa1580156103d1573d6000803e3d6000fd5b505050506040513d60208110156103e757600080fd5b81019080805190602001909291905050509350606081606083670de0b6b3a764000002901c02901c9550610552565b8173ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561045c57600080fd5b505afa158015610470573d6000803e3d6000fd5b505050506040513d602081101561048657600080fd5b810190808051906020019092919050505094508273ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b1580156104df57600080fd5b505afa1580156104f3573d6000803e3d6000fd5b505050506040513d602081101561050957600080fd5b8101908080519060200190929190505050935080817f0de0b6b3a76400000000000000000000000000000000000000000000000000008161054657fe5b048161054e57fe5b0495505b5050505b945094509491505056fea264697066735822122026940708b88c9378e58c4ef43052377fb8f76d3fb7fc556a768c78ce176aadc664736f6c63430007060033

Deployed Bytecode

0x608060405234801561001057600080fd5b506004361061002b5760003560e01c8063ecbbfef414610030575b600080fd5b6100bf6004803603608081101561004657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803560ff1690602001909291905050506100e9565b604051808481526020018360ff1681526020018260ff168152602001935050505060405180910390f35b600080600060038460ff1614156105565760008573ffffffffffffffffffffffffffffffffffffffff16630dfe16816040518163ffffffff1660e01b815260040160206040518083038186803b15801561014257600080fd5b505afa158015610156573d6000803e3d6000fd5b505050506040513d602081101561016c57600080fd5b8101908080519060200190929190505050905060008673ffffffffffffffffffffffffffffffffffffffff1663d21220a76040518163ffffffff1660e01b815260040160206040518083038186803b1580156101c757600080fd5b505afa1580156101db573d6000803e3d6000fd5b505050506040513d60208110156101f157600080fd5b8101908080519060200190929190505050905060008773ffffffffffffffffffffffffffffffffffffffff16633850c7bd6040518163ffffffff1660e01b815260040160806040518083038186803b15801561024c57600080fd5b505afa158015610260573d6000803e3d6000fd5b505050506040513d608081101561027657600080fd5b810190808051906020019092919080519060200190929190805190602001909291908051906020019092919050505050505073ffffffffffffffffffffffffffffffffffffffff1690508973ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610416578273ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561033a57600080fd5b505afa15801561034e573d6000803e3d6000fd5b505050506040513d602081101561036457600080fd5b810190808051906020019092919050505094508173ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b1580156103bd57600080fd5b505afa1580156103d1573d6000803e3d6000fd5b505050506040513d60208110156103e757600080fd5b81019080805190602001909291905050509350606081606083670de0b6b3a764000002901c02901c9550610552565b8173ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561045c57600080fd5b505afa158015610470573d6000803e3d6000fd5b505050506040513d602081101561048657600080fd5b810190808051906020019092919050505094508273ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b1580156104df57600080fd5b505afa1580156104f3573d6000803e3d6000fd5b505050506040513d602081101561050957600080fd5b8101908080519060200190929190505050935080817f0de0b6b3a76400000000000000000000000000000000000000000000000000008161054657fe5b048161054e57fe5b0495505b5050505b945094509491505056fea264697066735822122026940708b88c9378e58c4ef43052377fb8f76d3fb7fc556a768c78ce176aadc664736f6c63430007060033

Deployed Bytecode Sourcemap

1207:975:0:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1238:941;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1346:12;1360:18;1380:16;1456:1;1449:3;:8;;;1446:726;;;1474:14;1506:11;1491:34;;;:36;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1474:53;;1542:14;1574:11;1559:34;;;:36;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1542:53;;1611:20;1653:11;1638:33;;;:35;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1610:63;;;;;;;1701:9;1691:19;;:6;:19;;;1688:473;;;1761:6;1746:31;;;:33;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1731:48;;1826:6;1811:31;;;:33;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1798:46;;1920:2;1903:12;1897:2;1880:12;1873:4;:19;1872:27;;1871:44;1870:52;;1863:59;;1688:473;;;1993:6;1978:31;;;:33;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1963:48;;2058:6;2043:31;;;:33;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2030:46;;2133:12;2118;2103:11;2102:28;;;;;;:43;;;;;;2095:50;;1688:473;1446:726;;;;1238:941;;;;;;;;:::o

Swarm Source

ipfs://26940708b88c9378e58c4ef43052377fb8f76d3fb7fc556a768c78ce176aadc6

Block Transaction Gas Used Reward
view all blocks produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits

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.