Commit Graph

128 Commits

Author SHA1 Message Date
Anurag Gupta 95cd64ce02
token-swap: Making Arc struct as Sync (#2896)
* box changed to arc

* Imported Arc in all files

* warnings removed

* Updated fuzz

* Removed useless Arc
2022-02-11 13:18:06 +01:00
Anurag Gupta 78e29e9238
token-swap: Changed Wrap SwapCurve's calculator field into Arc instead of Box (#2860)
* box changed to arc

* Imported Arc in all files

* warnings removed

* Updated fuzz
2022-02-03 20:22:51 +01:00
Tyera Eulberg 83c3ffad25
Bump solana crates to v1.9.5 (#2780)
* Bump solana crates to v1.9.5

* Update sol_set_return_data type signature and un-ignore test
2022-01-21 22:52:10 -07:00
Jon Cinque 81f50127f1
token: Bump version to 3.3.0 (#2765) 2022-01-21 01:47:02 +01:00
Peyton Randolph c5d73812cb
[token-swap] Upgrade PyO3 from 0.12.3 to 0.15.1 (#2673)
* Update PyO3 from 0.12.3 to 0.15.1

* run cargo fmt --all
2021-12-29 22:54:57 -05:00
Jon Cinque 6ee008d256
Update SDK to 1.9.2, fix warnings (#2674)
* Update SDK to 1.9.2, fix warnings

* Upgrade honggfuzz

* Use `get_latest_blockhash` correctly
2021-12-28 23:02:47 -05:00
Phạm Văn Dũng a6a1ce4290
fix account list in token_swap instructions docs (#2648) 2021-12-17 13:05:23 +01:00
Michael Vines 1a0155e34b Update to Rust 1.57.0 2021-12-09 23:56:47 -08:00
Jon Cinque f83240a868
token-swap: Prevent single deposits for curves that don't allow it (#2590) 2021-11-17 23:41:55 +01:00
Jon Cinque fcbc0d3501
token-swap: Add comment for stable curve A calculation (#2556) 2021-11-03 19:48:25 +01:00
Michael Vines 9acb082dc3 Upgrade to Solana v1.8.1 2021-10-20 22:52:19 -07:00
Michael Vines 12732f8d5a Upgrade to Solana 1.8.0 2021-10-12 09:40:06 -07:00
Jon Cinque 867417306a
token-swap: Use `find_program_address` on-chain during init (#2363) 2021-08-31 23:09:42 +02:00
Michael Vines 4406265d4a Upgrade to Solana 1.7.11 2021-08-30 12:41:08 -07:00
Tyera Eulberg 30fccebdc6
Bump solana crates (#2139) 2021-07-23 16:47:06 +00:00
Jon Cinque ddc029e14d
token: Bump to 3.2.0 everywhere (#2116) 2021-07-20 23:40:32 +02:00
Brian Anderson 8fbb54bf5f
Eliminate doc warnings (#2058)
* Add URL autolinks to docs in spl-math

* Autolink URLs in doc comments

* Surround 'account references' doc items with code spans to avoid warnings
2021-07-15 17:58:37 -05:00
dependabot[bot] 73e4e0c533
build(deps): bump enum_dispatch from 0.3.5 to 0.3.7 (#2017)
Bumps [enum_dispatch](https://gitlab.com/antonok/enum_dispatch) from 0.3.5 to 0.3.7.
- [Release notes](https://gitlab.com/antonok/enum_dispatch/tags)
- [Changelog](https://gitlab.com/antonok/enum_dispatch/blob/master/CHANGELOG.md)
- [Commits](https://gitlab.com/antonok/enum_dispatch/commits/master)

---
updated-dependencies:
- dependency-name: enum_dispatch
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-07-02 17:52:01 +00:00
Tyera Eulberg 0acc8c8bad
Bump solana and borsh crates (#2015) 2021-07-02 16:53:41 +00:00
dependabot[bot] c98e05fe37
build(deps): bump roots from 0.0.6 to 0.0.7 (#2009)
Bumps [roots](https://github.com/vorot/roots) from 0.0.6 to 0.0.7.
- [Release notes](https://github.com/vorot/roots/releases)
- [Changelog](https://github.com/vorot/roots/blob/master/CHANGELOG.md)
- [Commits](https://github.com/vorot/roots/compare/v0.0.6...v0.0.7)

---
updated-dependencies:
- dependency-name: roots
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-07-01 12:11:43 +00:00
Jon Cinque 21f8af34e7
Update all solana dependencies to 1.7.3, fix issues (#1958)
* 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
2021-06-25 00:39:08 +02:00
Tyera Eulberg e28af24443 Bump solana version 2021-06-14 16:02:27 -06:00
Jon Cinque de8433e815
ci: Split out test-bpf into separate workflows for each program (#1893)
* ci: Split token, token-swap, and token-lending out

* Remove token lending js in main runner

* token-swap: Update proptest to trigger build

* Remove unused Cargo.lock file

* lending: Update proptest to trigger lending build

* Fix lending test

* Try re-using action

* binary-oracle-pair: Bump token version to trigger build

* Reference action differently

* Add checkout step before local action

* Move out cargo test bpf step

* Add more programs

* Update example file to trigger job

* Update library file to trigger build

* Update name-service file to trigger build

* Update record file to trigger build

* Update shared memory file to trigger build

* Add pull request runners for each probram / library

* Fix pull-request yml file referencing unknown step
2021-06-11 22:35:00 +02:00
Jon Cinque 929dd59e50
token-swap: Fuzz all curves (#1796) 2021-05-25 22:10:31 +00:00
Jon Cinque 5f692a0b61
token-swap: Make single token withdrawal fair with better calcs (#1794)
* Separate deposit and withdraw single side calcs

* token-swap: Make single token withdrawal fair with better calcs

* Fix JS test calcs
2021-05-25 22:05:06 +02:00
akamutsu 4915c0910a
Implementation of stable curve methods (#1488)
* WIP: Implementation of the remainder of stablecurve methods

* Edits based on PR feedback

* revert SwapVersion

* PR fixes

* checked add / sub

* reverted to using RoundDirection instead of LiquidityProviderOperaiton

* removed LiquidityProviderOperation enum

* Revert flipped parameters

* initial attempt at noramlized_value

* use d for noramlize value for stable curve

* TradeDirection instead of RoundDirection for trading_tokens_to_pool_tokens

* reimplemented the trading_tokens_to_pool tokens function for stable

* Typo

* fix rounding errors in pool_tokens_to_trading_tokens

* try different values of amplification factor in test for stable curve

* fixed broken tests, use constant_product normalized_value function

* use cubic solver

* fix noramlize_value function bad maths

* redid noramlized value for one last time

* added more proptests

* Get tests to work

* Fixup for prod usage

Co-authored-by: Yutaro Mori <me@yutaromori.com>
Co-authored-by: Jon Cinque <jon.cinque@gmail.com>
2021-05-19 02:44:01 +02:00
Elliott Benisty 58221fc9ae
Fix potential vulnerabilities in programs using spl-token CPIs by adding program id checks (#1714)
* Add spl-token program id check helper function. Add program id to instruction bindings.

* Run cargo fmt

* Fixup tests

* Skip ATA tests when custom token program-id

Co-authored-by: Tyera Eulberg <tyera@solana.com>
2021-05-12 22:36:41 +00:00
Trent Nelson 1f36ca301b Bump solana crates to v1.6.7 2021-05-05 04:39:49 +00:00
Jon Cinque 0f4f2b8de9
token-swap: Fix slippage on withdraw tokens (#1637)
* token-swap: Fix withdrawal all tokens slippage

When withdrawing, the slippage check is done before `min`ing the token a
and b amounts, which makes it possible to ignore the desired slippage,
and lose out on a lot more than expected.

This has an additional knock-on effect. When burning all of the pool
tokens, it becomes impossible to ever use it again.

* Check for slippage after getting the actual amount that would be
  traded
* Re-initialize the pool token amount on the next deposit if all pool
  tokens were burned

Fixes #1629

* Fmt + clippy

* Deposit one side on 0 pool tokens just gives new supply back
2021-04-29 14:26:47 +02:00
Michael Vines 1e47030549 Update SPL to Solana v1.6.6 2021-04-23 13:39:51 -07:00
B 9281b6e828
feat: adjust fee constraints (#1596) 2021-04-14 13:33:34 -05:00
Jon Cinque e8f59e42ba
token-swap: Bump crate version to 2.1.0 for release (#1573) 2021-04-05 21:56:38 +02:00
Jon Cinque f309df4f35
token-swap: Update package version to match crates (#1561) 2021-04-01 20:53:59 +02:00
Michael Vines 448be67cfa Update to Solana 1.6.2 2021-03-30 09:38:04 -07:00
Jon Cinque d336b8b714
stake-pool: Use checked_ceil_div for withdraw calc (#1482)
* stake-pool: Use checked_ceil_div for withdraw calc

When a stake account is totally removed from a stake pool by the
manager, there's a chance that the operation would not take enough of
the manager's pool tokens by 1 due to truncation.

Do a ceiling division instead, and refactor ceiling division into the
math library.

* Use new function name on CLI

* Cargo fmt
2021-03-23 00:33:51 +01:00
Michael Vines 662f38f939 Bump Solana version to 1.6.1 2021-03-18 04:07:16 +00:00
Michael Vines 626376653d Clippy 2021-03-16 18:33:37 -07:00
Michael Vines 686444088b Bump Solana version to 1.5.15 2021-03-16 18:33:37 -07:00
Jon Cinque 9c12b50703
Update solana-program to 1.5.11 (#1362)
* Update solana-program to 1.5.11

* Update all programs
2021-03-02 19:19:50 +01:00
dependabot[bot] 5b4c62ce49
build(deps): bump solana-program from 1.5.6 to 1.5.8 (#1261)
Bumps [solana-program](https://github.com/solana-labs/solana) from 1.5.6 to 1.5.8.
- [Release notes](https://github.com/solana-labs/solana/releases)
- [Changelog](https://github.com/solana-labs/solana/blob/master/RELEASE.md)
- [Commits](https://github.com/solana-labs/solana/compare/v1.5.6...v1.5.8)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-02-17 23:56:18 +00:00
Trent Nelson 2316b6092e chore: token - bump version to 3.1.0 2021-02-11 16:30:03 -07:00
Trent Nelson 188c03e9a1 chore: bump solana crates to 1.5.6 2021-02-11 16:30:03 -07:00
Jon Cinque beb4aa7e7f
spl-math: Add separate package to test instruction usage (#1205)
* Refactor to use spl-math

* Run cargo fmt

* Fixup fuzz

* Add spl math program

* Add u64-based approximation

* Cleanup

* Downgrade solana sdk for CI

* Move U256 impl to stable curve

* Remove generic newtonian, use traits

* Cargo fmt

* Move math/program -> libraries/math

* Revert Cargo.lock changes

* Add u128 instruction count tests

* cargo fmt
2021-02-10 17:40:54 +01:00
Jon Cinque b26491552f
token-swap: Add version to state (#985)
* Add version to token swap state

* Fix fuzz

* Cargo fmt

* Revert solana localnet version

* Update enum dispatch
2021-02-04 15:22:33 +01:00
Jon Cinque d16da5b913
Update rust stable to 1.49 (and add token swap program id) (#1158)
* Update token swap program id

* Update rust stable to 1.49
2021-02-04 14:20:15 +01:00
Jon Cinque 40b7690a58
swap: Add rounding correction for deposit / withdraw (#1061)
* Add rounding specification for deposit / withdraw

The fuzzing test was improved to make sure that the value of pool tokens
(minus fees) never changed, which revealed a calc bug with deposits and
withdrawals.  If someone withdraws, they can take additional small
value out of the pool in the form of truncated value.

Before, deposit and withdrawal used the same calculation, rounding up the token
A and B amounts.  Remember that deposit / withdrawal specify the pool
token amount, and calculate the amount of A / B required to get to that
many pool tokens.  On withdrawal, we were giving back a little bit too
much.  The concept is that everything would even out since a deposit is
required for a withdrawal, which makes everything a wash.

Fuzzing found this issue very quickly! The change is to introduce a
rounding parameter to avoid ever giving away too much value, either
during deposit or withdrawal.

* Cleanup

* Add withdraw test

* Cleanup

* Cargo fmt

* Remove curve tests from fuzzing cfg

* Update JS test

* Cleanup test

* Update honggfuzz again

* Fix fee on JS test

* Force correct version of honggfuzz for CI (remove later)

* Improve value tests using PreciseNumber everywhere

* Fix ceiling

* Add comment for 0 tokens

* Fix ceiling div, add in constant price calc

* Revert ceiling division as template and use trait, too much boilerplate

* Run cargo fmt
2021-01-15 18:17:27 +01:00
Jon Cinque fd24042815
Pin honggfuzz to 0.5.52 (#1072) 2021-01-14 23:07:07 +01:00
Jon Cinque 7f17a140b1
swap: Avoid fuzz 1 token withdrawal errors by using fee account (#1058)
* Fix fuzz 1 token withdrawal errors with fee account

* Reintroduce special logic

* Cargo fmt
2021-01-12 13:57:58 +01:00
Jon Cinque 608b75a115
swap: Move transfers into user account to the end of instructions (#1047)
* Move transfers into user account to the end of instructions

* Run cargo fmt
2021-01-11 19:20:34 +01:00
Jon Cinque a86abe49cd
token-swap: Add user transfer authority (#1033)
* 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
2021-01-06 20:55:31 +01:00