# Candy Shop Implementation > Present implementation details ## Lottery * **Governance Contract**:- To manage key variables of the lottery. * Fees per swap * Proxy contract address of lending function(Compound & aave) & Swap function(Uniswap for now). * Lottery Duration * Cost per candy * Threshold Amount. * Admins * required Functions to change the above key variables by the admin. * **Lottery Contract**:- User interact with this contract and whole lottery logic goes here. Assets are stored here. * Start new draw function * Reward and clear the prize pool function. * Swap Function. * Sponsor Deposit and withdrawal function. * Mapping of candies to user for each draw. * Mapping of supported Stable tokens. * Mapping of sponsor principal amount. * Mapping of Each Lottery details(total Tickets, start time, end time, status of lottery) * **Lending Proxy Contract**:- Deposit and withdraw function of different protocols are present here. * **Swap Proxy Contract**:- Swap Function of different dex are present here. Note: Proxy contracts can be changeable only for the next draw. If changed also will be using the old proxy for the current draw. --- **Lottery Flow** * **Sponsorship** - * Can deposit any desired token, then we will convert into supported stable coins deposit into lending protocols. * Interest amount is used as prize money in the lottery. * Can withdraw the principal amount only after the lottery is completed. * **Swap** - * User has an option whether the user can participate or not in the lottery. * Principal amount + interest amount will be used in the prize pool. * ***Small Swap***(Below threshold amount) - * Fee amount is calculated by the amount user wants to swap. * Fee amount collected from the user will be converted into supported stable coins if it's not a stable coin. * Fee Amount `x` is converted into candies. `no of candies = x / candyPrice` * Fee amount `x` is deposited into lending protocols. * ***Huge Swap***(Above threshold amount) - * Fee Amount is calculated and collected from the arbs profit. * If the user wants to participate in the lottery, then profits from arbs are split into two parts `80%` of the profits are given back to the user and `20%` of the profits are deposited into lending protocols * If the user opts out from the lottery, then profits from arbs are split into two parts `90%` of the profits are given back to the user and `10%` of the profits are deposited into lending protocols