## Curve Finance Part 2: Swapping Tokens

This post explores the dynamics of the StableSwap invariant when swapping tokens.

This post explores the dynamics of the StableSwap invariant when swapping tokens.

This post is the first in a multipart series exploring the mathematics behind Curve Finance stable pools. We will begin by introducing the StableSwap invariant and discuss some of the mathematics behind its construction.

The marginal price for a Uniswap V2 (constant product) style AMM is typically quoted without working through the mathematical deriviation. In this post I work through the derivation of the marginal price formula.

Hyperparameter tuning is an important step for maximizing the performance of a model. Several Python packages have been developed specifically for this purpose. Scikit-learn provides a few options, GridSearchCV and RandomizedSearchCV being two of the more popular options. Outside of scikit-learn, the Optunity, Spearmint and hyperopt packages are all designed for optimization. In this post, I will focus on the hyperopt package which provides algorithms that are able to outperform randomized search and can find results comparable to a grid search while fitting substantially less models.

While I was a teaching assistant for an undergraduate numerical analysis course, I developed this two-page Matlab cheatsheet. It covers basic programming concepts in Matlab and provides an example on generating a plot. This cheatsheet is a valuable resource when first learning Matlab.

Bohemian eigenvalues are the distribution of the eigenvalues of a random matrix. More specifically, this article explores matrices of low dimension (typically no larger than 10 x 10) whose entries are integers of bounded height. The name “Bohemian” is intended as a mnemonic and is derived from “Bounded Height Integer Matrix Eigenvalues” (BHIME). Here I present an overview of some preliminary results arising from this project.

Matlab provides a powerful plotting interface. Unfortunately, the default settings do not produce the most visually appealing figures. Unlike other popular plotting libraries (ggplot2, matplotlib, highcharts, Plotly, etc.), Matlab has no simple method for changing the overall appearance of a plot. One option is to use a platform such as Plotly within Matlab. In this article I discuss how you can improve the appearance of the native plotting architecture within Matlab to give your figures a more professional, refined look.

Have you ever applied custom styling to a figure in Matlab only to discover this styling does not transfer to subsequent figures? Unfortunately, plot styling only applies to the figure it was initially applied to. Luckily, an under-documented feature in Matlab allows you to set global properties for your figures.

The TikZ package is a great tool for generating publication quality illustrations of Markov chains in LaTeX. This article presents 3 examples along with the complete LaTeX source. At each step, links are provided to the LaTeX source on Overleaf where you can view and edit the examples.