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
  • Prerequisites
  • Example: Calculate Minting Fee
  1. SDK

Get Started

Prerequisites

Before you begin, ensure you have the following installed:

  • Node.js (version 18 or higher)

  • npm / yarn / pnpm

  • Git (for cloning the repository)

  1. Install SDK

    • install the required npm packages:

    • npm install satoshi-sdk
  2. import package

    • In your TypeScript or JavaScript project, import the SDK:

    • import { SatoshiClient } from 'satoshi-sdk';

Example: Calculate Minting Fee

This example shows how to use the Satoshi Protocol SDK to calculate the minting fee for a given amount of satUSD using a specific collateral type on the BEVM_MAINNET. It utilizes several functions and configurations provided by the SDK to accomplish this.

Code

import { getPublicClientByConfig, ProtocolConfigMap } from 'satoshi-sdk';

// Define the protocol configuration for the BEVM_MAINNET
const protocolConfig = ProtocolConfigMap.BEVM_MAINNET;

// Select the first collateral type available in the configuration
const collateral = protocolConfig.COLLATERALS[0];

// Get a public client configured for the selected protocol configuration
const publicClient = getPublicClientByConfig(protocolConfig);

// Define the amount for which the minting fee needs to be calculated
const amount = 123456789n;  // Using a BigInt for large numbers

// Async function to perform the minting fee calculation
async function calculateMintingFee() {
  const result = await getBorrowingFee(
    {
      publicClient,
      protocolConfig,
      troveManagerAddr: collateral.TROVE_MANAGER_BEACON_PROXY_ADDRESS,
    },
    amount
  );
  
  // Log the result to the console
  console.log('Minting Fee:', result);
}

// Call the function to execute the operation
calculateMintingFee();
PreviousIntroductionNextPosition

Last updated 9 months ago