Skip to content

Grant Proposal: Stablecoin in Web3 & Sustainability 2022

Notifications You must be signed in to change notification settings

rafapolo/celohuobihack

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 

Repository files navigation

logo

VERAΞFIKO

Celo x Huobi: Stablecoin in Web3 & Sustainability 2022

In Esperanto, Vera Efico means Real Impact.

Description

In one line, we collect cMCO2 while providing a private fiat ↠ crypto bridge for brazilians.

This project proposes a noble usage for the Celo stablecoin pegged to the brazilian official R$ Real currency: an innovative system enabling the 1.3 billion bank accounts in the country to acquire tokens and multi-chain cryptocurrencies at Huobi Exchange from their own bank accounts in a more private way. Taking advantage of the new Brazilian Central Bank protocol for instant payment, PIX, we convert a Fiat transfer into 1:1 Celo Real, tradable for the +500 tokens and cryptocurrencies at Huobi - whose market data is published into IPFS and accessed through our dApp. Bridging it, we collect an experimental market-maker fee, directly distributed into impactMarket's poverty alleviation mechanisms, and our own cMCO2 token vault - managed by the DAO proposals focused on protecting Brazilian lands.

Context

  • Brazil is the sixth most populated country in the world. Home to roughly 214 million people today, it accounts for almost half of South America’s inhabitants. By 2023 we might have our own CBDCs.
  • Over 60% of Brazil’s population fall under the millennial or Gen Z bracket, with youths aged 15–24 accounting for more than ⅓ of the total population.
  • According to an Harvard Business School case-study, “in December 2018 the interest rate in Brazil for corporate loans was 52.3%, for consumer loans it was 120.0% and for credit card indebtedness it was 272.42%". DeFi might change this scenario.
  • Of the whole population, around 70% have regular Internet access and own a smartphone. There are more phones than people.
  • For now, we have creative friends earning the brazilian minimum wage of $0.95 per hour (R$1200/month ~ $230), while official statistics shows that half of Brazilian workers receives even less.
  • In their blind thirst for profit, some big investment firms providing crypto are also linked with Amazon-deforestation ventures. In the last 30 years, rainforests equivalent to Spain's territory size was devastated.
  • More than 20 percent of the world oxygen is produced in the Amazon Rainforest, still home of more than 300 original tribes, and with 40% of its territories under non-protective Brazilian policies.

Problem(s)

With open eyes, Latin America is full of problems - specially on public governance and the local usage of resources - which Celo technologies opens new paradigms on decentralized coordination to better deal with. While it is important to see problems holistically, we need to be analytic to propose small iterative steps to pedagogically achieve solutions together. Let's describe a few stories around us, as inspirations for a smaller generalized problem to tackle;

  • For years we interact on a Telegram group with 40 thousand brazilians supporting each other on buying cryptocurrency out of centralized exchanges, discussing projects, micro-investing, doing risky p2p and announcing all sort of demands involving the cryptoeconomy.
  • Many people get really lost on the Exchanges bureaucracies requirements and with frustrated UX navigation, when they just need a token to join a game, vote on a DAO, invest as some trusted friends suggests, or just to PoolTogether. Most users are digging opportunities on profitable trends.
  • Many people don't trust the Fiat<>Crypto centralized Companies regarding the way they might monitor wallets, or don't want to make these few founders richer.
  • Cryptocurrencies on some p2p platforms can be up to 20% more expensive than on CEX.
  • Lots of confusions with order books, liquidity, and complex miners + withdraw fees arithmetic, plus the fear we hear around declaring it for taxation.
  • Most friends-of-friends mediation solutions (as we have done some times) requires some hours-before R$ Real/BRL deposit and a later conversion and transfer with a variable price. The new Brazilian payment protocol changes that.
  • Many people just want a non-custodian fast service: Choose -> Pay in R$ -> and Receive the cryptocurrency or token in their own private wallet.

For this Hackaton, we are experimenting with a 3-pillars system provided to the group above, re-routing a tiny part of this new decentralized financial flows into real impact beyond crypto per se.

Vision

When coinage was first introduced into the Greek world in the 7th century BC, it was not seen as an economic instrument so much as a magical charm, "a talisman that could at will transform itself into any desirable or desired object." Today, 2800 years later, the notion that money is a tool to satisfy the individual's unlimited desires is still dominant. We hope to bring it more collectively-purposeful in the 2800 years ahead.

