Giter VIP home page Giter VIP logo

pool's Introduction

Pool Program

Rust smart contract for Solana liquidity pools with variable token number.

Building

To build the Pool program, use the normal build command for Solana programs:

cargo build-bpf

Deployment

To deploy the pool program:

  1. Check that the TOKEN_COUNT const is set to the number of constituent tokens you want the pool program to initialize
  2. Build the program:
cargo build-bpf
  1. Deploy the program using:
solana program deploy --program-id <path_to_keypair> ./target/deploy/pool.so
  1. To adjust the number of constituent tokens for the Pool Program, adjust the TOKEN_COUNT const in src/lib.rs then rebuild and deploy the program to a new program_id

Audits and Security

Audit scheduled, starting ~Nov 1st 2021

Mainnet Deployments

Pools with 4 Tokens: SWiMBJS9iBU1rMLAKBVfp73ThW1xPPwKdBHEU2JFpuo

Pools with 6 Tokens: SWiMDJYFUGj6cPrQ6QYYYWZtvXQdRChSVAygDZDsCHC

Running Tests

cd swim/pool
# run all tests
cargo test-bpf -- --show-output
# run all tests with suppressed noisy logs
cargo test-bpf -- --show-output --nocapture --test-threads=1 2>&1 | ./sol_spam_filter.py
# run specific test
cargo test-bpf -- --test test_pool_init --show-output

Fuzzing

The honggfuzz library is incompatable with macOS big sur and above (as of 11/01/2021). The workaround is to run the fuzzing tests within a docker container and was based on the solution found here

How to run fuzz tests on mac os x in docker container

# 1. build docker container (only have to do this one time)
$ docker build -t pool .
# 2. run docker container
# $ docker run -it --security-opt seccomp=unrestricted -v $(pwd):/app/ pool bash 
$ docker run -it --privileged -v $(pwd):/app/ pool bash 
# should be in the docker container now
$ cd fuzz
$ BPF_OUT_DIR="/app/target/deploy" HFUZZ_RUN_ARGS="-t 100 -N 1000 -Q  " cargo hfuzz run pool_fuzz 
# redirect output to files
$ BPF_OUT_DIR="/app/target/deploy" HFUZZ_RUN_ARGS="-t 100 -N 500 -Q -d -v" cargo hfuzz run pool_fuzz > test_output.txt 2>&1
# -t = timeout in seconds
# -n = number of threads
# -N = number of iterations
# --exit_upon_crash

# run fuzz debugger 
# file for fuzz can be found in /app/fuzz/hfuzz_workspace/pool_fuzz/HONGGFUZZ.REPORT.TXT
$ BPF_OUT_DIR="/app/target/deploy" cargo hfuzz run-debug pool_fuzz 'hfuzz_workspace/pool_fuzz/SIGABRT.PC.7f3088fedce1.STACK.19a84c71ce.CODE.-6.ADDR.0.INSTR.mov____0x108(%rsp),%rax.fuzz'

Troubleshooting

If you encounter the following error during the docker build or docker run stage, in Docker Desktop go to "Preferences" -> "Resources" and increase the memory and swap then retry again:

"fatal error: ld terminated with signal 9"

Disclaimer

Use at your own risk. Swim Protocol Foundation, and its representatives and agents disclaim all warranties, express or implied, related to the application you are accessing, and are not liable for any transactions you conduct thereon or losses that may result therefrom. US Persons are not permitted to access or use this application.

pool's People

Contributors

darwhin avatar swimivan avatar swimricky avatar wormat 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.