Mumbai Testnet

Contract

0x0D4168f4e87C391D2A92264841106140bc12FE02

Overview

MATIC Balance

Multichain Info

N/A
Transaction Hash
Method
Block
From
To
Value
0x60806040256463742022-03-24 11:02:09797 days ago1648119729IN
 Create: PayoutHelper
0 MATIC0.002694258.50000013

Parent Transaction Hash Block From To Value
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
PayoutHelper

Compiler Version
v0.8.5+commit.a4f2e591

Optimization Enabled:
Yes with 800 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity Standard Json-Input format)

File 1 of 3 : PayoutHelper.sol
// SPDX-License-Identifier: agpl-3.0
pragma solidity 0.8.5;

import "../interfaces/IDerivativeLogic.sol";
import "../libs/LibDerivative.sol";

contract PayoutHelper {
    struct ExecutionPayout {
        uint256 buyerPayout;
        uint256 sellerPayout;
    }

    function getExecutionPayouts(LibDerivative.Derivative calldata _derivative, uint256[] calldata _results)
        external
        view
        returns (ExecutionPayout[] memory executionPayouts)
    {
        IDerivativeLogic logic = IDerivativeLogic(_derivative.syntheticId);

        executionPayouts = new ExecutionPayout[](_results.length);

        for (uint256 i = 0; i < _results.length; i++) {
            (uint256 buyerPayout, uint256 sellerPayout) = logic.getExecutionPayout(_derivative, _results[i]);
            executionPayouts[i] = ExecutionPayout(buyerPayout, sellerPayout);
        }
    }
}

File 2 of 3 : IDerivativeLogic.sol
// SPDX-License-Identifier: agpl-3.0
pragma solidity 0.8.5;

import "../libs/LibDerivative.sol";

/// @title Opium.Interface.IDerivativeLogic is an interface that every syntheticId should implement
interface IDerivativeLogic {
    // Event with syntheticId metadata JSON string (for DIB.ONE derivative explorer)
    event LogMetadataSet(string metadata);

    /// @notice Validates ticker
    /// @param _derivative Derivative Instance of derivative to validate
    /// @return Returns boolean whether ticker is valid
    function validateInput(LibDerivative.Derivative memory _derivative) external view returns (bool);

    /// @return Returns the custom name of a derivative ticker which will be used as part of the name of its positions
    function getSyntheticIdName() external view returns (string memory);

    /// @notice Calculates margin required for derivative creation
    /// @param _derivative Derivative Instance of derivative
    /// @return buyerMargin uint256 Margin needed from buyer (LONG position)
    /// @return sellerMargin uint256 Margin needed from seller (SHORT position)
    function getMargin(LibDerivative.Derivative memory _derivative)
        external
        view
        returns (uint256 buyerMargin, uint256 sellerMargin);

    /// @notice Calculates payout for derivative execution
    /// @param _derivative Derivative Instance of derivative
    /// @param _result uint256 Data retrieved from oracleId on the maturity
    /// @return buyerPayout uint256 Payout in ratio for buyer (LONG position holder)
    /// @return sellerPayout uint256 Payout in ratio for seller (SHORT position holder)
    function getExecutionPayout(LibDerivative.Derivative memory _derivative, uint256 _result)
        external
        view
        returns (uint256 buyerPayout, uint256 sellerPayout);

    /// @notice Returns syntheticId author address for Opium commissions
    /// @return authorAddress address The address of syntheticId address
    function getAuthorAddress() external view returns (address authorAddress);

    /// @notice Returns syntheticId author commission in base of COMMISSION_BASE
    /// @return commission uint256 Author commission
    function getAuthorCommission() external view returns (uint256 commission);

    /// @notice Returns whether thirdparty could execute on derivative's owner's behalf
    /// @param _derivativeOwner address Derivative owner address
    /// @return Returns boolean whether _derivativeOwner allowed third party execution
    function thirdpartyExecutionAllowed(address _derivativeOwner) external view returns (bool);

    /// @notice Sets whether thirds parties are allowed or not to execute derivative's on msg.sender's behalf
    /// @param _allow bool Flag for execution allowance
    function allowThirdpartyExecution(bool _allow) external;
}

File 2 of 3 : LibDerivative.sol
// SPDX-License-Identifier: agpl-3.0
pragma solidity 0.8.5;

/// @title Opium.Lib.LibDerivative contract should be inherited by contracts that use Derivative structure and calculate derivativeHash
library LibDerivative {
    enum PositionType {
        SHORT,
        LONG
    }

    // Opium derivative structure (ticker) definition
    struct Derivative {
        // Margin parameter for syntheticId
        uint256 margin;
        // Maturity of derivative
        uint256 endTime;
        // Additional parameters for syntheticId
        uint256[] params;
        // oracleId of derivative
        address oracleId;
        // Margin token address of derivative
        address token;
        // syntheticId of derivative
        address syntheticId;
    }

    /// @notice Calculates hash of provided Derivative
    /// @param _derivative Derivative Instance of derivative to hash
    /// @return derivativeHash bytes32 Derivative hash
    function getDerivativeHash(Derivative memory _derivative) internal pure returns (bytes32 derivativeHash) {
        derivativeHash = keccak256(
            abi.encodePacked(
                _derivative.margin,
                _derivative.endTime,
                _derivative.params,
                _derivative.oracleId,
                _derivative.token,
                _derivative.syntheticId
            )
        );
    }
}

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 800
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "metadata": {
    "useLiteralContent": true
  },
  "libraries": {}
}

Contract ABI