As we write, the largest national crypto CEX in Brazil, with more than 1.5 million users, had a 24h trading volume of $4,345,824 from small investors. Basic maths shows us that every day, their users spend the equivalent to a minimum-wage paid to 300 people for one year, or hypothetically, beyond the pure individual speculation, this one-day crypto-flow of small investors could fund 20 people with spectacular skills together for two year to research and build real impact projects. Even a fraction of this crypto-exchanges flows could become relevant investments for Open Universities or ReFi Hacklabs.

There is money! But the ways it is operated today makes it extremely concentrated in networks far from the urgent social and environmental needs. We are Celo Maximalists, in the sense of believing that there are beautiful ways to understand wealth and spread prosperity, as the new programmable monetary paradigm creates new economic models. We believe it is a question of exemplar collective organization and distributed awareness, potentially enabled by blockchain concepts, removing the barriers for better cooperation among financially-aware self-managed collectives.

Changing time, we remember that some technologies can be revolutionary, as when on the 12th century Fibonacci published about the Hindu-Arabic numeral system, bringing light to the works of the 9th century mathematicians Al-Khwārizmī - "Algorithm" comes from his name - who translated older Sanskrit texts from the 5th century Hindu mathematician Aryabhata, who, one thousand years before the colonization of America, calculated Earth's circumference with an accuracy of 0.3% without clocks or telescopes, just using his own methods and numeric system based on phonetics. For more than one thousand years Europeans used Roman numerals, a non-decimal system making daily arithmetic almost impossible. Can you imaginable it in use today? In plain MMXXII. Obsolete, the Statistics Foundations came 5 centuries after the Hindu-Arabic numeral were introduced to Europeans, so, understanding our chances we could finally navigate into better luck.

The full way around in non-linear hypertextual history, some researchers says the english word cash came from the Sanskrit unit of measure, Karṣa (कर्ष). In between, it was just in the the 13th century that Marco Polo described in his book of travels the surprising fiat money of the Yuan Dynasty; "these pieces of paper are issued with as much solemnity and authority as if they were of pure gold or silver...and indeed everybody takes them readily".

Back them, a paper carrying the same value as gold could be equally hard to explain and believe as some of us today describing algorithms running on computers around the globe, acting as distributed treasures potentially operated by many keys - text files carrying secrets that can unlock an increasing wealth of carbon-markets tokens, economically designed on principles of ecological Karma. Beyond gold; virtual units with values sealed by divine Mathematicians's laws, crypt'okens tradable for real properties in sacred places. When it doesn't sound mystical, for most of us, it is difficult to fully comprehend how it is possible - if some trees wood's fiber could become valuable paper-money tokenizing gold, now distributed programmed algorithms can store intangible natural and cultural values in itself.

Information Technologies, as language tools, allow us to shape not just the future, but doing so by changing past methods and visions still reverberating on us now. Opening the unimaginable, as when electric light turned on in the night of the first houses just 140 years ago, we believe humanity can project itself with poverty and deforestation as obsolete as smallpox. Remembered in history. Willing so was the first step into all conquers, and working on the reinvention of money's narrative and redistribution is a challenging inspiration for better times where collective actions can reinvent and perform new modes of distributed care.

Tech & Architecture

Coming from decades on web2 engineering, to experiment with web3 protocols and frameworks is an exciting challenge, breaking the traditional closed clients-servers paradigm into an open decentralized computing system. While we missed to have integrated tests, we achieved a high-level system architecture without servers, load balancers or databases working as a hybrid-exchange, bridging a Fiat currency paired with it's equivalent stablecoin into other tokens and chains. With so many open-sourced DAOs and dApps, we decided to focus on the most innovative part of the system, The Agent, a from-scratch software written in Ruby connected to a local Celo Full Node and IPFS, mediating the on/off chain exchanges. Our framework also grasps the potential to evolve as a hybrid payment solution.

