River
Satoshi Protocol V1
Satoshi Protocol V1
  • Intro
    • πŸ”οΈIntroduction
    • πŸ§‘β€πŸš€Mission
    • ❔FAQs
  • Mechanism
    • πŸ—ΊοΈOverview
    • 🏦Minting
    • πŸ›‘οΈStability Pool and Liquidations
    • βš–οΈRedemption & Price Stability
    • 🏧Nexus Yield Module (NYM)
    • ♻️Swap
    • 🌎MultiChain
    • 🌑️Recovery Mode
    • πŸ’°Revenue Structure
    • ⚑Risk Management
  • outro
    • πŸ”—Official Links
    • βš–οΈOracle
    • πŸ“”Deployed Contracts
    • πŸ”Audit Reports
  • How to use
    • πŸ—οΈCreate Position
    • πŸͺ£Deposit into Stability Pool
  • SDK
    • Introduction
    • Get Started
    • Position
      • Operation - OpenTrove
      • Operation - Deposit
      • Operation - Mint
      • Operation - Withdraw
      • Operation - Repay
      • Operation - Redemption
    • Stability Pool
      • Operation - Deposit
      • Operation - Withdraw
      • Operation - Claim rewards
    • Nexus Yield Module
      • Operation - Swap In
      • Operation - Swap Out
      • Operation - Withdraw
Powered by GitBook
On this page
  • Key Steps
  • Usage
  • Example
  1. SDK
  2. Position

Operation - Repay

Key Steps

  1. Parse Repayment Amount:

    • Convert the repayment amount into the correct unit using the parseUnits function, specifying the number of decimals that match the debt token's specifications (usually 18, like Ethereum).

  2. Execute Repayment Transaction:

    • Use the doRepay function to initiate the repayment. This function requires parameters such as the public and wallet clients, protocol configuration, collateral details, and the repayment amount. It processes the transaction on the blockchain and updates the user's debt status accordingly.

Usage

This function is typically used by users who wish to:

  • Decrease Financial Liabilities: Repaying part of the minted amount to reduce the accruing interest and improve financial standing.

  • Improve Trove Health: Enhancing the collateral-to-debt ratio to secure the trove against potential liquidations in volatile market conditions.

Example

import { parseUnits } from 'viem';
import { publicClient, walletClient, protocolConfig, collateral } from 'satoshi-sdk';

async function repayDebt() {
  // Step 1: Define the amount to repay
  const repayAmt = parseUnits('5', DEBT_TOKEN_DECIMALS);  // Repaying 5 SAT stablecoins

  // Step 2: Execute the repayment transaction
  const receipt = await satoshiClient.Postition.doRepay({
    publicClient,
    walletClient,
    protocolConfig,
    collateral,
    repayAmt,
  });

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

repayDebt();

This example function, repayDebt, outlines the process of repaying a specified amount of satUSD stablecoins. It demonstrates how to correctly convert the repayment amount to the proper unit and execute the transaction, ensuring the debt is correctly reduced in the user's trove.

PreviousOperation - WithdrawNextOperation - Redemption

Last updated 8 months ago