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
);
// ...
}
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");
}
// ...
}
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
- Modify the AgentMigrator contract to include a mechanism to unlock LP tokens from the old
veTokenduring migration. - 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
- Founder deployed initial bonding curve.
- 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
initialLockamount. - The protocol team deploys new versions of the Agent contracts and encourages migration.
- The founder attempts to migrate their Agent using
AgentMigrator.migrateAgent(). - 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).
- New LP tokens are staked in the new
veToken, but the original LP tokens (worth~35,000 usd) remain locked in the oldveToken. - The founder now has capital locked in two places - the new
veToken(functional) and the oldveToken(obsolete). - The founder cannot withdraw their original locked LP until after 10 years from the original deployment date.
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
- Founder deploys initial bonding curve.
- Founder graduates the bonding curve, converting virtual tokens to LP tokens locked in the original veToken.
- Protocol team deploys new Agent contracts and encourages migration.
- Founder calls migrateAgent() to migrate their Agent.
- Founder must transfer additional virtual tokens to create new LP.
- 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.