The ミ tree pillars of our prototyped system,

  1. ミ The MOΞDAO - smart contracts
  • moeda is the portuguese world for coin; a moedão is a big one.
  • coordinate the proposals for the shared cMCO2 vault usage
  • a simple DAO fork base, compiled with Truffle
  • HybridEx, our initial Contract managing on-chain orders
  1. ミ The dApp - a distributed progressive frontend
  • accessible through IPFS
  • no tracking, cookies or analytics
  • connects users to their Celo wallets
  • validate & convert R$ to cR$ through Moedax on-ramp provider
  • reads the contract's oracle providing current Huobi metadata
  • stores a new Order on the contract
  • todo: validate provider's metadata signature to avoid potential price-manipulations
  1. ミ The Agent - an on/off-chain smart-node proposal
  • detecting and converting cReal incomes
  • bridging Huobi Exchange metadata on IPNS
  • executing on-chain Orders off-chain
  • managing transactions and finances
  • donating half of the collected fees
  • converting cReal fees into cMCO2
  • prompting the accessible distributed data,



                            # ==============================
                            # Agent VERAΞFIKO v0.1
                            # ==============================
                            # Huobi Account 40337003
                            # ==============================
                            # spot balance:
                            # CELO 28.75
                            # cUSD 138.15 (liquidity)
                            # ==============================
                            # last CELO buy at $0.8637 cUSD
                            # ==============================
                            # {"id"=>468375750,
                            #  "low"=>0.8405,
                            #  "high"=>0.9599,
                            #  "open"=>0.8629,
                            #  "close"=>0.8658,
                            #  "vol"=>96570.47165076,
                            #  "amount"=>107133.24710231682,
                            #  "version"=>468375750,
                            #  "count"=>2083}
                            # ==============================
                            # wss:// reading Huobi markets...
                            # ==============================
                            # ipfs:// publishing changes ...
                            # ==============================
                            # celo:// new income transfer!
                            # ==============================
                            # Order#2481 executed!
                            # ==============================
                            # $ Celo.exchangeRealValues()
                            #    => USD: 4.786 
                            #    => EUR: 5.33 
                            #    => REAL: 1.0
                            # $ _

Modeled as,

  classDiagram
      Agent -- Huobi
      Agent -- Celo
      Agent -- Web3Utils
      Agent --> Contract
      class dApp{
          + cMCO2_balance
          + available_liquidity
          - list_huobi_tokens()
          - list_history()
          - validate_user()
          - acquire_cReal()
          - acquire_token()
      }
      dApp --> Contract
      class Huobi{
        + marketmaker_fee 
        + tradable_tokens
        + celo_balance
        + cusd_balance
        - create_order("*cusd", amount)
        - order_status(id)
        - execute_witdraw(token, to)
        - withdraw_status(id)
        - last_tokens_prices()
        - send_celo_fees_to_vault()
      }
      class Celo{
          + cMCO2_balance
          + CELO_balance
          + cReal_balance
          - call celo-cli()
          - swap(celo<>cReal)
          - transfer_celo_to_huobi()
          - refundTxt()
          - generate_cMCO2_from_fees()
      }
      class Web3Utils{
        + contract_address
        + ipns_metadata_path
        - deploy_contract()
        - monitor_events()
        - decode_txt_data()
        - publish_json_metadata()
        - todo: generate_pix_contract()
      }
      class Agent{
        + summary      
        - print_local_balances()
        - print_huobi_balances()
        - print_last_celo_tick()
        - generate_tokens_metadata()
      }
      Contract --> Order
      class Contract{
          - owner
          - ipns_metadata_path
          - post_order()
      }
        class Order {
          - string token
          - string to_addr
          - string chain
          - uint cbrl_amount 
        }

Loading

In a nutshell,

The Smart Node Agent has a contract deployed on the Celo network with an IPNS path string. This path is used by the dApp as a decentralized oracle providing updated information on our preprocessed Huobi market data. This contract also stores on-chain orders. Though it operates by itself, the Agent can call Mento stability mechanism for conversions and transfers, and it also integrates the Huobi API - executing centralized orders and withdraws.

The Agent should be kept awake, constantly checking new cReal deposits and reading Huobi websockets market ticks for the pairs potentially tradable for Celo Reais on our own mechanism. For each price_change event, the prices+fees are calculated as cR$ Real and published through IPNS on a distributed metadata.json

The Interplanetary File System protocol is extended with the proposed IPNS Name System, solving the problem of a distributed file having a distinct address on each update, unable to have a unique URL for the updated file. We encode the ipns:// path on the smart contract, enabling the dApp to read an always-updated version of the metadata.json provided off-chain by the Agent.

