Skip to content

Instantly share code, notes, and snippets.

@patcito
Created February 19, 2026 02:39
Show Gist options
  • Select an option

  • Save patcito/5bdf73233ee25f5bebd5bbdce5e7df18 to your computer and use it in GitHub Desktop.

Select an option

Save patcito/5bdf73233ee25f5bebd5bbdce5e7df18 to your computer and use it in GitHub Desktop.

Lend Asset Detail Endpoint

Endpoint

GET /mm/asset/detail?chainId=146&symbol=USDC
GET /mm/asset/detail?chainId=146&symbol=USDC&user=0xYourAddress

Parameters

Param Required Description
chainId yes Blockchain ID (146 = Sonic)
symbol yes Token symbol (case-insensitive): USDC, wS
user no Wallet address — when provided, response includes userData

TypeScript Types

interface LendAssetDetail {
  address: string;           // token contract address
  symbol: string;            // e.g. "USDC"
  name: string;              // e.g. "USD Coin"
  decimals: number;
  chainId: number;
  chainName: string;         // e.g. "Sonic"
  isSuppliable: boolean;     // collateral enabled on-chain
  isBorrowable: boolean;     // always true for lending tokens
  supplyApyPct: number;      // supply APY as percentage, e.g. 4.02
  borrowApyPct: number;      // borrow APY as percentage, e.g. 5.13
  tokenprice: number;        // USD price float, e.g. 1.0
  tokenPriceChange: number;  // absolute 24h change in USD
  tokenPriceChangePct: number; // percentage 24h change
  metrics: LendAssetMetrics;
  series: LendAssetSeries;
  userData: LendAssetUserData | null;  // null when no user param
}

interface LendAssetMetrics {
  totalDeposited: number;       // native units (cash + borrows)
  totalDepositedUsd: number;    // USD value
  totalDepositedChange: number; // 24h change percentage
  totalBorrowed: number;        // native units
  totalBorrowedUsd: number;
  totalBorrowedChange: number;  // 24h change percentage
  totalAvailable: number;       // native units (cash)
  totalAvailableUsd: number;
}

interface LendAssetSeries {
  price: LendSeriesPoint[];          // USD price over 30d
  depositApy: LendSeriesPoint[];     // supply APY % over 30d
  borrowApy: LendSeriesPoint[];      // borrow APY % over 30d
  totalAvailable: LendSeriesPoint[]; // available USD over 30d
}

interface LendSeriesPoint {
  timestamp: number;  // unix seconds
  value: number;      // float
}

interface LendAssetUserData {
  walletBalance: number;     // native units in wallet
  walletBalanceUsd: number;
  deposited: number;         // native units deposited as collateral
  depositedUsd: number;
  borrowed: number;          // native units of debt
  borrowedUsd: number;
  activity: LendActivityItem[];
}

interface LendActivityItem {
  action: "deposit" | "withdraw" | "borrow" | "repay";
  amount: number;      // native units
  amountUsd: number;
  timestamp: number;   // unix seconds
  txHash: string;
}

Example Response

// GET /mm/asset/detail?chainId=146&symbol=USDC
{
  "address": "0x29219dd400f2Bf60E5a23d13Be72B486D4038894",
  "symbol": "USDC",
  "name": "USD Coin",
  "decimals": 6,
  "chainId": 146,
  "chainName": "Sonic",
  "isSuppliable": true,
  "isBorrowable": true,
  "supplyApyPct": 4.02,
  "borrowApyPct": 5.13,
  "tokenprice": 1.0,
  "tokenPriceChange": 0.001,
  "tokenPriceChangePct": 0.1,
  "metrics": {
    "totalDeposited": 1250000.0,
    "totalDepositedUsd": 1250000.0,
    "totalDepositedChange": 2.5,
    "totalBorrowed": 800000.0,
    "totalBorrowedUsd": 800000.0,
    "totalBorrowedChange": 1.3,
    "totalAvailable": 450000.0,
    "totalAvailableUsd": 450000.0
  },
  "series": {
    "price": [
      { "timestamp": 1708300800, "value": 0.9998 },
      { "timestamp": 1708304400, "value": 1.0001 }
    ],
    "depositApy": [
      { "timestamp": 1708300800, "value": 3.95 },
      { "timestamp": 1708304400, "value": 4.02 }
    ],
    "borrowApy": [
      { "timestamp": 1708300800, "value": 5.10 },
      { "timestamp": 1708304400, "value": 5.13 }
    ],
    "totalAvailable": [
      { "timestamp": 1708300800, "value": 440000.0 },
      { "timestamp": 1708304400, "value": 450000.0 }
    ]
  },
  "userData": null
}

Usage in useLendAsset.tsx

const fetchLendAssetDetail = async (
  chainId: number,
  symbol: string,
  user?: string
): Promise<LendAssetDetail> => {
  const params = new URLSearchParams({ chainId: String(chainId), symbol });
  if (user) params.set("user", user);
  const res = await fetch(`${API_BASE}/mm/asset/detail?${params}`);
  if (!res.ok) throw new Error(await res.text());
  const json = await res.json();
  return json.data; // wrapped in { success: true, data: ... }
};

Notes

  • All numeric values are number (float64) — no string parsing needed
  • Series data covers 30 days at 1-hour intervals
  • userData is null when user param is omitted; when provided and the user has no positions, fields are 0 with an empty activity array
  • APY values (supplyApyPct, borrowApyPct, series depositApy/borrowApy) are percentages (e.g. 4.02 means 4.02%)
  • totalDepositedChange and totalBorrowedChange are 24h percentage changes
  • Price/metrics use on-chain data as primary source with Redis snapshots as fallback
  • Supported tokens on Sonic (chainId=146): USDC, wS
  • Error responses: { "success": false, "message": "..." } with HTTP 400
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment