Skip to content

feat: add name, symbol, and decimals to erc4626Abi - #5656

Merged
jxom merged 1 commit into
wevm:mainfrom
mortezashojaei:feat/erc4626-abi-metadata
Nov 24, 2026
Merged

jxom merged 1 commit into
wevm:mainfrom
mortezashojaei:feat/erc4626-abi-metadata

Conversation

@mortezashojaei

Copy link
Copy Markdown
Contributor

Refs #5655

Why

EIP-4626 says vaults MUST implement ERC-20's optional metadata extensions. erc4626Abi already includes the ERC-20 share functions (balanceOf, totalSupply, transfer, …) but not name, symbol, or decimals. As a result, functionName: 'decimals' with erc4626Abi fails to type-check and throws AbiFunctionNotFoundError at runtime.

Public code works around this by spreading the ABIs together ([...erc20Abi, ...erc4626Abi] in gskril/evm-portfolio, fassko/flare-smart-accounts and 0xPolygon/polygon-agent-cli). Other projects switch to erc20Abi for these calls on the vault address (yearn/yearn.fi) or redeclare a vault ABI with decimals() (yearn/vault-pnl-logs). Permalinks are in #5655.

What

  • src/constants/abis.ts: adds decimals() view returns (uint8), name() view returns (string) and symbol() view returns (string) to erc4626Abi. They match erc20Abi and keep the existing alphabetical order and key style.
  • src/constants/abis.test.ts: updates the existing exports abis inline snapshot.
  • Patch changeset.

Usage

import { erc4626Abi } from 'viem'

const [name, symbol, decimals, asset] = await client.multicall({
  allowFailure: false,
  contracts: [
    { address: vault, abi: erc4626Abi, functionName: 'name' },
    { address: vault, abi: erc4626Abi, functionName: 'symbol' },
    { address: vault, abi: erc4626Abi, functionName: 'decimals' }, // number
    { address: vault, abi: erc4626Abi, functionName: 'asset' },
  ],
})

Validation

  • SKIP_GLOBAL_SETUP=true pnpm test --run --update all src/constants/abis.test.ts, then the same command without --update all: 1 passed. The snapshot diff contains only the three new entries.
  • tsc -p src/tsconfig.json --noEmit: passes.
  • biome check on the changed files: clean.
  • I also ran a throwaway script (not included) that runs the snippet above against Ethereum mainnet:
    • With this change, it type-checks (decimals: number) and returns Savings Dai/sDAI/18 for sDAI and Steakhouse USDC/steakUSDC/18 for steakUSDC.
    • Against main's abis.ts, the name, symbol and decimals entries are type errors.

Compatibility

This only adds ABI entries. There are no new exports or dependencies. Code that spreads erc20Abi into erc4626Abi keeps working.

AI assistance

I prepared this with help from an AI coding assistant (Claude Code). I reviewed the evidence, diff, and test results.

@vercel

vercel Bot commented Nov 24, 2026

Copy link
Copy Markdown

@mortezashojaei is attempting to deploy a commit to the Wevm Team on Vercel.

A member of the Team first needs to authorize it.

@changeset-bot

changeset-bot Bot commented Nov 24, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 5f7dc38

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
viem Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@jxom
jxom merged commit 68291ac into wevm:main Nov 24, 2026
28 of 35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants