Converting Token Amounts
Between native and pool dimensions
Each pool contains a denominator
property which is defined during the pool contract deployment. Token amounts are always converted to the denominated form when interacting with a pool. All operations with tokens are performed in the pool denominated realm (we also call it pool or shielded dimension). The following functions perform conversions between the shielded token and the native one.
Native to Shielded
Convert native tokens to the pool dimension. The result is always rounded down.
Parameters
amountWei
: token amount in the native dimension (in wei
for most ERC20 tokens)
Returns
Promise
returns bigint
: amount representation in the current pool dimension (rounded down if needed).
Example
Shielded to Native
Convert pool tokens from the pool dimension to the native dimension.
Parameters
amountShielded
: token amount in the pool dimension (denominated value).
Returns
Promise
returns bigint
: amount representation in the native token dimension (rounded down if needed).
Example
Last updated
Was this helpful?