Git Product home page Git Product logo

celo-lottery's Introduction

SavingsCELO

SavingsCELO is a fully fungible ERC-20 compliant representation for an interest bearing Locked CELO.

In human speak:

  • User deposits CELO in SavingsCELO contract to receive SavingsCELO (sCELO) tokens.
  • After some time passes, the user can return sCELO tokens to the SavingsCELO contract and receive more CELO back than they deposited.
  • While deposits are instant, retrievals are delayed by the unlocking period (3 days).
  • sCELO tokens can be transferred from one account to another without any restrictions and all sCELO tokens in circulation are equivalent to each other.

Smart Contract architecture

SavingsCELO.sol

SavingsCELO is the primary contract that manages deposits and withdrawals and implements the ERC20 standard for the sCELO tokens.

SavingsCELO contract is un-upgradable, but it does have an admin/owner with extra privileges:

  • Owner can authorize a contract that can vote on behalf of the Locked CELO that is stored in the contract.
  • Owner can also authorize a standard vote signer. This functionality exists mainly as an emergency hatch, in case there is some backwards-incompatible change in core Celo contracts that breaks regular proxy voting.
  • Owner does not have any privileges to transfer out any of the CELO locked in the contract. However, a malicious owner could potentially block withdrawals through complex steps of continuously creating new governance proposals and upvoting those proposals using CELO locked in the contract. Constant upvoting on these Governance proposals would essentially block withdrawals.
  • Final step for finalizing the SavingsCELO project is to transfer its ownership to GovernanceProxy (i.e. regular Celo governance).

SavingsCELOVoterV1.sol

SavingsCELOVoterV1 is the first version of the SavingsCELO voter contract. It supports voting for only one group at a time, and does not support any governance voting.

Owner/admin of SavingsCELOVoterV1 is called the "Group Manager" and is responsible for choosing the group that SavingsCELO votes for.

  • By default, the voted group will be the deployed SavingsCELOVGroup contract.
  • Group Manager can change the voted group in case of an emergency (i.e. if the currently voted group gets slashed, or if there is no longer enough CELO in the contract to keep the group elected)

SavingsCELOVGroup.sol

SavingsCELOVGroup implements a special type of validator group. The owner of this group is the same "Group Manager".

Group Manager has the following privileges:

  • Can deposit/withdraw/lock/unlock CELO for the group.
  • Can authorize a vote signer.
  • Can authorize a validator signer to manage group members and its commission.

Group Manager doesn't have access to the cUSD rewards. cUSD rewards that accumulate on SavingsCELOVGroup can only be converted to CELO and deposited back into SavingsCELO contract.

Usage

You can interact with the SavingsCELO contracts using a command-line interface.

> npm install -g celolottery@latest
> savingscli --help

SavingsCELO contracts are deployed on Baklava and Alfajores testnets too and savingscli supports interacting with those out of the box. Example:

> savingscli -n https://baklava-forno.celo-testnet.org --ledger-idx 0 balance

SDK - SavingsKit

celolottery npm package comes with the typescript libraries that can be used to easily interact with the SavingsCELO contracts. These libraries are based on @celo/contractkit. Checkout source for savingscli tool for example usage: src/cli.ts

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.