Overview
S Balance
S Value
$0.00More Info
Private Name Tags
ContractCreator
Loading...
Loading
Similar Match Source Code This contract matches the deployed Bytecode of the Source Code for Contract 0xAd3adde5...6652D05c3 The constructor portion of the code might be different and could alter the actual behaviour of the contract
Contract Name:
OrderBookReader
Compiler Version
v0.6.12+commit.27d51765
Optimization Enabled:
Yes with 10 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; import "../libraries/math/SafeMath.sol"; import "../core/interfaces/IOrderBook.sol"; contract OrderBookReader { using SafeMath for uint256; struct Vars { uint256 i; uint256 index; address account; uint256 uintLength; uint256 addressLength; } function getIncreaseOrders( address payable _orderBookAddress, address _account, uint256[] memory _indices ) external view returns (uint256[] memory, address[] memory) { Vars memory vars = Vars(0, 0, _account, 5, 3); uint256[] memory uintProps = new uint256[](vars.uintLength * _indices.length); address[] memory addressProps = new address[](vars.addressLength * _indices.length); IOrderBook orderBook = IOrderBook(_orderBookAddress); while (vars.i < _indices.length) { vars.index = _indices[vars.i]; ( address purchaseToken, uint256 purchaseTokenAmount, address collateralToken, address indexToken, uint256 sizeDelta, bool isLong, uint256 triggerPrice, bool triggerAboveThreshold, // uint256 executionFee ) = orderBook.getIncreaseOrder(vars.account, vars.index); uintProps[vars.i * vars.uintLength] = uint256(purchaseTokenAmount); uintProps[vars.i * vars.uintLength + 1] = uint256(sizeDelta); uintProps[vars.i * vars.uintLength + 2] = uint256(isLong ? 1 : 0); uintProps[vars.i * vars.uintLength + 3] = uint256(triggerPrice); uintProps[vars.i * vars.uintLength + 4] = uint256(triggerAboveThreshold ? 1 : 0); addressProps[vars.i * vars.addressLength] = (purchaseToken); addressProps[vars.i * vars.addressLength + 1] = (collateralToken); addressProps[vars.i * vars.addressLength + 2] = (indexToken); vars.i++; } return (uintProps, addressProps); } function getDecreaseOrders( address payable _orderBookAddress, address _account, uint256[] memory _indices ) external view returns (uint256[] memory, address[] memory) { Vars memory vars = Vars(0, 0, _account, 5, 2); uint256[] memory uintProps = new uint256[](vars.uintLength * _indices.length); address[] memory addressProps = new address[](vars.addressLength * _indices.length); IOrderBook orderBook = IOrderBook(_orderBookAddress); while (vars.i < _indices.length) { vars.index = _indices[vars.i]; ( address collateralToken, uint256 collateralDelta, address indexToken, uint256 sizeDelta, bool isLong, uint256 triggerPrice, bool triggerAboveThreshold, // uint256 executionFee ) = orderBook.getDecreaseOrder(vars.account, vars.index); uintProps[vars.i * vars.uintLength] = uint256(collateralDelta); uintProps[vars.i * vars.uintLength + 1] = uint256(sizeDelta); uintProps[vars.i * vars.uintLength + 2] = uint256(isLong ? 1 : 0); uintProps[vars.i * vars.uintLength + 3] = uint256(triggerPrice); uintProps[vars.i * vars.uintLength + 4] = uint256(triggerAboveThreshold ? 1 : 0); addressProps[vars.i * vars.addressLength] = (collateralToken); addressProps[vars.i * vars.addressLength + 1] = (indexToken); vars.i++; } return (uintProps, addressProps); } function getSwapOrders( address payable _orderBookAddress, address _account, uint256[] memory _indices ) external view returns (uint256[] memory, address[] memory) { Vars memory vars = Vars(0, 0, _account, 5, 3); uint256[] memory uintProps = new uint256[](vars.uintLength * _indices.length); address[] memory addressProps = new address[](vars.addressLength * _indices.length); IOrderBook orderBook = IOrderBook(_orderBookAddress); while (vars.i < _indices.length) { vars.index = _indices[vars.i]; ( address path0, address path1, address path2, uint256 amountIn, uint256 minOut, uint256 triggerRatio, bool triggerAboveThreshold, bool shouldUnwrap, // uint256 executionFee ) = orderBook.getSwapOrder(vars.account, vars.index); uintProps[vars.i * vars.uintLength] = uint256(amountIn); uintProps[vars.i * vars.uintLength + 1] = uint256(minOut); uintProps[vars.i * vars.uintLength + 2] = uint256(triggerRatio); uintProps[vars.i * vars.uintLength + 3] = uint256(triggerAboveThreshold ? 1 : 0); uintProps[vars.i * vars.uintLength + 4] = uint256(shouldUnwrap ? 1 : 0); addressProps[vars.i * vars.addressLength] = (path0); addressProps[vars.i * vars.addressLength + 1] = (path1); addressProps[vars.i * vars.addressLength + 2] = (path2); vars.i++; } return (uintProps, addressProps); } }
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; interface IOrderBook { function getSwapOrder(address _account, uint256 _orderIndex) external view returns ( address path0, address path1, address path2, uint256 amountIn, uint256 minOut, uint256 triggerRatio, bool triggerAboveThreshold, bool shouldUnwrap, uint256 executionFee ); function getIncreaseOrder(address _account, uint256 _orderIndex) external view returns ( address purchaseToken, uint256 purchaseTokenAmount, address collateralToken, address indexToken, uint256 sizeDelta, bool isLong, uint256 triggerPrice, bool triggerAboveThreshold, uint256 executionFee ); function getDecreaseOrder(address _account, uint256 _orderIndex) external view returns ( address collateralToken, uint256 collateralDelta, address indexToken, uint256 sizeDelta, bool isLong, uint256 triggerPrice, bool triggerAboveThreshold, uint256 executionFee ); function executeSwapOrder(address, uint256, address payable) external; function executeDecreaseOrder(address, uint256, address payable) external; function executeIncreaseOrder(address, uint256, address payable) external; }
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
{ "optimizer": { "enabled": true, "runs": 10 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address payable","name":"_orderBookAddress","type":"address"},{"internalType":"address","name":"_account","type":"address"},{"internalType":"uint256[]","name":"_indices","type":"uint256[]"}],"name":"getDecreaseOrders","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address payable","name":"_orderBookAddress","type":"address"},{"internalType":"address","name":"_account","type":"address"},{"internalType":"uint256[]","name":"_indices","type":"uint256[]"}],"name":"getIncreaseOrders","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address payable","name":"_orderBookAddress","type":"address"},{"internalType":"address","name":"_account","type":"address"},{"internalType":"uint256[]","name":"_indices","type":"uint256[]"}],"name":"getSwapOrders","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"}]
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106100415760003560e01c80630ce933b9146100465780632e18146914610199578063c38ccd5014610253575b600080fd5b6101006004803603606081101561005c57600080fd5b6001600160a01b038235811692602081013590911691810190606081016040820135600160201b81111561008f57600080fd5b8201836020820111156100a157600080fd5b803590602001918460208302840111600160201b831117156100c257600080fd5b91908080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525092955061030d945050505050565b604051808060200180602001838103835285818151815260200191508051906020019060200280838360005b8381101561014457818101518382015260200161012c565b50505050905001838103825284818151815260200191508051906020019060200280838360005b8381101561018357818101518382015260200161016b565b5050505090500194505050505060405180910390f35b610100600480360360608110156101af57600080fd5b6001600160a01b038235811692602081013590911691810190606081016040820135600160201b8111156101e257600080fd5b8201836020820111156101f457600080fd5b803590602001918460208302840111600160201b8311171561021557600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550610675945050505050565b6101006004803603606081101561026957600080fd5b6001600160a01b038235811692602081013590911691810190606081016040820135600160201b81111561029c57600080fd5b8201836020820111156102ae57600080fd5b803590602001918460208302840111600160201b831117156102cf57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550610a17945050505050565b606080610318610db9565b6040518060a001604052806000815260200160008152602001866001600160a01b031681526020016005815260200160028152509050606084518260600151026001600160401b038111801561036d57600080fd5b50604051908082528060200260200182016040528015610397578160200160208202803683370190505b509050606085518360800151026001600160401b03811180156103b957600080fd5b506040519080825280602002602001820160405280156103e3578160200160208202803683370190505b509050875b865184511015610667578684600001518151811061040257fe5b60200260200101518460200181815250506000806000806000806000876001600160a01b031663026032ee8c604001518d602001516040518363ffffffff1660e01b815260040180836001600160a01b03168152602001828152602001925050506101006040518083038186803b15801561047c57600080fd5b505afa158015610490573d6000803e3d6000fd5b505050506040513d6101008110156104a757600080fd5b810190808051906020019092919080519060200190929190805190602001909291908051906020019092919080519060200190929190805190602001909291908051906020019092919080519060200190929190505050509650965096509650965096509650858a8c606001518d60000151028151811061052457fe5b602002602001018181525050838a8c606001518d60000151026001018151811061054a57fe5b60200260200101818152505082610562576000610565565b60015b60ff168a8c606001518d60000151026002018151811061058157fe5b602002602001018181525050818a8c606001518d6000015102600301815181106105a757fe5b602002602001018181525050806105bf5760006105c2565b60015b60ff168a8c606001518d6000015102600401815181106105de57fe5b60200260200101818152505086898c608001518d60000151028151811061060157fe5b60200260200101906001600160a01b031690816001600160a01b03168152505084898c608001518d60000151026001018151811061063b57fe5b6001600160a01b0390921660209283029190910190910152505088516001018952506103e89350505050565b509097909650945050505050565b606080610680610db9565b6040518060a001604052806000815260200160008152602001866001600160a01b031681526020016005815260200160038152509050606084518260600151026001600160401b03811180156106d557600080fd5b506040519080825280602002602001820160405280156106ff578160200160208202803683370190505b509050606085518360800151026001600160401b038111801561072157600080fd5b5060405190808252806020026020018201604052801561074b578160200160208202803683370190505b509050875b865184511015610667578684600001518151811061076a57fe5b6020026020010151846020018181525050600080600080600080600080886001600160a01b031663d0d40cd68d604001518e602001516040518363ffffffff1660e01b815260040180836001600160a01b03168152602001828152602001925050506101206040518083038186803b1580156107e557600080fd5b505afa1580156107f9573d6000803e3d6000fd5b505050506040513d61012081101561081057600080fd5b810190808051906020019092919080519060200190929190805190602001909291908051906020019092919080519060200190929190805190602001909291908051906020019092919080519060200190929190805190602001909291905050505097509750975097509750975097509750848b8d606001518e60000151028151811061089957fe5b602002602001018181525050838b8d606001518e6000015102600101815181106108bf57fe5b602002602001018181525050828b8d606001518e6000015102600201815181106108e557fe5b602002602001018181525050816108fd576000610900565b60015b60ff168b8d606001518e60000151026003018151811061091c57fe5b60200260200101818152505080610934576000610937565b60015b60ff168b8d606001518e60000151026004018151811061095357fe5b602002602001018181525050878a8d608001518e60000151028151811061097657fe5b60200260200101906001600160a01b031690816001600160a01b031681525050868a8d608001518e6000015102600101815181106109b057fe5b60200260200101906001600160a01b031690816001600160a01b031681525050858a8d608001518e6000015102600201815181106109ea57fe5b6001600160a01b0390921660209283029190910190910152505089516001018a5250610750945050505050565b606080610a22610db9565b6040518060a001604052806000815260200160008152602001866001600160a01b031681526020016005815260200160038152509050606084518260600151026001600160401b0381118015610a7757600080fd5b50604051908082528060200260200182016040528015610aa1578160200160208202803683370190505b509050606085518360800151026001600160401b0381118015610ac357600080fd5b50604051908082528060200260200182016040528015610aed578160200160208202803683370190505b509050875b8651845110156106675786846000015181518110610b0c57fe5b6020026020010151846020018181525050600080600080600080600080886001600160a01b031663d3bab1d18d604001518e602001516040518363ffffffff1660e01b815260040180836001600160a01b03168152602001828152602001925050506101206040518083038186803b158015610b8757600080fd5b505afa158015610b9b573d6000803e3d6000fd5b505050506040513d610120811015610bb257600080fd5b810190808051906020019092919080519060200190929190805190602001909291908051906020019092919080519060200190929190805190602001909291908051906020019092919080519060200190929190805190602001909291905050505097509750975097509750975097509750868b8d606001518e600001510281518110610c3b57fe5b602002602001018181525050838b8d606001518e600001510260010181518110610c6157fe5b60200260200101818152505082610c79576000610c7c565b60015b60ff168b8d606001518e600001510260020181518110610c9857fe5b602002602001018181525050818b8d606001518e600001510260030181518110610cbe57fe5b60200260200101818152505080610cd6576000610cd9565b60015b60ff168b8d606001518e600001510260040181518110610cf557fe5b602002602001018181525050878a8d608001518e600001510281518110610d1857fe5b60200260200101906001600160a01b031690816001600160a01b031681525050858a8d608001518e600001510260010181518110610d5257fe5b60200260200101906001600160a01b031690816001600160a01b031681525050848a8d608001518e600001510260020181518110610d8c57fe5b6001600160a01b0390921660209283029190910190910152505089516001018a5250610af2945050505050565b6040518060a00160405280600081526020016000815260200160006001600160a01b031681526020016000815260200160008152509056fea26469706673582212207b3a04568e210b44a87f12f3128570e5de9ccb0aca98a99a857a68c38966b39964736f6c634300060c0033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 31 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
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.