When the Protocol Pays the Attacker: The Economics of the GoldPesa Hook Exploit

Table of Contents


A liquidity-rebalancing mechanism is meant to keep a market stable when its reserves begin to shift out of balance. In GoldPesa’s case, however, the system appears to have had the opposite effect, using the protocol’s own capital to cover an obligation deliberately created by the attacker.

How was GoldPesa exploited

On 2 October 2026, attackers reportedly exploited GoldPesa’s GPXHooks contract on Base, draining approximately $114,000. According to Defimon’s preliminary on-chain reconstruction, the operation began with a 175,000 USDC loan from Morpho. The attacker used part of the borrowed funds to create a WETH/USDC liquidity position through Uniswap’s PositionManager, while leaving roughly 115,000 USDC outstanding. They then interacted with GoldPesa’s pool in a way that triggered the hook’s automated rebalancing process.

During the rebalance, GoldPesa’s hook burned its protocol-owned liquidity position and released approximately 148,900 USDC. Yet only around 33,900 USDC reportedly returned to the hook. The economic problem lies in what happened to the remaining 115,000 USDC: because the PoolManager settled all outstanding balances within the same transaction, capital belonging to the protocol was effectively used to cover the attacker’s unpaid obligation. The attacker was then able to close the position, withdraw roughly 115,000 USDC, repay the Morpho loan and convert the remaining proceeds into USDT. The funds were later reportedly moved from Base to Solana and then to BNB Chain.

Where the flaw seems to lie

GoldPesa had not released a detailed public post-mortem at the time of reporting, so the precise sequence still relies largely on Defimon’s reconstruction. Even so, the available evidence points to a clear economic weakness: the system successfully settled the transaction, but failed to distinguish between the attacker’s obligations and the protocol’s own capital. As a result, GoldPesa’s liquidity appears to have been used to make up the shortfall.
At its core, the incident appears to involve four separate financial elements: the attacker’s borrowed money, the assets placed into the liquidity position, the amount that position still owed and the liquidity owned by GoldPesa. Although these balances interacted within the same transaction, they did not belong to the same party and should not have been treated as interchangeable. The attacker’s unpaid obligation should have remained connected to their own position. Instead, GoldPesa’s rebalancing funds reportedly became available to cover it.

The redistribution can be expressed as:

Δ𝑊𝐴+Δ𝑊𝑃+𝐹=0

where is the change in the attacker’s wealth, is the change in the protocol’s wealth Δ𝑊𝐴Δ𝑊𝑃and represents borrowing fees, transaction costs and conversion expenses. If the attacker’s gain 𝐹came directly at the protocol’s expense, the rebalance did more than simply move liquidity between positions. It effectively transferred value from GoldPesa to the attacker.

This distinction lies at the heart of the case. A transaction can satisfy the system’s technical settlement rules while still producing an economically unfair outcome. The numbers may balance overall, but only because the wrong party’s money covered the obligation. Based on the reported figures, the difference between the amount released from GoldPesa’s position and the amount returned to its hook was approximately:

𝑅𝑒𝑏𝑎𝑙𝑎𝑛𝑐𝑒 𝑠ℎ𝑜𝑟𝑡𝑓𝑎𝑙𝑙=𝑉𝑟𝑒𝑙𝑒𝑎𝑠𝑒𝑑−𝑉𝑟𝑒𝑡𝑢𝑟𝑛𝑒𝑑
148,900−33,900=115,000 𝑈𝑆𝐷𝐶

This amount closely matches the unpaid balance linked to the attacker’s position. In effect, funds belonging to GoldPesa’s liquidity strategy appear to have covered a private obligation created by the attacker elsewhere in the transaction.

What the economics tell us

Economically, the incident resembles a negative externality. The attacker controlled the position and set the sequence in motion, but did not bear its full cost. Instead, part of the unpaid obligation appears to have fallen on GoldPesa’s liquidity, allowing the attacker to keep the benefit while the protocol and its stakeholders absorbed the loss. The attacker’s net profit can be represented as:

Π𝐴=𝑊−𝐶𝐵−𝐶𝑇−𝐶𝐿

