-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🐛 Improvement & Bug Fixes #25
Conversation
Pull Request Test Coverage Report for Build 4224359399Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
@GabrielePicco FindWhirlpoolAddress
tickSpacinghttps://github.com/orca-so/whirlpools/blob/main/sdk/tests/utils/index.ts WSOL/ATAI have not been able to check the entire test case, but I think that ATAs were created with the pool when it was created and is always present. If the following flow can be processed without any problem, it is OK!
|
Fix open/increase/decrease/collect/close with closed atas and added tests for native mint
Thanks @yugure-orca , those cases indeed identified some issues that I corrected. FindWhirlpoolAddressAdded more information in the returned pool. The method now return a pool object with: Address, TokenMintA, TokenMintB, Liquidity, Fee, TickSpacing Renamed all spacing to literals to avoid any assumptionpublic struct TickSpacing Added several tests to check the described cases and fixed issues
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have made minor comments where relevant to ATA.
Since there are many changes in this PR, it would be acceptable to address them in subsequent PRs (IMO).
Especially since the ATA part is a behind-the-scenes job that does not affect the interface.
Thanks @yugure-orca for the comments, I included the latest changes & fixes. Merging in master and releasing version 1.0 🚀 |
Include changes from https://gist.github.com/yugure-orca/dfc8027455b2db8bdb2bac4cf255acad
Problem
See https://gist.github.com/yugure-orca/dfc8027455b2db8bdb2bac4cf255acad for detailed description
Discussion
Solana.Unity.Dex/IDex.cs
Swap
Isn't amountSpecifiedTokenType almost the same role as inputTokenMintAddress?
The typescript-SDK's amountSpecifiedIsInput is used to switch between ExactIn and ExactOut modes.
In ExactOut, you can specify that you want to swap to get 500 USDC.
👉This mode is especially important for payments, and should be used more often for in-game currency exchange.
Solution
OpenPositionWithLiquidity
I seem to recall an error when including an instruction to initialize a TickArray and an instruction to use a TickArray in the same transaction.
I think this is an Anchor issue, but if it happens in testing, the current workaround is to separate the transactions and execute them serially.
Comments
Doesn't seems to be the case, the two test cases that open and increase liquidity in one transaction are passing.
OpenPositionWithLiquidity & IncreaseLiquidity
If the methods only receive tokenMaxA and tokenMaxB, the concept of slippage will no longer exist.
It may be necessary to either receive quote or liquidity as well.
Solution
UpdateFeesAndRewards & UpdateAnd...
IncreaseLiquidity also use
tickArrayLower
andtickArrayUpper
, but it do not accept them.I think it is possible to get from the position.
Solution
CollectRewards
rewardMintAddress
andrewardVaultAddress
should be known from the pool data.Compared to other methods, this argument seems to show low-level processing.
Solution
rewardMintAddress
andrewardVaultAddress
from the pool dataGetSwapQuote
Comment summary is the same as GetSwapQuoteFromWhirlpool?
Is it a method to find or route a Whirlpool?
Solution
FindWhirlpoolAddress
There is a restriction on the order of tokenMintA and tokenMintB: SOL/USDC but not USDC/SOL.
We can either ask the user to enter tokenMintA and tokenMintB in this order, or we can find the pair without distinguishing between A and B.
Maybe the later is beginner-friendly.
Comment
The TryFindWhirlpool internally is already trying to find a pool for the reverse token mints, in case of failure with the given tokens order.
GetTokenBySymbol
Symbol is fine, but I think ByMint is safer, since it can be duplicated or changed (e.g. BTC to soBTC).
Solution
missing? : FindPositions
I think that devs need a way to get a list of positions held by users.
https://github.com/everlastingsong/tour-de-whirlpool/blob/main/src_localization/EN/041_get_positions.ts
Solution
General
commitment
I think that it is OK to take a default value of commitment from RPCClient.
If the default value is
Finalized
, many will specifyConfirmed
orProcessed
on each call.Because
Finalized
takes approx 10-15 sec.Solution
tickSpacing
https://github.com/garbles-labs/Solana.Unity-Core/blob/master/src/Solana.Unity.Dex/Ticks/TickSpacing.cs
It's hard to name, but a stable pool like USDC/USDT has tickSpacing 1.
I think the most general-purpose and usable tickSpacing is 64 (0.3% fee).
I think tickSpacing 128 (1% fee) is for more volatile tokens.
Comments
Happy to rename, but shouldn't we stay consistent with naming defined here: https://github.com/orca-so/whirlpools/blob/main/sdk/tests/utils/index.ts ?
Bugfixes
PR#66: orca-so/whirlpools#66
https://github.com/garbles-labs/Solana.Unity-Core/blob/master/src/Solana.Unity.Dex/Orca/Swap/SwapUtils.cs#L74
Solution
DecimalUtil
👉In my experience, Solana newbies get confused with Decimals. I think it would be good to have a utility for u64/Decimal conversion.
https://github.com/orca-so/orca-sdks/blob/main/packages/common-sdk/src/math/decimal-util.ts
Solution
ATA for Wrapped SOL
I think it would be better to specify somewhere that the ATA for Wrapped SOL can be closed.
Solution
Orca/Orca/OrcaDex.cs
L67
https://github.com/garbles-labs/Solana.Unity-Core/blob/master/src/Solana.Unity.Dex/Orca/Orca/OrcaDex.cs#L67
amountSpecifiedTokenType, tokenAuthority are not used
Solution
L114
https://github.com/garbles-labs/Solana.Unity-Core/blob/master/src/Solana.Unity.Dex/Orca/Orca/OrcaDex.cs#L114
&& swapQuote.BtoA ?
Solution
L334
https://github.com/garbles-labs/Solana.Unity-Core/blob/master/src/Solana.Unity.Dex/Orca/Orca/OrcaDex.cs#L334
Cannot close if fees or rewards remain
https://github.com/orca-so/whirlpools/blob/main/sdk/src/impl/whirlpool-impl.ts#L448
Solution
L353
https://github.com/garbles-labs/Solana.Unity-Core/blob/master/src/Solana.Unity.Dex/Orca/Orca/OrcaDex.cs#L353
If only max is specified, there is no room for slippage to be set.
If there is even a slight price movement, it will fail.
Solution
L647
https://github.com/garbles-labs/Solana.Unity-Core/blob/master/src/Solana.Unity.Dex/Orca/Orca/OrcaDex.cs#L647
Can't find a pool with ts = 1?
Solution
General
I wonder if ATAs need to be created for increaseLiquidity, decreaseLiquidity, collectFees and collectReward as well.
Comments