Sentio Docs
Ask or search…

Handle Big Numbers

Sentio SDK uses javascript's native bigint for big integer calculations. However, if you want to do operations like division, you need to convert it to BigDecimal , otherwise, you may lose precision during the operation. We do provide utils for bigint to convert to BigDecimal.
const latestAnswer: bigint = 10n
// Use asBigDecimal to convert bigint to BigDecimal
const eth_usdc_price: BigDecimal = latestAnswer.asBigDecimal().div(BigDecimal(10).pow(18))
// Use scaleDown to further simplify code in some cases.
const eth_usdc_price2: BigDecimal = latestAnswer.scaleDown(18)