where is the value withdrawn, is the cost of borrowing from Morpho, represents trading 𝑊𝐶𝐵𝐶𝑇and blockchain transaction costs, and represents the cost of converting and moving the 𝐶𝐿proceeds. The protocol’s net loss can be expressed as:

𝐿𝑃=𝐶𝑃−𝑅

where is the amount of protocol capital used to settle the obligation and is any amount 𝐶𝑃𝑅subsequently recovered.

If roughly $115,000 of GoldPesa’s capital was redirected and little was later recovered, the protocol’s final loss would be close to the reported $114,000 once the attacker’s transaction fees and other operating costs are taken into account.

A useful measure of this imbalance is the protocol-subsidy ratio:

𝑃𝑆𝑅=𝑝𝑟𝑜𝑡𝑜𝑐𝑜𝑙 𝑓𝑢𝑛𝑑𝑠 𝑢𝑠𝑒𝑑 𝑡𝑜 𝑠𝑒𝑡𝑡𝑙𝑒 𝑎𝑛 𝑒𝑥𝑡𝑒𝑟𝑛𝑎𝑙 𝑜𝑏𝑙𝑖𝑔𝑎𝑡𝑖𝑜𝑛𝑡𝑜𝑡𝑎𝑙 𝑒𝑥𝑡𝑒𝑟𝑛𝑎𝑙 𝑜𝑏𝑙𝑖𝑔𝑎𝑡𝑖𝑜𝑛

Applying the reported figures gives:

𝑃𝑆𝑅=115,000115,000=1

A ratio of 1 would mean that the protocol’s capital covered the attacker’s entire outstanding obligation. The problem, then, was more serious than an unsuccessful rebalance or a poor trading outcome. GoldPesa’s own liquidity appears to have effectively financed the shortfall in a position controlled by the attacker.

Compounding weakness

The use of borrowed funds made the weakness far more dangerous. Rather than financing the operation entirely with personal capital, the attacker reportedly borrowed 175,000 USDC. The loan did not create the underlying vulnerability, but it reduced the attacker’s own financial exposure and allowed the operation to be carried out on a much larger scale.

This leverage can be illustrated through a capital-amplification ratio:

𝐶𝐴𝑅=𝑝𝑟𝑜𝑡𝑜𝑐𝑜𝑙 𝑐𝑎𝑝𝑖𝑡𝑎𝑙 𝑚𝑜𝑏𝑖𝑙𝑖𝑧𝑒𝑑𝑎𝑡𝑡𝑎𝑐𝑘𝑒𝑟 𝑐𝑎𝑝𝑖𝑡𝑎𝑙 𝑔𝑒𝑛𝑢𝑖𝑛𝑒𝑙𝑦 𝑎𝑡 𝑟𝑖𝑠𝑘

If an attacker exposed $5,000 of personal capital while causing $115,000 of protocol funds to be mobilized, the ratio would be:

𝐶𝐴𝑅=115,0005,000=23

In effect, every dollar of the attacker’s own capital at risk could potentially unlock $23 of protocol funds. The attacker’s actual personal contribution has not been publicly confirmed, but the calculation shows why temporary borrowing can make these attacks so effective. The attacker does not need enough money to finance the entire operation—only a strategy capable of extracting enough value to repay the loan, cover borrowing fees and transaction costs, and leave a profit:

𝑊𝐴≥𝐿𝐹+𝐼𝐹+𝐺

where is the amount withdrawn, is the borrowed principal, is the borrowing fee and 𝑊𝐴𝐿𝐹𝐼𝐹𝐺represents transaction expenses. Anything remaining after these obligations are settled becomes profit. Temporary liquidity therefore transforms a logical weakness into a scalable economic opportunity.

Exposure of risk in a connected system

The case also exposes the risks created when several DeFi systems interact. Morpho provided the temporary funds, the PositionManager created and tracked the position, the PoolManager settled the outstanding balances, and GoldPesa’s hook managed the protocol’s own liquidity. Each component appears to have performed its individual function, yet their interaction produced an unintended transfer of value from the protocol to the attacker.

