Operation - OpenTrove
Key Steps
Usage
Example
import { parseUnits, parseEther } from 'viem';
import { walletClient, publicClient, protocolConfig, collateral, wbtcABI, DEBT_TOKEN_DECIMALS } from 'satoshi-sdk';
// Step 1: Parse the minting amount and collateral amount
const mintingAmt = parseUnits('10', DEBT_TOKEN_DECIMALS); // Converts the string '10' into a BigNumber using the specified number of decimals
const totalCollAmt = parseEther('0.1'); // Converts the Ether string '0.1' to its Wei equivalent as a BigNumber
// Step 2: convert BEVM BTC to WBTC
const depositHash = await walletClient.writeContract({
chain: protocolConfig.CHAIN,
account: walletClient.account,
address: collateral.ADDRESS,
abi: wbtcABI,
functionName: 'deposit',
args: [],
value: totalCollAmt,
});
await waitTxReceipt({ publicClient }, depositHash); // Wait for the transaction to be confirmed
// Step 3: Open a trove
const receipt = await satoshiClient.Postition.doOpenTrove({
collateral,
mintingAmt,
totalCollAmt,
});Last updated