Introduction
I was supposed to write about intent-centric architecture this week, but I got stuck in a math equation. So, like any other player in the venture ecosystem - I pivoted. Presenting a short piece on curve calculations.
Project: Platypus Finance
Platypus Finance is a stableswap whose design is liability-centric rather than asset-centric, i.e, the protocol tracks token accounts rather than token pools. Here is their Yellow Paper.
Mechanism Walk Through
Let’s breakdown the maths behind a $1k swap from USDT to USDC:
The terminal exchange rate is given by:
f i-j is the exchange rate sourced from Chainlink;
h is the haircut, fixed at 0.01%;
Si-j is the swap slippage;
g(r) is the account slippage at coverage ratio, r; which leads us to the last formula:
The paper defines r* as a threshold coverage ratio. The team chose k=0.00002 and n=7 which gives r* = 0.3298[2].
Now we pick up live data[3]. Before the swap:
USDT: assets, liabilities, r = (14.4mn, 14.4/1.33 mn, 1.3379)
USDC: assets, liabilities, r = (29.8mn, 29.8/0.786 mn, 0.7868)
Documenting the calculations in a working sheet[4].
After the 1k swap:
-> r’USDT, r’USDC = (1.3379, 0.7867)
-> g(r’USDT), g(r’USDC), g(rUSDT), g(rUSDC) = (0.0002605, 0.0107172, 0.0002688, 0.0107338) [in %]
-> sUSDT, sUSDC = (-0.0014, 0.0954) [in %]
-> Si-j = 0.0940%
-> fi-j = 1.00077101 [Chainlink]
-> f* i-j = 999.729
The actual amount received for this data: 998.855[5]
Delta in actual v/s calculated values= -0.874
….but my worksheet isn’t scaling, i.e, when I try to compute the answers for $1 or $10,000 the delta is too large, if you have any ideas on how to fix it/have a secret stash of AMM Excel sheets, please DM.
Why This Mechanism Is Exciting
Platypus uses a single variant slippage function instead of invariant curves. This allows them to have open pools instead of fragmenting liquidity for the same token in different pools. In his 2013 paper, A. Othman[6] describes the ‘AMM trilemma’ wherein a protocol can have any two of the following but not all three: path independence, liquidity sensitivity, and no arbitrage. Platypus solves for the first two and uses extra mechanisms to block arbitrage but they do not have a perfect no-arb protocol.
How Can It Be Improved
Self-balancing pools help protocols achieve comparable liquidity in their pools. This can be tested by giving out base pool rewards in the inverse ratio of their contribution to the TVL of the protocol. Secondly, as the protocol scales it will see highly risky assets trying to enter the omnipool. It might be prudent to introduce ‘child’ pools or time-bound isolated pools to manage risk.
Conclusion
I find math equations terribly cool, if you’re working on a new AMM/deFi design, please ping me your scribbled-down math equations.
References
[1] Founder’s profile on LinkedIn https://www.linkedin.com/in/liejenhoung/
[2] Threshold coverage ratio formula
[3] Platypus pool data snap
[4] Working sheet https://docs.google.com/spreadsheets/d/1-M6ombqDSn6FETWY4Mw8_APZX-WV2N87A-LTD4s8JGc/edit#gid=552973582
[5] Platypus swap data snap
[6] A Practical Liquidity-Sensitive AMM (A. Othman et all, 2012)