* Add user transfer authority to swap instruction
* Add user transfer authority to deposit all
* Add authority to withdraw all
* Add authority to deposit one
* Add authority to withdraw one
* Update fuzzer
* Add user transfer authority to JS
* Add extra check on instruction fuzz
* Refactor division
* Fix tests from fixed deposit math
* Fixup comments and cleanup fuzz
* Run fmt
* Address review feedback
* Fix JS test
* Add instructions to deposit / withdraw one token
* Run cargo fmt
* Fix clippy issues
* Add JS interface
* Add tests for new instructions
* Run prettier
* Rename deposit and withdraw
* Rename withdraw -> withdraw all in program
* Rename single token instructions
* Add offset curve
* Fix for math
* Add PreciseNumber
* Use Balancer formulation for trading token -> pool token conversion
* Add round-trip conversion testing
* Add offset curve to JS
* Run cargo fmt
* Update JS test numbers for new calcs
* Integrate review feedback
* Allow for withdrawals when one side is 0
* Run cargo fmt
* Disallow deposits for offset curve
* Run cargo fmt
* Allow for withdrawals through 0
* Add price parameter for flat / constant price curve
This encompasses a lot of changes to properly support the constant price
curve, and fixes some old pain points to make the whole thing easier to
use, including:
* refactor fees out of the curve
* move all fee calculations into new Fees type
* modify constraints to only care about curve types and fee
* add price parameter into constant price curve (flat curve)
* Run cargo fmt and clippy
* Revert interface changes and math update
* Run cargo fmt
* Address review feedback
* Fix fraction validation for zeros
* Add extra check
* Add extra check on init
* Run cargo fmt
* Clippy
* Add token program id check on unpack
* Run cargo fmt
* Add checks for program id ownership on swap account
* Add truncation check during swapping
* Run cargo fmt
* Update truncation to ceiling the value
* Run cargo fmt
* Fix JS test
* Refund back not needed source tokens
* Run cargo fmt
* Add swap_without_fees method to trait
* Fix merge problem
Co-authored-by: Justin Starry <[email protected]>
* Add mints to swap info
* Add mints to JS
* Add fee account in SwapInfo / init
* Add test for 0 fee, init test fully
* Add withdraw command interface
* Add fee accounts to swap instruction
* Add calculations for swap and withdraw fees
* Run cargo fmt
* Add new fees to JS and test
* Review feedback: fixup instruction doc and clone
* Update order of accounts in instructions
* Run cargo fmt
* Fix owner fee pool token calculation to include trading fee
* Add owner fees to flat curve, per request
* Fix instruction comment numbering
* Add more errors types for clearer calculation errors
Add a check for withdrawing from fee account
* Cargo fmt
* Pass TokenSwap state into the constructor to simplify function calls
* WIP: Update program to return token_program_id
* Add tokenProgramId to js TokenSwapInfo object
* Address pr comments
* Remove TokenSwapInfo and use loadTokenSwap as the primary way to fetch TokenSwap metadata
* Fix module.d.ts
* Address pr comments
* Clarification on comments
Co-authored-by: Yutaro Mori <[email protected]>
* token-swap: Add token supply in invariant calculation
* Refactor state classes into curve components for future use
* Align pool initialization with Uniswap using geometric mean of token
amounts
* Fix deposit and withdraw instruction to work as a proportion of pool
tokens
* Add math utilities to calculate the geometric mean with u64
* Improve variable names
* Use a fixed starting pool size
* Run cargo fmt
* Update js tests with new pool numbers
* Run linting
* Remove math
* Fix BN type issues found by flow
* Run `pretty` properly
* Add `build:program` like for spl-token
* Add TypeScript to CI
* snake_case -> camelCase variables
* Combine transactions on swap initialization
* Make instruction functions static
* Fix local token-swap tests
* Change generation of program address to use a nonce
* Accept nonce properly in initialization
* Include nonce in TokenSwap structure
* Fixup serialization with new parameter (padding used for now)
* Update dependencies
Update toml / lock files
Fix token swap initialization end-to-end
Cleanup unit test to use `find_program_address`
Add / refactor tests
Most importantly, added a special test to make sure that
token_program_id is provided at the end of CPI instructions, since
unit testing did not pick up that problem, and it was tough to debug
during end-to-end testing
* Revert some testing changes for PR
* Update token-swap/program/src/processor.rs
Co-authored-by: Tyera Eulberg <[email protected]>
* Integrate review comments
* Fmt and clippy
* Refactor for clippy
* Fmt again
* Fix npm lint error
* Clarify signers line as requested
Co-authored-by: Tyera Eulberg <[email protected]>