Giter VIP home page Giter VIP logo

contracts-raffle's Introduction

@looksrare/contracts-raffle

Tests License: MIT

Description

This project contains the smart contracts used for LooksRare's raffle protocol. The main contract Raffle allows anyone to create a raffle with multiple prizes and winners. The fees must be paid in ETH or ERC-20, while the prizes can be ERC-721, ERC-1155, ETH or ERC-20.

Deployments

Network Raffle RaffleV2
Ethereum 0x0000000000009703EcD0fFEa3143fc9096DE91B0 0x0000000000aDEaD599C11A0C9a7475B67852c1D0
Goerli 0xC5F7FCde87e30Aa339d3d61B4fe3c1C261f6EEe2 0xda28aC345040C9abC0E19AfD6025c4f5A45C4b30
Sepolia 0xb0C8a1a0569F7302d36e380755f1835C3e59aCB9 0xae7cf912ab5d9f6aa53126ea7aabd007f844ceec

Raffle states

Each raffle consists of the following states:

  1. None There is no raffle at the provided ID.

  2. Open The raffle has been created, prizes have been deposited and is open for entries.

  3. Drawing When a raffle's minimum entries has reached before the cutoff time, the smart contract calls Chainlink VRF to draw a random number to determine the winners. Raffle owners also have the option to draw the winners if the minimum entries is not met after the cutoff time. The state Drawing represents the intermediary state of waiting for Chainlink VRF's callback.

  4. RandomnessFulfilled When Chainlink VRF's callback is complete, the raffle stores the random words and transitions to RandomnessFulfilled.

  5. Drawn The process to store random words and to select the winners are separated into 2 functions as there is a 2.5m callback gas limit from Chainlink. Once the winners are selected via the function selectWinners, the raffle is considered Drawn.

  6. Complete After the raffle creator claims the fees accumulated from selling raffle tickets, the raffle is considered Complete.

  7. Refundable If the raffle is still in the Created state (no prizes were deposited) or is not able to sell out at least the specified minimum entries, then the raffle can be cancelled. The raffle can be transitioned to Refundable state if there are deposited prizes. The raffle creator can withdraw the prizes and the ticket buyers can withdraw the fees spent (if any).

  8. Cancelled A raffle can transition from Refundable to Cancelled by having the raffle creator withdrawing the prizes or it can transition from Created to Cancelled directly if the prizes were never deposited. Ticket buyers can still withdraw the fees spent.

Protocol fees

The contract owner can set a protocol fee recipient and a protocol fee basis points (up to 25%) per raffle.

Pricing options

Each raffle can have between 1 to 5 pricing options. The rules are as follows:

  1. The raffle's minimum entries must be divisible by the first pricing option's entries count.
  2. The first pricing option must not have a price of 0.
  3. Each pricing option after the first one must have a higher entries count than the previous one.
  4. Each pricing option after the first one must have a higher total price than the previous one.
  5. Each pricing option after the first one must not have a higher price per entry than the previous one.
  6. Each pricing option's entries count must be divisible by the next pricing option's entries count.

Misc. rules

  1. Each raffle's lifespan must between 1 day to 7 days.
  2. If the fee/prize token is an ERC-20, then it must be allowed by the contract owner (LooksRare's multi-sig).
  3. There can be up to 200 prizes per raffle. Each ERC-721 prize counts as 1 even if they belong to the same collection. Each ERC-20 / ERC-1155 with the same token ID and multiple winners count as 1.
  4. The maximum winners per raffle is 200.

contracts-raffle's People

Contributors

0xhiroshi avatar 0xjurassicpunk avatar dependabot[bot] avatar hexacroes avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.