bifrost-slpx-stake

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Bifrost SLPx Stake

Bifrost SLPx 质押操作

Execute Bifrost vETH liquid staking operations: mint, redeem, and claim.
执行Bifrost vETH流动性质押操作:铸造、赎回和领取。

Contract & Network

合约与网络

vETH is deployed on Ethereum and three L2 networks. The same contract address is used across all chains.
ChainChainIdVETH ContractWETH (underlying)Default RPCFallback RPC
Ethereum1
0xc3997ff81f2831929499c4eE4Ee4e0F08F42D4D8
0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2
https://ethereum.publicnode.com
https://1rpc.io/eth
Base8453
0xc3997ff81f2831929499c4eE4Ee4e0F08F42D4D8
0x4200000000000000000000000000000000000006
https://base.publicnode.com
https://1rpc.io/base
Optimism10
0xc3997ff81f2831929499c4eE4Ee4e0F08F42D4D8
0x4200000000000000000000000000000000000006
https://optimism.publicnode.com
https://1rpc.io/op
Arbitrum42161
0xc3997ff81f2831929499c4eE4Ee4e0F08F42D4D8
0x82aF49447D8a07e3bd95BD0d56f35241523fBab1
https://arbitrum-one.publicnode.com
https://1rpc.io/arb
vETH已部署在Ethereum及三条L2链上,所有链使用相同的合约地址。
链名称ChainIdvETH合约地址底层WETH地址默认RPC备用RPC
Ethereum1
0xc3997ff81f2831929499c4eE4Ee4e0F08F42D4D8
0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2
https://ethereum.publicnode.com
https://1rpc.io/eth
Base8453
0xc3997ff81f2831929499c4eE4Ee4e0F08F42D4D8
0x4200000000000000000000000000000000000006
https://base.publicnode.com
https://1rpc.io/base
Optimism10
0xc3997ff81f2831929499c4eE4Ee4e0F08F42D4D8
0x4200000000000000000000000000000000000006
https://optimism.publicnode.com
https://1rpc.io/op
Arbitrum42161
0xc3997ff81f2831929499c4eE4Ee4e0F08F42D4D8
0x82aF49447D8a07e3bd95BD0d56f35241523fBab1
https://arbitrum-one.publicnode.com
https://1rpc.io/arb

Configuration

配置

On first run, ask the user whether they want to configure custom settings. If not, use the defaults above.
首次运行时,询问用户是否需要配置自定义设置。若不需要,则使用上述默认值。

Environment Variables

环境变量

