Weekly Report 2021/08/15

We build on top of the Cardano blockchain at MELD, so improving the platform is one of our priorities. This weekly report gives some insights into our contribution to the Cardano ecosystem and the progress of our internal projects.

Plutus

Documentation

We have been spending a good amount of effort to help update Plutus documentation, which is usually out of date due to lightning development progress. One can never get enough good documentation. The whole community needs this!

This past week we continued to work on some documentation:

This week includes:

  • In code: update forge-related terms in PureScript code.
  • Proofread the Extended UTXO Ledger Model paper.
  • Track differences between the EUTXO specs & the latest code base. Ready to update the former.
  • Write a bit more on the EUTXO model.
  • On-going proposals:
    • Unify the terms “currency id” & “currency symbol”?
    • Proofread the remaining papers.
    • Proofread and continue to write each module’s README.
    • Write more about PAB, write a dedicated document for it (critical to any dApp work).
    • Write more about the compilation pipeline & evaluators, write a dedicated document for them (critical to Hachi work).

Alonzo Purple dependencies

We’ve updated Plutus’s Cardano dependencies to Alonzo Purple:

This work includes:

  • Bump Cardano dependencies to Alonzo Purple.
  • Update stack setup (Still clunky, to be honest, but probably not a priority).
  • default.nix: Fix outdated PAB exes that block nix build.
  • Remove era from TxBodyError.
  • Set txScriptValidity to TxScriptValidityNone (under unused) in toCardanoTxBody for now. This defaults to ScriptValid, meaning all transactions cannot include scripts that fail validation, which can be configurable later on by adding an extra field to Tx.

For further references, see related commits:

A nice curry on top

We’ve also added curry & uncurry to PlutusTx.Prelude:

We’ve been expanding HLint to support Plutus (Hachi Lint) and found the lack of these functions. We hope this addition will be helpful in general!

Cardano core

Cardano code base is moving extremely fast! We frequently test our projects with the latest updates to help evaluate and fix breaking changes simultaneously.

Below is our latest work there:

The Cardano Node one includes:

  • Bump cardano-ledger-specs to reflect these changes:
    • UnRedeemableScripts to MissingRedeemers.
    • WitnessPPDataHash to ScriptIntegrityHash.
    • Self-construct defaultCostModel, which was deprecated.
  • Bump cardano-base accordingly for Blake2bPrefix.
  • Bump plutus accordingly for BuiltinByteString.
  • Bump ouroboros-network accordingly to be compatible with cardano-ledger-specs.

The rest are some Plutus and Ledger Specs updates. For further references, see related commits:

Haskell ecosystem

We’ve been talking to the Haskell Foundation! The plan is to become a sponsor and contributor to the Foundation and the whole ecosystem in general. Contributions should include open-source development that is key to MELD, Cardano, and Haskell. Also, educational efforts to guide more people into this wonderland. Our development team has been training Vietnamese Haskell engineers for 3 years. It’s time to join the bigger conversations now!

More concretely, we want to contribute to the following projects:

  • Tools that benefit Cardano/Haskell development like HLint/Hachi Lint and HLS.
  • Work that benefits the compilation pipeline from Haskell to Untyped Plutus Core.
  • GHC: Improve compilation speed, runtime performance, and resource usage.
  • Refactor GHC to reduce complexity, to help make GHC thrive for the many years to come.
  • Improve educational resources to make it easier for newcomers to learn especially.

Errors as (structured) values

This is a very useful body of work! We want to join hands because there are newcomer-friendly tasks for us to get familiar with GHC work. We can then help integrate this new diagnostic infrastructure to HLS and HLint to meet our goals and extend our experience.

Our first GHC PR that addresses ghc#20118:

The starting point is to convert diagnostics in GHC.Tc.Validity to proper TcRnMessage (Typecheck & Rename messages). We’ve completed:

  • TcRnTupleConstraintInst is an error that occurs whenever an instance for a tuple constraint is specified.
  • TcRnInstArityMismatch whenever the arity of the instance head doesn’t match its type’s.
  • TcRnAbstractClassInst whenever an instance of an abstract class is specified.
  • TcRnNoClassInstHead whenever an instance head is not headed by a class.

We hope to complete the rest in the upcoming week.

More references:

HLint

We continue to study and contribute to HLint, which is critical to the development of Hachi Lint.

This week’s pull requests:

These include:

  • When NumericUnderscores is on, suggest underscores with a chunk size of 3 for decimal literals and 4 for non-decimal literals.
  • Trim irrelevant parts in the hint output.

MELD team will keep on expanding our R&D within the Cardano & Haskell ecosystem. More updates on this area will follow soon. Stay tuned!

Hachi

MELD Announces Hachi!

Hachi is our effort to develop a suite of security analysis tools for Plutus smart contracts. This project will be open-sourced to the public eventually. For now, we focus on research and experiments on Cardano to better understand how to have the best approach for each problem.

Here is a quick summary of what we have done this week:

  • Continue smart contract security research. Refine and write many more proposals.
  • Review many more smart contract security issues on Ethereum.
  • Write and review more contracts with vulnerabilities on Cardano.
  • Have a clearer direction to develop Hachi Lint.
  • Port Plutus Core built-in functions to Racket. More work to flatten Untyped Plutus Core closures.
  • Continue tooling work for the compilation pipeline from Haskell to Untyped Plutus Core.
  • Prototype the first symbolic execution for (non-Turing complete) Untyped Plutus Core.