[{"inputs":[{"components":[{"internalType":"uint256","name":"margin","type":"uint256"},{"internalType":"uint256","name":"endTime","type":"uint256"},{"internalType":"uint256[]","name":"params","type":"uint256[]"},{"internalType":"address","name":"oracleId","type":"address"},{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"syntheticId","type":"address"}],"internalType":"struct LibDerivative.Derivative","name":"_derivative","type":"tuple"},{"internalType":"uint256[]","name":"_results","type":"uint256[]"}],"name":"getExecutionPayouts","outputs":[{"components":[{"internalType":"uint256","name":"buyerPayout","type":"uint256"},{"internalType":"uint256","name":"sellerPayout","type":"uint256"}],"internalType":"struct PayoutHelper.ExecutionPayout[]","name":"executionPayouts","type":"tuple[]"}],"stateMutability":"view","type":"function"}]

608060405234801561001057600080fd5b506104c6806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c80638800c3b514610030575b600080fd5b61004361003e366004610205565b610059565b604051610050919061031a565b60405180910390f35b6060600061006d60c0860160a087016101e3565b90508267ffffffffffffffff8111156100885761008861047a565b6040519080825280602002602001820160405280156100cd57816020015b60408051808201909152600080825260208201528152602001906001900390816100a65790505b50915060005b838110156101be57600080836001600160a01b031663dd0060fd8989898781811061010057610100610464565b905060200201356040518363ffffffff1660e01b8152600401610124929190610369565b604080518083038186803b15801561013b57600080fd5b505afa15801561014f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061017391906102a7565b9150915060405180604001604052808381526020018281525085848151811061019e5761019e610464565b6020026020010181905250505080806101b69061043b565b9150506100d3565b50509392505050565b80356001600160a01b03811681146101de57600080fd5b919050565b6000602082840312156101f557600080fd5b6101fe826101c7565b9392505050565b60008060006040848603121561021a57600080fd5b833567ffffffffffffffff8082111561023257600080fd5b9085019060c0828803121561024657600080fd5b9093506020850135908082111561025c57600080fd5b818601915086601f83011261027057600080fd5b81358181111561027f57600080fd5b8760208260051b850101111561029457600080fd5b6020830194508093505050509250925092565b600080604083850312156102ba57600080fd5b505080516020909101519092909150565b81835260007f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8311156102fd57600080fd5b8260051b8083602087013760009401602001938452509192915050565b602080825282518282018190526000919060409081850190868401855b8281101561035c57815180518552860151868501529284019290850190600101610337565b5091979650505050505050565b60408152823560408201526020830135606082015260006040840135601e1985360301811261039757600080fd5b8401803567ffffffffffffffff8111156103b057600080fd5b8060051b36038613156103c257600080fd5b60c060808501526103db610100850182602085016102cb565b9150506103ea606086016101c7565b6001600160a01b031660a0840152610404608086016101c7565b6001600160a01b031660c084015261041e60a086016101c7565b6001600160a01b031660e084015260209092019290925292915050565b600060001982141561045d57634e487b7160e01b600052601160045260246000fd5b5060010190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fdfea26469706673582212203411f2636f9a3891a380a82be3ebc19ae0295d39cdc639e7321d2cc8e713117964736f6c63430008050033

Deployed Bytecode

0x608060405234801561001057600080fd5b506004361061002b5760003560e01c80638800c3b514610030575b600080fd5b61004361003e366004610205565b610059565b604051610050919061031a565b60405180910390f35b6060600061006d60c0860160a087016101e3565b90508267ffffffffffffffff8111156100885761008861047a565b6040519080825280602002602001820160405280156100cd57816020015b60408051808201909152600080825260208201528152602001906001900390816100a65790505b50915060005b838110156101be57600080836001600160a01b031663dd0060fd8989898781811061010057610100610464565b905060200201356040518363ffffffff1660e01b8152600401610124929190610369565b604080518083038186803b15801561013b57600080fd5b505afa15801561014f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061017391906102a7565b9150915060405180604001604052808381526020018281525085848151811061019e5761019e610464565b6020026020010181905250505080806101b69061043b565b9150506100d3565b50509392505050565b80356001600160a01b03811681146101de57600080fd5b919050565b6000602082840312156101f557600080fd5b6101fe826101c7565b9392505050565b60008060006040848603121561021a57600080fd5b833567ffffffffffffffff8082111561023257600080fd5b9085019060c0828803121561024657600080fd5b9093506020850135908082111561025c57600080fd5b818601915086601f83011261027057600080fd5b81358181111561027f57600080fd5b8760208260051b850101111561029457600080fd5b6020830194508093505050509250925092565b600080604083850312156102ba57600080fd5b505080516020909101519092909150565b81835260007f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8311156102fd57600080fd5b8260051b8083602087013760009401602001938452509192915050565b602080825282518282018190526000919060409081850190868401855b8281101561035c57815180518552860151868501529284019290850190600101610337565b5091979650505050505050565b60408152823560408201526020830135606082015260006040840135601e1985360301811261039757600080fd5b8401803567ffffffffffffffff8111156103b057600080fd5b8060051b36038613156103c257600080fd5b60c060808501526103db610100850182602085016102cb565b9150506103ea606086016101c7565b6001600160a01b031660a0840152610404608086016101c7565b6001600160a01b031660c084015261041e60a086016101c7565b6001600160a01b031660e084015260209092019290925292915050565b600060001982141561045d57634e487b7160e01b600052601160045260246000fd5b5060010190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fdfea26469706673582212203411f2636f9a3891a380a82be3ebc19ae0295d39cdc639e7321d2cc8e713117964736f6c63430008050033

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Txn Hash Block Value Eth2 PubKey Valid
View All Deposits
[ 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.