Skip to content

Integration Overview

This guide will walk you through integrating Renalta's Embedded Yield into your application.

Implementation Note

The following integration guides assume you're using viem with JS/TS, but the contract calls are the same regardless of integration language and web3 library.

Additional Resources

  • For contract addresses and supported tokens, see the Addresses page
  • For monitoring protocol changes, see the Monitoring page
  • For information on fee structures, see the Fees page

Getting the Current Rate

Before integrating deposits and withdrawals, you may want to display the current APY to users:

import { createPublicClient, http } from 'viem'
import { base } from 'viem/chains'

const client = createPublicClient({
  chain: base,
  transport: http()
})

const RENALTA_VAULT = "0x5cb7149698e7d968ff23ffe2f43d9fcd663bcb8a"

async function getCurrentAPY() {
  const rate = await client.readContract({
    address: RENALTA_VAULT,
    abi: [{
      inputs: [],
      name: 'stableRate',
      outputs: [{ type: 'uint256' }],
      stateMutability: 'view',
      type: 'function'
    }],
    functionName: 'stableRate'
  })

  // Convert from UD60x18 format to percentage
  const apy = (Number(rate) / 1e18) * 100
  return apy
}

Depositing

Depositing into the Renalta Stable Yield Vault is the same as depositing into any ERC4626 vault. Before depositing, you must approve the vault to spend your USDC.

import { createWalletClient, custom, erc20Abi, parseUnits } from "viem"
import { base } from "viem/chains"

const RENALTA_VAULT = "0x5cb7149698e7d968ff23ffe2f43d9fcd663bcb8a"
const USDC = "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913" // USDC on Base

const walletClient = createWalletClient({
    chain: base,
    transport: custom(window.ethereum),
})
const amount = parseUnits("100", 6) // $100 - USDC uses 6 decimals

// Approve USDC spending
await walletClient.writeContract({
    chain: base,
    abi: erc20Abi,
    account: walletClient.account,
    address: USDC,
    functionName: "approve",
    args: [RENALTA_VAULT, amount],
})

After approval, you can deposit:

import { createWalletClient, custom, erc4626Abi, parseUnits } from "viem"
import { base } from "viem/chains"

const RENALTA_VAULT = "0x5cb7149698e7d968ff23ffe2f43d9fcd663bcb8a"

const walletClient = createWalletClient({
    chain: base,
    transport: custom(window.ethereum),
})
const amount = parseUnits("100", 6) // $100 - USDC uses 6 decimals
const txReceipt = await walletClient.writeContract({
    chain: base,
    abi: erc4626Abi,
    account: walletClient.account,
    address: RENALTA_VAULT,
    functionName: "deposit",
    args: [amount, walletClient.account],
})
console.log("Deposit TX receipt", txReceipt)

Withdrawing

Withdrawing from the Renalta stable yield vault follows the standard ERC4626 withdrawal pattern.

import { createWalletClient, custom, erc4626Abi, parseUnits } from "viem"
import { base } from "viem/chains"

const RENALTA_VAULT = "0x5cb7149698e7d968ff23ffe2f43d9fcd663bcb8a"

const walletClient = createWalletClient({
    chain: base,
    transport: custom(window.ethereum),
})
const amount = parseUnits("100", 6) // $100 - USDC uses 6 decimals
const txReceipt = await walletClient.writeContract({
    chain: base,
    abi: erc4626Abi,
    account: walletClient.account,
    address: RENALTA_VAULT,
    functionName: "withdraw",
    args: [amount, walletClient.account, walletClient.account],
})
console.log("Withdrawal TX receipt", txReceipt)