Even though most work is still highly experimental, we may be able to start demoing things from next week. Stay tuned for more!

ADAmatic

MELD and VENT Present ADAmatic!

We continue to work on the architecture and specifications of the bridge. With a lot more case studies:

  • Feed ChainLink data from Polygon to Cardano smart contracts.
  • Connect the MELDed Assets service to RenVM on Polygon for trustless custodial BTC, and a lot more.
  • Cross-chain swaps with SushiSwap through the bridge.

For the first two cases, we also study the requirements for building native integration on Cardano. Since both ChainLink and RenVM are interoperable by design!

We’ve also been talking around to bring more builders to the project. Not just to have more people who build, more parties to run the ADAmatic nodes, but to also brainstorm together for more integration ideas. After all ADAmatic is for the community and by the community.

MELD

MELD.com

mFiat

  • Keep dependencies up to date. Quickly handle breaking changes.
  • Complete the specifications for the first two production iterations.
  • Implement those two iterations, ready for internal review and audit.
  • Torture the contracts to find security issues. Fix the found ones.
  • Improve PAB setup.
  • Write test cases to demo the following to private investors (after NDA):
    • Oracle, CDP & Stability Pool (for liquidation) setup.
    • Oracle updates asset prices.
    • Other users fail to update asset prices.
    • Open a new CDP to mint mUSD.
    • Can’t open a new CDP that doesn’t satisfy the minimal collateral ratio.
    • Deposit and withdraw collateral against the CDP.
    • Can’t withdraw too much collateral that violate the minimal collateral ratio.
    • Mint and burn mUSD against the CDP.
    • Can’t mint too many new tokens that violate the minimal collateral ratio.
    • Can’t burn more than the minted amount.
    • Provide mUSD to the stability pool.
    • Withdraw mUSD from the stability pool.
    • Can’t withdraw more mUSD than the provided amount from the stability pool.
    • Can’t liquidate a healthy CDP.
    • Liquidate an under-collateralized CDP.

At the moment, we’re completing reviewing and auditing the first two iterations. We expect to have 2-3 more iterations before being mainnet-ready. One of them includes delegation of collateralized ADA!

Lending & Borrowing

  • Keep dependencies up to date. Quickly handle breaking changes.
  • Complete the specifications for the first production iteration.
  • Implement that iteration, ready for internal review and audit.
  • Write test cases to demo the following to private investors (after NDA):
    • Lending pool setup.
    • Lenders can lend mUSD to the lending pool.
    • Lenders can withdraw mUSD from the lending pool.
    • Lenders can’t withdraw more mUSD than the provided amount plus interest from the lending pool.
    • Borrowers can deposit ADA as collateral to borrow mUSD.
    • Borrowers can’t open a new CDP that doesn’t satisfy the minimal collateral ratio.
    • Borrowers can’t borrow when the lending pool doesn’t have enough funds.
    • Borrowers can deposit and withdraw collateral against their CDP.
    • Borrowers can’t withdraw too much collateral that violates the minimal collateral ratio.
    • Borrowers can’t borrow more from the CDP, as long as the minimal collateral ratio is maintained.
    • Borrowers can repay their loan with interest to get back their collateral.

With the Oracle and Liquidation systems currently “borrowed” from mFiat. We also have many more test cases for negative values and edge cases like that, but listing all of them is probably not a good idea.

This lending & borrowing infrastructure should take many more iterations to be mainnet-ready. It has more agents and interactions than mFiat, and we want it to be secure and efficient since day one in production.

Hopefully, the project overview last week and the actions overview this week are enough to introduce these two components. Let’s look forward to being more technical and involved from next week!

Tokenomics & Economics

  • Collect more data to analyze.
  • More tokenomics research in general. Focus on token utility and its relation to price.
  • Refine more parameters for the whole economics model.
  • More Market Cap and TVL work for a better price discovery function.
  • Refine token release schedule. Start work to fix the erroneous graphs in the White Paper.
  • Forecast protocol usage and traffic to estimate treasury release schedule, protocol fees, insurance solvency, staking APY, and more.
  • More performance metrics work to evaluate each model iteration.
  • Start thinking about algorithmic collateral ratio.

Our biggest problem at the moment is the lack of data to analyze. Especially on Cardano, where concrete on-chain contract fees and liquidity/trading volumes haven’t been captured. The focus now is to complete the frame of the economics model, build a solid simulator then hardcore data collection and analysis. Then keep iterating to improve the model.

Tokenomics overview has been covered in the White Paper, so we go straight into progress in this first report. We’ve been picking up speed and talking to many awesome Quants lately. We’ll have separate economics reports and articles when things get stable enough, and hopefully many economics Yellow Papers too!

MELDApp

We’ve been making good progress with the ISPO dashboard and MELDApp. The Croatian team has been overloaded with work to meet the tight roadmap, so we don’t want to trouble them. We’ll gradually introduce their updates later on. We’ve only included tokenomics & economics work and gone a bit further into core work this week anyway.

The plan for the MELDApp is still to do public beta testing this quarter and release the first production version next quarter.