Modeling & Simulating Bonding Curves

This piece shares our open source library to model and simulate Bonding Curves and discusses our methodology.

In the rapidly evolving world of crypto-economics, Bonding Curves have risen as vital components for crafting robust digital economies.  Our mission at the Bonding Curve Research Group (BCRG), is to pioneer in-depth research, practical applications, and empirical analysis of bonding curves. We aim to contribute to the data and knowledge commons of these crypto-economic primitives, so that the full disruptive potential of bonding curves may be utilized by the emerging generation of token engineers and web3 entrepreneurs.

The Unexplored Potential of Bonding Curves

Bonding Curves are an integral component of the DeFi ecosystem. They are used frequently by nearly every web3 and crypto enthusiast. Uniswap, Balancer, Curve, Sushiswap, Pancakeswap, all leverage bonding curves in their core infrastructure to facilitate trading. Other Web3 projects like the TEC, DIA DAO, Molecule, Truebit, or Aavegotchi have used bonding curves as an issuance and redemption mechanism for their digital economy.

Bonding curves allow us to mathematically describe the relationships between different assets, thus creating novel value & exchange systems. They allow us to impose constraints on the configuration space of exchange and inflation, on growth and decay, on price and supply, to name a few. Despite their broad use through the crypto ecosystem our understanding of bonding curves remains superficial. We at the BCRG have taken a data science approach to unravel the potential of these crypto economic primitives. To dive deeper into their empirical analysis, we’ve created data loading tools and interactive visualization models in python. We are excited to share with you our open source github library and methodology for simulating bonding curves in this article.

Introducing the Conding Burves Library

The conding library is an open source python library that the BCRG is launching as a schelling point for token engineers who are interested in modeling, simulation, and analysis of bonding curves. The library offers two primary functions, easy data loading from dune dashboards for analyzing existing bonding curves deployed on chain, and a collection of bonding curve models that offer interactive parameterization and visualization dashboards for exploring the full design space of bonding curves. These two components, data loading, and modeling, can be combined to perform powerful analysis and stress testing on economic units as well as modular compositions of tokenized ecosystems of bonding curves.

/* How to install the coding library in your python environment. */

Pip install conding

Conding Case Study #1 TEC ABC

To embark on this analysis, we first needed to dissect the blockchain data, a daunting task considering the inherently challenging parsing structure of blockchains. Fortunately, on-chain analytics firms have emerged to assist in discerning the hidden insights on-chain.

The TEC was chosen due to its early support of the BCRG, helping to lay our foundation. Moreover, they pioneered the innovative Augmented Bonding Curve (ABC) , which we consider a Primary Automatic Market Maker (PAMM). It creates an automated market for a new token with dynamic supply by linking mints and burns of the token to user deposits or withdrawals of a reserve asset.

Take that Data for a Walk

Interrogating blockchain data isn't a walk in the park, but thankfully, DApps like Dune Analytics and The Graph Protocol come to our rescue, offering handy ways to query blockchain data.  For our analysis, we leaned heavily on Dune Analytics. Our SQL wizard had created an insightful dashboard of queries for the TEC, hitting the mark on many data points of interest to us.

While we would love to paint this as a smooth sail, the reality is that event data from smart contracts are often not directly posted on-chain. Hence, our SQL maestro had to perform a few tricks to construct the tables we needed.

One lesson we’ve learned already that we’d like to pass along to Bonding Curve developers: analytics is much easier when you post event data on-chain for your bonding curves, rather than having it occur internally to the smart contract. Events will streamline the process of reading and analyzing your bonding curve data in the future!

With our Dune queries prepared, we created a data wrapper that allowed us to pull the Dune data into a Python object. This simplified the process of feeding the data into our Python Bonding Curve model of the ABC, which can be found in our GitHub Repository.

/* Example of importing our Dune Dashboard into our python environment. */

From conding.dune.tec import TECDashboard

tec = TECDashboard()
tec.market_information.holders_distribution()

Python Panel for Interactive Parameterization and Visualization

We utilize an emerging python data science tool chain based on the holoviz ecosystem to create interactive modeling and data visualization that can be rendered in jupyter notebooks or deployed as web applications. To construct bonding curve models, we create parameterized classes using the param library. Param is an extremely powerful paradigm for python programming that enables guarantees to be built into code. It is strong typing, documentation, and gui development all baked into one convenient api that requires describing the parameters that define the data structures of a codebase. With this we can create powerful re-usable models using clean object oriented class based structures. To construct applications we use the complimentary panel library, which itself is built using param.

Piercing Through the Veil

Why bother simulating and modeling your Bonding Curves? So we can figure out what these complex systems are doing, particularly since the economic health of our projects relies on them! Through modeling and simulation, we aim to decipher the behavior of Bonding Curves, identify breaking points, seek sustainable launch parameters, and strategize mitigation measures for potential black swan events.

In this case, we focused our simulation efforts on the ABC of the TEC. Do note, we have various models in progress on our Github, including the likes of Uniswap, Curve, and Bancor bonding curve models. If you're playing around with our code, which we genuinely hope you do, ensure you pick the appropriate Bonding Curve for your needs!

After bringing in the data from Dune, into our python environment via a wrapper, our first milestone was to backtest the TEC data to corroborate the accuracy of our model. You can check out the video here.

Backtest of TEC Bonding Curve data.
Backtest of TEC Bonding Curve data.

After ensuring that our model mirrors the historical data accurately, we are poised for a deeper and more intriguing analysis. Though resource constraints have kept us from diving into this arena yet, here's a glimpse of some possibilities on our radar:

  • Comprehensive A-Z testing of Bonding Curve parameters in various scenarios

  • Unit testing: scrutinizing a single code file/bit

  • Integration testing: amalgamating different functions in a smart contract

  • Exploring malevolent strategies to extract from PAMM and/or SAMM, flash loans, varying liquidity volumes, etc

  • Penetration testing: Gauging the limits of the models

  • What-if Analysis: projecting outcomes if, say, TEC shot up to $7

  • Evaluating the effects of arbitrage between PAMMs & SAMMs (volatility dampening)

Future Vision: Digital Twin Bonding Curve and Real-Time Dashboards

Picture this: a real-time digital twin of your Bonding Curve, thriving in a coding environment suitable for data analysis, constantly updated with live blockchain data. This concept could revolutionize how we perceive and understand the impacts of Bonding Curves and their effects on more stable and resilient token economies.

Live dashboards could offer real-time insights, transforming lagging indicators into prompt responses. These dashboards could guide decision-making, foster sustainability, and offer transparency for the entire network. We’re taking the first steps towards realizing this vision at the BCRG, and we welcome everyone to fork our repo, explore these ideas, and join us on this journey. The work done thus far is merely the start. We look forward to embarking on this challenging journey to enable a safe and sustainable Web3 for everyone, even if they're unaware they're using it. Our ultimate vision? A world where everyone interacts seamlessly with Bonding Curves without even realizing it. Bonding Curves are undeniably pivotal in shaping our emerging crypto-economic ecosystems and we understand far too little about them!

About the Bonding Curve Research Group

The BCRG is driving forward the research, development, education, and application of Bonding Curves in their various forms. As a collective of multidisciplinary researchers, we are on a mission to empower communities and projects, unlocking new opportunities through Web3 education and token engineering.

**Learn more & connect with us **🐦Twitter | 📌 Notion |📚 Medium

Subscribe to Bonding Curve Research Group
Receive the latest updates directly to your inbox.
Mint this entry as an NFT to add it to your collection.
Verification
This entry has been permanently stored onchain and signed by its creator.