The resulting exposure can be represented as:

𝑅𝑠𝑦𝑠𝑡𝑒𝑚=𝑖=1𝑛Σ𝑅𝑖+𝑅𝑖𝑛𝑡𝑒𝑟𝑎𝑐𝑡𝑖𝑜𝑛

Here, represents the identifiable risk of each individual component, while captures 𝑅𝑖𝑅𝑖𝑛𝑡𝑒𝑟𝑎𝑐𝑡𝑖𝑜𝑛vulnerabilities that emerge only when those components are combined. Total system risk may therefore exceed the sum of the risks visible in each contract:

𝑅𝑠𝑦𝑠𝑡𝑒𝑚>𝑖=1𝑛Σ𝑅𝑖

The same problem can arise through interconnected balance sheets in traditional finance, where a liability created by one institution may ultimately be passed to another through guarantees, collateral arrangements or settlement rules. In GoldPesa’s case, however, that connection was embedded directly in the smart contracts rather than established through a written financial agreement.

This may also explain why reviewing each contract in isolation is not always sufficient. A hook might perform as intended under normal conditions yet produce a very different economic outcome when another position enters the same settlement process with an outstanding balance. The analysis may therefore need to extend beyond a single function or contract and consider the full sequence through which assets and liabilities move.

Another important feature of the incident is that the attacker may not have needed direct permission to withdraw GoldPesa’s liquidity. Instead, they appear to have created conditions that caused the hook to move protocol-owned funds automatically. This could be understood as a form of indirect economic access: although the attacker could not simply call a treasury-withdrawal function, they may have been able to trigger a separate process that deployed the protocol’s assets in a way that benefited their position.

Further security ramifications

The security question, then, is not simply whether an unauthorized user can withdraw protocol funds directly. Auditors must also consider whether someone can create conditions that cause an automated function to use those funds to cover a private obligation. This is especially important for programmable hooks, where an otherwise ordinary swap may trigger customized rebalancing, fee adjustments or liquidity movements. The user may never gain direct control of the protocol’s capital, but could still control the sequence of events that causes it to move.

Although GoldPesa’s losses were modest compared with the largest DeFi exploits, the mechanism behind the incident has broader implications. Protocol-owned liquidity is generally intended to make a market more stable by deepening its pools, reducing slippage and limiting reliance on costly external incentives. When it works as intended, this can create a positive cycle: deeper liquidity improves trading conditions, attracts more activity and strengthens the market further.

GoldPesa, however, illustrates the other side of this model. If an automated mechanism handles protocol-owned capital incorrectly, the protocol may become the party left absorbing the loss. A resource intended to strengthen liquidity can then have the opposite effect, turning a security incident into the starting point of a negative liquidity cycle.

Liquidity providers may also begin demanding a higher expected return to compensate for the additional uncertainty created by hooks and complex settlement structures:

𝐸(𝑅𝐿𝑃)=𝑅𝑓+π𝑀+π𝑆+π𝐶+π𝐻

In this expression, represents a baseline return, is the market-risk premium, is 𝑅𝑓π𝑀π𝑆compensation for smart-contract risk, represents composability risk and captures the π𝐶π𝐻additional risk associated with programmable hooks.

If liquidity providers begin demanding higher compensation for the additional risk, GoldPesa may have to offer larger incentives simply to attract the same amount of capital. The economic consequences could therefore extend beyond the funds lost in the incident, affecting the protocol through higher financing costs, thinner liquidity, lower trading activity and persistent doubts about whether the mechanism could produce a similar transfer again.

The incident may also affect how investors view hook-based markets more broadly. Some liquidity providers may prefer simpler pools whose accounting is easier to understand, reducing demand for newer and less-tested designs even when they offer genuine improvements. If capital increasingly moves toward a small group of established platforms, liquidity could become more concentrated and failures at those protocols would carry greater consequences for the wider market.

The case may also reshape how protocol-owned liquidity is viewed. The fact that capital belongs to a protocol does not necessarily make it safer than funds supplied by outside investors. Its security still depends on the conditions under which it can be moved, the actions that can trigger those movements and the obligations it may ultimately be used to settle. Users may therefore place greater importance on understanding whether separate positions interact within the same settlement process and whether an automated rebalancing mechanism can become exposed to liabilities created by other participants.

