The insane DeFi has driven many people crazy, the base to all of those projects are those swaps, notably Uniswap, now the shining Sushi. Nothing more to talk about them, all is crazy, but good. This crazy has attracted more developers on Ethereum platform, though we have the cool Mixin Network, we don’t have swaps available. Now I propose a swap engine to make swap easier than ever and anywhere else, by facilitating hundreds of millions of dollars worth cryptos in the network, and most importantly the free and instant finalization.
The core of swaps is a formula to calculate price by liquidity, for Uniswap it’s
x * y = k, where both
y are token amount, and
k is an invariant, and it remains the same whenever a trades happen. Let’s say we have 100 XIN and 10 BTC in the liquidity pool, i.e.
x = 100, y = 10, the formula would be
100 * 10 = 1000. Whenever a trade happens, someone deposits 1 BTC to buy some XIN, the formula should be calculated as
(100 - x) * (10 + 1) = 1000 => x = 100/11 = 9.09, i.e. they buys 9.09 XIN with 1 BTC. Of course we don’t mention swap fees yet, Uniswap charges 0.3%, and after the trade, the fees will be provided as liquidity. When provides liquidity to the pool, the invariant
k should change, and a larger
k means deeper market, ergo lower price slippage.
We already have the Ocean as an decentralized exchange, which provides a traditional order book engine, that is almost impossible for Ethereum, and that’s why they have such innovations like Uniswap to take advantage of their slowness. That says we could make Ocean as a swap engine in no more than hours engineering efforts. Right now when a transfer to an Ocean broker is received, the engine puts an entry in the order book according to the legit memo, otherwise rebates it. To make it work as a swap engine, we needs a formula and somewhere to handle the liquidity pool, as the pool requires both tokens provided at the same time, but the simplicity of Mixin Network allows only one exact transfer per snapshot. Still pretty doable, now the proposal to swap the Ocean.
Incentives make things bootstrap easier, we borrow the idea from SushiSwap, and make a token called SHIP, which represents the privileges of the Ocean, 0.05% of all fees will be distributed to SHIP holders. SHIP will be minted every hour proportionately to all liquidity providers based on their XIN value, and for the first 2 weeks the mint is 10x faster to reward early adopters. Besides SHIP, we have DROP as the liquidity providing token per market, the same as those Uniswap LP tokens, and 0.25% of all fees will be distributed to DROP holders. DROP is minted the same as Uniswap.
There is no way to make tokens in Mixin Network, so we make a single SHIP ERC20 token contract on Ethereum, and one DROP ERC20 token contract per Ocean Swap market. Again the simplicity of Mixin Network allows only simple transfers, no mints, so we make all tokens 1 billion in total supply on Ethereum, and transfer all of them to the Mixin Network account of Ocean Swap engine, then make its accounts transparent by providing its access token. All liquidity pools are also transparent, so that the SHIP and DROP distributions could be validated by all that no frauds happen. Both cons and pros are in this solution, it relies on some central engine distribution, but provides better security against hacking, and the same transparency as Ethereum contracts. More over, the central engine can be improved further by multisig.
The very first step is to provide liquidity for the pair of tokens to trade, let’s say the BTC-XIN market. There is no liquidity at first, and the first provider will define the price. The first who makes two legit transfers will be the first provider.
All Ocean Swap transfers should have their memos encoded in the following binary format, and make base64 conversions before sending out.
BASE | QUOTE | ACTION | EXTRA
BASE and QUOTE are the binary UUID of the tokens. In this case,
c94ac88f-4671-3976-b60a-09064f1811e8 in binary format. To make things easier, the engine will only accept XIN as the QUOTE for now.
ACTION is one byte where
0 is swap, i.e. trade,
1 is mint, i.e. provide liquidity. In this case,
EXTRA here should be a binary UUID, it must be identical for both token transfers for the same liquidity providing operation, and must not be same as any other UUID.
Whenever the swap engine receives a mint transfer, it will wait like 5 minutes for another transfer with the same EXTRA. And if the other one arrives on time, the engine asserts the liquidity price is in proper range correlates with the existing pool. Otherwise all the first mint transfers will be rebated by deducting 1% fee.
After a liquidity provided, the engine will sends some corresponding DROP tokens to the provider proportional to the XIN value of provided versus the total liquidity in this market.
This operation is much easier than providing liquidity, just sends out a single transfer to any broker with a proper memo.
BASE and QUOTE should be the same format as the liquidity providing action.
ACTION is of course
EXTRA is not needed at all.
The engine will validate your memo, if legit the swapped token will be transferred to the sender instantly. Otherwise the transfer will be rebated by deducting 1% fee.
Sends a single transfer of the DROP token to any broker will remove some or all of your liquidities. Since the DROP token already has all the market information, memo is not needed at all. After the engine receives the transfer, two transfers will be sent to the sender instantly, the transfer amount is proportional to the DROP value versus the total DROP liquidity in this market.
The engine is simple in design, and there are also few promotion ideas.
We may reward the broker with 0.05% fees, the the DROP holders get 0.2%.
What SushiSwap does to utilize the liquidity of Uniswap may also apply to Ocean.
Who will build this engine and swap the Ocean?