tezos-checker / checker

An in-development "robocoin" system for the Tezos blockchain
24 stars 16 forks source link

Configurable oracle entrypoints #317

Open gkaracha opened 2 years ago

gkaracha commented 2 years ago

Currently Checker makes the following assumptions regarding the oracles:

  1. Index oracle
    • The oracle provides an entrypoint %getPrice of type (nat * nat) contract .
    • The fraction captures the price of X in TEZ (i.e., has units TEZ/X), where X stands for USD, or CHF, or some other currency.
  2. CFMM oracle
    • The oracle provides an entrypoint %getCfmmPrice of type (nat * nat) contract.
    • The fraction captures the price of T in C (i.e., has units C/T), where C stands for the collateral type and T stands for the on-chain token we are replicating.

Currently there is no standard regarding how should such entrypoints be named or what their type should be. Though we cannot easily allow the entrypoint types to be configured at build time, we certainly can (and probably should) choose the entrypoint names at build time, from the yaml configuration file. The above names are merely placeholders.

Relevant files (as of b572b25)

Sidenote: checker_tools/builder/templates/indexGetOracleEntrypoint.ml.jinja and checker_tools/builder/templates/tokenGetOracleEntrypoint.ml.jinja are already jinja templates, and util/mock_oracle.tz and util/mock_cfmm_oracle.tz can be generated at build time by calling ligo compile-contract, so we'd have to turn util/mock_oracle.mligo and util/mock_cfmm_oracle.mligo into jinja templates as well to accommodate the needed changes.