VariableDescriptionDefault
BIFROST_CHAIN
Target chain name (
ethereum
,
base
,
optimism
,
arbitrum
)
ethereum
BIFROST_RPC_URL
Custom RPC endpointPer-chain default from table above
BIFROST_VETH_ADDRESS
VETH contract address (override)
0xc3997ff81f2831929499c4eE4Ee4e0F08F42D4D8
BIFROST_PRIVATE_KEY
Private key for agent-side signing (hex, with or without 0x prefix)Not set (manual signing mode)
变量名称描述默认值
BIFROST_CHAIN
目标链名称(
ethereum
base
optimism
arbitrum
ethereum
BIFROST_RPC_URL
自定义RPC端点对应链的默认RPC(见上表)
BIFROST_VETH_ADDRESS
vETH合约地址(覆盖默认值)
0xc3997ff81f2831929499c4eE4Ee4e0F08F42D4D8
BIFROST_PRIVATE_KEY
代理端签名用私钥(十六进制,可带或不带0x前缀)未设置(手动签名模式)

Wallet Setup

钱包设置

Two signing modes. Default is manual signing (no setup needed).
Default: Manual Signing
Output complete transaction details (to, value, data, gas, chainId). User signs with their own wallet (MetaMask, Ledger, CLI, etc.).
Option: Agent-Side Signing
Set
BIFROST_PRIVATE_KEY
as an environment variable, or import via Foundry keystore:
bash
cast wallet import bifrost-agent --interactive
When
BIFROST_PRIVATE_KEY
is set, the agent can sign and broadcast transactions directly using
cast send
.
支持两种签名模式,默认是手动签名(无需额外设置)。
默认:手动签名
输出完整的交易详情(接收地址、金额、数据、Gas、ChainId)。用户使用自己的钱包(MetaMask、Ledger、CLI等)进行签名。
可选:代理端签名
BIFROST_PRIVATE_KEY
设置为环境变量,或通过Foundry密钥库导入:
bash
cast wallet import bifrost-agent --interactive
当设置
BIFROST_PRIVATE_KEY
后,代理可直接使用
cast send
签名并广播交易。

Quick Reference

快速参考

Write Operations

写入操作

OperationFunctionSelectorDescription
Mint vETH (via ETH)
depositWithETH()
0x1166dab6
Stake native ETH to mint vETH. ETH is sent as
msg.value
. The contract wraps ETH → WETH internally — no ERC-20 approval needed. Reverts
EthNotSent()
if
msg.value == 0
Mint vETH (via WETH)
deposit(uint256,address)
0x6e553f65
Deposit WETH directly to mint vETH for
receiver
. Requires prior WETH approval to the VETH contract
Redeem vETH
redeem(uint256,address,address)
0xba087652
Burn
shares
of vETH to initiate ETH withdrawal for
receiver
. ETH enters a redemption queue and is NOT returned instantly. Requires
owner == msg.sender
or sufficient allowance
Claim as ETH
withdrawCompleteToETH()
0x3ec549e9
Claim ALL completed withdrawals as native ETH. Internally calls
withdrawCompleteTo(this)
then unwraps WETH → ETH. Reverts
EthTransferFailed()
if ETH transfer fails
Claim as WETH
withdrawComplete()
0x266a3bce
Claim ALL completed withdrawals as WETH to
msg.sender
. Use this if
withdrawCompleteToETH()
fails
Claim to address
withdrawCompleteTo(address)
0xf29ee493
Claim ALL completed withdrawals as WETH to a specified
receiver
address
操作函数选择器描述
铸造vETH(通过ETH)
depositWithETH()
0x1166dab6
质押原生ETH铸造vETH。ETH以
msg.value
形式发送,合约会在内部将ETH包装为WETH——无需进行ERC-20授权。若
msg.value == 0
,会触发
EthNotSent()
回滚
铸造vETH(通过WETH)
deposit(uint256,address)
0x6e553f65
直接存入WETH为
receiver
铸造vETH,需预先向vETH合约授权WETH
赎回vETH
redeem(uint256,address,address)
0xba087652
销毁
shares
数量的vETH,为
receiver
发起ETH提取申请。ETH会进入赎回队列,不会立即到账。要求
owner == msg.sender
或拥有足够的授权额度
领取ETH
withdrawCompleteToETH()
0x3ec549e9
领取所有已完成赎回的原生ETH。内部先调用
withdrawCompleteTo(this)
,再将WETH解包为ETH。若ETH转账失败,会触发
EthTransferFailed()
回滚
领取WETH
withdrawComplete()
0x266a3bce
领取所有已完成赎回的WETH至
msg.sender
地址。若
withdrawCompleteToETH()
失败,可使用此方法
领取至指定地址
withdrawCompleteTo(address)
0xf29ee493
领取所有已完成赎回的WETH至指定的
receiver
地址

Pre-Execution Query Functions

执行前查询函数

QueryFunctionSelectorDescription
Preview deposit
previewDeposit(uint256)
0xef8b30f7
Simulate deposit and return exact vETH shares to be minted
Preview redeem
previewRedeem(uint256)
0x4cdad506
Simulate redemption and return exact ETH to be returned
Fallback: shares calc
convertToShares(uint256)
0xc6e6f592
Convert ETH amount to vETH shares using current Oracle exchange rate
Fallback: assets calc
convertToAssets(uint256)
0x07a2d13a
Convert vETH shares to ETH value using current Oracle exchange rate
vETH balance
balanceOf(address)
0x70a08231
Get vETH token balance of a specific address
Max redeemable
maxRedeem(address)
0xd905777e
Maximum vETH shares the owner can redeem in a single tx
Claimable ETH
canWithdrawalAmount(address)
0x52a630b9
Returns
(totalAvailableAmount, pendingDeleteIndex, pendingDeleteAmount)
. First value = ETH ready to claim
查询项函数选择器描述
预览存款
previewDeposit(uint256)
0xef8b30f7
模拟存款操作,返回预计可铸造的vETH份额
预览赎回
previewRedeem(uint256)
0x4cdad506
模拟赎回操作,返回预计可提取的ETH数量
备选:份额计算
convertToShares(uint256)
0xc6e6f592
使用当前Oracle汇率将ETH金额转换为vETH份额
备选:资产计算
convertToAssets(uint256)
0x07a2d13a
使用当前Oracle汇率将vETH份额转换为ETH价值
vETH余额
balanceOf(address)
0x70a08231
查询指定地址的vETH代币余额
最大可赎回量
maxRedeem(address)
0xd905777e
所有者单次交易可赎回的最大vETH份额
可领取ETH
canWithdrawalAmount(address)
0x52a630b9
返回
(totalAvailableAmount, pendingDeleteIndex, pendingDeleteAmount)
,第一个值为可领取的ETH数量

How to Call

调用方式

Read queries — use
eth_call
(no gas):
bash
undefined
只读查询 — 使用
eth_call
(无需Gas):
bash
undefined

Method A: cast (preferred)

方式A:使用cast(推荐)

cast call <VETH_CONTRACT>
"<FUNCTION_SIGNATURE>(<ARG_TYPES>)(<RETURN_TYPES>)" <ARGS>
--rpc-url <RPC_URL>
cast call <VETH_CONTRACT>
"<FUNCTION_SIGNATURE>(<ARG_TYPES>)(<RETURN_TYPES>)" <ARGS>
--rpc-url <RPC_URL>

Method B: curl (if cast unavailable)

方式B:使用curl(若cast不可用)

curl -s -X POST <RPC_URL>
-H "Content-Type: application/json"
-d '{"jsonrpc":"2.0","id":1,"method":"eth_call","params":[{"to":"<VETH_CONTRACT>","data":"<SELECTOR><ENCODED_ARGS>"},"latest"]}'

If `previewDeposit` or `previewRedeem` fails, fall back to `convertToShares` / `convertToAssets` (same encoding).

**Write transactions** — use `cast send` (requires wallet):

```bash
curl -s -X POST <RPC_URL>
-H "Content-Type: application/json"
-d '{"jsonrpc":"2.0","id":1,"method":"eth_call","params":[{"to":"<VETH_CONTRACT>","data":"<SELECTOR><ENCODED_ARGS>"},"latest"]}'

若`previewDeposit`或`previewRedeem`调用失败,可改用`convertToShares`/`convertToAssets`(编码方式相同)。

**写入交易** — 使用`cast send`(需要钱包):

```bash

Mint vETH (stake native ETH)

铸造vETH(质押原生ETH)

cast send <VETH_CONTRACT>
"depositWithETH()" --value <AMOUNT_IN_WEI>
--rpc-url <RPC_URL> --private-key <PRIVATE_KEY>
cast send <VETH_CONTRACT>
"depositWithETH()" --value <AMOUNT_IN_WEI>
--rpc-url <RPC_URL> --private-key <PRIVATE_KEY>

Redeem vETH (unstake)

赎回vETH(解除质押)

cast send <VETH_CONTRACT>
"redeem(uint256,address,address)" <SHARES_IN_WEI> <USER_ADDR> <USER_ADDR>
--rpc-url <RPC_URL> --private-key <PRIVATE_KEY>
cast send <VETH_CONTRACT>
"redeem(uint256,address,address)" <SHARES_IN_WEI> <USER_ADDR> <USER_ADDR>
--rpc-url <RPC_URL> --private-key <PRIVATE_KEY>

Claim ETH (withdraw completed redemptions)

领取ETH(提取已完成的赎回资产)

cast send <VETH_CONTRACT>
"withdrawCompleteToETH()"
--rpc-url <RPC_URL> --private-key <PRIVATE_KEY>
undefined
cast send <VETH_CONTRACT>
"withdrawCompleteToETH()"
--rpc-url <RPC_URL> --private-key <PRIVATE_KEY>
undefined

Calldata Encoding (for manual signing output)

调用数据编码(用于手动签名输出)

  • uint256: convert wei to hex, left-pad to 64 chars
  • address: remove 0x prefix, left-pad to 64 chars
  • canWithdrawalAmount
    returns 3 × uint256 (192 hex chars):
    (totalAvailableAmount, pendingDeleteIndex, pendingDeleteAmount)
    . First 64 chars = claimable ETH amount
  • uint256:将wei值转换为十六进制,左填充至64个字符
  • address:移除0x前缀,左填充至64个字符
  • canWithdrawalAmount
    返回3个uint256值(共192个十六进制字符):
    (totalAvailableAmount, pendingDeleteIndex, pendingDeleteAmount)
    ,前64个字符为可领取的ETH数量

API 1: Mint vETH (Stake ETH)

API 1:铸造vETH(质押ETH)

Pre-Execution

执行前准备

  1. Query rate:
    previewDeposit(amount)
    → expected vETH
  2. Check wallet:
    BIFROST_PRIVATE_KEY
    env var or Foundry keystore
    bifrost-agent
  3. Display preview and wait for CONFIRM
  1. 查询汇率:
    previewDeposit(amount)
    → 预计可获得的vETH数量
  2. 检查钱包:是否设置
    BIFROST_PRIVATE_KEY
    环境变量或Foundry密钥库中的
    bifrost-agent
  3. 显示预览信息,等待用户输入CONFIRM确认

Transaction

交易详情

FieldValue
To
<VETH_CONTRACT>
ValueUser's ETH amount in wei
Data
0x1166dab6
ChainIdPer selected chain
字段
接收地址
<VETH_CONTRACT>
金额用户质押的ETH金额(wei单位)
数据
0x1166dab6
ChainId所选链对应的ChainId

Manual Signing Output

手动签名输出

To:       <VETH_CONTRACT>
Value:    {wei} ({amount} ETH)
Data:     0x1166dab6
ChainId:  {chainId}
To:       <VETH_CONTRACT>
Value:    {wei} ({amount} ETH)
Data:     0x1166dab6
ChainId:  {chainId}

API 2: Redeem vETH (Unstake)

API 2:赎回vETH(解除质押)

Pre-Execution

执行前准备

  1. Check
    balanceOf(user)
    ≥ redeem amount
  2. Query
    previewRedeem(shares)
    → expected ETH
  3. Check
    maxRedeem(user)
  4. Display preview (warn: ETH enters queue, NOT instant) and wait for CONFIRM
  1. 检查
    balanceOf(user)
    ≥ 赎回份额
  2. 查询
    previewRedeem(shares)
    → 预计可获得的ETH数量
  3. 检查
    maxRedeem(user)
  4. 显示预览信息(提示:ETH会进入队列,不会立即到账),等待用户输入CONFIRM确认

Transaction

交易详情

FieldValue
To
<VETH_CONTRACT>
Value
0
DataABI-encoded
redeem(shares, userAddr, userAddr)
ChainIdPer selected chain
Encode calldata:
cast calldata "redeem(uint256,address,address)" <SHARES> <ADDR> <ADDR>
字段
接收地址
<VETH_CONTRACT>
金额
0
数据ABI编码后的
redeem(shares, userAddr, userAddr)
ChainId所选链对应的ChainId
编码调用数据:
cast calldata "redeem(uint256,address,address)" <SHARES> <ADDR> <ADDR>

API 3: Claim Redeemed ETH

API 3:领取赎回的ETH

Pre-Execution

执行前准备

  1. Check
    canWithdrawalAmount(user)
    — first return value = claimable amount
  2. If 0: inform user redemption may still be processing
  3. If > 0: display claimable amount and wait for CONFIRM
  1. 调用
    canWithdrawalAmount(user)
    — 返回值的第一个参数为可领取金额
  2. 若金额为0:告知用户赎回可能仍在处理中
  3. 若金额大于0:显示可领取金额,等待用户输入CONFIRM确认

Transaction

交易详情

FieldValue
To
<VETH_CONTRACT>
Value
0
Data
0x3ec549e9
ChainIdPer selected chain
字段
接收地址
<VETH_CONTRACT>
金额
0
数据
0x3ec549e9
ChainId所选链对应的ChainId

Agent Behavior

代理行为

  1. Environment check: on first interaction, ask user if they want to configure
    BIFROST_CHAIN
    ,
    BIFROST_RPC_URL
    , or
    BIFROST_PRIVATE_KEY
    . If not, use Ethereum Mainnet defaults with manual signing mode
  2. RPC selection: use
    BIFROST_RPC_URL
    if set; otherwise use per-chain default RPC. Fall back to per-chain fallback RPC on failure
  3. Multi-chain awareness: when user specifies a chain (e.g. "on Base", "on Arbitrum"), switch to that chain's RPC, WETH address, and chainId accordingly
  4. Wallet detection: check
    BIFROST_PRIVATE_KEY
    env var or Foundry keystore
    bifrost-agent
    . If found, ask user whether to use it. If not, output tx data for manual signing
  5. CONFIRM required: display transaction preview (amount, rate, expected output, chain) and require user to type CONFIRM before any write
  6. Private key import requires CONFIRM: show security warning first, require CONFIRM before accepting key
  7. Key retention is user-controlled: after tx, ask user whether to keep or delete the key
  8. Balance pre-check: verify sufficient ETH/vETH before building tx
  9. Prefer cast, fall back to curl: use pre-computed calldata from selector table if cast fails
  10. No credential display: never echo private keys; truncate addresses (first 6 + last 4)
  11. Post-completion tip: if no wallet configured, suggest "set up wallet" after operation
  12. After successful tx, provide block explorer link:
    https://etherscan.io/tx/{hash}
    (Ethereum),
    https://basescan.org/tx/{hash}
    (Base),
    https://optimistic.etherscan.io/tx/{hash}
    (Optimism),
    https://arbiscan.io/tx/{hash}
    (Arbitrum)
  13. Useful links: direct users to Bifrost vETH page or Bifrost App when relevant
  1. 环境检查:首次交互时,询问用户是否需要配置
    BIFROST_CHAIN
    BIFROST_RPC_URL
    BIFROST_PRIVATE_KEY
    。若不需要,则使用Ethereum主网默认配置及手动签名模式
  2. RPC选择:若设置了
    BIFROST_RPC_URL
    则使用该地址;否则使用对应链的默认RPC。若默认RPC调用失败,自动切换至备用RPC
  3. 多链适配:当用户指定链(如“在Base上”、“在Arbitrum上”)时,自动切换至对应链的RPC、WETH地址和ChainId
  4. 钱包检测:检查是否设置
    BIFROST_PRIVATE_KEY
    环境变量或Foundry密钥库中的
    bifrost-agent
    。若存在,询问用户是否使用该钱包;若不存在,则输出交易数据供手动签名
  5. 强制确认:显示交易预览信息(金额、汇率、预计输出、链信息),要求用户输入CONFIRM后再执行任何写入操作
  6. 私钥导入需确认:先显示安全警告,要求用户输入CONFIRM后再接受私钥
  7. 密钥由用户控制:交易完成后,询问用户是否保留或删除密钥
  8. 余额预检查:在构建交易前,验证ETH/vETH余额是否充足
  9. 优先使用cast,备选curl:若cast调用失败,使用选择器表中的预计算调用数据
  10. 不显示凭证:绝不回显私钥;地址仅显示前6位+后4位
  11. 操作后提示:若未配置钱包,操作完成后建议用户“设置钱包”
  12. 交易成功后,提供区块浏览器链接:Ethereum链为
    https://etherscan.io/tx/{hash}
    ,Base链为
    https://basescan.org/tx/{hash}
    ,Optimism链为
    https://optimistic.etherscan.io/tx/{hash}
    ,Arbitrum链为
    https://arbiscan.io/tx/{hash}
  13. 实用链接:相关场景下,引导用户访问Bifrost vETH页面Bifrost应用

Security

安全注意事项

  1. Private keys are opt-in only — default outputs unsigned tx data
  2. Explicit CONFIRM for every write operation
  3. Validate amounts against balance and protocol limits
  4. Recommend dedicated wallet with limited funds for agent-side signing
  1. 私钥为可选配置 — 默认输出未签名的交易数据
  2. 所有写入操作均需明确输入CONFIRM确认
  3. 验证金额是否符合余额及协议限制
  4. 建议使用专用钱包且仅存入有限资金用于代理端签名

Error Handling

错误处理

ErrorUser Message
EthNotSent()
(0x8689d991)
"No ETH included. Please specify the amount."
EthTransferFailed()
"ETH transfer failed. Try claiming as WETH with withdrawComplete()."
ZeroWithdrawAmount()
(0xd6d9e665)
"No claimable ETH. Your redemption may still be processing."
ERC4626ExceededMaxRedeem
(0xb94abeec)
"Redeem exceeds your maximum. Check balance."
Pausable: paused
"VETH contract is paused. Try again later."
Insufficient ETH"Insufficient ETH. Balance: {bal}, Needed: {amount + gas}."
Insufficient vETH"Insufficient vETH. Balance: {bal}, Requested: {amount}."
Max withdraw count exceeded"Too many pending redemptions. Claim existing ones first."
RPC failure"Unable to connect. Retrying with backup endpoint..."
错误类型用户提示信息
EthNotSent()
(0x8689d991)
"未包含ETH,请指定质押金额。"
EthTransferFailed()
"ETH转账失败,请尝试使用withdrawComplete()领取WETH。"
ZeroWithdrawAmount()
(0xd6d9e665)
"无可领取的ETH,您的赎回申请可能仍在处理中。"
ERC4626ExceededMaxRedeem
(0xb94abeec)
"赎回金额超过您的最大限额,请检查余额。"
Pausable: paused
"vETH合约已暂停,请稍后重试。"
ETH余额不足"ETH余额不足。当前余额:{bal},所需金额:{amount + gas}。"
vETH余额不足"vETH余额不足。当前余额:{bal},申请金额:{amount}。"
待处理赎回数量过多"待处理赎回数量过多,请先领取已完成的赎回资产。"
RPC调用失败"无法连接至网络,正在尝试使用备用端点..."

Notes

注意事项

  1. depositWithETH()
    wraps ETH → WETH internally via
    WETH.deposit()
    . No ERC-20 approval needed. For direct WETH deposits, use
    deposit(uint256,address)
    instead (requires WETH approval)
  2. withdrawCompleteToETH()
    internally calls
    withdrawCompleteTo(address(this))
    to receive WETH, then unwraps to ETH via
    WETH.withdraw()
    , then sends ETH to caller. If ETH transfer fails, use
    withdrawComplete()
    to receive WETH instead
  3. Redemption is NOT instant —
    redeem()
    /
    withdraw()
    add entries to the withdrawal queue, processed in batches via Bifrost cross-chain mechanism
  4. All write functions are protected by
    whenNotPaused
    and
    nonReentrant
    (ReentrancyGuardUpgradeable)
  5. Gas estimates are approximate; use
    cast estimate
    for accuracy
  1. depositWithETH()
    通过内部调用
    WETH.deposit()
    将ETH包装为WETH,无需ERC-20授权。若需直接存入WETH,请使用
    deposit(uint256,address)
    (需预先授权WETH)
  2. withdrawCompleteToETH()
    内部先调用
    withdrawCompleteTo(address(this))
    领取WETH,再通过
    WETH.withdraw()
    解包为ETH,最后将ETH发送给调用者。若ETH转账失败,可使用
    withdrawComplete()
    领取WETH
  3. 赎回并非即时到账 —
    redeem()
    /
    withdraw()
    会将申请加入赎回队列,通过Bifrost跨链机制批量处理
  4. 所有写入函数均受
    whenNotPaused
    nonReentrant
    (ReentrancyGuardUpgradeable)保护
  5. Gas预估为近似值,若需精确值可使用
    cast estimate