Apprecio.Finance - Decentralized On-Chain Inflation Dashboard (v0.2)
November 20th, 2021

Public team members: @haycarlitos, @espejelomar.

Abstract: (AF)

AF is a decentralized inflation dashboard powered by IPFS, Filecoin, and Chainlink. Its main objective is to resist censorship and provide an alternative to centralized measures such as those that come from Central Banks and national statistical agencies. AF implements decentralization at three different times in its design. (1) The price data are obtained from more than 1,000 different sources (in the Mexican case), independent of the government, which prevents the failure or manipulation of any source from significantly affecting the inflation calculation. (2) Data is automatically stored off-chain using the Interplanetary File System (IPFS), for data to be distributed across multiple off-chain nodes, and Filecoin, for data permanence and availability at any moment. (3) Aggregate prices and inflation rate are stored on-chain, Kovan testnet for AF v0.2, using Chainlink. The last two steps would also allow the data to be cryptographically signed twice.

Disclaimer and AF’s Current State

AF v0.2 is a work in progress. It was inspired by (1) the 1729 Newsletter call to create an inflation board and (2) the Chainklink Fall 2021 Hackathon. The data was obtained mainly through laborious but important grassroots work to collect in a decentralized manner the prices of items from small suppliers through the Mexican fintech Apprecio web and mobile applications. More data was obtained by scrapping medium and large providers. This makes AF as decentralized as possible. However, there is still work to be done to obtain more and enough price data from the last months.

The inflation rate and the aggregate prices obtained by AF are not definitive and are not comparable to the official rate provided by the Mexican government.

AF plans to continue this work step by step due to the importance of the task.

Introduction: Whoever Causes the Problem Cannot Be Trusted to Measure it

Inspiration for AF came from August 5, 2021, 1729 Newsletter, sponsored by Bajali Srinivasan (@balajis):

“Inflation is a monetary phenomenon, a function of money printing. But it is also in part a social phenomenon, a function of mass psychology. If enough of the right people believe that inflation is going to happen, it will. As such, when inflation is happening, there is often a push to censor discussion of inflation itself, under the grounds that discussing the problem actually causes it in the first place. That is exactly what happened in Argentina and Venezuela over the last decade […] And that is why the world needs a global, decentralized, censorship-resistant inflation dashboard.

Why do we need an inflation dashboard? Because trillions of dollars have been printed over the last year – and it's not just dollars. Many countries besides the US have been printing fiat like mad to fund the response to COVID. Figures that shocked and stunned ten years ago ($787B for the bailout!) no longer warrant a headline today, though they may well result in headlines tomorrow.

If inflation is a government-caused problem, we can't necessarily rely on government statistics like the CPI to diagnose it or remediate it. Indeed, in places with high inflation, censorship and denial is the rule rather than the exception.”

As of November 2021, AF is implemented only for Mexico, which faces its biggest inflationary crisis in 20 years with an annual inflation rate of almost 7% (Forbes, November 2021). However, there are plans to extend the data sources to the United States and Brazil in the coming months.

Source: Made using INEGI data.
Source: Made using INEGI data.

AF Design

To achieve the highest possible resistance to censorship, AF implements decentralization at three different times in its design. The following figure captures them.

Decentralization at three stages.
Decentralization at three stages.

Data Recollection

This step is crucial to maintain decentralization. If manipulation of the data source by a third party can significantly alter AF's inflation rate measurement, then the objective of censorship resistance would be compromised.

Thus, for the Mexican case, our first measure, the data are obtained from two different types of sources.

  1. Small sellers. Through the Apprecio web and mobile applications.
  2. Medium and large sellers. Through web scrapping of online stores.

Data Recollection: Small vendors (tienditas, in Spanish)

AF is unique in that it takes advantage of a data source such as that from small vendors.

In Latin America, these sellers are frequent. Around 700 thousand tienditas exist in Mexico and generate 1% of GDP. Not taking this data source into account would greatly skew the inflation estimate. However, obtaining data from these sources is a grassroots activity. There is no database that tracks prices in these relevant units.

We take advantage of the work of the Mexican Apprecio fintech with more than 8 thousand small vendors as clients throughout the Mexican Republic. Among other financial and strategic services, Apprecio helps small suppliers to calculate the ideal prices for their products. To do this, they require units to charge the prices at which they offer their products. AF then uses these data to calculate inflation. homepage homepage

