Skip to main content

Architecture


The V1 of the Pragma Oracle consists of three smart contracts, that each play a role in making the oracle easy to use and robust.

The first is the Publisher Registry, which is the most static. This is designed to be updated extremely infrequently because its state should be permanent (each publisher and their address). This is currently an ownable contract but will become permissionless as Pragma decentralizes.

The second is the Oracle implementation and its proxy, which are also designed to be updated only as frequently as absolutely necessary. This is the contract which protocols use, and the one to which publishers publish. In the background, it coordinates the Publisher Registry and the Oracle contract implementation(s). The implementation contains the logic for storing and aggregating specific key/value data streams.

Aggregation

Capture-d-e-cran-2023-11-16-a-18-08-21

Our system incorporates multiple publishers, each responsible for providing data from various sources. To determine the price for a given source, we consider the prices submitted by all these publishers. Our approach involves conducting an initial on-chain aggregation based on the median of these prices. This median value then becomes the established price for that particular source.

This aggregation process is triggered when one of the aggregation functions, as outlined in the 'Consuming Data' section, is called. During this process, users have the flexibility to choose their preferred method of aggregation for the sources. This choice allows them to tailor the final price calculation according to their specific needs or criteria. By utilizing this method of aggregation, we enhance the security of the final price determination, making it less vulnerable to manipulation, as it incorporates a broad and balanced range of data from multiple publishers.

Security

Our contracts have thoroughly been peer-reviewed by multiple actors in the starknet ecosystem. They have also undergone a full audit by Nethermind which you can find the report here.

In case you find bugs in our contracts, we have a bug bounty program in place with ImmuneFi, or you can contact us directly at matthias@pragma.build

Deployed Contracts

On Starknet, the contracts are currently deployed at the following addresses:

ContractTestnet (Cairo 0)Testnet (Cairo 1)Mainnet (Cairo 0)Mainnet (Cairo 1)
Publisher RegistryTestnetSepoliaMainnetMainnet
OracleTestnetSepoliaMainnetMainnet

Pragma X

Pragma X is the V2 of the oracle, currently live only on testnet. If you want to learn more about its architecture, you can watch this or this, if you prefer to read, take a look at our Mirror.