Telegram USD
WebsiteMiniapp
  • 👋Welcome
  • Getting Started
    • 🗽Introduction
    • 😢Ecosystem Challenges
      • Low Yield on TON
      • Limited Real-World Integration
      • High DeFi Barriers
    • 🤙A New Path Forward
  • How tgUSD Works
    • 🏠Architecture
      • ▶️Current Version
      • 🌴Core Components
        • Engine
        • Staking
      • 🔮Next Version
    • ⚖️Peg Stability
    • 💰Protocol Revenue
    • 🙋‍♀️Use Cases
      • DeFi
        • Yield Tokenization
        • Lending
        • Dex
        • Leverage Yield Farming
        • Derivatives
        • Arbitrage
      • Cross-Chain Expansion
        • TAC
        • Tycho
  • Rewards
    • 🌟Ambassador Program
    • ✴️What is Torch XP
  • Technical
    • 📖Telegram USD SDK
      • Setup
      • Mint tgUSD
      • Stake tgUSD
      • Unstake stgUSD
      • Get stgUSD Conversion Rate
        • On-chain method
        • Off-chain method
    • 🛠️Deployments
  • Security
    • ✳️Risks
    • 🛡️Audits
  • User Guide
    • How to Mint
    • How to Stake
    • How to Unstake
    • FAQ
  • Legal
    • Terms of Service
  • Privacy Policy
  • Other
    • 🎨Brand Kit
  • Links
    • Website
  • tgUSD Miniapp
  • Telegram Channel
  • X (Twitter)
Powered by GitBook
On this page
  • Step 1: Import modules & Initialize Staking Contract
  • Step2: Get stgUSD conversion rate
  1. Technical
  2. Telegram USD SDK
  3. Get stgUSD Conversion Rate

Off-chain method

Step 1: Import modules & Initialize Staking Contract

import { Address, TonClient4 } from "@ton/ton";
import { tgUSDStaking } from "@torch-finance/tgusd-sdk";

const tonClient = new TonClient4({
  endpoint: 'https://mainnet-v4.tonhubapi.com',
});

// Staking Contract
const stakingAddress = Address.parse("EQDsRxOvYyhOAi-zHBSN2NkHcjwFB1aaMSnqJG7Chm14x02P")
const tgUSDJettonMaster = Address.parse("EQCJ7ASxOkI6Ws5Bh8J74XZbRX8861jFgTZT42DXv71-UISf")
const stgUSDJettonMaster = Address.parse("EQC2OdSIRyDofBjKYtR-ZN-Xk3eHN9gEujY7deoHNRBdZ5QG")
const staking = tonClient.open(tgUSDStaking.createFromAddress(stakingAddress, tgUSDJettonMaster, stgUSDJettonMaster));

Step2: Get stgUSD conversion rate

const { totalActiveStake, totalShares } = await staking.getConversionRatio();
  • totalActiveStake / totalShares represents the current conversion rate of 1 stgUSD in tgUSD (You can control the rounding precision as needed)

PreviousOn-chain methodNextDeployments

Last updated 13 days ago

📖