Overview
ETH Balance
0.123490349622023 ETH
ETH Value
$219.63 (@ $1,778.53/ETH)More Info
Private Name Tags
ContractCreator
Latest 9 from a total of 9 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Execute Withdraw... | 312819986 | 47 days ago | IN | 0 ETH | 0.00003326 | ||||
Execute Withdraw... | 309411292 | 57 days ago | IN | 0 ETH | 0.00002361 | ||||
Execute Withdraw... | 303869530 | 73 days ago | IN | 0 ETH | 0.00002602 | ||||
Execute Withdraw... | 301757440 | 80 days ago | IN | 0 ETH | 0.00003272 | ||||
Execute Withdraw... | 285438423 | 127 days ago | IN | 0 ETH | 0.00007582 | ||||
Execute Withdraw... | 285427370 | 127 days ago | IN | 0 ETH | 0.0000387 | ||||
Execute Withdraw... | 283413208 | 133 days ago | IN | 0 ETH | 0.00010657 | ||||
Execute Withdraw... | 282658532 | 135 days ago | IN | 0 ETH | 0.00003453 | ||||
Execute Withdraw... | 279676882 | 144 days ago | IN | 0 ETH | 0.00003581 |
Latest 25 internal transactions (View All)
Advanced mode:
Parent Transaction Hash | Block | From | To | |||
---|---|---|---|---|---|---|
329225818 | 5 hrs ago | 0.00015816 ETH | ||||
329225818 | 5 hrs ago | 0.00015816 ETH | ||||
329225800 | 5 hrs ago | 0.0002475 ETH | ||||
329225800 | 5 hrs ago | 0.0002475 ETH | ||||
322861935 | 18 days ago | 0.00113045 ETH | ||||
322861935 | 18 days ago | 0.00113045 ETH | ||||
322861915 | 18 days ago | 0.00144817 ETH | ||||
322861915 | 18 days ago | 0.00144817 ETH | ||||
314318387 | 43 days ago | 0.02086646 ETH | ||||
314318387 | 43 days ago | 0.02086646 ETH | ||||
314318355 | 43 days ago | 0.02701568 ETH | ||||
314318355 | 43 days ago | 0.02701568 ETH | ||||
313817751 | 44 days ago | 0.00018838 ETH | ||||
313817751 | 44 days ago | 0.00018838 ETH | ||||
313817737 | 44 days ago | 0.0002475 ETH | ||||
313817737 | 44 days ago | 0.0002475 ETH | ||||
312819750 | 47 days ago | 0.0001794 ETH | ||||
312819750 | 47 days ago | 0.0001794 ETH | ||||
312819739 | 47 days ago | 0.0002475 ETH | ||||
312819739 | 47 days ago | 0.0002475 ETH | ||||
311756311 | 50 days ago | 0.00018772 ETH | ||||
311756311 | 50 days ago | 0.00018772 ETH | ||||
311756297 | 50 days ago | 0.0002475 ETH | ||||
311756297 | 50 days ago | 0.0002475 ETH | ||||
309673451 | 56 days ago | 0.06574189 ETH |
Loading...
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.
Similar Match Source Code This contract matches the deployed Bytecode of the Source Code for Contract 0xEcd64fB5...63Ff86034 The constructor portion of the code might be different and could alter the actual behaviour of the contract
Contract Name:
IsolationModeTraderProxy
Compiler Version
v0.8.9+commit.e5eed63a
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: GPL-3.0-or-later /* Copyright 2023 Dolomite This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ pragma solidity ^0.8.9; import { Address } from "@openzeppelin/contracts/utils/Address.sol"; import { OnlyDolomiteMarginForUpgradeable } from "../helpers/OnlyDolomiteMarginForUpgradeable.sol"; import { ProxyContractHelpers } from "../helpers/ProxyContractHelpers.sol"; import { Require } from "../protocol/lib/Require.sol"; /** * @title IsolationModeTraderProxy * @author Dolomite * * @notice Base contract for upgradeable trader contracts */ contract IsolationModeTraderProxy is ProxyContractHelpers, OnlyDolomiteMarginForUpgradeable { // ============ Constants ============ bytes32 private constant _FILE = "IsolationModeTraderProxy"; bytes32 private constant _IMPLEMENTATION_SLOT = bytes32(uint256(keccak256("eip1967.proxy.owner")) - 1); // ===================== Events ===================== event ImplementationSet(address indexed implementation); // ============ Constructor ============ constructor( address _implementation, address _dolomiteMargin, bytes memory _initializationCalldata ) { _setImplementation(_implementation); _setDolomiteMarginViaSlot(_dolomiteMargin); Address.functionDelegateCall( implementation(), _initializationCalldata, "IsolationModeTraderProxy: Initialization failed" ); } // ===================== Functions ===================== receive() external payable {} // solhint-disable-line no-empty-blocks fallback() external payable { // solhint-disable-previous-line payable-fallback _callImplementation(implementation()); } function upgradeTo(address _newImplementation) external onlyDolomiteMarginOwner(msg.sender) { _setImplementation(_newImplementation); } function upgradeToAndCall( address _newImplementation, bytes calldata _upgradeCalldata ) external onlyDolomiteMarginOwner(msg.sender) { _setImplementation(_newImplementation); Address.functionDelegateCall(implementation(), _upgradeCalldata, "RegistryProxy: Upgrade failed"); } function implementation() public view returns (address) { return _getAddress(_IMPLEMENTATION_SLOT); } // ===================== Internal Functions ===================== function _setImplementation(address _newImplementation) internal { Require.that( Address.isContract(_newImplementation), _FILE, "Implementation is not a contract" ); _setAddress(_IMPLEMENTATION_SLOT, _newImplementation); emit ImplementationSet(_newImplementation); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * * Furthermore, `isContract` will also return true if the target contract within * the same transaction is already scheduled for destruction by `SELFDESTRUCT`, * which only has an effect at the end of a transaction. * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } }
// SPDX-License-Identifier: GPL-3.0-or-later /* Copyright 2023 Dolomite This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ pragma solidity ^0.8.9; import { ProxyContractHelpers } from "./ProxyContractHelpers.sol"; import { IOnlyDolomiteMargin } from "../interfaces/IOnlyDolomiteMargin.sol"; import { IDolomiteMargin } from "../protocol/interfaces/IDolomiteMargin.sol"; import { Require } from "../protocol/lib/Require.sol"; /** * @title OnlyDolomiteMarginForUpgradeable * @author Dolomite * * @notice Inheritable contract that restricts the calling of certain functions to `DolomiteMargin`, the owner of * `DolomiteMargin` or a `DolomiteMargin` global operator */ abstract contract OnlyDolomiteMarginForUpgradeable is IOnlyDolomiteMargin, ProxyContractHelpers { // ============ Constants ============ bytes32 private constant _FILE = "OnlyDolomiteMargin"; bytes32 private constant _DOLOMITE_MARGIN_SLOT = bytes32(uint256(keccak256("eip1967.proxy.dolomiteMargin")) - 1); // ============ Modifiers ============ modifier onlyDolomiteMargin(address _from) { _requireOnlyDolomiteMargin(_from); _; } modifier onlyDolomiteMarginOwner(address _from) { _requireOnlyDolomiteMarginOwner(_from); _; } modifier onlyDolomiteMarginGlobalOperator(address _from) { _requireOnlyDolomiteMarginGlobalOperator(_from); _; } // ============ Functions ============ function DOLOMITE_MARGIN() public virtual view returns (IDolomiteMargin) { return IDolomiteMargin(_getAddress(_DOLOMITE_MARGIN_SLOT)); } function DOLOMITE_MARGIN_OWNER() public view returns (address) { return DOLOMITE_MARGIN().owner(); } function _setDolomiteMarginViaSlot(address _dolomiteMargin) internal { _setAddress(_DOLOMITE_MARGIN_SLOT, _dolomiteMargin); } function _requireOnlyDolomiteMargin(address _from) internal view { Require.that( _from == address(DOLOMITE_MARGIN()), _FILE, "Only Dolomite can call function", _from ); } function _requireOnlyDolomiteMarginOwner(address _from) internal view { Require.that( _from == DOLOMITE_MARGIN_OWNER(), _FILE, "Caller is not owner of Dolomite", _from ); } function _requireOnlyDolomiteMarginGlobalOperator(address _from) internal view { Require.that( DOLOMITE_MARGIN().getIsGlobalOperator(_from), _FILE, "Caller is not a global operator", _from ); } }
// SPDX-License-Identifier: GPL-3.0-or-later /* Copyright 2023 Dolomite This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ pragma solidity ^0.8.9; /** * @title ProxyContractHelpers * @author Dolomite * * @notice Helper functions for upgradeable proxy contracts to use */ abstract contract ProxyContractHelpers { // ================ Internal Functions ================== function _callImplementation(address _implementation) internal { // solhint-disable-next-line no-inline-assembly assembly { // Copy msg.data. We take full control of memory in this inline assembly // block because it will not return to Solidity code. We overwrite the // Solidity scratch pad at memory position 0. calldatacopy(0, 0, calldatasize()) // Call the implementation. // out and outsize are 0 because we don't know the size yet. let result := delegatecall(gas(), _implementation, 0, calldatasize(), 0, 0) // Copy the returned data. returndatacopy(0, 0, returndatasize()) switch result // delegatecall returns 0 on error. case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) } } } function _setAddress(bytes32 slot, address _value) internal { // solhint-disable-next-line no-inline-assembly assembly { sstore(slot, _value) } } function _setUint256(bytes32 slot, uint256 _value) internal { // solhint-disable-next-line no-inline-assembly assembly { sstore(slot, _value) } } function _setUint256InMap(bytes32 slot, address key, uint256 _value) internal { // solhint-disable-next-line no-inline-assembly bytes32 mappingSlot = keccak256(abi.encode(key, slot)); assembly { sstore(mappingSlot, _value) } } function _setUint256InNestedMap(bytes32 slot, address key1, address key2, uint256 _value) internal { bytes32 mappingSlot = keccak256(abi.encode(key2, keccak256(abi.encode(key1, slot)))); assembly { sstore(mappingSlot, _value) } } function _getAddress(bytes32 slot) internal view returns (address value) { // solhint-disable-next-line no-inline-assembly assembly { value := sload(slot) } } function _getUint256(bytes32 slot) internal view returns (uint256 value) { // solhint-disable-next-line no-inline-assembly assembly { value := sload(slot) } } function _getUint256FromMap(bytes32 slot, address key) internal view returns (uint256 value) { // solhint-disable-next-line no-inline-assembly bytes32 mappingSlot = keccak256(abi.encode(key, slot)); assembly { value := sload(mappingSlot) } } function _getUint256InNestedMap(bytes32 slot, address key1, address key2) internal view returns (uint256 value) { bytes32 mappingSlot = keccak256(abi.encode(key2, keccak256(abi.encode(key1, slot)))); assembly { value := sload(mappingSlot) } } }
// SPDX-License-Identifier: GPL-3.0-or-later /* Copyright 2023 Dolomite This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ pragma solidity ^0.8.9; import { IDolomiteMargin } from "../protocol/interfaces/IDolomiteMargin.sol"; /** * @title IOnlyDolomiteMargin * @author Dolomite * * @notice This interface is for contracts that need to add modifiers for only DolomiteMargin / Owner caller. */ interface IOnlyDolomiteMargin { function DOLOMITE_MARGIN() external view returns (IDolomiteMargin); }
// SPDX-License-Identifier: GPL-3.0-or-later /* Copyright 2023 Dolomite. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ pragma solidity ^0.8.9; import { IDolomiteStructs } from "./IDolomiteStructs.sol"; /** * @title IDolomiteAccountRiskOverrideSetter * @author Dolomite * * @notice Interface that can be implemented by any contract that needs to implement risk overrides for an account. */ interface IDolomiteAccountRiskOverrideSetter { /** * @notice Gets the risk overrides for a given account owner. * * @param _accountOwner The owner of the account whose risk override should be retrieved. * @return marginRatioOverride The margin ratio override for this account. * @return liquidationSpreadOverride The liquidation spread override for this account. */ function getAccountRiskOverride( address _accountOwner ) external view returns ( IDolomiteStructs.Decimal memory marginRatioOverride, IDolomiteStructs.Decimal memory liquidationSpreadOverride ); }
// SPDX-License-Identifier: GPL-3.0-or-later /* Copyright 2023 Dolomite This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ pragma solidity ^0.8.9; /** * @title IDolomiteInterestSetter * @author Dolomite * * @notice This interface defines the functions that for an interest setter that can be used to determine the interest * rate of a market. */ interface IDolomiteInterestSetter { // ============ Enum ============ enum InterestSetterType { None, Linear, DoubleExponential, Other } // ============ Structs ============ struct InterestRate { uint256 value; } // ============ Functions ============ /** * Get the interest rate of a token given some borrowed and supplied amounts * * @param token The address of the ERC20 token for the market * @param borrowWei The total borrowed token amount for the market * @param supplyWei The total supplied token amount for the market * @return The interest rate per second */ function getInterestRate( address token, uint256 borrowWei, uint256 supplyWei ) external view returns (InterestRate memory); function interestSetterType() external pure returns (InterestSetterType); }
// SPDX-License-Identifier: GPL-3.0-or-later /* Copyright 2023 Dolomite This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ pragma solidity ^0.8.9; import { IDolomiteInterestSetter } from "./IDolomiteInterestSetter.sol"; import { IDolomiteMarginAdmin } from "./IDolomiteMarginAdmin.sol"; import { IDolomitePriceOracle } from "./IDolomitePriceOracle.sol"; /** * @title IDolomiteMargin * @author Dolomite * * @notice The interface for interacting with the main entry-point to DolomiteMargin */ interface IDolomiteMargin is IDolomiteMarginAdmin { // ================================================== // ================= Write Functions ================ // ================================================== /** * The main entry-point to DolomiteMargin that allows users and contracts to manage accounts. * Take one or more actions on one or more accounts. The msg.sender must be the owner or * operator of all accounts except for those being liquidated, vaporized, or traded with. * One call to operate() is considered a singular "operation". Account collateralization is * ensured only after the completion of the entire operation. * * @param accounts A list of all accounts that will be used in this operation. Cannot contain * duplicates. In each action, the relevant account will be referred-to by its * index in the list. * @param actions An ordered list of all actions that will be taken in this operation. The * actions will be processed in order. */ function operate( AccountInfo[] calldata accounts, ActionArgs[] calldata actions ) external; /** * Approves/disapproves any number of operators. An operator is an external address that has the * same permissions to manipulate an account as the owner of the account. Operators are simply * addresses and therefore may either be externally-owned Ethereum accounts OR smart contracts. * * Operators are also able to act as AutoTrader contracts on behalf of the account owner if the * operator is a smart contract and implements the IAutoTrader interface. * * @param args A list of OperatorArgs which have an address and a boolean. The boolean value * denotes whether to approve (true) or revoke approval (false) for that address. */ function setOperators( OperatorArg[] calldata args ) external; // ================================================== // ================= Read Functions ================ // ================================================== // ============ Getters for Markets ============ /** * Get the ERC20 token address for a market. * * @param token The token to query * @return The token's marketId if the token is valid */ function getMarketIdByTokenAddress( address token ) external view returns (uint256); /** * Get the ERC20 token address for a market. * * @param marketId The market to query * @return The token address */ function getMarketTokenAddress( uint256 marketId ) external view returns (address); /** * Return the maximum amount of the market that can be supplied on Dolomite. Always 0 or positive. * * @param marketId The market to query * @return The max amount of the market that can be supplied */ function getMarketMaxWei( uint256 marketId ) external view returns (Wei memory); /** * Return true if a particular market is in closing mode. Additional borrows cannot be taken * from a market that is closing. * * @param marketId The market to query * @return True if the market is closing */ function getMarketIsClosing( uint256 marketId ) external view returns (bool); /** * Get the price of the token for a market. * * @param marketId The market to query * @return The price of each atomic unit of the token */ function getMarketPrice( uint256 marketId ) external view returns (MonetaryPrice memory); /** * Get the total number of markets. * * @return The number of markets */ function getNumMarkets() external view returns (uint256); /** * Get the total principal amounts (borrowed and supplied) for a market. * * @param marketId The market to query * @return The total principal amounts */ function getMarketTotalPar( uint256 marketId ) external view returns (TotalPar memory); /** * Get the most recently cached interest index for a market. * * @param marketId The market to query * @return The most recent index */ function getMarketCachedIndex( uint256 marketId ) external view returns (InterestIndex memory); /** * Get the interest index for a market if it were to be updated right now. * * @param marketId The market to query * @return The estimated current index */ function getMarketCurrentIndex( uint256 marketId ) external view returns (InterestIndex memory); /** * Get the price oracle address for a market. * * @param marketId The market to query * @return The price oracle address */ function getMarketPriceOracle( uint256 marketId ) external view returns (IDolomitePriceOracle); /** * Get the interest-setter address for a market. * * @param marketId The market to query * @return The interest-setter address */ function getMarketInterestSetter( uint256 marketId ) external view returns (IDolomiteInterestSetter); /** * Get the margin premium for a market. A margin premium makes it so that any positions that * include the market require a higher collateralization to avoid being liquidated. * * @param marketId The market to query * @return The market's margin premium */ function getMarketMarginPremium( uint256 marketId ) external view returns (Decimal memory); /** * Get the spread premium for a market. A spread premium makes it so that any liquidations * that include the market have a higher spread than the global default. * * @param marketId The market to query * @return The market's spread premium */ function getMarketSpreadPremium( uint256 marketId ) external view returns (Decimal memory); /** * Return true if this market can be removed and its ID can be recycled and reused * * @param marketId The market to query * @return True if the market is recyclable */ function getMarketIsRecyclable( uint256 marketId ) external view returns (bool); /** * Gets the recyclable markets, up to `n` length. If `n` is greater than the length of the list, 0's are returned * for the empty slots. * * @param n The number of markets to get, bounded by the linked list being smaller than `n` * @return The list of recyclable markets, in the same order held by the linked list */ function getRecyclableMarkets( uint256 n ) external view returns (uint[] memory); /** * Get the current borrower interest rate for a market. * * @param marketId The market to query * @return The current interest rate */ function getMarketInterestRate( uint256 marketId ) external view returns (IDolomiteInterestSetter.InterestRate memory); /** * Get basic information about a particular market. * * @param marketId The market to query * @return A Market struct with the current state of the market */ function getMarket( uint256 marketId ) external view returns (Market memory); /** * Get comprehensive information about a particular market. * * @param marketId The market to query * @return A tuple containing the values: * - A Market struct with the current state of the market * - The current estimated interest index * - The current token price * - The current market interest rate */ function getMarketWithInfo( uint256 marketId ) external view returns ( Market memory, InterestIndex memory, MonetaryPrice memory, IDolomiteInterestSetter.InterestRate memory ); /** * Get the number of excess tokens for a market. The number of excess tokens is calculated by taking the current * number of tokens held in DolomiteMargin, adding the number of tokens owed to DolomiteMargin by borrowers, and * subtracting the number of tokens owed to suppliers by DolomiteMargin. * * @param marketId The market to query * @return The number of excess tokens */ function getNumExcessTokens( uint256 marketId ) external view returns (Wei memory); // ============ Getters for Accounts ============ /** * Get the principal value for a particular account and market. * * @param account The account to query * @param marketId The market to query * @return The principal value */ function getAccountPar( AccountInfo calldata account, uint256 marketId ) external view returns (Par memory); /** * Get the principal value for a particular account and market, with no check the market is valid. Meaning, markets * that don't exist return 0. * * @param account The account to query * @param marketId The market to query * @return The principal value */ function getAccountParNoMarketCheck( AccountInfo calldata account, uint256 marketId ) external view returns (Par memory); /** * Get the token balance for a particular account and market. * * @param account The account to query * @param marketId The market to query * @return The token amount */ function getAccountWei( AccountInfo calldata account, uint256 marketId ) external view returns (Wei memory); /** * Get the status of an account (Normal, Liquidating, or Vaporizing). * * @param account The account to query * @return The account's status */ function getAccountStatus( AccountInfo calldata account ) external view returns (AccountStatus); /** * Get a list of markets that have a non-zero balance for an account * * @param account The account to query * @return The non-sorted marketIds with non-zero balance for the account. */ function getAccountMarketsWithBalances( AccountInfo calldata account ) external view returns (uint256[] memory); /** * Get the number of markets that have a non-zero balance for an account * * @param account The account to query * @return The non-sorted marketIds with non-zero balance for the account. */ function getAccountNumberOfMarketsWithBalances( AccountInfo calldata account ) external view returns (uint256); /** * Get the marketId for an account's market with a non-zero balance at the given index * * @param account The account to query * @return The non-sorted marketIds with non-zero balance for the account. */ function getAccountMarketWithBalanceAtIndex( AccountInfo calldata account, uint256 index ) external view returns (uint256); /** * Get the number of markets with which an account has a negative balance. * * @param account The account to query * @return The non-sorted marketIds with non-zero balance for the account. */ function getAccountNumberOfMarketsWithDebt( AccountInfo calldata account ) external view returns (uint256); /** * Get the total supplied and total borrowed value of an account. * * @param account The account to query * @return The following values: * - The supplied value of the account * - The borrowed value of the account */ function getAccountValues( AccountInfo calldata account ) external view returns (MonetaryValue memory, MonetaryValue memory); /** * Get the total supplied and total borrowed values of an account adjusted by the marginPremium * of each market. Supplied values are divided by (1 + marginPremium) for each market and * borrowed values are multiplied by (1 + marginPremium) for each market. Comparing these * adjusted values gives the margin-ratio of the account which will be compared to the global * margin-ratio when determining if the account can be liquidated. * * @param account The account to query * @return The following values: * - The supplied value of the account (adjusted for marginPremium) * - The borrowed value of the account (adjusted for marginPremium) */ function getAdjustedAccountValues( AccountInfo calldata account ) external view returns (MonetaryValue memory, MonetaryValue memory); /** * Get an account's summary for each market. * * @param account The account to query * @return The following values: * - The market IDs for each market * - The ERC20 token address for each market * - The account's principal value for each market * - The account's (supplied or borrowed) number of tokens for each market */ function getAccountBalances( AccountInfo calldata account ) external view returns (uint[] memory, address[] memory, Par[] memory, Wei[] memory); // ============ Getters for Account Permissions ============ /** * Return true if a particular address is approved as an operator for an owner's accounts. * Approved operators can act on the accounts of the owner as if it were the operator's own. * * @param owner The owner of the accounts * @param operator The possible operator * @return True if operator is approved for owner's accounts */ function getIsLocalOperator( address owner, address operator ) external view returns (bool); /** * Return true if a particular address is approved as a global operator. Such an address can * act on any account as if it were the operator's own. * * @param operator The address to query * @return True if operator is a global operator */ function getIsGlobalOperator( address operator ) external view returns (bool); /** * Checks if the autoTrader can only be called invoked by a global operator * * @param autoTrader The trader that should be checked for special call privileges. */ function getIsAutoTraderSpecial(address autoTrader) external view returns (bool); /** * @return The address that owns the DolomiteMargin protocol */ function owner() external view returns (address); // ============ Getters for Risk Params ============ /** * Get the global minimum margin-ratio that every position must maintain to prevent being * liquidated. * * @return The global margin-ratio */ function getMarginRatio() external view returns (Decimal memory); /** * Get the global liquidation spread. This is the spread between oracle prices that incentivizes * the liquidation of risky positions. * * @return The global liquidation spread */ function getLiquidationSpread() external view returns (Decimal memory); /** * Get the adjusted liquidation spread for some market pair. This is equal to the global * liquidation spread multiplied by (1 + spreadPremium) for each of the two markets. * * @param heldMarketId The market for which the account has collateral * @param owedMarketId The market for which the account has borrowed tokens * @return The adjusted liquidation spread */ function getLiquidationSpreadForPair( uint256 heldMarketId, uint256 owedMarketId ) external view returns (Decimal memory); /** * Get the global earnings-rate variable that determines what percentage of the interest paid * by borrowers gets passed-on to suppliers. * * @return The global earnings rate */ function getEarningsRate() external view returns (Decimal memory); /** * Get the global minimum-borrow value which is the minimum value of any new borrow on DolomiteMargin. * * @return The global minimum borrow value */ function getMinBorrowedValue() external view returns (MonetaryValue memory); /** * Get all risk parameters in a single struct. * * @return All global risk parameters */ function getRiskParams() external view returns (RiskParams memory); /** * Get all risk parameter limits in a single struct. These are the maximum limits at which the * risk parameters can be set by the admin of DolomiteMargin. * * @return All global risk parameter limits */ function getRiskLimits() external view returns (RiskLimits memory); }
// SPDX-License-Identifier: GPL-3.0-or-later /* Copyright 2023 Dolomite This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ pragma solidity ^0.8.9; import { IDolomiteInterestSetter } from "./IDolomiteInterestSetter.sol"; import { IDolomitePriceOracle } from "./IDolomitePriceOracle.sol"; import { IDolomiteStructs } from "./IDolomiteStructs.sol"; /** * @title IDolomiteMarginAdmin * @author Dolomite * * @notice This interface defines the functions that can be called by the owner of DolomiteMargin. */ interface IDolomiteMarginAdmin is IDolomiteStructs { // ============ Token Functions ============ /** * Withdraw an ERC20 token for which there is an associated market. Only excess tokens can be withdrawn. The number * of excess tokens is calculated by taking the current number of tokens held in DolomiteMargin, adding the number * of tokens owed to DolomiteMargin by borrowers, and subtracting the number of tokens owed to suppliers by * DolomiteMargin. */ function ownerWithdrawExcessTokens( uint256 marketId, address recipient ) external returns (uint256); /** * Withdraw an ERC20 token for which there is no associated market. */ function ownerWithdrawUnsupportedTokens( address token, address recipient ) external returns (uint256); // ============ Market Functions ============ /** * Sets the number of non-zero balances an account may have within the same `accountIndex`. This ensures a user * cannot DOS the system by filling their account with non-zero balances (which linearly increases gas costs when * checking collateralization) and disallowing themselves to close the position, because the number of gas units * needed to process their transaction exceed the block's gas limit. In turn, this would prevent the user from also * being liquidated, causing the all of the capital to be "stuck" in the position. * * Lowering this number does not "freeze" user accounts that have more than the new limit of balances, because this * variable is enforced by checking the users number of non-zero balances against the max or if it sizes down before * each transaction finishes. */ function ownerSetAccountMaxNumberOfMarketsWithBalances( uint256 accountMaxNumberOfMarketsWithBalances ) external; /** * Add a new market to DolomiteMargin. Must be for a previously-unsupported ERC20 token. */ function ownerAddMarket( address token, IDolomitePriceOracle priceOracle, IDolomiteInterestSetter interestSetter, Decimal calldata marginPremium, Decimal calldata spreadPremium, uint256 maxWei, bool isClosing, bool isRecyclable ) external; /** * Removes a market from DolomiteMargin, sends any remaining tokens in this contract to `salvager` and invokes the * recyclable callback */ function ownerRemoveMarkets( uint[] calldata marketIds, address salvager ) external; /** * Set (or unset) the status of a market to "closing". The borrowedValue of a market cannot increase while its * status is "closing". */ function ownerSetIsClosing( uint256 marketId, bool isClosing ) external; /** * Set the price oracle for a market. */ function ownerSetPriceOracle( uint256 marketId, IDolomitePriceOracle priceOracle ) external; /** * Set the interest-setter for a market. */ function ownerSetInterestSetter( uint256 marketId, IDolomiteInterestSetter interestSetter ) external; /** * Set a premium on the minimum margin-ratio for a market. This makes it so that any positions that include this * market require a higher collateralization to avoid being liquidated. */ function ownerSetMarginPremium( uint256 marketId, Decimal calldata marginPremium ) external; function ownerSetMaxWei( uint256 marketId, uint256 maxWei ) external; /** * Set a premium on the liquidation spread for a market. This makes it so that any liquidations that include this * market have a higher spread than the global default. */ function ownerSetSpreadPremium( uint256 marketId, Decimal calldata spreadPremium ) external; // ============ Risk Functions ============ /** * Set the global minimum margin-ratio that every position must maintain to prevent being liquidated. */ function ownerSetMarginRatio( Decimal calldata ratio ) external; /** * Set the global liquidation spread. This is the spread between oracle prices that incentivizes the liquidation of * risky positions. */ function ownerSetLiquidationSpread( Decimal calldata spread ) external; /** * Set the global earnings-rate variable that determines what percentage of the interest paid by borrowers gets * passed-on to suppliers. */ function ownerSetEarningsRate( Decimal calldata earningsRate ) external; /** * Set the global minimum-borrow value which is the minimum value of any new borrow on DolomiteMargin. */ function ownerSetMinBorrowedValue( MonetaryValue calldata minBorrowedValue ) external; // ============ Global Operator Functions ============ /** * Approve (or disapprove) an address that is permissioned to be an operator for all accounts in DolomiteMargin. * Intended only to approve smart-contracts. */ function ownerSetGlobalOperator( address operator, bool approved ) external; /** * Approve (or disapprove) an auto trader that can only be called by a global operator. IE for expirations */ function ownerSetAutoTraderSpecial( address autoTrader, bool special ) external; }
// SPDX-License-Identifier: GPL-3.0-or-later /* Copyright 2023 Dolomite Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ pragma solidity ^0.8.9; /** * @title IDolomiteOracleSentinel * @author Dolomite * * Interface that Dolomite pings to check if the Blockchain or L2 is alive, if liquidations should be processed, and if * markets should are in size-down only mode. */ interface IDolomiteOracleSentinel { // ============ Events ============ event GracePeriodSet( uint256 gracePeriod ); // ============ Functions ============ /** * @dev Allows the owner to set the grace period duration, which specifies how long the system will disallow * liquidations after sequencer is back online. Only callable by the owner. * * @param _gracePeriod The new duration of the grace period */ function ownerSetGracePeriod( uint256 _gracePeriod ) external; /** * @return True if new borrows should be allowed, false otherwise */ function isBorrowAllowed() external view returns (bool); /** * @return True if liquidations should be allowed, false otherwise */ function isLiquidationAllowed() external view returns (bool); /** * @return The duration between when the feed comes back online and when the system will allow liquidations to be * processed normally */ function gracePeriod() external view returns (uint256); }
// SPDX-License-Identifier: GPL-3.0-or-later /* Copyright 2023 Dolomite This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ pragma solidity ^0.8.9; import { IDolomiteStructs } from "./IDolomiteStructs.sol"; /** * @title IDolomitePriceOracle * @author Dolomite * * @notice Interface that Price Oracles for DolomiteMargin must implement in order to report prices. */ interface IDolomitePriceOracle { // ============ Public Functions ============ /** * Get the price of a token * * @param token The ERC20 token address of the market * @return The USD price of a base unit of the token, then multiplied by 10^(36 - decimals). * So a USD-stable coin with 6 decimal places would return `price * 10^30`. * 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. */ function getPrice( address token ) external view returns (IDolomiteStructs.MonetaryPrice memory); }
// SPDX-License-Identifier: GPL-3.0-or-later /* Copyright 2023 Dolomite This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ pragma solidity ^0.8.9; import { IDolomiteAccountRiskOverrideSetter } from "./IDolomiteAccountRiskOverrideSetter.sol"; import { IDolomiteInterestSetter } from "./IDolomiteInterestSetter.sol"; import { IDolomiteOracleSentinel } from "./IDolomiteOracleSentinel.sol"; import { IDolomitePriceOracle } from "./IDolomitePriceOracle.sol"; /** * @title IDolomiteStructs * @author Dolomite * * @notice This interface defines the structs used by DolomiteMargin */ interface IDolomiteStructs { // ========================= Enums ========================= enum ActionType { Deposit, // supply tokens Withdraw, // borrow tokens Transfer, // transfer balance between accounts Buy, // buy an amount of some token (externally) Sell, // sell an amount of some token (externally) Trade, // trade tokens against another account Liquidate, // liquidate an undercollateralized or expiring account Vaporize, // use excess tokens to zero-out a completely negative account Call // send arbitrary data to an address } enum AssetDenomination { Wei, // the amount is denominated in wei Par // the amount is denominated in par } enum AssetReference { Delta, // the amount is given as a delta from the current value Target // the amount is given as an exact number to end up at } // ========================= Structs ========================= struct AccountInfo { address owner; // The address that owns the account uint256 number; // A nonce that allows a single address to control many accounts } /** * Most-recently-cached account status. * * Normal: Can only be liquidated if the account values are violating the global margin-ratio. * Liquid: Can be liquidated no matter the account values. * Can be vaporized if there are no more positive account values. * Vapor: Has only negative (or zeroed) account values. Can be vaporized. * */ enum AccountStatus { Normal, Liquid, Vapor } /* * Arguments that are passed to DolomiteMargin in an ordered list as part of a single operation. * Each ActionArgs has an actionType which specifies which action struct that this data will be * parsed into before being processed. */ struct ActionArgs { ActionType actionType; uint256 accountId; AssetAmount amount; uint256 primaryMarketId; uint256 secondaryMarketId; address otherAddress; uint256 otherAccountId; bytes data; } struct AssetAmount { bool sign; // true if positive AssetDenomination denomination; AssetReference ref; uint256 value; } struct Decimal { uint256 value; } struct InterestIndex { uint96 borrow; uint96 supply; uint32 lastUpdate; } struct Market { address token; // Whether additional borrows are allowed for this market bool isClosing; // Whether this market can be removed and its ID can be recycled and reused bool isRecyclable; // Total aggregated supply and borrow amount of the entire market TotalPar totalPar; // Interest index of the market InterestIndex index; // Contract address of the price oracle for this market IDolomitePriceOracle priceOracle; // Contract address of the interest setter for this market IDolomiteInterestSetter interestSetter; // Multiplier on the marginRatio for this market, IE 5% (0.05 * 1e18). This number increases the market's // required collateralization by: reducing the user's supplied value (in terms of dollars) for this market and // increasing its borrowed value. This is done through the following operation: // `suppliedWei = suppliedWei + (assetValueForThisMarket / (1 + marginPremium))` // This number increases the user's borrowed wei by multiplying it by: // `borrowedWei = borrowedWei + (assetValueForThisMarket * (1 + marginPremium))` Decimal marginPremium; // Multiplier on the liquidationSpread for this market, IE 20% (0.2 * 1e18). This number increases the // `liquidationSpread` using the following formula: // `liquidationSpread = liquidationSpread * (1 + spreadPremium)` // NOTE: This formula is applied up to two times - one for each market whose spreadPremium is greater than 0 // (when performing a liquidation between two markets) Decimal spreadPremium; // The maximum amount that can be held by the external. This allows the external to cap any additional risk // that is inferred by allowing borrowing against low-cap or assets with increased volatility. Setting this // value to 0 is analogous to having no limit. This value can never be below 0. Wei maxWei; } struct MarketV2 { // Contract address of the associated ERC20 token address token; // Whether additional borrows are allowed for this market bool isClosing; // Total aggregated supply and borrow amount of the entire market TotalPar totalPar; // Interest index of the market InterestIndex index; // Contract address of the price oracle for this market IDolomitePriceOracle priceOracle; // Contract address of the interest setter for this market IDolomiteInterestSetter interestSetter; // Multiplier on the marginRatio for this market, IE 5% (0.05 * 1e18). This number increases the market's // required collateralization by: reducing the user's supplied value (in terms of dollars) for this market and // increasing its borrowed value. This is done through the following operation: // `suppliedWei = suppliedWei + (assetValueForThisMarket / (1 + marginPremium))` // This number increases the user's borrowed wei by multiplying it by: // `borrowedWei = borrowedWei + (assetValueForThisMarket * (1 + marginPremium))` Decimal marginPremium; // Multiplier on the liquidationSpread for this market, IE 20% (0.2 * 1e18). This number increases the // `liquidationSpread` using the following formula: // `liquidationSpread = liquidationSpread * (1 + spreadPremium)` // NOTE: This formula is applied up to two times - one for each market whose spreadPremium is greater than 0 // (when performing a liquidation between two markets) Decimal liquidationSpreadPremium; // The maximum amount that can be held by the protocol. This allows the protocol to cap any additional risk // that is inferred by allowing borrowing against low-cap or assets with increased volatility. Setting this // value to 0 is analogous to having no limit. This value can never be below 0. Wei maxSupplyWei; // The maximum amount that can be borrowed by the protocol. This allows the protocol to cap any additional risk // that is inferred by allowing borrowing against low-cap or assets with increased volatility. Setting this // value to 0 is analogous to having no limit. This value can never be greater than 0. Wei maxBorrowWei; // The percentage of interest paid that is passed along from borrowers to suppliers. Setting this to 0 will // default to RiskParams.earningsRate. Decimal earningsRateOverride; } /* * The price of a base-unit of an asset. Has `36 - token.decimals` decimals */ struct MonetaryPrice { uint256 value; } struct MonetaryValue { uint256 value; } struct OperatorArg { address operator; bool trusted; } struct Par { bool sign; uint128 value; } struct RiskLimits { // The highest that the ratio can be for liquidating under-water accounts uint64 marginRatioMax; // The highest that the liquidation rewards can be when a liquidator liquidates an account uint64 liquidationSpreadMax; // The highest that the supply APR can be for a market, as a proportion of the borrow rate. Meaning, a rate of // 100% (1e18) would give suppliers all of the interest that borrowers are paying. A rate of 90% would give // suppliers 90% of the interest that borrowers pay. uint64 earningsRateMax; // The highest min margin ratio premium that can be applied to a particular market. Meaning, a value of 100% // (1e18) would require borrowers to maintain an extra 100% collateral to maintain a healthy margin ratio. This // value works by increasing the debt owed and decreasing the supply held for the particular market by this // amount, plus 1e18 (since a value of 10% needs to be applied as `decimal.plusOne`) uint64 marginPremiumMax; // The highest liquidation reward that can be applied to a particular market. This percentage is applied // in addition to the liquidation spread in `RiskParams`. Meaning a value of 1e18 is 100%. It is calculated as: // `liquidationSpread * Decimal.onePlus(spreadPremium)` uint64 spreadPremiumMax; uint128 minBorrowedValueMax; } struct RiskLimitsV2 { // The highest that the ratio can be for liquidating under-water accounts uint64 marginRatioMax; // The highest that the liquidation rewards can be when a liquidator liquidates an account uint64 liquidationSpreadMax; // The highest that the supply APR can be for a market, as a proportion of the borrow rate. Meaning, a rate of // 100% (1e18) would give suppliers all of the interest that borrowers are paying. A rate of 90% would give // suppliers 90% of the interest that borrowers pay. uint64 earningsRateMax; // The highest min margin ratio premium that can be applied to a particular market. Meaning, a value of 100% // (1e18) would require borrowers to maintain an extra 100% collateral to maintain a healthy margin ratio. This // value works by increasing the debt owed and decreasing the supply held for the particular market by this // amount, plus 1e18 (since a value of 10% needs to be applied as `decimal.plusOne`) uint64 marginPremiumMax; // The highest liquidation reward that can be applied to a particular market. This percentage is applied // in addition to the liquidation spread in `RiskParams`. Meaning a value of 1e18 is 100%. It is calculated as: // `liquidationSpread * Decimal.onePlus(spreadPremium)` uint64 liquidationSpreadPremiumMax; // The highest that the borrow interest rate can ever be. If the rate returned is ever higher, the rate is // capped at this value instead of reverting. The goal is to keep Dolomite operational under all circumstances // instead of inadvertently DOS'ing the protocol. uint96 interestRateMax; // The highest that the minBorrowedValue can be. This is the minimum amount of value that must be borrowed. // Typically a value of $100 (100 * 1e18) is more than sufficient. uint128 minBorrowedValueMax; } struct RiskParams { // Required ratio of over-collateralization Decimal marginRatio; // Percentage penalty incurred by liquidated accounts Decimal liquidationSpread; // Percentage of the borrower's interest fee that gets passed to the suppliers Decimal earningsRate; // The minimum absolute borrow value of an account // There must be sufficient incentivize to liquidate undercollateralized accounts MonetaryValue minBorrowedValue; // The maximum number of markets a user can have a non-zero balance for a given account. uint256 accountMaxNumberOfMarketsWithBalances; } // The global risk parameters that govern the health and security of the system struct RiskParamsV2 { // Required ratio of over-collateralization Decimal marginRatio; // Percentage penalty incurred by liquidated accounts Decimal liquidationSpread; // Percentage of the borrower's interest fee that gets passed to the suppliers Decimal earningsRate; // The minimum absolute borrow value of an account // There must be sufficient incentivize to liquidate undercollateralized accounts MonetaryValue minBorrowedValue; // The maximum number of markets a user can have a non-zero balance for a given account. uint256 accountMaxNumberOfMarketsWithBalances; // The oracle sentinel used to disable borrowing/liquidations if the sequencer goes down IDolomiteOracleSentinel oracleSentinel; // The gas limit used for making callbacks via `IExternalCallback::onInternalBalanceChange` to smart contract // wallets. Setting to 0 will effectively disable callbacks; setting it super large is not desired since it // could lead to DOS attacks on the protocol; however, hard coding a max value isn't preferred since some chains // can calculate gas usage differently (like ArbGas before Arbitrum rolled out nitro) uint256 callbackGasLimit; // Certain addresses are allowed to borrow with different LTV requirements. When an account's risk is overrode, // the global risk parameters are ignored and the account's risk parameters are used instead. mapping(address => IDolomiteAccountRiskOverrideSetter) accountRiskOverrideSetterMap; } struct TotalPar { uint128 borrow; uint128 supply; } struct TotalWei { uint128 borrow; uint128 supply; } struct Wei { bool sign; uint256 value; } }
// SPDX-License-Identifier: Apache-2.0 /* Copyright 2019 dYdX Trading Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ pragma solidity ^0.8.9; /** * @title Require * @author dYdX * * @notice Stringifies parameters to pretty-print revert messages. Costs more gas than regular require() */ library Require { // ============ Constants ============ uint256 private constant _ASCII_ZERO = 48; // '0' uint256 private constant _ASCII_RELATIVE_ZERO = 87; // 'a' - 10 uint256 private constant _ASCII_LOWER_EX = 120; // 'x' bytes2 private constant _COLON = 0x3a20; // ': ' bytes2 private constant _COMMA = 0x2c20; // ', ' bytes2 private constant _LPAREN = 0x203c; // ' <' bytes1 private constant _RPAREN = 0x3e; // '>' uint256 private constant _FOUR_BIT_MASK = 0xf; // ============ Library Functions ============ function that( bool must, bytes32 file, bytes32 reason ) internal pure { if (!must) { revert( string( abi.encodePacked( stringifyTruncated(file), _COLON, stringifyTruncated(reason) ) ) ); } } function that( bool must, bytes32 file, bytes32 reason, uint256 payloadA ) internal pure { if (!must) { revert( string( abi.encodePacked( stringifyTruncated(file), _COLON, stringifyTruncated(reason), _LPAREN, _stringify(payloadA), _RPAREN ) ) ); } } function that( bool must, bytes32 file, bytes32 reason, uint256 payloadA, uint256 payloadB ) internal pure { if (!must) { revert( string( abi.encodePacked( stringifyTruncated(file), _COLON, stringifyTruncated(reason), _LPAREN, _stringify(payloadA), _COMMA, _stringify(payloadB), _RPAREN ) ) ); } } function that( bool must, bytes32 file, bytes32 reason, address payloadA ) internal pure { if (!must) { revert( string( abi.encodePacked( stringifyTruncated(file), _COLON, stringifyTruncated(reason), _LPAREN, _stringify(payloadA), _RPAREN ) ) ); } } function that( bool must, bytes32 file, bytes32 reason, address payloadA, uint256 payloadB ) internal pure { if (!must) { revert( string( abi.encodePacked( stringifyTruncated(file), _COLON, stringifyTruncated(reason), _LPAREN, _stringify(payloadA), _COMMA, _stringify(payloadB), _RPAREN ) ) ); } } function that( bool must, bytes32 file, bytes32 reason, address payloadA, uint256 payloadB, uint256 payloadC ) internal pure { if (!must) { revert( string( abi.encodePacked( stringifyTruncated(file), _COLON, stringifyTruncated(reason), _LPAREN, _stringify(payloadA), _COMMA, _stringify(payloadB), _COMMA, _stringify(payloadC), _RPAREN ) ) ); } } function that( bool must, bytes32 file, bytes32 reason, bytes32 payloadA ) internal pure { if (!must) { revert( string( abi.encodePacked( stringifyTruncated(file), _COLON, stringifyTruncated(reason), _LPAREN, _stringify(payloadA), _RPAREN ) ) ); } } function that( bool must, bytes32 file, bytes32 reason, bytes32 payloadA, uint256 payloadB, uint256 payloadC ) internal pure { if (!must) { revert( string( abi.encodePacked( stringifyTruncated(file), _COLON, stringifyTruncated(reason), _LPAREN, _stringify(payloadA), _COMMA, _stringify(payloadB), _COMMA, _stringify(payloadC), _RPAREN ) ) ); } } // ============ Private Functions ============ function stringifyTruncated( bytes32 input ) internal pure returns (bytes memory) { // put the input bytes into the result bytes memory result = abi.encodePacked(input); // determine the length of the input by finding the location of the last non-zero byte for (uint256 i = 32; i > 0; ) { // reverse-for-loops with unsigned integer i--; // find the last non-zero byte in order to determine the length if (result[i] != 0) { uint256 length = i + 1; /* solhint-disable-next-line no-inline-assembly */ assembly { mstore(result, length) // r.length = length; } return result; } } // all bytes are zero return new bytes(0); } function stringifyFunctionSelector( bytes4 input ) internal pure returns (bytes memory) { uint256 z = uint256(bytes32(input) >> 224); // bytes4 are "0x" followed by 4 bytes of data which take up 2 characters each bytes memory result = new bytes(10); // populate the result with "0x" result[0] = bytes1(uint8(_ASCII_ZERO)); result[1] = bytes1(uint8(_ASCII_LOWER_EX)); // for each byte (starting from the lowest byte), populate the result with two characters for (uint256 i = 0; i < 4; i++) { // each byte takes two characters uint256 shift = i * 2; // populate the least-significant character result[9 - shift] = _char(z & _FOUR_BIT_MASK); z = z >> 4; // populate the most-significant character result[8 - shift] = _char(z & _FOUR_BIT_MASK); z = z >> 4; } return result; } function _stringify( uint256 input ) private pure returns (bytes memory) { if (input == 0) { return "0"; } // get the final string length uint256 j = input; uint256 length; while (j != 0) { length++; j /= 10; } // allocate the string bytes memory bstr = new bytes(length); // populate the string starting with the least-significant character j = input; for (uint256 i = length; i > 0; ) { // reverse-for-loops with unsigned integer i--; // take last decimal digit bstr[i] = bytes1(uint8(_ASCII_ZERO + (j % 10))); // remove the last decimal digit j /= 10; } return bstr; } function _stringify( address input ) private pure returns (bytes memory) { uint256 z = uint256(uint160(input)); // addresses are "0x" followed by 20 bytes of data which take up 2 characters each bytes memory result = new bytes(42); // populate the result with "0x" result[0] = bytes1(uint8(_ASCII_ZERO)); result[1] = bytes1(uint8(_ASCII_LOWER_EX)); // for each byte (starting from the lowest byte), populate the result with two characters for (uint256 i = 0; i < 20; i++) { // each byte takes two characters uint256 shift = i * 2; // populate the least-significant character result[41 - shift] = _char(z & _FOUR_BIT_MASK); z = z >> 4; // populate the most-significant character result[40 - shift] = _char(z & _FOUR_BIT_MASK); z = z >> 4; } return result; } function _stringify( bytes32 input ) private pure returns (bytes memory) { uint256 z = uint256(input); // bytes32 are "0x" followed by 32 bytes of data which take up 2 characters each bytes memory result = new bytes(66); // populate the result with "0x" result[0] = bytes1(uint8(_ASCII_ZERO)); result[1] = bytes1(uint8(_ASCII_LOWER_EX)); // for each byte (starting from the lowest byte), populate the result with two characters for (uint256 i = 0; i < 32; i++) { // each byte takes two characters uint256 shift = i * 2; // populate the least-significant character result[65 - shift] = _char(z & _FOUR_BIT_MASK); z = z >> 4; // populate the most-significant character result[64 - shift] = _char(z & _FOUR_BIT_MASK); z = z >> 4; } return result; } function _char( uint256 input ) private pure returns (bytes1) { // return ASCII digit (0-9) if (input < 10) { return bytes1(uint8(input + _ASCII_ZERO)); } // return ASCII letter (a-f) return bytes1(uint8(input + _ASCII_RELATIVE_ZERO)); } }
{ "optimizer": { "enabled": true, "runs": 200, "details": { "yul": false } }, "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":"address","name":"_implementation","type":"address"},{"internalType":"address","name":"_dolomiteMargin","type":"address"},{"internalType":"bytes","name":"_initializationCalldata","type":"bytes"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"implementation","type":"address"}],"name":"ImplementationSet","type":"event"},{"stateMutability":"payable","type":"fallback"},{"inputs":[],"name":"DOLOMITE_MARGIN","outputs":[{"internalType":"contract IDolomiteMargin","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DOLOMITE_MARGIN_OWNER","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"implementation","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_newImplementation","type":"address"}],"name":"upgradeTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newImplementation","type":"address"},{"internalType":"bytes","name":"_upgradeCalldata","type":"bytes"}],"name":"upgradeToAndCall","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]
Deployed Bytecode
0x60806040526004361061004e5760003560e01c806315c14a4a146100675780633659cfe6146100925780634f1ef286146100b25780635c60da1b146100d2578063cbffd921146100f457610055565b3661005557005b610065610060610109565b610142565b005b34801561007357600080fd5b5061007c61016b565b60405161008991906107ce565b60405180910390f35b34801561009e57600080fd5b506100656100ad36600461080c565b61019b565b3480156100be57600080fd5b506100656100cd36600461087f565b6101b2565b3480156100de57600080fd5b506100e7610109565b60405161008991906108e4565b34801561010057600080fd5b506100e7610248565b600061013d61013960017fa7b53796fd2d99cb1f5ae019b54f9e024446c3d12b483f733ccc62ed04eb126b610908565b5490565b905090565b3660008037600080366000845af43d6000803e808015610161573d6000f35b3d6000fd5b505050565b600061013d61013960017f01095cd170b13c49f67c675e3bc004094df00c531fa118e86b230655aba7aa17610908565b336101a5816103a7565b6101ae82610406565b5050565b336101bc816103a7565b6101c584610406565b6102416101d0610109565b84848080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152505060408051808201909152601d81527f526567697374727950726f78793a2055706772616465206661696c6564000000602082015291506102c29050565b5050505050565b600061025261016b565b6001600160a01b0316638da5cb5b6040518163ffffffff1660e01b815260040160206040518083038186803b15801561028a57600080fd5b505afa15801561029e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061013d919061092a565b6060600080856001600160a01b0316856040516102df9190610999565b600060405180830381855af49150503d806000811461031a576040519150601f19603f3d011682016040523d82523d6000602084013e61031f565b606091505b5091509150610330868383876104c7565b9695505050505050565b6001600160a01b03163b151590565b826101665761035782610515565b6101d160f51b61036683610515565b604051602001610378939291906109bc565b60408051601f198184030181529082905262461bcd60e51b825261039e91600401610a1f565b60405180910390fd5b6104036103b2610248565b6001600160a01b0316826001600160a01b0316147127b7363ca237b637b6b4ba32a6b0b933b4b760711b7f43616c6c6572206973206e6f74206f776e6572206f6620446f6c6f6d69746500846105b0565b50565b61045d6001600160a01b0382163b15157f49736f6c6174696f6e4d6f646554726164657250726f787900000000000000007f496d706c656d656e746174696f6e206973206e6f74206120636f6e7472616374610349565b61049061048b60017fa7b53796fd2d99cb1f5ae019b54f9e024446c3d12b483f733ccc62ed04eb126b610908565b829055565b6040516001600160a01b038216907fab64f92ab780ecbf4f3866f57cee465ff36c89450dcce20237ca7a8d81fb7d1390600090a250565b606083156105035782516104fc576001600160a01b0385163b6104fc5760405162461bcd60e51b815260040161039e90610a30565b508161050d565b61050d83836105fc565b949350505050565b606060008260405160200161052a9190610a71565b60408051601f19818403018152919052905060205b8015610595578061054f81610a86565b91505081818151811061056457610564610a9d565b01602001516001600160f81b03191615610590576000610585826001610ab3565b835250909392505050565b61053f565b5060408051600080825260208201909252905b509392505050565b836105f6576105be83610515565b6101d160f51b6105cd84610515565b61080f60f21b6105dc85610626565b604051610378959493929190601f60f91b90602001610adb565b50505050565b81511561060c5781518083602001fd5b8060405162461bcd60e51b815260040161039e9190610a1f565b60408051602a80825260608281019093526001600160a01b03841691600091602082018180368337019050509050603060f81b8160008151811061066c5761066c610a9d565b60200101906001600160f81b031916908160001a905350607860f81b8160018151811061069b5761069b610a9d565b60200101906001600160f81b031916908160001a90535060005b60148110156105a85760006106cb826002610b39565b90506106d9600f851661076c565b836106e5836029610908565b815181106106f5576106f5610a9d565b60200101906001600160f81b031916908160001a905350600484901c935061071f600f851661076c565b8361072b836028610908565b8151811061073b5761073b610a9d565b60200101906001600160f81b031916908160001a9053505060049290921c918061076481610b58565b9150506106b5565b6000600a82101561078b57610782603083610ab3565b60f81b92915050565b610782605783610ab3565b60006001600160a01b0382165b92915050565b60006107a382610796565b60006107a3826107a9565b6107c8816107b4565b82525050565b602081016107a382846107bf565b60006001600160a01b0382166107a3565b6107f6816107dc565b811461040357600080fd5b80356107a3816107ed565b60006020828403121561082157610821600080fd5b600061050d8484610801565b60008083601f84011261084257610842600080fd5b50813567ffffffffffffffff81111561085d5761085d600080fd5b60208301915083600182028301111561087857610878600080fd5b9250929050565b60008060006040848603121561089757610897600080fd5b60006108a38686610801565b935050602084013567ffffffffffffffff8111156108c3576108c3600080fd5b6108cf8682870161082d565b92509250509250925092565b6107c8816107dc565b602081016107a382846108db565b634e487b7160e01b600052601160045260246000fd5b60008282101561091a5761091a6108f2565b500390565b80516107a3816107ed565b60006020828403121561093f5761093f600080fd5b600061050d848461091f565b60005b8381101561096657818101518382015260200161094e565b838111156105f65750506000910152565b6000610981825190565b61098f81856020860161094b565b9290920192915050565b60006109a58284610977565b9392505050565b6001600160f01b031981166107c8565b60006109c88286610977565b91506109d482856109ac565b6002820191506109e48284610977565b95945050505050565b60006109f7825190565b808452602084019350610a0e81856020860161094b565b601f01601f19169290920192915050565b602080825281016109a581846109ed565b602080825281016107a381601d81527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000602082015260400190565b806107c8565b6000610a7d8284610a6b565b50602001919050565b600081610a9557610a956108f2565b506000190190565b634e487b7160e01b600052603260045260246000fd5b60008219821115610ac657610ac66108f2565b500190565b6001600160f81b031981166107c8565b6000610ae78289610977565b9150610af382886109ac565b600282019150610b038287610977565b9150610b0f82866109ac565b600282019150610b1f8285610977565b9150610b2b8284610acb565b506001019695505050505050565b6000816000190483118215151615610b5357610b536108f2565b500290565b6000600019821415610b6c57610b6c6108f2565b506001019056fea264697066735822122064aa9ab7607b06537d0d381c4a86a952e5a33a3df5f1263ae5ddaed8c6a7abfe64736f6c63430008090033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 34 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|---|---|---|---|---|
ARB | 100.00% | $1,779.99 | 0.1235 | $219.81 |
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
[ Download: CSV Export ]
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.