Skip to content

Instantly share code, notes, and snippets.

@ilanDoron
Created September 16, 2020 13:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ilanDoron/d9b4451ef9be0d717c2696cef1151b03 to your computer and use it in GitHub Desktop.
Save ilanDoron/d9b4451ef9be0d717c2696cef1151b03 to your computer and use it in GitHub Desktop.
pragma solidity 0.6.6;
contract Utils {
address internal constant ETH_TOKEN_ADDRESS = address(
0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE
);
address internal constant USDT_TOKEN_ADDRESS = address(
0xdAC17F958D2ee523a2206206994597C13D831ec7
);
address internal constant DAI_TOKEN_ADDRESS = address(
0x6B175474E89094C44Da98b954EedeAC495271d0F
);
address internal constant USDC_TOKEN_ADDRESS = address(
0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48
);
address internal constant WBTC_TOKEN_ADDRESS = address(
0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599
);
address internal constant KNC_TOKEN_ADDRESS = address(
0xdd974D5C2e2928deA5F71b9825b8b646686BD200
);
function getTokenDecimals(address token) public pure returns (uint256) {
if (token == ETH_TOKEN_ADDRESS) {
return 18;
} else if (token == USDT_TOKEN_ADDRESS) {
return 6;
} else if (token == DAI_TOKEN_ADDRESS) {
return 18;
} else if (token == USDC_TOKEN_ADDRESS) {
return 6;
} else if (token == WBTC_TOKEN_ADDRESS) {
return 8;
} else if (token == KNC_TOKEN_ADDRESS) {
return 18;
} else {
return 0;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment