Smartlink

Search…

Decentralized Exchange

Staking

Smart Contract Audits

Bug Bounty

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$

of XTZ to receive $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$

tokens to receive $a$

: $(x-a)*(y+0.9972*b)=x*y=k$

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$

of XTZ to receive $b_1$

of tokens and then $a_2$

of XTZ to receive $b_2$

of tokens. Or a user may “directly” sell

$a = a_1 + a_2$

of XTZ to receive $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$

of XTZ to receive $b_2$

of tokens and then $a_2$

of XTZ to receive $b-b_2$

of tokens. Or a user may "directly" sell

$a=a_1+a_2$

of XTZ to receive $b=b_1+b_2$

of tokens.As a consequence, a trader who sells

$a$

of XTZ receives the same amount $b$

he would have received if he had either first sold $a_1$

and then $a_2$

or first $a_2$

and then $a_1$

. This is composability.Last modified 1mo ago

Export as PDF

Copy link