Code Monkey home page Code Monkey logo

quarkchain-contracts's People

Contributors

dependabot[bot] avatar freshmanq avatar hanyunx avatar jishankai avatar jyouyj avatar ninjaahhh avatar qizhou avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

quarkchain-contracts's Issues

Support pool admin to adjust fee rate

because of PoSW lockup, it's possible that malicious miner will keep mining and not release stakers' funds. having a pool admin who can adjust the fee rate can mitigate this problem:

  1. a staker deploys the contract and sets the pool admin as himself/herself, then find other stakers and a miner to join. if the miner does't want to release the stakes, the pool admin should adjust the fee rate to 0 such that the miner won't get block rewards going forward; if the pool admin has bad intentions and sets the rate to an unreasonably high value, the miner can withdraw the hash power at any time. note that social consensus is needed if any staker wants to withdraw stakes during the mining, and it's up to the miner and stakes to discuss how the process should go (e.g. can withdraw every week / month while the miner stops mining temporarily)
  2. on the other hand, the miner can deploy the contract setting the pool admin to zero address, which means the fee rate is fixed. then the stakers must trust the miner to be able to withdraw the stakes

Update new token auction start/end mechanism

instead of explicitly calling start and end, we want to have a more autonomous approach

  1. supervisor (could be DAO in the future) sets the parameters
  2. the first bidder's action (bid) will automatically start the auction process, until duration is reached
  3. once ended, a new bid or an explicit call to end the auction will finalize the results of last round of auction

Testing scenario

unit tests should be under test folder

for auctioning new tokens:

  1. start an auction, one person bids, auction ends, he wins
  2. start an auction, one person bids, another person bids with a lower price, should fail
  3. start an auction, one person bids, another person outbids auction ends, the other guy wins
  4. start an auction, one person bids, another person places a bid at last minute before end time, the auction is extended. When the auction ends, the last bidder wins.
  5. (more to come)

for gas reserves:

  1. first time adding reserve should succeed
  2. adding more QKC to the reserve should succeed
  3. another person requests to have a higher exchange rate, should succeed
  4. another person requests to have a higher exchange rate, but doesn't have any QKC, should fail
  5. (more to come)

for how to write contract tests, this is a working example

feel free to add other test cases
cc @qizhou

Suggest to use uint256 for stake field

I see a lot of conversion from uint256 to uint128. Although it should be generally safe to convert as we have up to 1e28 tokens (about 2**93), but the conversion will succeed even such conversion may result in data loss.

Notice that changing to uint256 will add extra gas cost to adding and withdrawing stakes (I think it is about 5000 or 20000).

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.