magicblock-labs / magicblock-labs/Solana.Unity-Core
[Bug] PriceMath.TickIndexToPrice and PriceMath.SqrtPriceX64ToPrice Wrong price calculations
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 53
- Forks
- 23
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
Wrong price calculations
**To Reproduce**
```
Console.WriteLine(PriceMath.TickIndexToPrice(1, 9, 9));
Console.WriteLine(PriceMath.TickIndexToPrice(100, 9, 9));
```
```
10.00150003749937502188359611493754442728685383249508961171928583303106051744175749673006360257982567683817469619873
10.15112303331957826695058866288058596662162812280744838892230990557699568227283140711413108281156799322006970554316890624
```
**Expected behavior**
```
1.0001
1.0100496620928754
```
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Locate the implementations of PriceMath.TickIndexToPrice and PriceMath.SqrtPriceX64ToPrice, then run the reproduction calls from the issue. Compare their outputs with the expected values for tick indices 1 and 100, and verify both methods produce the corrected prices before considering the issue done.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- blockchain
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100