- 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
* 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.
- 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
* 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)
* 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>
- 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
- 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
- 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