Long thread on arbitrage and how it applies to @dextfprotocol , a project I know well. I will add in the future other protocols as well
Pls stay with me in the initial part
Who knows what arbitrage is?
Pls stay with me in the initial part
Who knows what arbitrage is?
Arbitrage is the practice of taking advantage of a price difference between two or more markets
https://en.wikipedia.org/wiki/Arbitrage
Typically the textbook definition would assume the transaction are riskless but often some risk apply
https://en.wikipedia.org/wiki/Arbitrage
Typically the textbook definition would assume the transaction are riskless but often some risk apply
- timing risk: you sell first and buy later but the price can move
- settlement risk: one of two trades fails
- often entails borrowing with the connected credit risk
- often entails leverage with the connected operational risks
https://en.wikipedia.org/wiki/Arbitrage#Risks
- settlement risk: one of two trades fails
- often entails borrowing with the connected credit risk
- often entails leverage with the connected operational risks
https://en.wikipedia.org/wiki/Arbitrage#Risks
This leads to weaker form of arbitrage, in real life, where you take advantage of the EXPECTED profit from a difference between two or more markets
@dextfprotocol allow the creation of XTF, digital funds which for the purpose of this thread are just a basket of other ERC20 tokens
XTF are ERC20 tokens themselves and hence can be listed on a @Uniswap or @SushiSwap or any other DEX https://twitter.com/Be1garat/status/1308220565988106241?s=20
XTF are ERC20 tokens themselves and hence can be listed on a @Uniswap or @SushiSwap or any other DEX https://twitter.com/Be1garat/status/1308220565988106241?s=20
This creates a market for the XTF that is different from the components of the fund
This means that the price at which the XTF trades may (usually is) different from the sum of the prices of the components
This means that the price at which the XTF trades may (usually is) different from the sum of the prices of the components
@dextfprotocol lets you create and destroy units of the XTF fund permissionlessly, you just need to have the components in your wallet to create units (can also use Kyber but I would discourage it until Kyber v3) or the XTF fund if you want to destroy it https://twitter.com/krugermacro/status/1356682528380383232?s=20
So for example if the XTF fund has 3 token A and 2 token B and Pa = 1 and Pb=2 then its value is Vx= 3x1+2x2=7
If on Uni instead its price is P1x = 8 then you can
- buy 3A+2B, cost 7
- create 1XTF
- sell it on Uni @ 8
- make 1 arbitrage profit
If on Uni instead its price is P1x = 8 then you can
- buy 3A+2B, cost 7
- create 1XTF
- sell it on Uni @ 8
- make 1 arbitrage profit
If, P2x = 5 then
- buy 1XTF
- destroy and receive 3A+2B
- sell A and B for 7 on Uni or other DEX
- make 2 arbitrage profit
- buy 1XTF
- destroy and receive 3A+2B
- sell A and B for 7 on Uni or other DEX
- make 2 arbitrage profit
Extra benefit of this is that in the first example Pa and Pb will increase a little (as you are buying them) and P1x will decrease a little (as you are selling it) for example
Pa -> 1.2, Pb -> 2.1 => Vx = 6.8
P1x -> 6.9
https://en.wikipedia.org/wiki/Arbitrage#Price_convergence
Pa -> 1.2, Pb -> 2.1 => Vx = 6.8
P1x -> 6.9
https://en.wikipedia.org/wiki/Arbitrage#Price_convergence
@dextfprotocol dapp makes it very easy to see.
In the this live example, you can see the value in red and the price on uni in green. And the button leads you immediately to the trading page on uni
You can mint units with a cost of 230$ in components and sell the fund for 256$
In the this live example, you can see the value in red and the price on uni in green. And the button leads you immediately to the trading page on uni
You can mint units with a cost of 230$ in components and sell the fund for 256$
Because Uni is an AMM with a deterministic price-quantity relationship, you can calculate precisely the amount of tokens you need to buy/sell to eliminate the arb
Q = LPe * (sqrt(Px/Vx)-1)
where LPe is the amount of ETH in the uniswap LP against the fund
Q = LPe * (sqrt(Px/Vx)-1)
where LPe is the amount of ETH in the uniswap LP against the fund
And you can prove that this is also the amount that maximise your profits
With a bit of Uniswap math you can also calculate what is the min price discrepancy that justify an arb as a function of gas fees and size of the Uni LP but I would leave it to another post
With a bit of Uniswap math you can also calculate what is the min price discrepancy that justify an arb as a function of gas fees and size of the Uni LP but I would leave it to another post
This is a neat alternative to oracles:
the possibility of arbitrage create a game theory equilibrium where the price of the fund is kept in line with its value (sum of the price of components), without the protocol needing to know either Pa, Pb or Px
https://twitter.com/Be1garat/status/1230646150031499264?s=20
the possibility of arbitrage create a game theory equilibrium where the price of the fund is kept in line with its value (sum of the price of components), without the protocol needing to know either Pa, Pb or Px
https://twitter.com/Be1garat/status/1230646150031499264?s=20
And no oracle means smaller attack surface for the protocol, fewer risks and less need for updating the contract.
Which in turn leads to a higher ability for the team to remove any admin power on the protocol
https://twitter.com/Be1garat/status/1335375003966078976?s=20
Which in turn leads to a higher ability for the team to remove any admin power on the protocol
https://twitter.com/Be1garat/status/1335375003966078976?s=20
If you add to the mix things like @furucombo you can create arbs in a single transaction: essentially is just a bunch of buy and sell instruction to uniswap and the creation/destruction instruction to DEXTF
https://twitter.com/Be1garat/status/1310938926761287680?s=20
https://twitter.com/Be1garat/status/1310938926761287680?s=20
Finally, if you add to the mix flashloans as you can do from @AaveAave or @dydxprotocol you don't even have to have the capital in the first place:
Single tx: flashloan -> buy components/XTF -> create/destroy -> sell XTF/components -> repay loan -> smile with profits
Single tx: flashloan -> buy components/XTF -> create/destroy -> sell XTF/components -> repay loan -> smile with profits
This enables a novel way to do arb:
typically, arb trades have small risk but are highly capital intensive and hence difficult to democratize
With flashloans for the first time in history, everyone has an unlimited access to capital (for a block)
typically, arb trades have small risk but are highly capital intensive and hence difficult to democratize
With flashloans for the first time in history, everyone has an unlimited access to capital (for a block)
On the other side, in a single tx, the self-packaged arb, would prob be frontrun, but frontrunning is a general problem that the @ethereum community is working to solve anyway https://twitter.com/Be1garat/status/1310940520911384578?s=20