Code Monkey home page Code Monkey logo

snapshot-strategies's Introduction

Snapshot strategies

Development

Install dependencies

yarn

Build package

yarn build

Test strategy with predefined tests (params from examples.json file)

Note: If you're writing a new strategy, make sure to add it to strategies/index.ts before testing*

# Test default strategy (erc20-balance-of)
yarn test
# Test strategy with name
yarn test --strategy=erc20-received
yarn test --strategy=eth-balance
# Test with more addresses from addresses.json
yarn test --strategy=eth-balance --more=200

Test validation with predefined tests (params from examples.json file)

yarn test:validation --validation=basic

Test strategy with different parameters

Change values inside test/scores.ts and run

ts-node test/scores.ts

Checklist for adding a new voting strategy or validation strategy

Here is a simple checklist to look at when reviewing a PR for a new strategy:

Overview

  • The strategy must be unique.
  • If the strategy does only a single call with an address as input, it's preferable to use the strategy "contract-call" instead of creating a new one.
  • For validations better to use basic validation and use existing strategies

Code

  • Strategies should always use a snapshot to calculate user's voting power. As a result the voting power should not change throughout the proposal duration.
  • There should be a maximum of 5 requests, a request can use "fetch" a "subgraphRequest" or "multicall".
  • The strategy should not send a request for each voters, this doesn't scale.
  • The strategy PR should not add any new dependency.
  • The score returned by the strategy should use the same casing for address as on the input, or should return checksum addresses.
  • Make sure that voting power of one address does not depend on other addresses.

Example

  • Example must include at least 1 address with a positive score.
  • Example must use a snapshot block number in the past.

Test

Recommended

  • Add a README.md file that describes the strategy and provides an example of parameters.
  • Use string ABI instead of object.

License

MIT.

snapshot-strategies's People

Contributors

renovate[bot] avatar chaituvr avatar github-actions[bot] avatar bonustrack avatar samuveth avatar onigiri-x avatar clement-ux avatar candoizo avatar espendk avatar buchaoqun avatar alberthaotan avatar trizin avatar qyuqianchen avatar wa0x6e avatar andytcf avatar rahulrumalla avatar andreibadea20 avatar mantisclone avatar joehquak avatar mktcode avatar vladanthales avatar jarrodlilkendey avatar vatsalgupta13 avatar sergerad avatar maxaleks avatar sirgawain0x avatar chef-jojo avatar 0xbutterfield avatar pepperstepper avatar johnmark13 avatar

Watchers

 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.