On the dApp side, once a Wallet is plugged, the +500 tokens prices encoded on the metadata are listed to be exchanged with cR$. We integrated a cReal on-ramp as an external solution, where some basic KYC is validated and the user proofs the ownership of his/her bank account, following local compliance and also protecting the provider, Moedax. Then, a conversion Real 1:1 cReal happens with a single generated PIX QrCode paid on any national mobile banking.

Now, jumping in, let's suppose someone with the connected wallet wants to buy a token with cReal on our decentralized approach. The dApp verifies the user's balance and - calling the contract - posts a new on-chain Order encoding his wish. A further cReal transfer with this order_id encoded, having this order's price, pays the conversion service. All transfers without an encoded order_id are considered donations.

The Agent owns the contract and the local Celo wallets, when it receives a transfer it checks the encoded data, validates it and orchestrate the few conversions from cReal to the desired token at Huobi. Afterall, it withdraws the token from the Exchange to the user's provided wallet and updates the contract:order status, or refunds the user's cReal - if fails for lack of liquidity, suddenly-higher slippages or was paid too late.

Every night, half of the collected Celo-Huobi bridging service fees are converted into cMCO2 and sent to MOΞDAO's vault.


Scenarios and co-sequences,

  sequenceDiagram
    actor Soul
    Soul-->>dApp: connect wallet
    loop
    Agent-->Huobi: listening markets data
    Agent-->>Agent: publish tokens metadata on ipfs
    dApp-->>Contract: get ipns metadata path
    end
    loop
      dApp-->>dApp: decode ipfs://metadata
      dApp-->>Soul: list tokens and cR$ prices
    end
    alt fiat 1:1 stablecoin
      Soul-->>dApp: top-up
      dApp-->>dApp: on-ramp provider integration
      dApp->>Soul: cReal 
    end
    alt acquire token
      Soul-->>dApp: order(token, chain, amount)
      dApp-->>Contract: post_order()
      dApp-->>Soul: QrCode for cReal
      Soul->>Agent: cReal
    end
    loop new_orders?
      Agent-->>Agent: event: income transaction's with an order_id
      Agent-->>Contract: read Order data
      Agent-->>Agent: execute_order, if valid
    end

    par execute_order
      Agent-->>Huobi: execute order
      Huobi->>Huobi: cusd-usdt
      Huobi->>Huobi: usdt-token
      Agent-->>Huobi: execute withdraw
      Huobi->>Soul: token
      Agent-->>Soul: refund cReal, if fails
      Agent-->>Contract: update statuses      
    end
    par rebalance_liquidity
    Agent->>Agent: cReal -> Celo
    Agent->>Huobi: Celo - fees
    Huobi->>Huobi: celo-cusd
    end
    loop midnight
    Agent-->>Agent: half fees to ImpactMarket
    Agent-->>Agent: half into our cMCO2
    end
Loading

Screenshot

The dApp reads the IPFS metadata with updated market data and stores on-chain orders.

screenshot

Team

Rafael Polo is a 37' Brazilian-Portuguese Computer Scientist from Rio de Janeiro with a Master in Information Systems and a Greek heart, experimenting with artificial and natural languages for the last 20 years. Worked as a Web2 Software Engineer in Berlin and co-created a Computer Lab in Athens, where volunteered as a teacher to on-the-edge communities for 4 years. In 2021 moved to Lisbon, when was graced by a Celo Community Fund to build Moedax, a Fiat to Celo Real on-ramp provider. As of 2022 crypto-crash, he is open for a job position or a new funded project challenge.

While I took a solo flight writing VERAΞFICO, "we" came from the conversations with many amazing people echoing around us, who would love to get funded as a team to build tools for the concepts we speculate so much about, bridging crypto to the masses in more enriching ways.

Links


VERAΞFIKO: Very Exotic Real Apparatus Ξ from Interplanetary Comrades Online

Aparato v0.1 - the totality of means by which a designated function is performed or a specific task executed, as in a system of government.

ni celas realan efikon // we target real impact // visamos impacto real // wir zielen auf echte wirkung ab // στοχεύουμε σε πραγματικό αντίκτυπο

Rafael Polo, June MMXXII