UNPKG

@dolomite-exchange/dolomite-margin

Version:

Ethereum Smart Contracts and TypeScript library used for the DolomiteMargin trading protocol

541 lines 22.1 kB
{ "contractName": "IPriceOracle", "abi": [ { "constant": true, "inputs": [], "name": "ONE_DOLLAR", "outputs": [ { "internalType": "uint256", "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [ { "internalType": "address", "name": "token", "type": "address" } ], "name": "getPrice", "outputs": [ { "components": [ { "internalType": "uint256", "name": "value", "type": "uint256" } ], "internalType": "struct Monetary.Price", "name": "", "type": "tuple" } ], "payable": false, "stateMutability": "view", "type": "function" } ], "metadata": "{\"compiler\":{\"version\":\"0.5.16+commit.9c3226ce\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"constant\":true,\"inputs\":[],\"name\":\"ONE_DOLLAR\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"}],\"name\":\"getPrice\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"internalType\":\"struct Monetary.Price\",\"name\":\"\",\"type\":\"tuple\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"author\":\"dYdX * Interface that Price Oracles for DolomiteMargin must implement in order to report prices.\",\"methods\":{\"getPrice(address)\":{\"params\":{\"token\":\"The ERC20 token address of the market\"},\"return\":\"The USD price of a base unit of the token, then multiplied by 10^36. So a USD-stable coin with 18 decimal places would return 10^18. This is the price of the base unit rather than the price of a \\\"human-readable\\\" token amount. Every ERC20 may have a different number of decimals.\"}},\"title\":\"IPriceOracle\"},\"userdoc\":{\"methods\":{\"getPrice(address)\":{\"notice\":\"Get the price of a token\"}}}},\"settings\":{\"compilationTarget\":{\"/home/cdc218/projects/dolomite-protocol-v2/contracts/protocol/interfaces/IPriceOracle.sol\":\"IPriceOracle\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"/home/cdc218/projects/dolomite-protocol-v2/contracts/protocol/interfaces/IPriceOracle.sol\":{\"keccak256\":\"0x3f7c3d1397390ea44c6d5e5730d49476431c3df3b28334fe38218de5edc31138\",\"urls\":[\"bzz-raw://63ebf926fca9ce33aaabaf93805686acc25daded1648d6dab59c8c4d05116918\",\"dweb:/ipfs/QmeGkDp7ycYstpfqCYBiqoCYwy876gabx8r42o5koj3H5A\"]},\"/home/cdc218/projects/dolomite-protocol-v2/contracts/protocol/lib/Monetary.sol\":{\"keccak256\":\"0x5257274f2d4d3605f3e97ec45fb902111fe9a22506f0b4cf308ea933bc81bfe2\",\"urls\":[\"bzz-raw://85b8023b78805063a2ec8d376f1f5983994eabd96efd8ceadb0224dbb71c5678\",\"dweb:/ipfs/QmaDhzCzRqsuHuJfhToEC4pATQHwhh7yWWsjwfuRzFT1kG\"]}},\"version\":1}", "bytecode": "0x", "deployedBytecode": "0x", "sourceMap": "", "deployedSourceMap": "", "source": "/*\n\n Copyright 2019 dYdX Trading Inc.\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n\n*/\n\npragma solidity ^0.5.7;\npragma experimental ABIEncoderV2;\n\nimport { Monetary } from \"../lib/Monetary.sol\";\n\n\n/**\n * @title IPriceOracle\n * @author dYdX\n *\n * Interface that Price Oracles for DolomiteMargin must implement in order to report prices.\n */\ncontract IPriceOracle {\n\n // ============ Constants ============\n\n uint256 public constant ONE_DOLLAR = 10 ** 36;\n\n // ============ Public Functions ============\n\n /**\n * Get the price of a token\n *\n * @param token The ERC20 token address of the market\n * @return The USD price of a base unit of the token, then multiplied by 10^36.\n * So a USD-stable coin with 18 decimal places would return 10^18.\n * This is the price of the base unit rather than the price of a \"human-readable\"\n * token amount. Every ERC20 may have a different number of decimals.\n */\n function getPrice(\n address token\n )\n public\n view\n returns (Monetary.Price memory);\n}\n", "sourcePath": "/home/cdc218/projects/dolomite-protocol-v2/contracts/protocol/interfaces/IPriceOracle.sol", "ast": { "absolutePath": "/home/cdc218/projects/dolomite-protocol-v2/contracts/protocol/interfaces/IPriceOracle.sol", "exportedSymbols": { "IPriceOracle": [ 24835 ] }, "id": 24836, "nodeType": "SourceUnit", "nodes": [ { "id": 24819, "literals": [ "solidity", "^", "0.5", ".7" ], "nodeType": "PragmaDirective", "src": "603:23:86" }, { "id": 24820, "literals": [ "experimental", "ABIEncoderV2" ], "nodeType": "PragmaDirective", "src": "627:33:86" }, { "absolutePath": "/home/cdc218/projects/dolomite-protocol-v2/contracts/protocol/lib/Monetary.sol", "file": "../lib/Monetary.sol", "id": 24822, "nodeType": "ImportDirective", "scope": 24836, "sourceUnit": 27761, "src": "662:47:86", "symbolAliases": [ { "foreign": 24821, "local": null } ], "unitAlias": "" }, { "baseContracts": [], "contractDependencies": [], "contractKind": "contract", "documentation": "@title IPriceOracle\n@author dYdX\n * Interface that Price Oracles for DolomiteMargin must implement in order to report prices.", "fullyImplemented": false, "id": 24835, "linearizedBaseContracts": [ 24835 ], "name": "IPriceOracle", "nodeType": "ContractDefinition", "nodes": [ { "constant": true, "id": 24827, "name": "ONE_DOLLAR", "nodeType": "VariableDeclaration", "scope": 24835, "src": "928:45:86", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 24823, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "928:7:86", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": { "argumentTypes": null, "commonType": { "typeIdentifier": "t_rational_1000000000000000000000000000000000000_by_1", "typeString": "int_const 1000...(29 digits omitted)...0000" }, "id": 24826, "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "hexValue": "3130", "id": 24824, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "965:2:86", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_10_by_1", "typeString": "int_const 10" }, "value": "10" }, "nodeType": "BinaryOperation", "operator": "**", "rightExpression": { "argumentTypes": null, "hexValue": "3336", "id": 24825, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "971:2:86", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_36_by_1", "typeString": "int_const 36" }, "value": "36" }, "src": "965:8:86", "typeDescriptions": { "typeIdentifier": "t_rational_1000000000000000000000000000000000000_by_1", "typeString": "int_const 1000...(29 digits omitted)...0000" } }, "visibility": "public" }, { "body": null, "documentation": "Get the price of a token\n * @param token The ERC20 token address of the market\n@return The USD price of a base unit of the token, then multiplied by 10^36.\n So a USD-stable coin with 18 decimal places would return 10^18.\n This is the price of the base unit rather than the price of a \"human-readable\"\n token amount. Every ERC20 may have a different number of decimals.", "id": 24834, "implemented": false, "kind": "function", "modifiers": [], "name": "getPrice", "nodeType": "FunctionDefinition", "parameters": { "id": 24830, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 24829, "name": "token", "nodeType": "VariableDeclaration", "scope": 24834, "src": "1540:13:86", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" }, "typeName": { "id": 24828, "name": "address", "nodeType": "ElementaryTypeName", "src": "1540:7:86", "stateMutability": "nonpayable", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "value": null, "visibility": "internal" } ], "src": "1530:29:86" }, "returnParameters": { "id": 24833, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 24832, "name": "", "nodeType": "VariableDeclaration", "scope": 24834, "src": "1605:21:86", "stateVariable": false, "storageLocation": "memory", "typeDescriptions": { "typeIdentifier": "t_struct$_Price_$27756_memory_ptr", "typeString": "struct Monetary.Price" }, "typeName": { "contractScope": null, "id": 24831, "name": "Monetary.Price", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 27756, "src": "1605:14:86", "typeDescriptions": { "typeIdentifier": "t_struct$_Price_$27756_storage_ptr", "typeString": "struct Monetary.Price" } }, "value": null, "visibility": "internal" } ], "src": "1604:23:86" }, "scope": 24835, "src": "1513:115:86", "stateMutability": "view", "superFunction": null, "visibility": "public" } ], "scope": 24836, "src": "855:775:86" } ], "src": "603:1028:86" }, "legacyAST": { "absolutePath": "/home/cdc218/projects/dolomite-protocol-v2/contracts/protocol/interfaces/IPriceOracle.sol", "exportedSymbols": { "IPriceOracle": [ 24835 ] }, "id": 24836, "nodeType": "SourceUnit", "nodes": [ { "id": 24819, "literals": [ "solidity", "^", "0.5", ".7" ], "nodeType": "PragmaDirective", "src": "603:23:86" }, { "id": 24820, "literals": [ "experimental", "ABIEncoderV2" ], "nodeType": "PragmaDirective", "src": "627:33:86" }, { "absolutePath": "/home/cdc218/projects/dolomite-protocol-v2/contracts/protocol/lib/Monetary.sol", "file": "../lib/Monetary.sol", "id": 24822, "nodeType": "ImportDirective", "scope": 24836, "sourceUnit": 27761, "src": "662:47:86", "symbolAliases": [ { "foreign": 24821, "local": null } ], "unitAlias": "" }, { "baseContracts": [], "contractDependencies": [], "contractKind": "contract", "documentation": "@title IPriceOracle\n@author dYdX\n * Interface that Price Oracles for DolomiteMargin must implement in order to report prices.", "fullyImplemented": false, "id": 24835, "linearizedBaseContracts": [ 24835 ], "name": "IPriceOracle", "nodeType": "ContractDefinition", "nodes": [ { "constant": true, "id": 24827, "name": "ONE_DOLLAR", "nodeType": "VariableDeclaration", "scope": 24835, "src": "928:45:86", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 24823, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "928:7:86", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": { "argumentTypes": null, "commonType": { "typeIdentifier": "t_rational_1000000000000000000000000000000000000_by_1", "typeString": "int_const 1000...(29 digits omitted)...0000" }, "id": 24826, "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "hexValue": "3130", "id": 24824, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "965:2:86", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_10_by_1", "typeString": "int_const 10" }, "value": "10" }, "nodeType": "BinaryOperation", "operator": "**", "rightExpression": { "argumentTypes": null, "hexValue": "3336", "id": 24825, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "971:2:86", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_36_by_1", "typeString": "int_const 36" }, "value": "36" }, "src": "965:8:86", "typeDescriptions": { "typeIdentifier": "t_rational_1000000000000000000000000000000000000_by_1", "typeString": "int_const 1000...(29 digits omitted)...0000" } }, "visibility": "public" }, { "body": null, "documentation": "Get the price of a token\n * @param token The ERC20 token address of the market\n@return The USD price of a base unit of the token, then multiplied by 10^36.\n So a USD-stable coin with 18 decimal places would return 10^18.\n This is the price of the base unit rather than the price of a \"human-readable\"\n token amount. Every ERC20 may have a different number of decimals.", "id": 24834, "implemented": false, "kind": "function", "modifiers": [], "name": "getPrice", "nodeType": "FunctionDefinition", "parameters": { "id": 24830, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 24829, "name": "token", "nodeType": "VariableDeclaration", "scope": 24834, "src": "1540:13:86", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" }, "typeName": { "id": 24828, "name": "address", "nodeType": "ElementaryTypeName", "src": "1540:7:86", "stateMutability": "nonpayable", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "value": null, "visibility": "internal" } ], "src": "1530:29:86" }, "returnParameters": { "id": 24833, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 24832, "name": "", "nodeType": "VariableDeclaration", "scope": 24834, "src": "1605:21:86", "stateVariable": false, "storageLocation": "memory", "typeDescriptions": { "typeIdentifier": "t_struct$_Price_$27756_memory_ptr", "typeString": "struct Monetary.Price" }, "typeName": { "contractScope": null, "id": 24831, "name": "Monetary.Price", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 27756, "src": "1605:14:86", "typeDescriptions": { "typeIdentifier": "t_struct$_Price_$27756_storage_ptr", "typeString": "struct Monetary.Price" } }, "value": null, "visibility": "internal" } ], "src": "1604:23:86" }, "scope": 24835, "src": "1513:115:86", "stateMutability": "view", "superFunction": null, "visibility": "public" } ], "scope": 24836, "src": "855:775:86" } ], "src": "603:1028:86" }, "compiler": { "name": "solc", "version": "0.5.16+commit.9c3226ce.Emscripten.clang" }, "networks": {}, "schemaVersion": "3.0.23", "updatedAt": "2025-06-22T04:01:53.959Z", "devdoc": { "author": "dYdX * Interface that Price Oracles for DolomiteMargin must implement in order to report prices.", "methods": { "getPrice(address)": { "params": { "token": "The ERC20 token address of the market" }, "return": "The USD price of a base unit of the token, then multiplied by 10^36. So a USD-stable coin with 18 decimal places would return 10^18. This is the price of the base unit rather than the price of a \"human-readable\" token amount. Every ERC20 may have a different number of decimals." } }, "title": "IPriceOracle" }, "userdoc": { "methods": { "getPrice(address)": { "notice": "Get the price of a token" } } } }