Opium Network
  • Opium Documentation
  • Introduction to Opium
    • What is Opium
    • FAQs
  • Restrictions
    • Restrictions
  • Security and Audits
    • Disclaimer
    • Audits
    • Bounty program
  • Governance
    • Decentralized setup
    • Governance flow
      • Proposal creating
      • Process of voting – technical description
    • $Opium governance token
  • For users
    • Opium.Finance
    • opium.exchange
  • FOR DEVELOPERS
    • Deployment Addresses
      • Opium Protocol v2
      • Opium Protocol v1
    • High-level overview
    • Opium Protocol V2
      • Core
      • Registry
      • SyntheticAggregator
      • OracleAggregator
      • OpiumProxyFactory
      • OpiumPositionToken
    • Opium Protocol V1
      • Core
      • Registry
      • TokenMinter
      • TokenSpender
      • SyntheticAggregator
      • OracleAggregator
      • Helpers
      • Interfaces
      • Common Errors
        • OracleAggregator Errors
        • Core Errors
      • oID - Oracle recipe
      • sID - Derivative recipe
      • EIP-2547: Composable Multiclass Token
    • Tutorials
      • OracleId examples
      • SyntheticId examples
      • End-to-end tutorial
    • Opium API
      • Subgraph V2
      • Subgraph V1
    • SDK
      • Opium V2 SDK
      • Opium Finance Pools SDK
      • Swap Rate SDK/API
  • Complex description
    • Glossary
    • Opium derivatives
    • Oracle and derivative recipes
    • Oracle and derivative registers
    • Opium margin
    • Opium swaps (TMtm)
    • Opium order books
Powered by GitBook
On this page
  • IDerivativeLogic
  • IOracleId

Was this helpful?

  1. FOR DEVELOPERS
  2. Opium Protocol V1

Interfaces

IDerivativeLogic

Derivative recipes implementing the IDerivativeLogic interface can make use of the HasCommission and ExecutableByThirdParty helper contracts. The HasCommission contract exposes the view functions to query information about the derivative’s author and sets the commission for the creation of the derivative at 0.25% of the profit. The ExecutableByThirdParty implements the set of functions necessary to allow third-party execution and query whether it has already been granted.

validateInput(Derivative memory _derivative) public view returns(bool);

It should allow to implement custom validation requirements for a derivative recipe

getMargin(Derivative memory _derivative) public view returns(uint256 buyerMargin, uint256 sellerMargin)

getExecutionPayout(Derivative memory _derivative, uint256 _result) public view returns(uint256 buyerPayout, uint256 sellerPayout)

The heart of customization of a derivative recipe. It is the function called by the Core contract to retrieve the payouts of a buyer and a seller. Any kind of payout logic - from traditional call/put options to more exotic products- should be implemented here.

getAuthorAddress() public view returns(address authorAddress);

It should return the derivative author’s address

getAuthorCommission() public view returns(uint256 commission);

It should return the derivative author’s commission

allowThirdPartyExecution(bool _allow) public

It should implement the logic to enable third party execution of the derivative’s positions

thirdPartyExecutionAllowed(address _derivativeOwner) public view returns(bool)

It should allow to retrieve whether third-party positions’ execution has been enabled for a given _derivativeOwner address

isPool() public view returns(bool)

deprecated

IOracleId

fetchData(address oracleId, uint256 timestamp) public

recursivelyFetchData(address oracleId, uint256 timestamp, uint256 period, uint256 times) public

calculateFetchPrice(address oracleId) public returns(uint256 fetchPrice)

PreviousHelpersNextCommon Errors

Last updated 3 years ago

Was this helpful?