Conversation
|
Important Notice This PR modifies an in-repo Go module. It is one of:
The dependent Go modules, especially the root one, will have to be Please follow the instructions below:
Please let us know if you need any help. |
p0mvn
left a comment
There was a problem hiding this comment.
Thanks for the change, please see comment
| func BigDecFromSDKInt(i Int) BigDec { | ||
| return NewBigDecFromBigIntWithPrec(i.BigInt(), 0) | ||
| } |
There was a problem hiding this comment.
Note that this is not mutative. See that BigInt() reinitializes the underlying buffer.
Let's still keep this, please. However, I'm also wondering if we can make a mutative version that would reuse the input's buffer?
There was a problem hiding this comment.
Yeah I see, currently it's hard to access Int.i directly without BigInt()
There was a problem hiding this comment.
Could you make an issue to consider this in the future and potentially talk to the SDK team about exposing such API?
There was a problem hiding this comment.
I tried returning Int.i in my local, performance is improved but the potential risks are unclear
pysel
left a comment
There was a problem hiding this comment.
thanks! left a small nit, lgtm when Roman's comment is addressed
| return NewBigDecFromBigIntWithPrec(d.BigInt(), PrecisionDec) | ||
| } | ||
|
|
||
| // BigDecFromSDKInt returns the BigDec representation of an sdkInt. |
There was a problem hiding this comment.
nit: I think we do not reference sdk anymore, Int is defined in osmomath package
| // BigDecFromSDKInt returns the BigDec representation of an sdkInt. | |
| // BigDecFromSDKInt returns the BigDec representation of an Int. |
|
@hieuvubk please add a changelog entry and create an issue. Thanks! |
|
Marking as draft until the requests are resolved |
| // our liquidity calculations will be off from our theoretical calculations within our tests. | ||
| // TODO (perf): consider better conversion helpers to minimize reallocations. | ||
| amountBigDec := osmomath.BigDecFromDec(amount.ToLegacyDec()) | ||
| amountBigDec := osmomath.BigDecFromSDKInt(amount) |
There was a problem hiding this comment.
Let's keep these comments please.
Do you mint creating an issue for this osmosis side and linking it to cosmos/cosmos-sdk#17772?
Thanks!
…-labs/osmosis into hieu/bigdec_from_sdk_int
* refactor/test(CL): Stricter rounding behavior in CL math methods; unit tests at low price level * comment updates * convert int => bigdec instead of int => dec => bigdec * tests * Liquidity1 lack * add changelog endpoint * update go mod * keep comments * go mod * fix * Update CHANGELOG.md --------- Co-authored-by: Roman <roman@osmosis.team> (cherry picked from commit e2b521d) # Conflicts: # CHANGELOG.md # go.mod # go.sum # osmomath/decimal_test.go # x/concentrated-liquidity/math/math.go
* Convert sdk.Int to BigDec (#6409) * refactor/test(CL): Stricter rounding behavior in CL math methods; unit tests at low price level * comment updates * convert int => bigdec instead of int => dec => bigdec * tests * Liquidity1 lack * add changelog endpoint * update go mod * keep comments * go mod * fix * Update CHANGELOG.md --------- Co-authored-by: Roman <roman@osmosis.team> (cherry picked from commit e2b521d) # Conflicts: # CHANGELOG.md # go.mod # go.sum # osmomath/decimal_test.go # x/concentrated-liquidity/math/math.go * resolve conflict * go mod tidy * update go mod * Update CHANGELOG.md --------- Co-authored-by: Hieu Vu <72878483+hieuvubk@users.noreply.github.com> Co-authored-by: roman <roman@osmosis.team>
Closes: #6370
What is the purpose of the change
Create a func
BigDecFromSDKIntto convert sdk.Int => BigDec instead of converting sdk.Int => sdk.Dec => BigDecBenchmark:
Testing and Verifying
(Please pick one of the following options)
This change is a trivial rework / code cleanup without any test coverage.
(or)
This change is already covered by existing tests, such as (please describe tests).
(or)
This change added tests and can be verified as follows:
(example:)
Documentation and Release Note
Unreleasedsection ofCHANGELOG.md?Where is the change documented?
x/{module}/README.md)