Install dependencies
1. Configure the Morpho market
Define the market parameters for the cbBTC/pathUSD market on Tempo. These parameters uniquely identify the Morpho Blue market your app will interact with.lltv (liquidation loan-to-value) determines the maximum ratio of debt to collateral before a position becomes liquidatable. To find these values for any market, query the Morpho Blue contract or look them up on the Morpho app.
Both cbBTC and pathUSD use 6 decimals on Tempo. When specifying amounts,
1_000_000n equals 1
cbBTC or 1 pathUSD. Note that cbBTC uses 8 decimals on other chains but 6 on Tempo.2. Set up the Privy wallet and viem client
Create a viem wallet client from the Privy embedded wallet and extend it with the Morpho SDK. ThemorphoViemExtension adds Morpho market methods directly to the client.
3. Supply collateral and borrow
Use the Morpho SDK to construct and send transactions atomically via Bundler3. The SDK handles ERC-20 approvals, MorphosetAuthorization for the GeneralAdapter1, and Permit/Permit2 signatures automatically through its requirements system.
The SDK bundles
supplyCollateral and borrow into a single atomic transaction via Bundler3. It
also includes an LLTV buffer check to prevent the new position from being instantly liquidatable.4. Repay and withdraw collateral
To close the position, repay the borrowed pathUSD and withdraw the cbBTC collateral. The SDK bundles repay and withdraw into a single atomic transaction (repay executes first, then withdraw).5. Check position health
Monitor a position’s health factor to alert users before liquidation risk becomes critical. TheAccrualPosition returned by getPositionData includes a built-in healthFactor getter (WAD-scaled). These values may be undefined if the oracle is unavailable.
Market parameters
Related resources
Morpho SDK
TypeScript SDK reference for Morpho protocol interactions
Sending transactions on Tempo
Create embedded wallets and send transactions on Tempo