Monitoring may not be enough

For smart-contract security companies, the case suggests that monitoring direct withdrawals alone may miss part of the risk. By the time a visible outflow occurs, value may already have shifted through the protocol’s internal accounting. Monitoring systems may therefore need to track how each transaction changes the financial position of every economically relevant participant:

Δ𝑊𝑖=𝑎𝑠𝑠𝑒𝑡𝑠 𝑟𝑒𝑐𝑒𝑖𝑣𝑒𝑑𝑖−𝑎𝑠𝑠𝑒𝑡𝑠 𝑐𝑜𝑛𝑡𝑟𝑖𝑏𝑢𝑡𝑒𝑑𝑖−𝑙𝑖𝑎𝑏𝑖𝑙𝑖𝑡𝑖𝑒𝑠 𝑐𝑟𝑒𝑎𝑡𝑒𝑑𝑖

A transaction may warrant closer examination when an external address receives a substantial and otherwise unexplained gain while the protocol suffers a closely corresponding loss:

Δ𝑊𝐴>0

and

Δ𝑊𝑃<0

without a legitimate exchange explaining the difference. In GoldPesa’s case, a monitoring system could have compared the proceeds the hook was expected to receive with the amount that actually returned to it. The resulting discrepancy of roughly $115,000 would have been a strong warning that protocol-owned capital may

have been redirected during settlement. A circuit breaker could enforce the condition:

𝑉𝑟𝑒𝑡𝑢𝑟𝑛𝑒𝑑≥𝑉𝑟𝑒𝑙𝑒𝑎𝑠𝑒𝑑−𝐿max 6

where represents the maximum authorized loss or deviation during a rebalance. If the value 𝐿maxreturned to the hook fell below this threshold, the transaction could revert or require additional authorization. Security providers may also need to examine sequences of events rather than assessing each action on its own. A temporary loan, the creation of a liquidity position, or an automated rebalance may each be legitimate in isolation. The pattern becomes far more concerning when a large borrowed position, an unsettled obligation, a movement of hook-controlled liquidity and an immediate withdrawal all appear within the same transaction.

This can be expressed probabilistically:

P(attack | A, B, C, D)P(attack | A) >

Several otherwise ordinary actions may become much more suspicious when they occur together in a particular order. Effective monitoring must therefore consider the full transaction sequence and the financial relationships between its participants, rather than relying only on isolated technical warning signs.
Audits require the same broader perspective. Testing an automated liquidity mechanism under ordinary conditions provides only part of the picture. It is also necessary to examine what happens when a participant uses borrowed funds, leaves part of a position unsettled and then activates a process involving protocol-owned capital. The relevant economic issue is whether that participant can retain the benefit while passing the associated liability to the protocol.

The possible solutions

One practical response would be to map the origin and final use of capital across the transaction. Such a map would identify where each pool of funds came from, which participant created each obligation and whose assets eventually paid it. Defimon’s monitoring model already incorporates elements of this approach by following transaction sequences and changes in individual balances alongside contract-level activity.

The importance of GoldPesa does not rest primarily on the reported size of the loss. Rather, the case may point to a less visible form of financial failure. It did not appear to involve only a false price, compromised key or straightforward withdrawal. According to the available reconstruction, the system may have settled the transaction without keeping the unpaid obligation connected to the position that created it.

Technical settlement alone is therefore an incomplete measure of whether a transaction functioned properly. Liabilities should remain with the parties responsible for them, protocol funds should not cover outside obligations without clear authorization, and transfers of value should remain economically traceable. As DeFi arrangements become more programmable, security analysis will increasingly need to examine their financial outcomes as well as their technical execution. GoldPesa’s mechanism was intended to manage the protocol’s liquidity. Yet the available evidence suggests that it may have allowed an attacker’s private liability to pass onto the protocol’s balance sheet, leaving GoldPesa to bear the resulting loss.

Share:

More Posts

Tell us your security needs