UPD — Universal Private DollarSDK Reference
Client API
createUPDClient — the main entry point for minting, burning, and querying UPD.
createUPDClient
import { createUPDClient } from '@permissionless-technologies/upd-sdk'
const upd = createUPDClient({
publicClient, // viem PublicClient
walletClient?, // viem WalletClient (required for write operations)
chainId: number, // e.g. 1 (mainnet), 11155111 (sepolia)
})Read Methods
upd.getUPDBalance(address)
const balance: bigint = await upd.getUPDBalance('0xAddress')upd.getTotalSupply()
const supply: bigint = await upd.getTotalSupply()upd.getCollateralInfo()
const info = await upd.getCollateralInfo()
// {
// totalCollateral: bigint, // total stETH in system
// totalUPD: bigint, // total UPD in circulation
// ratio: bigint, // collateralization ratio in basis points (10000 = 100%)
// ethPrice: bigint, // current ETH/USD price
// }upd.quoteMint(params)
Get a quote for minting UPD without submitting a transaction.
const quote = await upd.quoteMint({ ethAmount: parseEther('1') })
// {
// updAmount: bigint, // UPD you'll receive
// ethPrice: bigint, // ETH/USD price used
// fee: bigint, // protocol fee (if any)
// }upd.quoteBurn(params)
Get a quote for burning UPD without submitting a transaction.
const quote = await upd.quoteBurn({ updAmount: parseUnits('1000', 18) })
// {
// stEthAmount: bigint, // stETH you'll receive
// ethPrice: bigint, // ETH/USD price used
// }Write Methods
upd.mint(params)
Deposit ETH to mint UPD.
const { txHash, updMinted } = await upd.mint({
ethAmount: parseEther('1'),
minUpdOut?: bigint, // minimum UPD to receive (slippage protection)
})upd.burn(params)
Burn UPD to receive stETH.
const { txHash, stEthReceived } = await upd.burn({
updAmount: parseUnits('1000', 18),
minStEthOut?: bigint, // minimum stETH to receive
})upd.stake(params)
Stake UPD to receive sUPD.
const { txHash, supdReceived } = await upd.stake({
updAmount: parseUnits('1000', 18),
})upd.unstake(params)
Unstake sUPD to receive UPD.
const { txHash, updReceived } = await upd.unstake({
supdAmount: parseUnits('1000', 18),
})Pure Math Functions
These functions don't require a client — pure math for computing quotes locally:
import { quoteMintUPD, quoteBurnUPD, collateralizationRatio } from '@permissionless-technologies/upd-sdk/core'
// Compute UPD amount from ETH amount + ETH price
const updAmount = quoteMintUPD(parseEther('1'), ethPrice)
// Compute stETH from UPD amount + ETH price
const stEthAmount = quoteBurnUPD(parseUnits('3000', 18), ethPrice)
// Compute collateralization ratio
const ratio = collateralizationRatio(totalCollateral, ethPrice, totalUPDSupply)