osmosis icon indicating copy to clipboard operation
osmosis copied to clipboard

feat(osmomath): BigDec TruncateSDKInt helper

Open p0mvn opened this issue 1 year ago • 3 comments

Background

Currently, to return an SDK Int from BigDec one must go BigDec -> Dec -> SDK Int

Suggested Design

Introduce a helpers TruncateSDKInt and TruncateSDKIntMut where the latter mutates the BigDec buffer directly and does not do reallocations.

Acceptance Criteria

  • 2 helpers implemented
  • one does not do reallocations
  • each unit tested
  • backported to release branch and state-compat confirmed

p0mvn avatar Sep 21 '23 17:09 p0mvn

We also need a RountInt helper

p0mvn avatar Sep 21 '23 23:09 p0mvn

NewIntFromBigInt always allocates new big.Int pointer

return Int{new(big.Int).Set(i)}

hieuvubk avatar Sep 25 '23 18:09 hieuvubk

Waiting for https://github.com/cosmos/cosmos-sdk/pull/18030

hieuvubk avatar Oct 10 '23 07:10 hieuvubk