5. Minting osETH
Overview
Minting liquid staking tokens (osETH) allows users to maintain liquidity while staking their ETH.
In this section, we will guide you through checking minting limits, assessing vault health, and building and submitting minting transactions.
Checking Minting Limits
Before minting, we need to check the maximum amount of shares that can be minted.
This can be done using the getMint method:
const staker = new EthereumStaker({ network: 'hoodi' })
await staker.init()
const { maxMint } = await staker.getMaxMintForVault({
delegatorAddress: userAddress,
validatorAddress
})
console.log(maxMint) // '1' - 1 ETH
if (maxMint < amountToMint) {
// The user is trying to mint more than they can
throw new Error('Minting amount exceeds the limit')
}Calculating Health Factor for Minting
After confirming the minting limits, the next step is to assess the health factor of the vault. This involves evaluating the vault's health given the amount of shares the user intends to mint.
Use the getMintHealth method:
The getMintHealth method calculates the vault's health factor based on the current and intended minting amounts, ensuring the vault remains in a healthy state post-minting.
Executing the Minting Transaction
If the minting limits and health factors are within acceptable ranges, you can proceed to minting the shares.
To illustrate this, we use the buildMintTx method in the following example:
Next Steps
In this section, we covered the essential steps for minting osETH tokens, including checking minting limits, calculating the health factor, and executing the minting transaction.
To continue exploring the capabilities of your application, proceed to the next section: Burning osETH.
Last updated
Was this helpful?