convertToShares ​
Convert an asset amount to shares using the current exchange rate.
Signature ​
solidity
function convertToShares(uint256 assets) external view returns (uint256 shares);Parameters ​
| Name | Type | Description |
|---|---|---|
assets | uint256 | Asset amount (USDC, 6 decimals). |
Returns ​
| Name | Type | Description |
|---|---|---|
shares | uint256 | Equivalent share amount (18 decimals). |
Example ​
ts
import { parseUnits } from 'viem'
import { publicClient } from './client'
import { liteUsdVaultAbi } from './abi'
import { VAULT, USDC_DECIMALS } from './constants'
const assets = parseUnits('1000', USDC_DECIMALS)
const shares = await publicClient.readContract({
address: VAULT,
abi: liteUsdVaultAbi,
functionName: 'convertToShares',
args: [assets],
})
console.log('Converted shares:', shares)Notes ​
- Unlike
previewDeposit, this conversion is a pure rate conversion and may not account for all operation-specific effects.

