Skip to content

Latest commit

 

History

History
84 lines (57 loc) · 5.13 KB

README.md

File metadata and controls

84 lines (57 loc) · 5.13 KB

Wrapped Casper ERC20

Implementation of ERC20 standard, representing wrapped version of CSPR (native token of Casper Network).

Demo: https://www.loom.com/share/c52424ee09944fa6b8e6716c369b9496

Design

The Wrapped Casper contract allows users to interchange CSPR and WCSPR in a 1:1 ratio and vice versa.

It gives users option to trade and swap CSPR easily for other ERC20 tokens, and it allows users to get CSPR in exchange of ERC20 version of itself. WCSPR being represented on Decentralized, Centralized or peer-to-peer cryptocurrency exchanges will give users fast access to CSPR. So it could be used to cover user's need to pay tx's fees or to delegate native tokens for example.

To receive WCSPR users will transfer any amount of CSPR to contract's main purse and same amount of new WCSPR tokens would be minted and balanced to user. That operation cycle called deposit. To recieve CSPR users will specify amount of WCSPR to exchange and that value will be deducted of their balance and burned. That operation cycle called withdraw.

The Wrapped Casper contract holds CSPR on it's main purse, that could be withdrawn any time in exchange of WCSPR (ERC20). In case that every ERC20 mint and burn transactions are accompanied by CSPR transfer it is impossible to met situation when amount of WCSPR will exceed deposited CSPR amount. It means that there is no limit on withdrawals could exist. At the same time there is no limit on deposit for CSPR. Finaly total_supply will represent amount of deposited CSPR tokens. Everything mention above means that any loss of WCSPR tokens will lead for endless lock for a same amount of CSPR tokens inside of the contract, what will have a positive effect on CPSR price.

The Wrapped Casper contract is built with ERC-20 standard implementation for Casper Network from CasperLabs and uses it's sample ERC20 contract. Functionality of WCSPR implemented in two main entry points deposit and withdraw, one support entry point init and additional pre_deposit contract.

Deposit

Deposit operation starts from calling additional pre_deposit contract, that alows to initiate CSPR (native token) transfer. At that point specified amount of CSPR will be transfered from the main purse of a caller to a temporary_purse. After the main contract would be called by deposit entry point, passing temporary purse reference, that holds CSPR token. On that stage CSPR would be transfered from temporary purse to contract main purse. Once contract main purse will recieve deposited amount of CSPR, new WCSPR token would be minted in the adress of the caller.

It describes whole cycle of deposit operation for the Wrapped Casper contract. That wraps user's CSPR token into WCSPR token of ERC20 standard.

Withdraw

Withdraw operations starts from calling withdraw entry point of the Wrapped Casper contract. Initially a user's address would be checked for sufficient WCSPR balance. Specified amount of CSPR tokens would be send to the user. Exactly the same amount of WCSPR tokens would be burn from the user's balance.

It describes whole cycle of withdraw operation for the Wrapped Casper contract. Finaly it unwraps user's WCSPR tokens into CSPR tokens.

ERC20 standard functionality

Sample ERC20 project includes next entry points (functions):

  • name: provides token name
  • symbol: provides token symbol
  • decimals: provides token decimals
  • balance_of: provides account balance for requested adress
  • transfer: executes transfers of a specified amount of tokens to a recipient address
  • approve: allow a spender to transfer a set amount of tokens from a caller account
  • allowance: provides a set number of tokens that spender allowed to transfer from owner's account
  • transfer_from: executes transfers of a specified amount of tokens from a specified owner's address to a recipient address
  • total_supply: provides information about the current total token supply

Possible updates

  • Exclude possobility to specify contract address as recipient for WCSPR token transfers.

Interaction

WCSPR is represented on PicaSwap DEX (currently on Casper testnet).

WCSPR frontend and PicaSwap source codes could be reached here: https://github.com/PicaSwap/Picaswap

Roadmap

Q4 2021

  • Casper Association audit
  • Required enchances and updates
  • Additional changes
  • Final tests
  • Final Casper Association audit
  • Mainnet release on http://www.picaswap.io/

The Friendly Hackathon: Start Building On Casper!

Project is participant of Open topic bounties.

Initially we applied WCSPR project for Open topic: Intermediate Experience Level. Finishing it we found that implementation respresents higher level solution. And we applied for Open topic: Advanced Experience Level as well.

Final version of the submission contains: a smart contract, tests for it and front-end part, that alows users to interact with ERC20 version of Casper Token live on test-net.