Search…
Composability
Smartink's decentralized exchange follows the following rules, with 0.28% overall fees, when the initial reserves are
$x$
of token XTZ and
$y$
of tokens and the user sells
$a$
$b$
, the following can be observed with
$k$
being invariant:
$(x + 0.9972*a)*(y-b)=x*y=k$
By symmetry, the following formula holds with a sale of
$b$
$a$
:
$(x-a)*(y+0.9972*b)=x*y=k$

## Definition

Composability of such a decentralized exchange means that a trader gets the same price from participating all at once as in a set of small trades. Therefore, traders do not need to strategize how they make trades, which can be complex to achieve in a public blockchain context. They are therefore financially incentivized to quickly perform the largest possible trades, which has a positive impact on the gains of liquidity providers.

## Proof

Let
$a_1,a_2>0$
and
$b_1,b_2$
such that, with
$a=a_1+a_2$
and
$a = b_1+b_2$
:
$(x+0.9972∗a_1)∗(y−b_1)=k=\Biggl(x+0.9972*(a_1+a_2)\Biggr)*(y-(b_1+b_2)) \\=(x+0.9972*a)*(y-b)$
That means that with initial reserves of
$x$
of token XTZ and
$y$
of tokens a user may sell
$a_1$
$b_1$
of tokens and then
$a_2$
$b_2$
of tokens.
Or a user may “directly” sell
$a = a_1 + a_2$
$b = b_1 + b_2$
of tokens.
Let
$b_2$
such that
$(x+0.9972*a_2)*\Biggl(y-\tilde b_2\Biggr)=k$
Note that
$\tilde b_2$
is not necessarily equal to
$b_2$
.
Recall that
$b$
is the only real such that:
$(x+0.9972*a)*(y-b)=k$
Hence, with initial reserves
$x$
of token XTZ and y of tokens a user may sell
$a_2$
$b_2$
of tokens and then
$a_2$
$b-b_2$
of tokens.
Or a user may "directly" sell
$a=a_1+a_2$
$b=b_1+b_2$
of tokens.
As a consequence, a trader who sells
$a$
of XTZ receives the same amount
$b$
$a_1$
$a_2$
$a_2$
$a_1$