GithubHelp home page GithubHelp logo

ido-pool's Introduction

IDO Pool

This example provides an IDO mechanism that prevents giving "free money" to the quickest bidder. The IDO is selling a fixed amount of ๐Ÿ‰ tokens, guarantees the same price for every user and has three phases:

  1. Users can freely deposit and withdraw ๐Ÿ’ต tokens into the pool.
  2. They can only withdraw ๐Ÿ’ต tokens.
  3. They can only withdraw ๐Ÿ‰ tokens pro-rata to their share of deposited ๐Ÿ’ต tokens to the total amount deposited by all users.

The first two phases should last at least 24 hours each, the last one is unlimited.

Setup

  1. Install dependencies and run the tests to verify it's all working. If you are new to anchor you might want to check out the official guide.
npm install
anchor test
  1. Create 10 ๐Ÿ‰ tokens and 1000 ๐Ÿ’ต tokens for testing:
spl-token create-token --decimals 6
spl-token create-account $MINT_MELON
spl-token mint $MINT_MELON 10 $ACC_MELON

spl-token create-token --decimals 6
spl-token create-account $MINT_USDC
spl-token mint $MINT_USDC 1000 $ACC_USDC
  1. Deploy the contract and initialize it with 10 ๐Ÿ‰ tokens. For testing purposes this pool will only accept deposits for 5 minutes and withdrawals for one more minute afterwards. The default value for both parameters is 24 hours:
anchor launch
node cli/index.js init $MINT_USDC $MINT_MELON $ACC_MELON 10 --deposit_duration 300 --cancel_duration 60 --withdraw_duration 180
  1. Bid 100 ๐Ÿ’ต tokens. But first create an account to receive the redeemable pool token, that will allow you to receive ๐Ÿ‰ tokens in phase 3. You can increase or reduce your bid, by calling bid again.
spl-token create-account $MINT_REDEEM
node cli/index.js bid $ACC_POOL $ACC_USDC 100 $ACC_REDEEM

Configuration

To use the cli on other clusters than localnet set the env variable CLUSTER_RPC_URL=https://api.devnet.solana.com

ido-pool's People

Contributors

mschneider avatar sssrot avatar

Stargazers

 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.