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();

Last updated