Operation - Deposit

Key Steps

  1. Convert Collateral Amount:

    • Convert the desired amount of collateral into Wei using the parseEther function from the viem library. This ensures that the amount is in the smallest denomination of ether, which is necessary for precise blockchain transactions.

  2. Record the Deposit:

    • Once the transaction is confirmed, record the deposit within the protocol by calling the doDeposit function. This step updates the user's trove to reflect the added collateral, which could affect their minting capacity and collateral-to-debt ratio.

Usage

This function is typically used when a user wishes to:

  • Increase Minting Capacity: By adding more collateral, a user can safely mint more satUSD stablecoins while maintaining a healthy collateral-to-debt ratio.

  • Enhance Financial Security: More collateral in a trove provides a larger buffer against potential liquidation in case of market volatility.

Example

import { parseEther } from 'viem';
import { protocolConfig, wbtcABI } from 'satoshi-sdk';

async function addCollateral() {
  // Step 1: Convert the amount to add to Wei
  const addedCollAmt = parseEther('0.2');  // Let's add 0.2 BTC worth of WBTC
  const collateral = protocolConfig.COLLATERALS[0];  // WBTC Collateral

  // Step 2: Record the deposit in the protocol
  const receipt = await satoshiClient.Postition.doDeposit({
    collateral,
    addedCollAmt,
  });

  console.log('Deposit successful:', receipt);
}

addCollateral();

Last updated