SmartPiggies
HomepageAppPink PaperDiscord
  • Introduction
  • Getting Started
    • Accessing Testnet
    • What is a SmartPiggy NFT?
      • Background: What is a financial option?
    • Where do Piggies live?
      • Arbitrum Introduction
      • How to use Arbitrum
    • Parts of a Piggy
    • An example Piggy
    • Creating your first Piggy
      • Create a Piggy
      • Request a Piggy
  • Lifecycle of a Piggy
    • Approve Collateral
    • Auction
    • Buy
    • Bid
    • Finalize
    • Clear
    • Settle
    • Claim payout
    • Burn - Reclaim collateral
  • Advanced Functions
    • Transfer
    • Split
  • The User Interface
    • Explore Markets
      • Table Dropdown
    • My Dashboard
      • Table Dropdown
    • Wallet
      • Approving Collateral tokens
      • Approving Oracle tokens
      • Claiming payouts
      • Supported wallets
  • Oracles
    • Available oracles
    • Using your own oracles
    • SmartPiggies and Oracles
  • Arbitration
    • The (optional) Need for Arbitration
    • Setting an arbitrator
    • The Arbitration Process
    • Arbiter Reputation and History
  • FAQ
  • FAQ
  • Developers
    • Contracts
      • Calling the contracts directly
Powered by GitBook
On this page

Was this helpful?

  1. Oracles

SmartPiggies and Oracles

How SmartPiggies uses oracles

SmartPiggies use off-chain data to settle a piggy. Although SmartPiggies recommends selling a piggy back to the writer, as are typically done for traditional options, there are many reasons why the counterparties may need to execute a piggy, and this will involve a call to an oracle to retrieve off-chain data.

Off-chain data, here prices, are requested by a resolver, which is a smart contract that receives requests and relays results. A resolver contract address is associated with a piggy, this is, for all intents and purposes, the underlying that the piggy will execute against. When a piggy makes a request for a price, which can happen during the bidding process or the settlement process, SmartPiggies will execute a fetchData() function on the resolver. When the function is executed on the resolver, an external process (on following the blockchain, but not on it) will pick up the request being made on the resolver. 1^11 This external process is the oracle and is responsible for sending the desired data back to the resolver.

There will be a unique resolver for each underlying. The contract address of this specific resolver is saved into the piggy. This is the contract address used to fetch the price data, if the piggy is executed. For example, if a piggy's underlying is ETHUSD, a unique contract address, referencing the ETHUSD resolver, will be saved as the underlying of the piggy.

With this approach underlyings can be added or removed to the app. When interacting directly with the SmartPiggies contract, any address can be provided, but there are strict requirements for the resolver to execute correctly, and SmartPiggies recommends only using approved resolvers.

Footnotes

1 The technical sequence of events begins by the SmartPiggies contract calling a specific resolver. That resolver will call a DataProvider contract. The DataProvider will create a request event, which an external process will catch. The external process (the oracle) will fetch the data, and then make an on-chain call to the DataProvider including the data. The DataProvider will callback the resolver with the data, and the resolver will callback the SmartPiggies contract, updating the piggy with the requested data.

PreviousUsing your own oraclesNextThe (optional) Need for Arbitration

Last updated 3 years ago

Was this helpful?