* Add browser build commands and documentation
* Improve rollup configuration
* Remove unused external import from rollup configuration
* Move from Babel to Typescript plugin
Co-authored-by: Jon Cinque <jon.cinque@gmail.com>
* stake-pool-js: Prepare package for release
* Upgrade node version for new npm
* Regenerate package-lock.json
* Update README, fix build to remove test files
People want to know more about the validator list, but there isn't too
much info provided.
* Include the validator list as an optional parameter to pool creation
* Print out the address during creation
* Always print out the address during `list`
* Add docs about it
* - fix "attempt to subtract with overflow" issue
* Update stake-pool/cli/src/main.rs
Co-authored-by: Jon Cinque <jon.cinque@gmail.com>
* Update stake-pool/cli/src/main.rs
Co-authored-by: Jon Cinque <jon.cinque@gmail.com>
* - run cargo fmt on it
Co-authored-by: Jon Cinque <jon.cinque@gmail.com>
If the stake pool gives over the validator stake account to the staker,
they may keep it and make it impossible to re-add that validator in the
future.
Split the whole amount into a new stake account on removal.
* fix
* add check if new manager fee is spl token program
* Convert manager fee info check to fail only inside `Result` box
* update also checks validity of manager fee info
* clippy
* deny set preferred validator if validator is about to be removed, add tests
* fix copy paste error
* only allow Active validators to be set to preferred validator
Co-authored-by: Jon Cinque <jon.cinque@gmail.com>
Co-authored-by: Jon Cinque <jon.cinque@gmail.com>
* rename staking instructions
* modify DepositStake te to include manager fees and referrer, continue _stake refactor, referral fees WIP
* initialize with fees, fee application, checks
* inline functions
* temporarily substitute u8 for bool until borsh gets it's * straight
* set deposit fee
* apply deposit and referral fee to liquid deposit_sol too
* add set-deposit-fee, unify cli interface
* set-referral-fee
* full feature set for liquid deposits (?)
* add tests/set_referral_fee.rs
* fix missing serialization in process_set_referral_fee
* remove duplicated test case in tests/set_withdrawal_fee.rs
* tests WIP, numbers dont add up after non-zero deposit fee
* fix error, fix tests
* deposit_sol tests. Requires additional changes to work properly
* simplify deposit_sol tests, add referral fee tests for deposit and deposit_sol
* add `sol_deposit_authority`.
* split deposit_sol() & deposit_sol_with_authority(), cli sol_deposit --from, minor cleanup
* cli deposit-sol from argument should take keypair instead
* commands: set-sol-deposit-authority, show
* cli: pretty print stake pool struct
* chore: comments/naming
* fmt, clippy
* add args for `create-pool`
* mistake in the cli
* `system_prog` is `read_only`, require sig from `stake_deposit_auth`
* change deposit-sol-authority arg to optional acount, rename instruction::withdraw->withdraw_stake, remove unnecesary sys_prog arg for withdraw_stake
* resolve simple nits and suggestions
* cli: change default referrer to user's token receiver account instead of pool manager
* cli: remove show command, add fees to list command, rename pool -> epoch
* update tests for removed unnecessary referral fee account owner check and deposit sol
* cli changes: create ephemeral account for deposit_sol
* specify pool token type for account info name
* add check for manager fee acc in deposit_sol
* Apply suggestions from code review
Co-authored-by: Jon Cinque <jon.cinque@gmail.com>
* fix non-rebased bug
* SetDepositStakeAuthority
* refactor + tests + cli
* fmt
* clippy
* remove unnecessary comment
* ASK keyword
* unset deposit auth
* combine set fee instructions
* clippy
* applying suggestions
* apply out-of-date check only for FeeTypes that need it
* add fee + user = new tokens check
* Fix test
* Unify `SetDepositAuthority` instruction
* fmt
Co-authored-by: dhy1996 <dhy1996@live.com.sg>
Co-authored-by: Jesse Y. Cho <f8122dac91@gmail.com>
Co-authored-by: Jon Cinque <jon.cinque@gmail.com>
* Add ATA for pool fee account and more pool info
* stake-pool-cli: Integrate user feedback
* Add more output for `list` command, `-v` gives more info
* Default to the manager's associated token account when creating a pool
* Fix signer parameters (staker, manager, depositor, fee-payer, and
token-owner)
* On deposit / withdraw / add / remove validator, show the validator
stake account and where the stake is going to
* Update all dependencies to 1.7.3, fix issues
* Remove esm from mocha
* Fix missed token test
* Also update rust version
* token-swap: update tolerance on sim test
* Run `cargo clippy --fix` for needless_borrow errors
* Rerun cargo fmt
* first commit
* add schema for stakepool accounts
* got imports working
* add typescript support
* fix schema
* Change to use PublicKey type
* change to camelCase instead
* add type annotations to typescript classes
* add readme
* Add prettier linting
* add instructions to run
* add test section
* prettier clean up schema.ts
* convert index.js to index.ts
* actually use decode method available in Assignable
* rename stakepoolaccount so i can have a wrapper class
* add new class StakePool and change return type of getStakePoolAccounts
* remove extraneous .js files
* update schema to incorporate jon's comments
* remove unnecessary comments
* add helper functions to get individual accounts; cleaned up code
* add Fee, change denominator/numerator to BN
* Add enums so we can check what type an accountType is
* Remove name and ticker in StakePool class
* fix borshjs import
* change outdir to dist/ folder
* Edit package.json
* add toBuffer for schema.PublicKey
* add exports and default exports to index.ts
* fix trailing comma on tsconfig.json
* get mocha test harness working with ts-node, ts-mocha, esm
* fix borsh import
* clean up imports
* add working test script
* remove unneeded borshjs import
* add unit tests for both decodes (WIP)
* no need to console.log in testOnDevnet since we now have a test suite
* Add tests for ValidatorListAccount.decode
* add schema.decode.StakePoolAccount test
* Finish up
* reduce dependencies in package.json
* Add lint command to package.json
* Lint with prettier
* Update README.md with new commands
* Write explanatory comments in index.js
* Small linting change
* feat: introduce new borshjs deserializeUnchecked import
* lint: npm lint
* refactor: upgrade web3js version
* refactor: refactor type names
* refactor: npm run lint
* refactor: improve tsconfig.json
* feat: add declaration and declarationMap to tsconfig.json
* feat: allow getStakePoolAccounts to more robustly handle errors
* Update stake-pool/js/.gitignore
Co-authored-by: Jon Cinque <jon.cinque@gmail.com>
* Update stake-pool/js/package.json
Co-authored-by: Jon Cinque <jon.cinque@gmail.com>
* Update stake-pool/js/package.json
Co-authored-by: Jon Cinque <jon.cinque@gmail.com>
* Update stake-pool/js/package.json
Co-authored-by: Jon Cinque <jon.cinque@gmail.com>
* Update stake-pool/js/package.json
Co-authored-by: Jon Cinque <jon.cinque@gmail.com>
* refactor: modify `constructStakePoolSchema` to mutate in place
* lint: remove webpack.config.js
* lint: npm run lint
* lint: add comments above index.ts
* lint: lowercase schema
* feat: add full deserialization test
* Update stake-pool/js/package.json
Co-authored-by: Jon Cinque <jon.cinque@gmail.com>
* refactor: remove try-catch block in getStakePoolAccounts
* lint: lint
* refactor: use web3js pubkey
* refactor: move integration tests to separate file
* refactor: change test.js to do encode-decode loop
Co-authored-by: Jon Cinque <jon.cinque@gmail.com>
* stake-pool: Add ability to withdraw from transient stakes
It's possible for a very malicious pool staker to constantly increase /
decrease the stake on validators, making it impossible for people to get
their SOL out.
Update the accounting to know how much of the stake is active and how
much is transient and allow users to withdraw from transient accounts,
but only if there's no more active stake.
* Remove mut ickiness
While going back through the docs, I ended up doing a lot of the stake
pool CLI items:
* Deposit / withdraw command: Use associated token account by default
* Create command: Allow passing the stake pool and mint keypair (useful
for testing)
* Create command: Split the transaction for pool creation (required to get under the
transaction size limit)
* Add / remove validator command: take a validator vote account rather than stake
account, which makes integration from outside tools a lot simpler
* Update command: add a `--force` flag to force the update
* Update command: add a `--no-merge` flag to not merge while updating
(useful to allow the pool to work, even if the transient stake
accounts are unmergeable)
* Withdraw: Add `--use-reserve` flag to withdraw from reserve
* Withdraw: Add `--vote-account` arg to specify which validator to
withdraw from
The stake pool expects pool tokens to be delegated to the withdraw
authority before performing a withdrawal. If a user delegates too many
tokens to the withdraw authority, anyone else can take the rest of their
tokens by doing their own withdrawal.
Delegate pool tokens to an ephemeral keypair and sign with that.
* stake-pool: Add depositor key on init, required on deposit
Some stake pools need to be private, and not allow outside depositors.
Enhance the existing deposit authority in the stake pool be configurable
on initialization, and then require its signature on deposit.
The existing deposit authority is a program address, making deposits
permissionless. This allows a pool creator to set their own deposit_authority on
initialization. In a great turn of events, almost everything else works
the same way!
Here's the current workflow for deposit, where the user calls
stake_program::authorize and stake_pool::deposit in the same
transaction:
* stake_program::authorize assigns staker and withdraw authority to the
stake pool deposit authority
* stake_pool::deposit
- uses the deposit authority to assign authority on the deposited
stake account to the stake pool withdraw authority
- uses the withdraw authority to merge the deposited stake into the validator stake
The deposit authority must "sign" the transaction in order to reassign
authority to the withdraw authority. Currently, as a program address, it
can just do that. With this change, if the deposit authority is set
during initialization, then that deposit authority must sign the
instruction.
There's also a little update for ease-of-use to always do the
stake_program::authorize in the same transaction as stake_pool::deposit.
This way, in case someone tries to deposit into a forbidden stake pool, the
whole transaction will bail and their stake will stay as theirs.
* Address review feedback
* Fix rebase issues
* Add check for transient stake account activation on removal
* Add proper merging logic during update
* Format + clippy
* Add max possible validators
* Disallow removal for any transient stake state
* Reduce number of accounts for BPF instruction usage