Discrete Calculus for DeFi Math
Hello everyone and welcome to the CavalRe! ๐ค
In this article, I present a primer on discrete calculus with the intention of helping us analyze DeFi protocols running on blockchains, which are inherently discrete in nature.
Blockchain as a State Machineโ
The Ethereum yellow paper describes the Ethereum blockchain as a state machine with the state of the world denoted by . Given a transaction , the state is updated to a new state by the Ethereum state transition function denoted by
It is important to note the inherent discreteness of this process. There is no state between and A transaction takes you from some initial state to some final state with nothing in between and repeats indefinitely with every new transaction.
This discreteness has implications for how we should analyze blockchain protocols such as automated market makers (AMMs) so we will enhance our toolbox for dealing with this discreteness in the remainder of this article.
Node Functionsโ
Every blockchain needs to start with some initial state created by some kind of genesis event. Therefore, it makes sense to restrict to be a natural number with the initial state denoted A node function is simply a function
where denotes real numbers. Let denote a special function whose value is given by
Any node function can be expressed as a linear combination of these functions, i.e.
where is the value of at . The basis functions can be multiplied
which extends to the product of arbitrary node functions intuitively as