Commit Graph

132 Commits

Author SHA1 Message Date
Yutaro Mori 9a7386be60
Add collect protocol fees helper method (#73) 2023-01-08 13:22:05 +08:00
meep 9da4bd4a7d
Fix understated collectRewardsQuote and unit-tests for new collect functions (#72)
- Do not append updateFee ix if liquidity is zero in collectFee & collectReward util fn
- Fix collectRewardQuote use an estimated rewardGlobal accrued till the current timestamp
- Fix unit-tests to strictly verify amount collected from collectFee, collectReward and closePosition
2022-12-26 17:33:44 +07:00
meep 6f4be811fc
Update typedocs & env setup for 0.7.2 (#71) 2022-12-21 17:28:10 +07:00
meep 5b488e9226
v0.7.2 (#70) 2022-12-15 10:46:20 +07:00
atamari 9dd0ee5cfd
Support wSOL in close position and deps (#68)
* Account for wSOL in close position and deps

* Remove unused imports

* Remove .only

* Remove debug code

* fix test expectation

* Comments for closePosition patch (#69)

* Better tests for closePosition, collectFees, and collectRewards

* remove unused

* remove console.log

Co-authored-by: atamari <atamari@orca.so>
Co-authored-by: Otto Cheung <otto@orca.so>
Co-authored-by: meep <33380758+odcheung@users.noreply.github.com>
2022-12-14 23:09:09 +04:00
yugure-orca d0a5852d9d
fix: getTickArrayPublicKeys edge case (#66)
* fix: getTickArrayPublicKeys edge case

porting "shifted" in in_search_range of on-chain programs.
https://github.com/orca-so/whirlpools/blob/main/programs/whirlpool/src/state/tick.rs#L299

- getTickArrayPublicKeys: if the swap direction is B to A and tickCurrentIndex is greater than or equal to the last initializable tick in the TickArray, the TickArray adjacent to the swap direction is TickArray0
- TickArraySequence: Change the logic to determine whether TickArray0 contains tickCurrentIndex

* fix: test case & setting

- set jest timeout to 30 sec (default timeout (5 sec) is too short)
- change "before" to "beforeAll"
    In jest there is no before, use beforeAll for one-time setups
    https://jestjs.io/docs/setup-teardown
- add refresh=true on getPosition
    When checking TickArrays that needs to be initialized, a "null" cache remains in the fetcher, and listing TickArrays for the position fails.
2022-12-09 22:06:36 +09:00
atamari 89a8762b1c
[SDK] Close Position, Collect Fees, Collect Rewards (#58) 2022-12-06 17:15:22 +04:00
meep 1e2990ea1d
Expose more data on PositionUtil for easier quote generation (#63)
- Add WhirlpoolData, TickArrayData to Position
- Change collect fee to use PositionData instead of Position
2022-12-06 07:37:50 +07:00
Phil Chen 811fc73641
Fix IDL import for BorshAccountsCoder (#65) 2022-12-05 10:49:44 +07:00
tmoc 7b469d2df6 v0.6.1 2022-12-02 13:40:07 +08:00
tmoc 8add3f8f03
Add getWhirlpoolsWithParams method (#61)
* Adding get whirlpools with params method in WhirlpoolClient and AccountFetcher

* Removing comment

* Exporting Whirlpool account coder

* Updating getPoolsWithParams to always fetch latest data

* Removing getPoolsWithParams from WhirlpoolClient, using BorshAccountsCoder memcmp

* Updating comments

* Removing unused import
2022-12-02 13:34:57 +08:00
meep e45744f7a0
Release version v0.6.0 (#64) 2022-11-25 20:33:56 +07:00
meep 900cfb38a5
Revert back to common-js (#62) 2022-11-25 13:19:41 +07:00
meep 0fe7bda4d6
Simplify resolveATA in the Whirlpool space (#60)
- Remove resolve-ata-ix from the Instruction set and classify it as a util fn
- Add getTokenMintsFromWhirlpools function to get all token mints from a set of whirlpools
- Convert original fn to resolveAtaForMints that depends on the common-sdk resolveOrCreateATA
2022-11-24 19:20:46 +07:00
meep 3c7b90c147
Add collectFeesAndRewardsForPositions to allow easy fee/reward collection (#57)
- Add collectFeesAndRewardsForPositions to WhirlpoolClient
- Add collectAllForPositionAddressesTxns to WhirlpoolIx
2022-11-24 15:37:41 +07:00
yugure-orca 8a7ed57bc5
fix: strict initialized checking at swapQuoteWithParams (#55)
* fix: strict initialized checking at swapQuoteWithParams

- removed checkIfAllTickArraysInitialized from swapQuoteWithParams
- added check to ensure that all TickArrays are initialized at getSwapTx
- In a TickArraySequence, uninitialized TickArrays are truncated.
- fix sqrtPriceLimit range check
- fix commitment issue in test code
- remove test "swap with a manual quote with dev-fee of 200%" (the code does not throw the exception)

* refactor: TickArraySequence

- remove Non-null assertion operator(!)
- use simple foreach loop and early break
- avoid name ambiguity (tickArrays to sequence)
- set constructor argument (tickArrays) to readonly

passed all tests (integration & sdk)
2022-11-24 15:13:59 +09:00
meep 61874e5c56
Fix build to unblock yarn link in dev environment (#56)
- Changing to ES6 build
- Add `process` to this build to unblock webpack 5 resolution
- Remove forced resolution of web3.js
2022-11-23 11:30:27 +07:00
atamari 571810579d
[SDK] Add `WhirlpoolClient.createPool()` (#53) 2022-11-18 13:04:45 +04:00
meep c8dd6ad3ed
Add getPositions function to WhirlpoolClient (#52)
Provide a new method to fetch many positions in a single RPC call
2022-11-17 10:32:43 +07:00
meep 2a077a7c8f
Remove async from decreaseLiquidityQuote (#51) 2022-11-17 10:23:49 +07:00
meep 4e72234a76
v0.5.3 (#49)
* v0.5.3
* Update yarn docs for new dev fee swap functions
2022-09-22 00:20:15 -07:00
FuzzyYeti 4c60463841
Add swap with dev fee to typedocs (#48)
Co-authored-by: Fuzzy Yeti <fuzzyyeti@github.com>
2022-09-21 23:59:56 -07:00
meep 3ed18b84c0
Release whirlpools-sdk 0.5.2 (#47) 2022-09-20 11:10:13 -07:00
meep 0f592f267b
Allow developers to take additional fees from a swap (#46)
- Add a new swapWithDevFees function in the Whirlpool client class
- Add new swapQuoteByInputTokenWithDevFees quote function
2022-09-20 11:03:53 -07:00
FuzzyYeti 1acd1469bd
Update protocol_fee_rate comment (#44)
Co-authored-by: Fuzzy Yeti <fuzzyyeti@github.com>
2022-09-04 08:46:50 -07:00
solbricklayer bb1b3c47bf
update anchor installation link (#39)
Old (not working): https://project-serum.github.io/anchor/getting-started/installation.html#install-rust
New (working): https://book.anchor-lang.com/getting_started/installation.html#anchor
2022-08-16 10:20:11 -07:00
skrrb e4cd6552e9
sdk tests: fix MAX_U64 const definition (#41) 2022-08-16 10:19:32 -07:00
tmoc d7cca71df8 v0.5.1 2022-08-10 14:52:24 -04:00
tmoc 16bca0ea1f
Implement batch getPools method (#42)
* Adding getPools method in SDK client

* Adding fetching of token vault infos to whirlpool retrieval

* Adding retrieval of reward infos

* Adding comment about empty pubkey constant

* Updating comments

* Using PoolUtil to check for initialized rewards

* Updating getRewardInfos comment
2022-08-10 14:50:02 -04:00
yugure-orca 8fc92ea1af
Change data type for liquidity and sqrtPrice to BN (#40)
* Changing variable type to BN to handle liquidity
- Change type of variables handling liquidity from u64 to BN
- Fix: removing "async" from describe. must be defined synchronously.
- Fix: using BN to calculate the max value of u64 (test-constants.ts)
- Fix: adding "await" to wait transaction completion(swap-test-utils.ts)

* Changing variable type to BN to handle sqrtPrice
- Change type of variables handling sqrtPrice from u64 to BN
- Refactor: changing argument name of getTokenAmountsFromLiquidity
  to clarify required price is sqrtPrice

Co-authored-by: yugure <98769788+everlastingsong@users.noreply.github.com>
2022-08-01 20:49:52 +09:00
Otto Cheung a5e7d82494 v0.5.0 2022-07-22 10:17:08 -04:00
meep 11f17bae53
Upgrade Anchor (Typescript) dependency to 0.25 (#38)
- Updating the Anchor SDK dependency
- API changes on the parameters on WhirlpoolContext & WhirlpoolClient
2022-07-22 09:47:32 -04:00
Otto Cheung c33740ed3a v0.4.0 2022-07-21 15:26:09 -04:00
meep 025fbffdf0
Update typedocs and comments for swap refactor (#37) 2022-07-15 10:10:49 -04:00
meep 2df89bb552
[SDK] Refactoring swap-quote (#30)
- More accurate quote values - ported the swap logic from contract & add comprehensive unit-test suite to confirm quote values are identical to contract results
- More info available in quote - endTickIndex, sqrtPrice, feeAmount etc...
- Additional swapQuoteFromOutputToken to allow users to ask for a quote (and swap input parameters) based on the desired receive amount
- Bug fix on TickArray calculation that led to the annoying 0x1787 (InvalidTickArraySequence) error
- Addresses all errors in the old-swap quote where it fails to traverse tick-arrays in many cases
- Bug fix on WhirlpoolClient.swap where it incorrectly uses the quote.estimated values rather than the user defined tokenAmount value
2022-07-15 09:49:21 -04:00
meep 5798af2e51
Update comments and re-run yarn docs (#33) 2022-06-29 17:16:01 -04:00
Otto Cheung 266241f99b v0.3.1 2022-06-29 16:18:54 -04:00
meep b922062ccb
Change param ordering for Position's resolveATA (#32)
- Change parameter ordering for resolveATA as it is the most important parameter
- Default resolveATA to true. Power users who do not want to ping RPC constantly can manually turn it off
- Fix up some comments
2022-06-29 15:51:18 -04:00
meep 4416732e33
Add resolveATA option for Position's increase_liquidity (#31)
- Add an option to auto-generate ATA to perform increase_liquidity for Whirlpool's position class
2022-06-29 15:22:14 -04:00
Otto Cheung 537306c096 v0.2.3 2022-06-21 11:36:09 -05:00
Otto Cheung 3bcd4ee391 upgrade common-sdk to 0.0.7 2022-06-21 10:52:56 -05:00
meep a3ee117669
Upgrade initTickArrayForTicks for WhirlpoolClient (#28)
- Method will auto-check which tick-array requires initialization
- Will generate a list of initTickArray Ix for a transaction
- Modify test to send initTickArray + openPosition together
2022-06-21 10:51:18 -05:00
Otto Cheung dfcda482ba v0.2.2 2022-06-13 16:26:54 -07:00
meep 7c8dce249e
Add PoolUtil swap direction & token type util functions (#27)
Add util functions to PoolUtil to help identify swap direction & token A/B for token mints
2022-06-13 16:24:03 -07:00
Otto Cheung 09ddd60a34 Revert unexpected PoolUtil commits 2022-06-13 16:20:16 -07:00
Otto Cheung 076b1fc49a add return types 2022-06-13 16:17:02 -07:00
Otto Cheung 2feb023309 Revert "rename the old swapdirection in swap-quote"
This reverts commit 479acf26a2.
2022-06-13 10:50:50 -07:00
Otto Cheung 479acf26a2 rename the old swapdirection in swap-quote 2022-06-13 10:45:30 -07:00
Otto Cheung efa9daa623 add tests 2022-06-13 10:31:20 -07:00
Otto Cheung 8f387e52c2 revisions 2022-06-13 10:11:33 -07:00