* 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
* stake-pool: Separate manager from owner
* Add manager pubkey to stake pool
* Differentiate manager functions from owner functions
* Include a `set_manager` function to be used by the owner
* Change the term `owner` to `authority` in the CLI for clarity
* Rename manager -> staker and owner -> manager
* Split staker, manager, and token owner in CLI
* "Do not disturb the boss"