# Asset Conversions

Asset conversions are required for various Hive financial transactions. The @hiveio/wax library provides methods like vestsToHp and hbdToHive to facilitate these conversions.

# Using vestsToHp

The vestsToHp method converts VESTS into Hive Power (HP). This conversion requires three NaiAsset instances: one for the VESTS and two others for the total vesting fund Hive and total vesting shares.

# Code Snippet for vestsToHp

import { createWaxFoundation } from '@hiveio/wax';

// Create a Wax Foundation instance
const waxApi = await createWaxFoundation();

// Assume these amounts represent the vests, totalVestingFundHive, and totalVestingShares
const vestsAmount = 1_000000;
const totalVestingFundHiveAmount = 20_000;
const totalVestingSharesAmount = 5_000000;

// Convert amounts to `NaiAsset`
const vestsAsset = waxApi.vestsSatoshis(vestsAmount);
const totalVestingFundHiveAsset = waxApi.hiveSatoshis(totalVestingFundHiveAmount);
const totalVestingSharesAsset = waxApi.vestsSatoshis(totalVestingSharesAmount);

// Use `vestsToHp` to perform the conversion
const hpAsset = waxApi.vestsToHp(vestsAsset, totalVestingFundHiveAsset, totalVestingSharesAsset);
console.log(`HP Asset: ${JSON.stringify(hpAsset)}`);

# Using hbdToHive

The hbdToHive method converts HBD into Hive. This conversion requires three NaiAsset instances: one for the HBD, one for the base (another HBD asset), and one for the quote (a HIVE asset).

# Code Snippet for hbdToHive

import { createWaxFoundation } from '@hiveio/wax';

// Create a Wax Foundation instance
const waxApi = await createWaxFoundation();

// Assume these amounts represent the HBD, base, and quote
const hbdAmount = 1_000;
const baseAmount = 1_500;
const quoteAmount = 2_000;

// Convert amounts to `NaiAsset`
const hbdAsset = waxApi.hbdSatoshis(hbdAmount);
const baseAsset = waxApi.hbdSatoshis(baseAmount);
const quoteAsset = waxApi.hiveSatoshis(quoteAmount);

// Use `hbdToHive` to perform the conversion
const hiveAsset = waxApi.hbdToHive(hbdAsset, baseAsset, quoteAsset);
console.log(`Converted Hive Asset: ${JSON.stringify(hiveAsset)}`);