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)
Last updated