🔮 Oracle system

In Perpetual3's smart contracts, an Oracle is used to ensure the correct price conversions from fiat to crypto.

The Role of Oracle in Perpetual3

Perpetual3's Oracle system operates by having its identity encoded within the smart contract's global state. This identity is represented by an Ed25519 public key. This public key serves as a unique identifier for the Oracle and is used for verifying the Oracle data used in transactions.

The Oracle data, along with the corresponding signature, is provided by the user during the transaction. The smart contract uses this data and signature to verify the authenticity of the Oracle's information. This is done by checking the signature against the Oracle public key stored in the smart contract.

Data Generation Process

The Oracle data generation process starts with the Oracle accepting key transaction parameters like fiat price, fiat currency (e.g., USD, EUR). Furthermore, it also requires the payment type, which could be a Layer 1 token such as ALGO or ETH, or any other fungible token like USDC or USDT.

Upon receipt of these parameters, the Oracle generates the necessary data as follows:

  1. Price Conversion: The Oracle leverages APIs like Coin gecko to convert the provided fiat price into its equivalent cryptocurrency value. This step ensures that the payment reflects the current market rate of the chosen cryptocurrency against the provided fiat currency.

  2. Data Signing: After the price conversion, the Oracle appends the round number in which the conversion was made and signs this data using its private key. The signature ensures the integrity of the data and allows for its verification at a later stage by the smart contract.

Here is a simplified representation of this process:

  1. User provides: Fiat price, Fiat currency, Payment type.

  2. Oracle converts Fiat price into equivalent cryptocurrency value and adds the round number in which the conversion was made.

  3. Oracle signs the generated data and send back to the customer that later submit this data to the smart contract.

We chose to build our own oracle system because we need access to various price feeds of a lot of cryptocurrencies that are not usually supported by other oracles and may require a lot of time to be integrated.

While the current Oracle system operates centrally, we are actively working on a roadmap towards a more decentralized architecture. This progression will include leveraging distributed Oracle networks and decentralized price feeds, to ensure robustness and maintain security, while enhancing transparency and trust in the system. Stay tuned for updates on our ongoing development and innovations.

Last updated