> For the complete documentation index, see [llms.txt](https://resource.optiswap.pro/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://resource.optiswap.pro/optiswap/optisize.md).

# OptiSize

The hyperbolic shape of the xy=k slippage curve makes it important to consider order size when doing a swap.

Consideration of gas fees creates a convex optimization problem.

What order size gives the best outcome, in terms of the highest percent realization of spot price value?

When researching this question, we found it was easy to approximate by simulating transactions. Empirically we observed many wallets using this size.

A closed-form solution can be derived using calculus.

We call this the **OptiSize formula.**
