Source Code
Overview
ETH Balance
0 ETH
ETH Value
$0.00View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Cross-Chain Transactions
Loading...
Loading
Contract Name:
PythUtils
Compiler Version
v0.8.24+commit.e11b9ed9
Optimization Enabled:
No with 200 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;
library PythUtils {
/// @notice Converts a Pyth price to a uint256 with a target number of decimals
/// @param price The Pyth price
/// @param expo The Pyth price exponent
/// @param targetDecimals The target number of decimals
/// @return The price as a uint256
/// @dev Function will lose precision if targetDecimals is less than the Pyth price decimals.
/// This method will truncate any digits that cannot be represented by the targetDecimals.
/// e.g. If the price is 0.000123 and the targetDecimals is 2, the result will be 0
function convertToUint(
int64 price,
int32 expo,
uint8 targetDecimals
) public pure returns (uint256) {
if (price < 0 || expo > 0 || expo < -255) {
revert();
}
uint8 priceDecimals = uint8(uint32(-1 * expo));
if (targetDecimals >= priceDecimals) {
return
uint(uint64(price)) *
10 ** uint32(targetDecimals - priceDecimals);
} else {
return
uint(uint64(price)) /
10 ** uint32(priceDecimals - targetDecimals);
}
}
}{
"evmVersion": "paris",
"optimizer": {
"enabled": false,
"runs": 200
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"libraries": {}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"int64","name":"price","type":"int64"},{"internalType":"int32","name":"expo","type":"int32"},{"internalType":"uint8","name":"targetDecimals","type":"uint8"}],"name":"convertToUint","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"}]Contract Creation Code
6105a5610053600b82828239805160001a607314610046577f4e487b7100000000000000000000000000000000000000000000000000000000600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600436106100355760003560e01c8063b55522b21461003a575b600080fd5b610054600480360381019061004f9190610217565b61006a565b6040516100619190610283565b60405180910390f35b6000808460070b1280610080575060008360030b135b806100ad57507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff018360030b125b156100b757600080fd5b6000837fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6100e591906102cd565b90508060ff168360ff161061012c578083610100919061030a565b60ff16600a61010f9190610482565b8567ffffffffffffffff1661012491906104cd565b915050610160565b8281610138919061030a565b60ff16600a6101479190610482565b8567ffffffffffffffff1661015c919061053e565b9150505b9392505050565b600080fd5b60008160070b9050919050565b6101828161016c565b811461018d57600080fd5b50565b60008135905061019f81610179565b92915050565b60008160030b9050919050565b6101bb816101a5565b81146101c657600080fd5b50565b6000813590506101d8816101b2565b92915050565b600060ff82169050919050565b6101f4816101de565b81146101ff57600080fd5b50565b600081359050610211816101eb565b92915050565b6000806000606084860312156102305761022f610167565b5b600061023e86828701610190565b935050602061024f868287016101c9565b925050604061026086828701610202565b9150509250925092565b6000819050919050565b61027d8161026a565b82525050565b60006020820190506102986000830184610274565b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60006102d8826101a5565b91506102e3836101a5565b92508282026102f1816101a5565b91508082146103035761030261029e565b5b5092915050565b6000610315826101de565b9150610320836101de565b9250828203905060ff8111156103395761033861029e565b5b92915050565b60008160011c9050919050565b6000808291508390505b6001851115610396578086048111156103725761037161029e565b5b60018516156103815780820291505b808102905061038f8561033f565b9450610356565b94509492505050565b6000826103af576001905061046b565b816103bd576000905061046b565b81600181146103d357600281146103dd5761040c565b600191505061046b565b60ff8411156103ef576103ee61029e565b5b8360020a9150848211156104065761040561029e565b5b5061046b565b5060208310610133831016604e8410600b84101617156104415782820a90508381111561043c5761043b61029e565b5b61046b565b61044e848484600161034c565b925090508184048111156104655761046461029e565b5b81810290505b9392505050565b600063ffffffff82169050919050565b600061048d8261026a565b915061049883610472565b92506104c57fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff848461039f565b905092915050565b60006104d88261026a565b91506104e38361026a565b92508282026104f18161026a565b915082820484148315176105085761050761029e565b5b5092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b60006105498261026a565b91506105548361026a565b9250826105645761056361050f565b5b82820490509291505056fea26469706673582212200757f0aee5617a14dd8f70eff2258d46297d29ce039fb2582e2c8e42e5ae935864736f6c63430008180033
Deployed Bytecode
0x7314e5bacb5f98778aeefdd4f79dc8e007dd1586cf30146080604052600436106100355760003560e01c8063b55522b21461003a575b600080fd5b610054600480360381019061004f9190610217565b61006a565b6040516100619190610283565b60405180910390f35b6000808460070b1280610080575060008360030b135b806100ad57507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff018360030b125b156100b757600080fd5b6000837fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6100e591906102cd565b90508060ff168360ff161061012c578083610100919061030a565b60ff16600a61010f9190610482565b8567ffffffffffffffff1661012491906104cd565b915050610160565b8281610138919061030a565b60ff16600a6101479190610482565b8567ffffffffffffffff1661015c919061053e565b9150505b9392505050565b600080fd5b60008160070b9050919050565b6101828161016c565b811461018d57600080fd5b50565b60008135905061019f81610179565b92915050565b60008160030b9050919050565b6101bb816101a5565b81146101c657600080fd5b50565b6000813590506101d8816101b2565b92915050565b600060ff82169050919050565b6101f4816101de565b81146101ff57600080fd5b50565b600081359050610211816101eb565b92915050565b6000806000606084860312156102305761022f610167565b5b600061023e86828701610190565b935050602061024f868287016101c9565b925050604061026086828701610202565b9150509250925092565b6000819050919050565b61027d8161026a565b82525050565b60006020820190506102986000830184610274565b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60006102d8826101a5565b91506102e3836101a5565b92508282026102f1816101a5565b91508082146103035761030261029e565b5b5092915050565b6000610315826101de565b9150610320836101de565b9250828203905060ff8111156103395761033861029e565b5b92915050565b60008160011c9050919050565b6000808291508390505b6001851115610396578086048111156103725761037161029e565b5b60018516156103815780820291505b808102905061038f8561033f565b9450610356565b94509492505050565b6000826103af576001905061046b565b816103bd576000905061046b565b81600181146103d357600281146103dd5761040c565b600191505061046b565b60ff8411156103ef576103ee61029e565b5b8360020a9150848211156104065761040561029e565b5b5061046b565b5060208310610133831016604e8410600b84101617156104415782820a90508381111561043c5761043b61029e565b5b61046b565b61044e848484600161034c565b925090508184048111156104655761046461029e565b5b81810290505b9392505050565b600063ffffffff82169050919050565b600061048d8261026a565b915061049883610472565b92506104c57fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff848461039f565b905092915050565b60006104d88261026a565b91506104e38361026a565b92508282026104f18161026a565b915082820484148315176105085761050761029e565b5b5092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b60006105498261026a565b91506105548361026a565b9250826105645761056361050f565b5b82820490509291505056fea26469706673582212200757f0aee5617a14dd8f70eff2258d46297d29ce039fb2582e2c8e42e5ae935864736f6c63430008180033
Loading...
Loading
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in ETH
0
Multichain Portfolio | 35 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
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.