Skip to content
Business logic Audit finding Intermediate

Founder has to double-stake during migration with the initial LP locked in the old veToken

The migration function creates new token and veToken contracts but does not unlock the founder's original LP tokens from the old veToken, which remain locked for 10 years. Founders must therefore provide additional virtual tokens to migrate, leaving their original capital stuck in the obsolete contract.

oakcobalt Follow with gkrastenov

Originally disclosed on Code4rena

Submitted by oakcobalt, also found by gkrastenov

During the migration process implemented in AgentMigrator.sol, founders face a double-staking problem where their original LP tokens remain locked in the old AgentVeToken contract while they must provide additional virtual tokens for the migration to the new system.

Vulnerabilities

The AgentMigrator.migrateAgent() function creates new token, LP, veToken, and DAO contracts but fails to provide a mechanism to migrate the founder’s locked tokens from the old veToken contract:

function migrateAgent(
    uint256 id,
    string memory name,
    string memory symbol,
    bool canStake
) external noReentrant {
    // ...
    // Deploy Agent token & LP
    address token = _createNewAgentToken(name, symbol);
    address lp = IAgentToken(token).liquidityPools()[0];
    IERC20(_assetToken).transferFrom(founder, token, initialAmount);
    IAgentToken(token).addInitialLiquidity(address(this));

    // Deploy AgentVeToken
    address veToken = _createNewAgentVeToken(
        string.concat("Staked ", name),
        string.concat("s", symbol),
        lp,
        founder,
        canStake
    );

    // ...
    _nft.migrateVirtual(id, dao, token, lp, veToken);

    // Stake LP in new veToken
    IERC20(lp).approve(veToken, type(uint256).max);
    IAgentVeToken(veToken).stake(
        IERC20(lp).balanceOf(address(this)),
        founder,
        founder
    );
    // ...
}

https://github.com/code-423n4/2025-04-virtuals-protocol/blob/28e93273daec5a9c73c438e216dde04c084be452/contracts/virtualPersona/AgentMigrator.sol#L107-L131

Meanwhile, the original LP tokens remain locked in the old veToken due to the withdrawal restriction in AgentVeToken.withdraw():

function withdraw(uint256 amount) public noReentrant {
    address sender = _msgSender();
    require(balanceOf(sender) >= amount, "Insufficient balance");

    if ((sender == founder) && ((balanceOf(sender) - amount) < initialLock)) {
        require(block.timestamp >= matureAt, "Not mature yet");
    }
    // ...
}

https://github.com/code-423n4/2025-04-virtuals-protocol/blob/28e93273daec5a9c73c438e216dde04c084be452/contracts/virtualPersona/AgentVeToken.sol#L99-L100

Impact

  • Founders must provide duplicate capital (virtual tokens) during migration, as they cannot retrieve their original LP tokens to retrieve originally deposited virtual tokens in the old uniswap pair.
  • Original LP tokens remain locked in obsolete contracts for 10 years. Due to the bonding curve graduation requirements and genesis requirements, the locked virtual token values are significant (roughly 35000 virtual tokens (35000 usd) required to graduate a bonding curve pair).

Recommended mitigation steps

  1. Modify the AgentMigrator contract to include a mechanism to unlock LP tokens from the old veToken during migration.
  2. Add a privileged function to the AgentVeToken contract that allows the founder to withdraw their locked tokens in case of a migration.

Proof of Concept

  1. Founder deployed initial bonding curve.
  2. It requires roughly 35000 virtual tokens (35000 usd) to graduate and deploy agent tokens. At graduation, these are converted to LP tokens and locked in the original veToken, with the founder being unable to withdraw the initialLock amount.
  3. The protocol team deploys new versions of the Agent contracts and encourages migration.
  4. The founder attempts to migrate their Agent using AgentMigrator.migrateAgent().
  5. The founder must transfer additional virtual tokens to the new token contract to create new LP (assuming around the same amount of virtual tokens are required).
  6. New LP tokens are staked in the new veToken, but the original LP tokens (worth ~35,000 usd) remain locked in the old veToken.
  7. The founder now has capital locked in two places - the new veToken (functional) and the old veToken (obsolete).
  8. The founder cannot withdraw their original locked LP until after 10 years from the original deployment date.

The original report as published on Code4rena, by oakcobalt. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the migration function lacks any mechanism to release the founder's initialLock from the old veToken contract before requiring new capital for the new one.

Impact

Founders must provide duplicate capital during migration, and their original LP tokens (worth roughly 35,000 USD) remain locked in the obsolete contract for 10 years.

What the attacker needed

Founder has graduated a bonding curve; protocol team deploys new contracts; founder initiates migration

The fix

The AgentMigrator should include a mechanism to unlock LP tokens from the old veToken during migration, or AgentVeToken should add a privileged function allowing the founder to withdraw locked tokens in case of migration.

How it was found

  1. Founder deploys initial bonding curve.
  2. Founder graduates the bonding curve, converting virtual tokens to LP tokens locked in the original veToken.
  3. Protocol team deploys new Agent contracts and encourages migration.
  4. Founder calls migrateAgent() to migrate their Agent.
  5. Founder must transfer additional virtual tokens to create new LP.
  6. New LP is staked in the new veToken, but original LP remains locked in the old veToken.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

When a project upgrades its contracts, users often need to move their funds to the new version. Here, the founder's original deposit is locked in the old contract by a rule that prevents withdrawal for 10 years, so they have to pay again to use the new system. This means their money is stuck in two places at once.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by oakcobalt

View all

50 more disclosed reports, best first.

More from Virtuals Protocol

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.