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 provide utilities for bigint and other types like BN 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)