Attack entry point
The attack entry point is the Balancer: Vault contract, and the corresponding entry function is the batchSwap function, which internally calls onSwap to perform token swaps. function onSwap( SwapRequest memory swapRequest, uint256[] memory balances, uint256 indexIn, uint256 indexOut ) external override onlyVault(swapRequest.poolId) returns (uint256) { _beforeSwapJoinExit(); _validateIndexes(indexIn, indexOut, _getTotalTokens()); uint256[] memory scalingFactors = _scalingFactors(); return swapRequest.kind == IVault.SwapKind.GIVEN_IN ? _swapGivenIn(swapRequest, balances, indexIn, indexOut, scalingFactors) : _swapGivenOut(swapRequest, balances, indexIn, indexOut, scalingFactors); } From the function parameters and restrictions, we can obtain several pieces of information: Attackers need to call this function through Vault; they cannot call it directly. The function internally calls _scalingFactors() to obtain scaling factors for scaling operations. Scaling operations are handled in either _swapGivenIn または _swapGivenOut . Attack Pattern Analysis
BPT Price Calculation Method In Balancer’s stable pool model, the price of BPT is an important reference point, which determines how many BPTs a user receives and how many assets are received per BPT. BPT Price = D / totalSupply Where D = invariant, from Curve's StableSwap model. In the pool exchange calculation: // StableMath._calcOutGivenIn function _calcOutGivenIn( uint256 amplificationParameter, uint256[] memory balances, uint256 tokenIndexIn, uint256 tokenIndexOut, uint256 tokenAmountIn, uint256 invariant ) internal pure returns (uint256) { /********************************************************************************************************** // outGivenIn token x for y - polynomial equation to solve // // ay = amount out to calculate // // by = balance token out // // y = by - ay (finalBalanceOut) // // D = invariant DD^(n+1) // // A = amplification coefficient y^2 + ( S + ---------- - D) * y - ------------- = 0 // // n = number of tokens (A * n^n) A * n^2n * P // // S = sum of final balances but y // // P = product of final balances but y // **************************************************************************************************************/ // Amount out, so we round down overall. balances[tokenIndexIn] = balances[tokenIndexIn].add(tokenAmountIn); uint256 finalBalanceOut = _getTokenBalanceGivenInvariantAndAllOtherBalances( amplificationParameter, balances invariant, // using the old D tokenIndexOut ); // No need to use checked arithmetic since `tokenAmountIn` was actually added to the same balance right before // calling `_getTokenBalanceGivenInvariantAndAllOtherBalances` which doesn't alter the balances array. balances[tokenIndexIn] = balances[tokenIndexIn] - tokenAmountIn; return balances[tokenIndexOut].sub(finalBalanceOut).sub(1); } The portion that serves as the benchmark for BPT prices は a constant value D ; that is, manipulating BPT prices requires manipulating D. Let’s analyze the calculation process of D: // StableMath._calculateInvariant function _calculateInvariant(uint256 amplificationParameter, uint256[] memory balances) internal pure returns (uint256) { /********************************************************************************************** // invariant // // D = invariant D^(n+1) // // A = amplification coefficient A n^n S + D = AD n^n + ----------- // // S = sum of balances n^n P // // P = product of balances // // n = number of tokens // **********************************************************************************************/ // Always round down, to match Vyper's arithmetic (which always truncates). uint256 sum = 0; // S in the Curve version uint256 numTokens = balances.length; for (uint256 i = 0; i prevInvariant) { if (invariant - prevInvariant In the code above, the calculation of D depends on the scaled balances array . This means that an operation is needed to change the precision of these balances, leading to an error in the calculation of D. The root cause of accuracy loss // BaseGeneralPool._swapGivenIn function _swapGivenIn( SwapRequest memory swapRequest, uint256[] memory balances, uint256 indexIn, uint256 indexOut, uint256[] memory scalingFactors ) internal virtual returns (uint256) { // Fees are subtracted before scaling, to reduce the complexity of the rounding direction analysis. swapRequest.amount = _subtractSwapFeeAmount(swapRequest.amount); _upscaleArray(balances, scalingFactors); // Key: Upscale the balance swapRequest.amount = _upscale(swapRequest.amount, scalingFactors[indexIn]); uint256 amountOut = _onSwapGivenIn(swapRequest, balances, indexIn, indexOut); // amountOut tokens are exiting the Pool, so we round down. return _downscaleDown(amountOut, scalingFactors[indexOut]); } Scaling operation: // ScalingHelpers.sol function _upscaleArray(uint256[] memory amounts, uint256[] memory scalingFactors) pure { uint256 length = amounts.length; InputHelpers.ensureInputLengthMatch(length, scalingFactors.length); for (uint256 i = 0; i As shown above, when using _upscaleArray , if the balance is very small (e.g., 8-9 wei), the down-rounding of mulDown will result in a significant loss of precision. Attack process details Phase 1: Adjust to rounding boundary Attacker: BPT → cbETH Objective: To adjust the cbETH balance to the rounding boundary (e.g., ending in 9). Assume the initial state: cbETH Balance (Original): ...00000000009 wei (last digit is 9) Phase 2: Triggering Precision Loss (Core Vulnerability) Attacker: wstETH (8 wei) → cbETH Before scaling: cbETH Balance: ...000000000009 wei wstETH input: 8 wei Execute _upscaleArray: // cbETH scaling: 9 * 1e18 / 1e18 = 9 // But if the actual value is 9.5, it becomes 9 due to rounding down. scaled_cbETH = floor(9.5) = 9 Accuracy loss: 0.5 / 9.5 = 5.3% relative error calculation exchange: Input (wstETH): 8 wei (scaled) Balance (cbETH): 9 (Incorrect, it should be 9.5) Because cbETH is undervalued, the calculated new balance will also be undervalued, leading to an error in the D calculation. D_original = f(9.5, ...) D_new = f(9, ...) Phase 3: Profiting from the depressed BPT price Attacker: Underlying asset → BPT at this time: D_new = D_original - ΔD BPT price = D_new / totalSupply The attacker above used Batch Swap to perform multiple swaps within a single transaction: First exchange: BPT → cbETH (adjust balance) Second swap: wstETH (8) → cbETH (triggers precision loss) Third exchange: Underlying assets → BPT (profit) These swaps are all within the same batch swap transaction and share the same balance state , but _upscaleArray is called to modify the balances array for each swap. The lack of a callback mechanism The main process is started by Vault, so how does this lead to the accumulation of precision loss? The answer lies in the passing mechanism of the balances array . // The logic function when Vault calls onSwap: _processGeneralPoolSwapRequest(IPoolSwapStructs.SwapRequest memory request, IGeneralPool pool) private returns (uint256 amountCalculated) { bytes32 tokenInBalance; bytes32 tokenOutBalance; // We access both token indexes without checking existence, because we will do it manually immediately after. EnumerableMap.IERC20ToBytes32Map storage poolBalances = _generalPoolsBalances[request.poolId]; uint256 indexIn = poolBalances.unchecked_indexOf(request.tokenIn); uint256 indexOut = poolBalances.unchecked_indexOf(request.tokenOut); if (indexIn == 0 || indexOut == 0) { // The tokens might not be registered because the Pool itself is not registered. We check this to provide a // more accurate revert reason. _ensureRegisteredPool(request.poolId); _revert(Errors.TOKEN_NOT_REGISTERED); } // EnumerableMap stores indices *plus one* to use the zero index as a sentinel value - because these are valid, We can undo this. indexIn -= 1; indexOut -= 1; uint256 tokenAmount = poolBalances.length(); uint256[] memory currentBalances = new uint256[](tokenAmount); request.lastChangeBlock = 0; for (uint256 i = 0; i Analyzing the code above, although Vault creates a new currentBalances array every time onSwap is called, in Batch Swap : After the first exchange, the balance is updated (but the updated value may be inaccurate due to loss of precision). The second swap continues the calculation based on the result of the first swap. Accumulated loss of precision eventually leads to a significant decrease in the invariant value D. Key issues: // BaseGeneralPool._swapGivenIn function _swapGivenIn( SwapRequest memory swapRequest, uint256[] memory balances, uint256 indexIn, uint256 indexOut, uint256[] memory scalingFactors ) internal virtual returns (uint256) { // Fees are subtracted before scaling, to reduce the complexity of the rounding direction analysis. swapRequest.amount = _subtractSwapFeeAmount(swapRequest.amount); _upscaleArray(balances, scalingFactors); // Modify the array in place. swapRequest.amount = _upscale(swapRequest.amount, scalingFactors[indexIn]); uint256 amountOut = _onSwapGivenIn(swapRequest, balances, indexIn, indexOut); // amountOut tokens are exiting the Pool, so we round down. return _downscaleDown(amountOut, scalingFactors[indexOut]); } // Although Vault passes in a new array each time, but: // 1. If the balance is very small (8-9 wei), the precision loss during scaling is significant. // 2. In Batch Swap, subsequent swaps continue calculations based on the balance that has already lost precision. // 3. It was not verified whether the change in the invariant value D was within a reasonable range. 要約する
The reasons for Balancer's attack can be summarized as follows: 1. Scaling function uses rounding down : _upscaleArray 用途 mulDown for scaling, which will produce a significant loss of relative precision when the balance is very small (such as 8-9 wei). 2. Invariant value calculation is sensitive to precision : The calculation of the invariant value D depends on the scaled balances array, and the precision loss will be directly passed to the calculation of D, making D smaller. 3. Lack of verification of changes in invariant values : During the exchange process, it was not verified whether the changes in the invariant value D were within a reasonable range, which allowed attackers to repeatedly exploit the loss of precision to lower the price of BPT. 4. Accumulated precision loss in batch swap : In the same batch swap, the precision loss from multiple swaps will accumulate and eventually amplify into huge financial losses. These two issues—precision loss and lack of validation—combined with the attacker's careful design of boundary conditions, resulted in this loss. この記事はインターネットから得たものです。 Balancer hacked, vulnerability analysisRecommended Articles Related: BitMart Launches Pre-Market Trading, with Monad (MON) as the First Project Launched To further enrich its trading product portfolio and enhance user engagement and asset allocation flexibility, BitMart has officially launched a new feature: pre-market trading . This innovative mechanism provides users with the opportunity to invest in projects before their official launch, helping them capture early value more efficiently and gain direct access to high-quality assets. Pre-market trading: an innovative pre-release token trading mechanism Pre-market trading is an innovative financial tool launched by BitMart based on a staking mechanism. Users can mint PreTokens by staking USDT and trade them freely in a dedicated pre-market spot market. The core logic of this model is that before the project token is officially launched, PreToken provides users with a channel for early participation, thereby achieving pre-positioning and price discovery of potential assets. Key features… #分析# 交換#トークン© 版权声明配列 上一篇 The market has crashed, but you still have a chance to win it back. 下一篇 Tracing the Decoupling of $XUSD: Balancer Vulnerability and the Butterfly Effect of DeFi Leverage 相关文章 OTC trading outside the spotlight: interpreting the alternative games of crypto VCs 6086cf14eb90bc67ca4fc62b 37,280 Web3を「日常」に:OKX Web3の “次のフェーズ ”をザックが解説’ 6086cf14eb90bc67ca4fc62b 8,038 Odaily exclusive interview with Jarsy: How does Robinhood in the Pre-IPO field break the private equity investment thres 6086cf14eb90bc67ca4fc62b 26,823 1 In-Depth Analysis of the Crypto Compensation Report: Huh? These Guys Earn That Much? 6086cf14eb90bc67ca4fc62b 17,835 1 Scams of using celebrity Xs account to issue coins are frequent. Has the hype of celebrity meme coins come to an end? 6086cf14eb90bc67ca4fc62b 36,143 1 24H Hot Coins and News | The Trump family denies any connection with Trump Wallet; pump.fun plans to sell tokens for $4 6086cf14eb90bc67ca4fc62b 30,573 コメントはありません コメントを残すにはログインが必要です! すぐにログイン コメントはありません... Bee.com 世界最大の Web3 ポータル パートナー コインカープ バイナンス コインマーケットキャップ CoinGecko コインライブ 鎧 Bee Network APP をダウンロードして、Web3 の旅を始めましょう 白書 役割 よくある質問 © 2021-2026.無断複写・転載を禁じます。. プライバシーポリシー | 利用規約 Bee Networkアプリをダウンロード そしてWeb3の旅を始めましょう 世界最大のWeb3ポータル パートナー CoinCarp Binance CoinMarketCap CoinGecko Coinlive Armors 白書 役割 よくある質問 © 2021-2026.無断複写・転載を禁じます。. プライバシーポリシー | 利用規約 検索 検索インサイトオンチェーン社交ニュース 热门推荐: エアドロップハンター データ分析 クリプトセレブリティ トラップディテクタ 日本語 English 繁體中文 简体中文 Tiếng Việt العربية 한국어 Bahasa Indonesia हिन्दी اردو Русский 日本語
智能索引记录
-
2026-03-02 18:07:34
综合导航
成功
标题:Emergency Ambulance Simulator - Play Online For Free
简介:Play Emergency Ambulance Simulator game online for free on Y
-
2026-03-02 10:26:34
综合导航
成功
标题:Босоножки: купить босоножек недорого на RIA.com — Страница 3
简介:Купить босоножек недорого: большой выбор объявлений продам б
-
2026-03-02 21:08:47
综合导航
成功
标题:NVE Corp - Digital Input Isolated Transceivers (IL4xx / IL29xx / IL30xx ...
简介:This is Digital Input Isolated Transceivers (IL4xx / IL29xx
-
2026-03-02 17:01:21
图片素材
成功
标题:幼儿园的作文700字 描写幼儿园的作文 关于幼儿园的作文-作文网
简介:作文网精选关于幼儿园的700字作文,包含幼儿园的作文素材,关于幼儿园的作文题目,以幼儿园为话题的700字作文大全,作文网
-
2026-03-02 10:49:55
综合导航
成功
标题:Windows 10反馈中心开始关注非微软产品的用户体验-驱动人生
简介:微软对 Windows 10 操作系统上的“反馈中心”(Feedback Hub)功能很是重视,且最近将注意力拓展到了非
-
2026-03-02 10:50:55
综合导航
成功
标题:In-depth research report on the privacy coin sector: From the demand for anonymity to the revaluation of value in the er Bee Network
简介:I. Overview of the Privacy Coin Sector Since the birth of
-
2026-03-02 09:57:34
综合导航
成功
标题:Best Practice for Telecom Infrastructure
简介:Optimize telecom infrastructure with best practices for effi
-
2026-03-02 21:08:49
综合导航
成功
标题:å¦ç»è¯_å¦åç»è¯_è¯ç»ç½
简介:è¯ç»ç½å¦ç»è¯é¢é,æä¾å ³äºå¦ç»è¯ç¸å ³è¯è¯,å
-
2026-03-02 10:28:55
图片素材
成功
标题:初二观后感作文 观后感素材 观后感作文题目 观后感作文大全-作文网
简介:作文网优秀初二观后感作文大全,包含初二观后感作文素材,初二观后感作文题目、美文范文,作文网原创名师点评,欢迎投稿!
-
2026-03-02 19:06:05
综合导航
成功
标题:Titanic
简介:Titanic est un film réalisé par James Cameron avec Leonardo
-
2026-03-02 10:26:44
综合导航
成功
标题:GTA5报错ERR_GFX_D3D_INIT初始化失败?完整解决方案-驱动人生
简介:GTA5启动时报错ERR_GFX_D3D_INIT初始化失败怎么办?本文从显卡驱动、DirectX和运行库等角度系统分析
-
2026-03-02 10:40:23
综合导航
成功
标题:BTC’s medium-term trend is weakening; short-term fluctuations cannot mask directional risks Invited Analysis Bee Network
简介:Core Summary: • From a macro technical perspective (see Fig
-
2026-03-02 10:51:27
综合导航
成功
标题:世子征程最新章节_第五十四章 重组神位应运生朦朦胧胧万世清第1页_世子征程免费章节_恋上你看书网
简介:第五十四章 重组神位应运生朦朦胧胧万世清第1页_世子征程_飞羽上将火镰_恋上你看书网
-
2026-03-02 18:08:54
旅游出行
成功
标题:十、黄金甲虫: 蒙塔利欧公国-常冰树林_暗喻幻想ReFantazio全剧情流程全任务攻略-全收集全黄金虫位置-全攻略_3DM单机
简介:《暗喻幻想:ReFantazio》全流程全任务攻略,全收集全黄金虫位置。《暗喻幻想:ReFantazio》主线剧情流程图
-
2026-03-02 17:03:57
综合导航
成功
标题:Dawn Veer Pallas Textiles
简介:Similar to the impression of action within a work of art, th
-
2026-03-02 17:46:01
综合导航
成功
标题:万古仙穹第四季最新章节_万古仙穹第四季小说免费全文阅读_恋上你看书网
简介:天地为棋盘,众生为棋子!不愿做棋子,当为下棋人!棋败,身死道消!棋胜,万寿无疆!一枚古朴的围棋子,带着古海穿越到神洲大地
-
2026-03-02 10:32:53
综合导航
成功
标题:年中销售分析报告-果果圈模板
简介:年中销售分析报告,模板图表多样,不同角度解析数据。模板让销售数据可视化,方便进行数据复盘,欢迎大家下载使用。
-
2026-03-02 21:07:44
综合导航
成功
标题:Kids' Athletic Clothes, Shoes & Gear - Long Sleeves or Belts or Sets or Dresses and Rompers Under Armour
简介:Shop Kids
-
2026-03-02 21:09:53
综合导航
成功
标题:Daily Planet|Litecoin and other projects are customized as memes; Gary Gensler is sued by attorneys general of multiple Bee Network
简介:Headlines Litecoin official post says it is positioned as M
-
2026-03-02 14:06:08
综合导航
成功
标题:高考分数揭晓之后-高考作文
简介:在现实生活或工作学习中,大家都尝试过写作文吧,作文是一种言语活动,具有高度的综合性和创造性。那么你有了解过作文吗?以下是
-
2026-03-02 18:07:09
综合导航
成功
标题:东莞市赢泰通智能装备有限公司
简介:东莞市东莞市赢泰通智能装备有限公司有限公司_东方马达、日本和泉一级代理,专业销售日本东方马达(oriental moto
-
2026-03-02 10:24:36
教育培训
成功
标题:2025年中级注册安全工程师考试报名入口-相关阅读-233网校
简介:本页面提供:“2025年中级注册安全工程师考试报名入口”的相关阅读,包含:报名时间、报名流程、报名费、考试教材、准考证打
-
2026-03-02 14:12:32
综合导航
成功
标题:我要和你双修最新章节_全集TXT最新章节_我要和你双修最新章节_全集TXT小说免费全文阅读_恋上你看书网
简介:又名《亲ài的,我要和你修仙》,李元白一直不知道修炼了多年的混沌诀全名yīnyáng混沌诀,一部双修功法,李元白不知道是
-
2026-03-02 10:28:15
综合导航
成功
标题:プロダクト&テクノロジー PwC Japanグループ
简介:「プロダクト&テクノロジー」は新製品や新サービス、新ビジネスモデルを生み出す「イノベーション」の創出・活性化を支援する専
-
2026-03-02 14:17:31
教育培训
成功
标题:游什么作文四年级
简介:在现实生活或工作学习中,大家都写过作文吧,借助作文人们可以实现文化交流的目的。作文的注意事项有许多,你确定会写吗?下面是
-
2026-03-02 06:26:19
职场办公
成功
标题:梦想的小秘密(2)_800字_作文网
简介:白七七转头一看,是丰盛皇朝的厨房传来的爆炸声!眼尖的杨佳怡看见厨房里还有几名工作人员,杨佳怡连忙说: 快,皇朝里面还有人
-
2026-03-02 21:08:36
综合导航
成功
标题:The Next Phase of RWA: The Return of Productive Assets Bee Network
简介:As of mid-January 2026, according to statistics from rwa.xyz
-
2026-03-02 21:09:14
综合导航
成功
标题:Powell-Peralta Snakes 82A Longboard Wheels - Yellow - 69mm – CCS
简介:Wheel Size:,Wheel Duro:
-
2026-03-02 21:09:00
游戏娱乐
成功
标题:602《暗黑西游》前期如何发展 - 游戏攻略 - 602游戏平台 - 做玩家喜爱、信任的游戏平台!cccS
简介:在暗黑西游这款游戏中,我们玩家在游戏中前期要怎样发展。下面的这篇文章就为我们玩家提供一些参考。一起来看看吧!
-
2026-03-02 18:54:00
综合导航
成功
标题:徐岁宁和洛之鹤第几章结婚最新章节_第3章 宁第1页_徐岁宁和洛之鹤第几章结婚免费章节_恋上你看书网
简介:第3章 宁第1页_徐岁宁和洛之鹤第几章结婚_仅允_恋上你看书网