@swim-io/solana-contracts
TypeScript icon, indicating that this package has built-in type declarations

0.40.0 • Public • Published

Swim.io Pool Programs written in anchor

Development

If any changes are made to the smart contract that would require regenerating the idl run the following command from the swim-anchor directory and update any relevant sdk related code yarn run idl

Scripts (WIP)

Testing scripts on localnet

# for localnet testing
yarn run prep && anchor localnet --skip-build

anchor run initialize_pool
# copy address of pool into localnet_config.json

Run scripts on devnet

# for devnet
yarn run prep:devnet && anchor run --provider.cluster initialize_pool

Tests

  1. to run the tests in sdk/tests run any of the following from package/swim-anchor
yarn run test:propeller
yarn run test:pool
yarn run test

Troubleshooting

  1. if running into an error like this
FetchError: request to http://localhost:8899/ failed, reason: connect ECONNREFUSED 127.0.0.1:8899

check your npm version. npm lts/gallium (v16.15.1 as of this writing) works but v18.4.0 hits this issue

Deployment

anchor deploy --provider.cluster devnet --program-name two-pool --program-keypair ~/work/swim/keypairs/devnet/pool_restructure/two_pool_anchor.json

To Dos

  1. update yarn idl cmd once propeller is added to monorepo so that idl artifacts are generated into the correct directory for each program
  2. adjust visibility of imports/crates to only expose what's needed
  3. enhance lp metadata tests with mpl js storage mock logic
  4. anchor can't handle nested custom structs for inputs into ixs.
    1. look into using just u32 for lp_fee, gov_fee for ix inputs represented as pips
  5. Might have to think about seeds used to initialize pool PDA.
    1. not sure if susceptible to pda sharing exploit
      1. don't think so since as part of the process to initialize the pool pda, you need to initialize the lp_mint so, we should be safe from anyone being able to initialize another pda ("share" it)
    2. to be safe, could alternatively create pool token accounts prior to the InitializeInstruction, then use those as seeds for the pool state pda. that would be closer to secure solution from exploit docs
  6. maybe add a version field to TwoPool state (and seeds to derive pda)
    1. look into if versioning still worth it since accounts can now be re-allocated.
  7. rust documentation & documentation testing
  8. re-implement two pool fuzzing

Readme

Keywords

none

Package Sidebar

Install

npm i @swim-io/solana-contracts

Weekly Downloads

1

Version

0.40.0

License

none

Unpacked Size

883 kB

Total Files

20

Last publish

Collaborators

  • nicomiicro
  • arvakr
  • wormat