This source is decentralized. The data, for November 2021, comes from at least 1,000 different units and the number is growing. The fact that a unit does not report accurate data would not affect the general median price of the good and therefore any calculations made with the prices.

Data Recollection: Medium to Big Vendors

Prices from Walmart, La Comer, and Soriana are included to further decentralize data sources. AF scrapes their online stores. For Mexico, it is planned to include at least two additional sources: Costco and Sam's Club.

These sources provide the assurance of the constant presence of at least one price during any period. The main challenge comes from maintaining scrappers that can repeatedly beat the web pages. The 1729 Newsletter mentions several issues related to reliance on scrappers for pricing data, including dealing with automated countermeasures, maintaining the web crawler, and analyzing hard-to-determine units. AF met these problems successfully.

As the same 1729 publication proposes, the next step would be a strategic alliance with Oxxo to access its huge set of price data. Oxxo has a 50% share of the convenience store market and 14 million Mexicans buy something every day (for more information, see Packy McCormick's publication "FEMSA: The Most Interesting Company in Mexico". Screenshot below.). This would imply the challenge of providing incentives to one of the largest corporations in Latin America.

Extract from the ''‘FEMSA: The Most Interesting Company in Mexico" post by Packy McCormick.
Extract from the ''‘FEMSA: The Most Interesting Company in Mexico" post by Packy McCormick.

Decentralized storage off-chain

For AF to be a successful tool for openly measuring inflation, it must be available for audit (1) at any time and (2) as cheaply as possible.

Storage has at least two requirements for AF:

  1. Raw price data must be auditable. Currently, raw data storage is done off-chain due to gas prices. Possibly, the next step would be for AF to move to an Ethereum L2 and be able to store raw data on the chain.
  2. The data must be stored in a decentralized way. A central server means the consolidation of control over the data. Even off the chain, due to point 1, this should be achieved.

AF achieves both requirements by storing raw price data off-chain using IFPS. The entire price data set is divided into smaller chunks, cryptographic hashed, and assigned a unique fingerprint called a Content Identifier (CID). The dataset would be stored on at least one node, a local server anywhere in the world. By using the CID, other nodes can request the data and will cache the data themselves locally. This would increase the decentralization of the data set off the chain.

The data must always be online and available for direct request.

“While IPFS guarantees that any content on the network is discoverable, it doesn't guarantee that any content is persistently available. This is where Filecoin comes in […] a decentralized storage network in which storage providers rent their storage space to clients.” (IPFS documentation).

AF uses Filecoin so that price data is always available while maintaining its decentralization. The dataset would be anchored in at least one node.

The Web3.Storage solution enables AF (1) to automatically store the dataset in IPFS and back it up with Filecoin; and (2) replicate pricing data across a network of storage providers and verify its integrity.

This solution allows data to be persistent, available, and decentralized even off-chain. The next layer of decentralization will come from making the data available on-chain.

On-Chain Storage and Availability

Raw off-chain data of available sources are aggregated to obtain the median value of the prices for a determined period of time, leading to a single price per item that must be taken into account in the inflation calculation. AF calculates inflation off-chain using the function in AF's GitHub repository. The calculation is done off-chain to save gas. However, the next step is to allow any user to request an on-chain calculation.

AF v0.2 uses Chainlink to bring off-chain data to the Kovan testnet. The next step would be to run a node directly on the Ethereum Mainnet to add an additional layer of decentralization. Chainlink is a decentralized Oracle network that cryptographically signs and delivers data on-chain. Currently, any user can request (1) the current inflation rate; and (2) the aggregate prices of each of the items in the inflation calculation.

Inflation Calculation

Inflation calculation and data recollection is

The Future of AF

Three main points appear on the AF roadmap:

  1. Coverage extended to new countries. The next would be the United States and Brazil. Requests from other economies are appreciated.
  2. Possible migration to full on-chain storage. With the development of new Ethereum L2 rollups like Starknet, it's cheaper than ever to chain data. This would allow users to request and integrate AF data into their smart contracts inexpensively.
  3. Adding new data sources. The more good quality data sources AF uses, the more decentralized and secure the inflation rate will be. In Mexico, AF is already implementing data from small suppliers (tienditas) and retailers
Arweave TX
Ethereum Address
Content Digest