Candyshop is a DEX aggreagator that optimises for efficeiency by arbitrging user swaps and splitting arbitragep profits with user.
The lottery system is inspired by pool together to give binance like bounties for trading. Arbitrage is performed by using uniswapv2 flash swap. This way everyone is benifited.
How it's made
We have 2 sets of contracts: 1) Arbitrage Contracts performing arbitrage by using flash swap from UniswapV2 and normal swap using UniswapV1. 2) Lottery contracts where it manages the lottery system. Assets are deposited in Compound and Aave and the total amount(excluding sponsor principal amount) is distributed to the winners. Non-biased multiple lottery winners are chosen by random using Chainlink VRF. Whenever a user wants to swap a huge amount, and if there is low liquidity then a high slippage applies. Users can gain profit from this arbitrage opportunity by allowing us to do the arbitrage. We send the user's swap to uniswapV1 and do the original swap. After the UniswapV1 original swap, we use the flash-swaps to borrow the assets required to arbitrage and then we execute arbitrage on UniswapV1 using UniswapV2 as a price oracle. The profit generated by this arbitrage is split into two parts. 20% of the profit is taken as a candy fee for buying candies which will allow the user to participate in the lottery and 80% of the profit is returned to the user. All the candy fee collected from the swap is used as the prize pool for the lottery. An individual can also sponsor the lottery to increase the prize pool. Interest generated by the sponsorer's principal amount is only used for the prize pool. Prize pool amount is deposited in Aave or Compound to earn interest for a period of 1 week. When the lottery ends, winners are selected using Chainlink VRF to get the randomness and the prize amount is taken out from the lending protocols. The prize amount is given out to the winners and the sponsorer's principal amount is transferred back to the sponsorer. Frontend is developed using Reactjs.