Skip to main content

What is self financing anyway?

ยท 4 min read
Eric Forgy

Hello everyone and welcome to the CavalRe! ๐Ÿค 

In this article, we examine the concept of self financing. What it is and why it is important in the design and analysis of DeFi protocols.

Self Financing in TradFiโ€‹

So... what is self financing anyway?

Self financing is a lot like a conservation law of physics. Just as energy cannot be created or destroyed and can only be transformed, a transaction is self financing if no value is created or destroyed during the transaction and value is only transferred.

In the quant literature, e.g. the derivation of the Black-Scholes equation, self financing is such a natural and obvious constraint it is often mentioned in passing (if mentioned at all) by noting that the change in value of a portfolio consisting of ฮฑi\alpha_i units of security ii with price PiP_i is given by

dV=โˆ‘i=1nฮฑidPi.dV = \sum_{i=1}^n \alpha_i d P_i.

To distill this a bit, step back and write the value of the portfolio as

V=โˆ‘i=1nฮฑiPi.V = \sum_{i=1}^n \alpha_i P_i.

Taking the differential of this and applying the product rule gives

dV=โˆ‘i=1n(dฮฑi)Pi+โˆ‘i=1nฮฑidPi.dV = \sum_{i=1}^n (d \alpha_i) P_i + \sum_{i=1}^n \alpha_i dP_i.

We see the change in value of the portfolio can be decomposed into a change that is due to trading activity, i.e.

dVtrading=โˆ‘i=1n(dฮฑi)Pi,dV_{\text{trading}} = \sum_{i=1}^n (d \alpha_i) P_i,

and a change that is due to market movements, i.e.

dVmarket=โˆ‘i=1nฮฑidPi.dV_{\text{market}} = \sum_{i=1}^n \alpha_i dP_i.

Comparing this with the previous expression, we see that another way of saying a portfolio is self financing is to say that the change in value due to trading activity is zero, i.e.

โˆ‘i=1n(dฮฑi)Pi=0.\sum_{i=1}^n (d \alpha_i) P_i = 0.

Although requiring transactions to be self financing might seem intuitively obvious (because it is!), the unfortunate fact is that most DeFi protocols out there today are not self financing and this has implications.

Self Financing in DeFiโ€‹

Self financing in DeFi is essentially the same an in TradFi except, as mentioned in our previous article, when analyzing DeFi protocols, the inherent discreteness of the blockchain becomes important. We need to use analogous tools from discrete calculus to define what self financing means in the context of discrete blockchains.

The quantities and prices of tokens in a portfolio can be expressed as node functions

ฮฑi=โˆ‘tโˆˆNฮฑi,tetandPi=โˆ‘tโˆˆNPi,tet\alpha_i = \sum_{t\in\N} \alpha_{i,t} \mathbf{e}^t\quad\text{and}\quad P_i = \sum_{t\in\N} P_{i,t} \mathbf{e}^t

where the components ฮฑi,t,Pi,t\alpha_{i,t}, P_{i,t} represent the number and price, respectively, of token ii in the state tโˆˆN.t\in\N. The total value of a portfolio is then given by

V=โˆ‘i=1nฮฑiPiโ€…โ€ŠโŸนโ€…โ€ŠVt=โˆ‘i=1nฮฑi,tPi,t.V = \sum_{i=1}^n \alpha_i P_i\implies V_t = \sum_{i=1}^n \alpha_{i,t} P_{i,t}.

The change in value can then be expressed using the discrete product rule as

(ฮ”V)t,t+1=โˆ‘i=1n(ฮ”ฮฑi)t,t+1(EkiPi)t,t+1+โˆ‘i=1n(E1โˆ’kiฮฑi)t,t+1(ฮ”Pi)t,t+1,(\Delta V)_{t,t+1} = \sum_{i=1}^n (\Delta\alpha_i)_{t,t+1} (E_{k_i} P_i)_{t,t+1} + \sum_{i=1}^n (E_{1-k_i} \alpha_i)_{t,t+1} (\Delta P_i)_{t,t+1},

recalling that

(ฮ”f)t,t+1=ft+1โˆ’ft(\Delta f)_{t,t+1} = f_{t+1} - f_t


(Ekf)t,t+1=(1โˆ’k)ft+kft+1.(E_k f)_{t,t+1} = (1-k) f_t + k f_{t+1}.

In complete analogy to the continuum TradFi case, the discrete change in value can be decomposed into

(ฮ”Vtrading)t,t+1=โˆ‘i=1n(ฮ”ฮฑi)t,t+1(EkiPi)t,t+1,(\Delta V_\text{trading})_{t,t+1} = \sum_{i=1}^n (\Delta\alpha_i)_{t,t+1} (E_{k_i} P_i)_{t,t+1},

which is the change in value due to trading activity and

(ฮ”Vmarket)t,t+1=โˆ‘i=1n(E1โˆ’kiฮฑi)t,t+1(ฮ”Pi)t,t+1,(\Delta V_\text{market})_{t,t+1} = \sum_{i=1}^n (E_{1-k_i} \alpha_i)_{t,t+1} (\Delta P_i)_{t,t+1},

which is the change in value due to market movements.

We can now state that a portfolio is self financing on a blockchain if the change in value due to trading activity is zero, i.e. if

โˆ‘i=1n(ฮ”ฮฑi)t,t+1(EkiPi)t,t+1=0\sum_{i=1}^n (\Delta\alpha_i)_{t,t+1} (E_{k_i} P_i)_{t,t+1} = 0

or, equivalently,

(ฮ”V)t,t+1=โˆ‘i=1n(E1โˆ’kiฮฑi)t,t+1(ฮ”Pi)t,t+1.(\Delta V)_{t,t+1} = \sum_{i=1}^n (E_{1-k_i} \alpha_i)_{t,t+1} (\Delta P_i)_{t,t+1}.

Effective Pricesโ€‹

Examining the expression for the change in value due to trading activity, we can interpret the term

(EkiPi)t,t+1=(1โˆ’ki)(Pi)t+ki(Pi)t+1(E_{k_i} P_i)_{t,t+1} = (1-k_i) (P_i)_t + k_i (P_i)_{t+1}

as the effective price used for determining the value paid for / received from exchanging (ฮ”ฮฑi)t,t+1(\Delta\alpha_i)_{t,t+1} tokens. This means that

(E0Pi)t,t+1=(Pi)t(E_0 P_i)_{t,t+1} = (P_i)_t

corresponds to transactions occurring at the initial (stale) price determined in the previous block with no price slippage. Similarly,

(E1Pi)t,t+1=(Pi)t,t+1(E_1 P_i)_{t,t+1} = (P_i)_{t,t+1}

corresponds to transactions occurring at the terminal price only known in the next block, which depends on the size of the transaction and includes maximum price slippage. Finally,

(E1/2Pi)t,t+1=1/2(Pi)t+1/2(Pi)t+1(E_{1/2} P_i)_{t,t+1} = 1/2 (P_i)_t + 1/2 (P_i)_{t+1}

corresponds to transactions occurring at the exact midpoint between the initial and terminal prices.

So, what started as a purely mathematical consequence of the inherent discreteness of blockchain provides an intuitive financial interpretation of self financing with implications for the design, analysis and implementation of DeFi protocols.