Sushiswap - 3. Chain Dominance
Questions and Demands:
On what chains does Sushi have the most volume?
Sushi's expansion into other blockchains and ecosystems has been a core strategy for a while. How has the strategy played out?
How does Sushi's volume compare to other DEXes on chains like Polygon, Avalanche, and Arbitrum?
How does Uniswap's volume compare on these chains (wherever applicable)? Chart monthly changes in volume, number of users LPing, and the top LP pools per chain.
How do the incentives and rewards compare for pools on each chain?
Introduction:
What is SushiSwap? (SUSHI)The Beginner’s Guide
SushiSwap is a software running on Ethereum that seeks to incentivize a network of users to operate a platform where users can buy and sell crypto assets.
Similar to platforms like Uniswap and Balancer, SushiSwap uses a collection of liquidity pools to achieve this goal. Users first lock up assets into smart contracts, and traders then buy and sell cryptocurrencies from those pools, swapping out one token for another.
One of a growing number of decentralized finance (DeFi) platforms, SushiSwap allows users to trade cryptocurrencies without the need for a central operator administrator.
This means that decisions relating to the SushiSwap software are made by holders of its native cryptocurrency, SUSHI. Anyone holding a balance of the asset can propose changes to how it operates, and can vote on
submitted proposals by other users.
How does SushiSwap work? SushiSwap’s core function is to mirror a traditional exchange by facilitating the buying and selling of different crypto assets between users.
Rather than being supported by one central entity, tokens traded on SushiSwap are maintained by smart contracts, and users lock crypto on the software that can then be accessed by traders.
Of note, those who trade against locked assets pay a fee that is then distributed to all liquidity providers proportionally, based on their contribution to the pool.
SushiSwap Farms Liquidity providers contribute to SushiSwap pools by connecting their Ethereum wallet to the SushiSwap farming software and locking two assets into a smart contract. For example, SushiSwap’s USDT/ETH liquidity pool consists of equal values of USDT and ETH deposits.
Buyers can then swap tokens within the pool based on the protocol’s rules. Smart contracts running SushiSwap take the amount of tokens from the buyer and send an equivalent amount of tokens back, keeping the total pool price constant.
In exchange for maintaining liquidity in these pools, providers are then rewarded with protocol fees, along with a portion of the 100 newly minted SUSHI daily.
Providers can reclaim their funds whenever they wish, along with their “harvest”, which is the cryptocurrency earned from farming.
Users wishing to earn more cryptocurrency after harvesting their SUSHI can make use of the SushiBar, an application that allows them to stake their SUSHI to earn the xSUSHI token, which is composed of SUSHI tokens bought on the open market with a portion of all the fees generated on the exchange.
Read more : https://www.kraken.com/learn/what-is-sushiswap-sushi
For many of EVM chains like Arbitrium swap table is not available so we had to dig up information from transaction table and event table. There are huge JSon phrases on transaction table and event label so in fact we designed a swap decoder machine For creating our decoder first we dig up all transaction from event log massage. There is a JSon phrase on event log shows swap details. Token in token out amount in and amount out is some of the. many event contained all swap information token in, token out, amount in , amount out we dig ud up their as below:
case
when EVENT_INPUTS['fromToken'] is not null then EVENT_INPUTS['fromToken']
when EVENT_INPUTS['inputToken'] is not null then EVENT_INPUTS['inputToken']
when EVENT_INPUTS['tokenA'] is not null then EVENT_INPUTS['tokenA']
end
as token_in
,
--------------- amount in
case
when EVENT_INPUTS['amount0'] is not null and substr(EVENT_INPUTS['amount0'],1,1)!='-' then (EVENT_INPUTS['amount0'])
when EVENT_INPUTS['amount1'] is not null and substr(EVENT_INPUTS['amount1'],1,1)!='-' then (EVENT_INPUTS['amount1'])
when EVENT_INPUTS['inputValue'] is not null then (EVENT_INPUTS['inputValue'])
when EVENT_INPUTS['amountIn'] is not null then (EVENT_INPUTS['amountIn'])
when EVENT_INPUTS['amount'] is not null then (EVENT_INPUTS['amount']) --
when EVENT_INPUTS['amount0In'] is not null and EVENT_INPUTS['amount0In']!='0' then (EVENT_INPUTS['amount0In'] )
when EVENT_INPUTS['amount0In'] is not null and EVENT_INPUTS['amount0In']='0' then (EVENT_INPUTS['amount1In'] )
end
as amount_inn,
--------------- token out
case when EVENT_INPUTS['toToken'] is not null then EVENT_INPUTS['toToken']
when EVENT_INPUTS['outputToken'] is not null then EVENT_INPUTS['outputToken']
when EVENT_INPUTS['tokenB'] is not null then EVENT_INPUTS['tokenB']
end
as token_out,
--------------- amount out
case when EVENT_INPUTS['amount0'] is not null and substr(EVENT_INPUTS['amount0'],1,1)='-' then (EVENT_INPUTS['amount0'])
when EVENT_INPUTS['amount1'] is not null and substr(EVENT_INPUTS['amount1'],1,1)='-' then (EVENT_INPUTS['amount1'])
when EVENT_INPUTS['outputAmount'] is not null then (EVENT_INPUTS['outputAmount'])
when EVENT_INPUTS['outputValue'] is not null then (EVENT_INPUTS['outputValue'])
when EVENT_INPUTS['amountOut'] is not null then (EVENT_INPUTS['amountOut']) --
when EVENT_INPUTS['amount0In'] is not null and EVENT_INPUTS['amount0Out']!='0' then (EVENT_INPUTS['amount0Out'] )
when EVENT_INPUTS['amount0In'] is not null and EVENT_INPUTS['amount0Out']='0' then (EVENT_INPUTS['amount1Out'])
end
as amount0Outt
Many of event log just have amount in and amount out so we had to dig up token in and token out
From transaction table. So we inner joined two table event log and transaction by tx id. Now we have all JSon information.
we needed it find a transfer event that equals to amount in and amount out and then take the token information as token in or token out like Below:
when token_in is null and TX_JSON['receipt']['logs'][0]['decoded']['eventName']='Transfer' and (TX_JSON['receipt']['logs'][0]['decoded']['inputs']['from']=user or TX_JSON['receipt']['logs'][0]['decoded']['inputs']['to']in (PLATFORM_CONTRACT,vv )) and (TX_JSON['receipt']['logs'][0]['decoded']['inputs']['value']=AMOUNT_IN or TX_JSON['receipt']['logs'][0]['decoded']['inputs']['value']=AMOUNT_IN or TX_JSON['receipt']['logs'][0]['decoded']['inputs']['value']=abs(AMOUNT_IN) ) then TX_JSON['receipt']['logs'][0]['address']
We repeat the above command for 15th jason phrase to find out token in and token out.
Now we have all swap transaction of an EVM chain. Now we need to find decimals, token label and platform name
And we have done it by label tables and contract labels.
at last we could create a decoder that can extract all swap transaction from transaction table and event table for every EVM chain