Smartlink
Search…
Composability
Smartink's decentralized exchange follows the following rules, with 0.28% overall fees, when the initial reserves are
xx
of token XTZ and
yy
of tokens and the user sells
aa
of XTZ to receive
bb
, the following can be observed with
kk
being invariant:
(x+0.9972a)(yb)=xy=k(x + 0.9972*a)*(y-b)=x*y=k
By symmetry, the following formula holds with a sale of
bb
tokens to receive
aa
:
(xa)(y+0.9972b)=xy=k(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
a1,a2>0a_1,a_2>0
and
b1,b2b_1,b_2
such that, with
a=a1+a2a=a_1+a_2
and
a=b1+b2a = b_1+b_2
:
(x+0.9972a1)(yb1)=k=(x+0.9972(a1+a2))(y(b1+b2))=(x+0.9972a)(yb)(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
xx
of token XTZ and
yy
of tokens a user may sell
a1a_1
of XTZ to receive
b1b_1
of tokens and then
a2a_2
of XTZ to receive
b2b_2
of tokens.
Or a user may “directly” sell
a=a1+a2a = a_1 + a_2
of XTZ to receive
b=b1+b2b = b_1 + b_2
of tokens.
Let
b2b_2
such that
(x+0.9972a2)(yb~2)=k(x+0.9972*a_2)*\Biggl(y-\tilde b_2\Biggr)=k
Note that
b~2\tilde b_2
is not necessarily equal to
b2b_2
.
Recall that
bb
is the only real such that:
(x+0.9972a)(yb)=k(x+0.9972*a)*(y-b)=k
Hence, with initial reserves
xx
of token XTZ and y of tokens a user may sell
a2a_2
of XTZ to receive
b2b_2
of tokens and then
a2a_2
of XTZ to receive
bb2b-b_2
of tokens.
Or a user may "directly" sell
a=a1+a2a=a_1+a_2
of XTZ to receive
b=b1+b2b=b_1+b_2
of tokens.
As a consequence, a trader who sells
aa
of XTZ receives the same amount
bb
he would have received if he had either first sold
a1a_1
and then
a2a_2
or first
a2a_2
and then
a1a_1
. This is composability.
Last modified 16d ago
Copy link